[ARM] pxa: Gumstix Verdex PCMCIA support
[linux-2.6/verdex.git] / drivers / media / video / saa7134 / saa7134-core.c
blobf87757fccc72114bdafe8ad4454f8e9a3b49b20e
1 /*
3 * device driver for philips saa7134 based TV cards
4 * driver core
6 * (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
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/init.h>
24 #include <linux/list.h>
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/slab.h>
28 #include <linux/kmod.h>
29 #include <linux/sound.h>
30 #include <linux/interrupt.h>
31 #include <linux/delay.h>
32 #include <linux/mutex.h>
33 #include <linux/dma-mapping.h>
34 #include <linux/pm.h>
36 #include "saa7134-reg.h"
37 #include "saa7134.h"
39 MODULE_DESCRIPTION("v4l2 driver module for saa7130/34 based TV cards");
40 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
41 MODULE_LICENSE("GPL");
43 /* ------------------------------------------------------------------ */
45 static unsigned int irq_debug;
46 module_param(irq_debug, int, 0644);
47 MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
49 static unsigned int core_debug;
50 module_param(core_debug, int, 0644);
51 MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
53 static unsigned int gpio_tracking;
54 module_param(gpio_tracking, int, 0644);
55 MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
57 static unsigned int alsa = 1;
58 module_param(alsa, int, 0644);
59 MODULE_PARM_DESC(alsa,"enable/disable ALSA DMA sound [dmasound]");
61 static unsigned int latency = UNSET;
62 module_param(latency, int, 0444);
63 MODULE_PARM_DESC(latency,"pci latency timer");
65 int saa7134_no_overlay=-1;
66 module_param_named(no_overlay, saa7134_no_overlay, int, 0444);
67 MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
68 " [some VIA/SIS chipsets are known to have problem with overlay]");
70 static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
71 static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
72 static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
73 static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
74 static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
77 module_param_array(video_nr, int, NULL, 0444);
78 module_param_array(vbi_nr, int, NULL, 0444);
79 module_param_array(radio_nr, int, NULL, 0444);
80 module_param_array(tuner, int, NULL, 0444);
81 module_param_array(card, int, NULL, 0444);
83 MODULE_PARM_DESC(video_nr, "video device number");
84 MODULE_PARM_DESC(vbi_nr, "vbi device number");
85 MODULE_PARM_DESC(radio_nr, "radio device number");
86 MODULE_PARM_DESC(tuner, "tuner type");
87 MODULE_PARM_DESC(card, "card type");
89 DEFINE_MUTEX(saa7134_devlist_lock);
90 EXPORT_SYMBOL(saa7134_devlist_lock);
91 LIST_HEAD(saa7134_devlist);
92 EXPORT_SYMBOL(saa7134_devlist);
93 static LIST_HEAD(mops_list);
94 static unsigned int saa7134_devcount;
96 int (*saa7134_dmasound_init)(struct saa7134_dev *dev);
97 int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
99 #define dprintk(fmt, arg...) if (core_debug) \
100 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
102 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
104 unsigned long mode,status;
106 if (!gpio_tracking)
107 return;
108 /* rising SAA7134_GPIO_GPRESCAN reads the status */
109 saa_andorb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN,0);
110 saa_andorb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN,SAA7134_GPIO_GPRESCAN);
111 mode = saa_readl(SAA7134_GPIO_GPMODE0 >> 2) & 0xfffffff;
112 status = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & 0xfffffff;
113 printk(KERN_DEBUG
114 "%s: gpio: mode=0x%07lx in=0x%07lx out=0x%07lx [%s]\n",
115 dev->name, mode, (~mode) & status, mode & status, msg);
118 void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
120 u32 index, bitval;
122 index = 1 << bit_no;
123 switch (value) {
124 case 0: /* static value */
125 case 1: dprintk("setting GPIO%d to static %d\n", bit_no, value);
126 /* turn sync mode off if necessary */
127 if (index & 0x00c00000)
128 saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x00);
129 if (value)
130 bitval = index;
131 else
132 bitval = 0;
133 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, index);
134 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, index, bitval);
135 break;
136 case 3: /* tristate */
137 dprintk("setting GPIO%d to tristate\n", bit_no);
138 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0);
139 break;
143 /* ------------------------------------------------------------------ */
146 /* ----------------------------------------------------------- */
147 /* delayed request_module */
149 #if defined(CONFIG_MODULES) && defined(MODULE)
151 static void request_module_async(struct work_struct *work){
152 struct saa7134_dev* dev = container_of(work, struct saa7134_dev, request_module_wk);
153 if (card_is_empress(dev))
154 request_module("saa7134-empress");
155 if (card_is_dvb(dev))
156 request_module("saa7134-dvb");
157 if (alsa) {
158 if (dev->pci->device != PCI_DEVICE_ID_PHILIPS_SAA7130)
159 request_module("saa7134-alsa");
163 static void request_submodules(struct saa7134_dev *dev)
165 INIT_WORK(&dev->request_module_wk, request_module_async);
166 schedule_work(&dev->request_module_wk);
169 #else
170 #define request_submodules(dev)
171 #endif /* CONFIG_MODULES */
173 /* ------------------------------------------------------------------ */
175 /* nr of (saa7134-)pages for the given buffer size */
176 static int saa7134_buffer_pages(int size)
178 size = PAGE_ALIGN(size);
179 size += PAGE_SIZE; /* for non-page-aligned buffers */
180 size /= 4096;
181 return size;
184 /* calc max # of buffers from size (must not exceed the 4MB virtual
185 * address space per DMA channel) */
186 int saa7134_buffer_count(unsigned int size, unsigned int count)
188 unsigned int maxcount;
190 maxcount = 1024 / saa7134_buffer_pages(size);
191 if (count > maxcount)
192 count = maxcount;
193 return count;
196 int saa7134_buffer_startpage(struct saa7134_buf *buf)
198 return saa7134_buffer_pages(buf->vb.bsize) * buf->vb.i;
201 unsigned long saa7134_buffer_base(struct saa7134_buf *buf)
203 unsigned long base;
204 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
206 base = saa7134_buffer_startpage(buf) * 4096;
207 base += dma->sglist[0].offset;
208 return base;
211 /* ------------------------------------------------------------------ */
213 int saa7134_pgtable_alloc(struct pci_dev *pci, struct saa7134_pgtable *pt)
215 __le32 *cpu;
216 dma_addr_t dma_addr = 0;
218 cpu = pci_alloc_consistent(pci, SAA7134_PGTABLE_SIZE, &dma_addr);
219 if (NULL == cpu)
220 return -ENOMEM;
221 pt->size = SAA7134_PGTABLE_SIZE;
222 pt->cpu = cpu;
223 pt->dma = dma_addr;
224 return 0;
227 int saa7134_pgtable_build(struct pci_dev *pci, struct saa7134_pgtable *pt,
228 struct scatterlist *list, unsigned int length,
229 unsigned int startpage)
231 __le32 *ptr;
232 unsigned int i,p;
234 BUG_ON(NULL == pt || NULL == pt->cpu);
236 ptr = pt->cpu + startpage;
237 for (i = 0; i < length; i++, list++)
238 for (p = 0; p * 4096 < list->length; p++, ptr++)
239 *ptr = cpu_to_le32(sg_dma_address(list) - list->offset);
240 return 0;
243 void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
245 if (NULL == pt->cpu)
246 return;
247 pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
248 pt->cpu = NULL;
251 /* ------------------------------------------------------------------ */
253 void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
255 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
256 BUG_ON(in_interrupt());
258 videobuf_waiton(&buf->vb,0,0);
259 videobuf_dma_unmap(q, dma);
260 videobuf_dma_free(dma);
261 buf->vb.state = VIDEOBUF_NEEDS_INIT;
264 /* ------------------------------------------------------------------ */
266 int saa7134_buffer_queue(struct saa7134_dev *dev,
267 struct saa7134_dmaqueue *q,
268 struct saa7134_buf *buf)
270 struct saa7134_buf *next = NULL;
272 assert_spin_locked(&dev->slock);
273 dprintk("buffer_queue %p\n",buf);
274 if (NULL == q->curr) {
275 if (!q->need_two) {
276 q->curr = buf;
277 buf->activate(dev,buf,NULL);
278 } else if (list_empty(&q->queue)) {
279 list_add_tail(&buf->vb.queue,&q->queue);
280 buf->vb.state = VIDEOBUF_QUEUED;
281 } else {
282 next = list_entry(q->queue.next,struct saa7134_buf,
283 vb.queue);
284 q->curr = buf;
285 buf->activate(dev,buf,next);
287 } else {
288 list_add_tail(&buf->vb.queue,&q->queue);
289 buf->vb.state = VIDEOBUF_QUEUED;
291 return 0;
294 void saa7134_buffer_finish(struct saa7134_dev *dev,
295 struct saa7134_dmaqueue *q,
296 unsigned int state)
298 assert_spin_locked(&dev->slock);
299 dprintk("buffer_finish %p\n",q->curr);
301 /* finish current buffer */
302 q->curr->vb.state = state;
303 do_gettimeofday(&q->curr->vb.ts);
304 wake_up(&q->curr->vb.done);
305 q->curr = NULL;
308 void saa7134_buffer_next(struct saa7134_dev *dev,
309 struct saa7134_dmaqueue *q)
311 struct saa7134_buf *buf,*next = NULL;
313 assert_spin_locked(&dev->slock);
314 BUG_ON(NULL != q->curr);
316 if (!list_empty(&q->queue)) {
317 /* activate next one from queue */
318 buf = list_entry(q->queue.next,struct saa7134_buf,vb.queue);
319 dprintk("buffer_next %p [prev=%p/next=%p]\n",
320 buf,q->queue.prev,q->queue.next);
321 list_del(&buf->vb.queue);
322 if (!list_empty(&q->queue))
323 next = list_entry(q->queue.next,struct saa7134_buf,
324 vb.queue);
325 q->curr = buf;
326 buf->activate(dev,buf,next);
327 dprintk("buffer_next #2 prev=%p/next=%p\n",
328 q->queue.prev,q->queue.next);
329 } else {
330 /* nothing to do -- just stop DMA */
331 dprintk("buffer_next %p\n",NULL);
332 saa7134_set_dmabits(dev);
333 del_timer(&q->timeout);
335 if (card_has_mpeg(dev))
336 if (dev->ts_started)
337 saa7134_ts_stop(dev);
341 void saa7134_buffer_timeout(unsigned long data)
343 struct saa7134_dmaqueue *q = (struct saa7134_dmaqueue*)data;
344 struct saa7134_dev *dev = q->dev;
345 unsigned long flags;
347 spin_lock_irqsave(&dev->slock,flags);
349 /* try to reset the hardware (SWRST) */
350 saa_writeb(SAA7134_REGION_ENABLE, 0x00);
351 saa_writeb(SAA7134_REGION_ENABLE, 0x80);
352 saa_writeb(SAA7134_REGION_ENABLE, 0x00);
354 /* flag current buffer as failed,
355 try to start over with the next one. */
356 if (q->curr) {
357 dprintk("timeout on %p\n",q->curr);
358 saa7134_buffer_finish(dev,q,VIDEOBUF_ERROR);
360 saa7134_buffer_next(dev,q);
361 spin_unlock_irqrestore(&dev->slock,flags);
364 /* ------------------------------------------------------------------ */
366 int saa7134_set_dmabits(struct saa7134_dev *dev)
368 u32 split, task=0, ctrl=0, irq=0;
369 enum v4l2_field cap = V4L2_FIELD_ANY;
370 enum v4l2_field ov = V4L2_FIELD_ANY;
372 assert_spin_locked(&dev->slock);
374 if (dev->insuspend)
375 return 0;
377 /* video capture -- dma 0 + video task A */
378 if (dev->video_q.curr) {
379 task |= 0x01;
380 ctrl |= SAA7134_MAIN_CTRL_TE0;
381 irq |= SAA7134_IRQ1_INTE_RA0_1 |
382 SAA7134_IRQ1_INTE_RA0_0;
383 cap = dev->video_q.curr->vb.field;
386 /* video capture -- dma 1+2 (planar modes) */
387 if (dev->video_q.curr &&
388 dev->video_q.curr->fmt->planar) {
389 ctrl |= SAA7134_MAIN_CTRL_TE4 |
390 SAA7134_MAIN_CTRL_TE5;
393 /* screen overlay -- dma 0 + video task B */
394 if (dev->ovenable) {
395 task |= 0x10;
396 ctrl |= SAA7134_MAIN_CTRL_TE1;
397 ov = dev->ovfield;
400 /* vbi capture -- dma 0 + vbi task A+B */
401 if (dev->vbi_q.curr) {
402 task |= 0x22;
403 ctrl |= SAA7134_MAIN_CTRL_TE2 |
404 SAA7134_MAIN_CTRL_TE3;
405 irq |= SAA7134_IRQ1_INTE_RA0_7 |
406 SAA7134_IRQ1_INTE_RA0_6 |
407 SAA7134_IRQ1_INTE_RA0_5 |
408 SAA7134_IRQ1_INTE_RA0_4;
411 /* audio capture -- dma 3 */
412 if (dev->dmasound.dma_running) {
413 ctrl |= SAA7134_MAIN_CTRL_TE6;
414 irq |= SAA7134_IRQ1_INTE_RA3_1 |
415 SAA7134_IRQ1_INTE_RA3_0;
418 /* TS capture -- dma 5 */
419 if (dev->ts_q.curr) {
420 ctrl |= SAA7134_MAIN_CTRL_TE5;
421 irq |= SAA7134_IRQ1_INTE_RA2_1 |
422 SAA7134_IRQ1_INTE_RA2_0;
424 /* dma: setup channel 5 (= TS) */
426 saa_writeb(SAA7134_TS_DMA0, (dev->ts.nr_packets - 1) & 0xff);
427 saa_writeb(SAA7134_TS_DMA1,
428 ((dev->ts.nr_packets - 1) >> 8) & 0xff);
429 /* TSNOPIT=0, TSCOLAP=0 */
430 saa_writeb(SAA7134_TS_DMA2,
431 (((dev->ts.nr_packets - 1) >> 16) & 0x3f) | 0x00);
432 saa_writel(SAA7134_RS_PITCH(5), TS_PACKET_SIZE);
433 saa_writel(SAA7134_RS_CONTROL(5), SAA7134_RS_CONTROL_BURST_16 |
434 SAA7134_RS_CONTROL_ME |
435 (dev->ts.pt_ts.dma >> 12));
438 /* set task conditions + field handling */
439 if (V4L2_FIELD_HAS_BOTH(cap) || V4L2_FIELD_HAS_BOTH(ov) || cap == ov) {
440 /* default config -- use full frames */
441 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0d);
442 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0d);
443 saa_writeb(SAA7134_FIELD_HANDLING(TASK_A), 0x02);
444 saa_writeb(SAA7134_FIELD_HANDLING(TASK_B), 0x02);
445 split = 0;
446 } else {
447 /* split fields between tasks */
448 if (V4L2_FIELD_TOP == cap) {
449 /* odd A, even B, repeat */
450 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0d);
451 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0e);
452 } else {
453 /* odd B, even A, repeat */
454 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0e);
455 saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0d);
457 saa_writeb(SAA7134_FIELD_HANDLING(TASK_A), 0x01);
458 saa_writeb(SAA7134_FIELD_HANDLING(TASK_B), 0x01);
459 split = 1;
462 /* irqs */
463 saa_writeb(SAA7134_REGION_ENABLE, task);
464 saa_writel(SAA7134_IRQ1, irq);
465 saa_andorl(SAA7134_MAIN_CTRL,
466 SAA7134_MAIN_CTRL_TE0 |
467 SAA7134_MAIN_CTRL_TE1 |
468 SAA7134_MAIN_CTRL_TE2 |
469 SAA7134_MAIN_CTRL_TE3 |
470 SAA7134_MAIN_CTRL_TE4 |
471 SAA7134_MAIN_CTRL_TE5 |
472 SAA7134_MAIN_CTRL_TE6,
473 ctrl);
474 dprintk("dmabits: task=0x%02x ctrl=0x%02x irq=0x%x split=%s\n",
475 task, ctrl, irq, split ? "no" : "yes");
477 return 0;
480 /* ------------------------------------------------------------------ */
481 /* IRQ handler + helpers */
483 static char *irqbits[] = {
484 "DONE_RA0", "DONE_RA1", "DONE_RA2", "DONE_RA3",
485 "AR", "PE", "PWR_ON", "RDCAP", "INTL", "FIDT", "MMC",
486 "TRIG_ERR", "CONF_ERR", "LOAD_ERR",
487 "GPIO16?", "GPIO18", "GPIO22", "GPIO23"
489 #define IRQBITS ARRAY_SIZE(irqbits)
491 static void print_irqstatus(struct saa7134_dev *dev, int loop,
492 unsigned long report, unsigned long status)
494 unsigned int i;
496 printk(KERN_DEBUG "%s/irq[%d,%ld]: r=0x%lx s=0x%02lx",
497 dev->name,loop,jiffies,report,status);
498 for (i = 0; i < IRQBITS; i++) {
499 if (!(report & (1 << i)))
500 continue;
501 printk(" %s",irqbits[i]);
503 if (report & SAA7134_IRQ_REPORT_DONE_RA0) {
504 printk(" | RA0=%s,%s,%s,%ld",
505 (status & 0x40) ? "vbi" : "video",
506 (status & 0x20) ? "b" : "a",
507 (status & 0x10) ? "odd" : "even",
508 (status & 0x0f));
510 printk("\n");
513 static irqreturn_t saa7134_irq(int irq, void *dev_id)
515 struct saa7134_dev *dev = (struct saa7134_dev*) dev_id;
516 unsigned long report,status;
517 int loop, handled = 0;
519 if (dev->insuspend)
520 goto out;
522 for (loop = 0; loop < 10; loop++) {
523 report = saa_readl(SAA7134_IRQ_REPORT);
524 status = saa_readl(SAA7134_IRQ_STATUS);
526 /* If dmasound support is active and we get a sound report,
527 * mask out the report and let the saa7134-alsa module deal
528 * with it */
529 if ((report & SAA7134_IRQ_REPORT_DONE_RA3) &&
530 (dev->dmasound.priv_data != NULL) )
532 if (irq_debug > 1)
533 printk(KERN_DEBUG "%s/irq: preserving DMA sound interrupt\n",
534 dev->name);
535 report &= ~SAA7134_IRQ_REPORT_DONE_RA3;
538 if (0 == report) {
539 if (irq_debug > 1)
540 printk(KERN_DEBUG "%s/irq: no (more) work\n",
541 dev->name);
542 goto out;
545 handled = 1;
546 saa_writel(SAA7134_IRQ_REPORT,report);
547 if (irq_debug)
548 print_irqstatus(dev,loop,report,status);
551 if ((report & SAA7134_IRQ_REPORT_RDCAP) ||
552 (report & SAA7134_IRQ_REPORT_INTL))
553 saa7134_irq_video_signalchange(dev);
556 if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
557 (status & 0x60) == 0)
558 saa7134_irq_video_done(dev,status);
560 if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
561 (status & 0x40) == 0x40)
562 saa7134_irq_vbi_done(dev,status);
564 if ((report & SAA7134_IRQ_REPORT_DONE_RA2) &&
565 card_has_mpeg(dev))
566 saa7134_irq_ts_done(dev,status);
568 if (report & SAA7134_IRQ_REPORT_GPIO16) {
569 switch (dev->has_remote) {
570 case SAA7134_REMOTE_GPIO:
571 if (!dev->remote)
572 break;
573 if (dev->remote->mask_keydown & 0x10000) {
574 saa7134_input_irq(dev);
576 break;
578 case SAA7134_REMOTE_I2C:
579 break; /* FIXME: invoke I2C get_key() */
581 default: /* GPIO16 not used by IR remote */
582 break;
586 if (report & SAA7134_IRQ_REPORT_GPIO18) {
587 switch (dev->has_remote) {
588 case SAA7134_REMOTE_GPIO:
589 if (!dev->remote)
590 break;
591 if ((dev->remote->mask_keydown & 0x40000) ||
592 (dev->remote->mask_keyup & 0x40000)) {
593 saa7134_input_irq(dev);
595 break;
597 case SAA7134_REMOTE_I2C:
598 break; /* FIXME: invoke I2C get_key() */
600 default: /* GPIO18 not used by IR remote */
601 break;
606 if (10 == loop) {
607 print_irqstatus(dev,loop,report,status);
608 if (report & SAA7134_IRQ_REPORT_PE) {
609 /* disable all parity error */
610 printk(KERN_WARNING "%s/irq: looping -- "
611 "clearing PE (parity error!) enable bit\n",dev->name);
612 saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE);
613 } else if (report & SAA7134_IRQ_REPORT_GPIO16) {
614 /* disable gpio16 IRQ */
615 printk(KERN_WARNING "%s/irq: looping -- "
616 "clearing GPIO16 enable bit\n",dev->name);
617 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16);
618 } else if (report & SAA7134_IRQ_REPORT_GPIO18) {
619 /* disable gpio18 IRQs */
620 printk(KERN_WARNING "%s/irq: looping -- "
621 "clearing GPIO18 enable bit\n",dev->name);
622 saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
623 } else {
624 /* disable all irqs */
625 printk(KERN_WARNING "%s/irq: looping -- "
626 "clearing all enable bits\n",dev->name);
627 saa_writel(SAA7134_IRQ1,0);
628 saa_writel(SAA7134_IRQ2,0);
632 out:
633 return IRQ_RETVAL(handled);
636 /* ------------------------------------------------------------------ */
638 /* early init (no i2c, no irq) */
640 static int saa7134_hw_enable1(struct saa7134_dev *dev)
642 /* RAM FIFO config */
643 saa_writel(SAA7134_FIFO_SIZE, 0x08070503);
644 saa_writel(SAA7134_THRESHOULD, 0x02020202);
646 /* enable audio + video processing */
647 saa_writel(SAA7134_MAIN_CTRL,
648 SAA7134_MAIN_CTRL_VPLLE |
649 SAA7134_MAIN_CTRL_APLLE |
650 SAA7134_MAIN_CTRL_EXOSC |
651 SAA7134_MAIN_CTRL_EVFE1 |
652 SAA7134_MAIN_CTRL_EVFE2 |
653 SAA7134_MAIN_CTRL_ESFE |
654 SAA7134_MAIN_CTRL_EBDAC);
657 * Initialize OSS _after_ enabling audio clock PLL and audio processing.
658 * OSS initialization writes to registers via the audio DSP; these
659 * writes will fail unless the audio clock has been started. At worst,
660 * audio will not work.
663 /* enable peripheral devices */
664 saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
666 /* set vertical line numbering start (vbi needs this) */
667 saa_writeb(SAA7134_SOURCE_TIMING2, 0x20);
669 return 0;
672 static int saa7134_hwinit1(struct saa7134_dev *dev)
674 dprintk("hwinit1\n");
676 saa_writel(SAA7134_IRQ1, 0);
677 saa_writel(SAA7134_IRQ2, 0);
679 /* Clear any stale IRQ reports */
680 saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT));
682 mutex_init(&dev->lock);
683 spin_lock_init(&dev->slock);
685 saa7134_track_gpio(dev,"pre-init");
686 saa7134_video_init1(dev);
687 saa7134_vbi_init1(dev);
688 if (card_has_mpeg(dev))
689 saa7134_ts_init1(dev);
690 saa7134_input_init1(dev);
692 saa7134_hw_enable1(dev);
694 return 0;
697 /* late init (with i2c + irq) */
698 static int saa7134_hw_enable2(struct saa7134_dev *dev)
701 unsigned int irq2_mask;
703 /* enable IRQ's */
704 irq2_mask =
705 SAA7134_IRQ2_INTE_DEC3 |
706 SAA7134_IRQ2_INTE_DEC2 |
707 SAA7134_IRQ2_INTE_DEC1 |
708 SAA7134_IRQ2_INTE_DEC0 |
709 SAA7134_IRQ2_INTE_PE |
710 SAA7134_IRQ2_INTE_AR;
712 if (dev->has_remote == SAA7134_REMOTE_GPIO && dev->remote) {
713 if (dev->remote->mask_keydown & 0x10000)
714 irq2_mask |= SAA7134_IRQ2_INTE_GPIO16;
715 else if (dev->remote->mask_keydown & 0x40000)
716 irq2_mask |= SAA7134_IRQ2_INTE_GPIO18;
717 else if (dev->remote->mask_keyup & 0x40000)
718 irq2_mask |= SAA7134_IRQ2_INTE_GPIO18A;
721 if (dev->has_remote == SAA7134_REMOTE_I2C) {
722 request_module("ir-kbd-i2c");
725 saa_writel(SAA7134_IRQ1, 0);
726 saa_writel(SAA7134_IRQ2, irq2_mask);
728 return 0;
731 static int saa7134_hwinit2(struct saa7134_dev *dev)
734 dprintk("hwinit2\n");
736 saa7134_video_init2(dev);
737 saa7134_tvaudio_init2(dev);
739 saa7134_hw_enable2(dev);
741 return 0;
745 /* shutdown */
746 static int saa7134_hwfini(struct saa7134_dev *dev)
748 dprintk("hwfini\n");
750 if (card_has_mpeg(dev))
751 saa7134_ts_fini(dev);
752 saa7134_input_fini(dev);
753 saa7134_vbi_fini(dev);
754 saa7134_tvaudio_fini(dev);
755 return 0;
758 static void __devinit must_configure_manually(void)
760 unsigned int i,p;
762 printk(KERN_WARNING
763 "saa7134: <rant>\n"
764 "saa7134: Congratulations! Your TV card vendor saved a few\n"
765 "saa7134: cents for a eeprom, thus your pci board has no\n"
766 "saa7134: subsystem ID and I can't identify it automatically\n"
767 "saa7134: </rant>\n"
768 "saa7134: I feel better now. Ok, here are the good news:\n"
769 "saa7134: You can use the card=<nr> insmod option to specify\n"
770 "saa7134: which board do you have. The list:\n");
771 for (i = 0; i < saa7134_bcount; i++) {
772 printk(KERN_WARNING "saa7134: card=%d -> %-40.40s",
773 i,saa7134_boards[i].name);
774 for (p = 0; saa7134_pci_tbl[p].driver_data; p++) {
775 if (saa7134_pci_tbl[p].driver_data != i)
776 continue;
777 printk(" %04x:%04x",
778 saa7134_pci_tbl[p].subvendor,
779 saa7134_pci_tbl[p].subdevice);
781 printk("\n");
785 static struct video_device *vdev_init(struct saa7134_dev *dev,
786 struct video_device *template,
787 char *type)
789 struct video_device *vfd;
791 vfd = video_device_alloc();
792 if (NULL == vfd)
793 return NULL;
794 *vfd = *template;
795 vfd->v4l2_dev = &dev->v4l2_dev;
796 vfd->release = video_device_release;
797 vfd->debug = video_debug;
798 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
799 dev->name, type, saa7134_boards[dev->board].name);
800 return vfd;
803 static void saa7134_unregister_video(struct saa7134_dev *dev)
805 if (dev->video_dev) {
806 if (-1 != dev->video_dev->minor)
807 video_unregister_device(dev->video_dev);
808 else
809 video_device_release(dev->video_dev);
810 dev->video_dev = NULL;
812 if (dev->vbi_dev) {
813 if (-1 != dev->vbi_dev->minor)
814 video_unregister_device(dev->vbi_dev);
815 else
816 video_device_release(dev->vbi_dev);
817 dev->vbi_dev = NULL;
819 if (dev->radio_dev) {
820 if (-1 != dev->radio_dev->minor)
821 video_unregister_device(dev->radio_dev);
822 else
823 video_device_release(dev->radio_dev);
824 dev->radio_dev = NULL;
828 static void mpeg_ops_attach(struct saa7134_mpeg_ops *ops,
829 struct saa7134_dev *dev)
831 int err;
833 if (NULL != dev->mops)
834 return;
835 if (saa7134_boards[dev->board].mpeg != ops->type)
836 return;
837 err = ops->init(dev);
838 if (0 != err)
839 return;
840 dev->mops = ops;
843 static void mpeg_ops_detach(struct saa7134_mpeg_ops *ops,
844 struct saa7134_dev *dev)
846 if (NULL == dev->mops)
847 return;
848 if (dev->mops != ops)
849 return;
850 dev->mops->fini(dev);
851 dev->mops = NULL;
854 static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
855 const struct pci_device_id *pci_id)
857 struct saa7134_dev *dev;
858 struct saa7134_mpeg_ops *mops;
859 int err;
861 if (saa7134_devcount == SAA7134_MAXBOARDS)
862 return -ENOMEM;
864 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
865 if (NULL == dev)
866 return -ENOMEM;
868 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
869 if (err)
870 goto fail0;
872 /* pci init */
873 dev->pci = pci_dev;
874 if (pci_enable_device(pci_dev)) {
875 err = -EIO;
876 goto fail1;
879 dev->nr = saa7134_devcount;
880 sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
882 /* pci quirks */
883 if (pci_pci_problems) {
884 if (pci_pci_problems & PCIPCI_TRITON)
885 printk(KERN_INFO "%s: quirk: PCIPCI_TRITON\n", dev->name);
886 if (pci_pci_problems & PCIPCI_NATOMA)
887 printk(KERN_INFO "%s: quirk: PCIPCI_NATOMA\n", dev->name);
888 if (pci_pci_problems & PCIPCI_VIAETBF)
889 printk(KERN_INFO "%s: quirk: PCIPCI_VIAETBF\n", dev->name);
890 if (pci_pci_problems & PCIPCI_VSFX)
891 printk(KERN_INFO "%s: quirk: PCIPCI_VSFX\n",dev->name);
892 #ifdef PCIPCI_ALIMAGIK
893 if (pci_pci_problems & PCIPCI_ALIMAGIK) {
894 printk(KERN_INFO "%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n",
895 dev->name);
896 latency = 0x0A;
898 #endif
899 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) {
900 printk(KERN_INFO "%s: quirk: this driver and your "
901 "chipset may not work together"
902 " in overlay mode.\n",dev->name);
903 if (!saa7134_no_overlay) {
904 printk(KERN_INFO "%s: quirk: overlay "
905 "mode will be disabled.\n",
906 dev->name);
907 saa7134_no_overlay = 1;
908 } else {
909 printk(KERN_INFO "%s: quirk: overlay "
910 "mode will be forced. Use this"
911 " option at your own risk.\n",
912 dev->name);
916 if (UNSET != latency) {
917 printk(KERN_INFO "%s: setting pci latency timer to %d\n",
918 dev->name,latency);
919 pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency);
922 /* print pci info */
923 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
924 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
925 printk(KERN_INFO "%s: found at %s, rev: %d, irq: %d, "
926 "latency: %d, mmio: 0x%llx\n", dev->name,
927 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
928 dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
929 pci_set_master(pci_dev);
930 if (!pci_dma_supported(pci_dev, DMA_BIT_MASK(32))) {
931 printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name);
932 err = -EIO;
933 goto fail1;
936 /* board config */
937 dev->board = pci_id->driver_data;
938 if (card[dev->nr] >= 0 &&
939 card[dev->nr] < saa7134_bcount)
940 dev->board = card[dev->nr];
941 if (SAA7134_BOARD_NOAUTO == dev->board) {
942 must_configure_manually();
943 dev->board = SAA7134_BOARD_UNKNOWN;
945 dev->autodetected = card[dev->nr] != dev->board;
946 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
947 dev->tuner_addr = saa7134_boards[dev->board].tuner_addr;
948 dev->radio_type = saa7134_boards[dev->board].radio_type;
949 dev->radio_addr = saa7134_boards[dev->board].radio_addr;
950 dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf;
951 if (UNSET != tuner[dev->nr])
952 dev->tuner_type = tuner[dev->nr];
953 printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
954 dev->name,pci_dev->subsystem_vendor,
955 pci_dev->subsystem_device,saa7134_boards[dev->board].name,
956 dev->board, dev->autodetected ?
957 "autodetected" : "insmod option");
959 /* get mmio */
960 if (!request_mem_region(pci_resource_start(pci_dev,0),
961 pci_resource_len(pci_dev,0),
962 dev->name)) {
963 err = -EBUSY;
964 printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n",
965 dev->name,(unsigned long long)pci_resource_start(pci_dev,0));
966 goto fail1;
968 dev->lmmio = ioremap(pci_resource_start(pci_dev, 0),
969 pci_resource_len(pci_dev, 0));
970 dev->bmmio = (__u8 __iomem *)dev->lmmio;
971 if (NULL == dev->lmmio) {
972 err = -EIO;
973 printk(KERN_ERR "%s: can't ioremap() MMIO memory\n",
974 dev->name);
975 goto fail2;
978 /* initialize hardware #1 */
979 saa7134_board_init1(dev);
980 saa7134_hwinit1(dev);
982 /* get irq */
983 err = request_irq(pci_dev->irq, saa7134_irq,
984 IRQF_SHARED | IRQF_DISABLED, dev->name, dev);
985 if (err < 0) {
986 printk(KERN_ERR "%s: can't get IRQ %d\n",
987 dev->name,pci_dev->irq);
988 goto fail3;
991 /* wait a bit, register i2c bus */
992 msleep(100);
993 saa7134_i2c_register(dev);
994 saa7134_board_init2(dev);
996 saa7134_hwinit2(dev);
998 /* load i2c helpers */
999 if (card_is_empress(dev)) {
1000 struct v4l2_subdev *sd =
1001 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
1002 "saa6752hs", "saa6752hs",
1003 saa7134_boards[dev->board].empress_addr, NULL);
1005 if (sd)
1006 sd->grp_id = GRP_EMPRESS;
1009 if (saa7134_boards[dev->board].rds_addr) {
1010 struct v4l2_subdev *sd;
1012 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1013 &dev->i2c_adap, "saa6588", "saa6588",
1014 0, I2C_ADDRS(saa7134_boards[dev->board].rds_addr));
1015 if (sd) {
1016 printk(KERN_INFO "%s: found RDS decoder\n", dev->name);
1017 dev->has_rds = 1;
1021 request_submodules(dev);
1023 v4l2_prio_init(&dev->prio);
1025 mutex_lock(&saa7134_devlist_lock);
1026 list_for_each_entry(mops, &mops_list, next)
1027 mpeg_ops_attach(mops, dev);
1028 list_add_tail(&dev->devlist, &saa7134_devlist);
1029 mutex_unlock(&saa7134_devlist_lock);
1031 /* check for signal */
1032 saa7134_irq_video_signalchange(dev);
1034 if (TUNER_ABSENT != dev->tuner_type)
1035 saa_call_all(dev, tuner, s_standby);
1037 /* register v4l devices */
1038 if (saa7134_no_overlay > 0)
1039 printk(KERN_INFO "%s: Overlay support disabled.\n", dev->name);
1041 dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
1042 err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
1043 video_nr[dev->nr]);
1044 if (err < 0) {
1045 printk(KERN_INFO "%s: can't register video device\n",
1046 dev->name);
1047 goto fail4;
1049 printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
1050 dev->name, dev->video_dev->num);
1052 dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi");
1054 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
1055 vbi_nr[dev->nr]);
1056 if (err < 0)
1057 goto fail4;
1058 printk(KERN_INFO "%s: registered device vbi%d\n",
1059 dev->name, dev->vbi_dev->num);
1061 if (card_has_radio(dev)) {
1062 dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio");
1063 err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
1064 radio_nr[dev->nr]);
1065 if (err < 0)
1066 goto fail4;
1067 printk(KERN_INFO "%s: registered device radio%d\n",
1068 dev->name, dev->radio_dev->num);
1071 /* everything worked */
1072 saa7134_devcount++;
1074 if (saa7134_dmasound_init && !dev->dmasound.priv_data)
1075 saa7134_dmasound_init(dev);
1077 return 0;
1079 fail4:
1080 saa7134_unregister_video(dev);
1081 saa7134_i2c_unregister(dev);
1082 free_irq(pci_dev->irq, dev);
1083 fail3:
1084 saa7134_hwfini(dev);
1085 iounmap(dev->lmmio);
1086 fail2:
1087 release_mem_region(pci_resource_start(pci_dev,0),
1088 pci_resource_len(pci_dev,0));
1089 fail1:
1090 v4l2_device_unregister(&dev->v4l2_dev);
1091 fail0:
1092 kfree(dev);
1093 return err;
1096 static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1098 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
1099 struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
1100 struct saa7134_mpeg_ops *mops;
1102 /* Release DMA sound modules if present */
1103 if (saa7134_dmasound_exit && dev->dmasound.priv_data) {
1104 saa7134_dmasound_exit(dev);
1107 /* debugging ... */
1108 if (irq_debug) {
1109 u32 report = saa_readl(SAA7134_IRQ_REPORT);
1110 u32 status = saa_readl(SAA7134_IRQ_STATUS);
1111 print_irqstatus(dev,42,report,status);
1114 /* disable peripheral devices */
1115 saa_writeb(SAA7134_SPECIAL_MODE,0);
1117 /* shutdown hardware */
1118 saa_writel(SAA7134_IRQ1,0);
1119 saa_writel(SAA7134_IRQ2,0);
1120 saa_writel(SAA7134_MAIN_CTRL,0);
1122 /* shutdown subsystems */
1123 saa7134_hwfini(dev);
1125 /* unregister */
1126 mutex_lock(&saa7134_devlist_lock);
1127 list_del(&dev->devlist);
1128 list_for_each_entry(mops, &mops_list, next)
1129 mpeg_ops_detach(mops, dev);
1130 mutex_unlock(&saa7134_devlist_lock);
1131 saa7134_devcount--;
1133 saa7134_i2c_unregister(dev);
1134 saa7134_unregister_video(dev);
1137 /* the DMA sound modules should be unloaded before reaching
1138 this, but just in case they are still present... */
1139 if (dev->dmasound.priv_data != NULL) {
1140 free_irq(pci_dev->irq, &dev->dmasound);
1141 dev->dmasound.priv_data = NULL;
1145 /* release resources */
1146 free_irq(pci_dev->irq, dev);
1147 iounmap(dev->lmmio);
1148 release_mem_region(pci_resource_start(pci_dev,0),
1149 pci_resource_len(pci_dev,0));
1152 v4l2_device_unregister(&dev->v4l2_dev);
1154 /* free memory */
1155 kfree(dev);
1158 #ifdef CONFIG_PM
1160 /* resends a current buffer in queue after resume */
1161 static int saa7134_buffer_requeue(struct saa7134_dev *dev,
1162 struct saa7134_dmaqueue *q)
1164 struct saa7134_buf *buf, *next;
1166 assert_spin_locked(&dev->slock);
1168 buf = q->curr;
1169 next = buf;
1170 dprintk("buffer_requeue\n");
1172 if (!buf)
1173 return 0;
1175 dprintk("buffer_requeue : resending active buffers \n");
1177 if (!list_empty(&q->queue))
1178 next = list_entry(q->queue.next, struct saa7134_buf,
1179 vb.queue);
1180 buf->activate(dev, buf, next);
1182 return 0;
1185 static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
1187 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
1188 struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
1190 /* disable overlay - apps should enable it explicitly on resume*/
1191 dev->ovenable = 0;
1193 /* Disable interrupts, DMA, and rest of the chip*/
1194 saa_writel(SAA7134_IRQ1, 0);
1195 saa_writel(SAA7134_IRQ2, 0);
1196 saa_writel(SAA7134_MAIN_CTRL, 0);
1198 dev->insuspend = 1;
1199 synchronize_irq(pci_dev->irq);
1201 /* ACK interrupts once more, just in case,
1202 since the IRQ handler won't ack them anymore*/
1204 saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT));
1206 /* Disable timeout timers - if we have active buffers, we will
1207 fill them on resume*/
1209 del_timer(&dev->video_q.timeout);
1210 del_timer(&dev->vbi_q.timeout);
1211 del_timer(&dev->ts_q.timeout);
1213 if (dev->remote)
1214 saa7134_ir_stop(dev);
1216 pci_save_state(pci_dev);
1217 pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
1219 return 0;
1222 static int saa7134_resume(struct pci_dev *pci_dev)
1224 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
1225 struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
1226 unsigned long flags;
1228 pci_set_power_state(pci_dev, PCI_D0);
1229 pci_restore_state(pci_dev);
1231 /* Do things that are done in saa7134_initdev ,
1232 except of initializing memory structures.*/
1234 saa7134_board_init1(dev);
1236 /* saa7134_hwinit1 */
1237 if (saa7134_boards[dev->board].video_out)
1238 saa7134_videoport_init(dev);
1239 if (card_has_mpeg(dev))
1240 saa7134_ts_init_hw(dev);
1241 if (dev->remote)
1242 saa7134_ir_start(dev, dev->remote);
1243 saa7134_hw_enable1(dev);
1245 msleep(100);
1247 saa7134_board_init2(dev);
1249 /*saa7134_hwinit2*/
1250 saa7134_set_tvnorm_hw(dev);
1251 saa7134_tvaudio_setmute(dev);
1252 saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
1253 saa7134_tvaudio_init(dev);
1254 saa7134_tvaudio_do_scan(dev);
1255 saa7134_enable_i2s(dev);
1256 saa7134_hw_enable2(dev);
1258 saa7134_irq_video_signalchange(dev);
1260 /*resume unfinished buffer(s)*/
1261 spin_lock_irqsave(&dev->slock, flags);
1262 saa7134_buffer_requeue(dev, &dev->video_q);
1263 saa7134_buffer_requeue(dev, &dev->vbi_q);
1264 saa7134_buffer_requeue(dev, &dev->ts_q);
1266 /* FIXME: Disable DMA audio sound - temporary till proper support
1267 is implemented*/
1269 dev->dmasound.dma_running = 0;
1271 /* start DMA now*/
1272 dev->insuspend = 0;
1273 smp_wmb();
1274 saa7134_set_dmabits(dev);
1275 spin_unlock_irqrestore(&dev->slock, flags);
1277 return 0;
1279 #endif
1281 /* ----------------------------------------------------------- */
1283 int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
1285 struct saa7134_dev *dev;
1287 mutex_lock(&saa7134_devlist_lock);
1288 list_for_each_entry(dev, &saa7134_devlist, devlist)
1289 mpeg_ops_attach(ops, dev);
1290 list_add_tail(&ops->next,&mops_list);
1291 mutex_unlock(&saa7134_devlist_lock);
1292 return 0;
1295 void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
1297 struct saa7134_dev *dev;
1299 mutex_lock(&saa7134_devlist_lock);
1300 list_del(&ops->next);
1301 list_for_each_entry(dev, &saa7134_devlist, devlist)
1302 mpeg_ops_detach(ops, dev);
1303 mutex_unlock(&saa7134_devlist_lock);
1306 EXPORT_SYMBOL(saa7134_ts_register);
1307 EXPORT_SYMBOL(saa7134_ts_unregister);
1309 /* ----------------------------------------------------------- */
1311 static struct pci_driver saa7134_pci_driver = {
1312 .name = "saa7134",
1313 .id_table = saa7134_pci_tbl,
1314 .probe = saa7134_initdev,
1315 .remove = __devexit_p(saa7134_finidev),
1316 #ifdef CONFIG_PM
1317 .suspend = saa7134_suspend,
1318 .resume = saa7134_resume
1319 #endif
1322 static int saa7134_init(void)
1324 INIT_LIST_HEAD(&saa7134_devlist);
1325 printk(KERN_INFO "saa7130/34: v4l2 driver version %d.%d.%d loaded\n",
1326 (SAA7134_VERSION_CODE >> 16) & 0xff,
1327 (SAA7134_VERSION_CODE >> 8) & 0xff,
1328 SAA7134_VERSION_CODE & 0xff);
1329 #ifdef SNAPSHOT
1330 printk(KERN_INFO "saa7130/34: snapshot date %04d-%02d-%02d\n",
1331 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1332 #endif
1333 return pci_register_driver(&saa7134_pci_driver);
1336 static void saa7134_fini(void)
1338 pci_unregister_driver(&saa7134_pci_driver);
1341 module_init(saa7134_init);
1342 module_exit(saa7134_fini);
1344 /* ----------------------------------------------------------- */
1346 EXPORT_SYMBOL(saa7134_set_gpio);
1347 EXPORT_SYMBOL(saa7134_boards);
1349 /* ----------------- for the DMA sound modules --------------- */
1351 EXPORT_SYMBOL(saa7134_dmasound_init);
1352 EXPORT_SYMBOL(saa7134_dmasound_exit);
1353 EXPORT_SYMBOL(saa7134_pgtable_free);
1354 EXPORT_SYMBOL(saa7134_pgtable_build);
1355 EXPORT_SYMBOL(saa7134_pgtable_alloc);
1356 EXPORT_SYMBOL(saa7134_set_dmabits);
1358 /* ----------------------------------------------------------- */
1360 * Local variables:
1361 * c-basic-offset: 8
1362 * End: