From feb05d124af8a255a332468aa16309c285922c43 Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Tue, 6 Sep 2022 14:15:35 +0800 Subject: [PATCH] media: i2c: sc500ai support get channel info Signed-off-by: Zefa Chen Change-Id: I53e3d0389de3b0bcc5fd86a7184826aaecd39594 --- drivers/media/i2c/sc500ai.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/i2c/sc500ai.c b/drivers/media/i2c/sc500ai.c index b232eafdf210..7797885804a0 100644 --- a/drivers/media/i2c/sc500ai.c +++ b/drivers/media/i2c/sc500ai.c @@ -908,11 +908,23 @@ static int sc500ai_set_hdrae(struct sc500ai *sc500ai, return ret; } +static int sc500ai_get_channel_info(struct sc500ai *sc500ai, struct rkmodule_channel_info *ch_info) +{ + if (ch_info->index < PAD0 || ch_info->index >= PAD_MAX) + return -EINVAL; + ch_info->vc = sc500ai->cur_mode->vc[ch_info->index]; + ch_info->width = sc500ai->cur_mode->width; + ch_info->height = sc500ai->cur_mode->height; + ch_info->bus_fmt = sc500ai->cur_mode->bus_fmt; + return 0; +} + static long sc500ai_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) { struct sc500ai *sc500ai = to_sc500ai(sd); struct rkmodule_hdr_cfg *hdr; const struct sc500ai_mode *mode; + struct rkmodule_channel_info *ch_info; long ret = 0; u32 i, h, w; @@ -974,6 +986,10 @@ static long sc500ai_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) ret = sc500ai_write_reg(sc500ai->client, SC500AI_REG_CTRL_MODE, SC500AI_REG_VALUE_08BIT, SC500AI_MODE_SW_STANDBY); break; + case RKMODULE_GET_CHANNEL_INFO: + ch_info = (struct rkmodule_channel_info *)arg; + ret = sc500ai_get_channel_info(sc500ai, ch_info); + break; default: ret = -ENOIOCTLCMD; break; @@ -990,6 +1006,7 @@ static long sc500ai_compat_ioctl32(struct v4l2_subdev *sd, struct rkmodule_inf *inf; struct rkmodule_hdr_cfg *hdr; struct preisp_hdrae_exp_s *hdrae; + struct rkmodule_channel_info *ch_info; long ret = 0; u32 stream = 0; @@ -1056,6 +1073,21 @@ static long sc500ai_compat_ioctl32(struct v4l2_subdev *sd, ret = sc500ai_ioctl(sd, cmd, &stream); break; + case RKMODULE_GET_CHANNEL_INFO: + ch_info = kzalloc(sizeof(*ch_info), GFP_KERNEL); + if (!ch_info) { + ret = -ENOMEM; + return ret; + } + + ret = sc500ai_ioctl(sd, cmd, ch_info); + if (!ret) { + ret = copy_to_user(up, ch_info, sizeof(*ch_info)); + if (ret) + ret = -EFAULT; + } + kfree(ch_info); + break; default: ret = -ENOIOCTLCMD; break;