[XFRM]: skb_cow_data() does not set proper owner for new skbs.
[linux-2.6/verdex.git] / drivers / media / video / saa7134 / saa7134.h
blobac90a985323608ff20fc95383d2fe040e3825118
1 /*
2 * $Id: saa7134.h,v 1.38 2005/03/07 12:01:51 kraxel Exp $
4 * v4l2 device driver for philips saa7134 based TV cards
6 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
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.
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.
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.
23 #include <linux/version.h>
24 #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,12)
26 #include <linux/pci.h>
27 #include <linux/i2c.h>
28 #include <linux/videodev.h>
29 #include <linux/kdev_t.h>
30 #include <linux/input.h>
32 #include <asm/io.h>
34 #include <media/tuner.h>
35 #include <media/audiochip.h>
36 #include <media/id.h>
37 #include <media/ir-common.h>
38 #include <media/video-buf.h>
39 #include <media/video-buf-dvb.h>
41 #ifndef TRUE
42 # define TRUE (1==1)
43 #endif
44 #ifndef FALSE
45 # define FALSE (1==0)
46 #endif
47 #define UNSET (-1U)
49 /* 2.4 / 2.5 driver compatibility stuff */
51 /* ----------------------------------------------------------- */
52 /* enums */
54 enum saa7134_tvaudio_mode {
55 TVAUDIO_FM_MONO = 1,
56 TVAUDIO_FM_BG_STEREO = 2,
57 TVAUDIO_FM_SAT_STEREO = 3,
58 TVAUDIO_FM_K_STEREO = 4,
59 TVAUDIO_NICAM_AM = 5,
60 TVAUDIO_NICAM_FM = 6,
63 enum saa7134_audio_in {
64 TV = 1,
65 LINE1 = 2,
66 LINE2 = 3,
67 LINE2_LEFT,
70 enum saa7134_video_out {
71 CCIR656 = 1,
74 /* ----------------------------------------------------------- */
75 /* static data */
77 struct saa7134_tvnorm {
78 char *name;
79 v4l2_std_id id;
81 /* video decoder */
82 unsigned int sync_control;
83 unsigned int luma_control;
84 unsigned int chroma_ctrl1;
85 unsigned int chroma_gain;
86 unsigned int chroma_ctrl2;
87 unsigned int vgate_misc;
89 /* video scaler */
90 unsigned int h_start;
91 unsigned int h_stop;
92 unsigned int video_v_start;
93 unsigned int video_v_stop;
94 unsigned int vbi_v_start;
95 unsigned int vbi_v_stop;
96 unsigned int src_timing;
99 struct saa7134_tvaudio {
100 char *name;
101 v4l2_std_id std;
102 enum saa7134_tvaudio_mode mode;
103 int carr1;
104 int carr2;
107 struct saa7134_format {
108 char *name;
109 unsigned int fourcc;
110 unsigned int depth;
111 unsigned int pm;
112 unsigned int vshift; /* vertical downsampling (for planar yuv) */
113 unsigned int hshift; /* horizontal downsampling (for planar yuv) */
114 unsigned int bswap:1;
115 unsigned int wswap:1;
116 unsigned int yuv:1;
117 unsigned int planar:1;
118 unsigned int uvswap:1;
121 /* ----------------------------------------------------------- */
122 /* card configuration */
124 #define SAA7134_BOARD_NOAUTO UNSET
125 #define SAA7134_BOARD_UNKNOWN 0
126 #define SAA7134_BOARD_PROTEUS_PRO 1
127 #define SAA7134_BOARD_FLYVIDEO3000 2
128 #define SAA7134_BOARD_FLYVIDEO2000 3
129 #define SAA7134_BOARD_EMPRESS 4
130 #define SAA7134_BOARD_MONSTERTV 5
131 #define SAA7134_BOARD_MD9717 6
132 #define SAA7134_BOARD_TVSTATION_RDS 7
133 #define SAA7134_BOARD_CINERGY400 8
134 #define SAA7134_BOARD_MD5044 9
135 #define SAA7134_BOARD_KWORLD 10
136 #define SAA7134_BOARD_CINERGY600 11
137 #define SAA7134_BOARD_MD7134 12
138 #define SAA7134_BOARD_TYPHOON_90031 13
139 #define SAA7134_BOARD_ELSA 14
140 #define SAA7134_BOARD_ELSA_500TV 15
141 #define SAA7134_BOARD_ASUSTeK_TVFM7134 16
142 #define SAA7134_BOARD_VA1000POWER 17
143 #define SAA7134_BOARD_BMK_MPEX_NOTUNER 18
144 #define SAA7134_BOARD_VIDEOMATE_TV 19
145 #define SAA7134_BOARD_CRONOS_PLUS 20
146 #define SAA7134_BOARD_10MOONSTVMASTER 21
147 #define SAA7134_BOARD_MD2819 22
148 #define SAA7134_BOARD_BMK_MPEX_TUNER 23
149 #define SAA7134_BOARD_TVSTATION_DVR 24
150 #define SAA7134_BOARD_ASUSTEK_TVFM7133 25
151 #define SAA7134_BOARD_PINNACLE_PCTV_STEREO 26
152 #define SAA7134_BOARD_MANLI_MTV002 27
153 #define SAA7134_BOARD_MANLI_MTV001 28
154 #define SAA7134_BOARD_TG3000TV 29
155 #define SAA7134_BOARD_ECS_TVP3XP 30
156 #define SAA7134_BOARD_ECS_TVP3XP_4CB5 31
157 #define SAA7134_BOARD_AVACSSMARTTV 32
158 #define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33
159 #define SAA7134_BOARD_NOVAC_PRIMETV7133 34
160 #define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35
161 #define SAA7133_BOARD_UPMOST_PURPLE_TV 36
162 #define SAA7134_BOARD_ITEMS_MTV005 37
163 #define SAA7134_BOARD_CINERGY200 38
164 #define SAA7134_BOARD_FLYTVPLATINUM_MINI 39
165 #define SAA7134_BOARD_VIDEOMATE_TV_PVR 40
166 #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41
167 #define SAA7134_BOARD_SABRENT_SBTTVFM 42
168 #define SAA7134_BOARD_ZOLID_XPERT_TV7134 43
169 #define SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE 44
170 #define SAA7134_BOARD_AVERMEDIA_307 45
171 #define SAA7134_BOARD_AVERMEDIA_CARDBUS 46
172 #define SAA7134_BOARD_CINERGY400_CARDBUS 47
173 #define SAA7134_BOARD_CINERGY600_MK3 48
174 #define SAA7134_BOARD_VIDEOMATE_GOLD_PLUS 49
175 #define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50
176 #define SAA7134_BOARD_PROVIDEO_PV952 51
177 #define SAA7134_BOARD_AVERMEDIA_305 52
178 #define SAA7135_BOARD_ASUSTeK_TVFM7135 53
179 #define SAA7134_BOARD_FLYTVPLATINUM_FM 54
180 #define SAA7134_BOARD_FLYDVBTDUO 55
182 #define SAA7134_MAXBOARDS 8
183 #define SAA7134_INPUT_MAX 8
185 struct saa7134_input {
186 char *name;
187 unsigned int vmux;
188 enum saa7134_audio_in amux;
189 unsigned int gpio;
190 unsigned int tv:1;
193 enum saa7134_mpeg_type {
194 SAA7134_MPEG_UNUSED,
195 SAA7134_MPEG_EMPRESS,
196 SAA7134_MPEG_DVB,
199 struct saa7134_board {
200 char *name;
201 unsigned int audio_clock;
203 /* input switching */
204 unsigned int gpiomask;
205 struct saa7134_input inputs[SAA7134_INPUT_MAX];
206 struct saa7134_input radio;
207 struct saa7134_input mute;
209 /* i2c chip info */
210 unsigned int tuner_type;
211 unsigned int tda9887_conf;
213 /* peripheral I/O */
214 enum saa7134_video_out video_out;
215 enum saa7134_mpeg_type mpeg;
218 #define card_has_radio(dev) (NULL != saa7134_boards[dev->board].radio.name)
219 #define card_is_empress(dev) (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg)
220 #define card_is_dvb(dev) (SAA7134_MPEG_DVB == saa7134_boards[dev->board].mpeg)
221 #define card_has_mpeg(dev) (SAA7134_MPEG_UNUSED != saa7134_boards[dev->board].mpeg)
222 #define card(dev) (saa7134_boards[dev->board])
223 #define card_in(dev,n) (saa7134_boards[dev->board].inputs[n])
225 /* ----------------------------------------------------------- */
226 /* device / file handle status */
228 #define RESOURCE_OVERLAY 1
229 #define RESOURCE_VIDEO 2
230 #define RESOURCE_VBI 4
232 #define INTERLACE_AUTO 0
233 #define INTERLACE_ON 1
234 #define INTERLACE_OFF 2
236 #define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
238 struct saa7134_dev;
239 struct saa7134_dma;
241 /* saa7134 page table */
242 struct saa7134_pgtable {
243 unsigned int size;
244 u32 *cpu;
245 dma_addr_t dma;
248 /* tvaudio thread status */
249 struct saa7134_thread {
250 pid_t pid;
251 struct completion exit;
252 wait_queue_head_t wq;
253 unsigned int shutdown;
254 unsigned int scan1;
255 unsigned int scan2;
256 unsigned int mode;
259 /* buffer for one video/vbi/ts frame */
260 struct saa7134_buf {
261 /* common v4l buffer stuff -- must be first */
262 struct videobuf_buffer vb;
264 /* saa7134 specific */
265 struct saa7134_format *fmt;
266 unsigned int top_seen;
267 int (*activate)(struct saa7134_dev *dev,
268 struct saa7134_buf *buf,
269 struct saa7134_buf *next);
271 /* page tables */
272 struct saa7134_pgtable *pt;
275 struct saa7134_dmaqueue {
276 struct saa7134_dev *dev;
277 struct saa7134_buf *curr;
278 struct list_head queue;
279 struct timer_list timeout;
280 unsigned int need_two;
283 /* video filehandle status */
284 struct saa7134_fh {
285 struct saa7134_dev *dev;
286 unsigned int radio;
287 enum v4l2_buf_type type;
288 unsigned int resources;
289 #ifdef VIDIOC_G_PRIORITY
290 enum v4l2_priority prio;
291 #endif
293 /* video overlay */
294 struct v4l2_window win;
295 struct v4l2_clip clips[8];
296 unsigned int nclips;
298 /* video capture */
299 struct saa7134_format *fmt;
300 unsigned int width,height;
301 struct videobuf_queue cap;
302 struct saa7134_pgtable pt_cap;
304 /* vbi capture */
305 struct videobuf_queue vbi;
306 struct saa7134_pgtable pt_vbi;
309 /* oss dsp status */
310 struct saa7134_oss {
311 struct semaphore lock;
312 int minor_mixer;
313 int minor_dsp;
314 unsigned int users_dsp;
316 /* mixer */
317 enum saa7134_audio_in input;
318 unsigned int count;
319 unsigned int line1;
320 unsigned int line2;
322 /* dsp */
323 unsigned int afmt;
324 unsigned int rate;
325 unsigned int channels;
326 unsigned int recording_on;
327 unsigned int dma_running;
328 unsigned int blocks;
329 unsigned int blksize;
330 unsigned int bufsize;
331 struct saa7134_pgtable pt;
332 struct videobuf_dmabuf dma;
333 wait_queue_head_t wq;
334 unsigned int dma_blk;
335 unsigned int read_offset;
336 unsigned int read_count;
339 /* IR input */
340 struct saa7134_ir {
341 struct input_dev dev;
342 struct ir_input_state ir;
343 char name[32];
344 char phys[32];
345 u32 mask_keycode;
346 u32 mask_keydown;
347 u32 mask_keyup;
348 int polling;
349 u32 last_gpio;
350 struct timer_list timer;
353 /* ts/mpeg status */
354 struct saa7134_ts {
355 /* TS capture */
356 struct saa7134_pgtable pt_ts;
357 int nr_packets;
358 int nr_bufs;
361 /* ts/mpeg ops */
362 struct saa7134_mpeg_ops {
363 enum saa7134_mpeg_type type;
364 struct list_head next;
365 int (*init)(struct saa7134_dev *dev);
366 int (*fini)(struct saa7134_dev *dev);
367 void (*signal_change)(struct saa7134_dev *dev);
370 /* global device status */
371 struct saa7134_dev {
372 struct list_head devlist;
373 struct semaphore lock;
374 spinlock_t slock;
375 #ifdef VIDIOC_G_PRIORITY
376 struct v4l2_prio_state prio;
377 #endif
379 /* various device info */
380 unsigned int resources;
381 struct video_device *video_dev;
382 struct video_device *radio_dev;
383 struct video_device *vbi_dev;
384 struct saa7134_oss oss;
386 /* infrared remote */
387 int has_remote;
388 struct saa7134_ir *remote;
390 /* pci i/o */
391 char name[32];
392 int nr;
393 struct pci_dev *pci;
394 unsigned char pci_rev,pci_lat;
395 __u32 __iomem *lmmio;
396 __u8 __iomem *bmmio;
398 /* config info */
399 unsigned int board;
400 unsigned int tuner_type;
401 unsigned int tda9887_conf;
402 unsigned int gpio_value;
403 unsigned int irq2_mask;
405 /* i2c i/o */
406 struct i2c_adapter i2c_adap;
407 struct i2c_client i2c_client;
408 unsigned char eedata[64];
410 /* video overlay */
411 struct v4l2_framebuffer ovbuf;
412 struct saa7134_format *ovfmt;
413 unsigned int ovenable;
414 enum v4l2_field ovfield;
416 /* video+ts+vbi capture */
417 struct saa7134_dmaqueue video_q;
418 struct saa7134_dmaqueue vbi_q;
419 unsigned int video_fieldcount;
420 unsigned int vbi_fieldcount;
422 /* various v4l controls */
423 struct saa7134_tvnorm *tvnorm; /* video */
424 struct saa7134_tvaudio *tvaudio;
425 unsigned int ctl_input;
426 int ctl_bright;
427 int ctl_contrast;
428 int ctl_hue;
429 int ctl_saturation;
430 int ctl_freq;
431 int ctl_mute; /* audio */
432 int ctl_volume;
433 int ctl_invert; /* private */
434 int ctl_mirror;
435 int ctl_y_odd;
436 int ctl_y_even;
437 int ctl_automute;
439 /* crop */
440 struct v4l2_rect crop_bounds;
441 struct v4l2_rect crop_defrect;
442 struct v4l2_rect crop_current;
444 /* other global state info */
445 unsigned int automute;
446 struct saa7134_thread thread;
447 struct saa7134_input *input;
448 struct saa7134_input *hw_input;
449 unsigned int hw_mute;
450 int last_carrier;
451 int nosignal;
453 /* SAA7134_MPEG_* */
454 struct saa7134_ts ts;
455 struct saa7134_dmaqueue ts_q;
456 struct saa7134_mpeg_ops *mops;
458 /* SAA7134_MPEG_EMPRESS only */
459 struct video_device *empress_dev;
460 struct videobuf_queue empress_tsq;
461 unsigned int empress_users;
462 struct work_struct empress_workqueue;
463 int empress_started;
465 /* SAA7134_MPEG_DVB only */
466 struct videobuf_dvb dvb;
469 /* ----------------------------------------------------------- */
471 #define saa_readl(reg) readl(dev->lmmio + (reg))
472 #define saa_writel(reg,value) writel((value), dev->lmmio + (reg));
473 #define saa_andorl(reg,mask,value) \
474 writel((readl(dev->lmmio+(reg)) & ~(mask)) |\
475 ((value) & (mask)), dev->lmmio+(reg))
476 #define saa_setl(reg,bit) saa_andorl((reg),(bit),(bit))
477 #define saa_clearl(reg,bit) saa_andorl((reg),(bit),0)
479 #define saa_readb(reg) readb(dev->bmmio + (reg))
480 #define saa_writeb(reg,value) writeb((value), dev->bmmio + (reg));
481 #define saa_andorb(reg,mask,value) \
482 writeb((readb(dev->bmmio+(reg)) & ~(mask)) |\
483 ((value) & (mask)), dev->bmmio+(reg))
484 #define saa_setb(reg,bit) saa_andorb((reg),(bit),(bit))
485 #define saa_clearb(reg,bit) saa_andorb((reg),(bit),0)
487 #define saa_wait(us) { udelay(us); }
489 /* ----------------------------------------------------------- */
490 /* saa7134-core.c */
492 extern struct list_head saa7134_devlist;
494 void saa7134_print_ioctl(char *name, unsigned int cmd);
495 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
497 #define SAA7134_PGTABLE_SIZE 4096
499 int saa7134_pgtable_alloc(struct pci_dev *pci, struct saa7134_pgtable *pt);
500 int saa7134_pgtable_build(struct pci_dev *pci, struct saa7134_pgtable *pt,
501 struct scatterlist *list, unsigned int length,
502 unsigned int startpage);
503 void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt);
505 int saa7134_buffer_count(unsigned int size, unsigned int count);
506 int saa7134_buffer_startpage(struct saa7134_buf *buf);
507 unsigned long saa7134_buffer_base(struct saa7134_buf *buf);
509 int saa7134_buffer_queue(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
510 struct saa7134_buf *buf);
511 void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
512 unsigned int state);
513 void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
514 void saa7134_buffer_timeout(unsigned long data);
515 void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
517 int saa7134_set_dmabits(struct saa7134_dev *dev);
519 /* ----------------------------------------------------------- */
520 /* saa7134-cards.c */
522 extern struct saa7134_board saa7134_boards[];
523 extern const unsigned int saa7134_bcount;
524 extern struct pci_device_id __devinitdata saa7134_pci_tbl[];
526 extern int saa7134_board_init1(struct saa7134_dev *dev);
527 extern int saa7134_board_init2(struct saa7134_dev *dev);
530 /* ----------------------------------------------------------- */
531 /* saa7134-i2c.c */
533 int saa7134_i2c_register(struct saa7134_dev *dev);
534 int saa7134_i2c_unregister(struct saa7134_dev *dev);
535 void saa7134_i2c_call_clients(struct saa7134_dev *dev,
536 unsigned int cmd, void *arg);
539 /* ----------------------------------------------------------- */
540 /* saa7134-video.c */
542 extern struct video_device saa7134_video_template;
543 extern struct video_device saa7134_radio_template;
545 int saa7134_common_ioctl(struct saa7134_dev *dev,
546 unsigned int cmd, void *arg);
548 int saa7134_video_init1(struct saa7134_dev *dev);
549 int saa7134_video_init2(struct saa7134_dev *dev);
550 int saa7134_video_fini(struct saa7134_dev *dev);
551 void saa7134_irq_video_intl(struct saa7134_dev *dev);
552 void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
555 /* ----------------------------------------------------------- */
556 /* saa7134-ts.c */
558 #define TS_PACKET_SIZE 188 /* TS packets 188 bytes */
560 extern struct videobuf_queue_ops saa7134_ts_qops;
562 int saa7134_ts_init1(struct saa7134_dev *dev);
563 int saa7134_ts_fini(struct saa7134_dev *dev);
564 void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status);
566 int saa7134_ts_register(struct saa7134_mpeg_ops *ops);
567 void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops);
569 /* ----------------------------------------------------------- */
570 /* saa7134-vbi.c */
572 extern struct videobuf_queue_ops saa7134_vbi_qops;
573 extern struct video_device saa7134_vbi_template;
575 int saa7134_vbi_init1(struct saa7134_dev *dev);
576 int saa7134_vbi_fini(struct saa7134_dev *dev);
577 void saa7134_irq_vbi_done(struct saa7134_dev *dev, unsigned long status);
580 /* ----------------------------------------------------------- */
581 /* saa7134-tvaudio.c */
583 int saa7134_tvaudio_rx2mode(u32 rx);
585 void saa7134_tvaudio_setmute(struct saa7134_dev *dev);
586 void saa7134_tvaudio_setinput(struct saa7134_dev *dev,
587 struct saa7134_input *in);
588 void saa7134_tvaudio_setvolume(struct saa7134_dev *dev, int level);
589 int saa7134_tvaudio_getstereo(struct saa7134_dev *dev);
591 int saa7134_tvaudio_init2(struct saa7134_dev *dev);
592 int saa7134_tvaudio_fini(struct saa7134_dev *dev);
593 int saa7134_tvaudio_do_scan(struct saa7134_dev *dev);
595 int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value);
597 /* ----------------------------------------------------------- */
598 /* saa7134-oss.c */
600 extern struct file_operations saa7134_dsp_fops;
601 extern struct file_operations saa7134_mixer_fops;
603 int saa7134_oss_init1(struct saa7134_dev *dev);
604 int saa7134_oss_fini(struct saa7134_dev *dev);
605 void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status);
607 /* ----------------------------------------------------------- */
608 /* saa7134-input.c */
610 int saa7134_input_init1(struct saa7134_dev *dev);
611 void saa7134_input_fini(struct saa7134_dev *dev);
612 void saa7134_input_irq(struct saa7134_dev *dev);
615 * Local variables:
616 * c-basic-offset: 8
617 * End: