linux/drivers/media/usb/em28xx/em28xx.h

/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * em28xx.h - driver for Empia EM2800/EM2820/2840 USB video capture devices
 *
 * Copyright (C) 2005 Markus Rechberger <[email protected]>
 *		      Ludovico Cavedon <[email protected]>
 *		      Mauro Carvalho Chehab <[email protected]>
 * Copyright (C) 2012 Frank Schäfer <[email protected]>
 *
 * Based on the em2800 driver from Sascha Sommer <[email protected]>
 */

#ifndef _EM28XX_H
#define _EM28XX_H

#include <linux/bitfield.h>

#define EM28XX_VERSION
#define DRIVER_DESC

#include <linux/workqueue.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/kref.h>
#include <linux/videodev2.h>

#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-vmalloc.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/i2c/ir-kbd-i2c.h>
#include <media/rc-core.h>
#include "xc2028.h"
#include "xc5000.h"
#include "em28xx-reg.h"

/* Boards supported by driver */
#define EM2800_BOARD_UNKNOWN
#define EM2820_BOARD_UNKNOWN
#define EM2820_BOARD_TERRATEC_CINERGY_250
#define EM2820_BOARD_PINNACLE_USB_2
#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2
#define EM2820_BOARD_MSI_VOX_USB_2
#define EM2800_BOARD_TERRATEC_CINERGY_200
#define EM2800_BOARD_LEADTEK_WINFAST_USBII
#define EM2800_BOARD_KWORLD_USB2800
#define EM2820_BOARD_PINNACLE_DVC_90
#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900
#define EM2880_BOARD_TERRATEC_HYBRID_XS
#define EM2820_BOARD_KWORLD_PVRTV2800RF
#define EM2880_BOARD_TERRATEC_PRODIGY_XS
#define EM2820_BOARD_PROLINK_PLAYTV_USB2
#define EM2800_BOARD_VGEAR_POCKETTV
#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950
#define EM2880_BOARD_PINNACLE_PCTV_HD_PRO
#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2
#define EM2860_BOARD_SAA711X_REFERENCE_DESIGN
#define EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600
#define EM2800_BOARD_GRABBEEX_USB2800
#define EM2750_BOARD_UNKNOWN
#define EM2750_BOARD_DLCW_130
#define EM2820_BOARD_DLINK_USB_TV
#define EM2820_BOARD_GADMEI_UTV310
#define EM2820_BOARD_HERCULES_SMART_TV_USB2
#define EM2820_BOARD_PINNACLE_USB_2_FM1216ME
#define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE
#define EM2860_BOARD_TVP5150_REFERENCE_DESIGN
#define EM2820_BOARD_VIDEOLOGY_20K14XUSB
#define EM2821_BOARD_USBGEAR_VD204
#define EM2821_BOARD_SUPERCOMP_USB_2
#define EM2860_BOARD_ELGATO_VIDEO_CAPTURE
#define EM2860_BOARD_TERRATEC_HYBRID_XS
#define EM2860_BOARD_TYPHOON_DVD_MAKER
#define EM2860_BOARD_NETGMBH_CAM
#define EM2860_BOARD_GADMEI_UTV330
#define EM2861_BOARD_YAKUMO_MOVIE_MIXER
#define EM2861_BOARD_KWORLD_PVRTV_300U
#define EM2861_BOARD_PLEXTOR_PX_TV100U
#define EM2870_BOARD_KWORLD_350U
#define EM2870_BOARD_KWORLD_355U
#define EM2870_BOARD_TERRATEC_XS
#define EM2870_BOARD_TERRATEC_XS_MT2060
#define EM2870_BOARD_PINNACLE_PCTV_DVB
#define EM2870_BOARD_COMPRO_VIDEOMATE
#define EM2880_BOARD_KWORLD_DVB_305U
#define EM2880_BOARD_KWORLD_DVB_310U
#define EM2880_BOARD_MSI_DIGIVOX_AD
#define EM2880_BOARD_MSI_DIGIVOX_AD_II
#define EM2880_BOARD_TERRATEC_HYBRID_XS_FR
#define EM2881_BOARD_DNT_DA2_HYBRID
#define EM2881_BOARD_PINNACLE_HYBRID_PRO
#define EM2882_BOARD_KWORLD_VS_DVBT
#define EM2882_BOARD_TERRATEC_HYBRID_XS
#define EM2882_BOARD_PINNACLE_HYBRID_PRO_330E
#define EM2883_BOARD_KWORLD_HYBRID_330U
#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU
#define EM2874_BOARD_PCTV_HD_MINI_80E
#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850
#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2
#define EM2820_BOARD_GADMEI_TVR200
#define EM2860_BOARD_KAIOMY_TVNPC_U2
#define EM2860_BOARD_EASYCAP
#define EM2820_BOARD_IODATA_GVMVP_SZ
#define EM2880_BOARD_EMPIRE_DUAL_TV
#define EM2860_BOARD_TERRATEC_GRABBY
#define EM2860_BOARD_TERRATEC_AV350
#define EM2882_BOARD_KWORLD_ATSC_315U
#define EM2882_BOARD_EVGA_INDTUBE
#define EM2820_BOARD_SILVERCREST_WEBCAM
#define EM2861_BOARD_GADMEI_UTV330PLUS
#define EM2870_BOARD_REDDO_DVB_C_USB_BOX
#define EM2800_BOARD_VC211A
#define EM2882_BOARD_DIKOM_DK300
#define EM2870_BOARD_KWORLD_A340
#define EM2874_BOARD_LEADERSHIP_ISDBT
#define EM28174_BOARD_PCTV_290E
#define EM2884_BOARD_TERRATEC_H5
#define EM28174_BOARD_PCTV_460E
#define EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C
#define EM2884_BOARD_CINERGY_HTC_STICK
#define EM2860_BOARD_HT_VIDBOX_NW03
#define EM2874_BOARD_MAXMEDIA_UB425_TC
#define EM2884_BOARD_PCTV_510E
#define EM2884_BOARD_PCTV_520E
#define EM2884_BOARD_TERRATEC_HTC_USB_XS
#define EM2884_BOARD_C3TECH_DIGITAL_DUO
#define EM2874_BOARD_DELOCK_61959
#define EM2874_BOARD_KWORLD_UB435Q_V2
#define EM2765_BOARD_SPEEDLINK_VAD_LAPLACE
#define EM28178_BOARD_PCTV_461E
#define EM2874_BOARD_KWORLD_UB435Q_V3
#define EM28178_BOARD_PCTV_292E
#define EM2861_BOARD_LEADTEK_VC100
#define EM28178_BOARD_TERRATEC_T2_STICK_HD
#define EM2884_BOARD_ELGATO_EYETV_HYBRID_2008
#define EM28178_BOARD_PLEX_PX_BCUD
#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB
#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595
#define EM2884_BOARD_TERRATEC_H6
#define EM2882_BOARD_ZOLID_HYBRID_TV_STICK
#define EM2861_BOARD_MAGIX_VIDEOWANDLER2
#define EM28178_BOARD_PCTV_461E_V2
#define EM2860_BOARD_MYGICA_IGRABBER
#define EM2874_BOARD_HAUPPAUGE_USB_QUADHD
#define EM2860_BOARD_MYGICA_UTV3

/* Limits minimum and default number of buffers */
#define EM28XX_MIN_BUF
#define EM28XX_DEF_BUF

/*Limits the max URB message size */
#define URB_MAX_CTRL_SIZE

/* Params for validated field */
#define EM28XX_BOARD_NOT_VALIDATED
#define EM28XX_BOARD_VALIDATED

/* Params for em28xx_cmd() audio */
#define EM28XX_START_AUDIO
#define EM28XX_STOP_AUDIO

/* maximum number of em28xx boards */
#define EM28XX_MAXBOARDS

/* maximum number of frames that can be queued */
#define EM28XX_NUM_FRAMES
/* number of frames that get used for v4l2_read() */
#define EM28XX_NUM_READ_FRAMES

/* number of buffers for isoc transfers */
#define EM28XX_NUM_BUFS
#define EM28XX_DVB_NUM_BUFS

/* max number of I2C buses on em28xx devices */
#define NUM_I2C_BUSES

/*
 * isoc transfers: number of packets for each buffer
 * windows requests only 64 packets .. so we better do the same
 * this is what I found out for all alternate numbers there!
 */
#define EM28XX_NUM_ISOC_PACKETS
#define EM28XX_DVB_NUM_ISOC_PACKETS

/*
 * bulk transfers: transfer buffer size = packet size * packet multiplier
 * USB 2.0 spec says bulk packet size is always 512 bytes
 */
