cx88.h 23 KB

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