18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * DVB USB framework
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
68c2ecf20Sopenharmony_ci * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef DVB_USB_H
108c2ecf20Sopenharmony_ci#define DVB_USB_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/usb/input.h>
138c2ecf20Sopenharmony_ci#include <linux/firmware.h>
148c2ecf20Sopenharmony_ci#include <media/rc-core.h>
158c2ecf20Sopenharmony_ci#include <media/media-device.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <media/dvb_frontend.h>
188c2ecf20Sopenharmony_ci#include <media/dvb_demux.h>
198c2ecf20Sopenharmony_ci#include <media/dvb_net.h>
208c2ecf20Sopenharmony_ci#include <media/dmxdev.h>
218c2ecf20Sopenharmony_ci#include <media/dvb-usb-ids.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/*
248c2ecf20Sopenharmony_ci * device file: /dev/dvb/adapter[0-1]/frontend[0-2]
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * |-- device
278c2ecf20Sopenharmony_ci * |   |-- adapter0
288c2ecf20Sopenharmony_ci * |   |   |-- frontend0
298c2ecf20Sopenharmony_ci * |   |   |-- frontend1
308c2ecf20Sopenharmony_ci * |   |   `-- frontend2
318c2ecf20Sopenharmony_ci * |   `-- adapter1
328c2ecf20Sopenharmony_ci * |       |-- frontend0
338c2ecf20Sopenharmony_ci * |       |-- frontend1
348c2ecf20Sopenharmony_ci * |       `-- frontend2
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci *
378c2ecf20Sopenharmony_ci * Commonly used variable names:
388c2ecf20Sopenharmony_ci * d = pointer to device (struct dvb_usb_device *)
398c2ecf20Sopenharmony_ci * adap = pointer to adapter (struct dvb_usb_adapter *)
408c2ecf20Sopenharmony_ci * fe = pointer to frontend (struct dvb_frontend *)
418c2ecf20Sopenharmony_ci *
428c2ecf20Sopenharmony_ci * Use macros defined in that file to resolve needed pointers.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* helper macros for every DVB USB driver use */
468c2ecf20Sopenharmony_ci#define adap_to_d(adap) (container_of(adap, struct dvb_usb_device, \
478c2ecf20Sopenharmony_ci		adapter[adap->id]))
488c2ecf20Sopenharmony_ci#define adap_to_priv(adap) (adap_to_d(adap)->priv)
498c2ecf20Sopenharmony_ci#define fe_to_adap(fe) ((struct dvb_usb_adapter *) ((fe)->dvb->priv))
508c2ecf20Sopenharmony_ci#define fe_to_d(fe) (adap_to_d(fe_to_adap(fe)))
518c2ecf20Sopenharmony_ci#define fe_to_priv(fe) (fe_to_d(fe)->priv)
528c2ecf20Sopenharmony_ci#define d_to_priv(d) (d->priv)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) { \
558c2ecf20Sopenharmony_ci	char *direction; \
568c2ecf20Sopenharmony_ci	if (t == (USB_TYPE_VENDOR | USB_DIR_OUT)) \
578c2ecf20Sopenharmony_ci		direction = ">>>"; \
588c2ecf20Sopenharmony_ci	else \
598c2ecf20Sopenharmony_ci		direction = "<<<"; \
608c2ecf20Sopenharmony_ci	dev_dbg(&udev->dev, "%s: %02x %02x %02x %02x %02x %02x %02x %02x " \
618c2ecf20Sopenharmony_ci			"%s %*ph\n",  __func__, t, r, v & 0xff, v >> 8, \
628c2ecf20Sopenharmony_ci			i & 0xff, i >> 8, l & 0xff, l >> 8, direction, l, b); \
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define DVB_USB_STREAM_BULK(endpoint_, count_, size_) { \
668c2ecf20Sopenharmony_ci	.type = USB_BULK, \
678c2ecf20Sopenharmony_ci	.count = count_, \
688c2ecf20Sopenharmony_ci	.endpoint = endpoint_, \
698c2ecf20Sopenharmony_ci	.u = { \
708c2ecf20Sopenharmony_ci		.bulk = { \
718c2ecf20Sopenharmony_ci			.buffersize = size_, \
728c2ecf20Sopenharmony_ci		} \
738c2ecf20Sopenharmony_ci	} \
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) { \
778c2ecf20Sopenharmony_ci	.type = USB_ISOC, \
788c2ecf20Sopenharmony_ci	.count = count_, \
798c2ecf20Sopenharmony_ci	.endpoint = endpoint_, \
808c2ecf20Sopenharmony_ci	.u = { \
818c2ecf20Sopenharmony_ci		.isoc = { \
828c2ecf20Sopenharmony_ci			.framesperurb = frames_, \
838c2ecf20Sopenharmony_ci			.framesize = size_,\
848c2ecf20Sopenharmony_ci			.interval = interval_, \
858c2ecf20Sopenharmony_ci		} \
868c2ecf20Sopenharmony_ci	} \
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define DVB_USB_DEVICE(vend, prod, props_, name_, rc) \
908c2ecf20Sopenharmony_ci	.match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
918c2ecf20Sopenharmony_ci	.idVendor = (vend), \
928c2ecf20Sopenharmony_ci	.idProduct = (prod), \
938c2ecf20Sopenharmony_ci	.driver_info = (kernel_ulong_t) &((const struct dvb_usb_driver_info) { \
948c2ecf20Sopenharmony_ci		.props = (props_), \
958c2ecf20Sopenharmony_ci		.name = (name_), \
968c2ecf20Sopenharmony_ci		.rc_map = (rc), \
978c2ecf20Sopenharmony_ci	})
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct dvb_usb_device;
1008c2ecf20Sopenharmony_cistruct dvb_usb_adapter;
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/**
1038c2ecf20Sopenharmony_ci * structure for carrying all needed data from the device driver to the general
1048c2ecf20Sopenharmony_ci * dvb usb routines
1058c2ecf20Sopenharmony_ci * @name: device name
1068c2ecf20Sopenharmony_ci * @rc_map: name of rc codes table
1078c2ecf20Sopenharmony_ci * @props: structure containing all device properties
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_cistruct dvb_usb_driver_info {
1108c2ecf20Sopenharmony_ci	const char *name;
1118c2ecf20Sopenharmony_ci	const char *rc_map;
1128c2ecf20Sopenharmony_ci	const struct dvb_usb_device_properties *props;
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/**
1168c2ecf20Sopenharmony_ci * structure for remote controller configuration
1178c2ecf20Sopenharmony_ci * @map_name: name of rc codes table
1188c2ecf20Sopenharmony_ci * @allowed_protos: protocol(s) supported by the driver
1198c2ecf20Sopenharmony_ci * @change_protocol: callback to change protocol
1208c2ecf20Sopenharmony_ci * @query: called to query an event from the device
1218c2ecf20Sopenharmony_ci * @interval: time in ms between two queries
1228c2ecf20Sopenharmony_ci * @driver_type: used to point if a device supports raw mode
1238c2ecf20Sopenharmony_ci * @bulk_mode: device supports bulk mode for rc (disable polling mode)
1248c2ecf20Sopenharmony_ci * @timeout: set to length of last space before raw IR goes idle
1258c2ecf20Sopenharmony_ci */
1268c2ecf20Sopenharmony_cistruct dvb_usb_rc {
1278c2ecf20Sopenharmony_ci	const char *map_name;
1288c2ecf20Sopenharmony_ci	u64 allowed_protos;
1298c2ecf20Sopenharmony_ci	int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
1308c2ecf20Sopenharmony_ci	int (*query) (struct dvb_usb_device *d);
1318c2ecf20Sopenharmony_ci	unsigned int interval;
1328c2ecf20Sopenharmony_ci	enum rc_driver_type driver_type;
1338c2ecf20Sopenharmony_ci	bool bulk_mode;
1348c2ecf20Sopenharmony_ci	int timeout;
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/**
1388c2ecf20Sopenharmony_ci * usb streaming configuration for adapter
1398c2ecf20Sopenharmony_ci * @type: urb type
1408c2ecf20Sopenharmony_ci * @count: count of used urbs
1418c2ecf20Sopenharmony_ci * @endpoint: stream usb endpoint number
1428c2ecf20Sopenharmony_ci */
1438c2ecf20Sopenharmony_cistruct usb_data_stream_properties {
1448c2ecf20Sopenharmony_ci#define USB_BULK  1
1458c2ecf20Sopenharmony_ci#define USB_ISOC  2
1468c2ecf20Sopenharmony_ci	u8 type;
1478c2ecf20Sopenharmony_ci	u8 count;
1488c2ecf20Sopenharmony_ci	u8 endpoint;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	union {
1518c2ecf20Sopenharmony_ci		struct {
1528c2ecf20Sopenharmony_ci			unsigned int buffersize; /* per URB */
1538c2ecf20Sopenharmony_ci		} bulk;
1548c2ecf20Sopenharmony_ci		struct {
1558c2ecf20Sopenharmony_ci			int framesperurb;
1568c2ecf20Sopenharmony_ci			int framesize;
1578c2ecf20Sopenharmony_ci			int interval;
1588c2ecf20Sopenharmony_ci		} isoc;
1598c2ecf20Sopenharmony_ci	} u;
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/**
1638c2ecf20Sopenharmony_ci * properties of dvb usb device adapter
1648c2ecf20Sopenharmony_ci * @caps: adapter capabilities
1658c2ecf20Sopenharmony_ci * @pid_filter_count: pid count of adapter pid-filter
1668c2ecf20Sopenharmony_ci * @pid_filter_ctrl: called to enable/disable pid-filter
1678c2ecf20Sopenharmony_ci * @pid_filter: called to set/unset pid for filtering
1688c2ecf20Sopenharmony_ci * @stream: adapter usb stream configuration
1698c2ecf20Sopenharmony_ci */
1708c2ecf20Sopenharmony_ci#define MAX_NO_OF_FE_PER_ADAP 3
1718c2ecf20Sopenharmony_cistruct dvb_usb_adapter_properties {
1728c2ecf20Sopenharmony_ci#define DVB_USB_ADAP_HAS_PID_FILTER               0x01
1738c2ecf20Sopenharmony_ci#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
1748c2ecf20Sopenharmony_ci#define DVB_USB_ADAP_NEED_PID_FILTERING           0x04
1758c2ecf20Sopenharmony_ci	u8 caps;
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci	u8 pid_filter_count;
1788c2ecf20Sopenharmony_ci	int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
1798c2ecf20Sopenharmony_ci	int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	struct usb_data_stream_properties stream;
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci/**
1858c2ecf20Sopenharmony_ci * struct dvb_usb_device_properties - properties of a dvb-usb-device
1868c2ecf20Sopenharmony_ci * @driver_name: name of the owning driver module
1878c2ecf20Sopenharmony_ci * @owner: owner of the dvb_adapter
1888c2ecf20Sopenharmony_ci * @adapter_nr: values from the DVB_DEFINE_MOD_OPT_ADAPTER_NR() macro
1898c2ecf20Sopenharmony_ci * @bInterfaceNumber: usb interface number driver binds
1908c2ecf20Sopenharmony_ci * @size_of_priv: bytes allocated for the driver private data
1918c2ecf20Sopenharmony_ci * @generic_bulk_ctrl_endpoint: bulk control endpoint number for sent
1928c2ecf20Sopenharmony_ci * @generic_bulk_ctrl_endpoint_response: bulk control endpoint number for
1938c2ecf20Sopenharmony_ci *  receive
1948c2ecf20Sopenharmony_ci * @generic_bulk_ctrl_delay: delay between bulk control sent and receive message
1958c2ecf20Sopenharmony_ci * @probe: like probe on driver model
1968c2ecf20Sopenharmony_ci * @disconnect: like disconnect on driver model
1978c2ecf20Sopenharmony_ci * @identify_state: called to determine the firmware state (cold or warm) and
1988c2ecf20Sopenharmony_ci *  return possible firmware file name to be loaded
1998c2ecf20Sopenharmony_ci * @firmware: name of the firmware file to be loaded
2008c2ecf20Sopenharmony_ci * @download_firmware: called to download the firmware
2018c2ecf20Sopenharmony_ci * @i2c_algo: i2c_algorithm if the device has i2c-adapter
2028c2ecf20Sopenharmony_ci * @num_adapters: dvb usb device adapter count
2038c2ecf20Sopenharmony_ci * @get_adapter_count: called to resolve adapter count
2048c2ecf20Sopenharmony_ci * @adapter: array of all adapter properties of device
2058c2ecf20Sopenharmony_ci * @power_ctrl: called to enable/disable power of the device
2068c2ecf20Sopenharmony_ci * @read_config: called to resolve device configuration
2078c2ecf20Sopenharmony_ci * @read_mac_address: called to resolve adapter mac-address
2088c2ecf20Sopenharmony_ci * @frontend_attach: called to attach the possible frontends
2098c2ecf20Sopenharmony_ci * @frontend_detach: called to detach the possible frontends
2108c2ecf20Sopenharmony_ci * @tuner_attach: called to attach the possible tuners
2118c2ecf20Sopenharmony_ci * @frontend_ctrl: called to power on/off active frontend
2128c2ecf20Sopenharmony_ci * @streaming_ctrl: called to start/stop the usb streaming of adapter
2138c2ecf20Sopenharmony_ci * @init: called after adapters are created in order to finalize device
2148c2ecf20Sopenharmony_ci *  configuration
2158c2ecf20Sopenharmony_ci * @exit: called when driver is unloaded
2168c2ecf20Sopenharmony_ci * @get_rc_config: called to resolve used remote controller configuration
2178c2ecf20Sopenharmony_ci * @get_stream_config: called to resolve input and output stream configuration
2188c2ecf20Sopenharmony_ci *  of the adapter just before streaming is started. input stream is transport
2198c2ecf20Sopenharmony_ci *  stream from the demodulator and output stream is usb stream to host.
2208c2ecf20Sopenharmony_ci */
2218c2ecf20Sopenharmony_ci#define MAX_NO_OF_ADAPTER_PER_DEVICE 2
2228c2ecf20Sopenharmony_cistruct dvb_usb_device_properties {
2238c2ecf20Sopenharmony_ci	const char *driver_name;
2248c2ecf20Sopenharmony_ci	struct module *owner;
2258c2ecf20Sopenharmony_ci	short *adapter_nr;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	u8 bInterfaceNumber;
2288c2ecf20Sopenharmony_ci	unsigned int size_of_priv;
2298c2ecf20Sopenharmony_ci	u8 generic_bulk_ctrl_endpoint;
2308c2ecf20Sopenharmony_ci	u8 generic_bulk_ctrl_endpoint_response;
2318c2ecf20Sopenharmony_ci	unsigned int generic_bulk_ctrl_delay;
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	int (*probe)(struct dvb_usb_device *);
2348c2ecf20Sopenharmony_ci	void (*disconnect)(struct dvb_usb_device *);
2358c2ecf20Sopenharmony_ci#define WARM                  0
2368c2ecf20Sopenharmony_ci#define COLD                  1
2378c2ecf20Sopenharmony_ci	int (*identify_state) (struct dvb_usb_device *, const char **);
2388c2ecf20Sopenharmony_ci	const char *firmware;
2398c2ecf20Sopenharmony_ci#define RECONNECTS_USB        1
2408c2ecf20Sopenharmony_ci	int (*download_firmware) (struct dvb_usb_device *,
2418c2ecf20Sopenharmony_ci			const struct firmware *);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	struct i2c_algorithm *i2c_algo;
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci	unsigned int num_adapters;
2468c2ecf20Sopenharmony_ci	int (*get_adapter_count) (struct dvb_usb_device *);
2478c2ecf20Sopenharmony_ci	struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
2488c2ecf20Sopenharmony_ci	int (*power_ctrl) (struct dvb_usb_device *, int);
2498c2ecf20Sopenharmony_ci	int (*read_config) (struct dvb_usb_device *d);
2508c2ecf20Sopenharmony_ci	int (*read_mac_address) (struct dvb_usb_adapter *, u8 []);
2518c2ecf20Sopenharmony_ci	int (*frontend_attach) (struct dvb_usb_adapter *);
2528c2ecf20Sopenharmony_ci	int (*frontend_detach)(struct dvb_usb_adapter *);
2538c2ecf20Sopenharmony_ci	int (*tuner_attach) (struct dvb_usb_adapter *);
2548c2ecf20Sopenharmony_ci	int (*tuner_detach)(struct dvb_usb_adapter *);
2558c2ecf20Sopenharmony_ci	int (*frontend_ctrl) (struct dvb_frontend *, int);
2568c2ecf20Sopenharmony_ci	int (*streaming_ctrl) (struct dvb_frontend *, int);
2578c2ecf20Sopenharmony_ci	int (*init) (struct dvb_usb_device *);
2588c2ecf20Sopenharmony_ci	void (*exit) (struct dvb_usb_device *);
2598c2ecf20Sopenharmony_ci	int (*get_rc_config) (struct dvb_usb_device *, struct dvb_usb_rc *);
2608c2ecf20Sopenharmony_ci#define DVB_USB_FE_TS_TYPE_188        0
2618c2ecf20Sopenharmony_ci#define DVB_USB_FE_TS_TYPE_204        1
2628c2ecf20Sopenharmony_ci#define DVB_USB_FE_TS_TYPE_RAW        2
2638c2ecf20Sopenharmony_ci	int (*get_stream_config) (struct dvb_frontend *,  u8 *,
2648c2ecf20Sopenharmony_ci			struct usb_data_stream_properties *);
2658c2ecf20Sopenharmony_ci};
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/**
2688c2ecf20Sopenharmony_ci * generic object of an usb stream
2698c2ecf20Sopenharmony_ci * @buf_num: number of buffer allocated
2708c2ecf20Sopenharmony_ci * @buf_size: size of each buffer in buf_list
2718c2ecf20Sopenharmony_ci * @buf_list: array containing all allocate buffers for streaming
2728c2ecf20Sopenharmony_ci * @dma_addr: list of dma_addr_t for each buffer in buf_list
2738c2ecf20Sopenharmony_ci *
2748c2ecf20Sopenharmony_ci * @urbs_initialized: number of URBs initialized
2758c2ecf20Sopenharmony_ci * @urbs_submitted: number of URBs submitted
2768c2ecf20Sopenharmony_ci */
2778c2ecf20Sopenharmony_ci#define MAX_NO_URBS_FOR_DATA_STREAM 10
2788c2ecf20Sopenharmony_cistruct usb_data_stream {
2798c2ecf20Sopenharmony_ci	struct usb_device *udev;
2808c2ecf20Sopenharmony_ci	struct usb_data_stream_properties props;
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define USB_STATE_INIT    0x00
2838c2ecf20Sopenharmony_ci#define USB_STATE_URB_BUF 0x01
2848c2ecf20Sopenharmony_ci	u8 state;
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	void (*complete) (struct usb_data_stream *, u8 *, size_t);
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	struct urb    *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
2898c2ecf20Sopenharmony_ci	int            buf_num;
2908c2ecf20Sopenharmony_ci	unsigned long  buf_size;
2918c2ecf20Sopenharmony_ci	u8            *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
2928c2ecf20Sopenharmony_ci	dma_addr_t     dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	int urbs_initialized;
2958c2ecf20Sopenharmony_ci	int urbs_submitted;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	void *user_priv;
2988c2ecf20Sopenharmony_ci};
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci/**
3018c2ecf20Sopenharmony_ci * dvb adapter object on dvb usb device
3028c2ecf20Sopenharmony_ci * @props: pointer to adapter properties
3038c2ecf20Sopenharmony_ci * @stream: adapter the usb data stream
3048c2ecf20Sopenharmony_ci * @id: index of this adapter (starting with 0)
3058c2ecf20Sopenharmony_ci * @ts_type: transport stream, input stream, type
3068c2ecf20Sopenharmony_ci * @suspend_resume_active: set when there is ongoing suspend / resume
3078c2ecf20Sopenharmony_ci * @pid_filtering: is hardware pid_filtering used or not
3088c2ecf20Sopenharmony_ci * @feed_count: current feed count
3098c2ecf20Sopenharmony_ci * @max_feed_count: maimum feed count device can handle
3108c2ecf20Sopenharmony_ci * @dvb_adap: adapter dvb_adapter
3118c2ecf20Sopenharmony_ci * @dmxdev: adapter dmxdev
3128c2ecf20Sopenharmony_ci * @demux: adapter software demuxer
3138c2ecf20Sopenharmony_ci * @dvb_net: adapter dvb_net interfaces
3148c2ecf20Sopenharmony_ci * @sync_mutex: mutex used to sync control and streaming of the adapter
3158c2ecf20Sopenharmony_ci * @fe: adapter frontends
3168c2ecf20Sopenharmony_ci * @fe_init: rerouted frontend-init function
3178c2ecf20Sopenharmony_ci * @fe_sleep: rerouted frontend-sleep function
3188c2ecf20Sopenharmony_ci */
3198c2ecf20Sopenharmony_cistruct dvb_usb_adapter {
3208c2ecf20Sopenharmony_ci	const struct dvb_usb_adapter_properties *props;
3218c2ecf20Sopenharmony_ci	struct usb_data_stream stream;
3228c2ecf20Sopenharmony_ci	u8 id;
3238c2ecf20Sopenharmony_ci	u8 ts_type;
3248c2ecf20Sopenharmony_ci	bool suspend_resume_active;
3258c2ecf20Sopenharmony_ci	bool pid_filtering;
3268c2ecf20Sopenharmony_ci	u8 feed_count;
3278c2ecf20Sopenharmony_ci	u8 max_feed_count;
3288c2ecf20Sopenharmony_ci	s8 active_fe;
3298c2ecf20Sopenharmony_ci#define ADAP_INIT                0
3308c2ecf20Sopenharmony_ci#define ADAP_SLEEP               1
3318c2ecf20Sopenharmony_ci#define ADAP_STREAMING           2
3328c2ecf20Sopenharmony_ci	unsigned long state_bits;
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci	/* dvb */
3358c2ecf20Sopenharmony_ci	struct dvb_adapter   dvb_adap;
3368c2ecf20Sopenharmony_ci	struct dmxdev        dmxdev;
3378c2ecf20Sopenharmony_ci	struct dvb_demux     demux;
3388c2ecf20Sopenharmony_ci	struct dvb_net       dvb_net;
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
3418c2ecf20Sopenharmony_ci	int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
3428c2ecf20Sopenharmony_ci	int (*fe_sleep[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
3438c2ecf20Sopenharmony_ci};
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci/**
3468c2ecf20Sopenharmony_ci * dvb usb device object
3478c2ecf20Sopenharmony_ci * @props: device properties
3488c2ecf20Sopenharmony_ci * @name: device name
3498c2ecf20Sopenharmony_ci * @rc_map: name of rc codes table
3508c2ecf20Sopenharmony_ci * @rc_polling_active: set when RC polling is active
3518c2ecf20Sopenharmony_ci * @intf: pointer to the device's struct usb_interface
3528c2ecf20Sopenharmony_ci * @udev: pointer to the device's struct usb_device
3538c2ecf20Sopenharmony_ci * @rc: remote controller configuration
3548c2ecf20Sopenharmony_ci * @powered: indicated whether the device is power or not
3558c2ecf20Sopenharmony_ci * @usb_mutex: mutex for usb control messages
3568c2ecf20Sopenharmony_ci * @i2c_mutex: mutex for i2c-transfers
3578c2ecf20Sopenharmony_ci * @i2c_adap: device's i2c-adapter
3588c2ecf20Sopenharmony_ci * @rc_dev: rc device for the remote control
3598c2ecf20Sopenharmony_ci * @rc_query_work: work for polling remote
3608c2ecf20Sopenharmony_ci * @priv: private data of the actual driver (allocate by dvb usb, size defined
3618c2ecf20Sopenharmony_ci *  in size_of_priv of dvb_usb_properties).
3628c2ecf20Sopenharmony_ci */
3638c2ecf20Sopenharmony_cistruct dvb_usb_device {
3648c2ecf20Sopenharmony_ci	const struct dvb_usb_device_properties *props;
3658c2ecf20Sopenharmony_ci	const char *name;
3668c2ecf20Sopenharmony_ci	const char *rc_map;
3678c2ecf20Sopenharmony_ci	bool rc_polling_active;
3688c2ecf20Sopenharmony_ci	struct usb_interface *intf;
3698c2ecf20Sopenharmony_ci	struct usb_device *udev;
3708c2ecf20Sopenharmony_ci	struct dvb_usb_rc rc;
3718c2ecf20Sopenharmony_ci	int powered;
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	/* locking */
3748c2ecf20Sopenharmony_ci	struct mutex usb_mutex;
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	/* i2c */
3778c2ecf20Sopenharmony_ci	struct mutex i2c_mutex;
3788c2ecf20Sopenharmony_ci	struct i2c_adapter i2c_adap;
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci	struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci	/* remote control */
3838c2ecf20Sopenharmony_ci	struct rc_dev *rc_dev;
3848c2ecf20Sopenharmony_ci	char rc_phys[64];
3858c2ecf20Sopenharmony_ci	struct delayed_work rc_query_work;
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_ci	void *priv;
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ciextern int dvb_usbv2_probe(struct usb_interface *,
3918c2ecf20Sopenharmony_ci		const struct usb_device_id *);
3928c2ecf20Sopenharmony_ciextern void dvb_usbv2_disconnect(struct usb_interface *);
3938c2ecf20Sopenharmony_ciextern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t);
3948c2ecf20Sopenharmony_ciextern int dvb_usbv2_resume(struct usb_interface *);
3958c2ecf20Sopenharmony_ciextern int dvb_usbv2_reset_resume(struct usb_interface *);
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/* the generic read/write method for device control */
3988c2ecf20Sopenharmony_ciextern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16);
3998c2ecf20Sopenharmony_ciextern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16);
4008c2ecf20Sopenharmony_ci/* caller must hold lock when locked versions are called */
4018c2ecf20Sopenharmony_ciextern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *,
4028c2ecf20Sopenharmony_ci		u8 *, u16, u8 *, u16);
4038c2ecf20Sopenharmony_ciextern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16);
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci#endif
406