xref: /OK3568_Linux_fs/kernel/drivers/media/usb/dvb-usb-v2/dvb_usb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * DVB USB framework
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
6*4882a593Smuzhiyun  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef DVB_USB_H
10*4882a593Smuzhiyun #define DVB_USB_H
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <linux/usb/input.h>
13*4882a593Smuzhiyun #include <linux/firmware.h>
14*4882a593Smuzhiyun #include <media/rc-core.h>
15*4882a593Smuzhiyun #include <media/media-device.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include <media/dvb_frontend.h>
18*4882a593Smuzhiyun #include <media/dvb_demux.h>
19*4882a593Smuzhiyun #include <media/dvb_net.h>
20*4882a593Smuzhiyun #include <media/dmxdev.h>
21*4882a593Smuzhiyun #include <media/dvb-usb-ids.h>
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /*
24*4882a593Smuzhiyun  * device file: /dev/dvb/adapter[0-1]/frontend[0-2]
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  * |-- device
27*4882a593Smuzhiyun  * |   |-- adapter0
28*4882a593Smuzhiyun  * |   |   |-- frontend0
29*4882a593Smuzhiyun  * |   |   |-- frontend1
30*4882a593Smuzhiyun  * |   |   `-- frontend2
31*4882a593Smuzhiyun  * |   `-- adapter1
32*4882a593Smuzhiyun  * |       |-- frontend0
33*4882a593Smuzhiyun  * |       |-- frontend1
34*4882a593Smuzhiyun  * |       `-- frontend2
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * Commonly used variable names:
38*4882a593Smuzhiyun  * d = pointer to device (struct dvb_usb_device *)
39*4882a593Smuzhiyun  * adap = pointer to adapter (struct dvb_usb_adapter *)
40*4882a593Smuzhiyun  * fe = pointer to frontend (struct dvb_frontend *)
41*4882a593Smuzhiyun  *
42*4882a593Smuzhiyun  * Use macros defined in that file to resolve needed pointers.
43*4882a593Smuzhiyun  */
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /* helper macros for every DVB USB driver use */
46*4882a593Smuzhiyun #define adap_to_d(adap) (container_of(adap, struct dvb_usb_device, \
47*4882a593Smuzhiyun 		adapter[adap->id]))
48*4882a593Smuzhiyun #define adap_to_priv(adap) (adap_to_d(adap)->priv)
49*4882a593Smuzhiyun #define fe_to_adap(fe) ((struct dvb_usb_adapter *) ((fe)->dvb->priv))
50*4882a593Smuzhiyun #define fe_to_d(fe) (adap_to_d(fe_to_adap(fe)))
51*4882a593Smuzhiyun #define fe_to_priv(fe) (fe_to_d(fe)->priv)
52*4882a593Smuzhiyun #define d_to_priv(d) (d->priv)
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \
55*4882a593Smuzhiyun 	char *direction; \
56*4882a593Smuzhiyun 	if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
57*4882a593Smuzhiyun 		direction = ">>>"; \
58*4882a593Smuzhiyun 	else \
59*4882a593Smuzhiyun 		direction = "<<<"; \
60*4882a593Smuzhiyun 	dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \
61*4882a593Smuzhiyun 			"%s %*ph\n",  __func__, t, r, v & 0xff, v >> 8, \
62*4882a593Smuzhiyun 			i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define DVB_USB_STREAM_BULK(endpoint_, count_, size_) { \
66*4882a593Smuzhiyun 	.type = USB_BULK, \
67*4882a593Smuzhiyun 	.count = count_, \
68*4882a593Smuzhiyun 	.endpoint = endpoint_, \
69*4882a593Smuzhiyun 	.u = { \
70*4882a593Smuzhiyun 		.bulk = { \
71*4882a593Smuzhiyun 			.buffersize = size_, \
72*4882a593Smuzhiyun 		} \
73*4882a593Smuzhiyun 	} \
74*4882a593Smuzhiyun }
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) { \
77*4882a593Smuzhiyun 	.type = USB_ISOC, \
78*4882a593Smuzhiyun 	.count = count_, \
79*4882a593Smuzhiyun 	.endpoint = endpoint_, \
80*4882a593Smuzhiyun 	.u = { \
81*4882a593Smuzhiyun 		.isoc = { \
82*4882a593Smuzhiyun 			.framesperurb = frames_, \
83*4882a593Smuzhiyun 			.framesize = size_,\
84*4882a593Smuzhiyun 			.interval = interval_, \
85*4882a593Smuzhiyun 		} \
86*4882a593Smuzhiyun 	} \
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun #define DVB_USB_DEVICE(vend, prod, props_, name_, rc) \
90*4882a593Smuzhiyun 	.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
91*4882a593Smuzhiyun 	.idVendor = (vend), \
92*4882a593Smuzhiyun 	.idProduct = (prod), \
93*4882a593Smuzhiyun 	.driver_info = (kernel_ulong_t) &((const struct dvb_usb_driver_info) { \
94*4882a593Smuzhiyun 		.props = (props_), \
95*4882a593Smuzhiyun 		.name = (name_), \
96*4882a593Smuzhiyun 		.rc_map = (rc), \
97*4882a593Smuzhiyun 	})
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun struct dvb_usb_device;
100*4882a593Smuzhiyun struct dvb_usb_adapter;
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun /**
103*4882a593Smuzhiyun  * structure for carrying all needed data from the device driver to the general
104*4882a593Smuzhiyun  * dvb usb routines
105*4882a593Smuzhiyun  * @name: device name
106*4882a593Smuzhiyun  * @rc_map: name of rc codes table
107*4882a593Smuzhiyun  * @props: structure containing all device properties
108*4882a593Smuzhiyun  */
109*4882a593Smuzhiyun struct dvb_usb_driver_info {
110*4882a593Smuzhiyun 	const char *name;
111*4882a593Smuzhiyun 	const char *rc_map;
112*4882a593Smuzhiyun 	const struct dvb_usb_device_properties *props;
113*4882a593Smuzhiyun };
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /**
116*4882a593Smuzhiyun  * structure for remote controller configuration
117*4882a593Smuzhiyun  * @map_name: name of rc codes table
118*4882a593Smuzhiyun  * @allowed_protos: protocol(s) supported by the driver
119*4882a593Smuzhiyun  * @change_protocol: callback to change protocol
120*4882a593Smuzhiyun  * @query: called to query an event from the device
121*4882a593Smuzhiyun  * @interval: time in ms between two queries
122*4882a593Smuzhiyun  * @driver_type: used to point if a device supports raw mode
123*4882a593Smuzhiyun  * @bulk_mode: device supports bulk mode for rc (disable polling mode)
124*4882a593Smuzhiyun  * @timeout: set to length of last space before raw IR goes idle
125*4882a593Smuzhiyun  */
126*4882a593Smuzhiyun struct dvb_usb_rc {
127*4882a593Smuzhiyun 	const char *map_name;
128*4882a593Smuzhiyun 	u64 allowed_protos;
129*4882a593Smuzhiyun 	int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
130*4882a593Smuzhiyun 	int (*query) (struct dvb_usb_device *d);
131*4882a593Smuzhiyun 	unsigned int interval;
132*4882a593Smuzhiyun 	enum rc_driver_type driver_type;
133*4882a593Smuzhiyun 	bool bulk_mode;
134*4882a593Smuzhiyun 	int timeout;
135*4882a593Smuzhiyun };
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun /**
138*4882a593Smuzhiyun  * usb streaming configuration for adapter
139*4882a593Smuzhiyun  * @type: urb type
140*4882a593Smuzhiyun  * @count: count of used urbs
141*4882a593Smuzhiyun  * @endpoint: stream usb endpoint number
142*4882a593Smuzhiyun  */
143*4882a593Smuzhiyun struct usb_data_stream_properties {
144*4882a593Smuzhiyun #define USB_BULK  1
145*4882a593Smuzhiyun #define USB_ISOC  2
146*4882a593Smuzhiyun 	u8 type;
147*4882a593Smuzhiyun 	u8 count;
148*4882a593Smuzhiyun 	u8 endpoint;
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun 	union {
151*4882a593Smuzhiyun 		struct {
152*4882a593Smuzhiyun 			unsigned int buffersize; /* per URB */
153*4882a593Smuzhiyun 		} bulk;
154*4882a593Smuzhiyun 		struct {
155*4882a593Smuzhiyun 			int framesperurb;
156*4882a593Smuzhiyun 			int framesize;
157*4882a593Smuzhiyun 			int interval;
158*4882a593Smuzhiyun 		} isoc;
159*4882a593Smuzhiyun 	} u;
160*4882a593Smuzhiyun };
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun /**
163*4882a593Smuzhiyun  * properties of dvb usb device adapter
164*4882a593Smuzhiyun  * @caps: adapter capabilities
165*4882a593Smuzhiyun  * @pid_filter_count: pid count of adapter pid-filter
166*4882a593Smuzhiyun  * @pid_filter_ctrl: called to enable/disable pid-filter
167*4882a593Smuzhiyun  * @pid_filter: called to set/unset pid for filtering
168*4882a593Smuzhiyun  * @stream: adapter usb stream configuration
169*4882a593Smuzhiyun  */
170*4882a593Smuzhiyun #define MAX_NO_OF_FE_PER_ADAP 3
171*4882a593Smuzhiyun struct dvb_usb_adapter_properties {
172*4882a593Smuzhiyun #define DVB_USB_ADAP_HAS_PID_FILTER               0x01
173*4882a593Smuzhiyun #define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
174*4882a593Smuzhiyun #define DVB_USB_ADAP_NEED_PID_FILTERING           0x04
175*4882a593Smuzhiyun 	u8 caps;
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun 	u8 pid_filter_count;
178*4882a593Smuzhiyun 	int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
179*4882a593Smuzhiyun 	int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun 	struct usb_data_stream_properties stream;
182*4882a593Smuzhiyun };
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun /**
185*4882a593Smuzhiyun  * struct dvb_usb_device_properties - properties of a dvb-usb-device
186*4882a593Smuzhiyun  * @driver_name: name of the owning driver module
187*4882a593Smuzhiyun  * @owner: owner of the dvb_adapter
188*4882a593Smuzhiyun  * @adapter_nr: values from the DVB_DEFINE_MOD_OPT_ADAPTER_NR() macro
189*4882a593Smuzhiyun  * @bInterfaceNumber: usb interface number driver binds
190*4882a593Smuzhiyun  * @size_of_priv: bytes allocated for the driver private data
191*4882a593Smuzhiyun  * @generic_bulk_ctrl_endpoint: bulk control endpoint number for sent
192*4882a593Smuzhiyun  * @generic_bulk_ctrl_endpoint_response: bulk control endpoint number for
193*4882a593Smuzhiyun  *  receive
194*4882a593Smuzhiyun  * @generic_bulk_ctrl_delay: delay between bulk control sent and receive message
195*4882a593Smuzhiyun  * @probe: like probe on driver model
196*4882a593Smuzhiyun  * @disconnect: like disconnect on driver model
197*4882a593Smuzhiyun  * @identify_state: called to determine the firmware state (cold or warm) and
198*4882a593Smuzhiyun  *  return possible firmware file name to be loaded
199*4882a593Smuzhiyun  * @firmware: name of the firmware file to be loaded
200*4882a593Smuzhiyun  * @download_firmware: called to download the firmware
201*4882a593Smuzhiyun  * @i2c_algo: i2c_algorithm if the device has i2c-adapter
202*4882a593Smuzhiyun  * @num_adapters: dvb usb device adapter count
203*4882a593Smuzhiyun  * @get_adapter_count: called to resolve adapter count
204*4882a593Smuzhiyun  * @adapter: array of all adapter properties of device
205*4882a593Smuzhiyun  * @power_ctrl: called to enable/disable power of the device
206*4882a593Smuzhiyun  * @read_config: called to resolve device configuration
207*4882a593Smuzhiyun  * @read_mac_address: called to resolve adapter mac-address
208*4882a593Smuzhiyun  * @frontend_attach: called to attach the possible frontends
209*4882a593Smuzhiyun  * @frontend_detach: called to detach the possible frontends
210*4882a593Smuzhiyun  * @tuner_attach: called to attach the possible tuners
211*4882a593Smuzhiyun  * @frontend_ctrl: called to power on/off active frontend
212*4882a593Smuzhiyun  * @streaming_ctrl: called to start/stop the usb streaming of adapter
213*4882a593Smuzhiyun  * @init: called after adapters are created in order to finalize device
214*4882a593Smuzhiyun  *  configuration
215*4882a593Smuzhiyun  * @exit: called when driver is unloaded
216*4882a593Smuzhiyun  * @get_rc_config: called to resolve used remote controller configuration
217*4882a593Smuzhiyun  * @get_stream_config: called to resolve input and output stream configuration
218*4882a593Smuzhiyun  *  of the adapter just before streaming is started. input stream is transport
219*4882a593Smuzhiyun  *  stream from the demodulator and output stream is usb stream to host.
220*4882a593Smuzhiyun  */
221*4882a593Smuzhiyun #define MAX_NO_OF_ADAPTER_PER_DEVICE 2
222*4882a593Smuzhiyun struct dvb_usb_device_properties {
223*4882a593Smuzhiyun 	const char *driver_name;
224*4882a593Smuzhiyun 	struct module *owner;
225*4882a593Smuzhiyun 	short *adapter_nr;
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun 	u8 bInterfaceNumber;
228*4882a593Smuzhiyun 	unsigned int size_of_priv;
229*4882a593Smuzhiyun 	u8 generic_bulk_ctrl_endpoint;
230*4882a593Smuzhiyun 	u8 generic_bulk_ctrl_endpoint_response;
231*4882a593Smuzhiyun 	unsigned int generic_bulk_ctrl_delay;
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun 	int (*probe)(struct dvb_usb_device *);
234*4882a593Smuzhiyun 	void (*disconnect)(struct dvb_usb_device *);
235*4882a593Smuzhiyun #define WARM                  0
236*4882a593Smuzhiyun #define COLD                  1
237*4882a593Smuzhiyun 	int (*identify_state) (struct dvb_usb_device *, const char **);
238*4882a593Smuzhiyun 	const char *firmware;
239*4882a593Smuzhiyun #define RECONNECTS_USB        1
240*4882a593Smuzhiyun 	int (*download_firmware) (struct dvb_usb_device *,
241*4882a593Smuzhiyun 			const struct firmware *);
242*4882a593Smuzhiyun 
243*4882a593Smuzhiyun 	struct i2c_algorithm *i2c_algo;
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun 	unsigned int num_adapters;
246*4882a593Smuzhiyun 	int (*get_adapter_count) (struct dvb_usb_device *);
247*4882a593Smuzhiyun 	struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
248*4882a593Smuzhiyun 	int (*power_ctrl) (struct dvb_usb_device *, int);
249*4882a593Smuzhiyun 	int (*read_config) (struct dvb_usb_device *d);
250*4882a593Smuzhiyun 	int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
251*4882a593Smuzhiyun 	int (*frontend_attach) (struct dvb_usb_adapter *);
252*4882a593Smuzhiyun 	int (*frontend_detach)(struct dvb_usb_adapter *);
253*4882a593Smuzhiyun 	int (*tuner_attach) (struct dvb_usb_adapter *);
254*4882a593Smuzhiyun 	int (*tuner_detach)(struct dvb_usb_adapter *);
255*4882a593Smuzhiyun 	int (*frontend_ctrl) (struct dvb_frontend *, int);
256*4882a593Smuzhiyun 	int (*streaming_ctrl) (struct dvb_frontend *, int);
257*4882a593Smuzhiyun 	int (*init) (struct dvb_usb_device *);
258*4882a593Smuzhiyun 	void (*exit) (struct dvb_usb_device *);
259*4882a593Smuzhiyun 	int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
260*4882a593Smuzhiyun #define DVB_USB_FE_TS_TYPE_188        0
261*4882a593Smuzhiyun #define DVB_USB_FE_TS_TYPE_204        1
262*4882a593Smuzhiyun #define DVB_USB_FE_TS_TYPE_RAW        2
263*4882a593Smuzhiyun 	int (*get_stream_config) (struct dvb_frontend *,  u8 *,
264*4882a593Smuzhiyun 			struct usb_data_stream_properties *);
265*4882a593Smuzhiyun };
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun /**
268*4882a593Smuzhiyun  * generic object of an usb stream
269*4882a593Smuzhiyun  * @buf_num: number of buffer allocated
270*4882a593Smuzhiyun  * @buf_size: size of each buffer in buf_list
271*4882a593Smuzhiyun  * @buf_list: array containing all allocate buffers for streaming
272*4882a593Smuzhiyun  * @dma_addr: list of dma_addr_t for each buffer in buf_list
273*4882a593Smuzhiyun  *
274*4882a593Smuzhiyun  * @urbs_initialized: number of URBs initialized
275*4882a593Smuzhiyun  * @urbs_submitted: number of URBs submitted
276*4882a593Smuzhiyun  */
277*4882a593Smuzhiyun #define MAX_NO_URBS_FOR_DATA_STREAM 10
278*4882a593Smuzhiyun struct usb_data_stream {
279*4882a593Smuzhiyun 	struct usb_device *udev;
280*4882a593Smuzhiyun 	struct usb_data_stream_properties props;
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun #define USB_STATE_INIT    0x00
283*4882a593Smuzhiyun #define USB_STATE_URB_BUF 0x01
284*4882a593Smuzhiyun 	u8 state;
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun 	void (*complete) (struct usb_data_stream *, u8 *, size_t);
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 	struct urb    *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
289*4882a593Smuzhiyun 	int            buf_num;
290*4882a593Smuzhiyun 	unsigned long  buf_size;
291*4882a593Smuzhiyun 	u8            *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
292*4882a593Smuzhiyun 	dma_addr_t     dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
293*4882a593Smuzhiyun 
294*4882a593Smuzhiyun 	int urbs_initialized;
295*4882a593Smuzhiyun 	int urbs_submitted;
296*4882a593Smuzhiyun 
297*4882a593Smuzhiyun 	void *user_priv;
298*4882a593Smuzhiyun };
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun /**
301*4882a593Smuzhiyun  * dvb adapter object on dvb usb device
302*4882a593Smuzhiyun  * @props: pointer to adapter properties
303*4882a593Smuzhiyun  * @stream: adapter the usb data stream
304*4882a593Smuzhiyun  * @id: index of this adapter (starting with 0)
305*4882a593Smuzhiyun  * @ts_type: transport stream, input stream, type
306*4882a593Smuzhiyun  * @suspend_resume_active: set when there is ongoing suspend / resume
307*4882a593Smuzhiyun  * @pid_filtering: is hardware pid_filtering used or not
308*4882a593Smuzhiyun  * @feed_count: current feed count
309*4882a593Smuzhiyun  * @max_feed_count: maimum feed count device can handle
310*4882a593Smuzhiyun  * @dvb_adap: adapter dvb_adapter
311*4882a593Smuzhiyun  * @dmxdev: adapter dmxdev
312*4882a593Smuzhiyun  * @demux: adapter software demuxer
313*4882a593Smuzhiyun  * @dvb_net: adapter dvb_net interfaces
314*4882a593Smuzhiyun  * @sync_mutex: mutex used to sync control and streaming of the adapter
315*4882a593Smuzhiyun  * @fe: adapter frontends
316*4882a593Smuzhiyun  * @fe_init: rerouted frontend-init function
317*4882a593Smuzhiyun  * @fe_sleep: rerouted frontend-sleep function
318*4882a593Smuzhiyun  */
319*4882a593Smuzhiyun struct dvb_usb_adapter {
320*4882a593Smuzhiyun 	const struct dvb_usb_adapter_properties *props;
321*4882a593Smuzhiyun 	struct usb_data_stream stream;
322*4882a593Smuzhiyun 	u8 id;
323*4882a593Smuzhiyun 	u8 ts_type;
324*4882a593Smuzhiyun 	bool suspend_resume_active;
325*4882a593Smuzhiyun 	bool pid_filtering;
326*4882a593Smuzhiyun 	u8 feed_count;
327*4882a593Smuzhiyun 	u8 max_feed_count;
328*4882a593Smuzhiyun 	s8 active_fe;
329*4882a593Smuzhiyun #define ADAP_INIT                0
330*4882a593Smuzhiyun #define ADAP_SLEEP               1
331*4882a593Smuzhiyun #define ADAP_STREAMING           2
332*4882a593Smuzhiyun 	unsigned long state_bits;
333*4882a593Smuzhiyun 
334*4882a593Smuzhiyun 	/* dvb */
335*4882a593Smuzhiyun 	struct dvb_adapter   dvb_adap;
336*4882a593Smuzhiyun 	struct dmxdev        dmxdev;
337*4882a593Smuzhiyun 	struct dvb_demux     demux;
338*4882a593Smuzhiyun 	struct dvb_net       dvb_net;
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun 	struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
341*4882a593Smuzhiyun 	int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
342*4882a593Smuzhiyun 	int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
343*4882a593Smuzhiyun };
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun /**
346*4882a593Smuzhiyun  * dvb usb device object
347*4882a593Smuzhiyun  * @props: device properties
348*4882a593Smuzhiyun  * @name: device name
349*4882a593Smuzhiyun  * @rc_map: name of rc codes table
350*4882a593Smuzhiyun  * @rc_polling_active: set when RC polling is active
351*4882a593Smuzhiyun  * @intf: pointer to the device's struct usb_interface
352*4882a593Smuzhiyun  * @udev: pointer to the device's struct usb_device
353*4882a593Smuzhiyun  * @rc: remote controller configuration
354*4882a593Smuzhiyun  * @powered: indicated whether the device is power or not
355*4882a593Smuzhiyun  * @usb_mutex: mutex for usb control messages
356*4882a593Smuzhiyun  * @i2c_mutex: mutex for i2c-transfers
357*4882a593Smuzhiyun  * @i2c_adap: device's i2c-adapter
358*4882a593Smuzhiyun  * @rc_dev: rc device for the remote control
359*4882a593Smuzhiyun  * @rc_query_work: work for polling remote
360*4882a593Smuzhiyun  * @priv: private data of the actual driver (allocate by dvb usb, size defined
361*4882a593Smuzhiyun  *  in size_of_priv of dvb_usb_properties).
362*4882a593Smuzhiyun  */
363*4882a593Smuzhiyun struct dvb_usb_device {
364*4882a593Smuzhiyun 	const struct dvb_usb_device_properties *props;
365*4882a593Smuzhiyun 	const char *name;
366*4882a593Smuzhiyun 	const char *rc_map;
367*4882a593Smuzhiyun 	bool rc_polling_active;
368*4882a593Smuzhiyun 	struct usb_interface *intf;
369*4882a593Smuzhiyun 	struct usb_device *udev;
370*4882a593Smuzhiyun 	struct dvb_usb_rc rc;
371*4882a593Smuzhiyun 	int powered;
372*4882a593Smuzhiyun 
373*4882a593Smuzhiyun 	/* locking */
374*4882a593Smuzhiyun 	struct mutex usb_mutex;
375*4882a593Smuzhiyun 
376*4882a593Smuzhiyun 	/* i2c */
377*4882a593Smuzhiyun 	struct mutex i2c_mutex;
378*4882a593Smuzhiyun 	struct i2c_adapter i2c_adap;
379*4882a593Smuzhiyun 
380*4882a593Smuzhiyun 	struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
381*4882a593Smuzhiyun 
382*4882a593Smuzhiyun 	/* remote control */
383*4882a593Smuzhiyun 	struct rc_dev *rc_dev;
384*4882a593Smuzhiyun 	char rc_phys[64];
385*4882a593Smuzhiyun 	struct delayed_work rc_query_work;
386*4882a593Smuzhiyun 
387*4882a593Smuzhiyun 	void *priv;
388*4882a593Smuzhiyun };
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun extern int dvb_usbv2_probe(struct usb_interface *,
391*4882a593Smuzhiyun 		const struct usb_device_id *);
392*4882a593Smuzhiyun extern void dvb_usbv2_disconnect(struct usb_interface *);
393*4882a593Smuzhiyun extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t);
394*4882a593Smuzhiyun extern int dvb_usbv2_resume(struct usb_interface *);
395*4882a593Smuzhiyun extern int dvb_usbv2_reset_resume(struct usb_interface *);
396*4882a593Smuzhiyun 
397*4882a593Smuzhiyun /* the generic read/write method for device control */
398*4882a593Smuzhiyun extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16);
399*4882a593Smuzhiyun extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
400*4882a593Smuzhiyun /* caller must hold lock when locked versions are called */
401*4882a593Smuzhiyun extern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *,
402*4882a593Smuzhiyun 		u8 *, u16, u8 *, u16);
403*4882a593Smuzhiyun extern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16);
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun #endif
406