From: Marco Ziliani <rylos78@gmail.com>
To: Daniel Scally <dan.scally@ideasonboard.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, Chris Simpson <chris@nilk.net>,
Tony Garcia <tony@loafecho.com>,
Simon Kruse <simon0x+git@proton.me>,
"D. Manresa" <dmanresa@gmail.com>,
linux-kernel@vger.kernel.org, Marco Ziliani <rylos78@gmail.com>
Subject: [PATCH v3 1/4] media: i2c: ov5693: Keep driver-managed registers out of the global list
Date: Sat, 28 Nov 2026 00:11:33 +0100 [thread overview]
Message-ID: <20261128-ov5693-fixes-v3-1-bcdd169958b6@gmail.com> (raw)
In-Reply-To: <20261128-ov5693-fixes-v3-0-bcdd169958b6@gmail.com>
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@linux.intel.com>
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
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
next prev parent reply other threads:[~2026-11-27 23:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 23:11 [PATCH v3 0/4] media: i2c: ov5693: Fix mode changes, flips and autosuspend Marco Ziliani
2026-11-27 23:11 ` Marco Ziliani [this message]
2026-11-27 23:11 ` [PATCH v3 2/4] media: i2c: ov5693: Write format and crop changes to a powered sensor Marco Ziliani
2026-11-27 23:11 ` [PATCH v3 3/4] media: i2c: ov5693: Keep the Bayer order when flipping at full resolution Marco Ziliani
2026-11-27 23:11 ` [PATCH v3 4/4] media: i2c: ov5693: Use autosuspend when stopping the stream Marco Ziliani
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=20261128-ov5693-fixes-v3-1-bcdd169958b6@gmail.com \
--to=rylos78@gmail.com \
--cc=chris@nilk.net \
--cc=dan.scally@ideasonboard.com \
--cc=dmanresa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=simon0x+git@proton.me \
--cc=tony@loafecho.com \
/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®