linux/drivers/media/usb/dvb-usb/dvb-usb.h

/* SPDX-License-Identifier: GPL-2.0 */
/* dvb-usb.h is part of the DVB USB library.
 *
 * Copyright (C) 2004-6 Patrick Boettcher ([email protected])
 * see dvb-usb-init.c for copyright information.
 *
 * the headerfile, all dvb-usb-drivers have to include.
 *
 * TODO: clean-up the structures for unused fields and update the comments
 */
#ifndef __DVB_USB_H__
#define __DVB_USB_H__

#include <linux/input.h>
#include <linux/usb.h>
#include <linux/firmware.h>
#include <linux/mutex.h>
#include <media/rc-core.h>

#include <media/dvb_frontend.h>
#include <media/dvb_demux.h>
#include <media/dvb_net.h>
#include <media/dmxdev.h>

#include "dvb-pll.h"

#include <media/dvb-usb-ids.h>

/* debug */
#ifdef CONFIG_DVB_USB_DEBUG
#define dprintk(var, level, args...)

#define debug_dump(b, l, func)
#define DVB_USB_DEBUG_STATUS
#else
#define dprintk
#define debug_dump

#define DVB_USB_DEBUG_STATUS

#endif

/* generic log methods - taken from usb.h */
#ifndef DVB_USB_LOG_PREFIX
 #define DVB_USB_LOG_PREFIX
#endif

#undef err
#define err(format, arg...)
#undef info
#define info(format, arg...)
#undef warn
#define warn(format, arg...)

/**
 * struct dvb_usb_device_description - name and its according USB IDs
 * @name: real name of the box, regardless which DVB USB device class is in use
 * @cold_ids: array of struct usb_device_id which describe the device in
 *  pre-firmware state
 * @warm_ids: array of struct usb_device_id which describe the device in
 *  post-firmware state
 *
 * Each DVB USB device class can have one or more actual devices, this struct
 * assigns a name to it.
 */
struct dvb_usb_device_description {};

static inline u8 rc5_custom(struct rc_map_table *key)
{}

static inline u8 rc5_data(struct rc_map_table *key)
{}

static inline u16 rc5_scan(struct rc_map_table *key)
{}

struct dvb_usb_device;
struct dvb_usb_adapter;
struct usb_data_stream;

/*
 * Properties of USB streaming - TODO this structure should be somewhere else
 * describes the kind of USB transfer used for data-streaming.
 *  (BULK or ISOC)
 */
struct usb_data_stream_properties {};

/**
 * struct dvb_usb_adapter_fe_properties - properties of a dvb-usb-adapter.
 *    A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device.
 * @caps: capabilities of the DVB USB device.
 * @pid_filter_count: number of PID filter position in the optional hardware
 *  PID-filter.
 * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the
 *  device (not URB submitting/killing).
 *  This callback will be called without data URBs being active - data URBs
 *  will be submitted only after streaming_ctrl(1) returns successfully and
 *  they will be killed before streaming_ctrl(0) gets called.
 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
 * @pid_filter: called to set/unset a PID for filtering.
 * @frontend_attach: called to attach the possible frontends (fill fe-field
 *  of struct dvb_usb_device).
 * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
 *  pll_desc and pll_init_buf of struct dvb_usb_device).
 * @stream: configuration of the USB streaming
 * @size_of_priv: size of the priv memory in struct dvb_usb_adapter
 */
struct dvb_usb_adapter_fe_properties {};

#define MAX_NO_OF_FE_PER_ADAP
struct dvb_usb_adapter_properties {};

/**
 * struct dvb_rc_legacy - old properties of remote controller
 * @rc_map_table: a hard-wired array of struct rc_map_table (NULL to disable
 *  remote control handling).
 * @rc_map_size: number of items in @rc_map_table.
 * @rc_query: called to query an event event.
 * @rc_interval: time in ms between two queries.
 */
struct dvb_rc_legacy {};

/**
 * struct dvb_rc - properties of remote controller, using rc-core
 * @rc_codes: name of rc codes table
 * @protocol: type of protocol(s) currently used by the driver
 * @allowed_protos: protocol(s) supported by the driver
 * @driver_type: Used to point if a device supports raw mode
 * @change_protocol: callback to change protocol
 * @module_name: module name
 * @rc_query: called to query an event event.
 * @rc_interval: time in ms between two queries.
 * @bulk_mode: device supports bulk mode for RC (disable polling mode)
 * @scancode_mask: scancode mask
 */
struct dvb_rc {};

/**
 * enum dvb_usb_mode - Specifies if it is using a legacy driver or a new one
 *		       based on rc-core
 * This is initialized/used only inside dvb-usb-remote.c.
 * It shouldn't be set by the drivers.
 *
 * @DVB_RC_LEGACY: legacy driver
 * @DVB_RC_CORE: rc-core driver
 */
enum dvb_usb_mode {};

