[PATCH 2/3] media: i2c: adv748x-afe: Implement enum/get/set input
From: Ramzi BEN MEFTAH
Date: Tue Jun 16 2020 - 06:00:51 EST
From: Steve Longerbeam <steve_longerbeam@xxxxxxxxxx>
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@xxxxxxxxxx>
(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