diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-02-05 18:16:18 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-02-10 12:23:44 +0300 |
commit | 7047f2982a223e0ecca480c11a37bd9edf62b65a (patch) | |
tree | 9b0db4e7a89f338b3b39e747fa2d70f07da3166b /drivers/media/v4l2-core/v4l2-mc.c | |
parent | 8bf77f9e7013e46ca08151189357532f027c47e8 (diff) | |
download | linux-7047f2982a223e0ecca480c11a37bd9edf62b65a.tar.xz |
[media] v4l2-mc: add an ancillary routine for PCI-based MC
Instead of copyping the same code on all PCI devices that
would have a media controller, add a core ancillary routine.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-mc.c')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-mc.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index e6d2a711bb0b..b6cf6dbd4cd5 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -15,9 +15,44 @@ */ #include <linux/module.h> +#include <linux/pci.h> #include <media/media-entity.h> #include <media/v4l2-mc.h> + +struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, + char *name) +{ +#ifdef CONFIG_PCI + struct media_device *mdev; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return NULL; + + mdev->dev = &pci_dev->dev; + + if (name) + strlcpy(mdev->model, name, sizeof(mdev->model)); + else + strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); + + sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); + + mdev->hw_revision = pci_dev->subsystem_vendor << 16 + || pci_dev->subsystem_device; + + mdev->driver_version = LINUX_VERSION_CODE; + + media_device_init(mdev); + + return mdev; +#else + return NULL; +#endif +} +EXPORT_SYMBOL_GPL(v4l2_mc_pci_media_device_init); + int v4l2_mc_create_media_graph(struct media_device *mdev) { |