1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * The Virtual DTV test driver serves as a reference DVB driver and helps
4  * validate the existing APIs in the media subsystem. It can also aid
5  * developers working on userspace applications.
6  *
7  * When this module is loaded, it will attempt to modprobe 'dvb_vidtv_tuner' and 'dvb_vidtv_demod'.
8  *
9  * Copyright (C) 2020 Daniel W. S. Almeida
10  */
11 
12 #ifndef VIDTV_BRIDGE_H
13 #define VIDTV_BRIDGE_H
14 
15 /*
16  * For now, only one frontend is supported. See vidtv_start_streaming()
17  */
18 #define NUM_FE 1
19 
20 #include <linux/i2c.h>
21 #include <linux/platform_device.h>
22 #include <linux/types.h>
23 
24 #include <media/dmxdev.h>
25 #include <media/dvb_demux.h>
26 #include <media/dvb_frontend.h>
27 
28 #include "vidtv_mux.h"
29 
30 /**
31  * struct vidtv_dvb - Vidtv bridge state
32  * @pdev: The platform device. Obtained when the bridge is probed.
33  * @fe: The frontends. Obtained when probing the demodulator modules.
34  * @adapter: Represents a DTV adapter. See 'dvb_register_adapter'.
35  * @demux: The demux used by the dvb_dmx_swfilter_packets() call.
36  * @dmx_dev: Represents a demux device.
37  * @dmx_fe: The frontends associated with the demux.
38  * @i2c_adapter: The i2c_adapter associated with the bridge driver.
39  * @i2c_client_demod: The i2c_clients associated with the demodulator modules.
40  * @i2c_client_tuner: The i2c_clients associated with the tuner modules.
41  * @nfeeds: The number of feeds active.
42  * @feed_lock: Protects access to the start/stop stream logic/data.
43  * @streaming: Whether we are streaming now.
44  * @mux: The abstraction responsible for delivering MPEG TS packets to the bridge.
45  */
46 struct vidtv_dvb {
47 	struct platform_device *pdev;
48 	struct dvb_frontend *fe[NUM_FE];
49 	struct dvb_adapter adapter;
50 	struct dvb_demux demux;
51 	struct dmxdev dmx_dev;
52 	struct dmx_frontend dmx_fe[NUM_FE];
53 	struct i2c_adapter i2c_adapter;
54 	struct i2c_client *i2c_client_demod[NUM_FE];
55 	struct i2c_client *i2c_client_tuner[NUM_FE];
56 
57 	u32 nfeeds;
58 	struct mutex feed_lock; /* Protects access to the start/stop stream logic/data. */
59 
60 	bool streaming;
61 
62 	struct vidtv_mux *mux;
63 };
64 
65 #endif // VIDTV_BRIDG_H
66