[PATCH] Fix for cx88-cards.c for DVICO-FusionHDTV 3 GOLD Q
[deliverable/linux.git] / drivers / media / video / cx88 / cx88.h
1 /*
2 * $Id: cx88.h,v 1.56 2005/03/04 09:12:23 kraxel Exp $
3 *
4 * v4l2 device driver for cx2388x based TV cards
5 *
6 * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include <linux/pci.h>
24 #include <linux/i2c.h>
25 #include <linux/i2c-algo-bit.h>
26 #include <linux/videodev.h>
27 #include <linux/kdev_t.h>
28
29 #include <media/tuner.h>
30 #include <media/tveeprom.h>
31 #include <media/audiochip.h>
32 #include <media/video-buf.h>
33 #include <media/video-buf-dvb.h>
34
35 #include "btcx-risc.h"
36 #include "cx88-reg.h"
37
38 #include <linux/version.h>
39 #define CX88_VERSION_CODE KERNEL_VERSION(0,0,4)
40
41 #ifndef TRUE
42 # define TRUE (1==1)
43 #endif
44 #ifndef FALSE
45 # define FALSE (1==0)
46 #endif
47 #define UNSET (-1U)
48
49 #define CX88_MAXBOARDS 8
50
51 /* ----------------------------------------------------------- */
52 /* defines and enums */
53
54 #define V4L2_I2C_CLIENTS 1
55
56 #define FORMAT_FLAGS_PACKED 0x01
57 #define FORMAT_FLAGS_PLANAR 0x02
58
59 #define VBI_LINE_COUNT 17
60 #define VBI_LINE_LENGTH 2048
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 2
66
67 /* ----------------------------------------------------------- */
68 /* tv norms */
69
70 struct cx88_tvnorm {
71 char *name;
72 v4l2_std_id id;
73 u32 cxiformat;
74 u32 cxoformat;
75 };
76
77 static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
78 {
79 return (norm->id & V4L2_STD_625_50) ? 768 : 640;
80 // return (norm->id & V4L2_STD_625_50) ? 720 : 640;
81 }
82
83 static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
84 {
85 return (norm->id & V4L2_STD_625_50) ? 576 : 480;
86 }
87
88 /* ----------------------------------------------------------- */
89 /* static data */
90
91 struct cx8800_fmt {
92 char *name;
93 u32 fourcc; /* v4l2 format id */
94 int depth;
95 int flags;
96 u32 cxformat;
97 };
98
99 struct cx88_ctrl {
100 struct v4l2_queryctrl v;
101 u32 off;
102 u32 reg;
103 u32 sreg;
104 u32 mask;
105 u32 shift;
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 /* more */
119
120 struct sram_channel {
121 char *name;
122 u32 cmds_start;
123 u32 ctrl_start;
124 u32 cdt;
125 u32 fifo_start;
126 u32 fifo_size;
127 u32 ptr1_reg;
128 u32 ptr2_reg;
129 u32 cnt1_reg;
130 u32 cnt2_reg;
131 };
132 extern struct sram_channel cx88_sram_channels[];
133
134 /* ----------------------------------------------------------- */
135 /* card configuration */
136
137 #define CX88_BOARD_NOAUTO UNSET
138 #define CX88_BOARD_UNKNOWN 0
139 #define CX88_BOARD_HAUPPAUGE 1
140 #define CX88_BOARD_GDI 2
141 #define CX88_BOARD_PIXELVIEW 3
142 #define CX88_BOARD_ATI_WONDER_PRO 4
143 #define CX88_BOARD_WINFAST2000XP_EXPERT 5
144 #define CX88_BOARD_AVERTV_303 6
145 #define CX88_BOARD_MSI_TVANYWHERE_MASTER 7
146 #define CX88_BOARD_WINFAST_DV2000 8
147 #define CX88_BOARD_LEADTEK_PVR2000 9
148 #define CX88_BOARD_IODATA_GVVCP3PCI 10
149 #define CX88_BOARD_PROLINK_PLAYTVPVR 11
150 #define CX88_BOARD_ASUS_PVR_416 12
151 #define CX88_BOARD_MSI_TVANYWHERE 13
152 #define CX88_BOARD_KWORLD_DVB_T 14
153 #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15
154 #define CX88_BOARD_KWORLD_LTV883 16
155 #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD 17
156 #define CX88_BOARD_HAUPPAUGE_DVB_T1 18
157 #define CX88_BOARD_CONEXANT_DVB_T1 19
158 #define CX88_BOARD_PROVIDEO_PV259 20
159 #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
160 #define CX88_BOARD_PCHDTV_HD3000 22
161 #define CX88_BOARD_DNTV_LIVE_DVB_T 23
162 #define CX88_BOARD_HAUPPAUGE_ROSLYN 24
163 #define CX88_BOARD_DIGITALLOGIC_MEC 25
164 #define CX88_BOARD_IODATA_GVBCTV7E 26
165 #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q 27
166
167 enum cx88_itype {
168 CX88_VMUX_COMPOSITE1 = 1,
169 CX88_VMUX_COMPOSITE2,
170 CX88_VMUX_COMPOSITE3,
171 CX88_VMUX_COMPOSITE4,
172 CX88_VMUX_SVIDEO,
173 CX88_VMUX_TELEVISION,
174 CX88_VMUX_CABLE,
175 CX88_VMUX_DVB,
176 CX88_VMUX_DEBUG,
177 CX88_RADIO,
178 };
179
180 struct cx88_input {
181 enum cx88_itype type;
182 unsigned int vmux;
183 u32 gpio0, gpio1, gpio2, gpio3;
184 };
185
186 struct cx88_board {
187 char *name;
188 unsigned int tuner_type;
189 int tda9887_conf;
190 struct cx88_input input[8];
191 struct cx88_input radio;
192 int blackbird:1;
193 int dvb:1;
194 };
195
196 struct cx88_subid {
197 u16 subvendor;
198 u16 subdevice;
199 u32 card;
200 };
201
202 #define INPUT(nr) (&cx88_boards[core->board].input[nr])
203
204 /* ----------------------------------------------------------- */
205 /* device / file handle status */
206
207 #define RESOURCE_OVERLAY 1
208 #define RESOURCE_VIDEO 2
209 #define RESOURCE_VBI 4
210
211 #define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
212 //#define BUFFER_TIMEOUT (HZ*2)
213
214 /* buffer for one video frame */
215 struct cx88_buffer {
216 /* common v4l buffer stuff -- must be first */
217 struct videobuf_buffer vb;
218
219 /* cx88 specific */
220 unsigned int bpl;
221 struct btcx_riscmem risc;
222 struct cx8800_fmt *fmt;
223 u32 count;
224 };
225
226 struct cx88_dmaqueue {
227 struct list_head active;
228 struct list_head queued;
229 struct timer_list timeout;
230 struct btcx_riscmem stopper;
231 u32 count;
232 };
233
234 struct cx88_core {
235 struct list_head devlist;
236 atomic_t refcount;
237
238 /* board name */
239 int nr;
240 char name[32];
241
242 /* pci stuff */
243 int pci_bus;
244 int pci_slot;
245 u32 __iomem *lmmio;
246 u8 __iomem *bmmio;
247 u32 shadow[SHADOW_MAX];
248 int pci_irqmask;
249
250 /* i2c i/o */
251 struct i2c_adapter i2c_adap;
252 struct i2c_algo_bit_data i2c_algo;
253 struct i2c_client i2c_client;
254 u32 i2c_state, i2c_rc;
255
256 /* config info -- analog */
257 unsigned int board;
258 unsigned int tuner_type;
259 unsigned int tda9887_conf;
260 unsigned int has_radio;
261
262 /* config info -- dvb */
263 struct dvb_pll_desc *pll_desc;
264 unsigned int pll_addr;
265
266 /* state info */
267 struct task_struct *kthread;
268 struct cx88_tvnorm *tvnorm;
269 u32 tvaudio;
270 u32 audiomode_manual;
271 u32 audiomode_current;
272 u32 input;
273 u32 astat;
274
275 /* IR remote control state */
276 struct cx88_IR *ir;
277 };
278
279 struct cx8800_dev;
280 struct cx8802_dev;
281
282 /* ----------------------------------------------------------- */
283 /* function 0: video stuff */
284
285 struct cx8800_fh {
286 struct cx8800_dev *dev;
287 enum v4l2_buf_type type;
288 int radio;
289 unsigned int resources;
290
291 /* video overlay */
292 struct v4l2_window win;
293 struct v4l2_clip *clips;
294 unsigned int nclips;
295
296 /* video capture */
297 struct cx8800_fmt *fmt;
298 unsigned int width,height;
299 struct videobuf_queue vidq;
300
301 /* vbi capture */
302 struct videobuf_queue vbiq;
303 };
304
305 struct cx8800_suspend_state {
306 int disabled;
307 };
308
309 struct cx8800_dev {
310 struct cx88_core *core;
311 struct list_head devlist;
312 struct semaphore lock;
313 spinlock_t slock;
314
315 /* various device info */
316 unsigned int resources;
317 struct video_device *video_dev;
318 struct video_device *vbi_dev;
319 struct video_device *radio_dev;
320
321 /* pci i/o */
322 struct pci_dev *pci;
323 unsigned char pci_rev,pci_lat;
324
325 #if 0
326 /* video overlay */
327 struct v4l2_framebuffer fbuf;
328 struct cx88_buffer *screen;
329 #endif
330
331 /* capture queues */
332 struct cx88_dmaqueue vidq;
333 struct cx88_dmaqueue vbiq;
334
335 /* various v4l controls */
336 u32 freq;
337
338 /* other global state info */
339 struct cx8800_suspend_state state;
340 };
341
342 /* ----------------------------------------------------------- */
343 /* function 1: audio/alsa stuff */
344
345 struct cx8801_dev {
346 struct cx88_core *core;
347
348 /* pci i/o */
349 struct pci_dev *pci;
350 unsigned char pci_rev,pci_lat;
351 };
352
353 /* ----------------------------------------------------------- */
354 /* function 2: mpeg stuff */
355
356 struct cx8802_fh {
357 struct cx8802_dev *dev;
358 struct videobuf_queue mpegq;
359 };
360
361 struct cx8802_suspend_state {
362 int disabled;
363 };
364
365 struct cx8802_dev {
366 struct cx88_core *core;
367 struct semaphore lock;
368 spinlock_t slock;
369
370 /* pci i/o */
371 struct pci_dev *pci;
372 unsigned char pci_rev,pci_lat;
373
374 /* dma queues */
375 struct cx88_dmaqueue mpegq;
376 u32 ts_packet_size;
377 u32 ts_packet_count;
378
379 /* other global state info */
380 struct cx8802_suspend_state state;
381
382 /* for blackbird only */
383 struct list_head devlist;
384 struct video_device *mpeg_dev;
385 u32 mailbox;
386 int width;
387 int height;
388
389 /* for dvb only */
390 struct videobuf_dvb dvb;
391 void* fe_handle;
392 int (*fe_release)(void *handle);
393
394 /* for switching modulation types */
395 unsigned char ts_gen_cntrl;
396 };
397
398 /* ----------------------------------------------------------- */
399
400 #define cx_read(reg) readl(core->lmmio + ((reg)>>2))
401 #define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2))
402 #define cx_writeb(reg,value) writeb((value), core->bmmio + (reg))
403
404 #define cx_andor(reg,mask,value) \
405 writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\
406 ((value) & (mask)), core->lmmio+((reg)>>2))
407 #define cx_set(reg,bit) cx_andor((reg),(bit),(bit))
408 #define cx_clear(reg,bit) cx_andor((reg),(bit),0)
409
410 #define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
411
412 /* shadow registers */
413 #define cx_sread(sreg) (core->shadow[sreg])
414 #define cx_swrite(sreg,reg,value) \
415 (core->shadow[sreg] = value, \
416 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
417 #define cx_sandor(sreg,reg,mask,value) \
418 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
419 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
420
421 /* ----------------------------------------------------------- */
422 /* cx88-core.c */
423
424 extern char *cx88_vid_irqs[32];
425 extern char *cx88_mpeg_irqs[32];
426 extern void cx88_print_irqbits(char *name, char *tag, char **strings,
427 u32 bits, u32 mask);
428 extern void cx88_print_ioctl(char *name, unsigned int cmd);
429
430 extern int cx88_core_irq(struct cx88_core *core, u32 status);
431 extern void cx88_wakeup(struct cx88_core *core,
432 struct cx88_dmaqueue *q, u32 count);
433 extern void cx88_shutdown(struct cx88_core *core);
434 extern int cx88_reset(struct cx88_core *core);
435
436 extern int
437 cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
438 struct scatterlist *sglist,
439 unsigned int top_offset, unsigned int bottom_offset,
440 unsigned int bpl, unsigned int padding, unsigned int lines);
441 extern int
442 cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
443 struct scatterlist *sglist, unsigned int bpl,
444 unsigned int lines);
445 extern int
446 cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
447 u32 reg, u32 mask, u32 value);
448 extern void
449 cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
450
451 extern void cx88_risc_disasm(struct cx88_core *core,
452 struct btcx_riscmem *risc);
453 extern int cx88_sram_channel_setup(struct cx88_core *core,
454 struct sram_channel *ch,
455 unsigned int bpl, u32 risc);
456 extern void cx88_sram_channel_dump(struct cx88_core *core,
457 struct sram_channel *ch);
458
459 extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
460 unsigned int height, enum v4l2_field field);
461 extern int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm);
462
463 extern struct video_device *cx88_vdev_init(struct cx88_core *core,
464 struct pci_dev *pci,
465 struct video_device *template,
466 char *type);
467 extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
468 extern void cx88_core_put(struct cx88_core *core,
469 struct pci_dev *pci);
470
471 /* ----------------------------------------------------------- */
472 /* cx88-vbi.c */
473
474 void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f);
475 int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
476 int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
477 struct cx88_dmaqueue *q);
478 void cx8800_vbi_timeout(unsigned long data);
479
480 extern struct videobuf_queue_ops cx8800_vbi_qops;
481
482 /* ----------------------------------------------------------- */
483 /* cx88-i2c.c */
484
485 extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
486 extern void cx88_call_i2c_clients(struct cx88_core *core,
487 unsigned int cmd, void *arg);
488
489
490 /* ----------------------------------------------------------- */
491 /* cx88-cards.c */
492
493 extern struct cx88_board cx88_boards[];
494 extern const unsigned int cx88_bcount;
495
496 extern struct cx88_subid cx88_subids[];
497 extern const unsigned int cx88_idcount;
498
499 extern void cx88_card_list(struct cx88_core *core, struct pci_dev *pci);
500 extern void cx88_card_setup(struct cx88_core *core);
501
502 /* ----------------------------------------------------------- */
503 /* cx88-tvaudio.c */
504
505 #define WW_NONE 1
506 #define WW_BTSC 2
507 #define WW_NICAM_I 3
508 #define WW_NICAM_BGDKL 4
509 #define WW_A1 5
510 #define WW_A2_BG 6
511 #define WW_A2_DK 7
512 #define WW_A2_M 8
513 #define WW_EIAJ 9
514 #define WW_SYSTEM_L_AM 10
515 #define WW_I2SPT 11
516 #define WW_FM 12
517
518 void cx88_set_tvaudio(struct cx88_core *core);
519 void cx88_newstation(struct cx88_core *core);
520 void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
521 void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual);
522 int cx88_audio_thread(void *data);
523
524 /* ----------------------------------------------------------- */
525 /* cx88-input.c */
526
527 int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
528 int cx88_ir_fini(struct cx88_core *core);
529 void cx88_ir_irq(struct cx88_core *core);
530
531 /* ----------------------------------------------------------- */
532 /* cx88-mpeg.c */
533
534 int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
535 void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
536 void cx8802_cancel_buffers(struct cx8802_dev *dev);
537
538 int cx8802_init_common(struct cx8802_dev *dev);
539 void cx8802_fini_common(struct cx8802_dev *dev);
540
541 int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state);
542 int cx8802_resume_common(struct pci_dev *pci_dev);
543
544 /*
545 * Local variables:
546 * c-basic-offset: 8
547 * End:
548 */
This page took 0.042627 seconds and 6 git commands to generate.