aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/media/video/cx88/cx88.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/media/video/cx88/cx88.h')
-rw-r--r--drivers/media/video/cx88/cx88.h551
1 files changed, 551 insertions, 0 deletions
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
new file mode 100644
index 000000000000..b351d9eae615
--- /dev/null
+++ b/drivers/media/video/cx88/cx88.h
@@ -0,0 +1,551 @@
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
70struct cx88_tvnorm {
71 char *name;
72 v4l2_std_id id;
73 u32 cxiformat;
74 u32 cxoformat;
75};
76
77static 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
83static 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
91struct cx8800_fmt {
92 char *name;
93 u32 fourcc; /* v4l2 format id */
94 int depth;
95 int flags;
96 u32 cxformat;
97};
98
99struct 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
120struct 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};
132extern 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
166enum cx88_itype {
167 CX88_VMUX_COMPOSITE1 = 1,
168 CX88_VMUX_COMPOSITE2,
169 CX88_VMUX_COMPOSITE3,
170 CX88_VMUX_COMPOSITE4,
171 CX88_VMUX_SVIDEO,
172 CX88_VMUX_TELEVISION,
173 CX88_VMUX_CABLE,
174 CX88_VMUX_DVB,
175 CX88_VMUX_DEBUG,
176 CX88_RADIO,
177};
178
179struct cx88_input {
180 enum cx88_itype type;
181 unsigned int vmux;
182 u32 gpio0, gpio1, gpio2, gpio3;
183};
184
185struct cx88_board {
186 char *name;
187 unsigned int tuner_type;
188 int tda9887_conf;
189 struct cx88_input input[8];
190 struct cx88_input radio;
191 int blackbird:1;
192 int dvb:1;
193};
194
195struct cx88_subid {
196 u16 subvendor;
197 u16 subdevice;
198 u32 card;
199};
200
201#define INPUT(nr) (&cx88_boards[core->board].input[nr])
202
203/* ----------------------------------------------------------- */
204/* device / file handle status */
205
206#define RESOURCE_OVERLAY 1
207#define RESOURCE_VIDEO 2
208#define RESOURCE_VBI 4
209
210#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
211//#define BUFFER_TIMEOUT (HZ*2)
212
213/* buffer for one video frame */
214struct cx88_buffer {
215 /* common v4l buffer stuff -- must be first */
216 struct videobuf_buffer vb;
217
218 /* cx88 specific */
219 unsigned int bpl;
220 struct btcx_riscmem risc;
221 struct cx8800_fmt *fmt;
222 u32 count;
223};
224
225struct cx88_dmaqueue {
226 struct list_head active;
227 struct list_head queued;
228 struct timer_list timeout;
229 struct btcx_riscmem stopper;
230 u32 count;
231};
232
233struct cx88_core {
234 struct list_head devlist;
235 atomic_t refcount;
236
237 /* board name */
238 int nr;
239 char name[32];
240
241 /* pci stuff */
242 int pci_bus;
243 int pci_slot;
244 u32 __iomem *lmmio;
245 u8 __iomem *bmmio;
246 u32 shadow[SHADOW_MAX];
247 int pci_irqmask;
248
249 /* i2c i/o */
250 struct i2c_adapter i2c_adap;
251 struct i2c_algo_bit_data i2c_algo;
252 struct i2c_client i2c_client;
253 u32 i2c_state, i2c_rc;
254
255 /* config info -- analog */
256 unsigned int board;
257 unsigned int tuner_type;
258 unsigned int tda9887_conf;
259 unsigned int has_radio;
260
261 /* config info -- dvb */
262 struct dvb_pll_desc *pll_desc;
263 unsigned int pll_addr;
264
265 /* state info */
266 struct task_struct *kthread;
267 struct cx88_tvnorm *tvnorm;
268 u32 tvaudio;
269 u32 audiomode_manual;
270 u32 audiomode_current;
271 u32 input;
272 u32 astat;
273
274 /* IR remote control state */
275 struct cx88_IR *ir;
276};
277
278struct cx8800_dev;
279struct cx8802_dev;
280
281/* ----------------------------------------------------------- */
282/* function 0: video stuff */
283
284struct cx8800_fh {
285 struct cx8800_dev *dev;
286 enum v4l2_buf_type type;
287 int radio;
288 unsigned int resources;
289
290 /* video overlay */
291 struct v4l2_window win;
292 struct v4l2_clip *clips;
293 unsigned int nclips;
294
295 /* video capture */
296 struct cx8800_fmt *fmt;
297 unsigned int width,height;
298 struct videobuf_queue vidq;
299
300 /* vbi capture */
301 struct videobuf_queue vbiq;
302};
303
304struct cx8800_suspend_state {
305 int disabled;
306};
307
308struct cx8800_dev {
309 struct cx88_core *core;
310 struct list_head devlist;
311 struct semaphore lock;
312 spinlock_t slock;
313
314 /* various device info */
315 unsigned int resources;
316 struct video_device *video_dev;
317 struct video_device *vbi_dev;
318 struct video_device *radio_dev;
319
320 /* pci i/o */
321 struct pci_dev *pci;
322 unsigned char pci_rev,pci_lat;
323
324#if 0
325 /* video overlay */
326 struct v4l2_framebuffer fbuf;
327 struct cx88_buffer *screen;
328#endif
329
330 /* capture queues */
331 struct cx88_dmaqueue vidq;
332 struct cx88_dmaqueue vbiq;
333
334 /* various v4l controls */
335 u32 freq;
336
337 /* other global state info */
338 struct cx8800_suspend_state state;
339};
340
341/* ----------------------------------------------------------- */
342/* function 1: audio/alsa stuff */
343
344struct cx8801_dev {
345 struct cx88_core *core;
346
347 /* pci i/o */
348 struct pci_dev *pci;
349 unsigned char pci_rev,pci_lat;
350};
351
352/* ----------------------------------------------------------- */
353/* function 2: mpeg stuff */
354
355struct cx8802_fh {
356 struct cx8802_dev *dev;
357 struct videobuf_queue mpegq;
358};
359
360struct cx8802_suspend_state {
361 int disabled;
362};
363
364struct cx8802_dev {
365 struct cx88_core *core;
366 struct semaphore lock;
367 spinlock_t slock;
368
369 /* pci i/o */
370 struct pci_dev *pci;
371 unsigned char pci_rev,pci_lat;
372
373 /* dma queues */
374 struct cx88_dmaqueue mpegq;
375 u32 ts_packet_size;
376 u32 ts_packet_count;
377
378 /* other global state info */
379 struct cx8802_suspend_state state;
380
381 /* for blackbird only */
382 struct list_head devlist;
383 struct video_device *mpeg_dev;
384 u32 mailbox;
385 int width;
386 int height;
387
388 /* for dvb only */
389 struct videobuf_dvb dvb;
390 void* fe_handle;
391 int (*fe_release)(void *handle);
392
393 /* for switching modulation types */
394 unsigned char ts_gen_cntrl;
395};
396
397/* ----------------------------------------------------------- */
398
399#define cx_read(reg) readl(core->lmmio + ((reg)>>2))
400#define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2))
401#define cx_writeb(reg,value) writeb((value), core->bmmio + (reg))
402
403#define cx_andor(reg,mask,value) \
404 writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\
405 ((value) & (mask)), core->lmmio+((reg)>>2))
406#define cx_set(reg,bit) cx_andor((reg),(bit),(bit))
407#define cx_clear(reg,bit) cx_andor((reg),(bit),0)
408
409#define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
410
411/* shadow registers */
412#define cx_sread(sreg) (core->shadow[sreg])
413#define cx_swrite(sreg,reg,value) \
414 (core->shadow[sreg] = value, \
415 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
416#define cx_sandor(sreg,reg,mask,value) \
417 (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
418 writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
419
420/* ----------------------------------------------------------- */
421/* cx88-core.c */
422
423extern char *cx88_pci_irqs[32];
424extern char *cx88_vid_irqs[32];
425extern char *cx88_mpeg_irqs[32];
426extern void cx88_print_irqbits(char *name, char *tag, char **strings,
427 u32 bits, u32 mask);
428extern void cx88_print_ioctl(char *name, unsigned int cmd);
429
430extern int cx88_core_irq(struct cx88_core *core, u32 status);
431extern void cx88_wakeup(struct cx88_core *core,
432 struct cx88_dmaqueue *q, u32 count);
433extern void cx88_shutdown(struct cx88_core *core);
434extern int cx88_reset(struct cx88_core *core);
435
436extern int
437cx88_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);
441extern int
442cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
443 struct scatterlist *sglist, unsigned int bpl,
444 unsigned int lines);
445extern int
446cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
447 u32 reg, u32 mask, u32 value);
448extern void
449cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
450
451extern void cx88_risc_disasm(struct cx88_core *core,
452 struct btcx_riscmem *risc);
453extern int cx88_sram_channel_setup(struct cx88_core *core,
454 struct sram_channel *ch,
455 unsigned int bpl, u32 risc);
456extern void cx88_sram_channel_dump(struct cx88_core *core,
457 struct sram_channel *ch);
458
459extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
460 unsigned int height, enum v4l2_field field);
461extern int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm);
462
463extern struct video_device *cx88_vdev_init(struct cx88_core *core,
464 struct pci_dev *pci,
465 struct video_device *template,
466 char *type);
467extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
468extern void cx88_core_put(struct cx88_core *core,
469 struct pci_dev *pci);
470
471/* ----------------------------------------------------------- */
472/* cx88-vbi.c */
473
474void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f);
475int cx8800_start_vbi_dma(struct cx8800_dev *dev,
476 struct cx88_dmaqueue *q,
477 struct cx88_buffer *buf);
478int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
479int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
480 struct cx88_dmaqueue *q);
481void cx8800_vbi_timeout(unsigned long data);
482
483extern struct videobuf_queue_ops cx8800_vbi_qops;
484
485/* ----------------------------------------------------------- */
486/* cx88-i2c.c */
487
488extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
489extern void cx88_call_i2c_clients(struct cx88_core *core,
490 unsigned int cmd, void *arg);
491
492
493/* ----------------------------------------------------------- */
494/* cx88-cards.c */
495
496extern struct cx88_board cx88_boards[];
497extern const unsigned int cx88_bcount;
498
499extern struct cx88_subid cx88_subids[];
500extern const unsigned int cx88_idcount;
501
502extern void cx88_card_list(struct cx88_core *core, struct pci_dev *pci);
503extern void cx88_card_setup(struct cx88_core *core);
504
505/* ----------------------------------------------------------- */
506/* cx88-tvaudio.c */
507
508#define WW_NONE 1
509#define WW_BTSC 2
510#define WW_NICAM_I 3
511#define WW_NICAM_BGDKL 4
512#define WW_A1 5
513#define WW_A2_BG 6
514#define WW_A2_DK 7
515#define WW_A2_M 8
516#define WW_EIAJ 9
517#define WW_SYSTEM_L_AM 10
518#define WW_I2SPT 11
519#define WW_FM 12
520
521void cx88_set_tvaudio(struct cx88_core *core);
522void cx88_newstation(struct cx88_core *core);
523void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
524void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual);
525int cx88_audio_thread(void *data);
526
527/* ----------------------------------------------------------- */
528/* cx88-input.c */
529
530int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
531int cx88_ir_fini(struct cx88_core *core);
532void cx88_ir_irq(struct cx88_core *core);
533
534/* ----------------------------------------------------------- */
535/* cx88-mpeg.c */
536
537int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf);
538void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
539void cx8802_cancel_buffers(struct cx8802_dev *dev);
540
541int cx8802_init_common(struct cx8802_dev *dev);
542void cx8802_fini_common(struct cx8802_dev *dev);
543
544int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state);
545int cx8802_resume_common(struct pci_dev *pci_dev);
546
547/*
548 * Local variables:
549 * c-basic-offset: 8
550 * End:
551 */