cx88.h 22 KB

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