diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-07 11:23:40 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-07 11:23:40 +0100 |
commit | 03ba675c15fe86ace9d44dc86d769b6695621e69 (patch) | |
tree | e50ffde04eeab204325633b4750b7e2d70e05e23 /linux | |
parent | 3fd8c59cdeaedaa51a5db45b8dbf67dc6b907e19 (diff) | |
download | mediapointer-dvb-s2-03ba675c15fe86ace9d44dc86d769b6695621e69.tar.gz mediapointer-dvb-s2-03ba675c15fe86ace9d44dc86d769b6695621e69.tar.bz2 |
saa7146: implement v4l2_device support.
From: Hans Verkuil <hverkuil@xs4all.nl>
Priority: normal
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 17 | ||||
-rw-r--r-- | linux/include/media/saa7146.h | 3 |
2 files changed, 13 insertions, 7 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index 9bce837f3..ef11ab98c 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -367,13 +367,16 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ERR(("out of memory.\n")); goto out; } + err = v4l2_device_register(&pci->dev, &dev->v4l2_dev); + if (err) + goto err_free; DEB_EE(("pci:%p\n",pci)); err = pci_enable_device(pci); if (err < 0) { ERR(("pci_enable_device() failed.\n")); - goto err_free; + goto err_unreg; } /* enable bus-mastering */ @@ -456,8 +459,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); dev->ext = ext; - pci_set_drvdata(pci, dev); - mutex_init(&dev->lock); spin_lock_init(&dev->int_slock); spin_lock_init(&dev->slock); @@ -481,7 +482,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent if (ext->attach(dev, pci_ext)) { DEB_D(("ext->attach() failed for %p. skipping device.\n",dev)); - goto err_unprobe; + goto err_free_i2c; } INIT_LIST_HEAD(&dev->item); @@ -492,8 +493,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent out: return err; -err_unprobe: - pci_set_drvdata(pci, NULL); err_free_i2c: pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, dev->d_i2c.dma_handle); @@ -511,6 +510,8 @@ err_release: pci_release_region(pci, 0); err_disable: pci_disable_device(pci); +err_unreg: + v4l2_device_unregister(&dev->v4l2_dev); err_free: kfree(dev); goto out; @@ -518,7 +519,8 @@ err_free: static void saa7146_remove_one(struct pci_dev *pdev) { - struct saa7146_dev* dev = pci_get_drvdata(pdev); + struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev); + struct saa7146_dev *dev = container_of(v4l2_dev, struct saa7146_dev, v4l2_dev); struct { void *addr; dma_addr_t dma; @@ -532,6 +534,7 @@ static void saa7146_remove_one(struct pci_dev *pdev) DEB_EE(("dev:%p\n",dev)); dev->ext->detach(dev); + v4l2_device_unregister(&dev->v4l2_dev); /* shut down all video dma transfers */ saa7146_write(dev, MC1, 0x00ff0000); diff --git a/linux/include/media/saa7146.h b/linux/include/media/saa7146.h index 8034124f1..689bc8ebd 100644 --- a/linux/include/media/saa7146.h +++ b/linux/include/media/saa7146.h @@ -14,6 +14,7 @@ #include "compat.h" #include <linux/mutex.h> #include <linux/scatterlist.h> +#include <media/v4l2-device.h> #include <linux/vmalloc.h> /* for vmalloc() */ #include <linux/mm.h> /* for vmalloc_to_page() */ @@ -111,6 +112,8 @@ struct saa7146_dev struct list_head item; + struct v4l2_device v4l2_dev; + /* different device locks */ spinlock_t slock; struct mutex lock; |