7 #define FC_LOG_PREFIX "flexcop-pci"
10 static int enable_pid_filtering = 1;
13 "enable hardware pid filtering: supported values: 0 (fullts), 1");
15 static int irq_chk_intv = 100;
17 MODULE_PARM_DESC(irq_chk_intv,
"set the interval for IRQ streaming watchdog.");
19 #ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
20 #define dprintk(level,args...) \
21 do { if ((debug & level)) printk(args); } while (0)
24 #define dprintk(level,args...)
25 #define DEBSTATUS " (debugging is not enabled)"
28 #define deb_info(args...) dprintk(0x01, args)
29 #define deb_reg(args...) dprintk(0x02, args)
30 #define deb_ts(args...) dprintk(0x04, args)
31 #define deb_irq(args...) dprintk(0x08, args)
32 #define deb_chk(args...) dprintk(0x10, args)
37 "set debug level (1=info,2=regs,4=TS,8=irqdma,16=check (|-able))."
40 #define DRIVER_VERSION "0.1"
41 #define DRIVER_NAME "flexcop-pci"
47 #define FC_PCI_INIT 0x01
48 #define FC_PCI_DMA_INIT 0x02
55 #define FC_DEFAULT_DMA1_BUFSIZE (1280 * 188)
56 #define FC_DEFAULT_DMA2_BUFSIZE (10 * 188)
73 static int lastwreg, lastwval, lastrreg, lastrval;
82 if (lastrreg != r || lastrval != v.
raw) {
83 lastrreg =
r; lastrval = v.
raw;
95 if (lastwreg != r || lastwval != v.
raw) {
96 lastwreg =
r; lastwval = v.
raw;
113 deb_chk(
"no IRQ since the last check\n");
116 deb_info(
"flexcop-pci: stream problem, resetting pid filter\n");
118 spin_lock_irq(&fc->
demux.lock);
128 spin_unlock_irq(&fc->
demux.lock);
157 if (v.
irq_20c.Data_receiver_error)
158 deb_chk(
"data receiver error\n");
159 if (v.
irq_20c.Continuity_error_flag)
160 deb_chk(
"Contunuity error flag is set\n");
161 if (v.
irq_20c.LLC_SNAP_FLAG_set)
162 deb_chk(
"LLC_SNAP_FLAG_set is set\n");
166 if ((fc_pci->
count % 1000) == 0)
167 deb_chk(
"%d valid irq took place so far\n", fc_pci->
count);
169 if (v.
irq_20c.DMA1_IRQ_Status == 1) {
172 fc_pci->
dma[0].cpu_addr0,
173 fc_pci->
dma[0].size / 188);
176 fc_pci->
dma[0].cpu_addr1,
177 fc_pci->
dma[0].size / 188);
183 }
else if (v.
irq_20c.DMA1_Timer_Status == 1) {
186 u32 cur_pos = cur_addr - fc_pci->
dma[0].dma_addr0;
188 deb_irq(
"%u irq: %08x cur_addr: %llx: cur_pos: %08x, "
189 "last_cur_pos: %08x ",
191 v.
raw, (
unsigned long long)cur_addr, cur_pos,
198 if (cur_pos < fc_pci->last_dma1_cur_pos) {
199 deb_irq(
" end was reached: passing %d bytes ",
200 (fc_pci->
dma[0].size*2 - 1) -
203 fc_pci->
dma[0].cpu_addr0 +
205 (fc_pci->
dma[0].size*2) -
214 fc_pci->
dma[0].cpu_addr0 +
223 deb_irq(
"isr for flexcop called, "
224 "apparently without reason (%08x)\n", v.
raw);
228 spin_unlock_irqrestore(&fc_pci->
irq_lock, flags);
253 deb_irq(
"DMA xfer disabled\n");
258 static int flexcop_pci_dma_init(
struct flexcop_pci *fc_pci)
281 static void flexcop_pci_dma_exit(
struct flexcop_pci *fc_pci)
290 static int flexcop_pci_init(
struct flexcop_pci *fc_pci)
294 info(
"card revision %x", fc_pci->
pdev->revision);
301 goto err_pci_disable_device;
303 fc_pci->
io_mem = pci_iomap(fc_pci->
pdev, 0, 0x800);
306 err(
"cannot map io memory\n");
308 goto err_pci_release_regions;
311 pci_set_drvdata(fc_pci->
pdev, fc_pci);
315 goto err_pci_iounmap;
322 pci_set_drvdata(fc_pci->
pdev,
NULL);
323 err_pci_release_regions:
325 err_pci_disable_device:
330 static void flexcop_pci_exit(
struct flexcop_pci *fc_pci)
335 pci_set_drvdata(fc_pci->
pdev,
NULL);
350 err(
"out of memory\n");
364 if (enable_pid_filtering)
365 info(
"will use the HW PID filter.");
367 info(
"will pass the complete TS to the demuxer.");
376 if ((ret = flexcop_pci_init(fc_pci)) != 0)
384 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
389 if (irq_chk_intv > 0)
399 flexcop_pci_exit(fc_pci);
408 static void flexcop_pci_remove(
struct pci_dev *pdev)
410 struct flexcop_pci *fc_pci = pci_get_drvdata(pdev);
412 if (irq_chk_intv > 0)
415 flexcop_pci_dma_exit(fc_pci);
417 flexcop_pci_exit(fc_pci);
428 static struct pci_driver flexcop_pci_driver = {
429 .name =
"b2c2_flexcop_pci",
430 .id_table = flexcop_pci_tbl,
431 .probe = flexcop_pci_probe,
432 .remove = flexcop_pci_remove,
435 static int __init flexcop_pci_module_init(
void)
437 return pci_register_driver(&flexcop_pci_driver);
440 static void __exit flexcop_pci_module_exit(
void)