#define EM28XX_BULK_PACKET_MULTIPLIER
#define EM28XX_DVB_BULK_PACKET_MULTIPLIER

#define EM28XX_INTERLACED_DEFAULT

/* time in msecs to wait for AC97 xfers to finish */
#define EM28XX_AC97_XFER_TIMEOUT

/* max. number of button state polling addresses */
#define EM28XX_NUM_BUTTON_ADDRESSES_MAX

#define PRIMARY_TS
#define SECONDARY_TS

enum em28xx_mode {};

struct em28xx;

/**
 * struct em28xx_usb_bufs - Contains URB-related buffer data
 *
 * @max_pkt_size:	max packet size of isoc transaction
 * @num_packets:	number of packets in each buffer
 * @num_bufs:		number of allocated urb
 * @urb:		urb for isoc/bulk transfers
 * @buf:		transfer buffers for isoc/bulk transfer
 */
struct em28xx_usb_bufs {};

/**
 * struct em28xx_usb_ctl - Contains URB-related buffer data
 *
 * @analog_bufs:	isoc/bulk transfer buffers for analog mode
 * @digital_bufs:	isoc/bulk transfer buffers for digital mode
 * @vid_buf:		Stores already requested video buffers
 * @vbi_buf:		Stores already requested VBI buffers
 * @urb_data_copy:	copy data from URB
 */
struct em28xx_usb_ctl {};

/**
 * struct em28xx_fmt - Struct to enumberate video formats
 *
 * @fourcc:	v4l2 format id
 * @depth:	mean number of bits to represent a pixel
 * @reg:	em28xx register value to set it
 */
struct em28xx_fmt {};

/**
 * struct em28xx_buffer- buffer for storing one video frame
 *
 * @vb:		common v4l buffer stuff
 * @list:	List to associate it with the other buffers
 * @mem:	pointer to the buffer, as returned by vb2_plane_vaddr()
 * @length:	length of the buffer, as returned by vb2_plane_size()
 * @top_field:	If non-zero, indicate that the buffer is the top field
 * @pos:	Indicate the next position of the buffer to be filled.
 * @vb_buf:	pointer to vmalloc memory address in vb
 *
 * .. note::
 *
 *    in interlaced mode, @pos is reset to zero at the start of each new
 *    field (not frame !)
 */
struct em28xx_buffer {};

struct em28xx_dmaqueue {};

/* inputs */

#define MAX_EM28XX_INPUT
enum enum28xx_itype {};

enum em28xx_ac97_mode {};

struct em28xx_audio_mode {};

enum em28xx_int_audio_type {};

enum em28xx_usb_audio_type {};

/**
 * enum em28xx_amux - describes the type of audio input used by em28xx
 *
 * @EM28XX_AMUX_UNUSED:
 *	Used only on em28xx dev->map field, in order to mark an entry
 *	as unused.
 * @EM28XX_AMUX_VIDEO:
 *	On devices without AC97, this is the only value that it is currently
 *	allowed.
 *	On devices with AC97, it corresponds to the AC97 mixer "Video" control.
 * @EM28XX_AMUX_LINE_IN:
 *	Only for devices with AC97. Corresponds to AC97 mixer "Line In".
 * @EM28XX_AMUX_VIDEO2:
 *	Only for devices with AC97. It means that em28xx should use "Line In"
 *	And AC97 should use the "Video" mixer control.
 * @EM28XX_AMUX_PHONE:
 *	Only for devices with AC97. Corresponds to AC97 mixer "Phone".
 * @EM28XX_AMUX_MIC:
 *	Only for devices with AC97. Corresponds to AC97 mixer "Mic".
 * @EM28XX_AMUX_CD:
 *	Only for devices with AC97. Corresponds to AC97 mixer "CD".
 * @EM28XX_AMUX_AUX:
 *	Only for devices with AC97. Corresponds to AC97 mixer "Aux".
 * @EM28XX_AMUX_PCM_OUT:
 *	Only for devices with AC97. Corresponds to AC97 mixer "PCM out".
 *
 * The em28xx chip itself has only two audio inputs: tuner and line in.
 * On almost all devices, only the tuner input is used.
 *
 * However, on most devices, an auxiliary AC97 codec device is used,
 * usually connected to the em28xx tuner input (except for
 * @EM28XX_AMUX_LINE_IN).
 *
 * The AC97 device typically have several different inputs and outputs.
 * The exact number and description depends on their model.
 *
 * It is possible to AC97 to mixer more than one different entries at the
 * same time, via the alsa mux.
 */
