[PATCH 2/3] media: mt9v032: Add control for row noise correction

From: Primoz Fiser

Date: Fri Oct 09 2026 - 06:30:56 EST


From: Jan Luebbe <jlu@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
Signed-off-by: Primoz Fiser <primoz.fiser@xxxxxxxxx>
---
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