2 * Driver for the NXP SAA7164 PCIe bridge
4 * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/init.h>
23 #include <linux/list.h>
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/kmod.h>
27 #include <linux/kernel.h>
28 #include <linux/slab.h>
29 #include <linux/interrupt.h>
30 #include <linux/delay.h>
31 #include <asm/div64.h>
35 MODULE_DESCRIPTION("Driver for NXP SAA7164 based TV cards");
36 MODULE_AUTHOR("Steven Toth <stoth@kernellabs.com>");
37 MODULE_LICENSE("GPL");
48 unsigned int saa_debug
;
49 module_param_named(debug
, saa_debug
, int, 0644);
50 MODULE_PARM_DESC(debug
, "enable debug messages");
52 unsigned int encoder_buffers
= SAA7164_MAX_ENCODER_BUFFERS
;
53 module_param(encoder_buffers
, int, 0644);
54 MODULE_PARM_DESC(encoder_buffers
, "Total buffers in read queue 16-512 def:64");
56 unsigned int waitsecs
= 10;
57 module_param(waitsecs
, int, 0644);
58 MODULE_PARM_DESC(waitsecs
, "timeout on firmware messages");
60 static unsigned int card
[] = {[0 ... (SAA7164_MAXBOARDS
- 1)] = UNSET
};
61 module_param_array(card
, int, NULL
, 0444);
62 MODULE_PARM_DESC(card
, "card type");
64 unsigned int print_histogram
= 64;
65 module_param(print_histogram
, int, 0644);
66 MODULE_PARM_DESC(print_histogram
, "print histogram values once");
68 static unsigned int saa7164_devcount
;
70 static DEFINE_MUTEX(devlist
);
71 LIST_HEAD(saa7164_devlist
);
75 void saa7164_dumphex16FF(struct saa7164_dev
*dev
, u8
*buf
, int len
)
79 memset(&tmp
[0], 0xff, sizeof(tmp
));
81 printk(KERN_INFO
"--------------------> "
82 "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
84 for (i
= 0; i
< len
; i
+= 16) {
85 if (memcmp(&tmp
, buf
+ i
, sizeof(tmp
)) != 0) {
86 printk(KERN_INFO
" [0x%08x] "
87 "%02x %02x %02x %02x %02x %02x %02x %02x "
88 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i
,
89 *(buf
+i
+0), *(buf
+i
+1), *(buf
+i
+2), *(buf
+i
+3),
90 *(buf
+i
+4), *(buf
+i
+5), *(buf
+i
+6), *(buf
+i
+7),
91 *(buf
+i
+8), *(buf
+i
+9), *(buf
+i
+10), *(buf
+i
+11),
92 *(buf
+i
+12), *(buf
+i
+13), *(buf
+i
+14), *(buf
+i
+15));
97 static void saa7164_pack_verifier(struct saa7164_buffer
*buf
)
99 u8
*p
= (u8
*)buf
->cpu
;
102 for (i
= 0; i
< buf
->actual_size
; i
+= 2048) {
104 if ( (*(p
+ i
+ 0) != 0x00) || (*(p
+ i
+ 1) != 0x00) || (*(p
+ i
+ 2) != 0x01) || (*(p
+ i
+ 3) != 0xBA) )
105 printk(KERN_ERR
"No pack at 0x%x\n", i
);
109 static void saa7164_ts_verifier(struct saa7164_buffer
*buf
)
111 struct saa7164_port
*port
= buf
->port
;
114 u8
*bufcpu
= (u8
*)buf
->cpu
;
116 port
->sync_errors
= 0;
117 port
->v_cc_errors
= 0;
118 port
->a_cc_errors
= 0;
120 for (i
= 0; i
< buf
->actual_size
; i
+= 188) {
121 if (*(bufcpu
+ i
) != 0x47)
124 /* Query pid lower 8 bits */
125 tmp
= *(bufcpu
+ i
+ 2);
126 cc
= *(bufcpu
+ i
+ 3) & 0x0f;
129 a
= ((port
->last_v_cc
+ 1) & 0x0f);
131 printk(KERN_ERR
"video cc last = %x current = %x i = %d\n", port
->last_v_cc
, cc
, i
);
135 port
->last_v_cc
= cc
;
138 a
= ((port
->last_a_cc
+ 1) & 0x0f);
140 printk(KERN_ERR
"audio cc last = %x current = %x i = %d\n", port
->last_a_cc
, cc
, i
);
144 port
->last_a_cc
= cc
;
149 if (port
->v_cc_errors
)
150 printk(KERN_ERR
"video pid cc, %d errors\n", port
->v_cc_errors
);
152 if (port
->a_cc_errors
)
153 printk(KERN_ERR
"audio pid cc, %d errors\n", port
->a_cc_errors
);
155 if (port
->sync_errors
)
156 printk(KERN_ERR
"sync_errors = %d\n", port
->sync_errors
);
159 static void saa7164_histogram_reset(struct saa7164_histogram
*hg
, char *name
)
163 memset(hg
, 0, sizeof(struct saa7164_histogram
));
164 strcpy(hg
->name
, name
);
166 /* First 30ms x 1ms */
167 for (i
= 0; i
< 30; i
++) {
168 hg
->counter1
[0 + i
].val
= i
;
171 /* 30 - 200ms x 10ms */
172 for (i
= 0; i
< 18; i
++) {
173 hg
->counter1
[30 + i
].val
= 30 + (i
* 10);
176 /* 200 - 2000ms x 100ms */
177 for (i
= 0; i
< 15; i
++) {
178 hg
->counter1
[48 + i
].val
= 200 + (i
* 200);
181 /* Catch all massive value (2secs) */
182 hg
->counter1
[55].val
= 2000;
184 /* Catch all massive value (4secs) */
185 hg
->counter1
[56].val
= 4000;
187 /* Catch all massive value (8secs) */
188 hg
->counter1
[57].val
= 8000;
190 /* Catch all massive value (15secs) */
191 hg
->counter1
[58].val
= 15000;
193 /* Catch all massive value (30secs) */
194 hg
->counter1
[59].val
= 30000;
196 /* Catch all massive value (60secs) */
197 hg
->counter1
[60].val
= 60000;
199 /* Catch all massive value (5mins) */
200 hg
->counter1
[61].val
= 300000;
202 /* Catch all massive value (15mins) */
203 hg
->counter1
[62].val
= 900000;
205 /* Catch all massive values (1hr) */
206 hg
->counter1
[63].val
= 3600000;
209 void saa7164_histogram_update(struct saa7164_histogram
*hg
, u32 val
)
212 for (i
= 0; i
< 64; i
++ ) {
213 if (val
<= hg
->counter1
[i
].val
) {
214 hg
->counter1
[i
].count
++;
215 hg
->counter1
[i
].update_time
= jiffies
;
221 static void saa7164_histogram_print(struct saa7164_port
*port
,
222 struct saa7164_histogram
*hg
)
227 printk(KERN_ERR
"Histogram named %s (ms, count, last_update_jiffy)\n", hg
->name
);
228 for (i
= 0; i
< 64; i
++ ) {
229 if (hg
->counter1
[i
].count
== 0)
232 printk(KERN_ERR
" %4d %12d %Ld\n",
234 hg
->counter1
[i
].count
,
235 hg
->counter1
[i
].update_time
);
239 printk(KERN_ERR
"Total: %d\n", entries
);
242 static void saa7164_work_enchandler(struct work_struct
*w
)
244 struct saa7164_port
*port
=
245 container_of(w
, struct saa7164_port
, workenc
);
246 struct saa7164_dev
*dev
= port
->dev
;
247 struct saa7164_buffer
*buf
;
248 struct saa7164_user_buffer
*ubuf
;
249 struct list_head
*c
, *n
;
254 port
->last_svc_msecs_diff
= port
->last_svc_msecs
;
255 port
->last_svc_msecs
= jiffies_to_msecs(jiffies
);
256 port
->last_svc_wp
= saa7164_readl(port
->bufcounter
);
257 port
->last_svc_rp
= port
->last_irq_rp
;
258 wp
= port
->last_svc_wp
;
259 rp
= port
->last_svc_rp
;
262 port
->last_svc_msecs_diff
= port
->last_svc_msecs
-
263 port
->last_svc_msecs_diff
;
265 saa7164_histogram_update(&port
->svc_interval
,
266 port
->last_svc_msecs_diff
);
268 port
->last_irq_svc_msecs_diff
= port
->last_svc_msecs
-
269 port
->last_irq_msecs
;
271 saa7164_histogram_update(&port
->irq_svc_interval
,
272 port
->last_irq_svc_msecs_diff
);
275 "%s() %Ldms elapsed irq->deferred %Ldms wp: %d rp: %d\n",
277 port
->last_svc_msecs_diff
,
278 port
->last_irq_svc_msecs_diff
,
283 if ((rp
< 0) || (rp
> 7)) {
284 printk(KERN_ERR
"%s() illegal rp count %d\n", __func__
, rp
);
288 mutex_lock(&port
->dmaqueue_lock
);
290 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
292 buf
= list_entry(c
, struct saa7164_buffer
, list
);
293 if (i
++ > port
->hwcfg
.buffercount
) {
294 printk(KERN_ERR
"%s() illegal i count %d\n",
300 if ( (*(p
+ buf
->actual_size
+ 0) != 0xff) ||
301 (*(p
+ buf
->actual_size
+ 1) != 0xff) ||
302 (*(p
+ buf
->actual_size
+ 2) != 0xff) ||
303 (*(p
+ buf
->actual_size
+ 3) != 0xff) ||
304 (*(p
+ buf
->actual_size
+ 0x10) != 0xff) ||
305 (*(p
+ buf
->actual_size
+ 0x11) != 0xff) ||
306 (*(p
+ buf
->actual_size
+ 0x12) != 0xff) ||
307 (*(p
+ buf
->actual_size
+ 0x13) != 0xff) )
309 printk(KERN_ERR
"%s() buf %p failed guard check\n", __func__
, buf
);
310 saa7164_dumphex16(dev
, p
+ buf
->actual_size
- 32, 64);
313 if (buf
->idx
== wp
) {
314 /* Ignore this, it's being updated currently by the dma engine */
316 if (buf
->idx
== rp
) {
318 crc
= crc32(0, buf
->cpu
, buf
->actual_size
);
319 if (crc
!= port
->shadow_crc
[rp
])
320 printk(KERN_ERR
"%s crc didn't match shadow was 0x%x now 0x%x\n",
321 __func__
, port
->shadow_crc
[rp
], crc
);
323 /* Found the buffer, deal with it */
324 dprintk(DBGLVL_IRQ
, "%s() wp: %d processing: %d crc32: 0x%x\n",
325 __func__
, wp
, rp
, buf
->crc
);
327 /* Validate the incoming buffer content */
328 if (port
->encoder_params
.stream_type
== V4L2_MPEG_STREAM_TYPE_MPEG2_TS
)
329 saa7164_ts_verifier(buf
);
330 if (port
->encoder_params
.stream_type
== V4L2_MPEG_STREAM_TYPE_MPEG2_PS
)
331 saa7164_pack_verifier(buf
);
333 /* find a free user buffer and clone to it */
334 if (!list_empty(&port
->list_buf_free
.list
)) {
336 /* Pull the first buffer from the used list */
337 ubuf
= list_first_entry(&port
->list_buf_free
.list
,
338 struct saa7164_user_buffer
, list
);
340 if (buf
->actual_size
<= ubuf
->actual_size
) {
342 memcpy_fromio(ubuf
->data
, buf
->cpu
, ubuf
->actual_size
);
344 /* Throw a new checksum on the read buffer */
345 ubuf
->crc
= crc32(0, ubuf
->data
, ubuf
->actual_size
);
347 if ((crc
== port
->shadow_crc
[rp
]) && (crc
== ubuf
->crc
))
354 "rp: %d dmacrc: 0x%08x shadcrc: 0x%08x ubufcrc: 0x%08x %s\n",
355 rp
, buf
->crc
, port
->shadow_crc
[rp
], ubuf
->crc
,
356 ok
? "crcgood" : "crcbad");
358 /* Requeue the buffer on the free list */
361 list_move_tail(&ubuf
->list
,
362 &port
->list_buf_used
.list
);
364 /* Flag any userland waiters */
365 wake_up_interruptible(&port
->wait_read
);
368 printk(KERN_ERR
"buf %p bufsize fails match\n", buf
);
372 printk(KERN_ERR
"encirq no free buffers, increase param encoder_buffers\n");
374 /* Ensure offset into buffer remains 0, fill buffer
375 * with known bad data. We check for this data at a later point
377 saa7164_buffer_zero_offsets(port
, rp
);
378 memset_io(buf
->cpu
, 0xff, buf
->pci_size
);
379 buf
->crc
= crc32(0, buf
->cpu
, buf
->actual_size
);
383 /* Validate all other checksums, on previous buffers - they should never change */
384 crc
= crc32(0, buf
->cpu
, buf
->actual_size
);
385 if (crc
!= buf
->crc
) {
386 printk(KERN_ERR
"buf[%d].crc became invalid, was 0x%x became 0x%x rp: %d wp: %d\n",
387 buf
->idx
, buf
->crc
, crc
, rp
, wp
);
388 //saa7164_dumphex16FF(dev, (u8 *)buf->cpu, buf->actual_size);
389 saa7164_dumphex16FF(dev
, (u8
*)buf
->cpu
, 256);
396 mutex_unlock(&port
->dmaqueue_lock
);
398 if (print_histogram
== port
->nr
) {
399 saa7164_histogram_print(port
, &port
->irq_interval
);
400 saa7164_histogram_print(port
, &port
->svc_interval
);
401 saa7164_histogram_print(port
, &port
->irq_svc_interval
);
402 saa7164_histogram_print(port
, &port
->read_interval
);
403 saa7164_histogram_print(port
, &port
->poll_interval
);
404 print_histogram
= 64 + port
->nr
;
407 static void saa7164_work_cmdhandler(struct work_struct
*w
)
409 struct saa7164_dev
*dev
= container_of(w
, struct saa7164_dev
, workcmd
);
411 /* Wake up any complete commands */
412 saa7164_irq_dequeue(dev
);
415 static void saa7164_buffer_deliver(struct saa7164_buffer
*buf
)
417 struct saa7164_port
*port
= buf
->port
;
419 /* Feed the transport payload into the kernel demux */
420 dvb_dmx_swfilter_packets(&port
->dvb
.demux
, (u8
*)buf
->cpu
,
421 SAA7164_TS_NUMBER_OF_LINES
);
425 static irqreturn_t
saa7164_irq_encoder(struct saa7164_port
*port
)
427 struct saa7164_dev
*dev
= port
->dev
;
428 struct saa7164_buffer
*buf
;
429 struct list_head
*c
, *n
;
433 /* Find the current write point from the hardware */
434 wp
= saa7164_readl(port
->bufcounter
);
435 if (wp
> (port
->hwcfg
.buffercount
- 1)) {
436 printk(KERN_ERR
"%s() illegal buf count %d\n", __func__
, wp
);
440 /* Find the previous buffer to the current write point */
446 if ((rp
< 0) || (rp
> 7)) {
447 printk(KERN_ERR
"%s() illegal rp count %d\n", __func__
, rp
);
451 if (rp
!= ((port
->last_irq_rp
+ 1) % 8)) {
452 printk(KERN_ERR
"%s() Multiple bufs on interrupt, port %p\n",
457 port
->last_irq_msecs_diff
= port
->last_irq_msecs
;
459 /* Collect new stats */
460 port
->last_irq_msecs
= jiffies_to_msecs(jiffies
);
461 port
->last_irq_wp
= wp
;
462 port
->last_irq_rp
= rp
;
464 /* Calculate stats */
465 port
->last_irq_msecs_diff
= port
->last_irq_msecs
-
466 port
->last_irq_msecs_diff
;
468 saa7164_histogram_update(&port
->irq_interval
,
469 port
->last_irq_msecs_diff
);
471 dprintk(DBGLVL_IRQ
, "%s() %Ldms elapsed wp: %d rp: %d\n",
473 port
->last_irq_msecs_diff
,
477 /* Find the used buffer, shadow copy it before we've
478 * acked the interrupt.
480 // mutex_lock(&port->dmaqueue_lock);
481 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
483 buf
= list_entry(c
, struct saa7164_buffer
, list
);
484 if (i
++ > port
->hwcfg
.buffercount
) {
485 printk(KERN_ERR
"%s() illegal i count %d\n",
491 if ( (*(p
+ buf
->actual_size
+ 0) != 0xff) ||
492 (*(p
+ buf
->actual_size
+ 1) != 0xff) ||
493 (*(p
+ buf
->actual_size
+ 2) != 0xff) ||
494 (*(p
+ buf
->actual_size
+ 3) != 0xff) ||
495 (*(p
+ buf
->actual_size
+ 0x10) != 0xff) ||
496 (*(p
+ buf
->actual_size
+ 0x11) != 0xff) ||
497 (*(p
+ buf
->actual_size
+ 0x12) != 0xff) ||
498 (*(p
+ buf
->actual_size
+ 0x13) != 0xff) )
500 printk(KERN_ERR
"buf %p failed guard check\n", buf
);
501 saa7164_dumphex16(dev
, p
+ buf
->actual_size
- 32, 64);
504 if (buf
->idx
== rp
) {
506 memcpy_fromio(port
->shadow_buf
[rp
], buf
->cpu
, buf
->actual_size
);
508 port
->shadow_crc
[rp
] = crc32(0, port
->shadow_buf
[rp
], buf
->actual_size
);
510 buf
->crc
= crc32(0, buf
->cpu
, buf
->actual_size
);
512 if (port
->shadow_crc
[rp
] != buf
->crc
)
513 printk(KERN_ERR
"%s() crc check failed 0x%x vs 0x%x\n",
514 __func__
, port
->shadow_crc
[rp
], buf
->crc
);
519 // mutex_unlock(&port->dmaqueue_lock);
520 schedule_work(&port
->workenc
);
525 static irqreturn_t
saa7164_irq_ts(struct saa7164_port
*port
)
527 struct saa7164_dev
*dev
= port
->dev
;
528 struct saa7164_buffer
*buf
;
529 struct list_head
*c
, *n
;
532 /* Find the current write point from the hardware */
533 wp
= saa7164_readl(port
->bufcounter
);
534 if (wp
> (port
->hwcfg
.buffercount
- 1))
537 /* Find the previous buffer to the current write point */
543 /* Lookup the WP in the buffer list */
544 /* TODO: turn this into a worker thread */
545 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
546 buf
= list_entry(c
, struct saa7164_buffer
, list
);
547 if (i
++ > port
->hwcfg
.buffercount
)
550 if (buf
->idx
== rp
) {
551 /* Found the buffer, deal with it */
552 dprintk(DBGLVL_IRQ
, "%s() wp: %d processing: %d\n",
554 saa7164_buffer_deliver(buf
);
562 /* Primary IRQ handler and dispatch mechanism */
563 static irqreturn_t
saa7164_irq(int irq
, void *dev_id
)
565 struct saa7164_dev
*dev
= dev_id
;
566 struct saa7164_port
*porta
= &dev
->ports
[ SAA7164_PORT_TS1
];
567 struct saa7164_port
*portb
= &dev
->ports
[ SAA7164_PORT_TS2
];
568 struct saa7164_port
*portc
= &dev
->ports
[ SAA7164_PORT_ENC1
];
569 struct saa7164_port
*portd
= &dev
->ports
[ SAA7164_PORT_ENC2
];
571 u32 intid
, intstat
[INT_SIZE
/4];
572 int i
, handled
= 0, bit
;
575 printk(KERN_ERR
"%s() No device specified\n", __func__
);
580 /* Check that the hardware is accessable. If the status bytes are
581 * 0xFF then the device is not accessable, the the IRQ belongs
583 * 4 x u32 interrupt registers.
585 for (i
= 0; i
< INT_SIZE
/4; i
++) {
587 /* TODO: Convert into saa7164_readl() */
588 /* Read the 4 hardware interrupt registers */
589 intstat
[i
] = saa7164_readl(dev
->int_status
+ (i
* 4));
597 /* For each of the HW interrupt registers */
598 for (i
= 0; i
< INT_SIZE
/4; i
++) {
601 /* Each function of the board has it's own interruptid.
602 * Find the function that triggered then call
605 for (bit
= 0; bit
< 32; bit
++) {
607 if (((intstat
[i
] >> bit
) & 0x00000001) == 0)
610 /* Calculate the interrupt id (0x00 to 0x7f) */
612 intid
= (i
* 32) + bit
;
613 if (intid
== dev
->intfdesc
.bInterruptId
) {
614 /* A response to an cmd/api call */
615 schedule_work(&dev
->workcmd
);
616 } else if (intid
== porta
->hwcfg
.interruptid
) {
618 /* Transport path 1 */
619 saa7164_irq_ts(porta
);
621 } else if (intid
== portb
->hwcfg
.interruptid
) {
623 /* Transport path 2 */
624 saa7164_irq_ts(portb
);
626 } else if (intid
== portc
->hwcfg
.interruptid
) {
629 saa7164_irq_encoder(portc
);
631 } else if (intid
== portd
->hwcfg
.interruptid
) {
634 saa7164_irq_encoder(portd
);
637 /* Find the function */
639 "%s() unhandled interrupt "
642 __func__
, i
, bit
, intid
);
647 saa7164_writel(dev
->int_ack
+ (i
* 4), intstat
[i
]);
652 return IRQ_RETVAL(handled
);
655 void saa7164_getfirmwarestatus(struct saa7164_dev
*dev
)
657 struct saa7164_fw_status
*s
= &dev
->fw_status
;
659 dev
->fw_status
.status
= saa7164_readl(SAA_DEVICE_SYSINIT_STATUS
);
660 dev
->fw_status
.mode
= saa7164_readl(SAA_DEVICE_SYSINIT_MODE
);
661 dev
->fw_status
.spec
= saa7164_readl(SAA_DEVICE_SYSINIT_SPEC
);
662 dev
->fw_status
.inst
= saa7164_readl(SAA_DEVICE_SYSINIT_INST
);
663 dev
->fw_status
.cpuload
= saa7164_readl(SAA_DEVICE_SYSINIT_CPULOAD
);
664 dev
->fw_status
.remainheap
=
665 saa7164_readl(SAA_DEVICE_SYSINIT_REMAINHEAP
);
667 dprintk(1, "Firmware status:\n");
668 dprintk(1, " .status = 0x%08x\n", s
->status
);
669 dprintk(1, " .mode = 0x%08x\n", s
->mode
);
670 dprintk(1, " .spec = 0x%08x\n", s
->spec
);
671 dprintk(1, " .inst = 0x%08x\n", s
->inst
);
672 dprintk(1, " .cpuload = 0x%08x\n", s
->cpuload
);
673 dprintk(1, " .remainheap = 0x%08x\n", s
->remainheap
);
676 u32
saa7164_getcurrentfirmwareversion(struct saa7164_dev
*dev
)
680 reg
= saa7164_readl(SAA_DEVICE_VERSION
);
681 dprintk(1, "Device running firmware version %d.%d.%d.%d (0x%x)\n",
682 (reg
& 0x0000fc00) >> 10,
683 (reg
& 0x000003e0) >> 5,
685 (reg
& 0xffff0000) >> 16,
691 /* TODO: Debugging func, remove */
692 void saa7164_dumphex16(struct saa7164_dev
*dev
, u8
*buf
, int len
)
696 printk(KERN_INFO
"--------------------> "
697 "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
699 for (i
= 0; i
< len
; i
+= 16)
700 printk(KERN_INFO
" [0x%08x] "
701 "%02x %02x %02x %02x %02x %02x %02x %02x "
702 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i
,
703 *(buf
+i
+0), *(buf
+i
+1), *(buf
+i
+2), *(buf
+i
+3),
704 *(buf
+i
+4), *(buf
+i
+5), *(buf
+i
+6), *(buf
+i
+7),
705 *(buf
+i
+8), *(buf
+i
+9), *(buf
+i
+10), *(buf
+i
+11),
706 *(buf
+i
+12), *(buf
+i
+13), *(buf
+i
+14), *(buf
+i
+15));
709 /* TODO: Debugging func, remove */
710 void saa7164_dumpregs(struct saa7164_dev
*dev
, u32 addr
)
714 dprintk(1, "--------------------> "
715 "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
717 for (i
= 0; i
< 0x100; i
+= 16)
718 dprintk(1, "region0[0x%08x] = "
719 "%02x %02x %02x %02x %02x %02x %02x %02x"
720 " %02x %02x %02x %02x %02x %02x %02x %02x\n", i
,
721 (u8
)saa7164_readb(addr
+ i
+ 0),
722 (u8
)saa7164_readb(addr
+ i
+ 1),
723 (u8
)saa7164_readb(addr
+ i
+ 2),
724 (u8
)saa7164_readb(addr
+ i
+ 3),
725 (u8
)saa7164_readb(addr
+ i
+ 4),
726 (u8
)saa7164_readb(addr
+ i
+ 5),
727 (u8
)saa7164_readb(addr
+ i
+ 6),
728 (u8
)saa7164_readb(addr
+ i
+ 7),
729 (u8
)saa7164_readb(addr
+ i
+ 8),
730 (u8
)saa7164_readb(addr
+ i
+ 9),
731 (u8
)saa7164_readb(addr
+ i
+ 10),
732 (u8
)saa7164_readb(addr
+ i
+ 11),
733 (u8
)saa7164_readb(addr
+ i
+ 12),
734 (u8
)saa7164_readb(addr
+ i
+ 13),
735 (u8
)saa7164_readb(addr
+ i
+ 14),
736 (u8
)saa7164_readb(addr
+ i
+ 15)
740 static void saa7164_dump_hwdesc(struct saa7164_dev
*dev
)
742 dprintk(1, "@0x%p hwdesc sizeof(tmComResHWDescr_t) = %d bytes\n",
743 &dev
->hwdesc
, (u32
)sizeof(tmComResHWDescr_t
));
745 dprintk(1, " .bLength = 0x%x\n", dev
->hwdesc
.bLength
);
746 dprintk(1, " .bDescriptorType = 0x%x\n", dev
->hwdesc
.bDescriptorType
);
747 dprintk(1, " .bDescriptorSubtype = 0x%x\n",
748 dev
->hwdesc
.bDescriptorSubtype
);
750 dprintk(1, " .bcdSpecVersion = 0x%x\n", dev
->hwdesc
.bcdSpecVersion
);
751 dprintk(1, " .dwClockFrequency = 0x%x\n", dev
->hwdesc
.dwClockFrequency
);
752 dprintk(1, " .dwClockUpdateRes = 0x%x\n", dev
->hwdesc
.dwClockUpdateRes
);
753 dprintk(1, " .bCapabilities = 0x%x\n", dev
->hwdesc
.bCapabilities
);
754 dprintk(1, " .dwDeviceRegistersLocation = 0x%x\n",
755 dev
->hwdesc
.dwDeviceRegistersLocation
);
757 dprintk(1, " .dwHostMemoryRegion = 0x%x\n",
758 dev
->hwdesc
.dwHostMemoryRegion
);
760 dprintk(1, " .dwHostMemoryRegionSize = 0x%x\n",
761 dev
->hwdesc
.dwHostMemoryRegionSize
);
763 dprintk(1, " .dwHostHibernatMemRegion = 0x%x\n",
764 dev
->hwdesc
.dwHostHibernatMemRegion
);
766 dprintk(1, " .dwHostHibernatMemRegionSize = 0x%x\n",
767 dev
->hwdesc
.dwHostHibernatMemRegionSize
);
770 static void saa7164_dump_intfdesc(struct saa7164_dev
*dev
)
772 dprintk(1, "@0x%p intfdesc "
773 "sizeof(tmComResInterfaceDescr_t) = %d bytes\n",
774 &dev
->intfdesc
, (u32
)sizeof(tmComResInterfaceDescr_t
));
776 dprintk(1, " .bLength = 0x%x\n", dev
->intfdesc
.bLength
);
777 dprintk(1, " .bDescriptorType = 0x%x\n", dev
->intfdesc
.bDescriptorType
);
778 dprintk(1, " .bDescriptorSubtype = 0x%x\n",
779 dev
->intfdesc
.bDescriptorSubtype
);
781 dprintk(1, " .bFlags = 0x%x\n", dev
->intfdesc
.bFlags
);
782 dprintk(1, " .bInterfaceType = 0x%x\n", dev
->intfdesc
.bInterfaceType
);
783 dprintk(1, " .bInterfaceId = 0x%x\n", dev
->intfdesc
.bInterfaceId
);
784 dprintk(1, " .bBaseInterface = 0x%x\n", dev
->intfdesc
.bBaseInterface
);
785 dprintk(1, " .bInterruptId = 0x%x\n", dev
->intfdesc
.bInterruptId
);
786 dprintk(1, " .bDebugInterruptId = 0x%x\n",
787 dev
->intfdesc
.bDebugInterruptId
);
789 dprintk(1, " .BARLocation = 0x%x\n", dev
->intfdesc
.BARLocation
);
792 static void saa7164_dump_busdesc(struct saa7164_dev
*dev
)
794 dprintk(1, "@0x%p busdesc sizeof(tmComResBusDescr_t) = %d bytes\n",
795 &dev
->busdesc
, (u32
)sizeof(tmComResBusDescr_t
));
797 dprintk(1, " .CommandRing = 0x%016Lx\n", dev
->busdesc
.CommandRing
);
798 dprintk(1, " .ResponseRing = 0x%016Lx\n", dev
->busdesc
.ResponseRing
);
799 dprintk(1, " .CommandWrite = 0x%x\n", dev
->busdesc
.CommandWrite
);
800 dprintk(1, " .CommandRead = 0x%x\n", dev
->busdesc
.CommandRead
);
801 dprintk(1, " .ResponseWrite = 0x%x\n", dev
->busdesc
.ResponseWrite
);
802 dprintk(1, " .ResponseRead = 0x%x\n", dev
->busdesc
.ResponseRead
);
805 /* Much of the hardware configuration and PCI registers are configured
806 * dynamically depending on firmware. We have to cache some initial
807 * structures then use these to locate other important structures
810 static void saa7164_get_descriptors(struct saa7164_dev
*dev
)
812 memcpy_fromio(&dev
->hwdesc
, dev
->bmmio
, sizeof(tmComResHWDescr_t
));
813 memcpy_fromio(&dev
->intfdesc
, dev
->bmmio
+ sizeof(tmComResHWDescr_t
),
814 sizeof(tmComResInterfaceDescr_t
));
815 memcpy_fromio(&dev
->busdesc
, dev
->bmmio
+ dev
->intfdesc
.BARLocation
,
816 sizeof(tmComResBusDescr_t
));
818 if (dev
->hwdesc
.bLength
!= sizeof(tmComResHWDescr_t
)) {
819 printk(KERN_ERR
"Structure tmComResHWDescr_t is mangled\n");
820 printk(KERN_ERR
"Need %x got %d\n", dev
->hwdesc
.bLength
,
821 (u32
)sizeof(tmComResHWDescr_t
));
823 saa7164_dump_hwdesc(dev
);
825 if (dev
->intfdesc
.bLength
!= sizeof(tmComResInterfaceDescr_t
)) {
826 printk(KERN_ERR
"struct tmComResInterfaceDescr_t is mangled\n");
827 printk(KERN_ERR
"Need %x got %d\n", dev
->intfdesc
.bLength
,
828 (u32
)sizeof(tmComResInterfaceDescr_t
));
830 saa7164_dump_intfdesc(dev
);
832 saa7164_dump_busdesc(dev
);
835 static int saa7164_pci_quirks(struct saa7164_dev
*dev
)
840 static int get_resources(struct saa7164_dev
*dev
)
842 if (request_mem_region(pci_resource_start(dev
->pci
, 0),
843 pci_resource_len(dev
->pci
, 0), dev
->name
)) {
845 if (request_mem_region(pci_resource_start(dev
->pci
, 2),
846 pci_resource_len(dev
->pci
, 2), dev
->name
))
850 printk(KERN_ERR
"%s: can't get MMIO memory @ 0x%llx or 0x%llx\n",
852 (u64
)pci_resource_start(dev
->pci
, 0),
853 (u64
)pci_resource_start(dev
->pci
, 2));
858 static int saa7164_port_init(struct saa7164_dev
*dev
, int portnr
)
860 struct saa7164_port
*port
= 0;
863 if ((portnr
< 0) || (portnr
>= SAA7164_MAX_PORTS
))
866 port
= &dev
->ports
[ portnr
];
871 if ((portnr
== SAA7164_PORT_TS1
) || (portnr
== SAA7164_PORT_TS2
))
872 port
->type
= SAA7164_MPEG_DVB
;
874 if ((portnr
== SAA7164_PORT_ENC1
) || (portnr
== SAA7164_PORT_ENC2
))
875 port
->type
= SAA7164_MPEG_ENCODER
;
879 /* Init all the critical resources */
880 mutex_init(&port
->dvb
.lock
);
881 INIT_LIST_HEAD(&port
->dmaqueue
.list
);
882 mutex_init(&port
->dmaqueue_lock
);
884 INIT_LIST_HEAD(&port
->list_buf_used
.list
);
885 INIT_LIST_HEAD(&port
->list_buf_free
.list
);
886 init_waitqueue_head(&port
->wait_read
);
888 /* We need a deferred interrupt handler for cmd handling */
889 INIT_WORK(&port
->workenc
, saa7164_work_enchandler
);
891 saa7164_histogram_reset(&port
->irq_interval
, "irq intervals");
892 saa7164_histogram_reset(&port
->svc_interval
, "deferred intervals");
893 saa7164_histogram_reset(&port
->irq_svc_interval
,
894 "irq to deferred intervals");
895 saa7164_histogram_reset(&port
->read_interval
,
896 "encoder read() intervals");
897 saa7164_histogram_reset(&port
->poll_interval
,
898 "encoder poll() intervals");
900 if (port
->type
== SAA7164_MPEG_ENCODER
) {
901 for (i
= 0; i
< 8; i
++) {
902 port
->shadow_buf
[i
] = kzalloc(256 * 128, GFP_KERNEL
);
903 if (port
->shadow_buf
[i
] == 0)
904 printk(KERN_ERR
"%s() shadow_buf ENOMEM\n", __func__
);
906 memset(port
->shadow_buf
[i
], 0xff, 256 * 128);
907 port
->shadow_crc
[i
] = crc32(0, port
->shadow_buf
[i
], 256 * 128);
915 static int saa7164_dev_setup(struct saa7164_dev
*dev
)
919 mutex_init(&dev
->lock
);
920 atomic_inc(&dev
->refcount
);
921 dev
->nr
= saa7164_devcount
++;
923 sprintf(dev
->name
, "saa7164[%d]", dev
->nr
);
925 mutex_lock(&devlist
);
926 list_add_tail(&dev
->devlist
, &saa7164_devlist
);
927 mutex_unlock(&devlist
);
931 if (card
[dev
->nr
] < saa7164_bcount
)
932 dev
->board
= card
[dev
->nr
];
934 for (i
= 0; UNSET
== dev
->board
&& i
< saa7164_idcount
; i
++)
935 if (dev
->pci
->subsystem_vendor
== saa7164_subids
[i
].subvendor
&&
936 dev
->pci
->subsystem_device
==
937 saa7164_subids
[i
].subdevice
)
938 dev
->board
= saa7164_subids
[i
].card
;
940 if (UNSET
== dev
->board
) {
941 dev
->board
= SAA7164_BOARD_UNKNOWN
;
942 saa7164_card_list(dev
);
945 dev
->pci_bus
= dev
->pci
->bus
->number
;
946 dev
->pci_slot
= PCI_SLOT(dev
->pci
->devfn
);
948 /* I2C Defaults / setup */
949 dev
->i2c_bus
[0].dev
= dev
;
950 dev
->i2c_bus
[0].nr
= 0;
951 dev
->i2c_bus
[1].dev
= dev
;
952 dev
->i2c_bus
[1].nr
= 1;
953 dev
->i2c_bus
[2].dev
= dev
;
954 dev
->i2c_bus
[2].nr
= 2;
956 /* Transport + Encoder ports 1, 2, 3, 4 - Defaults / setup */
957 saa7164_port_init(dev
, SAA7164_PORT_TS1
);
958 saa7164_port_init(dev
, SAA7164_PORT_TS2
);
959 saa7164_port_init(dev
, SAA7164_PORT_ENC1
);
960 saa7164_port_init(dev
, SAA7164_PORT_ENC2
);
962 if (get_resources(dev
) < 0) {
963 printk(KERN_ERR
"CORE %s No more PCIe resources for "
964 "subsystem: %04x:%04x\n",
965 dev
->name
, dev
->pci
->subsystem_vendor
,
966 dev
->pci
->subsystem_device
);
972 /* PCI/e allocations */
973 dev
->lmmio
= ioremap(pci_resource_start(dev
->pci
, 0),
974 pci_resource_len(dev
->pci
, 0));
976 dev
->lmmio2
= ioremap(pci_resource_start(dev
->pci
, 2),
977 pci_resource_len(dev
->pci
, 2));
979 dev
->bmmio
= (u8 __iomem
*)dev
->lmmio
;
980 dev
->bmmio2
= (u8 __iomem
*)dev
->lmmio2
;
982 /* Inerrupt and ack register locations offset of bmmio */
983 dev
->int_status
= 0x183000 + 0xf80;
984 dev
->int_ack
= 0x183000 + 0xf90;
987 "CORE %s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
988 dev
->name
, dev
->pci
->subsystem_vendor
,
989 dev
->pci
->subsystem_device
, saa7164_boards
[dev
->board
].name
,
990 dev
->board
, card
[dev
->nr
] == dev
->board
?
991 "insmod option" : "autodetected");
993 saa7164_pci_quirks(dev
);
998 static void saa7164_dev_unregister(struct saa7164_dev
*dev
)
1000 dprintk(1, "%s()\n", __func__
);
1002 release_mem_region(pci_resource_start(dev
->pci
, 0),
1003 pci_resource_len(dev
->pci
, 0));
1005 release_mem_region(pci_resource_start(dev
->pci
, 2),
1006 pci_resource_len(dev
->pci
, 2));
1008 if (!atomic_dec_and_test(&dev
->refcount
))
1011 iounmap(dev
->lmmio
);
1012 iounmap(dev
->lmmio2
);
1017 static int __devinit
saa7164_initdev(struct pci_dev
*pci_dev
,
1018 const struct pci_device_id
*pci_id
)
1020 struct saa7164_dev
*dev
;
1024 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
1030 if (pci_enable_device(pci_dev
)) {
1035 if (saa7164_dev_setup(dev
) < 0) {
1040 /* print pci info */
1041 pci_read_config_byte(pci_dev
, PCI_CLASS_REVISION
, &dev
->pci_rev
);
1042 pci_read_config_byte(pci_dev
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
1043 printk(KERN_INFO
"%s/0: found at %s, rev: %d, irq: %d, "
1044 "latency: %d, mmio: 0x%llx\n", dev
->name
,
1045 pci_name(pci_dev
), dev
->pci_rev
, pci_dev
->irq
,
1047 (unsigned long long)pci_resource_start(pci_dev
, 0));
1049 pci_set_master(pci_dev
);
1051 if (!pci_dma_supported(pci_dev
, 0xffffffff)) {
1052 printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev
->name
);
1057 err
= request_irq(pci_dev
->irq
, saa7164_irq
,
1058 IRQF_SHARED
| IRQF_DISABLED
, dev
->name
, dev
);
1060 printk(KERN_ERR
"%s: can't get IRQ %d\n", dev
->name
,
1066 pci_set_drvdata(pci_dev
, dev
);
1068 /* Init the internal command list */
1069 for (i
= 0; i
< SAA_CMD_MAX_MSG_UNITS
; i
++) {
1070 dev
->cmds
[i
].seqno
= i
;
1071 dev
->cmds
[i
].inuse
= 0;
1072 mutex_init(&dev
->cmds
[i
].lock
);
1073 init_waitqueue_head(&dev
->cmds
[i
].wait
);
1076 /* We need a deferred interrupt handler for cmd handling */
1077 INIT_WORK(&dev
->workcmd
, saa7164_work_cmdhandler
);
1079 /* Only load the firmware if we know the board */
1080 if (dev
->board
!= SAA7164_BOARD_UNKNOWN
) {
1082 err
= saa7164_downloadfirmware(dev
);
1085 "Failed to boot firmware, no features "
1090 saa7164_get_descriptors(dev
);
1091 saa7164_dumpregs(dev
, 0);
1092 saa7164_getcurrentfirmwareversion(dev
);
1093 saa7164_getfirmwarestatus(dev
);
1094 err
= saa7164_bus_setup(dev
);
1097 "Failed to setup the bus, will continue\n");
1098 saa7164_bus_dump(dev
);
1100 /* Ping the running firmware via the command bus and get the
1101 * firmware version, this checks the bus is running OK.
1104 if (saa7164_api_get_fw_version(dev
, &version
) == SAA_OK
)
1105 dprintk(1, "Bus is operating correctly using "
1106 "version %d.%d.%d.%d (0x%x)\n",
1107 (version
& 0x0000fc00) >> 10,
1108 (version
& 0x000003e0) >> 5,
1109 (version
& 0x0000001f),
1110 (version
& 0xffff0000) >> 16,
1114 "Failed to communicate with the firmware\n");
1116 /* Bring up the I2C buses */
1117 saa7164_i2c_register(&dev
->i2c_bus
[0]);
1118 saa7164_i2c_register(&dev
->i2c_bus
[1]);
1119 saa7164_i2c_register(&dev
->i2c_bus
[2]);
1120 saa7164_gpio_setup(dev
);
1121 saa7164_card_setup(dev
);
1124 /* Parse the dynamic device configuration, find various
1125 * media endpoints (MPEG, WMV, PS, TS) and cache their
1126 * configuration details into the driver, so we can
1127 * reference them later during simething_register() func,
1128 * interrupt handlers, deferred work handlers etc.
1130 saa7164_api_enum_subdevs(dev
);
1132 /* Begin to create the video sub-systems and register funcs */
1133 if (saa7164_boards
[dev
->board
].porta
== SAA7164_MPEG_DVB
) {
1134 if (saa7164_dvb_register(&dev
->ports
[ SAA7164_PORT_TS1
]) < 0) {
1135 printk(KERN_ERR
"%s() Failed to register "
1136 "dvb adapters on porta\n",
1141 if (saa7164_boards
[dev
->board
].portb
== SAA7164_MPEG_DVB
) {
1142 if (saa7164_dvb_register(&dev
->ports
[ SAA7164_PORT_TS2
]) < 0) {
1143 printk(KERN_ERR
"%s() Failed to register "
1144 "dvb adapters on portb\n",
1149 if (saa7164_boards
[dev
->board
].portc
== SAA7164_MPEG_ENCODER
) {
1150 if (saa7164_encoder_register(&dev
->ports
[ SAA7164_PORT_ENC1
]) < 0) {
1151 printk(KERN_ERR
"%s() Failed to register "
1152 "mpeg encoder\n", __func__
);
1156 if (saa7164_boards
[dev
->board
].portd
== SAA7164_MPEG_ENCODER
) {
1157 if (saa7164_encoder_register(&dev
->ports
[ SAA7164_PORT_ENC2
]) < 0) {
1158 printk(KERN_ERR
"%s() Failed to register "
1159 "mpeg encoder\n", __func__
);
1163 } /* != BOARD_UNKNOWN */
1165 printk(KERN_ERR
"%s() Unsupported board detected, "
1166 "registering without firmware\n", __func__
);
1168 dprintk(1, "%s() parameter debug = %d\n", __func__
, saa_debug
);
1169 dprintk(1, "%s() parameter waitsecs = %d\n", __func__
, waitsecs
);
1175 saa7164_dev_unregister(dev
);
1181 static void saa7164_shutdown(struct saa7164_dev
*dev
)
1183 dprintk(1, "%s()\n", __func__
);
1186 static void __devexit
saa7164_finidev(struct pci_dev
*pci_dev
)
1188 struct saa7164_dev
*dev
= pci_get_drvdata(pci_dev
);
1189 struct saa7164_port
*port
;
1192 saa7164_histogram_print(&dev
->ports
[ SAA7164_PORT_ENC1
],
1193 &dev
->ports
[ SAA7164_PORT_ENC1
].irq_interval
);
1194 saa7164_histogram_print(&dev
->ports
[ SAA7164_PORT_ENC1
],
1195 &dev
->ports
[ SAA7164_PORT_ENC1
].svc_interval
);
1196 saa7164_histogram_print(&dev
->ports
[ SAA7164_PORT_ENC1
],
1197 &dev
->ports
[ SAA7164_PORT_ENC1
].irq_svc_interval
);
1198 saa7164_histogram_print(&dev
->ports
[ SAA7164_PORT_ENC1
],
1199 &dev
->ports
[ SAA7164_PORT_ENC1
].read_interval
);
1200 saa7164_histogram_print(&dev
->ports
[ SAA7164_PORT_ENC1
],
1201 &dev
->ports
[ SAA7164_PORT_ENC1
].poll_interval
);
1203 saa7164_shutdown(dev
);
1205 port
= &dev
->ports
[ SAA7164_PORT_ENC1
];
1206 if (port
->type
== SAA7164_MPEG_ENCODER
) {
1207 for (i
= 0; i
< 8; i
++) {
1208 kfree(port
->shadow_buf
[i
]);
1209 port
->shadow_buf
[i
] = 0;
1212 port
= &dev
->ports
[ SAA7164_PORT_ENC2
];
1213 if (port
->type
== SAA7164_MPEG_ENCODER
) {
1214 for (i
= 0; i
< 8; i
++) {
1215 kfree(port
->shadow_buf
[i
]);
1216 port
->shadow_buf
[i
] = 0;
1221 if (saa7164_boards
[dev
->board
].porta
== SAA7164_MPEG_DVB
)
1222 saa7164_dvb_unregister(&dev
->ports
[ SAA7164_PORT_TS1
]);
1224 if (saa7164_boards
[dev
->board
].portb
== SAA7164_MPEG_DVB
)
1225 saa7164_dvb_unregister(&dev
->ports
[ SAA7164_PORT_TS2
]);
1227 if (saa7164_boards
[dev
->board
].portc
== SAA7164_MPEG_ENCODER
)
1228 saa7164_encoder_unregister(&dev
->ports
[ SAA7164_PORT_ENC1
]);
1230 if (saa7164_boards
[dev
->board
].portd
== SAA7164_MPEG_ENCODER
)
1231 saa7164_encoder_unregister(&dev
->ports
[ SAA7164_PORT_ENC2
]);
1233 saa7164_i2c_unregister(&dev
->i2c_bus
[0]);
1234 saa7164_i2c_unregister(&dev
->i2c_bus
[1]);
1235 saa7164_i2c_unregister(&dev
->i2c_bus
[2]);
1237 pci_disable_device(pci_dev
);
1239 /* unregister stuff */
1240 free_irq(pci_dev
->irq
, dev
);
1241 pci_set_drvdata(pci_dev
, NULL
);
1243 mutex_lock(&devlist
);
1244 list_del(&dev
->devlist
);
1245 mutex_unlock(&devlist
);
1247 saa7164_dev_unregister(dev
);
1251 static struct pci_device_id saa7164_pci_tbl
[] = {
1256 .subvendor
= PCI_ANY_ID
,
1257 .subdevice
= PCI_ANY_ID
,
1259 /* --- end of list --- */
1262 MODULE_DEVICE_TABLE(pci
, saa7164_pci_tbl
);
1264 static struct pci_driver saa7164_pci_driver
= {
1266 .id_table
= saa7164_pci_tbl
,
1267 .probe
= saa7164_initdev
,
1268 .remove
= __devexit_p(saa7164_finidev
),
1274 static int __init
saa7164_init(void)
1276 printk(KERN_INFO
"saa7164 driver loaded\n");
1277 return pci_register_driver(&saa7164_pci_driver
);
1280 static void __exit
saa7164_fini(void)
1282 pci_unregister_driver(&saa7164_pci_driver
);
1285 module_init(saa7164_init
);
1286 module_exit(saa7164_fini
);