[v2,15/19] media: v4l-core add v4l_enable_media_tuner() to check for tuner availability
diff mbox

Message ID 1647341b774540fd9afbc7bb58e1a76510893ad4.1437599281.git.shuahkh@osg.samsung.com
State New
Headers show

Commit Message

Shuah Khan July 22, 2015, 10:42 p.m. UTC
Add a new interface to be used by v4l-core to invoke enable_source
handler in the media_device to find tuner entity connected to the
decoder and check is it is available. enable_source handler will
activate the link if tuner is available.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 drivers/media/v4l2-core/v4l2-dev.c | 17 +++++++++++++++++
 include/media/v4l2-dev.h           |  3 +++
 2 files changed, 20 insertions(+)

Patch
diff mbox

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 71a1b93..00fc71d 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -230,6 +230,23 @@  struct video_device *video_devdata(struct file *file)
 }
 EXPORT_SYMBOL(video_devdata);
 
+int v4l_enable_media_tuner(struct video_device *vdev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+	struct media_device *mdev = vdev->decoder->parent;
+	int ret;
+
+	/* decoder */
+	if (!mdev || !mdev->enable_source)
+			return 0;
+	ret = mdev->enable_source(vdev->decoder);
+	if (ret)
+		return -EBUSY;
+	return 0;
+#endif /* CONFIG_MEDIA_CONTROLLER */
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l_enable_media_tuner);
 
 /* Priority handling */
 
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index acbcd2f..eff3852 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -86,6 +86,7 @@  struct video_device
 {
 #if defined(CONFIG_MEDIA_CONTROLLER)
 	struct media_entity entity;
+	struct media_entity *decoder;
 #endif
 	/* device ops */
 	const struct v4l2_file_operations *fops;
@@ -178,6 +179,8 @@  struct video_device * __must_check video_device_alloc(void);
 /* this release function frees the vdev pointer */
 void video_device_release(struct video_device *vdev);
 
+int v4l_enable_media_tuner(struct video_device *vdev);
+
 /* this release function does nothing, use when the video_device is a
    static global struct. Note that having a static video_device is
    a dubious construction at best. */