• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define VIDTV_PDEV_NAME "vidtv"
20 
21 #include <linux/i2c.h>
22 #include <linux/platform_device.h>
23 #include <linux/types.h>
24 
25 #include <media/dmxdev.h>
26 #include <media/dvb_demux.h>
27 #include <media/dvb_frontend.h>
28 #include <media/media-device.h>
29 
30 #include "vidtv_mux.h"
31 
32 /**
33  * struct vidtv_dvb - Vidtv bridge state
34  * @pdev: The platform device. Obtained when the bridge is probed.
35  * @fe: The frontends. Obtained when probing the demodulator modules.
36  * @adapter: Represents a DTV adapter. See 'dvb_register_adapter'.
37  * @demux: The demux used by the dvb_dmx_swfilter_packets() call.
38  * @dmx_dev: Represents a demux device.
39  * @dmx_fe: The frontends associated with the demux.
40  * @i2c_adapter: The i2c_adapter associated with the bridge driver.
41  * @i2c_client_demod: The i2c_clients associated with the demodulator modules.
42  * @i2c_client_tuner: The i2c_clients associated with the tuner modules.
43  * @nfeeds: The number of feeds active.
44  * @feed_lock: Protects access to the start/stop stream logic/data.
45  * @streaming: Whether we are streaming now.
46  * @mux: The abstraction responsible for delivering MPEG TS packets to the bridge.
47  * @mdev: The media_device struct for media controller support.
48  */
49 struct vidtv_dvb {
50 	struct platform_device *pdev;
51 	struct dvb_frontend *fe[NUM_FE];
52 	struct dvb_adapter adapter;
53 	struct dvb_demux demux;
54 	struct dmxdev dmx_dev;
55 	struct dmx_frontend dmx_fe[NUM_FE];
56 	struct i2c_adapter i2c_adapter;
57 	struct i2c_client *i2c_client_demod[NUM_FE];
58 	struct i2c_client *i2c_client_tuner[NUM_FE];
59 
60 	u32 nfeeds;
61 	struct mutex feed_lock; /* Protects access to the start/stop stream logic/data. */
62 
63 	bool streaming;
64 
65 	struct vidtv_mux *mux;
66 
67 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
68 	struct media_device mdev;
69 #endif /* CONFIG_MEDIA_CONTROLLER_DVB */
70 };
71 
72 #endif // VIDTV_BRIDG_H
73