From: Primoz Fiser <primoz.fiser@norik.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
upstream@lists.phytec.de
Subject: [PATCH 2/3] media: mt9v032: Add control for row noise correction
Date: Fri, 9 Oct 2026 12:28:16 +0200 [thread overview]
Message-ID: <20261009102817.2421388-3-primoz.fiser@norik.com> (raw)
In-Reply-To: <20261009102817.2421388-1-primoz.fiser@norik.com>
From: Jan Luebbe <jlu@pengutronix.de>
The sensor's row noise correction algorithm was previously always
disabled by unconditionally writing 0 to MT9V032_ROW_NOISE_CORR_CONTROL,
with no way for userspace to enable it.
Add a V4L2_CID_ROW_NOISE_CORRECTION boolean control so userspace can
toggle the model-specific enable value (MT9V032_ROW_NOISE_CORR_ENABLE /
MT9V034_ROW_NOISE_CORR_ENABLE) at runtime. Default to disabled to
preserve existing behaviour.
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
---
drivers/media/i2c/mt9v032.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 5da10fe42552..d8e34e128d77 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -167,6 +167,7 @@ struct mt9v032_model_data {
unsigned int pclk_reg;
unsigned int aec_max_shutter_reg;
const struct v4l2_ctrl_config * const aec_max_shutter_v4l2_ctrl;
+ unsigned int row_noise_enable;
};
struct mt9v032_model_info {
@@ -231,6 +232,7 @@ struct mt9v032 {
u32 sysclk;
u16 aec_agc;
u16 hblank;
+ bool row_noise_corr;
struct {
struct v4l2_ctrl *test_pattern;
struct v4l2_ctrl *test_pattern_color;
@@ -356,11 +358,6 @@ static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on)
return ret;
}
- /* Disable the noise correction algorithm and restore the controls. */
- ret = regmap_write(map, MT9V032_ROW_NOISE_CORR_CONTROL, 0);
- if (ret < 0)
- return ret;
-
return v4l2_ctrl_handler_setup(&mt9v032->ctrls);
}
@@ -679,6 +676,10 @@ static int mt9v032_set_selection(struct v4l2_subdev *subdev,
* Maximum shutter width used for AEC.
*/
#define V4L2_CID_AEC_MAX_SHUTTER_WIDTH (V4L2_CID_USER_BASE | 0x1007)
+/*
+ * Row Noise Correction enable.
+ */
+#define V4L2_CID_ROW_NOISE_CORRECTION (V4L2_CID_USER_BASE | 0x1008)
static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
{
@@ -770,6 +771,11 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
return regmap_write(map,
mt9v032->model->data->aec_max_shutter_reg,
ctrl->val);
+ case V4L2_CID_ROW_NOISE_CORRECTION:
+ mt9v032->row_noise_corr = ctrl->val;
+ return regmap_write(map, MT9V032_ROW_NOISE_CORR_CONTROL,
+ mt9v032->row_noise_corr ?
+ mt9v032->model->data->row_noise_enable : 0);
}
return 0;
@@ -850,6 +856,16 @@ static const struct v4l2_ctrl_config mt9v032_aegc_controls[] = {
.step = 1,
.def = 2,
.flags = 0,
+ }, {
+ .ops = &mt9v032_ctrl_ops,
+ .id = V4L2_CID_ROW_NOISE_CORRECTION,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "Row Noise Correction",
+ .min = 0,
+ .max = 1,
+ .step = 1,
+ .def = 0,
+ .flags = 0,
}
};
@@ -1246,6 +1262,7 @@ static const struct mt9v032_model_data mt9v032_model_data[] = {
.pclk_reg = MT9V032_PIXEL_CLOCK,
.aec_max_shutter_reg = MT9V032_AEC_MAX_SHUTTER_WIDTH,
.aec_max_shutter_v4l2_ctrl = &mt9v032_aec_max_shutter_width,
+ .row_noise_enable = MT9V032_ROW_NOISE_CORR_ENABLE,
}, {
/* MT9V024, MT9V034 */
.min_row_time = 690,
@@ -1257,6 +1274,7 @@ static const struct mt9v032_model_data mt9v032_model_data[] = {
.pclk_reg = MT9V034_PIXEL_CLOCK,
.aec_max_shutter_reg = MT9V034_AEC_MAX_SHUTTER_WIDTH,
.aec_max_shutter_v4l2_ctrl = &mt9v034_aec_max_shutter_width,
+ .row_noise_enable = MT9V034_ROW_NOISE_CORR_ENABLE,
},
};
--
2.34.1
next prev parent reply other threads:[~2026-10-09 10:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 10:28 [PATCH 0/3] media: mt9v032: Improvements from PHYTEC Primoz Fiser
2026-10-09 10:28 ` [PATCH 1/3] media: mt9v032: Support color format selection Primoz Fiser
2026-10-09 10:28 ` Primoz Fiser [this message]
2026-10-09 10:28 ` [PATCH 3/3] media: mt9v032: Add get_mbus_config subdev_pad_ops callback Primoz Fiser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261009102817.2421388-3-primoz.fiser@norik.com \
--to=primoz.fiser@norik.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=upstream@lists.phytec.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®