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