18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * The Virtual DTV test driver serves as a reference DVB driver and helps
48c2ecf20Sopenharmony_ci * validate the existing APIs in the media subsystem. It can also aid
58c2ecf20Sopenharmony_ci * developers working on userspace applications.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tuner' and 'dvb_vidtv_demod'.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (C) 2020 Daniel W. S. Almeida
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef VIDTV_BRIDGE_H
138c2ecf20Sopenharmony_ci#define VIDTV_BRIDGE_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * For now, only one frontend is supported. See vidtv_start_streaming()
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#define NUM_FE 1
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include <linux/i2c.h>
218c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
228c2ecf20Sopenharmony_ci#include <linux/types.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <media/dmxdev.h>
258c2ecf20Sopenharmony_ci#include <media/dvb_demux.h>
268c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "vidtv_mux.h"
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/**
318c2ecf20Sopenharmony_ci * struct vidtv_dvb - Vidtv bridge state
328c2ecf20Sopenharmony_ci * @pdev: The platform device. Obtained when the bridge is probed.
338c2ecf20Sopenharmony_ci * @fe: The frontends. Obtained when probing the demodulator modules.
348c2ecf20Sopenharmony_ci * @adapter: Represents a DTV adapter. See 'dvb_register_adapter'.
358c2ecf20Sopenharmony_ci * @demux: The demux used by the dvb_dmx_swfilter_packets() call.
368c2ecf20Sopenharmony_ci * @dmx_dev: Represents a demux device.
378c2ecf20Sopenharmony_ci * @dmx_fe: The frontends associated with the demux.
388c2ecf20Sopenharmony_ci * @i2c_adapter: The i2c_adapter associated with the bridge driver.
398c2ecf20Sopenharmony_ci * @i2c_client_demod: The i2c_clients associated with the demodulator modules.
408c2ecf20Sopenharmony_ci * @i2c_client_tuner: The i2c_clients associated with the tuner modules.
418c2ecf20Sopenharmony_ci * @nfeeds: The number of feeds active.
428c2ecf20Sopenharmony_ci * @feed_lock: Protects access to the start/stop stream logic/data.
438c2ecf20Sopenharmony_ci * @streaming: Whether we are streaming now.
448c2ecf20Sopenharmony_ci * @mux: The abstraction responsible for delivering MPEG TS packets to the bridge.
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_cistruct vidtv_dvb {
478c2ecf20Sopenharmony_ci	struct platform_device *pdev;
488c2ecf20Sopenharmony_ci	struct dvb_frontend *fe[NUM_FE];
498c2ecf20Sopenharmony_ci	struct dvb_adapter adapter;
508c2ecf20Sopenharmony_ci	struct dvb_demux demux;
518c2ecf20Sopenharmony_ci	struct dmxdev dmx_dev;
528c2ecf20Sopenharmony_ci	struct dmx_frontend dmx_fe[NUM_FE];
538c2ecf20Sopenharmony_ci	struct i2c_adapter i2c_adapter;
548c2ecf20Sopenharmony_ci	struct i2c_client *i2c_client_demod[NUM_FE];
558c2ecf20Sopenharmony_ci	struct i2c_client *i2c_client_tuner[NUM_FE];
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	u32 nfeeds;
588c2ecf20Sopenharmony_ci	struct mutex feed_lock; /* Protects access to the start/stop stream logic/data. */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	bool streaming;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	struct vidtv_mux *mux;
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#endif // VIDTV_BRIDG_H
66