[alsa-devel] [PATCH v2 15/19] media: v4l-core add v4l_enable_media_tuner() to check for tuner availability

Shuah Khan shuahkh at osg.samsung.com
Thu Jul 23 00:42:16 CEST 2015


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 at osg.samsung.com>
---
 drivers/media/v4l2-core/v4l2-dev.c | 17 +++++++++++++++++
 include/media/v4l2-dev.h           |  3 +++
 2 files changed, 20 insertions(+)

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. */
-- 
2.1.4



More information about the Alsa-devel mailing list