lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1592301619-17631-2-git-send-email-rbmeftah@de.adit-jv.com>
Date:   Tue, 16 Jun 2020 12:00:16 +0200
From:   Ramzi BEN MEFTAH <rbmeftah@...adit-jv.com>
To:     Kieran Bingham <kieran.bingham@...asonboard.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Hans Verkuil <hans.verkuil@...co.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Janusz Krzysztofik <jmkrzyszt@...il.com>,
        Jacopo Mondi <jacopo@...ndi.org>,
        Steve Longerbeam <steve_longerbeam@...tor.com>,
        Ezequiel Garcia <ezequiel@...labora.com>,
        Arnd Bergmann <arnd@...db.de>, <linux-media@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Michael Rodin <mrodin@...adit-jv.com>, <efriedrich@...adit-jv.com>,
        <erosca@...adit-jv.com>
Subject: [PATCH 2/3] media: i2c: adv748x-afe: Implement enum/get/set input

From: Steve Longerbeam <steve_longerbeam@...tor.com>

The adv748x-afe sub-device driver does not support changing the
analog input, so enuminput returns only the status of a single
input at index=0. Likewise g_input returns only index 0, and s_input
returns -EINVAL if index is not 0, and otherwise does nothing.

Signed-off-by: Steve Longerbeam <steve_longerbeam@...tor.com>
(cherry picked from ADIT v4.14 commit 8aadc35d3ae252a1eaed8506fbd1675911465bbd)
---
 drivers/media/i2c/adv748x/adv748x-afe.c | 42 ++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
index dbbb1e4..6b090f4 100644
--- a/drivers/media/i2c/adv748x/adv748x-afe.c
+++ b/drivers/media/i2c/adv748x/adv748x-afe.c
@@ -154,7 +154,7 @@ static void adv748x_afe_set_video_standard(struct adv748x_state *state,
 		   (sdpstd & 0xf) << ADV748X_SDP_VID_SEL_SHIFT);
 }
 
-static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)
+static int adv748x_afe_set_input(struct adv748x_afe *afe, unsigned int input)
 {
 	struct adv748x_state *state = adv748x_afe_to_state(afe);
 
@@ -267,6 +267,39 @@ static int adv748x_afe_g_input_status(struct v4l2_subdev *sd, u32 *status)
 	return ret;
 }
 
+static int adv748x_afe_enuminput(struct v4l2_subdev *sd,
+				 struct v4l2_input *input)
+{
+	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
+
+	if (input->index != 0)
+		return -EINVAL;
+
+	input->type = V4L2_INPUT_TYPE_CAMERA;
+	input->capabilities = V4L2_IN_CAP_STD;
+	input->status = V4L2_IN_ST_NO_SIGNAL;
+	/* API says we must return all supported standards */
+	input->std = V4L2_STD_ALL;
+
+	snprintf(input->name, sizeof(input->name), "%s AIN%u",
+		 sd->name, afe->input);
+
+	return adv748x_afe_g_input_status(sd, &input->status);
+}
+
+static int adv748x_afe_g_input(struct v4l2_subdev *sd, u32 *index)
+{
+	*index = 0;
+	return 0;
+}
+
+static int adv748x_afe_s_input(struct v4l2_subdev *sd, u32 index)
+{
+	if (index != 0)
+		return -EINVAL;
+	return 0;
+}
+
 static int adv748x_afe_s_stream(struct v4l2_subdev *sd, int enable)
 {
 	struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
@@ -277,7 +310,7 @@ static int adv748x_afe_s_stream(struct v4l2_subdev *sd, int enable)
 	mutex_lock(&state->mutex);
 
 	if (enable) {
-		ret = adv748x_afe_s_input(afe, afe->input);
+		ret = adv748x_afe_set_input(afe, afe->input);
 		if (ret)
 			goto unlock;
 	}
@@ -306,6 +339,9 @@ static const struct v4l2_subdev_video_ops adv748x_afe_video_ops = {
 	.querystd = adv748x_afe_querystd,
 	.g_tvnorms = adv748x_afe_g_tvnorms,
 	.g_input_status = adv748x_afe_g_input_status,
+	.enuminput = adv748x_afe_enuminput,
+	.g_input = adv748x_afe_g_input,
+	.s_input = adv748x_afe_s_input,
 	.s_stream = adv748x_afe_s_stream,
 	.g_pixelaspect = adv748x_afe_g_pixelaspect,
 };
@@ -520,7 +556,7 @@ int adv748x_afe_init(struct adv748x_afe *afe)
 		}
 	}
 
-	adv748x_afe_s_input(afe, afe->input);
+	adv748x_afe_set_input(afe, afe->input);
 
 	adv_dbg(state, "AFE Default input set to %d\n", afe->input);
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