^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * tm6000.h - driver for TM5600/TM6000/TM6010 USB video capture devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2006-2007 Mauro Carvalho Chehab <mchehab@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) 2007 Michel Ludwig <michel.ludwig@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * - DVB-T support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <media/v4l2-common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <media/videobuf-vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "tm6000-usb-isoc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <media/v4l2-fh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/dvb/frontend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <media/dvb_demux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <media/dvb_frontend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <media/dmxdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Inputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) enum tm6000_itype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) TM6000_INPUT_TV = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) TM6000_INPUT_COMPOSITE1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) TM6000_INPUT_COMPOSITE2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) TM6000_INPUT_SVIDEO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) TM6000_INPUT_DVB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) TM6000_INPUT_RADIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) enum tm6000_mux {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) TM6000_VMUX_VIDEO_A = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) TM6000_VMUX_VIDEO_B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) TM6000_VMUX_VIDEO_AB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) TM6000_AMUX_ADC1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) TM6000_AMUX_ADC2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) TM6000_AMUX_SIF1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) TM6000_AMUX_SIF2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) TM6000_AMUX_I2S,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) enum tm6000_devtype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) TM6000 = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) TM5600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) TM6010,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct tm6000_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum tm6000_itype type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) enum tm6000_mux vmux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) enum tm6000_mux amux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned int v_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) unsigned int a_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* ------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Basic structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * ------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct tm6000_fmt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u32 fourcc; /* v4l2 format id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int depth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* buffer for one video frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct tm6000_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* common v4l buffer stuff -- must be first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct videobuf_buffer vb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct tm6000_fmt *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct tm6000_dmaqueue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct list_head active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct list_head queued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* thread for generating video stream*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct task_struct *kthread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) wait_queue_head_t wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* Counters to control fps rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int ini_jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* device states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) enum tm6000_core_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) DEV_INITIALIZED = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) DEV_DISCONNECTED = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) DEV_MISCONFIGURED = 0x04,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* io methods */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) enum tm6000_io_method {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) IO_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) IO_READ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) IO_MMAP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) enum tm6000_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) TM6000_MODE_UNKNOWN = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) TM6000_MODE_ANALOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) TM6000_MODE_DIGITAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct tm6000_gpio {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int tuner_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int tuner_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int demod_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int demod_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int power_led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int dvb_led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int ir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct tm6000_capabilities {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned int has_tuner:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned int has_tda9874:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) unsigned int has_dvb:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned int has_zl10353:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned int has_eeprom:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned int has_remote:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) unsigned int has_radio:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct tm6000_dvb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct dvb_adapter adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct dvb_demux demux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct dvb_frontend *frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct dmxdev dmxdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) unsigned int streams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct urb *bulk_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct snd_tm6000_card {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) spinlock_t reg_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct tm6000_core *core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct snd_pcm_substream *substream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* temporary data for buffer fill processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned buf_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) unsigned period_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct tm6000_endpoint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct usb_host_endpoint *endp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) __u8 bInterfaceNumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) __u8 bAlternateSetting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned maxsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define TM6000_QUIRK_NO_USB_DELAY (1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct tm6000_core {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* generic device properties */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) char name[30]; /* name (including minor) of the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int model; /* index in the device_data struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int devno; /* marks the number of this device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) enum tm6000_devtype dev_type; /* type of device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) unsigned char eedata[256]; /* Eeprom data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) unsigned eedata_size; /* Size of the eeprom info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) v4l2_std_id norm; /* Current norm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) int width, height; /* Selected resolution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) enum tm6000_core_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Device Capabilities*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct tm6000_capabilities caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* Used to load alsa/dvb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct work_struct request_module_wk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* Tuner configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int tuner_type; /* type of the tuner */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int tuner_addr; /* tuner address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct tm6000_gpio gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) char *ir_codes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) __u8 radio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Demodulator configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int demod_addr; /* demodulator address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int audio_bitrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* i2c i/o */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct i2c_adapter i2c_adap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct i2c_client i2c_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /* extension */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct list_head devlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* video for linux */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) int users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* various device info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct tm6000_fh *resources; /* Points to fh that is streaming */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) bool is_res_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct video_device vfd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct video_device radio_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct tm6000_dmaqueue vidq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct v4l2_device v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct v4l2_ctrl_handler ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct v4l2_ctrl_handler radio_ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct tm6000_input vinput[3]; /* video input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct tm6000_input rinput; /* radio input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) unsigned int fourcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) enum tm6000_mode mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) int ctl_mute; /* audio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) int ctl_volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) int amode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* DVB-T support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct tm6000_dvb *dvb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /* audio support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct snd_tm6000_card *adev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) atomic_t stream_started; /* stream should be running if true */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct tm6000_IR *ir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* locks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct mutex usb_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* usb transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct usb_device *udev; /* the usb device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct tm6000_endpoint bulk_in, bulk_out, isoc_in, isoc_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct tm6000_endpoint int_in, int_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* scaler!=0 if scaler is active*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int scaler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /* Isoc control struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) struct usb_isoc_ctl isoc_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) spinlock_t slock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* urb dma buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) char **urb_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) dma_addr_t *urb_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) unsigned int urb_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) unsigned long quirks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) enum tm6000_ops_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) TM6000_AUDIO = 0x10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) TM6000_DVB = 0x20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct tm6000_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct list_head next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) enum tm6000_ops_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int (*init)(struct tm6000_core *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) int (*fini)(struct tm6000_core *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) int (*fillbuf)(struct tm6000_core *, char *buf, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct tm6000_fh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct v4l2_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct tm6000_core *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) unsigned int radio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /* video capture */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct tm6000_fmt *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) unsigned int width, height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct videobuf_queue vb_vidq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) enum v4l2_buf_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) #define TM6000_STD (V4L2_STD_PAL|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) V4L2_STD_PAL_M|V4L2_STD_PAL_60|V4L2_STD_NTSC_M| \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) V4L2_STD_NTSC_M_JP|V4L2_STD_SECAM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /* In tm6000-cards.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) int tm6000_tuner_callback(void *ptr, int component, int command, int arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) int tm6000_xc5000_callback(void *ptr, int component, int command, int arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int tm6000_cards_setup(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) void tm6000_flash_led(struct tm6000_core *dev, u8 state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /* In tm6000-core.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) int tm6000_read_write_usb(struct tm6000_core *dev, u8 reqtype, u8 req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u16 value, u16 index, u8 *buf, u16 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int tm6000_get_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) int tm6000_get_reg32(struct tm6000_core *dev, u8 req, u16 value, u16 index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int tm6000_set_reg(struct tm6000_core *dev, u8 req, u16 value, u16 index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) int tm6000_set_reg_mask(struct tm6000_core *dev, u8 req, u16 value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) u16 index, u16 mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) int tm6000_init(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) int tm6000_reset(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) int tm6000_init_analog_mode(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) int tm6000_init_digital_mode(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) int tm6000_set_audio_bitrate(struct tm6000_core *dev, int bitrate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) int tm6000_set_audio_rinput(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) int tm6000_tvaudio_set_mute(struct tm6000_core *dev, u8 mute);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) void tm6000_set_volume(struct tm6000_core *dev, int vol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) int tm6000_v4l2_register(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int tm6000_v4l2_unregister(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) int tm6000_v4l2_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) void tm6000_set_fourcc_format(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) void tm6000_remove_from_devlist(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) void tm6000_add_into_devlist(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) int tm6000_register_extension(struct tm6000_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) void tm6000_unregister_extension(struct tm6000_ops *ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) void tm6000_init_extension(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) void tm6000_close_extension(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) int tm6000_call_fillbuf(struct tm6000_core *dev, enum tm6000_ops_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) char *buf, int size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /* In tm6000-stds.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) void tm6000_get_std_res(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int tm6000_set_standard(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /* In tm6000-i2c.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) int tm6000_i2c_register(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) int tm6000_i2c_unregister(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* In tm6000-queue.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int tm6000_v4l2_mmap(struct file *filp, struct vm_area_struct *vma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) int tm6000_vidioc_streamon(struct file *file, void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) enum v4l2_buf_type i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) int tm6000_vidioc_streamoff(struct file *file, void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) enum v4l2_buf_type i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) int tm6000_vidioc_reqbufs(struct file *file, void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct v4l2_requestbuffers *rb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) int tm6000_vidioc_querybuf(struct file *file, void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct v4l2_buffer *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) int tm6000_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) int tm6000_vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) ssize_t tm6000_v4l2_read(struct file *filp, char __user * buf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) loff_t *f_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) unsigned int tm6000_v4l2_poll(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct poll_table_struct *wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) int tm6000_queue_init(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* In tm6000-alsa.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*int tm6000_audio_init(struct tm6000_core *dev, int idx);*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /* In tm6000-input.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) int tm6000_ir_init(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) int tm6000_ir_fini(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void tm6000_ir_wait(struct tm6000_core *dev, u8 state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int tm6000_ir_int_start(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) void tm6000_ir_int_stop(struct tm6000_core *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) /* Debug stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) extern int tm6000_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #define dprintk(dev, level, fmt, arg...) do {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (tm6000_debug & level) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) printk(KERN_INFO "(%lu) %s %s :"fmt, jiffies, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) dev->name, __func__ , ##arg); } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #define V4L2_DEBUG_REG 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #define V4L2_DEBUG_I2C 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) #define V4L2_DEBUG_QUEUE 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) #define V4L2_DEBUG_ISOC 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #define V4L2_DEBUG_RES_LOCK 0x0040 /* Resource locking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) #define V4L2_DEBUG_OPEN 0x0080 /* video open/close debug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #define tm6000_err(fmt, arg...) do {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) printk(KERN_ERR "tm6000 %s :"fmt, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) __func__ , ##arg); } while (0)