From 5142b5cdf613f6b61e9506eee81e908045b22404 Mon Sep 17 00:00:00 2001
From: Daniel Mack <daniel@zonque.org>
Date: Tue, 5 Dec 2017 11:39:42 +0100
Subject: [PATCH] camss: expose sensor controls on video node
---
.../media/platform/qcom/camss-8x16/camss-video.c | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
@@ -640,10 +640,34 @@ static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = {
* V4L2 file operations
*/
+static struct media_entity *video_find_sensor(struct camss_video *video)
+{
+ struct media_pad *pad = &video->pad;
+
+ while (1) {
+ struct media_entity *entity;
+
+ if (!(pad->flags & MEDIA_PAD_FL_SINK))
+ return NULL;
+
+ pad = media_entity_remote_pad(pad);
+ if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
+ return NULL;
+
+ entity = pad->entity;
+
+ if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
+ return entity;
+
+ pad = &entity->pads[0];
+ }
+}
+
static int video_open(struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct camss_video *video = video_drvdata(file);
+ struct media_entity *sensor_entity;
struct v4l2_fh *vfh;
int ret;
@@ -660,6 +684,14 @@ static int video_open(struct file *file)
file->private_data = vfh;
+ sensor_entity = video_find_sensor(video);
+ if (sensor_entity) {
+ struct v4l2_subdev *sd =
+ media_entity_to_v4l2_subdev(sensor_entity);
+
+ vdev->ctrl_handler = sd->ctrl_handler;
+ }
+
ret = v4l2_pipeline_pm_use(&vdev->entity, 1);
if (ret < 0) {
dev_err(video->camss->dev, "Failed to power up pipeline: %d\n",
--
2.14.3