21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #include <linux/module.h>
26 static int saa7146_num;
38 pr_info(
" @ %li jiffies:\n", jiffies);
39 for (i = 0; i <= 0x148; i += 4)
55 value &= ~(0xff << (8*
port));
56 value |= (data << (8*
port));
61 static inline int saa7146_wait_for_debi_done_sleep(
struct saa7146_dev *dev,
62 unsigned long us1,
unsigned long us2)
74 pr_err(
"%s: %s timed out while waiting for registers getting programmed\n",
89 DEB_S(
"%s: %s timed out while waiting for transfer completion\n",
99 static inline int saa7146_wait_for_debi_done_busyloop(
struct saa7146_dev *dev,
100 unsigned long us1,
unsigned long us2)
110 pr_err(
"%s: %s timed out while waiting for registers getting programmed\n",
111 dev->
name, __func__);
124 DEB_S(
"%s: %s timed out while waiting for transfer completion\n",
125 dev->
name, __func__);
137 return saa7146_wait_for_debi_done_sleep(dev, 50000, 250000);
139 return saa7146_wait_for_debi_done_busyloop(dev, 50000, 250000);
149 static struct scatterlist* vmalloc_to_sg(
unsigned char *virt,
int nr_pages)
159 for (i = 0; i < nr_pages; i++, virt +=
PAGE_SIZE) {
164 sg_set_page(&sglist[i], pg,
PAGE_SIZE, 0);
185 if (!(pt->
slist = vmalloc_to_sg(mem, pages)))
194 goto err_free_pgtable;
262 for (i = 0; i < sglen; i++, list++) {
268 for (p = 0; p * 4096 < list->
length; p++, ptr++) {
277 for(i=nr_pages;i<1024;i++) {
309 if (dev->
ext->irq_mask & isr) {
310 if (dev->
ext->irq_func)
311 dev->
ext->irq_func(dev, &isr);
312 isr &= ~dev->
ext->irq_mask;
316 DEB_INT(
"irq: RPS0 (0x%08x)\n", isr);
335 pr_warn(
"%s: unexpected i2c irq: isr %08x psr %08x ssr %08x\n",
336 dev->
name, isr, psr, ssr);
341 ERR(
"warning: interrupt enabled, but not handled properly.(0x%08x)\n",
343 ERR(
"disabling interrupt source(s)!\n");
344 SAA7146_IER_DISABLE(dev,isr);
363 ERR(
"out of memory\n");
371 ERR(
"pci_enable_device() failed\n");
392 ERR(
"ioremap() failed\n");
417 ERR(
"request_irq() failed\n");
426 if (!dev->
d_rps0.cpu_addr)
432 if (!dev->
d_rps1.cpu_addr)
437 &dev->
d_i2c.dma_handle);
438 if (!dev->
d_i2c.cpu_addr)
447 pr_info(
"found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x)\n",
468 if (
ext->probe &&
ext->probe(dev)) {
469 DEB_D(
"ext->probe() failed for %p. skipping device.\n", dev);
473 if (
ext->attach(dev, pci_ext)) {
474 DEB_D(
"ext->attach() failed for %p. skipping device.\n", dev);
480 pci_set_drvdata(pci, &dev->
v4l2_dev);
490 dev->
d_i2c.dma_handle);
510 static void saa7146_remove_one(
struct pci_dev *pdev)
512 struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
513 struct saa7146_dev *dev = to_saa7146_dev(v4l2_dev);
518 { dev->
d_i2c.cpu_addr, dev->
d_i2c.dma_handle },
526 dev->
ext->detach(dev);
528 pci_set_drvdata(pdev,
NULL);
538 for (
p = dev_map;
p->addr;
p++)
558 ext->
driver.probe = saa7146_init_one;
559 ext->
driver.remove = saa7146_remove_one;
562 return pci_register_driver(&ext->
driver);