All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: unlisted-recipients:; (no To-header on input)@casper.infradead.org
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: [PATCH 5/6] [media] v4l2-mc: add an ancillary routine for PCI-based MC
Date: Fri,  5 Feb 2016 14:04:59 -0200	[thread overview]
Message-ID: <e861d9c437dd6c469f3aff23df78949e85e23c54.1454688188.git.mchehab@osg.samsung.com> (raw)
In-Reply-To: <cover.1454688187.git.mchehab@osg.samsung.com>
In-Reply-To: <cover.1454688187.git.mchehab@osg.samsung.com>

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 | 35 +++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 24 +++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 7276dbbbe830..e8dc3cfac666 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)
 
 {
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index 3097493e6cf1..18bcdbb300d4 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -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,10 +110,28 @@ 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
-- 
2.5.0



  parent reply	other threads:[~2016-02-05 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 16:04 [PATCH 0/6] Add media controller support to saa7134 Mauro Carvalho Chehab
2016-02-05 16:04 ` [PATCH 1/6] [media] add media controller support to videobuf2-dvb Mauro Carvalho Chehab
2016-02-05 16:04 ` [PATCH 2/6] [media] saa7134: use input types, instead of hardcoding strings Mauro Carvalho Chehab
2016-02-05 16:04 ` [PATCH 3/6] [media] saa7134: unconditionlally update TV standard at demod Mauro Carvalho Chehab
2016-02-05 16:04 ` [PATCH 4/6] [media] saa7134: Get rid of struct saa7134_input.tv field Mauro Carvalho Chehab
2016-02-05 16:04 ` Mauro Carvalho Chehab [this message]
2016-02-05 16:05 ` [PATCH 6/6] [media] saa7134: add media controller support Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e861d9c437dd6c469f3aff23df78949e85e23c54.1454688188.git.mchehab@osg.samsung.com \
    --to=mchehab@osg.samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.