From b1d21d84ec9cc2c49ef3f1e4c58c309e6ce57358 Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Tue, 6 Sep 2022 14:37:29 +0800 Subject: [PATCH] media: i2c: sc530ai support get channel info Signed-off-by: Zefa Chen Change-Id: Ie52ca66917de1e1dc9da36ece34d8a3ed44e24fb --- drivers/media/i2c/sc530ai.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/i2c/sc530ai.c b/drivers/media/i2c/sc530ai.c index 547a465d2f81..b8d818cbe30d 100644 --- a/drivers/media/i2c/sc530ai.c +++ b/drivers/media/i2c/sc530ai.c @@ -1128,11 +1128,23 @@ static int sc530ai_set_hdrae(struct sc530ai *sc530ai, return ret; } +static int sc530ai_get_channel_info(struct sc530ai *sc530ai, struct rkmodule_channel_info *ch_info) +{ + if (ch_info->index < PAD0 || ch_info->index >= PAD_MAX) + return -EINVAL; + ch_info->vc = sc530ai->cur_mode->vc[ch_info->index]; + ch_info->width = sc530ai->cur_mode->width; + ch_info->height = sc530ai->cur_mode->height; + ch_info->bus_fmt = sc530ai->cur_mode->bus_fmt; + return 0; +} + static long sc530ai_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) { struct sc530ai *sc530ai = to_sc530ai(sd); struct rkmodule_hdr_cfg *hdr; const struct sc530ai_mode *mode; + struct rkmodule_channel_info *ch_info; long ret = 0; u32 i, h = 0, w; @@ -1208,6 +1220,10 @@ static long sc530ai_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) SC530AI_REG_VALUE_08BIT, SC530AI_MODE_SW_STANDBY); break; + case RKMODULE_GET_CHANNEL_INFO: + ch_info = (struct rkmodule_channel_info *)arg; + ret = sc530ai_get_channel_info(sc530ai, ch_info); + break; default: ret = -ENOIOCTLCMD; break; @@ -1224,6 +1240,7 @@ static long sc530ai_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; @@ -1294,6 +1311,21 @@ static long sc530ai_compat_ioctl32(struct v4l2_subdev *sd, ret = sc530ai_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 = sc530ai_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;