82 lines
2.0 KiB
Diff
82 lines
2.0 KiB
Diff
From 6ea422ff3561bc5241527e478884dd64e9caabe6 Mon Sep 17 00:00:00 2001
|
|
From: Ondrej Jirman <megi@xff.cz>
|
|
Date: Thu, 9 Jun 2022 01:04:18 +0200
|
|
Subject: [PATCH 354/389] media: i2c: imx258: Add debug register access
|
|
|
|
This is useful during development.
|
|
|
|
Signed-off-by: Ondrej Jirman <megi@xff.cz>
|
|
---
|
|
drivers/media/i2c/imx258.c | 48 ++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 48 insertions(+)
|
|
|
|
diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
|
|
index 83068d1033ea..553b4a821563 100644
|
|
--- a/drivers/media/i2c/imx258.c
|
|
+++ b/drivers/media/i2c/imx258.c
|
|
@@ -1275,6 +1275,53 @@ static int imx258_identify_module(struct imx258 *imx258)
|
|
return 0;
|
|
}
|
|
|
|
+#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
+static int imx258_g_register(struct v4l2_subdev *sd,
|
|
+ struct v4l2_dbg_register *reg)
|
|
+{
|
|
+ struct imx258 *imx258 = to_imx258(sd);
|
|
+ u32 val = 0;
|
|
+ int ret;
|
|
+
|
|
+ if (reg->reg > 0xffff)
|
|
+ return -EINVAL;
|
|
+
|
|
+ reg->size = 1;
|
|
+
|
|
+ mutex_lock(&imx258->mutex);
|
|
+ ret = imx258_read_reg(imx258, reg->reg, 1, &val);
|
|
+ mutex_unlock(&imx258->mutex);
|
|
+ if (ret)
|
|
+ return -EIO;
|
|
+
|
|
+ reg->val = val;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int imx258_s_register(struct v4l2_subdev *sd,
|
|
+ const struct v4l2_dbg_register *reg)
|
|
+{
|
|
+ struct imx258 *imx258 = to_imx258(sd);
|
|
+ int ret;
|
|
+
|
|
+ if (reg->reg > 0xffff || reg->val > 0xff)
|
|
+ return -EINVAL;
|
|
+
|
|
+ mutex_lock(&imx258->mutex);
|
|
+ ret = imx258_write_reg(imx258, reg->reg, 1, reg->val);
|
|
+ mutex_unlock(&imx258->mutex);
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+#endif
|
|
+
|
|
+static const struct v4l2_subdev_core_ops imx258_core_ops = {
|
|
+#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
+ .g_register = imx258_g_register,
|
|
+ .s_register = imx258_s_register,
|
|
+#endif
|
|
+};
|
|
+
|
|
static const struct v4l2_subdev_video_ops imx258_video_ops = {
|
|
.s_stream = imx258_set_stream,
|
|
};
|
|
@@ -1287,6 +1334,7 @@ static const struct v4l2_subdev_pad_ops imx258_pad_ops = {
|
|
};
|
|
|
|
static const struct v4l2_subdev_ops imx258_subdev_ops = {
|
|
+ .core = &imx258_core_ops,
|
|
.video = &imx258_video_ops,
|
|
.pad = &imx258_pad_ops,
|
|
};
|
|
--
|
|
2.35.3
|
|
|