1b285192aSMauro Carvalho Chehab /* 2b285192aSMauro Carvalho Chehab * 3b285192aSMauro Carvalho Chehab * v4l2 device driver for cx2388x based TV cards 4b285192aSMauro Carvalho Chehab * 5b285192aSMauro Carvalho Chehab * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 6b285192aSMauro Carvalho Chehab * 7b285192aSMauro Carvalho Chehab * This program is free software; you can redistribute it and/or modify 8b285192aSMauro Carvalho Chehab * it under the terms of the GNU General Public License as published by 9b285192aSMauro Carvalho Chehab * the Free Software Foundation; either version 2 of the License, or 10b285192aSMauro Carvalho Chehab * (at your option) any later version. 11b285192aSMauro Carvalho Chehab * 12b285192aSMauro Carvalho Chehab * This program is distributed in the hope that it will be useful, 13b285192aSMauro Carvalho Chehab * but WITHOUT ANY WARRANTY; without even the implied warranty of 14b285192aSMauro Carvalho Chehab * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15b285192aSMauro Carvalho Chehab * GNU General Public License for more details. 16b285192aSMauro Carvalho Chehab * 17b285192aSMauro Carvalho Chehab * You should have received a copy of the GNU General Public License 18b285192aSMauro Carvalho Chehab * along with this program; if not, write to the Free Software 19b285192aSMauro Carvalho Chehab * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20b285192aSMauro Carvalho Chehab */ 21b285192aSMauro Carvalho Chehab 22b285192aSMauro Carvalho Chehab #include <linux/pci.h> 23b285192aSMauro Carvalho Chehab #include <linux/i2c.h> 24b285192aSMauro Carvalho Chehab #include <linux/i2c-algo-bit.h> 25b285192aSMauro Carvalho Chehab #include <linux/videodev2.h> 26b285192aSMauro Carvalho Chehab #include <linux/kdev_t.h> 27b285192aSMauro Carvalho Chehab 28b285192aSMauro Carvalho Chehab #include <media/v4l2-device.h> 29b285192aSMauro Carvalho Chehab #include <media/v4l2-fh.h> 30b285192aSMauro Carvalho Chehab #include <media/tuner.h> 31b285192aSMauro Carvalho Chehab #include <media/tveeprom.h> 320b6b6302SHans Verkuil #include <media/videobuf2-dma-sg.h> 33b285192aSMauro Carvalho Chehab #include <media/cx2341x.h> 340b6b6302SHans Verkuil #include <media/videobuf2-dvb.h> 35b285192aSMauro Carvalho Chehab #include <media/ir-kbd-i2c.h> 36b285192aSMauro Carvalho Chehab #include <media/wm8775.h> 37b285192aSMauro Carvalho Chehab 38b285192aSMauro Carvalho Chehab #include "cx88-reg.h" 39b285192aSMauro Carvalho Chehab #include "tuner-xc2028.h" 40b285192aSMauro Carvalho Chehab 41b285192aSMauro Carvalho Chehab #include <linux/mutex.h> 42b285192aSMauro Carvalho Chehab 430b6b6302SHans Verkuil #define CX88_VERSION "1.0.0" 44b285192aSMauro Carvalho Chehab 45b285192aSMauro Carvalho Chehab #define UNSET (-1U) 46b285192aSMauro Carvalho Chehab 47b285192aSMauro Carvalho Chehab #define CX88_MAXBOARDS 8 48b285192aSMauro Carvalho Chehab 49b285192aSMauro Carvalho Chehab /* Max number of inputs by card */ 50b285192aSMauro Carvalho Chehab #define MAX_CX88_INPUT 8 51b285192aSMauro Carvalho Chehab 52b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 53b285192aSMauro Carvalho Chehab /* defines and enums */ 54b285192aSMauro Carvalho Chehab 55b285192aSMauro Carvalho Chehab /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */ 56b285192aSMauro Carvalho Chehab #define CX88_NORMS (V4L2_STD_ALL \ 57b285192aSMauro Carvalho Chehab & ~V4L2_STD_PAL_H \ 58b285192aSMauro Carvalho Chehab & ~V4L2_STD_NTSC_M_KR \ 59b285192aSMauro Carvalho Chehab & ~V4L2_STD_SECAM_LC) 60b285192aSMauro Carvalho Chehab 61b285192aSMauro Carvalho Chehab #define FORMAT_FLAGS_PACKED 0x01 62b285192aSMauro Carvalho Chehab #define FORMAT_FLAGS_PLANAR 0x02 63b285192aSMauro Carvalho Chehab 64b285192aSMauro Carvalho Chehab #define VBI_LINE_COUNT 17 65b285192aSMauro Carvalho Chehab #define VBI_LINE_LENGTH 2048 66b285192aSMauro Carvalho Chehab 67b285192aSMauro Carvalho Chehab #define AUD_RDS_LINES 4 68b285192aSMauro Carvalho Chehab 69b285192aSMauro Carvalho Chehab /* need "shadow" registers for some write-only ones ... */ 70b285192aSMauro Carvalho Chehab #define SHADOW_AUD_VOL_CTL 1 71b285192aSMauro Carvalho Chehab #define SHADOW_AUD_BAL_CTL 2 72b285192aSMauro Carvalho Chehab #define SHADOW_MAX 3 73b285192aSMauro Carvalho Chehab 74b285192aSMauro Carvalho Chehab /* FM Radio deemphasis type */ 75b285192aSMauro Carvalho Chehab enum cx88_deemph_type { 76b285192aSMauro Carvalho Chehab FM_NO_DEEMPH = 0, 77b285192aSMauro Carvalho Chehab FM_DEEMPH_50, 78b285192aSMauro Carvalho Chehab FM_DEEMPH_75 79b285192aSMauro Carvalho Chehab }; 80b285192aSMauro Carvalho Chehab 81b285192aSMauro Carvalho Chehab enum cx88_board_type { 82b285192aSMauro Carvalho Chehab CX88_BOARD_NONE = 0, 83b285192aSMauro Carvalho Chehab CX88_MPEG_DVB, 84b285192aSMauro Carvalho Chehab CX88_MPEG_BLACKBIRD 85b285192aSMauro Carvalho Chehab }; 86b285192aSMauro Carvalho Chehab 87b285192aSMauro Carvalho Chehab enum cx8802_board_access { 88b285192aSMauro Carvalho Chehab CX8802_DRVCTL_SHARED = 1, 89b285192aSMauro Carvalho Chehab CX8802_DRVCTL_EXCLUSIVE = 2, 90b285192aSMauro Carvalho Chehab }; 91b285192aSMauro Carvalho Chehab 92b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 93b285192aSMauro Carvalho Chehab /* tv norms */ 94b285192aSMauro Carvalho Chehab 9534206439SMauro Carvalho Chehab static inline unsigned int norm_maxw(v4l2_std_id norm) 96b285192aSMauro Carvalho Chehab { 970b6b6302SHans Verkuil return 720; 98b285192aSMauro Carvalho Chehab } 99b285192aSMauro Carvalho Chehab 100b285192aSMauro Carvalho Chehab 10134206439SMauro Carvalho Chehab static inline unsigned int norm_maxh(v4l2_std_id norm) 102b285192aSMauro Carvalho Chehab { 1030b6b6302SHans Verkuil return (norm & V4L2_STD_525_60) ? 480 : 576; 104b285192aSMauro Carvalho Chehab } 105b285192aSMauro Carvalho Chehab 106b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 107b285192aSMauro Carvalho Chehab /* static data */ 108b285192aSMauro Carvalho Chehab 109b285192aSMauro Carvalho Chehab struct cx8800_fmt { 110b285192aSMauro Carvalho Chehab const char *name; 111b285192aSMauro Carvalho Chehab u32 fourcc; /* v4l2 format id */ 112b285192aSMauro Carvalho Chehab int depth; 113b285192aSMauro Carvalho Chehab int flags; 114b285192aSMauro Carvalho Chehab u32 cxformat; 115b285192aSMauro Carvalho Chehab }; 116b285192aSMauro Carvalho Chehab 117b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 118b285192aSMauro Carvalho Chehab /* SRAM memory management data (see cx88-core.c) */ 119b285192aSMauro Carvalho Chehab 120b285192aSMauro Carvalho Chehab #define SRAM_CH21 0 /* video */ 121b285192aSMauro Carvalho Chehab #define SRAM_CH22 1 122b285192aSMauro Carvalho Chehab #define SRAM_CH23 2 123b285192aSMauro Carvalho Chehab #define SRAM_CH24 3 /* vbi */ 124b285192aSMauro Carvalho Chehab #define SRAM_CH25 4 /* audio */ 125b285192aSMauro Carvalho Chehab #define SRAM_CH26 5 126b285192aSMauro Carvalho Chehab #define SRAM_CH28 6 /* mpeg */ 127b285192aSMauro Carvalho Chehab #define SRAM_CH27 7 /* audio rds */ 128b285192aSMauro Carvalho Chehab /* more */ 129b285192aSMauro Carvalho Chehab 130b285192aSMauro Carvalho Chehab struct sram_channel { 131b285192aSMauro Carvalho Chehab const char *name; 132b285192aSMauro Carvalho Chehab u32 cmds_start; 133b285192aSMauro Carvalho Chehab u32 ctrl_start; 134b285192aSMauro Carvalho Chehab u32 cdt; 135b285192aSMauro Carvalho Chehab u32 fifo_start; 136b285192aSMauro Carvalho Chehab u32 fifo_size; 137b285192aSMauro Carvalho Chehab u32 ptr1_reg; 138b285192aSMauro Carvalho Chehab u32 ptr2_reg; 139b285192aSMauro Carvalho Chehab u32 cnt1_reg; 140b285192aSMauro Carvalho Chehab u32 cnt2_reg; 141b285192aSMauro Carvalho Chehab }; 142b285192aSMauro Carvalho Chehab extern const struct sram_channel cx88_sram_channels[]; 143b285192aSMauro Carvalho Chehab 144b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 145b285192aSMauro Carvalho Chehab /* card configuration */ 146b285192aSMauro Carvalho Chehab 147b285192aSMauro Carvalho Chehab #define CX88_BOARD_NOAUTO UNSET 148b285192aSMauro Carvalho Chehab #define CX88_BOARD_UNKNOWN 0 149b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE 1 150b285192aSMauro Carvalho Chehab #define CX88_BOARD_GDI 2 151b285192aSMauro Carvalho Chehab #define CX88_BOARD_PIXELVIEW 3 152b285192aSMauro Carvalho Chehab #define CX88_BOARD_ATI_WONDER_PRO 4 153b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST2000XP_EXPERT 5 154b285192aSMauro Carvalho Chehab #define CX88_BOARD_AVERTV_STUDIO_303 6 155b285192aSMauro Carvalho Chehab #define CX88_BOARD_MSI_TVANYWHERE_MASTER 7 156b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DV2000 8 157b285192aSMauro Carvalho Chehab #define CX88_BOARD_LEADTEK_PVR2000 9 158b285192aSMauro Carvalho Chehab #define CX88_BOARD_IODATA_GVVCP3PCI 10 159b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROLINK_PLAYTVPVR 11 160b285192aSMauro Carvalho Chehab #define CX88_BOARD_ASUS_PVR_416 12 161b285192aSMauro Carvalho Chehab #define CX88_BOARD_MSI_TVANYWHERE 13 162b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_DVB_T 14 163b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15 164b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_LTV883 16 165b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q 17 166b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_DVB_T1 18 167b285192aSMauro Carvalho Chehab #define CX88_BOARD_CONEXANT_DVB_T1 19 168b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROVIDEO_PV259 20 169b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21 170b285192aSMauro Carvalho Chehab #define CX88_BOARD_PCHDTV_HD3000 22 171b285192aSMauro Carvalho Chehab #define CX88_BOARD_DNTV_LIVE_DVB_T 23 172b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_ROSLYN 24 173b285192aSMauro Carvalho Chehab #define CX88_BOARD_DIGITALLOGIC_MEC 25 174b285192aSMauro Carvalho Chehab #define CX88_BOARD_IODATA_GVBCTV7E 26 175b285192aSMauro Carvalho Chehab #define CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO 27 176b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28 177b285192aSMauro Carvalho Chehab #define CX88_BOARD_ADSTECH_DVB_T_PCI 29 178b285192aSMauro Carvalho Chehab #define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 30 179b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD 31 180b285192aSMauro Carvalho Chehab #define CX88_BOARD_AVERMEDIA_ULTRATV_MC_550 32 181b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_VSTREAM_EXPERT_DVD 33 182b285192aSMauro Carvalho Chehab #define CX88_BOARD_ATI_HDTVWONDER 34 183b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV1000 35 184b285192aSMauro Carvalho Chehab #define CX88_BOARD_AVERTV_303 36 185b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1 37 186b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_NOVASE2_S1 38 187b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_DVBS_100 39 188b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR1100 40 189b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR1100LP 41 190b285192aSMauro Carvalho Chehab #define CX88_BOARD_DNTV_LIVE_DVB_T_PRO 42 191b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_DVB_T_CX22702 43 192b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44 193b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45 194b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46 195b285192aSMauro Carvalho Chehab #define CX88_BOARD_PCHDTV_HD5500 47 196b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_MCE200_DELUXE 48 197b285192aSMauro Carvalho Chehab #define CX88_BOARD_PIXELVIEW_PLAYTV_P7000 49 198b285192aSMauro Carvalho Chehab #define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50 199b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV2000H 51 200b285192aSMauro Carvalho Chehab #define CX88_BOARD_GENIATECH_DVBS 52 201b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR3000 53 202b285192aSMauro Carvalho Chehab #define CX88_BOARD_NORWOOD_MICRO 54 203b285192aSMauro Carvalho Chehab #define CX88_BOARD_TE_DTV_250_OEM_SWANN 55 204b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR1300 56 205b285192aSMauro Carvalho Chehab #define CX88_BOARD_ADSTECH_PTV_390 57 206b285192aSMauro Carvalho Chehab #define CX88_BOARD_PINNACLE_PCTV_HD_800i 58 207b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO 59 208b285192aSMauro Carvalho Chehab #define CX88_BOARD_PINNACLE_HYBRID_PCTV 60 209b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_TV2000_XP_GLOBAL 61 210b285192aSMauro Carvalho Chehab #define CX88_BOARD_POWERCOLOR_REAL_ANGEL 62 211b285192aSMauro Carvalho Chehab #define CX88_BOARD_GENIATECH_X8000_MT 63 212b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO 64 213b285192aSMauro Carvalho Chehab #define CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD 65 214b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROLINK_PV_8000GT 66 215b285192aSMauro Carvalho Chehab #define CX88_BOARD_KWORLD_ATSC_120 67 216b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR4000 68 217b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_HVR4000LITE 69 218b285192aSMauro Carvalho Chehab #define CX88_BOARD_TEVII_S460 70 219b285192aSMauro Carvalho Chehab #define CX88_BOARD_OMICOM_SS4_PCI 71 220b285192aSMauro Carvalho Chehab #define CX88_BOARD_TBS_8920 72 221b285192aSMauro Carvalho Chehab #define CX88_BOARD_TEVII_S420 73 222b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROLINK_PV_GLOBAL_XTREME 74 223b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROF_7300 75 224b285192aSMauro Carvalho Chehab #define CX88_BOARD_SATTRADE_ST4200 76 225b285192aSMauro Carvalho Chehab #define CX88_BOARD_TBS_8910 77 226b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROF_6200 78 227b285192aSMauro Carvalho Chehab #define CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII 79 228b285192aSMauro Carvalho Chehab #define CX88_BOARD_HAUPPAUGE_IRONLY 80 229b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV1800H 81 230b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV2000H_J 82 231b285192aSMauro Carvalho Chehab #define CX88_BOARD_PROF_7301 83 232b285192aSMauro Carvalho Chehab #define CX88_BOARD_SAMSUNG_SMT_7020 84 233b285192aSMauro Carvalho Chehab #define CX88_BOARD_TWINHAN_VP1027_DVBS 85 234b285192aSMauro Carvalho Chehab #define CX88_BOARD_TEVII_S464 86 235b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV2000H_PLUS 87 236b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_DTV1800H_XC4000 88 237b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_TV2000_XP_GLOBAL_6F36 89 238b285192aSMauro Carvalho Chehab #define CX88_BOARD_WINFAST_TV2000_XP_GLOBAL_6F43 90 239b285192aSMauro Carvalho Chehab 240b285192aSMauro Carvalho Chehab enum cx88_itype { 241b285192aSMauro Carvalho Chehab CX88_VMUX_COMPOSITE1 = 1, 242b285192aSMauro Carvalho Chehab CX88_VMUX_COMPOSITE2, 243b285192aSMauro Carvalho Chehab CX88_VMUX_COMPOSITE3, 244b285192aSMauro Carvalho Chehab CX88_VMUX_COMPOSITE4, 245b285192aSMauro Carvalho Chehab CX88_VMUX_SVIDEO, 246b285192aSMauro Carvalho Chehab CX88_VMUX_TELEVISION, 247b285192aSMauro Carvalho Chehab CX88_VMUX_CABLE, 248b285192aSMauro Carvalho Chehab CX88_VMUX_DVB, 249b285192aSMauro Carvalho Chehab CX88_VMUX_DEBUG, 250b285192aSMauro Carvalho Chehab CX88_RADIO, 251b285192aSMauro Carvalho Chehab }; 252b285192aSMauro Carvalho Chehab 253b285192aSMauro Carvalho Chehab struct cx88_input { 254b285192aSMauro Carvalho Chehab enum cx88_itype type; 255b285192aSMauro Carvalho Chehab u32 gpio0, gpio1, gpio2, gpio3; 256b285192aSMauro Carvalho Chehab unsigned int vmux:2; 257b285192aSMauro Carvalho Chehab unsigned int audioroute:4; 258b285192aSMauro Carvalho Chehab }; 259b285192aSMauro Carvalho Chehab 260facd2366SHans Verkuil enum cx88_audio_chip { 261f66b2a1cSHans Verkuil CX88_AUDIO_WM8775 = 1, 262facd2366SHans Verkuil CX88_AUDIO_TVAUDIO, 263facd2366SHans Verkuil }; 264facd2366SHans Verkuil 265b285192aSMauro Carvalho Chehab struct cx88_board { 266b285192aSMauro Carvalho Chehab const char *name; 267b285192aSMauro Carvalho Chehab unsigned int tuner_type; 268b285192aSMauro Carvalho Chehab unsigned int radio_type; 269b285192aSMauro Carvalho Chehab unsigned char tuner_addr; 270b285192aSMauro Carvalho Chehab unsigned char radio_addr; 271b285192aSMauro Carvalho Chehab int tda9887_conf; 272b285192aSMauro Carvalho Chehab struct cx88_input input[MAX_CX88_INPUT]; 273b285192aSMauro Carvalho Chehab struct cx88_input radio; 274b285192aSMauro Carvalho Chehab enum cx88_board_type mpeg; 275facd2366SHans Verkuil enum cx88_audio_chip audio_chip; 276b285192aSMauro Carvalho Chehab int num_frontends; 277b285192aSMauro Carvalho Chehab 278b285192aSMauro Carvalho Chehab /* Used for I2S devices */ 279b285192aSMauro Carvalho Chehab int i2sinputcntl; 280b285192aSMauro Carvalho Chehab }; 281b285192aSMauro Carvalho Chehab 282b285192aSMauro Carvalho Chehab struct cx88_subid { 283b285192aSMauro Carvalho Chehab u16 subvendor; 284b285192aSMauro Carvalho Chehab u16 subdevice; 285b285192aSMauro Carvalho Chehab u32 card; 286b285192aSMauro Carvalho Chehab }; 287b285192aSMauro Carvalho Chehab 288b285192aSMauro Carvalho Chehab enum cx88_tvaudio { 289b285192aSMauro Carvalho Chehab WW_NONE = 1, 290b285192aSMauro Carvalho Chehab WW_BTSC, 291b285192aSMauro Carvalho Chehab WW_BG, 292b285192aSMauro Carvalho Chehab WW_DK, 293b285192aSMauro Carvalho Chehab WW_I, 294b285192aSMauro Carvalho Chehab WW_L, 295b285192aSMauro Carvalho Chehab WW_EIAJ, 296b285192aSMauro Carvalho Chehab WW_I2SPT, 297b285192aSMauro Carvalho Chehab WW_FM, 298b285192aSMauro Carvalho Chehab WW_I2SADC, 299b285192aSMauro Carvalho Chehab WW_M 300b285192aSMauro Carvalho Chehab }; 301b285192aSMauro Carvalho Chehab 302b285192aSMauro Carvalho Chehab #define INPUT(nr) (core->board.input[nr]) 303b285192aSMauro Carvalho Chehab 304b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 305b285192aSMauro Carvalho Chehab /* device / file handle status */ 306b285192aSMauro Carvalho Chehab 307b285192aSMauro Carvalho Chehab #define RESOURCE_OVERLAY 1 308b285192aSMauro Carvalho Chehab #define RESOURCE_VIDEO 2 309b285192aSMauro Carvalho Chehab #define RESOURCE_VBI 4 310b285192aSMauro Carvalho Chehab 311b285192aSMauro Carvalho Chehab #define BUFFER_TIMEOUT msecs_to_jiffies(2000) 312b285192aSMauro Carvalho Chehab 3135e7045e3SHans Verkuil struct cx88_riscmem { 3145e7045e3SHans Verkuil unsigned int size; 3155e7045e3SHans Verkuil __le32 *cpu; 3165e7045e3SHans Verkuil __le32 *jmp; 3175e7045e3SHans Verkuil dma_addr_t dma; 3185e7045e3SHans Verkuil }; 3195e7045e3SHans Verkuil 320b285192aSMauro Carvalho Chehab /* buffer for one video frame */ 321b285192aSMauro Carvalho Chehab struct cx88_buffer { 322b285192aSMauro Carvalho Chehab /* common v4l buffer stuff -- must be first */ 3230b6b6302SHans Verkuil struct vb2_buffer vb; 3240b6b6302SHans Verkuil struct list_head list; 325b285192aSMauro Carvalho Chehab 326b285192aSMauro Carvalho Chehab /* cx88 specific */ 327b285192aSMauro Carvalho Chehab unsigned int bpl; 3285e7045e3SHans Verkuil struct cx88_riscmem risc; 329b285192aSMauro Carvalho Chehab u32 count; 330b285192aSMauro Carvalho Chehab }; 331b285192aSMauro Carvalho Chehab 332b285192aSMauro Carvalho Chehab struct cx88_dmaqueue { 333b285192aSMauro Carvalho Chehab struct list_head active; 334b285192aSMauro Carvalho Chehab u32 count; 335b285192aSMauro Carvalho Chehab }; 336b285192aSMauro Carvalho Chehab 337b285192aSMauro Carvalho Chehab struct cx88_core { 338b285192aSMauro Carvalho Chehab struct list_head devlist; 339b285192aSMauro Carvalho Chehab atomic_t refcount; 340b285192aSMauro Carvalho Chehab 341b285192aSMauro Carvalho Chehab /* board name */ 342b285192aSMauro Carvalho Chehab int nr; 343b285192aSMauro Carvalho Chehab char name[32]; 34448a8a03bSMauro Carvalho Chehab u32 model; 345b285192aSMauro Carvalho Chehab 346b285192aSMauro Carvalho Chehab /* pci stuff */ 347b285192aSMauro Carvalho Chehab int pci_bus; 348b285192aSMauro Carvalho Chehab int pci_slot; 349b285192aSMauro Carvalho Chehab u32 __iomem *lmmio; 350b285192aSMauro Carvalho Chehab u8 __iomem *bmmio; 351b285192aSMauro Carvalho Chehab u32 shadow[SHADOW_MAX]; 352b285192aSMauro Carvalho Chehab int pci_irqmask; 353b285192aSMauro Carvalho Chehab 354b285192aSMauro Carvalho Chehab /* i2c i/o */ 355b285192aSMauro Carvalho Chehab struct i2c_adapter i2c_adap; 356b285192aSMauro Carvalho Chehab struct i2c_algo_bit_data i2c_algo; 357b285192aSMauro Carvalho Chehab struct i2c_client i2c_client; 358b285192aSMauro Carvalho Chehab u32 i2c_state, i2c_rc; 359b285192aSMauro Carvalho Chehab 360b285192aSMauro Carvalho Chehab /* config info -- analog */ 361b285192aSMauro Carvalho Chehab struct v4l2_device v4l2_dev; 362b285192aSMauro Carvalho Chehab struct v4l2_ctrl_handler video_hdl; 363b285192aSMauro Carvalho Chehab struct v4l2_ctrl *chroma_agc; 364b285192aSMauro Carvalho Chehab struct v4l2_ctrl_handler audio_hdl; 365b285192aSMauro Carvalho Chehab struct v4l2_subdev *sd_wm8775; 366b285192aSMauro Carvalho Chehab struct i2c_client *i2c_rtc; 367b285192aSMauro Carvalho Chehab unsigned int boardnr; 368b285192aSMauro Carvalho Chehab struct cx88_board board; 369b285192aSMauro Carvalho Chehab 370b285192aSMauro Carvalho Chehab /* Supported V4L _STD_ tuner formats */ 371b285192aSMauro Carvalho Chehab unsigned int tuner_formats; 372b285192aSMauro Carvalho Chehab 373b285192aSMauro Carvalho Chehab /* config info -- dvb */ 3748268979aSPeter Senna Tschudin #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) 375b285192aSMauro Carvalho Chehab int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); 376b285192aSMauro Carvalho Chehab #endif 377b285192aSMauro Carvalho Chehab void (*gate_ctrl)(struct cx88_core *core, int open); 378b285192aSMauro Carvalho Chehab 379b285192aSMauro Carvalho Chehab /* state info */ 380b285192aSMauro Carvalho Chehab struct task_struct *kthread; 381b285192aSMauro Carvalho Chehab v4l2_std_id tvnorm; 382*ccd6f1d4SHans Verkuil unsigned width, height; 383*ccd6f1d4SHans Verkuil unsigned field; 384b285192aSMauro Carvalho Chehab enum cx88_tvaudio tvaudio; 385b285192aSMauro Carvalho Chehab u32 audiomode_manual; 386b285192aSMauro Carvalho Chehab u32 audiomode_current; 387b285192aSMauro Carvalho Chehab u32 input; 388b285192aSMauro Carvalho Chehab u32 last_analog_input; 389b285192aSMauro Carvalho Chehab u32 astat; 390b285192aSMauro Carvalho Chehab u32 use_nicam; 391b285192aSMauro Carvalho Chehab unsigned long last_change; 392b285192aSMauro Carvalho Chehab 393b285192aSMauro Carvalho Chehab /* IR remote control state */ 394b285192aSMauro Carvalho Chehab struct cx88_IR *ir; 395b285192aSMauro Carvalho Chehab 396b285192aSMauro Carvalho Chehab /* I2C remote data */ 397b285192aSMauro Carvalho Chehab struct IR_i2c_init_data init_data; 398b285192aSMauro Carvalho Chehab struct wm8775_platform_data wm8775_data; 399b285192aSMauro Carvalho Chehab 400b285192aSMauro Carvalho Chehab struct mutex lock; 401b285192aSMauro Carvalho Chehab /* various v4l controls */ 402b285192aSMauro Carvalho Chehab u32 freq; 403b285192aSMauro Carvalho Chehab 404b285192aSMauro Carvalho Chehab /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 405b285192aSMauro Carvalho Chehab struct cx8802_dev *dvbdev; 406b285192aSMauro Carvalho Chehab enum cx88_board_type active_type_id; 407b285192aSMauro Carvalho Chehab int active_ref; 408b285192aSMauro Carvalho Chehab int active_fe_id; 409b285192aSMauro Carvalho Chehab }; 410b285192aSMauro Carvalho Chehab 411b285192aSMauro Carvalho Chehab static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) 412b285192aSMauro Carvalho Chehab { 413b285192aSMauro Carvalho Chehab return container_of(v4l2_dev, struct cx88_core, v4l2_dev); 414b285192aSMauro Carvalho Chehab } 415b285192aSMauro Carvalho Chehab 416b285192aSMauro Carvalho Chehab #define call_hw(core, grpid, o, f, args...) \ 417b285192aSMauro Carvalho Chehab do { \ 418b285192aSMauro Carvalho Chehab if (!core->i2c_rc) { \ 419b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 420b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 1); \ 421b285192aSMauro Carvalho Chehab v4l2_device_call_all(&core->v4l2_dev, grpid, o, f, ##args); \ 422b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 423b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 0); \ 424b285192aSMauro Carvalho Chehab } \ 425b285192aSMauro Carvalho Chehab } while (0) 426b285192aSMauro Carvalho Chehab 427b285192aSMauro Carvalho Chehab #define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args) 428b285192aSMauro Carvalho Chehab 429b285192aSMauro Carvalho Chehab #define WM8775_GID (1 << 0) 430b285192aSMauro Carvalho Chehab 431b285192aSMauro Carvalho Chehab #define wm8775_s_ctrl(core, id, val) \ 432b285192aSMauro Carvalho Chehab do { \ 433b285192aSMauro Carvalho Chehab struct v4l2_ctrl *ctrl_ = \ 434b285192aSMauro Carvalho Chehab v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ 435b285192aSMauro Carvalho Chehab if (ctrl_ && !core->i2c_rc) { \ 436b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 437b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 1); \ 438b285192aSMauro Carvalho Chehab v4l2_ctrl_s_ctrl(ctrl_, val); \ 439b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 440b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 0); \ 441b285192aSMauro Carvalho Chehab } \ 442b285192aSMauro Carvalho Chehab } while (0) 443b285192aSMauro Carvalho Chehab 444b285192aSMauro Carvalho Chehab #define wm8775_g_ctrl(core, id) \ 445b285192aSMauro Carvalho Chehab ({ \ 446b285192aSMauro Carvalho Chehab struct v4l2_ctrl *ctrl_ = \ 447b285192aSMauro Carvalho Chehab v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ 448b285192aSMauro Carvalho Chehab s32 val = 0; \ 449b285192aSMauro Carvalho Chehab if (ctrl_ && !core->i2c_rc) { \ 450b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 451b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 1); \ 452b285192aSMauro Carvalho Chehab val = v4l2_ctrl_g_ctrl(ctrl_); \ 453b285192aSMauro Carvalho Chehab if (core->gate_ctrl) \ 454b285192aSMauro Carvalho Chehab core->gate_ctrl(core, 0); \ 455b285192aSMauro Carvalho Chehab } \ 456b285192aSMauro Carvalho Chehab val; \ 457b285192aSMauro Carvalho Chehab }) 458b285192aSMauro Carvalho Chehab 459b285192aSMauro Carvalho Chehab struct cx8800_dev; 460b285192aSMauro Carvalho Chehab struct cx8802_dev; 461b285192aSMauro Carvalho Chehab 462b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 463b285192aSMauro Carvalho Chehab /* function 0: video stuff */ 464b285192aSMauro Carvalho Chehab 465b285192aSMauro Carvalho Chehab struct cx8800_suspend_state { 466b285192aSMauro Carvalho Chehab int disabled; 467b285192aSMauro Carvalho Chehab }; 468b285192aSMauro Carvalho Chehab 469b285192aSMauro Carvalho Chehab struct cx8800_dev { 470b285192aSMauro Carvalho Chehab struct cx88_core *core; 471b285192aSMauro Carvalho Chehab spinlock_t slock; 472b285192aSMauro Carvalho Chehab 473b285192aSMauro Carvalho Chehab /* various device info */ 474b285192aSMauro Carvalho Chehab unsigned int resources; 475b285192aSMauro Carvalho Chehab struct video_device *video_dev; 476b285192aSMauro Carvalho Chehab struct video_device *vbi_dev; 477b285192aSMauro Carvalho Chehab struct video_device *radio_dev; 478b285192aSMauro Carvalho Chehab 479b285192aSMauro Carvalho Chehab /* pci i/o */ 480b285192aSMauro Carvalho Chehab struct pci_dev *pci; 481b285192aSMauro Carvalho Chehab unsigned char pci_rev,pci_lat; 482b285192aSMauro Carvalho Chehab 483b285192aSMauro Carvalho Chehab const struct cx8800_fmt *fmt; 484b285192aSMauro Carvalho Chehab 485b285192aSMauro Carvalho Chehab /* capture queues */ 486b285192aSMauro Carvalho Chehab struct cx88_dmaqueue vidq; 4870b6b6302SHans Verkuil struct vb2_queue vb2_vidq; 488b285192aSMauro Carvalho Chehab struct cx88_dmaqueue vbiq; 4890b6b6302SHans Verkuil struct vb2_queue vb2_vbiq; 490b285192aSMauro Carvalho Chehab 491b285192aSMauro Carvalho Chehab /* various v4l controls */ 492b285192aSMauro Carvalho Chehab 493b285192aSMauro Carvalho Chehab /* other global state info */ 494b285192aSMauro Carvalho Chehab struct cx8800_suspend_state state; 495b285192aSMauro Carvalho Chehab }; 496b285192aSMauro Carvalho Chehab 497b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 498b285192aSMauro Carvalho Chehab /* function 1: audio/alsa stuff */ 499b285192aSMauro Carvalho Chehab /* =============> moved to cx88-alsa.c <====================== */ 500b285192aSMauro Carvalho Chehab 501b285192aSMauro Carvalho Chehab 502b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 503b285192aSMauro Carvalho Chehab /* function 2: mpeg stuff */ 504b285192aSMauro Carvalho Chehab 505b285192aSMauro Carvalho Chehab struct cx8802_suspend_state { 506b285192aSMauro Carvalho Chehab int disabled; 507b285192aSMauro Carvalho Chehab }; 508b285192aSMauro Carvalho Chehab 509b285192aSMauro Carvalho Chehab struct cx8802_driver { 510b285192aSMauro Carvalho Chehab struct cx88_core *core; 511b285192aSMauro Carvalho Chehab 512b285192aSMauro Carvalho Chehab /* List of drivers attached to device */ 513b285192aSMauro Carvalho Chehab struct list_head drvlist; 514b285192aSMauro Carvalho Chehab 515b285192aSMauro Carvalho Chehab /* Type of driver and access required */ 516b285192aSMauro Carvalho Chehab enum cx88_board_type type_id; 517b285192aSMauro Carvalho Chehab enum cx8802_board_access hw_access; 518b285192aSMauro Carvalho Chehab 519b285192aSMauro Carvalho Chehab /* MPEG 8802 internal only */ 520b285192aSMauro Carvalho Chehab int (*suspend)(struct pci_dev *pci_dev, pm_message_t state); 521b285192aSMauro Carvalho Chehab int (*resume)(struct pci_dev *pci_dev); 522b285192aSMauro Carvalho Chehab 523b285192aSMauro Carvalho Chehab /* Callers to the following functions must hold core->lock */ 524b285192aSMauro Carvalho Chehab 525b285192aSMauro Carvalho Chehab /* MPEG 8802 -> mini driver - Driver probe and configuration */ 526b285192aSMauro Carvalho Chehab int (*probe)(struct cx8802_driver *drv); 527b285192aSMauro Carvalho Chehab int (*remove)(struct cx8802_driver *drv); 528b285192aSMauro Carvalho Chehab 529b285192aSMauro Carvalho Chehab /* MPEG 8802 -> mini driver - Access for hardware control */ 530b285192aSMauro Carvalho Chehab int (*advise_acquire)(struct cx8802_driver *drv); 531b285192aSMauro Carvalho Chehab int (*advise_release)(struct cx8802_driver *drv); 532b285192aSMauro Carvalho Chehab 533b285192aSMauro Carvalho Chehab /* MPEG 8802 <- mini driver - Access for hardware control */ 534b285192aSMauro Carvalho Chehab int (*request_acquire)(struct cx8802_driver *drv); 535b285192aSMauro Carvalho Chehab int (*request_release)(struct cx8802_driver *drv); 536b285192aSMauro Carvalho Chehab }; 537b285192aSMauro Carvalho Chehab 538b285192aSMauro Carvalho Chehab struct cx8802_dev { 539b285192aSMauro Carvalho Chehab struct cx88_core *core; 540b285192aSMauro Carvalho Chehab spinlock_t slock; 541b285192aSMauro Carvalho Chehab 542b285192aSMauro Carvalho Chehab /* pci i/o */ 543b285192aSMauro Carvalho Chehab struct pci_dev *pci; 544b285192aSMauro Carvalho Chehab unsigned char pci_rev,pci_lat; 545b285192aSMauro Carvalho Chehab 546b285192aSMauro Carvalho Chehab /* dma queues */ 547b285192aSMauro Carvalho Chehab struct cx88_dmaqueue mpegq; 5480b6b6302SHans Verkuil struct vb2_queue vb2_mpegq; 549b285192aSMauro Carvalho Chehab u32 ts_packet_size; 550b285192aSMauro Carvalho Chehab u32 ts_packet_count; 551b285192aSMauro Carvalho Chehab 552b285192aSMauro Carvalho Chehab /* other global state info */ 553b285192aSMauro Carvalho Chehab struct cx8802_suspend_state state; 554b285192aSMauro Carvalho Chehab 555b285192aSMauro Carvalho Chehab /* for blackbird only */ 556b285192aSMauro Carvalho Chehab struct list_head devlist; 5578268979aSPeter Senna Tschudin #if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) 558b285192aSMauro Carvalho Chehab struct video_device *mpeg_dev; 559b285192aSMauro Carvalho Chehab u32 mailbox; 560b285192aSMauro Carvalho Chehab unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ 561b285192aSMauro Carvalho Chehab 562b285192aSMauro Carvalho Chehab /* mpeg params */ 563b285192aSMauro Carvalho Chehab struct cx2341x_handler cxhdl; 564b285192aSMauro Carvalho Chehab #endif 565b285192aSMauro Carvalho Chehab 5668268979aSPeter Senna Tschudin #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) 567b285192aSMauro Carvalho Chehab /* for dvb only */ 5680b6b6302SHans Verkuil struct vb2_dvb_frontends frontends; 569b285192aSMauro Carvalho Chehab #endif 570b285192aSMauro Carvalho Chehab 5718268979aSPeter Senna Tschudin #if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 572b285192aSMauro Carvalho Chehab /* For VP3045 secondary I2C bus support */ 573b285192aSMauro Carvalho Chehab struct vp3054_i2c_state *vp3054; 574b285192aSMauro Carvalho Chehab #endif 575b285192aSMauro Carvalho Chehab /* for switching modulation types */ 576b285192aSMauro Carvalho Chehab unsigned char ts_gen_cntrl; 577b285192aSMauro Carvalho Chehab 578b285192aSMauro Carvalho Chehab /* List of attached drivers; must hold core->lock to access */ 579b285192aSMauro Carvalho Chehab struct list_head drvlist; 580b285192aSMauro Carvalho Chehab 581b285192aSMauro Carvalho Chehab struct work_struct request_module_wk; 582b285192aSMauro Carvalho Chehab }; 583b285192aSMauro Carvalho Chehab 584b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 585b285192aSMauro Carvalho Chehab 586b285192aSMauro Carvalho Chehab #define cx_read(reg) readl(core->lmmio + ((reg)>>2)) 587b285192aSMauro Carvalho Chehab #define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2)) 588b285192aSMauro Carvalho Chehab #define cx_writeb(reg,value) writeb((value), core->bmmio + (reg)) 589b285192aSMauro Carvalho Chehab 590b285192aSMauro Carvalho Chehab #define cx_andor(reg,mask,value) \ 591b285192aSMauro Carvalho Chehab writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\ 592b285192aSMauro Carvalho Chehab ((value) & (mask)), core->lmmio+((reg)>>2)) 593b285192aSMauro Carvalho Chehab #define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) 594b285192aSMauro Carvalho Chehab #define cx_clear(reg,bit) cx_andor((reg),(bit),0) 595b285192aSMauro Carvalho Chehab 596b285192aSMauro Carvalho Chehab #define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); } 597b285192aSMauro Carvalho Chehab 598b285192aSMauro Carvalho Chehab /* shadow registers */ 599b285192aSMauro Carvalho Chehab #define cx_sread(sreg) (core->shadow[sreg]) 600b285192aSMauro Carvalho Chehab #define cx_swrite(sreg,reg,value) \ 601b285192aSMauro Carvalho Chehab (core->shadow[sreg] = value, \ 602b285192aSMauro Carvalho Chehab writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 603b285192aSMauro Carvalho Chehab #define cx_sandor(sreg,reg,mask,value) \ 604b285192aSMauro Carvalho Chehab (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \ 605b285192aSMauro Carvalho Chehab writel(core->shadow[sreg], core->lmmio + ((reg)>>2))) 606b285192aSMauro Carvalho Chehab 607b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 608b285192aSMauro Carvalho Chehab /* cx88-core.c */ 609b285192aSMauro Carvalho Chehab 61002615ed5SMauro Carvalho Chehab extern unsigned int cx88_core_debug; 61102615ed5SMauro Carvalho Chehab 612b285192aSMauro Carvalho Chehab extern void cx88_print_irqbits(const char *name, const char *tag, const char *strings[], 613b285192aSMauro Carvalho Chehab int len, u32 bits, u32 mask); 614b285192aSMauro Carvalho Chehab 615b285192aSMauro Carvalho Chehab extern int cx88_core_irq(struct cx88_core *core, u32 status); 616b285192aSMauro Carvalho Chehab extern void cx88_wakeup(struct cx88_core *core, 617b285192aSMauro Carvalho Chehab struct cx88_dmaqueue *q, u32 count); 618b285192aSMauro Carvalho Chehab extern void cx88_shutdown(struct cx88_core *core); 619b285192aSMauro Carvalho Chehab extern int cx88_reset(struct cx88_core *core); 620b285192aSMauro Carvalho Chehab 621b285192aSMauro Carvalho Chehab extern int 6225e7045e3SHans Verkuil cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, 623b285192aSMauro Carvalho Chehab struct scatterlist *sglist, 624b285192aSMauro Carvalho Chehab unsigned int top_offset, unsigned int bottom_offset, 625b285192aSMauro Carvalho Chehab unsigned int bpl, unsigned int padding, unsigned int lines); 626b285192aSMauro Carvalho Chehab extern int 6275e7045e3SHans Verkuil cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, 628b285192aSMauro Carvalho Chehab struct scatterlist *sglist, unsigned int bpl, 629b285192aSMauro Carvalho Chehab unsigned int lines, unsigned int lpi); 630b285192aSMauro Carvalho Chehab 631b285192aSMauro Carvalho Chehab extern void cx88_risc_disasm(struct cx88_core *core, 6325e7045e3SHans Verkuil struct cx88_riscmem *risc); 633b285192aSMauro Carvalho Chehab extern int cx88_sram_channel_setup(struct cx88_core *core, 634b285192aSMauro Carvalho Chehab const struct sram_channel *ch, 635b285192aSMauro Carvalho Chehab unsigned int bpl, u32 risc); 636b285192aSMauro Carvalho Chehab extern void cx88_sram_channel_dump(struct cx88_core *core, 637b285192aSMauro Carvalho Chehab const struct sram_channel *ch); 638b285192aSMauro Carvalho Chehab 639b285192aSMauro Carvalho Chehab extern int cx88_set_scale(struct cx88_core *core, unsigned int width, 640b285192aSMauro Carvalho Chehab unsigned int height, enum v4l2_field field); 641b285192aSMauro Carvalho Chehab extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); 642b285192aSMauro Carvalho Chehab 643b285192aSMauro Carvalho Chehab extern struct video_device *cx88_vdev_init(struct cx88_core *core, 644b285192aSMauro Carvalho Chehab struct pci_dev *pci, 645b285192aSMauro Carvalho Chehab const struct video_device *template_, 646b285192aSMauro Carvalho Chehab const char *type); 647b285192aSMauro Carvalho Chehab extern struct cx88_core *cx88_core_get(struct pci_dev *pci); 648b285192aSMauro Carvalho Chehab extern void cx88_core_put(struct cx88_core *core, 649b285192aSMauro Carvalho Chehab struct pci_dev *pci); 650b285192aSMauro Carvalho Chehab 651b285192aSMauro Carvalho Chehab extern int cx88_start_audio_dma(struct cx88_core *core); 652b285192aSMauro Carvalho Chehab extern int cx88_stop_audio_dma(struct cx88_core *core); 653b285192aSMauro Carvalho Chehab 654b285192aSMauro Carvalho Chehab 655b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 656b285192aSMauro Carvalho Chehab /* cx88-vbi.c */ 657b285192aSMauro Carvalho Chehab 658b285192aSMauro Carvalho Chehab /* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ 659b285192aSMauro Carvalho Chehab int cx8800_vbi_fmt (struct file *file, void *priv, 660b285192aSMauro Carvalho Chehab struct v4l2_format *f); 661b285192aSMauro Carvalho Chehab 662b285192aSMauro Carvalho Chehab /* 663b285192aSMauro Carvalho Chehab int cx8800_start_vbi_dma(struct cx8800_dev *dev, 664b285192aSMauro Carvalho Chehab struct cx88_dmaqueue *q, 665b285192aSMauro Carvalho Chehab struct cx88_buffer *buf); 666b285192aSMauro Carvalho Chehab */ 6670b6b6302SHans Verkuil void cx8800_stop_vbi_dma(struct cx8800_dev *dev); 6680b6b6302SHans Verkuil int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); 669b285192aSMauro Carvalho Chehab 6700b6b6302SHans Verkuil extern const struct vb2_ops cx8800_vbi_qops; 671b285192aSMauro Carvalho Chehab 672b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 673b285192aSMauro Carvalho Chehab /* cx88-i2c.c */ 674b285192aSMauro Carvalho Chehab 675b285192aSMauro Carvalho Chehab extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci); 676b285192aSMauro Carvalho Chehab 677b285192aSMauro Carvalho Chehab 678b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 679b285192aSMauro Carvalho Chehab /* cx88-cards.c */ 680b285192aSMauro Carvalho Chehab 681b285192aSMauro Carvalho Chehab extern int cx88_tuner_callback(void *dev, int component, int command, int arg); 682b285192aSMauro Carvalho Chehab extern int cx88_get_resources(const struct cx88_core *core, 683b285192aSMauro Carvalho Chehab struct pci_dev *pci); 684b285192aSMauro Carvalho Chehab extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr); 685b285192aSMauro Carvalho Chehab extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl); 686b285192aSMauro Carvalho Chehab 687b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 688b285192aSMauro Carvalho Chehab /* cx88-tvaudio.c */ 689b285192aSMauro Carvalho Chehab 690b285192aSMauro Carvalho Chehab void cx88_set_tvaudio(struct cx88_core *core); 691b285192aSMauro Carvalho Chehab void cx88_newstation(struct cx88_core *core); 692b285192aSMauro Carvalho Chehab void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t); 693b285192aSMauro Carvalho Chehab void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual); 694b285192aSMauro Carvalho Chehab int cx88_audio_thread(void *data); 695b285192aSMauro Carvalho Chehab 696b285192aSMauro Carvalho Chehab int cx8802_register_driver(struct cx8802_driver *drv); 697b285192aSMauro Carvalho Chehab int cx8802_unregister_driver(struct cx8802_driver *drv); 698b285192aSMauro Carvalho Chehab 699b285192aSMauro Carvalho Chehab /* Caller must hold core->lock */ 700b285192aSMauro Carvalho Chehab struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); 701b285192aSMauro Carvalho Chehab 702b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 703b285192aSMauro Carvalho Chehab /* cx88-dsp.c */ 704b285192aSMauro Carvalho Chehab 705b285192aSMauro Carvalho Chehab s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core); 706b285192aSMauro Carvalho Chehab 707b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 708b285192aSMauro Carvalho Chehab /* cx88-input.c */ 709b285192aSMauro Carvalho Chehab 710b285192aSMauro Carvalho Chehab int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci); 711b285192aSMauro Carvalho Chehab int cx88_ir_fini(struct cx88_core *core); 712b285192aSMauro Carvalho Chehab void cx88_ir_irq(struct cx88_core *core); 713b285192aSMauro Carvalho Chehab int cx88_ir_start(struct cx88_core *core); 714b285192aSMauro Carvalho Chehab void cx88_ir_stop(struct cx88_core *core); 715b285192aSMauro Carvalho Chehab extern void cx88_i2c_init_ir(struct cx88_core *core); 716b285192aSMauro Carvalho Chehab 717b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 718b285192aSMauro Carvalho Chehab /* cx88-mpeg.c */ 719b285192aSMauro Carvalho Chehab 7200b6b6302SHans Verkuil int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, 721*ccd6f1d4SHans Verkuil struct cx88_buffer *buf); 722b285192aSMauro Carvalho Chehab void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 723b285192aSMauro Carvalho Chehab void cx8802_cancel_buffers(struct cx8802_dev *dev); 7240b6b6302SHans Verkuil int cx8802_start_dma(struct cx8802_dev *dev, 7250b6b6302SHans Verkuil struct cx88_dmaqueue *q, 7260b6b6302SHans Verkuil struct cx88_buffer *buf); 727b285192aSMauro Carvalho Chehab 728b285192aSMauro Carvalho Chehab /* ----------------------------------------------------------- */ 729b285192aSMauro Carvalho Chehab /* cx88-video.c*/ 730b285192aSMauro Carvalho Chehab int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i); 731b530a447SHans Verkuil int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); 732b285192aSMauro Carvalho Chehab int cx88_video_mux(struct cx88_core *core, unsigned int input); 733b285192aSMauro Carvalho Chehab void cx88_querycap(struct file *file, struct cx88_core *core, 734b285192aSMauro Carvalho Chehab struct v4l2_capability *cap); 735