^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Driver for the Auvitek AU0828 USB bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/i2c-algo-bit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <media/tveeprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /* Analog */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <media/videobuf2-v4l2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <media/videobuf2-vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <media/v4l2-fh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <media/media-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <media/media-dev-allocator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* DVB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <media/demux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <media/dmxdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <media/dvb_demux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <media/dvb_frontend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <media/dvb_net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <media/dvbdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include "au0828-reg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include "au0828-cards.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define URB_COUNT 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define URB_BUFSIZE (0xe522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* Analog constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define NTSC_STD_W 720
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define NTSC_STD_H 480
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define AU0828_INTERLACED_DEFAULT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* Definition for AU0828 USB transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define AU0828_MAX_ISO_BUFS 12 /* maybe resize this value in the future */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define AU0828_ISO_PACKETS_PER_URB 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define AU0828_MIN_BUF 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define AU0828_DEF_BUF 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define AU0828_MAX_INPUT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* au0828 resource types (used for res_get/res_lock etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define AU0828_RESOURCE_VIDEO 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define AU0828_RESOURCE_VBI 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) enum au0828_itype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) AU0828_VMUX_UNDEFINED = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) AU0828_VMUX_COMPOSITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) AU0828_VMUX_SVIDEO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) AU0828_VMUX_CABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) AU0828_VMUX_TELEVISION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) AU0828_VMUX_DVB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct au0828_input {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) enum au0828_itype type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) unsigned int vmux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned int amux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) void (*audio_setup) (void *priv, int enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct au0828_board {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned int tuner_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned char tuner_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned char i2c_clk_divider;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned char has_ir_i2c:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned char has_analog:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct au0828_input input[AU0828_MAX_INPUT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct au0828_dvb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct dvb_adapter adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct dvb_frontend *frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct dvb_demux demux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct dmxdev dmxdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct dmx_frontend fe_hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct dmx_frontend fe_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct dvb_net net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) int feeding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) int start_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int stop_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) int (*set_frontend)(struct dvb_frontend *fe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) enum au0828_stream_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) STREAM_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) STREAM_INTERRUPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) STREAM_ON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define AUVI_INPUT(nr) (dev->board.input[nr])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* device state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) enum au0828_dev_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) DEV_INITIALIZED = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) DEV_DISCONNECTED = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) DEV_MISCONFIGURED = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct au0828_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct au0828_usb_isoc_ctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /* max packet size of isoc transaction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int max_pkt_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* number of allocated urbs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int num_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* urb for isoc transfers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct urb **urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /* transfer buffers for isoc transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) char **transfer_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* Last buffer command and region */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) u8 cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int pos, size, pktsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* Last field: ODD or EVEN? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* Stores incomplete commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u32 tmp_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int tmp_buf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* Stores already requested buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct au0828_buffer *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct au0828_buffer *vbi_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* Stores the number of received fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int nfields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* isoc urb callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int (*isoc_copy) (struct au0828_dev *dev, struct urb *urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* buffer for one video frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct au0828_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /* common v4l buffer stuff -- must be first */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct vb2_v4l2_buffer vb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) void *mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) unsigned long length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int top_field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* pointer to vmalloc memory address in vb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) char *vb_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct au0828_dmaqueue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct list_head active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* Counters to control buffer fill */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct au0828_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct usb_device *usbdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) int boardnr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct au0828_board board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) u8 ctrlmsg[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* I2C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct i2c_adapter i2c_adap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct i2c_algorithm i2c_algo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct i2c_client i2c_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) u32 i2c_rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /* Digital */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct au0828_dvb dvb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct work_struct restart_streaming;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct timer_list bulk_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int bulk_timeout_running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #ifdef CONFIG_VIDEO_AU0828_V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Analog */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct v4l2_device v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct v4l2_ctrl_handler v4l2_ctrl_hdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #ifdef CONFIG_VIDEO_AU0828_RC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct au0828_rc *ir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct video_device vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct video_device vbi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /* Videobuf2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct vb2_queue vb_vidq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct vb2_queue vb_vbiq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct mutex vb_queue_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct mutex vb_vbi_queue_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) unsigned int frame_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) unsigned int vbi_frame_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct timer_list vid_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int vid_timeout_running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct timer_list vbi_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int vbi_timeout_running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int streaming_users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) int vbi_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int vbi_height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) u32 vbi_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) v4l2_std_id std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) u32 field_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) u32 frame_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u32 bytesperline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) u8 ctrl_ainput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) __u8 isoc_in_endpointaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) u8 isoc_init_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) int greenscreen_detected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) int ctrl_freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int input_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) int std_set_in_tuner_core;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) unsigned int ctrl_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) long unsigned int dev_state; /* defined at enum au0828_dev_state */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) enum au0828_stream_state stream_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) wait_queue_head_t open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /* Isoc control struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct au0828_dmaqueue vidq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct au0828_dmaqueue vbiq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct au0828_usb_isoc_ctl isoc_ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) spinlock_t slock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* usb transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int alt; /* alternate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int max_pkt_size; /* max packet size of isoc transaction */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) int num_alt; /* Number of alternative settings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct urb *urb[AU0828_MAX_ISO_BUFS]; /* urb for isoc transfers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) char *transfer_buffer[AU0828_MAX_ISO_BUFS];/* transfer buffers for isoc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) transfer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /* DVB USB / URB Related */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) bool urb_streaming, need_urb_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct urb *urbs[URB_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /* Preallocated transfer digital transfer buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) char *dig_transfer_buffer[URB_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #ifdef CONFIG_MEDIA_CONTROLLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct media_device *media_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct media_pad video_pad, vbi_pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) struct media_entity *decoder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct media_entity input_ent[AU0828_MAX_INPUT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct media_pad input_pad[AU0828_MAX_INPUT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct media_entity_notify entity_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct media_entity *tuner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct media_link *active_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct media_entity *active_source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct media_entity *active_sink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct media_entity *active_link_owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct media_entity *active_link_user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct media_pipeline *active_link_user_pipe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) bool active_link_shared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #define au0828_read(dev, reg) au0828_readreg(dev, reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #define au0828_write(dev, reg, value) au0828_writereg(dev, reg, value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #define au0828_andor(dev, reg, mask, value) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) au0828_writereg(dev, reg, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) (au0828_readreg(dev, reg) & ~(mask)) | ((value) & (mask)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) #define au0828_set(dev, reg, bit) au0828_andor(dev, (reg), (bit), (bit))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #define au0828_clear(dev, reg, bit) au0828_andor(dev, (reg), (bit), 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* au0828-core.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) extern void au0828_usb_release(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) extern int au0828_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* au0828-cards.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) extern struct au0828_board au0828_boards[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) extern struct usb_device_id au0828_usb_id_table[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) extern void au0828_gpio_setup(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) extern int au0828_tuner_callback(void *priv, int component,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) int command, int arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) extern void au0828_card_setup(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* au0828-i2c.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) extern int au0828_i2c_register(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) extern int au0828_i2c_unregister(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /* au0828-video.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) extern int au0828_start_analog_streaming(struct vb2_queue *vq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsigned int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) extern void au0828_stop_vbi_streaming(struct vb2_queue *vq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #ifdef CONFIG_VIDEO_AU0828_V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) extern int au0828_v4l2_device_register(struct usb_interface *interface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) extern int au0828_analog_register(struct au0828_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct usb_interface *interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) extern int au0828_analog_unregister(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) extern void au0828_usb_v4l2_media_release(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) extern void au0828_v4l2_suspend(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) extern void au0828_v4l2_resume(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static inline int au0828_v4l2_device_register(struct usb_interface *interface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct au0828_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) { return 0; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) static inline int au0828_analog_register(struct au0828_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) struct usb_interface *interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) { return 0; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static inline int au0828_analog_unregister(struct au0828_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) { return 0; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static inline void au0828_usb_v4l2_media_release(struct au0828_dev *dev) { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static inline void au0828_v4l2_resume(struct au0828_dev *dev) { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) /* ----------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* au0828-dvb.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) extern int au0828_dvb_register(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) extern void au0828_dvb_unregister(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) void au0828_dvb_suspend(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) void au0828_dvb_resume(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /* au0828-vbi.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) extern const struct vb2_ops au0828_vbi_qops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) #define dprintk(level, fmt, arg...)\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) do { if (au0828_debug & level)\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) printk(KERN_DEBUG pr_fmt(fmt), ## arg);\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* au0828-input.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) #ifdef CONFIG_VIDEO_AU0828_RC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) extern int au0828_rc_register(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) extern void au0828_rc_unregister(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) extern int au0828_rc_suspend(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) extern int au0828_rc_resume(struct au0828_dev *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) static inline int au0828_rc_register(struct au0828_dev *dev) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static inline void au0828_rc_unregister(struct au0828_dev *dev) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static inline int au0828_rc_suspend(struct au0828_dev *dev) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static inline int au0828_rc_resume(struct au0828_dev *dev) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) #endif