[PATCH v3 1/4] media: i2c: ov5693: Keep driver-managed registers out of the global list
From: Marco Ziliani
Date: Fri Nov 27 2026 - 18:11:56 EST
ov5693_global_regs writes three registers that the driver also programs:
0x350b, the low byte of the analogue gain set by the gain control, and
FORMAT1/FORMAT2 (0x3820/0x3821), whose binning and flip bits follow the
format and the flip controls. The values from the list are overwritten
anyway, so the overlap only hides which code owns those registers.
Drop the three entries. Program the FORMAT registers in full from
ov5693_mode_configure() instead, except for the flip bits, which stay
with the flip controls. That keeps the values the list used to write:
0x00 for FORMAT1, and bits 4:3 of FORMAT2, which the vendor sequence
sets and whose purpose isn't documented.
Suggested-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Signed-off-by: Marco Ziliani <rylos78@xxxxxxxxx>
---
drivers/media/i2c/ov5693.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 56599f9ca..d221f7951 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -94,11 +94,17 @@
#define OV5693_FORMAT1_FLIP_VERT_ISP_EN BIT(6)
#define OV5693_FORMAT1_FLIP_VERT_SENSOR_EN BIT(1)
#define OV5693_FORMAT1_VBIN_EN BIT(0)
+#define OV5693_FORMAT1_FLIP_VERT_MASK (OV5693_FORMAT1_FLIP_VERT_ISP_EN | \
+ OV5693_FORMAT1_FLIP_VERT_SENSOR_EN)
#define OV5693_FORMAT2_REG CCI_REG8(0x3821)
#define OV5693_FORMAT2_HDR_EN BIT(7)
#define OV5693_FORMAT2_FLIP_HORZ_ISP_EN BIT(2)
#define OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN BIT(1)
#define OV5693_FORMAT2_HBIN_EN BIT(0)
+#define OV5693_FORMAT2_FLIP_HORZ_MASK (OV5693_FORMAT2_FLIP_HORZ_ISP_EN | \
+ OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN)
+/* Set by the vendor initialisation sequence, purpose undocumented */
+#define OV5693_FORMAT2_VENDOR_BITS GENMASK(4, 3)
#define OV5693_ISP_CTRL2_REG CCI_REG8(0x5002)
#define OV5693_ISP_SCALE_ENABLE BIT(7)
@@ -203,7 +209,6 @@ static const struct cci_reg_sequence ov5693_global_regs[] = {
{CCI_REG8(0x3106), 0x00},
{CCI_REG8(0x3406), 0x01},
{CCI_REG8(0x3503), 0x07},
- {CCI_REG8(0x350b), 0x40},
{CCI_REG8(0x3601), 0x0a},
{CCI_REG8(0x3602), 0x38},
{CCI_REG8(0x3612), 0x80},
@@ -322,8 +327,6 @@ static const struct cci_reg_sequence ov5693_global_regs[] = {
{CCI_REG8(0x5848), 0x01},
{CCI_REG8(0x5849), 0x0c},
{CCI_REG8(0x5e10), 0x0c},
- {CCI_REG8(0x3820), 0x00},
- {CCI_REG8(0x3821), 0x1e},
{CCI_REG8(0x5041), 0x14}
};
@@ -364,8 +367,7 @@ static const u8 ov5693_test_pattern_bits[] = {
static int ov5693_flip_vert_configure(struct ov5693_device *ov5693,
bool enable)
{
- u8 bits = OV5693_FORMAT1_FLIP_VERT_ISP_EN |
- OV5693_FORMAT1_FLIP_VERT_SENSOR_EN;
+ u8 bits = OV5693_FORMAT1_FLIP_VERT_MASK;
int ret;
ret = cci_update_bits(ov5693->regmap, OV5693_FORMAT1_REG, bits,
@@ -379,8 +381,7 @@ static int ov5693_flip_vert_configure(struct ov5693_device *ov5693,
static int ov5693_flip_horz_configure(struct ov5693_device *ov5693,
bool enable)
{
- u8 bits = OV5693_FORMAT2_FLIP_HORZ_ISP_EN |
- OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN;
+ u8 bits = OV5693_FORMAT2_FLIP_HORZ_MASK;
int ret;
ret = cci_update_bits(ov5693->regmap, OV5693_FORMAT2_REG, bits,
@@ -603,14 +604,18 @@ static int ov5693_mode_configure(struct ov5693_device *ov5693)
cci_write(ov5693->regmap, OV5693_SUB_INC_Y_REG,
((mode->inc_y_odd << 4) & 0xf0) | 0x01, &ret);
- /* Binning */
+ /*
+ * Binning. Program all the bits of the FORMAT registers except the
+ * flips, which follow the flip controls.
+ */
cci_update_bits(ov5693->regmap, OV5693_FORMAT1_REG,
- OV5693_FORMAT1_VBIN_EN,
+ GENMASK(7, 0) & ~OV5693_FORMAT1_FLIP_VERT_MASK,
mode->binning_y ? OV5693_FORMAT1_VBIN_EN : 0, &ret);
cci_update_bits(ov5693->regmap, OV5693_FORMAT2_REG,
- OV5693_FORMAT2_HBIN_EN,
- mode->binning_x ? OV5693_FORMAT2_HBIN_EN : 0, &ret);
+ GENMASK(7, 0) & ~OV5693_FORMAT2_FLIP_HORZ_MASK,
+ OV5693_FORMAT2_VENDOR_BITS |
+ (mode->binning_x ? OV5693_FORMAT2_HBIN_EN : 0), &ret);
return ret;
}
--
2.56.1