18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci Copyright (C) 2008 <srinivasa.deevi at conexant dot com> 68c2ecf20Sopenharmony_ci Based on em28xx driver 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _CX231XX_H 118c2ecf20Sopenharmony_ci#define _CX231XX_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/videodev2.h> 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 168c2ecf20Sopenharmony_ci#include <linux/i2c.h> 178c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 188c2ecf20Sopenharmony_ci#include <linux/mutex.h> 198c2ecf20Sopenharmony_ci#include <linux/usb.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include <media/drv-intf/cx2341x.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <media/videobuf2-vmalloc.h> 248c2ecf20Sopenharmony_ci#include <media/v4l2-device.h> 258c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h> 268c2ecf20Sopenharmony_ci#include <media/v4l2-fh.h> 278c2ecf20Sopenharmony_ci#include <media/rc-core.h> 288c2ecf20Sopenharmony_ci#include <media/i2c/ir-kbd-i2c.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include "cx231xx-reg.h" 318c2ecf20Sopenharmony_ci#include "cx231xx-pcb-cfg.h" 328c2ecf20Sopenharmony_ci#include "cx231xx-conf-reg.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define DRIVER_NAME "cx231xx" 358c2ecf20Sopenharmony_ci#define PWR_SLEEP_INTERVAL 10 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* I2C addresses for control block in Cx231xx */ 388c2ecf20Sopenharmony_ci#define AFE_DEVICE_ADDRESS 0x60 398c2ecf20Sopenharmony_ci#define I2S_BLK_DEVICE_ADDRESS 0x98 408c2ecf20Sopenharmony_ci#define VID_BLK_I2C_ADDRESS 0x88 418c2ecf20Sopenharmony_ci#define VERVE_I2C_ADDRESS 0x40 428c2ecf20Sopenharmony_ci#define DIF_USE_BASEBAND 0xFFFFFFFF 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Boards supported by driver */ 458c2ecf20Sopenharmony_ci#define CX231XX_BOARD_UNKNOWN 0 468c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_CARRAERA 1 478c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_SHELBY 2 488c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_RDE_253S 3 498c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_RDU_253S 4 508c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_VIDEO_GRABBER 5 518c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_RDE_250 6 528c2ecf20Sopenharmony_ci#define CX231XX_BOARD_CNXT_RDU_250 7 538c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_EXETER 8 548c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_USBLIVE2 9 558c2ecf20Sopenharmony_ci#define CX231XX_BOARD_PV_PLAYTV_USB_HYBRID 10 568c2ecf20Sopenharmony_ci#define CX231XX_BOARD_PV_XCAPTURE_USB 11 578c2ecf20Sopenharmony_ci#define CX231XX_BOARD_KWORLD_UB430_USB_HYBRID 12 588c2ecf20Sopenharmony_ci#define CX231XX_BOARD_ICONBIT_U100 13 598c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL 14 608c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC 15 618c2ecf20Sopenharmony_ci#define CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2 16 628c2ecf20Sopenharmony_ci#define CX231XX_BOARD_OTG102 17 638c2ecf20Sopenharmony_ci#define CX231XX_BOARD_KWORLD_UB445_USB_HYBRID 18 648c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx 19 658c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx 20 668c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_955Q 21 678c2ecf20Sopenharmony_ci#define CX231XX_BOARD_TERRATEC_GRABBY 22 688c2ecf20Sopenharmony_ci#define CX231XX_BOARD_EVROMEDIA_FULL_HYBRID_FULLHD 23 698c2ecf20Sopenharmony_ci#define CX231XX_BOARD_ASTROMETA_T2HYBRID 24 708c2ecf20Sopenharmony_ci#define CX231XX_BOARD_THE_IMAGING_SOURCE_DFG_USB2_PRO 25 718c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_935C 26 728c2ecf20Sopenharmony_ci#define CX231XX_BOARD_HAUPPAUGE_975 27 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Limits minimum and default number of buffers */ 758c2ecf20Sopenharmony_ci#define CX231XX_MIN_BUF 4 768c2ecf20Sopenharmony_ci#define CX231XX_DEF_BUF 12 778c2ecf20Sopenharmony_ci#define CX231XX_DEF_VBI_BUF 6 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define VBI_LINE_COUNT 17 808c2ecf20Sopenharmony_ci#define VBI_LINE_LENGTH 1440 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/*Limits the max URB message size */ 838c2ecf20Sopenharmony_ci#define URB_MAX_CTRL_SIZE 80 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* Params for validated field */ 868c2ecf20Sopenharmony_ci#define CX231XX_BOARD_NOT_VALIDATED 1 878c2ecf20Sopenharmony_ci#define CX231XX_BOARD_VALIDATED 0 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* maximum number of cx231xx boards */ 908c2ecf20Sopenharmony_ci#define CX231XX_MAXBOARDS 8 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* maximum number of frames that can be queued */ 938c2ecf20Sopenharmony_ci#define CX231XX_NUM_FRAMES 5 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* number of buffers for isoc transfers */ 968c2ecf20Sopenharmony_ci#define CX231XX_NUM_BUFS 8 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci/* number of packets for each buffer 998c2ecf20Sopenharmony_ci windows requests only 40 packets .. so we better do the same 1008c2ecf20Sopenharmony_ci this is what I found out for all alternate numbers there! 1018c2ecf20Sopenharmony_ci */ 1028c2ecf20Sopenharmony_ci#define CX231XX_NUM_PACKETS 40 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* default alternate; 0 means choose the best */ 1058c2ecf20Sopenharmony_ci#define CX231XX_PINOUT 0 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define CX231XX_INTERLACED_DEFAULT 1 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* time to wait when stopping the isoc transfer */ 1108c2ecf20Sopenharmony_ci#define CX231XX_URB_TIMEOUT \ 1118c2ecf20Sopenharmony_ci msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define CX231xx_NORMS (\ 1148c2ecf20Sopenharmony_ci V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \ 1158c2ecf20Sopenharmony_ci V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \ 1168c2ecf20Sopenharmony_ci V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | \ 1178c2ecf20Sopenharmony_ci V4L2_STD_PAL_60 | V4L2_STD_SECAM_L | V4L2_STD_SECAM_DK) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define SLEEP_S5H1432 30 1208c2ecf20Sopenharmony_ci#define CX23417_OSC_EN 8 1218c2ecf20Sopenharmony_ci#define CX23417_RESET 9 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistruct cx23417_fmt { 1248c2ecf20Sopenharmony_ci u32 fourcc; /* v4l2 format id */ 1258c2ecf20Sopenharmony_ci int depth; 1268c2ecf20Sopenharmony_ci int flags; 1278c2ecf20Sopenharmony_ci u32 cxformat; 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_cienum cx231xx_mode { 1308c2ecf20Sopenharmony_ci CX231XX_SUSPEND, 1318c2ecf20Sopenharmony_ci CX231XX_ANALOG_MODE, 1328c2ecf20Sopenharmony_ci CX231XX_DIGITAL_MODE, 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cienum cx231xx_std_mode { 1368c2ecf20Sopenharmony_ci CX231XX_TV_AIR = 0, 1378c2ecf20Sopenharmony_ci CX231XX_TV_CABLE 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cienum cx231xx_stream_state { 1418c2ecf20Sopenharmony_ci STREAM_OFF, 1428c2ecf20Sopenharmony_ci STREAM_INTERRUPT, 1438c2ecf20Sopenharmony_ci STREAM_ON, 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct cx231xx; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_cistruct cx231xx_isoc_ctl { 1498c2ecf20Sopenharmony_ci /* max packet size of isoc transaction */ 1508c2ecf20Sopenharmony_ci int max_pkt_size; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci /* number of allocated urbs */ 1538c2ecf20Sopenharmony_ci int num_bufs; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci /* urb for isoc transfers */ 1568c2ecf20Sopenharmony_ci struct urb **urb; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci /* transfer buffers for isoc transfer */ 1598c2ecf20Sopenharmony_ci char **transfer_buffer; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci /* Last buffer command and region */ 1628c2ecf20Sopenharmony_ci u8 cmd; 1638c2ecf20Sopenharmony_ci int pos, size, pktsize; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci /* Last field: ODD or EVEN? */ 1668c2ecf20Sopenharmony_ci int field; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci /* Stores incomplete commands */ 1698c2ecf20Sopenharmony_ci u32 tmp_buf; 1708c2ecf20Sopenharmony_ci int tmp_buf_len; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci /* Stores already requested buffers */ 1738c2ecf20Sopenharmony_ci struct cx231xx_buffer *buf; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci /* Stores the number of received fields */ 1768c2ecf20Sopenharmony_ci int nfields; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci /* isoc urb callback */ 1798c2ecf20Sopenharmony_ci int (*isoc_copy) (struct cx231xx *dev, struct urb *urb); 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cistruct cx231xx_bulk_ctl { 1838c2ecf20Sopenharmony_ci /* max packet size of bulk transaction */ 1848c2ecf20Sopenharmony_ci int max_pkt_size; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci /* number of allocated urbs */ 1878c2ecf20Sopenharmony_ci int num_bufs; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci /* urb for bulk transfers */ 1908c2ecf20Sopenharmony_ci struct urb **urb; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci /* transfer buffers for bulk transfer */ 1938c2ecf20Sopenharmony_ci char **transfer_buffer; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci /* Last buffer command and region */ 1968c2ecf20Sopenharmony_ci u8 cmd; 1978c2ecf20Sopenharmony_ci int pos, size, pktsize; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /* Last field: ODD or EVEN? */ 2008c2ecf20Sopenharmony_ci int field; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci /* Stores incomplete commands */ 2038c2ecf20Sopenharmony_ci u32 tmp_buf; 2048c2ecf20Sopenharmony_ci int tmp_buf_len; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci /* Stores already requested buffers */ 2078c2ecf20Sopenharmony_ci struct cx231xx_buffer *buf; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci /* Stores the number of received fields */ 2108c2ecf20Sopenharmony_ci int nfields; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci /* bulk urb callback */ 2138c2ecf20Sopenharmony_ci int (*bulk_copy) (struct cx231xx *dev, struct urb *urb); 2148c2ecf20Sopenharmony_ci}; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_cistruct cx231xx_fmt { 2178c2ecf20Sopenharmony_ci char *name; 2188c2ecf20Sopenharmony_ci u32 fourcc; /* v4l2 format id */ 2198c2ecf20Sopenharmony_ci int depth; 2208c2ecf20Sopenharmony_ci int reg; 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/* buffer for one video frame */ 2248c2ecf20Sopenharmony_cistruct cx231xx_buffer { 2258c2ecf20Sopenharmony_ci /* common v4l buffer stuff -- must be first */ 2268c2ecf20Sopenharmony_ci struct vb2_v4l2_buffer vb; 2278c2ecf20Sopenharmony_ci struct list_head list; 2288c2ecf20Sopenharmony_ci struct list_head frame; 2298c2ecf20Sopenharmony_ci int top_field; 2308c2ecf20Sopenharmony_ci int receiving; 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cienum ps_package_head { 2348c2ecf20Sopenharmony_ci CX231XX_NEED_ADD_PS_PACKAGE_HEAD = 0, 2358c2ecf20Sopenharmony_ci CX231XX_NONEED_PS_PACKAGE_HEAD 2368c2ecf20Sopenharmony_ci}; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_cistruct cx231xx_dmaqueue { 2398c2ecf20Sopenharmony_ci struct list_head active; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci wait_queue_head_t wq; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci /* Counters to control buffer fill */ 2448c2ecf20Sopenharmony_ci int pos; 2458c2ecf20Sopenharmony_ci u8 is_partial_line; 2468c2ecf20Sopenharmony_ci u8 partial_buf[8]; 2478c2ecf20Sopenharmony_ci u8 last_sav; 2488c2ecf20Sopenharmony_ci int current_field; 2498c2ecf20Sopenharmony_ci u32 bytes_left_in_line; 2508c2ecf20Sopenharmony_ci u32 lines_completed; 2518c2ecf20Sopenharmony_ci u8 field1_done; 2528c2ecf20Sopenharmony_ci u32 lines_per_field; 2538c2ecf20Sopenharmony_ci u32 sequence; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci /*Mpeg2 control buffer*/ 2568c2ecf20Sopenharmony_ci u8 *p_left_data; 2578c2ecf20Sopenharmony_ci u32 left_data_count; 2588c2ecf20Sopenharmony_ci u8 mpeg_buffer_done; 2598c2ecf20Sopenharmony_ci u32 mpeg_buffer_completed; 2608c2ecf20Sopenharmony_ci enum ps_package_head add_ps_package_head; 2618c2ecf20Sopenharmony_ci char ps_head[10]; 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci/* inputs */ 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci#define MAX_CX231XX_INPUT 4 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cienum cx231xx_itype { 2698c2ecf20Sopenharmony_ci CX231XX_VMUX_COMPOSITE1 = 1, 2708c2ecf20Sopenharmony_ci CX231XX_VMUX_SVIDEO, 2718c2ecf20Sopenharmony_ci CX231XX_VMUX_TELEVISION, 2728c2ecf20Sopenharmony_ci CX231XX_VMUX_CABLE, 2738c2ecf20Sopenharmony_ci CX231XX_RADIO, 2748c2ecf20Sopenharmony_ci CX231XX_VMUX_DVB, 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_cienum cx231xx_v_input { 2788c2ecf20Sopenharmony_ci CX231XX_VIN_1_1 = 0x1, 2798c2ecf20Sopenharmony_ci CX231XX_VIN_2_1, 2808c2ecf20Sopenharmony_ci CX231XX_VIN_3_1, 2818c2ecf20Sopenharmony_ci CX231XX_VIN_4_1, 2828c2ecf20Sopenharmony_ci CX231XX_VIN_1_2 = 0x01, 2838c2ecf20Sopenharmony_ci CX231XX_VIN_2_2, 2848c2ecf20Sopenharmony_ci CX231XX_VIN_3_2, 2858c2ecf20Sopenharmony_ci CX231XX_VIN_1_3 = 0x1, 2868c2ecf20Sopenharmony_ci CX231XX_VIN_2_3, 2878c2ecf20Sopenharmony_ci CX231XX_VIN_3_3, 2888c2ecf20Sopenharmony_ci}; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci/* cx231xx has two audio inputs: tuner and line in */ 2918c2ecf20Sopenharmony_cienum cx231xx_amux { 2928c2ecf20Sopenharmony_ci /* This is the only entry for cx231xx tuner input */ 2938c2ecf20Sopenharmony_ci CX231XX_AMUX_VIDEO, /* cx231xx tuner */ 2948c2ecf20Sopenharmony_ci CX231XX_AMUX_LINE_IN, /* Line In */ 2958c2ecf20Sopenharmony_ci}; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistruct cx231xx_reg_seq { 2988c2ecf20Sopenharmony_ci unsigned char bit; 2998c2ecf20Sopenharmony_ci unsigned char val; 3008c2ecf20Sopenharmony_ci int sleep; 3018c2ecf20Sopenharmony_ci}; 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_cistruct cx231xx_input { 3048c2ecf20Sopenharmony_ci enum cx231xx_itype type; 3058c2ecf20Sopenharmony_ci unsigned int vmux; 3068c2ecf20Sopenharmony_ci enum cx231xx_amux amux; 3078c2ecf20Sopenharmony_ci struct cx231xx_reg_seq *gpio; 3088c2ecf20Sopenharmony_ci}; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci#define INPUT(nr) (&cx231xx_boards[dev->model].input[nr]) 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cienum cx231xx_decoder { 3138c2ecf20Sopenharmony_ci CX231XX_NODECODER, 3148c2ecf20Sopenharmony_ci CX231XX_AVDECODER 3158c2ecf20Sopenharmony_ci}; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_cienum CX231XX_I2C_MASTER_PORT { 3188c2ecf20Sopenharmony_ci I2C_0 = 0, /* master 0 - internal connection */ 3198c2ecf20Sopenharmony_ci I2C_1 = 1, /* master 1 - used with mux */ 3208c2ecf20Sopenharmony_ci I2C_2 = 2, /* master 2 */ 3218c2ecf20Sopenharmony_ci I2C_1_MUX_1 = 3, /* master 1 - port 1 (I2C_DEMOD_EN = 0) */ 3228c2ecf20Sopenharmony_ci I2C_1_MUX_3 = 4 /* master 1 - port 3 (I2C_DEMOD_EN = 1) */ 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_cistruct cx231xx_board { 3268c2ecf20Sopenharmony_ci char *name; 3278c2ecf20Sopenharmony_ci int vchannels; 3288c2ecf20Sopenharmony_ci int tuner_type; 3298c2ecf20Sopenharmony_ci int tuner_addr; 3308c2ecf20Sopenharmony_ci v4l2_std_id norm; /* tv norm */ 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci /* demod related */ 3338c2ecf20Sopenharmony_ci int demod_addr; 3348c2ecf20Sopenharmony_ci int demod_addr2; 3358c2ecf20Sopenharmony_ci u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */ 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci /* GPIO Pins */ 3388c2ecf20Sopenharmony_ci struct cx231xx_reg_seq *dvb_gpio; 3398c2ecf20Sopenharmony_ci struct cx231xx_reg_seq *suspend_gpio; 3408c2ecf20Sopenharmony_ci struct cx231xx_reg_seq *tuner_gpio; 3418c2ecf20Sopenharmony_ci /* Negative means don't use it */ 3428c2ecf20Sopenharmony_ci s8 tuner_sif_gpio; 3438c2ecf20Sopenharmony_ci s8 tuner_scl_gpio; 3448c2ecf20Sopenharmony_ci s8 tuner_sda_gpio; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* PIN ctrl */ 3478c2ecf20Sopenharmony_ci u32 ctl_pin_status_mask; 3488c2ecf20Sopenharmony_ci u8 agc_analog_digital_select_gpio; 3498c2ecf20Sopenharmony_ci u32 gpio_pin_status_mask; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci /* i2c masters */ 3528c2ecf20Sopenharmony_ci u8 tuner_i2c_master; 3538c2ecf20Sopenharmony_ci u8 demod_i2c_master; 3548c2ecf20Sopenharmony_ci u8 ir_i2c_master; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci /* for devices with I2C chips for IR */ 3578c2ecf20Sopenharmony_ci char *rc_map_name; 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci unsigned int max_range_640_480:1; 3608c2ecf20Sopenharmony_ci unsigned int has_dvb:1; 3618c2ecf20Sopenharmony_ci unsigned int has_417:1; 3628c2ecf20Sopenharmony_ci unsigned int valid:1; 3638c2ecf20Sopenharmony_ci unsigned int no_alt_vanc:1; 3648c2ecf20Sopenharmony_ci unsigned int external_av:1; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci unsigned char xclk, i2c_speed; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci enum cx231xx_decoder decoder; 3698c2ecf20Sopenharmony_ci int output_mode; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci struct cx231xx_input input[MAX_CX231XX_INPUT]; 3728c2ecf20Sopenharmony_ci struct cx231xx_input radio; 3738c2ecf20Sopenharmony_ci struct rc_map *ir_codes; 3748c2ecf20Sopenharmony_ci}; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* device states */ 3778c2ecf20Sopenharmony_cienum cx231xx_dev_state { 3788c2ecf20Sopenharmony_ci DEV_INITIALIZED = 0x01, 3798c2ecf20Sopenharmony_ci DEV_DISCONNECTED = 0x02, 3808c2ecf20Sopenharmony_ci}; 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cienum AFE_MODE { 3838c2ecf20Sopenharmony_ci AFE_MODE_LOW_IF, 3848c2ecf20Sopenharmony_ci AFE_MODE_BASEBAND, 3858c2ecf20Sopenharmony_ci AFE_MODE_EU_HI_IF, 3868c2ecf20Sopenharmony_ci AFE_MODE_US_HI_IF, 3878c2ecf20Sopenharmony_ci AFE_MODE_JAPAN_HI_IF 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cienum AUDIO_INPUT { 3918c2ecf20Sopenharmony_ci AUDIO_INPUT_MUTE, 3928c2ecf20Sopenharmony_ci AUDIO_INPUT_LINE, 3938c2ecf20Sopenharmony_ci AUDIO_INPUT_TUNER_TV, 3948c2ecf20Sopenharmony_ci AUDIO_INPUT_SPDIF, 3958c2ecf20Sopenharmony_ci AUDIO_INPUT_TUNER_FM 3968c2ecf20Sopenharmony_ci}; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci#define CX231XX_AUDIO_BUFS 5 3998c2ecf20Sopenharmony_ci#define CX231XX_NUM_AUDIO_PACKETS 16 4008c2ecf20Sopenharmony_ci#define CX231XX_ISO_NUM_AUDIO_PACKETS 64 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci/* cx231xx extensions */ 4038c2ecf20Sopenharmony_ci#define CX231XX_AUDIO 0x10 4048c2ecf20Sopenharmony_ci#define CX231XX_DVB 0x20 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistruct cx231xx_audio { 4078c2ecf20Sopenharmony_ci char name[50]; 4088c2ecf20Sopenharmony_ci char *transfer_buffer[CX231XX_AUDIO_BUFS]; 4098c2ecf20Sopenharmony_ci struct urb *urb[CX231XX_AUDIO_BUFS]; 4108c2ecf20Sopenharmony_ci struct usb_device *udev; 4118c2ecf20Sopenharmony_ci unsigned int capture_transfer_done; 4128c2ecf20Sopenharmony_ci struct snd_pcm_substream *capture_pcm_substream; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci unsigned int hwptr_done_capture; 4158c2ecf20Sopenharmony_ci struct snd_card *sndcard; 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci int users, shutdown; 4188c2ecf20Sopenharmony_ci /* locks */ 4198c2ecf20Sopenharmony_ci spinlock_t slock; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci int alt; /* alternate */ 4228c2ecf20Sopenharmony_ci int max_pkt_size; /* max packet size of isoc transaction */ 4238c2ecf20Sopenharmony_ci int num_alt; /* Number of alternative settings */ 4248c2ecf20Sopenharmony_ci unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 4258c2ecf20Sopenharmony_ci u16 end_point_addr; 4268c2ecf20Sopenharmony_ci}; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_cistruct cx231xx; 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci/*****************************************************************/ 4318c2ecf20Sopenharmony_ci/* set/get i2c */ 4328c2ecf20Sopenharmony_ci/* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ 4338c2ecf20Sopenharmony_ci#define I2C_SPEED_1M 0x0 4348c2ecf20Sopenharmony_ci#define I2C_SPEED_400K 0x1 4358c2ecf20Sopenharmony_ci#define I2C_SPEED_100K 0x2 4368c2ecf20Sopenharmony_ci#define I2C_SPEED_5M 0x3 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci/* 0-- STOP transaction */ 4398c2ecf20Sopenharmony_ci#define I2C_STOP 0x0 4408c2ecf20Sopenharmony_ci/* 1-- do not transmit STOP at end of transaction */ 4418c2ecf20Sopenharmony_ci#define I2C_NOSTOP 0x1 4428c2ecf20Sopenharmony_ci/* 1--allow slave to insert clock wait states */ 4438c2ecf20Sopenharmony_ci#define I2C_SYNC 0x1 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistruct cx231xx_i2c { 4468c2ecf20Sopenharmony_ci struct cx231xx *dev; 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci int nr; 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci /* i2c i/o */ 4518c2ecf20Sopenharmony_ci struct i2c_adapter i2c_adap; 4528c2ecf20Sopenharmony_ci int i2c_rc; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci /* different settings for each bus */ 4558c2ecf20Sopenharmony_ci u8 i2c_period; 4568c2ecf20Sopenharmony_ci u8 i2c_nostop; 4578c2ecf20Sopenharmony_ci u8 i2c_reserve; 4588c2ecf20Sopenharmony_ci}; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_cistruct cx231xx_i2c_xfer_data { 4618c2ecf20Sopenharmony_ci u8 dev_addr; 4628c2ecf20Sopenharmony_ci u8 direction; /* 1 - IN, 0 - OUT */ 4638c2ecf20Sopenharmony_ci u8 saddr_len; /* sub address len */ 4648c2ecf20Sopenharmony_ci u16 saddr_dat; /* sub addr data */ 4658c2ecf20Sopenharmony_ci u8 buf_size; /* buffer size */ 4668c2ecf20Sopenharmony_ci u8 *p_buffer; /* pointer to the buffer */ 4678c2ecf20Sopenharmony_ci}; 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_cistruct VENDOR_REQUEST_IN { 4708c2ecf20Sopenharmony_ci u8 bRequest; 4718c2ecf20Sopenharmony_ci u16 wValue; 4728c2ecf20Sopenharmony_ci u16 wIndex; 4738c2ecf20Sopenharmony_ci u16 wLength; 4748c2ecf20Sopenharmony_ci u8 direction; 4758c2ecf20Sopenharmony_ci u8 bData; 4768c2ecf20Sopenharmony_ci u8 *pBuff; 4778c2ecf20Sopenharmony_ci}; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_cistruct cx231xx_tvnorm { 4808c2ecf20Sopenharmony_ci char *name; 4818c2ecf20Sopenharmony_ci v4l2_std_id id; 4828c2ecf20Sopenharmony_ci u32 cxiformat; 4838c2ecf20Sopenharmony_ci u32 cxoformat; 4848c2ecf20Sopenharmony_ci}; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_cienum TRANSFER_TYPE { 4878c2ecf20Sopenharmony_ci Raw_Video = 0, 4888c2ecf20Sopenharmony_ci Audio, 4898c2ecf20Sopenharmony_ci Vbi, /* VANC */ 4908c2ecf20Sopenharmony_ci Sliced_cc, /* HANC */ 4918c2ecf20Sopenharmony_ci TS1_serial_mode, 4928c2ecf20Sopenharmony_ci TS2, 4938c2ecf20Sopenharmony_ci TS1_parallel_mode 4948c2ecf20Sopenharmony_ci} ; 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_cistruct cx231xx_video_mode { 4978c2ecf20Sopenharmony_ci /* Isoc control struct */ 4988c2ecf20Sopenharmony_ci struct cx231xx_dmaqueue vidq; 4998c2ecf20Sopenharmony_ci struct cx231xx_isoc_ctl isoc_ctl; 5008c2ecf20Sopenharmony_ci struct cx231xx_bulk_ctl bulk_ctl; 5018c2ecf20Sopenharmony_ci /* locks */ 5028c2ecf20Sopenharmony_ci spinlock_t slock; 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci /* usb transfer */ 5058c2ecf20Sopenharmony_ci int alt; /* alternate */ 5068c2ecf20Sopenharmony_ci int max_pkt_size; /* max packet size of isoc transaction */ 5078c2ecf20Sopenharmony_ci int num_alt; /* Number of alternative settings */ 5088c2ecf20Sopenharmony_ci unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 5098c2ecf20Sopenharmony_ci u16 end_point_addr; 5108c2ecf20Sopenharmony_ci}; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_cistruct cx231xx_tsport { 5138c2ecf20Sopenharmony_ci struct cx231xx *dev; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci int nr; 5168c2ecf20Sopenharmony_ci int sram_chno; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci /* dma queues */ 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci u32 ts_packet_size; 5218c2ecf20Sopenharmony_ci u32 ts_packet_count; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci int width; 5248c2ecf20Sopenharmony_ci int height; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci /* locks */ 5278c2ecf20Sopenharmony_ci spinlock_t slock; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci /* registers */ 5308c2ecf20Sopenharmony_ci u32 reg_gpcnt; 5318c2ecf20Sopenharmony_ci u32 reg_gpcnt_ctl; 5328c2ecf20Sopenharmony_ci u32 reg_dma_ctl; 5338c2ecf20Sopenharmony_ci u32 reg_lngth; 5348c2ecf20Sopenharmony_ci u32 reg_hw_sop_ctrl; 5358c2ecf20Sopenharmony_ci u32 reg_gen_ctrl; 5368c2ecf20Sopenharmony_ci u32 reg_bd_pkt_status; 5378c2ecf20Sopenharmony_ci u32 reg_sop_status; 5388c2ecf20Sopenharmony_ci u32 reg_fifo_ovfl_stat; 5398c2ecf20Sopenharmony_ci u32 reg_vld_misc; 5408c2ecf20Sopenharmony_ci u32 reg_ts_clk_en; 5418c2ecf20Sopenharmony_ci u32 reg_ts_int_msk; 5428c2ecf20Sopenharmony_ci u32 reg_ts_int_stat; 5438c2ecf20Sopenharmony_ci u32 reg_src_sel; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci /* Default register vals */ 5468c2ecf20Sopenharmony_ci int pci_irqmask; 5478c2ecf20Sopenharmony_ci u32 dma_ctl_val; 5488c2ecf20Sopenharmony_ci u32 ts_int_msk_val; 5498c2ecf20Sopenharmony_ci u32 gen_ctrl_val; 5508c2ecf20Sopenharmony_ci u32 ts_clk_en_val; 5518c2ecf20Sopenharmony_ci u32 src_sel_val; 5528c2ecf20Sopenharmony_ci u32 vld_misc_val; 5538c2ecf20Sopenharmony_ci u32 hw_sop_ctrl_val; 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci /* Allow a single tsport to have multiple frontends */ 5568c2ecf20Sopenharmony_ci u32 num_frontends; 5578c2ecf20Sopenharmony_ci void *port_priv; 5588c2ecf20Sopenharmony_ci}; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci/* main device struct */ 5618c2ecf20Sopenharmony_cistruct cx231xx { 5628c2ecf20Sopenharmony_ci /* generic device properties */ 5638c2ecf20Sopenharmony_ci char name[30]; /* name (including minor) of the device */ 5648c2ecf20Sopenharmony_ci int model; /* index in the device_data struct */ 5658c2ecf20Sopenharmony_ci int devno; /* marks the number of this device */ 5668c2ecf20Sopenharmony_ci struct device *dev; /* pointer to USB interface's dev */ 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci struct cx231xx_board board; 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci /* For I2C IR support */ 5718c2ecf20Sopenharmony_ci struct IR_i2c_init_data init_data; 5728c2ecf20Sopenharmony_ci struct i2c_client *ir_i2c_client; 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci unsigned int stream_on:1; /* Locks streams */ 5758c2ecf20Sopenharmony_ci unsigned int vbi_stream_on:1; /* Locks streams for VBI */ 5768c2ecf20Sopenharmony_ci unsigned int has_audio_class:1; 5778c2ecf20Sopenharmony_ci unsigned int has_alsa_audio:1; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci unsigned int i2c_scan_running:1; /* true only during i2c_scan */ 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci struct cx231xx_fmt *format; 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci struct v4l2_device v4l2_dev; 5848c2ecf20Sopenharmony_ci struct v4l2_subdev *sd_cx25840; 5858c2ecf20Sopenharmony_ci struct v4l2_subdev *sd_tuner; 5868c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler ctrl_handler; 5878c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler radio_ctrl_handler; 5888c2ecf20Sopenharmony_ci struct cx2341x_handler mpeg_ctrl_handler; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */ 5918c2ecf20Sopenharmony_ci atomic_t stream_started; /* stream should be running if true */ 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci struct list_head devlist; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci int tuner_type; /* type of the tuner */ 5968c2ecf20Sopenharmony_ci int tuner_addr; /* tuner address */ 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ 5998c2ecf20Sopenharmony_ci struct cx231xx_i2c i2c_bus[3]; 6008c2ecf20Sopenharmony_ci struct i2c_mux_core *muxc; 6018c2ecf20Sopenharmony_ci struct i2c_adapter *i2c_mux_adap[2]; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci unsigned int xc_fw_load_done:1; 6048c2ecf20Sopenharmony_ci unsigned int port_3_switch_enabled:1; 6058c2ecf20Sopenharmony_ci /* locks */ 6068c2ecf20Sopenharmony_ci struct mutex gpio_i2c_lock; 6078c2ecf20Sopenharmony_ci struct mutex i2c_lock; 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci /* video for linux */ 6108c2ecf20Sopenharmony_ci int users; /* user count for exclusive use */ 6118c2ecf20Sopenharmony_ci struct video_device vdev; /* video for linux device struct */ 6128c2ecf20Sopenharmony_ci v4l2_std_id norm; /* selected tv norm */ 6138c2ecf20Sopenharmony_ci int ctl_freq; /* selected frequency */ 6148c2ecf20Sopenharmony_ci unsigned int ctl_ainput; /* selected audio input */ 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_ci /* frame properties */ 6178c2ecf20Sopenharmony_ci int width; /* current frame width */ 6188c2ecf20Sopenharmony_ci int height; /* current frame height */ 6198c2ecf20Sopenharmony_ci int interlaced; /* 1=interlace fields, 0=just top fields */ 6208c2ecf20Sopenharmony_ci unsigned int size; 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci struct cx231xx_audio adev; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci /* states */ 6258c2ecf20Sopenharmony_ci enum cx231xx_dev_state state; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci struct work_struct request_module_wk; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci /* locks */ 6308c2ecf20Sopenharmony_ci struct mutex lock; 6318c2ecf20Sopenharmony_ci struct mutex ctrl_urb_lock; /* protects urb_buf */ 6328c2ecf20Sopenharmony_ci struct list_head inqueue, outqueue; 6338c2ecf20Sopenharmony_ci wait_queue_head_t open, wait_frame, wait_stream; 6348c2ecf20Sopenharmony_ci struct video_device vbi_dev; 6358c2ecf20Sopenharmony_ci struct video_device radio_dev; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci#if defined(CONFIG_MEDIA_CONTROLLER) 6388c2ecf20Sopenharmony_ci struct media_device *media_dev; 6398c2ecf20Sopenharmony_ci struct media_pad video_pad, vbi_pad; 6408c2ecf20Sopenharmony_ci struct media_entity input_ent[MAX_CX231XX_INPUT]; 6418c2ecf20Sopenharmony_ci struct media_pad input_pad[MAX_CX231XX_INPUT]; 6428c2ecf20Sopenharmony_ci#endif 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_ci struct vb2_queue vidq; 6458c2ecf20Sopenharmony_ci struct vb2_queue vbiq; 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci unsigned char eedata[256]; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci struct cx231xx_video_mode video_mode; 6508c2ecf20Sopenharmony_ci struct cx231xx_video_mode vbi_mode; 6518c2ecf20Sopenharmony_ci struct cx231xx_video_mode sliced_cc_mode; 6528c2ecf20Sopenharmony_ci struct cx231xx_video_mode ts1_mode; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci atomic_t devlist_count; 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci struct usb_device *udev; /* the usb device */ 6578c2ecf20Sopenharmony_ci char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci /* helper funcs that call usb_control_msg */ 6608c2ecf20Sopenharmony_ci int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, 6618c2ecf20Sopenharmony_ci char *buf, int len); 6628c2ecf20Sopenharmony_ci int (*cx231xx_write_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, 6638c2ecf20Sopenharmony_ci char *buf, int len); 6648c2ecf20Sopenharmony_ci int (*cx231xx_send_usb_command) (struct cx231xx_i2c *i2c_bus, 6658c2ecf20Sopenharmony_ci struct cx231xx_i2c_xfer_data *req_data); 6668c2ecf20Sopenharmony_ci int (*cx231xx_gpio_i2c_read) (struct cx231xx *dev, u8 dev_addr, 6678c2ecf20Sopenharmony_ci u8 *buf, u8 len); 6688c2ecf20Sopenharmony_ci int (*cx231xx_gpio_i2c_write) (struct cx231xx *dev, u8 dev_addr, 6698c2ecf20Sopenharmony_ci u8 *buf, u8 len); 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci int (*cx231xx_set_analog_freq) (struct cx231xx *dev, u32 freq); 6728c2ecf20Sopenharmony_ci int (*cx231xx_reset_analog_tuner) (struct cx231xx *dev); 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_ci enum cx231xx_mode mode; 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci struct cx231xx_dvb *dvb; 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci /* Cx231xx supported PCB config's */ 6798c2ecf20Sopenharmony_ci struct pcb_config current_pcb_config; 6808c2ecf20Sopenharmony_ci u8 current_scenario_idx; 6818c2ecf20Sopenharmony_ci u8 interface_count; 6828c2ecf20Sopenharmony_ci u8 max_iad_interface_count; 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci /* GPIO related register direction and values */ 6858c2ecf20Sopenharmony_ci u32 gpio_dir; 6868c2ecf20Sopenharmony_ci u32 gpio_val; 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci /* Power Modes */ 6898c2ecf20Sopenharmony_ci int power_mode; 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci /* afe parameters */ 6928c2ecf20Sopenharmony_ci enum AFE_MODE afe_mode; 6938c2ecf20Sopenharmony_ci u32 afe_ref_count; 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci /* video related parameters */ 6968c2ecf20Sopenharmony_ci u32 video_input; 6978c2ecf20Sopenharmony_ci u32 active_mode; 6988c2ecf20Sopenharmony_ci u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */ 6998c2ecf20Sopenharmony_ci enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */ 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci /*mode: digital=1 or analog=0*/ 7028c2ecf20Sopenharmony_ci u8 mode_tv; 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci u8 USE_ISO; 7058c2ecf20Sopenharmony_ci struct cx231xx_tvnorm encodernorm; 7068c2ecf20Sopenharmony_ci struct cx231xx_tsport ts1, ts2; 7078c2ecf20Sopenharmony_ci struct vb2_queue mpegq; 7088c2ecf20Sopenharmony_ci struct video_device v4l_device; 7098c2ecf20Sopenharmony_ci atomic_t v4l_reader_count; 7108c2ecf20Sopenharmony_ci u32 freq; 7118c2ecf20Sopenharmony_ci unsigned int input; 7128c2ecf20Sopenharmony_ci u32 cx23417_mailbox; 7138c2ecf20Sopenharmony_ci u32 __iomem *lmmio; 7148c2ecf20Sopenharmony_ci u8 __iomem *bmmio; 7158c2ecf20Sopenharmony_ci}; 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ciextern struct list_head cx231xx_devlist; 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci#define cx25840_call(cx231xx, o, f, args...) \ 7208c2ecf20Sopenharmony_ci v4l2_subdev_call(cx231xx->sd_cx25840, o, f, ##args) 7218c2ecf20Sopenharmony_ci#define tuner_call(cx231xx, o, f, args...) \ 7228c2ecf20Sopenharmony_ci v4l2_subdev_call(cx231xx->sd_tuner, o, f, ##args) 7238c2ecf20Sopenharmony_ci#define call_all(dev, o, f, args...) \ 7248c2ecf20Sopenharmony_ci v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_cistruct cx231xx_ops { 7278c2ecf20Sopenharmony_ci struct list_head next; 7288c2ecf20Sopenharmony_ci char *name; 7298c2ecf20Sopenharmony_ci int id; 7308c2ecf20Sopenharmony_ci int (*init) (struct cx231xx *); 7318c2ecf20Sopenharmony_ci int (*fini) (struct cx231xx *); 7328c2ecf20Sopenharmony_ci}; 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_ci/* call back functions in dvb module */ 7358c2ecf20Sopenharmony_ciint cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq); 7368c2ecf20Sopenharmony_ciint cx231xx_reset_analog_tuner(struct cx231xx *dev); 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci/* Provided by cx231xx-i2c.c */ 7398c2ecf20Sopenharmony_civoid cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port); 7408c2ecf20Sopenharmony_ciint cx231xx_i2c_register(struct cx231xx_i2c *bus); 7418c2ecf20Sopenharmony_civoid cx231xx_i2c_unregister(struct cx231xx_i2c *bus); 7428c2ecf20Sopenharmony_ciint cx231xx_i2c_mux_create(struct cx231xx *dev); 7438c2ecf20Sopenharmony_ciint cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no); 7448c2ecf20Sopenharmony_civoid cx231xx_i2c_mux_unregister(struct cx231xx *dev); 7458c2ecf20Sopenharmony_cistruct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port); 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci/* Internal block control functions */ 7488c2ecf20Sopenharmony_ciint cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, 7498c2ecf20Sopenharmony_ci u8 saddr_len, u32 *data, u8 data_len, int master); 7508c2ecf20Sopenharmony_ciint cx231xx_write_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, 7518c2ecf20Sopenharmony_ci u8 saddr_len, u32 data, u8 data_len, int master); 7528c2ecf20Sopenharmony_ciint cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, 7538c2ecf20Sopenharmony_ci u16 saddr, u8 saddr_len, u32 *data, u8 data_len); 7548c2ecf20Sopenharmony_ciint cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, 7558c2ecf20Sopenharmony_ci u16 saddr, u8 saddr_len, u32 data, u8 data_len); 7568c2ecf20Sopenharmony_ciint cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, 7578c2ecf20Sopenharmony_ci u16 register_address, u8 bit_start, u8 bit_end, 7588c2ecf20Sopenharmony_ci u32 value); 7598c2ecf20Sopenharmony_ciint cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, 7608c2ecf20Sopenharmony_ci u16 saddr, u32 mask, u32 value); 7618c2ecf20Sopenharmony_ciu32 cx231xx_set_field(u32 field_mask, u32 data); 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci/*verve r/w*/ 7648c2ecf20Sopenharmony_civoid initGPIO(struct cx231xx *dev); 7658c2ecf20Sopenharmony_civoid uninitGPIO(struct cx231xx *dev); 7668c2ecf20Sopenharmony_ci/* afe related functions */ 7678c2ecf20Sopenharmony_ciint cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count); 7688c2ecf20Sopenharmony_ciint cx231xx_afe_init_channels(struct cx231xx *dev); 7698c2ecf20Sopenharmony_ciint cx231xx_afe_setup_AFE_for_baseband(struct cx231xx *dev); 7708c2ecf20Sopenharmony_ciint cx231xx_afe_set_input_mux(struct cx231xx *dev, u32 input_mux); 7718c2ecf20Sopenharmony_ciint cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode); 7728c2ecf20Sopenharmony_ciint cx231xx_afe_update_power_control(struct cx231xx *dev, 7738c2ecf20Sopenharmony_ci enum AV_MODE avmode); 7748c2ecf20Sopenharmony_ciint cx231xx_afe_adjust_ref_count(struct cx231xx *dev, u32 video_input); 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci/* i2s block related functions */ 7778c2ecf20Sopenharmony_ciint cx231xx_i2s_blk_initialize(struct cx231xx *dev); 7788c2ecf20Sopenharmony_ciint cx231xx_i2s_blk_update_power_control(struct cx231xx *dev, 7798c2ecf20Sopenharmony_ci enum AV_MODE avmode); 7808c2ecf20Sopenharmony_ciint cx231xx_i2s_blk_set_audio_input(struct cx231xx *dev, u8 audio_input); 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci/* DIF related functions */ 7838c2ecf20Sopenharmony_ciint cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, 7848c2ecf20Sopenharmony_ci u32 function_mode, u32 standard); 7858c2ecf20Sopenharmony_civoid cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, 7868c2ecf20Sopenharmony_ci u8 spectral_invert, u32 mode); 7878c2ecf20Sopenharmony_ciu32 cx231xx_Get_Colibri_CarrierOffset(u32 mode, u32 standerd); 7888c2ecf20Sopenharmony_civoid cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, 7898c2ecf20Sopenharmony_ci u8 spectral_invert, u32 mode); 7908c2ecf20Sopenharmony_civoid cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev); 7918c2ecf20Sopenharmony_civoid reset_s5h1432_demod(struct cx231xx *dev); 7928c2ecf20Sopenharmony_civoid cx231xx_dump_HH_reg(struct cx231xx *dev); 7938c2ecf20Sopenharmony_civoid update_HH_register_after_set_DIF(struct cx231xx *dev); 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ciint cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard); 7988c2ecf20Sopenharmony_ciint cx231xx_tuner_pre_channel_change(struct cx231xx *dev); 7998c2ecf20Sopenharmony_ciint cx231xx_tuner_post_channel_change(struct cx231xx *dev); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci/* video parser functions */ 8028c2ecf20Sopenharmony_ciu8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, 8038c2ecf20Sopenharmony_ci u32 *p_bytes_used); 8048c2ecf20Sopenharmony_ciu8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, 8058c2ecf20Sopenharmony_ci u32 *p_bytes_used); 8068c2ecf20Sopenharmony_ciint cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 8078c2ecf20Sopenharmony_ci u8 *p_buffer, u32 bytes_to_copy); 8088c2ecf20Sopenharmony_civoid cx231xx_reset_video_buffer(struct cx231xx *dev, 8098c2ecf20Sopenharmony_ci struct cx231xx_dmaqueue *dma_q); 8108c2ecf20Sopenharmony_ciu8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q); 8118c2ecf20Sopenharmony_ciu32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 8128c2ecf20Sopenharmony_ci u8 *p_line, u32 length, int field_number); 8138c2ecf20Sopenharmony_ciu32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 8148c2ecf20Sopenharmony_ci u8 sav_eav, u8 *p_buffer, u32 buffer_size); 8158c2ecf20Sopenharmony_civoid cx231xx_swab(u16 *from, u16 *to, u16 len); 8168c2ecf20Sopenharmony_ci 8178c2ecf20Sopenharmony_ci/* Provided by cx231xx-core.c */ 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ciu32 cx231xx_request_buffers(struct cx231xx *dev, u32 count); 8208c2ecf20Sopenharmony_civoid cx231xx_queue_unusedframes(struct cx231xx *dev); 8218c2ecf20Sopenharmony_civoid cx231xx_release_buffers(struct cx231xx *dev); 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_ci/* read from control pipe */ 8248c2ecf20Sopenharmony_ciint cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, 8258c2ecf20Sopenharmony_ci char *buf, int len); 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci/* write to control pipe */ 8288c2ecf20Sopenharmony_ciint cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, 8298c2ecf20Sopenharmony_ci char *buf, int len); 8308c2ecf20Sopenharmony_ciint cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode); 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ciint cx231xx_send_vendor_cmd(struct cx231xx *dev, 8338c2ecf20Sopenharmony_ci struct VENDOR_REQUEST_IN *ven_req); 8348c2ecf20Sopenharmony_ciint cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, 8358c2ecf20Sopenharmony_ci struct cx231xx_i2c_xfer_data *req_data); 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_ci/* Gpio related functions */ 8388c2ecf20Sopenharmony_ciint cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, 8398c2ecf20Sopenharmony_ci u8 len, u8 request, u8 direction); 8408c2ecf20Sopenharmony_ciint cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value); 8418c2ecf20Sopenharmony_ciint cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number, 8428c2ecf20Sopenharmony_ci int pin_value); 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_start(struct cx231xx *dev); 8458c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_end(struct cx231xx *dev); 8468c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data); 8478c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf); 8488c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_read_ack(struct cx231xx *dev); 8498c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_write_ack(struct cx231xx *dev); 8508c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_write_nak(struct cx231xx *dev); 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); 8538c2ecf20Sopenharmony_ciint cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_ci/* audio related functions */ 8568c2ecf20Sopenharmony_ciint cx231xx_set_audio_decoder_input(struct cx231xx *dev, 8578c2ecf20Sopenharmony_ci enum AUDIO_INPUT audio_input); 8588c2ecf20Sopenharmony_ci 8598c2ecf20Sopenharmony_ciint cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type); 8608c2ecf20Sopenharmony_ciint cx231xx_set_video_alternate(struct cx231xx *dev); 8618c2ecf20Sopenharmony_ciint cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt); 8628c2ecf20Sopenharmony_ciint is_fw_load(struct cx231xx *dev); 8638c2ecf20Sopenharmony_ciint cx231xx_check_fw(struct cx231xx *dev); 8648c2ecf20Sopenharmony_ciint cx231xx_init_isoc(struct cx231xx *dev, int max_packets, 8658c2ecf20Sopenharmony_ci int num_bufs, int max_pkt_size, 8668c2ecf20Sopenharmony_ci int (*isoc_copy) (struct cx231xx *dev, 8678c2ecf20Sopenharmony_ci struct urb *urb)); 8688c2ecf20Sopenharmony_ciint cx231xx_init_bulk(struct cx231xx *dev, int max_packets, 8698c2ecf20Sopenharmony_ci int num_bufs, int max_pkt_size, 8708c2ecf20Sopenharmony_ci int (*bulk_copy) (struct cx231xx *dev, 8718c2ecf20Sopenharmony_ci struct urb *urb)); 8728c2ecf20Sopenharmony_civoid cx231xx_stop_TS1(struct cx231xx *dev); 8738c2ecf20Sopenharmony_civoid cx231xx_start_TS1(struct cx231xx *dev); 8748c2ecf20Sopenharmony_civoid cx231xx_uninit_isoc(struct cx231xx *dev); 8758c2ecf20Sopenharmony_civoid cx231xx_uninit_bulk(struct cx231xx *dev); 8768c2ecf20Sopenharmony_ciint cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode); 8778c2ecf20Sopenharmony_ciint cx231xx_unmute_audio(struct cx231xx *dev); 8788c2ecf20Sopenharmony_ciint cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size); 8798c2ecf20Sopenharmony_civoid cx231xx_disable656(struct cx231xx *dev); 8808c2ecf20Sopenharmony_civoid cx231xx_enable656(struct cx231xx *dev); 8818c2ecf20Sopenharmony_ciint cx231xx_demod_reset(struct cx231xx *dev); 8828c2ecf20Sopenharmony_ciint cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio); 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ci/* Device list functions */ 8858c2ecf20Sopenharmony_civoid cx231xx_release_resources(struct cx231xx *dev); 8868c2ecf20Sopenharmony_civoid cx231xx_release_analog_resources(struct cx231xx *dev); 8878c2ecf20Sopenharmony_ciint cx231xx_register_analog_devices(struct cx231xx *dev); 8888c2ecf20Sopenharmony_civoid cx231xx_remove_from_devlist(struct cx231xx *dev); 8898c2ecf20Sopenharmony_civoid cx231xx_add_into_devlist(struct cx231xx *dev); 8908c2ecf20Sopenharmony_civoid cx231xx_init_extension(struct cx231xx *dev); 8918c2ecf20Sopenharmony_civoid cx231xx_close_extension(struct cx231xx *dev); 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci/* hardware init functions */ 8948c2ecf20Sopenharmony_ciint cx231xx_dev_init(struct cx231xx *dev); 8958c2ecf20Sopenharmony_civoid cx231xx_dev_uninit(struct cx231xx *dev); 8968c2ecf20Sopenharmony_civoid cx231xx_config_i2c(struct cx231xx *dev); 8978c2ecf20Sopenharmony_ciint cx231xx_config(struct cx231xx *dev); 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ci/* Stream control functions */ 9008c2ecf20Sopenharmony_ciint cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask); 9018c2ecf20Sopenharmony_ciint cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask); 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ciint cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type); 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci/* Power control functions */ 9068c2ecf20Sopenharmony_ciint cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode); 9078c2ecf20Sopenharmony_ciint cx231xx_power_suspend(struct cx231xx *dev); 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_ci/* chip specific control functions */ 9108c2ecf20Sopenharmony_ciint cx231xx_init_ctrl_pin_status(struct cx231xx *dev); 9118c2ecf20Sopenharmony_ciint cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, 9128c2ecf20Sopenharmony_ci u8 analog_or_digital); 9138c2ecf20Sopenharmony_ciint cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3); 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_ci/* video audio decoder related functions */ 9168c2ecf20Sopenharmony_civoid video_mux(struct cx231xx *dev, int index); 9178c2ecf20Sopenharmony_ciint cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input); 9188c2ecf20Sopenharmony_ciint cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input); 9198c2ecf20Sopenharmony_ciint cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); 9208c2ecf20Sopenharmony_ciint cx231xx_set_audio_input(struct cx231xx *dev, u8 input); 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci/* Provided by cx231xx-video.c */ 9238c2ecf20Sopenharmony_ciint cx231xx_register_extension(struct cx231xx_ops *dev); 9248c2ecf20Sopenharmony_civoid cx231xx_unregister_extension(struct cx231xx_ops *dev); 9258c2ecf20Sopenharmony_civoid cx231xx_init_extension(struct cx231xx *dev); 9268c2ecf20Sopenharmony_civoid cx231xx_close_extension(struct cx231xx *dev); 9278c2ecf20Sopenharmony_civoid cx231xx_v4l2_create_entities(struct cx231xx *dev); 9288c2ecf20Sopenharmony_ciint cx231xx_querycap(struct file *file, void *priv, 9298c2ecf20Sopenharmony_ci struct v4l2_capability *cap); 9308c2ecf20Sopenharmony_ciint cx231xx_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t); 9318c2ecf20Sopenharmony_ciint cx231xx_s_tuner(struct file *file, void *priv, const struct v4l2_tuner *t); 9328c2ecf20Sopenharmony_ciint cx231xx_g_frequency(struct file *file, void *priv, 9338c2ecf20Sopenharmony_ci struct v4l2_frequency *f); 9348c2ecf20Sopenharmony_ciint cx231xx_s_frequency(struct file *file, void *priv, 9358c2ecf20Sopenharmony_ci const struct v4l2_frequency *f); 9368c2ecf20Sopenharmony_ciint cx231xx_enum_input(struct file *file, void *priv, 9378c2ecf20Sopenharmony_ci struct v4l2_input *i); 9388c2ecf20Sopenharmony_ciint cx231xx_g_input(struct file *file, void *priv, unsigned int *i); 9398c2ecf20Sopenharmony_ciint cx231xx_s_input(struct file *file, void *priv, unsigned int i); 9408c2ecf20Sopenharmony_ciint cx231xx_g_chip_info(struct file *file, void *fh, struct v4l2_dbg_chip_info *chip); 9418c2ecf20Sopenharmony_ciint cx231xx_g_register(struct file *file, void *priv, 9428c2ecf20Sopenharmony_ci struct v4l2_dbg_register *reg); 9438c2ecf20Sopenharmony_ciint cx231xx_s_register(struct file *file, void *priv, 9448c2ecf20Sopenharmony_ci const struct v4l2_dbg_register *reg); 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci/* Provided by cx231xx-cards.c */ 9478c2ecf20Sopenharmony_ciextern void cx231xx_pre_card_setup(struct cx231xx *dev); 9488c2ecf20Sopenharmony_ciextern void cx231xx_card_setup(struct cx231xx *dev); 9498c2ecf20Sopenharmony_ciextern struct cx231xx_board cx231xx_boards[]; 9508c2ecf20Sopenharmony_ciextern struct usb_device_id cx231xx_id_table[]; 9518c2ecf20Sopenharmony_ciextern const unsigned int cx231xx_bcount; 9528c2ecf20Sopenharmony_ciint cx231xx_tuner_callback(void *ptr, int component, int command, int arg); 9538c2ecf20Sopenharmony_ci 9548c2ecf20Sopenharmony_ci/* cx23885-417.c */ 9558c2ecf20Sopenharmony_ciextern int cx231xx_417_register(struct cx231xx *dev); 9568c2ecf20Sopenharmony_ciextern void cx231xx_417_unregister(struct cx231xx *dev); 9578c2ecf20Sopenharmony_ci 9588c2ecf20Sopenharmony_ci/* cx23885-input.c */ 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_ci#if defined(CONFIG_VIDEO_CX231XX_RC) 9618c2ecf20Sopenharmony_ciint cx231xx_ir_init(struct cx231xx *dev); 9628c2ecf20Sopenharmony_civoid cx231xx_ir_exit(struct cx231xx *dev); 9638c2ecf20Sopenharmony_ci#else 9648c2ecf20Sopenharmony_cistatic inline int cx231xx_ir_init(struct cx231xx *dev) 9658c2ecf20Sopenharmony_ci{ 9668c2ecf20Sopenharmony_ci return 0; 9678c2ecf20Sopenharmony_ci} 9688c2ecf20Sopenharmony_cistatic inline void cx231xx_ir_exit(struct cx231xx *dev) {} 9698c2ecf20Sopenharmony_ci#endif 9708c2ecf20Sopenharmony_ci 9718c2ecf20Sopenharmony_cistatic inline unsigned int norm_maxw(struct cx231xx *dev) 9728c2ecf20Sopenharmony_ci{ 9738c2ecf20Sopenharmony_ci if (dev->board.max_range_640_480) 9748c2ecf20Sopenharmony_ci return 640; 9758c2ecf20Sopenharmony_ci else 9768c2ecf20Sopenharmony_ci return 720; 9778c2ecf20Sopenharmony_ci} 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_cistatic inline unsigned int norm_maxh(struct cx231xx *dev) 9808c2ecf20Sopenharmony_ci{ 9818c2ecf20Sopenharmony_ci if (dev->board.max_range_640_480) 9828c2ecf20Sopenharmony_ci return 480; 9838c2ecf20Sopenharmony_ci else 9848c2ecf20Sopenharmony_ci return (dev->norm & V4L2_STD_625_50) ? 576 : 480; 9858c2ecf20Sopenharmony_ci} 9868c2ecf20Sopenharmony_ci#endif 987