Lines Matching +full:wp +full:- +full:content
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
45 MODULE_PARM_DESC(encoder_buffers, "Total buffers in read queue 16-512 def:64");
49 MODULE_PARM_DESC(vbi_buffers, "Total buffers in read queue 16-512 def:64");
55 static unsigned int card[] = {[0 ... (SAA7164_MAXBOARDS - 1)] = UNSET };
86 u8 *p = (u8 *)buf->cpu; in saa7164_pack_verifier()
89 for (i = 0; i < buf->actual_size; i += 2048) { in saa7164_pack_verifier()
107 struct saa7164_port *port = buf->port; in saa7164_ts_verifier()
111 u8 *bufcpu = (u8 *)buf->cpu; in saa7164_ts_verifier()
113 port->sync_errors = 0; in saa7164_ts_verifier()
114 port->v_cc_errors = 0; in saa7164_ts_verifier()
115 port->a_cc_errors = 0; in saa7164_ts_verifier()
117 for (i = 0; i < buf->actual_size; i += 188) { in saa7164_ts_verifier()
119 port->sync_errors++; in saa7164_ts_verifier()
126 a = ((port->last_v_cc + 1) & 0x0f); in saa7164_ts_verifier()
129 port->last_v_cc, cc, i); in saa7164_ts_verifier()
130 port->v_cc_errors++; in saa7164_ts_verifier()
133 port->last_v_cc = cc; in saa7164_ts_verifier()
136 a = ((port->last_a_cc + 1) & 0x0f); in saa7164_ts_verifier()
139 port->last_a_cc, cc, i); in saa7164_ts_verifier()
140 port->a_cc_errors++; in saa7164_ts_verifier()
143 port->last_a_cc = cc; in saa7164_ts_verifier()
152 if (port->v_cc_errors && (port->done_first_interrupt > 1)) in saa7164_ts_verifier()
153 printk(KERN_ERR "video pid cc, %d errors\n", port->v_cc_errors); in saa7164_ts_verifier()
155 if (port->a_cc_errors && (port->done_first_interrupt > 1)) in saa7164_ts_verifier()
156 printk(KERN_ERR "audio pid cc, %d errors\n", port->a_cc_errors); in saa7164_ts_verifier()
158 if (port->sync_errors && (port->done_first_interrupt > 1)) in saa7164_ts_verifier()
159 printk(KERN_ERR "sync_errors = %d\n", port->sync_errors); in saa7164_ts_verifier()
161 if (port->done_first_interrupt == 1) in saa7164_ts_verifier()
162 port->done_first_interrupt++; in saa7164_ts_verifier()
170 strscpy(hg->name, name, sizeof(hg->name)); in saa7164_histogram_reset()
174 hg->counter1[0 + i].val = i; in saa7164_histogram_reset()
176 /* 30 - 200ms x 10ms */ in saa7164_histogram_reset()
178 hg->counter1[30 + i].val = 30 + (i * 10); in saa7164_histogram_reset()
180 /* 200 - 2000ms x 100ms */ in saa7164_histogram_reset()
182 hg->counter1[48 + i].val = 200 + (i * 200); in saa7164_histogram_reset()
185 hg->counter1[55].val = 2000; in saa7164_histogram_reset()
188 hg->counter1[56].val = 4000; in saa7164_histogram_reset()
191 hg->counter1[57].val = 8000; in saa7164_histogram_reset()
194 hg->counter1[58].val = 15000; in saa7164_histogram_reset()
197 hg->counter1[59].val = 30000; in saa7164_histogram_reset()
200 hg->counter1[60].val = 60000; in saa7164_histogram_reset()
203 hg->counter1[61].val = 300000; in saa7164_histogram_reset()
206 hg->counter1[62].val = 900000; in saa7164_histogram_reset()
209 hg->counter1[63].val = 3600000; in saa7164_histogram_reset()
216 if (val <= hg->counter1[i].val) { in saa7164_histogram_update()
217 hg->counter1[i].count++; in saa7164_histogram_update()
218 hg->counter1[i].update_time = jiffies; in saa7164_histogram_update()
230 printk(KERN_ERR "Histogram named %s (ms, count, last_update_jiffy)\n", hg->name); in saa7164_histogram_print()
232 if (hg->counter1[i].count == 0) in saa7164_histogram_print()
236 hg->counter1[i].val, in saa7164_histogram_print()
237 hg->counter1[i].count, in saa7164_histogram_print()
238 hg->counter1[i].update_time); in saa7164_histogram_print()
247 struct saa7164_dev *dev = port->dev; in saa7164_work_enchandler_helper()
254 mutex_lock(&port->dmaqueue_lock); in saa7164_work_enchandler_helper()
255 list_for_each_safe(c, n, &port->dmaqueue.list) { in saa7164_work_enchandler_helper()
258 if (i++ > port->hwcfg.buffercount) { in saa7164_work_enchandler_helper()
264 if (buf->idx == bufnr) { in saa7164_work_enchandler_helper()
271 buf->crc = crc32(0, buf->cpu, buf->actual_size); in saa7164_work_enchandler_helper()
275 p = (u8 *)buf->cpu; in saa7164_work_enchandler_helper()
276 if ((*(p + buf->actual_size + 0) != 0xff) || in saa7164_work_enchandler_helper()
277 (*(p + buf->actual_size + 1) != 0xff) || in saa7164_work_enchandler_helper()
278 (*(p + buf->actual_size + 2) != 0xff) || in saa7164_work_enchandler_helper()
279 (*(p + buf->actual_size + 3) != 0xff) || in saa7164_work_enchandler_helper()
280 (*(p + buf->actual_size + 0x10) != 0xff) || in saa7164_work_enchandler_helper()
281 (*(p + buf->actual_size + 0x11) != 0xff) || in saa7164_work_enchandler_helper()
282 (*(p + buf->actual_size + 0x12) != 0xff) || in saa7164_work_enchandler_helper()
283 (*(p + buf->actual_size + 0x13) != 0xff)) { in saa7164_work_enchandler_helper()
288 p + buf->actual_size - 32, 64, false); in saa7164_work_enchandler_helper()
293 if ((port->nr != SAA7164_PORT_VBI1) && (port->nr != SAA7164_PORT_VBI2)) { in saa7164_work_enchandler_helper()
294 /* Validate the incoming buffer content */ in saa7164_work_enchandler_helper()
295 if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_TS) in saa7164_work_enchandler_helper()
297 else if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_PS) in saa7164_work_enchandler_helper()
302 if (!list_empty(&port->list_buf_free.list)) { in saa7164_work_enchandler_helper()
305 ubuf = list_first_entry(&port->list_buf_free.list, in saa7164_work_enchandler_helper()
308 if (buf->actual_size <= ubuf->actual_size) { in saa7164_work_enchandler_helper()
310 memcpy(ubuf->data, buf->cpu, ubuf->actual_size); in saa7164_work_enchandler_helper()
314 ubuf->crc = crc32(0, ubuf->data, ubuf->actual_size); in saa7164_work_enchandler_helper()
318 ubuf->pos = 0; in saa7164_work_enchandler_helper()
320 list_move_tail(&ubuf->list, in saa7164_work_enchandler_helper()
321 &port->list_buf_used.list); in saa7164_work_enchandler_helper()
324 wake_up_interruptible(&port->wait_read); in saa7164_work_enchandler_helper()
337 memset(buf->cpu, 0xff, buf->pci_size); in saa7164_work_enchandler_helper()
340 buf->crc = crc32(0, buf->cpu, buf->actual_size); in saa7164_work_enchandler_helper()
346 mutex_unlock(&port->dmaqueue_lock); in saa7164_work_enchandler_helper()
353 struct saa7164_dev *dev = port->dev; in saa7164_work_enchandler()
355 u32 wp, mcb, rp; in saa7164_work_enchandler() local
357 port->last_svc_msecs_diff = port->last_svc_msecs; in saa7164_work_enchandler()
358 port->last_svc_msecs = jiffies_to_msecs(jiffies); in saa7164_work_enchandler()
360 port->last_svc_msecs_diff = port->last_svc_msecs - in saa7164_work_enchandler()
361 port->last_svc_msecs_diff; in saa7164_work_enchandler()
363 saa7164_histogram_update(&port->svc_interval, in saa7164_work_enchandler()
364 port->last_svc_msecs_diff); in saa7164_work_enchandler()
366 port->last_irq_svc_msecs_diff = port->last_svc_msecs - in saa7164_work_enchandler()
367 port->last_irq_msecs; in saa7164_work_enchandler()
369 saa7164_histogram_update(&port->irq_svc_interval, in saa7164_work_enchandler()
370 port->last_irq_svc_msecs_diff); in saa7164_work_enchandler()
373 "%s() %Ldms elapsed irq->deferred %Ldms wp: %d rp: %d\n", in saa7164_work_enchandler()
375 port->last_svc_msecs_diff, in saa7164_work_enchandler()
376 port->last_irq_svc_msecs_diff, in saa7164_work_enchandler()
377 port->last_svc_wp, in saa7164_work_enchandler()
378 port->last_svc_rp in saa7164_work_enchandler()
382 wp = saa7164_readl(port->bufcounter); in saa7164_work_enchandler()
383 if (wp > (port->hwcfg.buffercount - 1)) { in saa7164_work_enchandler()
384 printk(KERN_ERR "%s() illegal buf count %d\n", __func__, wp); in saa7164_work_enchandler()
389 if (wp == 0) in saa7164_work_enchandler()
390 mcb = (port->hwcfg.buffercount - 1); in saa7164_work_enchandler()
392 mcb = wp - 1; in saa7164_work_enchandler()
395 if (port->done_first_interrupt == 0) { in saa7164_work_enchandler()
396 port->done_first_interrupt++; in saa7164_work_enchandler()
399 rp = (port->last_svc_rp + 1) % 8; in saa7164_work_enchandler()
401 if (rp > (port->hwcfg.buffercount - 1)) { in saa7164_work_enchandler()
407 port->last_svc_rp = rp; in saa7164_work_enchandler()
414 if (print_histogram == port->nr) { in saa7164_work_enchandler()
415 saa7164_histogram_print(port, &port->irq_interval); in saa7164_work_enchandler()
416 saa7164_histogram_print(port, &port->svc_interval); in saa7164_work_enchandler()
417 saa7164_histogram_print(port, &port->irq_svc_interval); in saa7164_work_enchandler()
418 saa7164_histogram_print(port, &port->read_interval); in saa7164_work_enchandler()
419 saa7164_histogram_print(port, &port->poll_interval); in saa7164_work_enchandler()
421 print_histogram = 64 + port->nr; in saa7164_work_enchandler()
429 struct saa7164_dev *dev = port->dev; in saa7164_work_vbihandler()
431 u32 wp, mcb, rp; in saa7164_work_vbihandler() local
433 port->last_svc_msecs_diff = port->last_svc_msecs; in saa7164_work_vbihandler()
434 port->last_svc_msecs = jiffies_to_msecs(jiffies); in saa7164_work_vbihandler()
435 port->last_svc_msecs_diff = port->last_svc_msecs - in saa7164_work_vbihandler()
436 port->last_svc_msecs_diff; in saa7164_work_vbihandler()
438 saa7164_histogram_update(&port->svc_interval, in saa7164_work_vbihandler()
439 port->last_svc_msecs_diff); in saa7164_work_vbihandler()
441 port->last_irq_svc_msecs_diff = port->last_svc_msecs - in saa7164_work_vbihandler()
442 port->last_irq_msecs; in saa7164_work_vbihandler()
444 saa7164_histogram_update(&port->irq_svc_interval, in saa7164_work_vbihandler()
445 port->last_irq_svc_msecs_diff); in saa7164_work_vbihandler()
448 "%s() %Ldms elapsed irq->deferred %Ldms wp: %d rp: %d\n", in saa7164_work_vbihandler()
450 port->last_svc_msecs_diff, in saa7164_work_vbihandler()
451 port->last_irq_svc_msecs_diff, in saa7164_work_vbihandler()
452 port->last_svc_wp, in saa7164_work_vbihandler()
453 port->last_svc_rp in saa7164_work_vbihandler()
457 wp = saa7164_readl(port->bufcounter); in saa7164_work_vbihandler()
458 if (wp > (port->hwcfg.buffercount - 1)) { in saa7164_work_vbihandler()
459 printk(KERN_ERR "%s() illegal buf count %d\n", __func__, wp); in saa7164_work_vbihandler()
464 if (wp == 0) in saa7164_work_vbihandler()
465 mcb = (port->hwcfg.buffercount - 1); in saa7164_work_vbihandler()
467 mcb = wp - 1; in saa7164_work_vbihandler()
470 if (port->done_first_interrupt == 0) { in saa7164_work_vbihandler()
471 port->done_first_interrupt++; in saa7164_work_vbihandler()
474 rp = (port->last_svc_rp + 1) % 8; in saa7164_work_vbihandler()
476 if (rp > (port->hwcfg.buffercount - 1)) { in saa7164_work_vbihandler()
482 port->last_svc_rp = rp; in saa7164_work_vbihandler()
489 if (print_histogram == port->nr) { in saa7164_work_vbihandler()
490 saa7164_histogram_print(port, &port->irq_interval); in saa7164_work_vbihandler()
491 saa7164_histogram_print(port, &port->svc_interval); in saa7164_work_vbihandler()
492 saa7164_histogram_print(port, &port->irq_svc_interval); in saa7164_work_vbihandler()
493 saa7164_histogram_print(port, &port->read_interval); in saa7164_work_vbihandler()
494 saa7164_histogram_print(port, &port->poll_interval); in saa7164_work_vbihandler()
496 print_histogram = 64 + port->nr; in saa7164_work_vbihandler()
510 struct saa7164_port *port = buf->port; in saa7164_buffer_deliver()
513 dvb_dmx_swfilter_packets(&port->dvb.demux, (u8 *)buf->cpu, in saa7164_buffer_deliver()
520 struct saa7164_dev *dev = port->dev; in saa7164_irq_vbi()
523 port->last_irq_msecs_diff = port->last_irq_msecs; in saa7164_irq_vbi()
526 port->last_irq_msecs = jiffies_to_msecs(jiffies); in saa7164_irq_vbi()
529 port->last_irq_msecs_diff = port->last_irq_msecs - in saa7164_irq_vbi()
530 port->last_irq_msecs_diff; in saa7164_irq_vbi()
532 saa7164_histogram_update(&port->irq_interval, in saa7164_irq_vbi()
533 port->last_irq_msecs_diff); in saa7164_irq_vbi()
536 port->last_irq_msecs_diff); in saa7164_irq_vbi()
539 schedule_work(&port->workenc); in saa7164_irq_vbi()
545 struct saa7164_dev *dev = port->dev; in saa7164_irq_encoder()
548 port->last_irq_msecs_diff = port->last_irq_msecs; in saa7164_irq_encoder()
551 port->last_irq_msecs = jiffies_to_msecs(jiffies); in saa7164_irq_encoder()
554 port->last_irq_msecs_diff = port->last_irq_msecs - in saa7164_irq_encoder()
555 port->last_irq_msecs_diff; in saa7164_irq_encoder()
557 saa7164_histogram_update(&port->irq_interval, in saa7164_irq_encoder()
558 port->last_irq_msecs_diff); in saa7164_irq_encoder()
561 port->last_irq_msecs_diff); in saa7164_irq_encoder()
563 schedule_work(&port->workenc); in saa7164_irq_encoder()
569 struct saa7164_dev *dev = port->dev; in saa7164_irq_ts()
572 int wp, i = 0, rp; in saa7164_irq_ts() local
575 wp = saa7164_readl(port->bufcounter); in saa7164_irq_ts()
577 BUG_ON(wp > (port->hwcfg.buffercount - 1)); in saa7164_irq_ts()
580 if (wp == 0) in saa7164_irq_ts()
581 rp = (port->hwcfg.buffercount - 1); in saa7164_irq_ts()
583 rp = wp - 1; in saa7164_irq_ts()
585 /* Lookup the WP in the buffer list */ in saa7164_irq_ts()
587 list_for_each_safe(c, n, &port->dmaqueue.list) { in saa7164_irq_ts()
589 BUG_ON(i > port->hwcfg.buffercount); in saa7164_irq_ts()
592 if (buf->idx == rp) { in saa7164_irq_ts()
594 dprintk(DBGLVL_IRQ, "%s() wp: %d processing: %d\n", in saa7164_irq_ts()
595 __func__, wp, rp); in saa7164_irq_ts()
619 porta = &dev->ports[SAA7164_PORT_TS1]; in saa7164_irq()
620 portb = &dev->ports[SAA7164_PORT_TS2]; in saa7164_irq()
621 portc = &dev->ports[SAA7164_PORT_ENC1]; in saa7164_irq()
622 portd = &dev->ports[SAA7164_PORT_ENC2]; in saa7164_irq()
623 porte = &dev->ports[SAA7164_PORT_VBI1]; in saa7164_irq()
624 portf = &dev->ports[SAA7164_PORT_VBI2]; in saa7164_irq()
635 intstat[i] = saa7164_readl(dev->int_status + (i * 4)); in saa7164_irq()
659 if (intid == dev->intfdesc.bInterruptId) { in saa7164_irq()
661 schedule_work(&dev->workcmd); in saa7164_irq()
662 } else if (intid == porta->hwcfg.interruptid) { in saa7164_irq()
667 } else if (intid == portb->hwcfg.interruptid) { in saa7164_irq()
672 } else if (intid == portc->hwcfg.interruptid) { in saa7164_irq()
677 } else if (intid == portd->hwcfg.interruptid) { in saa7164_irq()
682 } else if (intid == porte->hwcfg.interruptid) { in saa7164_irq()
687 } else if (intid == portf->hwcfg.interruptid) { in saa7164_irq()
701 saa7164_writel(dev->int_ack + (i * 4), intstat[i]); in saa7164_irq()
711 struct saa7164_fw_status *s = &dev->fw_status; in saa7164_getfirmwarestatus()
713 dev->fw_status.status = saa7164_readl(SAA_DEVICE_SYSINIT_STATUS); in saa7164_getfirmwarestatus()
714 dev->fw_status.mode = saa7164_readl(SAA_DEVICE_SYSINIT_MODE); in saa7164_getfirmwarestatus()
715 dev->fw_status.spec = saa7164_readl(SAA_DEVICE_SYSINIT_SPEC); in saa7164_getfirmwarestatus()
716 dev->fw_status.inst = saa7164_readl(SAA_DEVICE_SYSINIT_INST); in saa7164_getfirmwarestatus()
717 dev->fw_status.cpuload = saa7164_readl(SAA_DEVICE_SYSINIT_CPULOAD); in saa7164_getfirmwarestatus()
718 dev->fw_status.remainheap = in saa7164_getfirmwarestatus()
722 dprintk(1, " .status = 0x%08x\n", s->status); in saa7164_getfirmwarestatus()
723 dprintk(1, " .mode = 0x%08x\n", s->mode); in saa7164_getfirmwarestatus()
724 dprintk(1, " .spec = 0x%08x\n", s->spec); in saa7164_getfirmwarestatus()
725 dprintk(1, " .inst = 0x%08x\n", s->inst); in saa7164_getfirmwarestatus()
726 dprintk(1, " .cpuload = 0x%08x\n", s->cpuload); in saa7164_getfirmwarestatus()
727 dprintk(1, " .remainheap = 0x%08x\n", s->remainheap); in saa7164_getfirmwarestatus()
750 dprintk(1, "--------------------> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); in saa7164_dumpregs()
777 &dev->hwdesc, (u32)sizeof(struct tmComResHWDescr)); in saa7164_dump_hwdesc()
779 dprintk(1, " .bLength = 0x%x\n", dev->hwdesc.bLength); in saa7164_dump_hwdesc()
780 dprintk(1, " .bDescriptorType = 0x%x\n", dev->hwdesc.bDescriptorType); in saa7164_dump_hwdesc()
782 dev->hwdesc.bDescriptorSubtype); in saa7164_dump_hwdesc()
784 dprintk(1, " .bcdSpecVersion = 0x%x\n", dev->hwdesc.bcdSpecVersion); in saa7164_dump_hwdesc()
785 dprintk(1, " .dwClockFrequency = 0x%x\n", dev->hwdesc.dwClockFrequency); in saa7164_dump_hwdesc()
786 dprintk(1, " .dwClockUpdateRes = 0x%x\n", dev->hwdesc.dwClockUpdateRes); in saa7164_dump_hwdesc()
787 dprintk(1, " .bCapabilities = 0x%x\n", dev->hwdesc.bCapabilities); in saa7164_dump_hwdesc()
789 dev->hwdesc.dwDeviceRegistersLocation); in saa7164_dump_hwdesc()
792 dev->hwdesc.dwHostMemoryRegion); in saa7164_dump_hwdesc()
795 dev->hwdesc.dwHostMemoryRegionSize); in saa7164_dump_hwdesc()
798 dev->hwdesc.dwHostHibernatMemRegion); in saa7164_dump_hwdesc()
801 dev->hwdesc.dwHostHibernatMemRegionSize); in saa7164_dump_hwdesc()
807 &dev->intfdesc, (u32)sizeof(struct tmComResInterfaceDescr)); in saa7164_dump_intfdesc()
809 dprintk(1, " .bLength = 0x%x\n", dev->intfdesc.bLength); in saa7164_dump_intfdesc()
810 dprintk(1, " .bDescriptorType = 0x%x\n", dev->intfdesc.bDescriptorType); in saa7164_dump_intfdesc()
812 dev->intfdesc.bDescriptorSubtype); in saa7164_dump_intfdesc()
814 dprintk(1, " .bFlags = 0x%x\n", dev->intfdesc.bFlags); in saa7164_dump_intfdesc()
815 dprintk(1, " .bInterfaceType = 0x%x\n", dev->intfdesc.bInterfaceType); in saa7164_dump_intfdesc()
816 dprintk(1, " .bInterfaceId = 0x%x\n", dev->intfdesc.bInterfaceId); in saa7164_dump_intfdesc()
817 dprintk(1, " .bBaseInterface = 0x%x\n", dev->intfdesc.bBaseInterface); in saa7164_dump_intfdesc()
818 dprintk(1, " .bInterruptId = 0x%x\n", dev->intfdesc.bInterruptId); in saa7164_dump_intfdesc()
820 dev->intfdesc.bDebugInterruptId); in saa7164_dump_intfdesc()
822 dprintk(1, " .BARLocation = 0x%x\n", dev->intfdesc.BARLocation); in saa7164_dump_intfdesc()
828 &dev->busdesc, (u32)sizeof(struct tmComResBusDescr)); in saa7164_dump_busdesc()
830 dprintk(1, " .CommandRing = 0x%016Lx\n", dev->busdesc.CommandRing); in saa7164_dump_busdesc()
831 dprintk(1, " .ResponseRing = 0x%016Lx\n", dev->busdesc.ResponseRing); in saa7164_dump_busdesc()
832 dprintk(1, " .CommandWrite = 0x%x\n", dev->busdesc.CommandWrite); in saa7164_dump_busdesc()
833 dprintk(1, " .CommandRead = 0x%x\n", dev->busdesc.CommandRead); in saa7164_dump_busdesc()
834 dprintk(1, " .ResponseWrite = 0x%x\n", dev->busdesc.ResponseWrite); in saa7164_dump_busdesc()
835 dprintk(1, " .ResponseRead = 0x%x\n", dev->busdesc.ResponseRead); in saa7164_dump_busdesc()
845 memcpy_fromio(&dev->hwdesc, dev->bmmio, sizeof(struct tmComResHWDescr)); in saa7164_get_descriptors()
846 memcpy_fromio(&dev->intfdesc, dev->bmmio + sizeof(struct tmComResHWDescr), in saa7164_get_descriptors()
848 memcpy_fromio(&dev->busdesc, dev->bmmio + dev->intfdesc.BARLocation, in saa7164_get_descriptors()
851 if (dev->hwdesc.bLength != sizeof(struct tmComResHWDescr)) { in saa7164_get_descriptors()
853 printk(KERN_ERR "Need %x got %d\n", dev->hwdesc.bLength, in saa7164_get_descriptors()
858 if (dev->intfdesc.bLength != sizeof(struct tmComResInterfaceDescr)) { in saa7164_get_descriptors()
860 printk(KERN_ERR "Need %x got %d\n", dev->intfdesc.bLength, in saa7164_get_descriptors()
875 if (request_mem_region(pci_resource_start(dev->pci, 0), in get_resources()
876 pci_resource_len(dev->pci, 0), dev->name)) { in get_resources()
878 if (request_mem_region(pci_resource_start(dev->pci, 2), in get_resources()
879 pci_resource_len(dev->pci, 2), dev->name)) in get_resources()
884 dev->name, in get_resources()
885 (u64)pci_resource_start(dev->pci, 0), in get_resources()
886 (u64)pci_resource_start(dev->pci, 2)); in get_resources()
888 return -EBUSY; in get_resources()
897 port = &dev->ports[portnr]; in saa7164_port_init()
899 port->dev = dev; in saa7164_port_init()
900 port->nr = portnr; in saa7164_port_init()
903 port->type = SAA7164_MPEG_DVB; in saa7164_port_init()
906 port->type = SAA7164_MPEG_ENCODER; in saa7164_port_init()
909 INIT_WORK(&port->workenc, saa7164_work_enchandler); in saa7164_port_init()
911 port->type = SAA7164_MPEG_VBI; in saa7164_port_init()
914 INIT_WORK(&port->workenc, saa7164_work_vbihandler); in saa7164_port_init()
919 mutex_init(&port->dvb.lock); in saa7164_port_init()
920 INIT_LIST_HEAD(&port->dmaqueue.list); in saa7164_port_init()
921 mutex_init(&port->dmaqueue_lock); in saa7164_port_init()
923 INIT_LIST_HEAD(&port->list_buf_used.list); in saa7164_port_init()
924 INIT_LIST_HEAD(&port->list_buf_free.list); in saa7164_port_init()
925 init_waitqueue_head(&port->wait_read); in saa7164_port_init()
928 saa7164_histogram_reset(&port->irq_interval, "irq intervals"); in saa7164_port_init()
929 saa7164_histogram_reset(&port->svc_interval, "deferred intervals"); in saa7164_port_init()
930 saa7164_histogram_reset(&port->irq_svc_interval, in saa7164_port_init()
932 saa7164_histogram_reset(&port->read_interval, in saa7164_port_init()
934 saa7164_histogram_reset(&port->poll_interval, in saa7164_port_init()
944 mutex_init(&dev->lock); in saa7164_dev_setup()
945 atomic_inc(&dev->refcount); in saa7164_dev_setup()
946 dev->nr = saa7164_devcount++; in saa7164_dev_setup()
948 snprintf(dev->name, sizeof(dev->name), "saa7164[%d]", dev->nr); in saa7164_dev_setup()
951 list_add_tail(&dev->devlist, &saa7164_devlist); in saa7164_dev_setup()
955 dev->board = UNSET; in saa7164_dev_setup()
956 if (card[dev->nr] < saa7164_bcount) in saa7164_dev_setup()
957 dev->board = card[dev->nr]; in saa7164_dev_setup()
959 for (i = 0; UNSET == dev->board && i < saa7164_idcount; i++) in saa7164_dev_setup()
960 if (dev->pci->subsystem_vendor == saa7164_subids[i].subvendor && in saa7164_dev_setup()
961 dev->pci->subsystem_device == in saa7164_dev_setup()
963 dev->board = saa7164_subids[i].card; in saa7164_dev_setup()
965 if (UNSET == dev->board) { in saa7164_dev_setup()
966 dev->board = SAA7164_BOARD_UNKNOWN; in saa7164_dev_setup()
970 dev->pci_bus = dev->pci->bus->number; in saa7164_dev_setup()
971 dev->pci_slot = PCI_SLOT(dev->pci->devfn); in saa7164_dev_setup()
974 dev->i2c_bus[0].dev = dev; in saa7164_dev_setup()
975 dev->i2c_bus[0].nr = 0; in saa7164_dev_setup()
976 dev->i2c_bus[1].dev = dev; in saa7164_dev_setup()
977 dev->i2c_bus[1].nr = 1; in saa7164_dev_setup()
978 dev->i2c_bus[2].dev = dev; in saa7164_dev_setup()
979 dev->i2c_bus[2].nr = 2; in saa7164_dev_setup()
981 /* Transport + Encoder ports 1, 2, 3, 4 - Defaults / setup */ in saa7164_dev_setup()
991 dev->name, dev->pci->subsystem_vendor, in saa7164_dev_setup()
992 dev->pci->subsystem_device); in saa7164_dev_setup()
994 saa7164_devcount--; in saa7164_dev_setup()
995 return -ENODEV; in saa7164_dev_setup()
999 dev->lmmio = ioremap(pci_resource_start(dev->pci, 0), in saa7164_dev_setup()
1000 pci_resource_len(dev->pci, 0)); in saa7164_dev_setup()
1002 dev->lmmio2 = ioremap(pci_resource_start(dev->pci, 2), in saa7164_dev_setup()
1003 pci_resource_len(dev->pci, 2)); in saa7164_dev_setup()
1005 dev->bmmio = (u8 __iomem *)dev->lmmio; in saa7164_dev_setup()
1006 dev->bmmio2 = (u8 __iomem *)dev->lmmio2; in saa7164_dev_setup()
1009 dev->int_status = 0x183000 + 0xf80; in saa7164_dev_setup()
1010 dev->int_ack = 0x183000 + 0xf90; in saa7164_dev_setup()
1014 dev->name, dev->pci->subsystem_vendor, in saa7164_dev_setup()
1015 dev->pci->subsystem_device, saa7164_boards[dev->board].name, in saa7164_dev_setup()
1016 dev->board, card[dev->nr] == dev->board ? in saa7164_dev_setup()
1028 release_mem_region(pci_resource_start(dev->pci, 0), in saa7164_dev_unregister()
1029 pci_resource_len(dev->pci, 0)); in saa7164_dev_unregister()
1031 release_mem_region(pci_resource_start(dev->pci, 2), in saa7164_dev_unregister()
1032 pci_resource_len(dev->pci, 2)); in saa7164_dev_unregister()
1034 if (!atomic_dec_and_test(&dev->refcount)) in saa7164_dev_unregister()
1037 iounmap(dev->lmmio); in saa7164_dev_unregister()
1038 iounmap(dev->lmmio2); in saa7164_dev_unregister()
1051 if (index-- == 0) { in saa7164_seq_start()
1067 if (list_is_last(&dev->devlist, &saa7164_devlist)) in saa7164_seq_next()
1088 seq_printf(m, "%s = %p\n", dev->name, dev); in saa7164_seq_show()
1091 b = &dev->bus; in saa7164_seq_show()
1092 mutex_lock(&b->lock); in saa7164_seq_show()
1095 b->m_dwSetReadPos, saa7164_readl(b->m_dwSetReadPos)); in saa7164_seq_show()
1098 b->m_dwSetWritePos, saa7164_readl(b->m_dwSetWritePos)); in saa7164_seq_show()
1101 b->m_dwGetReadPos, saa7164_readl(b->m_dwGetReadPos)); in saa7164_seq_show()
1104 b->m_dwGetWritePos, saa7164_readl(b->m_dwGetWritePos)); in saa7164_seq_show()
1108 for (i = 0; i < b->m_dwSizeSetRing; i++) { in saa7164_seq_show()
1112 seq_printf(m, " %02x", readb(b->m_pdwSetRing + i)); in saa7164_seq_show()
1123 for (i = 0; i < b->m_dwSizeGetRing; i++) { in saa7164_seq_show()
1127 seq_printf(m, " %02x", readb(b->m_pdwGetRing + i)); in saa7164_seq_show()
1135 mutex_unlock(&b->lock); in saa7164_seq_show()
1185 /* Polling this costs us 1-2% of the arm CPU */ in saa7164_thread_function()
1219 /* no error - so request an msi interrupt */ in saa7164_enable_msi()
1220 err = request_irq(pci_dev->irq, saa7164_irq, 0, in saa7164_enable_msi()
1221 dev->name, dev); in saa7164_enable_msi()
1243 return -ENOMEM; in saa7164_initdev()
1245 err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev); in saa7164_initdev()
1247 dev_err(&pci_dev->dev, "v4l2_device_register failed\n"); in saa7164_initdev()
1252 dev->pci = pci_dev; in saa7164_initdev()
1254 err = -EIO; in saa7164_initdev()
1259 err = -EINVAL; in saa7164_initdev()
1264 dev->pci_rev = pci_dev->revision; in saa7164_initdev()
1265 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); in saa7164_initdev()
1267 dev->name, in saa7164_initdev()
1268 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, in saa7164_initdev()
1269 dev->pci_lat, in saa7164_initdev()
1274 err = dma_set_mask(&pci_dev->dev, 0xffffffff); in saa7164_initdev()
1276 printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); in saa7164_initdev()
1282 dev->msi = true; in saa7164_initdev()
1285 or msi is not enabled - fallback to shared interrupt */ in saa7164_initdev()
1287 err = request_irq(pci_dev->irq, saa7164_irq, in saa7164_initdev()
1288 IRQF_SHARED, dev->name, dev); in saa7164_initdev()
1291 printk(KERN_ERR "%s: can't get IRQ %d\n", dev->name, in saa7164_initdev()
1292 pci_dev->irq); in saa7164_initdev()
1293 err = -EIO; in saa7164_initdev()
1302 dev->cmds[i].seqno = i; in saa7164_initdev()
1303 dev->cmds[i].inuse = 0; in saa7164_initdev()
1304 mutex_init(&dev->cmds[i].lock); in saa7164_initdev()
1305 init_waitqueue_head(&dev->cmds[i].wait); in saa7164_initdev()
1309 INIT_WORK(&dev->workcmd, saa7164_work_cmdhandler); in saa7164_initdev()
1312 if (dev->board != SAA7164_BOARD_UNKNOWN) { in saa7164_initdev()
1347 saa7164_i2c_register(&dev->i2c_bus[0]); in saa7164_initdev()
1348 saa7164_i2c_register(&dev->i2c_bus[1]); in saa7164_initdev()
1349 saa7164_i2c_register(&dev->i2c_bus[2]); in saa7164_initdev()
1361 /* Begin to create the video sub-systems and register funcs */ in saa7164_initdev()
1362 if (saa7164_boards[dev->board].porta == SAA7164_MPEG_DVB) { in saa7164_initdev()
1363 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS1]) < 0) { in saa7164_initdev()
1369 if (saa7164_boards[dev->board].portb == SAA7164_MPEG_DVB) { in saa7164_initdev()
1370 if (saa7164_dvb_register(&dev->ports[SAA7164_PORT_TS2]) < 0) { in saa7164_initdev()
1376 if (saa7164_boards[dev->board].portc == SAA7164_MPEG_ENCODER) { in saa7164_initdev()
1377 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC1]) < 0) { in saa7164_initdev()
1383 if (saa7164_boards[dev->board].portd == SAA7164_MPEG_ENCODER) { in saa7164_initdev()
1384 if (saa7164_encoder_register(&dev->ports[SAA7164_PORT_ENC2]) < 0) { in saa7164_initdev()
1390 if (saa7164_boards[dev->board].porte == SAA7164_MPEG_VBI) { in saa7164_initdev()
1391 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI1]) < 0) { in saa7164_initdev()
1397 if (saa7164_boards[dev->board].portf == SAA7164_MPEG_VBI) { in saa7164_initdev()
1398 if (saa7164_vbi_register(&dev->ports[SAA7164_PORT_VBI2]) < 0) { in saa7164_initdev()
1406 dev->kthread = kthread_run(saa7164_thread_function, dev, in saa7164_initdev()
1408 if (IS_ERR(dev->kthread)) { in saa7164_initdev()
1409 dev->kthread = NULL; in saa7164_initdev()
1431 v4l2_device_unregister(&dev->v4l2_dev); in saa7164_initdev()
1445 if (dev->board != SAA7164_BOARD_UNKNOWN) { in saa7164_finidev()
1446 if (fw_debug && dev->kthread) { in saa7164_finidev()
1447 kthread_stop(dev->kthread); in saa7164_finidev()
1448 dev->kthread = NULL; in saa7164_finidev()
1450 if (dev->firmwareloaded) in saa7164_finidev()
1454 saa7164_histogram_print(&dev->ports[SAA7164_PORT_ENC1], in saa7164_finidev()
1455 &dev->ports[SAA7164_PORT_ENC1].irq_interval); in saa7164_finidev()
1456 saa7164_histogram_print(&dev->ports[SAA7164_PORT_ENC1], in saa7164_finidev()
1457 &dev->ports[SAA7164_PORT_ENC1].svc_interval); in saa7164_finidev()
1458 saa7164_histogram_print(&dev->ports[SAA7164_PORT_ENC1], in saa7164_finidev()
1459 &dev->ports[SAA7164_PORT_ENC1].irq_svc_interval); in saa7164_finidev()
1460 saa7164_histogram_print(&dev->ports[SAA7164_PORT_ENC1], in saa7164_finidev()
1461 &dev->ports[SAA7164_PORT_ENC1].read_interval); in saa7164_finidev()
1462 saa7164_histogram_print(&dev->ports[SAA7164_PORT_ENC1], in saa7164_finidev()
1463 &dev->ports[SAA7164_PORT_ENC1].poll_interval); in saa7164_finidev()
1464 saa7164_histogram_print(&dev->ports[SAA7164_PORT_VBI1], in saa7164_finidev()
1465 &dev->ports[SAA7164_PORT_VBI1].read_interval); in saa7164_finidev()
1466 saa7164_histogram_print(&dev->ports[SAA7164_PORT_VBI2], in saa7164_finidev()
1467 &dev->ports[SAA7164_PORT_VBI2].poll_interval); in saa7164_finidev()
1471 if (saa7164_boards[dev->board].porta == SAA7164_MPEG_DVB) in saa7164_finidev()
1472 saa7164_dvb_unregister(&dev->ports[SAA7164_PORT_TS1]); in saa7164_finidev()
1474 if (saa7164_boards[dev->board].portb == SAA7164_MPEG_DVB) in saa7164_finidev()
1475 saa7164_dvb_unregister(&dev->ports[SAA7164_PORT_TS2]); in saa7164_finidev()
1477 if (saa7164_boards[dev->board].portc == SAA7164_MPEG_ENCODER) in saa7164_finidev()
1478 saa7164_encoder_unregister(&dev->ports[SAA7164_PORT_ENC1]); in saa7164_finidev()
1480 if (saa7164_boards[dev->board].portd == SAA7164_MPEG_ENCODER) in saa7164_finidev()
1481 saa7164_encoder_unregister(&dev->ports[SAA7164_PORT_ENC2]); in saa7164_finidev()
1483 if (saa7164_boards[dev->board].porte == SAA7164_MPEG_VBI) in saa7164_finidev()
1484 saa7164_vbi_unregister(&dev->ports[SAA7164_PORT_VBI1]); in saa7164_finidev()
1486 if (saa7164_boards[dev->board].portf == SAA7164_MPEG_VBI) in saa7164_finidev()
1487 saa7164_vbi_unregister(&dev->ports[SAA7164_PORT_VBI2]); in saa7164_finidev()
1489 saa7164_i2c_unregister(&dev->i2c_bus[0]); in saa7164_finidev()
1490 saa7164_i2c_unregister(&dev->i2c_bus[1]); in saa7164_finidev()
1491 saa7164_i2c_unregister(&dev->i2c_bus[2]); in saa7164_finidev()
1494 free_irq(pci_dev->irq, dev); in saa7164_finidev()
1496 if (dev->msi) { in saa7164_finidev()
1498 dev->msi = false; in saa7164_finidev()
1504 list_del(&dev->devlist); in saa7164_finidev()
1508 v4l2_device_unregister(&dev->v4l2_dev); in saa7164_finidev()
1520 /* --- end of list --- */