[media] v4l2-mc: add an ancillary routine for PCI-based MC
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 5 Feb 2016 15:16:18 +0000 (13:16 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 10 Feb 2016 09:23:44 +0000 (07:23 -0200)
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>
drivers/media/v4l2-core/v4l2-mc.c
include/media/v4l2-mc.h

index e6d2a711bb0b05755324d095075930cc6c80f3d3..b6cf6dbd4cd5cc688b8d3354533efae2b6aa310a 100644 (file)
  */
 
 #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)
 
 {
index aed9e9b87f82e1edb7c55c4c6793d520289ba2ab..6fad97277a0b23f8392f1978caa4c41fe960eee7 100644 (file)
@@ -92,6 +92,10 @@ enum demod_pad_index {
        DEMOD_NUM_PADS
 };
 
+
+struct pci_dev;                /* We don't need to include pci.h here */
+
+#ifdef CONFIG_MEDIA_CONTROLLER
 /**
  * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
  *
@@ -106,11 +110,29 @@ enum demod_pad_index {
  * interface centric PC-consumer's hardware, V4L2 subdev centric camera
  * hardware should not use this routine, as it will not build the right graph.
  */
-#ifdef CONFIG_MEDIA_CONTROLLER
 int v4l2_mc_create_media_graph(struct media_device *mdev);
+
+/**
+ * v4l2_mc_pci_media_device_init() - create and initialize a
+ *     struct &media_device from a PCI device.
+ *
+ * @pci_dev:   pointer to struct pci_dev
+ * @name:      media device name. If %NULL, the routine will use the default
+ *             name for the pci device, given by pci_name() macro.
+ */
+struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
+                                                  char *name);
+
+
 #else
 static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
 {
        return 0;
 }
+
+struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
+                                                  char *name) {
+       return NULL;
+}
+
 #endif
This page took 0.029913 seconds and 5 git commands to generate.