enum em28xx_amux {};

enum em28xx_aout {};

static inline int ac97_return_record_select(int a_out)
{}

struct em28xx_reg_seq {};

struct em28xx_input {};

#define INPUT(nr)

enum em28xx_decoder {};

enum em28xx_sensor {};

enum em28xx_adecoder {};

enum em28xx_led_role {};

struct em28xx_led {};

enum em28xx_button_role {};

struct em28xx_button {};

struct em28xx_board {};

struct em28xx_eeprom {};

#define EM28XX_CAPTURE_STREAM_EN

/* em28xx extensions */
#define EM28XX_AUDIO
#define EM28XX_DVB
#define EM28XX_RC
#define EM28XX_V4L2

/* em28xx resource types (used for res_get/res_lock etc */
#define EM28XX_RESOURCE_VIDEO
#define EM28XX_RESOURCE_VBI

struct em28xx_v4l2 {};

struct em28xx_audio {};

enum em28xx_i2c_algo_type {};

struct em28xx_i2c_bus {};

/* main device struct */
struct em28xx {};

#define kref_to_dev(d)

struct em28xx_ops {};

/* Provided by em28xx-i2c.c */
void em28xx_do_i2c_scan(struct em28xx *dev, unsigned int bus);
int  em28xx_i2c_register(struct em28xx *dev, unsigned int bus,
			 enum em28xx_i2c_algo_type algo_type);
int  em28xx_i2c_unregister(struct em28xx *dev, unsigned int bus);

/* Provided by em28xx-core.c */
int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
			    char *buf, int len);
int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg);
int em28xx_read_reg(struct em28xx *dev, u16 reg);
int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
			  int len);
int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
			  u8 bitmask);
int em28xx_toggle_reg_bits(struct em28xx *dev, u16 reg, u8 bitmask);

int em28xx_read_ac97(struct em28xx *dev, u8 reg);
int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);

int em28xx_audio_analog_set(struct em28xx *dev);
int em28xx_audio_setup(struct em28xx *dev);

const struct em28xx_led *em28xx_find_led(struct em28xx *dev,
					 enum em28xx_led_role role);
int em28xx_capture_start(struct em28xx *dev, int start);
int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
		      int num_bufs, int max_pkt_size, int packet_multiplier);
int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode,
			 int xfer_bulk,
			 int num_bufs, int max_pkt_size, int packet_multiplier,
			 int (*urb_data_copy)
					(struct em28xx *dev, struct urb *urb));
void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode);
void em28xx_stop_urbs(struct em28xx *dev);
int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode);
int em28xx_gpio_set(struct em28xx *dev, const struct em28xx_reg_seq *gpio);
int em28xx_register_extension(struct em28xx_ops *dev);
void em28xx_unregister_extension(struct em28xx_ops *dev);
void em28xx_init_extension(struct em28xx *dev);
void em28xx_close_extension(struct em28xx *dev);
int em28xx_suspend_extension(struct em28xx *dev);
int em28xx_resume_extension(struct em28xx *dev);

/* Provided by em28xx-cards.c */
extern const struct em28xx_board em28xx_boards[];
extern struct usb_device_id em28xx_id_table[];
int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl);
void em28xx_free_device(struct kref *ref);

/* Provided by em28xx-camera.c */
int em28xx_detect_sensor(struct em28xx *dev);
int em28xx_init_camera(struct em28xx *dev);

#endif