/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * DVB USB framework * * Copyright (C) 2004-6 Patrick Boettcher <[email protected]> * Copyright (C) 2012 Antti Palosaari <[email protected]> */ #ifndef DVB_USB_H #define DVB_USB_H #include <linux/usb/input.h> #include <linux/firmware.h> #include <media/rc-core.h> #include <media/media-device.h> #include <media/dvb_frontend.h> #include <media/dvb_demux.h> #include <media/dvb_net.h> #include <media/dmxdev.h> #include <media/dvb-usb-ids.h> /* * device file: /dev/dvb/adapter[0-1]/frontend[0-2] * * |-- device * | |-- adapter0 * | | |-- frontend0 * | | |-- frontend1 * | | `-- frontend2 * | `-- adapter1 * | |-- frontend0 * | |-- frontend1 * | `-- frontend2 * * * Commonly used variable names: * d = pointer to device (struct dvb_usb_device *) * adap = pointer to adapter (struct dvb_usb_adapter *) * fe = pointer to frontend (struct dvb_frontend *) * * Use macros defined in that file to resolve needed pointers. */ /* helper macros for every DVB USB driver use */ #define adap_to_d(adap) … #define adap_to_priv(adap) … #define fe_to_adap(fe) … #define fe_to_d(fe) … #define fe_to_priv(fe) … #define d_to_priv(d) … #define dvb_usb_dbg_usb_control_msg(udev, r, t, v, i, b, l) … #define DVB_USB_STREAM_BULK(endpoint_, count_, size_) … #define DVB_USB_STREAM_ISOC(endpoint_, count_, frames_, size_, interval_) … #define DVB_USB_DEVICE(vend, prod, props_, name_, rc) … struct dvb_usb_device; struct dvb_usb_adapter; /** * struct dvb_usb_driver_info - structure for carrying all needed data from the * device driver to the general * dvb usb routines * @name: device name * @rc_map: name of rc codes table * @props: structure containing all device properties */ struct dvb_usb_driver_info { … }; /** * struct dvb_usb_rc - structure for remote controller configuration * @map_name: name of rc codes table * @allowed_protos: protocol(s) supported by the driver * @change_protocol: callback to change protocol * @query: called to query an event from the device * @interval: time in ms between two queries * @driver_type: used to point if a device supports raw mode * @bulk_mode: device supports bulk mode for rc (disable polling mode) * @timeout: set to length of last space before raw IR goes idle */ struct dvb_usb_rc { … }; /** * struct usb_data_stream_properties - usb streaming configuration for adapter * @type: urb type * @count: count of used urbs * @endpoint: stream usb endpoint number * @u: union for @bulk and @isoc */ struct usb_data_stream_properties { … }; /** * struct dvb_usb_adapter_properties - properties of dvb usb device adapter * @caps: adapter capabilities * @pid_filter_count: pid count of adapter pid-filter * @pid_filter_ctrl: called to enable/disable pid-filter * @pid_filter: called to set/unset pid for filtering * @stream: adapter usb stream configuration */ struct dvb_usb_adapter_properties { … }; /** * struct dvb_usb_device_properties - properties of a dvb-usb-device * @driver_name: name of the owning driver module * @owner: owner of the dvb_adapter * @adapter_nr: values from the DVB_DEFINE_MOD_OPT_ADAPTER_NR() macro * @bInterfaceNumber: usb interface number driver binds * @size_of_priv: bytes allocated for the driver private data * @generic_bulk_ctrl_endpoint: bulk control endpoint number for sent * @generic_bulk_ctrl_endpoint_response: bulk control endpoint number for * receive * @generic_bulk_ctrl_delay: delay between bulk control sent and receive message * @probe: like probe on driver model * @disconnect: like disconnect on driver model * @identify_state: called to determine the firmware state (cold or warm) and * return possible firmware file name to be loaded * @firmware: name of the firmware file to be loaded * @download_firmware: called to download the firmware * @i2c_algo: i2c_algorithm if the device has i2c-adapter * @num_adapters: dvb usb device adapter count * @get_adapter_count: called to resolve adapter count * @adapter: array of all adapter properties of device * @power_ctrl: called to enable/disable power of the device * @read_config: called to resolve device configuration * @read_mac_address: called to resolve adapter mac-address * @frontend_attach: called to attach the possible frontends * @frontend_detach: called to detach the possible frontends * @tuner_attach: called to attach the possible tuners * @tuner_detach: called to detach the possible tuners * @frontend_ctrl: called to power on/off active frontend * @streaming_ctrl: called to start/stop the usb streaming of adapter * @init: called after adapters are created in order to finalize device * configuration * @exit: called when driver is unloaded * @get_rc_config: called to resolve used remote controller configuration * @get_stream_config: called to resolve input and output stream configuration * of the adapter just before streaming is started. input stream is transport * stream from the demodulator and output stream is usb stream to host. */ struct dvb_usb_device_properties { … }; /** * struct usb_data_stream - generic object of an usb stream * @udev: USB device * @props: properties * @state: state of the data stream * @complete: complete callback * @urb_list: list of URBs * @buf_num: number of buffer allocated * @buf_size: size of each buffer in buf_list * @buf_list: array containing all allocate buffers for streaming * @dma_addr: list of dma_addr_t for each buffer in buf_list * * @urbs_initialized: number of URBs initialized * @urbs_submitted: number of URBs submitted * @user_priv: private pointer */ struct usb_data_stream { … }; /** * struct dvb_usb_adapter - dvb adapter object on dvb usb device * @props: pointer to adapter properties * @stream: adapter the usb data stream * @id: index of this adapter (starting with 0) * @ts_type: transport stream, input stream, type * @suspend_resume_active: set when there is ongoing suspend / resume * @pid_filtering: is hardware pid_filtering used or not * @feed_count: current feed count * @max_feed_count: maimum feed count device can handle * @active_fe: active frontend * @state_bits: status bits * @dvb_adap: adapter dvb_adapter * @dmxdev: adapter dmxdev * @demux: adapter software demuxer * @dvb_net: adapter dvb_net interfaces * @fe: adapter frontends * @fe_init: rerouted frontend-init function * @fe_sleep: rerouted frontend-sleep function */ struct dvb_usb_adapter { … }; /** * struct dvb_usb_device - dvb usb device object * @props: device properties * @name: device name * @rc_map: name of rc codes table * @rc_polling_active: set when RC polling is active * @intf: pointer to the device's struct usb_interface * @udev: pointer to the device's struct usb_device * @rc: remote controller configuration * @powered: indicated whether the device is power or not * @usb_mutex: mutex for usb control messages * @i2c_mutex: mutex for i2c-transfers * @i2c_adap: device's i2c-adapter * @adapter: adapters * @rc_dev: rc device for the remote control * @rc_phys: rc path * @rc_query_work: work for polling remote * @priv: private data of the actual driver (allocate by dvb usb, size defined * in size_of_priv of dvb_usb_properties). */ struct dvb_usb_device { … }; extern int dvb_usbv2_probe(struct usb_interface *, const struct usb_device_id *); extern void dvb_usbv2_disconnect(struct usb_interface *); extern int dvb_usbv2_suspend(struct usb_interface *, pm_message_t); extern int dvb_usbv2_resume(struct usb_interface *); extern int dvb_usbv2_reset_resume(struct usb_interface *); /* the generic read/write method for device control */ extern int dvb_usbv2_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16); extern int dvb_usbv2_generic_write(struct dvb_usb_device *, u8 *, u16); /* caller must hold lock when locked versions are called */ extern int dvb_usbv2_generic_rw_locked(struct dvb_usb_device *, u8 *, u16, u8 *, u16); extern int dvb_usbv2_generic_write_locked(struct dvb_usb_device *, u8 *, u16); #endif