/**
 * struct dvb_usb_device_properties - properties of a dvb-usb-device
 * @caps: capabilities
 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
 *  download.
 * @firmware: name of the firmware file.
 * @download_firmware: called to download the firmware when the usb_ctrl is
 *  DEVICE_SPECIFIC.
 * @no_reconnect: device doesn't do a reconnect after downloading the firmware,
 *  so do the warm initialization right after it
 *
 * @size_of_priv: how many bytes shall be allocated for the private field
 *  of struct dvb_usb_device.
 * @priv_init: optional callback to initialize the variable that private field
 * of struct dvb_usb_device has pointer to just after it had been allocated and
 * zeroed.
 * @priv_destroy: just like priv_init, only called before deallocating
 * the memory pointed by private field of struct dvb_usb_device.
 *
 * @num_adapters: the number of adapters in @adapters
 * @adapter: the adapters
 * @power_ctrl: called to enable/disable power of the device.
 * @read_mac_address: called to read the MAC address of the device.
 * @identify_state: called to determine the state (cold or warm), when it
 *  is not distinguishable by the USB IDs.
 *
 * @rc: remote controller properties
 *
 * @i2c_algo: i2c_algorithm if the device has I2CoverUSB.
 *
 * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic
 *  endpoint which received control messages with bulk transfers. When this
 *  is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
 *  helper functions.
 *
 * @generic_bulk_ctrl_endpoint_response: some DVB USB devices use a separate
 *  endpoint for responses to control messages sent with bulk transfers via
 *  the generic_bulk_ctrl_endpoint. When this is non-zero, this will be used
 *  instead of the generic_bulk_ctrl_endpoint when reading usb responses in
 *  the dvb_usb_generic_rw helper function.
 *
 * @num_device_descs: number of struct dvb_usb_device_description in @devices
 * @devices: array of struct dvb_usb_device_description compatibles with these
 *  properties.
 */
struct dvb_usb_device_properties {};

/**
 * struct usb_data_stream - generic object of an USB stream
 * @udev: the USB device
 * @props: data stream properties
 * @state: state of the 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: for private use.
 */
struct usb_data_stream {};

/**
 * struct dvb_usb_fe_adapter - a DVB adapter on a USB device
 * @fe: frontend
 * @fe_init:  rerouted frontend-init (wakeup) function.
 * @fe_sleep: rerouted frontend-sleep function.
 * @stream: the usb data stream.
 * @pid_filtering: is hardware pid_filtering used or not.
 * @max_feed_count: how many feeds can be handled simultaneously by this
 *  device
 * @priv: private pointer
 */
struct dvb_usb_fe_adapter {};

/**
 * struct dvb_usb_adapter - a DVB adapter on a USB device
 * @dev: DVB USB device pointer
 * @props: properties
 * @state: status
 * @id: index of this adapter (starting with 0).
 *
 * @feedcount: number of requested feeds (used for streaming-activation)
 *
 * @dvb_adap: device's dvb_adapter.
 * @dmxdev: device's dmxdev.
 * @demux: device's software demuxer.
 * @dvb_net: device's dvb_net interfaces.
 *
 * @fe_adap: frontend adapters
 * @active_fe: active frontend
 * @num_frontends_initialized: number of initialized frontends
 * @priv: private pointer
 */
struct dvb_usb_adapter {};

/**
 * struct dvb_usb_device - object of a DVB USB device
 * @props: copy of the struct dvb_usb_properties this device belongs to.
 * @desc: pointer to the device's struct dvb_usb_device_description.
 * @state: initialization and runtime state of the device.
 *
 * @powered: indicated whether the device is power or not.
 *  Powered is in/decremented for each call to modify the state.
 * @udev: pointer to the device's struct usb_device.
 *
 * @data_mutex: mutex to protect the data structure used to store URB data
 * @usb_mutex: mutex of USB control messages (reading needs two messages).
 *	Please notice that this mutex is used internally at the generic
 *	URB control functions. So, drivers using dvb_usb_generic_rw() and
 *	derivated functions should not lock it internally.
 * @i2c_mutex: mutex for i2c-transfers
 *
 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
 *
 * @num_adapters_initialized: number of initialized adapters
 * @adapter: adapters
 *
 * @rc_dev: rc device for the remote control (rc-core mode)
 * @input_dev: input device for the remote control (legacy mode)
 * @rc_phys: rc device path
 * @rc_query_work: struct work_struct frequent rc queries
 * @last_event: last triggered event
 * @last_state: last state (no, pressed, repeat)
 * @owner: owner of the dvb_adapter
 * @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_usb_device_init(struct usb_interface *,
			       const struct dvb_usb_device_properties *,
			       struct module *, struct dvb_usb_device **,
			       short *adapter_nums);
extern void dvb_usb_device_exit(struct usb_interface *);

/* the generic read/write method for device control */
extern int __must_check
dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16, int);
extern int __must_check
dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);

/* commonly used remote control parsing */
int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *d, u8 keybuf[5],
				u32 *event, int *state);

/* commonly used firmware download types and function */
struct hexline {};
extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos);


#endif