From: Maurizio Casciano <mauriziocasciano7@gmail.com>
To: mchehab@kernel.org, linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, bingbu.cao@amd.com,
jacopo.mondi@ideasonboard.com, nicholas@rothemail.net,
andy@kernel.org, andriy.shevchenko@intel.com, hansg@kernel.org,
gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v6 01/16] media: ov8858: Extract digital gain programming
Date: Tue, 1 Sep 2026 21:04:23 +0200 [thread overview]
Message-ID: <ec1729f6eb60f3d29707fc3d13e247d2b072dfc8.1788286339.git.mauriziocasciano7@gmail.com> (raw)
In-Reply-To: <cover.1788286339.git.mauriziocasciano7@gmail.com>
Move the existing packed digital-gain register programming into a
helper so clock-specific gain handling can be added separately.
This is a pure refactoring: preserve both the register packing and the
explanatory comment without changing the bytes written to the sensor.
Assisted-by: LLM sparse
Signed-off-by: Maurizio Casciano <mauriziocasciano7@gmail.com>
---
drivers/media/i2c/ov8858.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/media/i2c/ov8858.c b/drivers/media/i2c/ov8858.c
index 3f45f7fab833..d95f034de752 100644
--- a/drivers/media/i2c/ov8858.c
+++ b/drivers/media/i2c/ov8858.c
@@ -1523,6 +1523,23 @@ static int ov8858_enable_test_pattern(struct ov8858 *ov8858, u32 pattern)
return ov8858_write(ov8858, OV8858_REG_TEST_PATTERN, val, NULL);
}
+static int ov8858_set_long_digital_gain(struct ov8858 *ov8858, u32 gain)
+{
+ u16 long_gain;
+
+ /*
+ * Digital gain is assembled as:
+ * 0x350a[7:0] = dgain[13:6]
+ * 0x350b[5:0] = dgain[5:0]
+ * Reassemble the control value to write it in one go.
+ */
+ long_gain = (gain & OV8858_LONG_DIGIGAIN_L_MASK) |
+ ((gain & OV8858_LONG_DIGIGAIN_H_MASK) <<
+ OV8858_LONG_DIGIGAIN_H_SHIFT);
+
+ return ov8858_write(ov8858, OV8858_REG_LONG_DIGIGAIN, long_gain, NULL);
+}
+
static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct ov8858 *ov8858 = container_of(ctrl->handler,
@@ -1531,7 +1548,6 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)
struct i2c_client *client = v4l2_get_subdevdata(&ov8858->subdev);
struct v4l2_mbus_framefmt *format;
struct v4l2_subdev_state *state;
- u16 digi_gain;
s64 max_exp;
int ret;
@@ -1570,17 +1586,7 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)
ctrl->val, NULL);
break;
case V4L2_CID_DIGITAL_GAIN:
- /*
- * Digital gain is assembled as:
- * 0x350a[7:0] = dgain[13:6]
- * 0x350b[5:0] = dgain[5:0]
- * Reassemble the control value to write it in one go.
- */
- digi_gain = (ctrl->val & OV8858_LONG_DIGIGAIN_L_MASK)
- | ((ctrl->val & OV8858_LONG_DIGIGAIN_H_MASK) <<
- OV8858_LONG_DIGIGAIN_H_SHIFT);
- ret = ov8858_write(ov8858, OV8858_REG_LONG_DIGIGAIN,
- digi_gain, NULL);
+ ret = ov8858_set_long_digital_gain(ov8858, ctrl->val);
break;
case V4L2_CID_VBLANK:
ret = ov8858_write(ov8858, OV8858_REG_VTS,
--
2.53.0
next prev parent reply other threads:[~2026-09-01 19:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 19:04 [PATCH v6 00/16] media: Add Yoga Book camera support Maurizio Casciano
2026-09-01 19:04 ` Maurizio Casciano [this message]
2026-09-01 22:16 ` [PATCH v6 01/16] media: ov8858: Extract digital gain programming Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 02/16] media: ov8858: support 19.2 MHz clock and CHT gain setup Maurizio Casciano
2026-09-02 10:33 ` Sakari Ailus
2026-09-02 13:13 ` Andy Shevchenko
2026-09-01 19:04 ` [PATCH v6 03/16] media: ov2740: Use C99 initializers for ACPI IDs Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 04/16] media: ov2740: Add OVTI2740 ACPI ID Maurizio Casciano
2026-09-01 22:17 ` Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 05/16] media: ov8858: Add INT3477 " Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 06/16] media: intel: ipu-bridge: Add Yoga Book camera sensors Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 07/16] media: atomisp: Add Yoga Book camera configuration Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 08/16] media: ov2740: support 288 MHz link frequency Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 09/16] media: intel: ipu-bridge: allow sensor-specific link frequencies Maurizio Casciano
2026-09-01 22:21 ` Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 10/16] media: atomisp: derive CSI-2 timing from sensor link frequency Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 11/16] media: atomisp: provide Yoga Book OV2740 " Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 12/16] media: ov2740: release group hold after gain write errors Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 13/16] media: ov2740: add manual white balance controls Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 14/16] media: atomisp: Use struct v4l2_area for padding Maurizio Casciano
2026-09-03 4:38 ` Andy Shevchenko
2026-09-01 19:04 ` [PATCH v6 15/16] media: atomisp: allow raw Bayer capture Maurizio Casciano
2026-09-01 19:04 ` [PATCH v6 16/16] media: i2c: Add WV517S lens actuator driver Maurizio Casciano
2026-09-02 13:27 ` [PATCH v6 00/16] media: Add Yoga Book camera support Andy Shevchenko
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=ec1729f6eb60f3d29707fc3d13e247d2b072dfc8.1788286339.git.mauriziocasciano7@gmail.com \
--to=mauriziocasciano7@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=bingbu.cao@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=jacopo.mondi@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=nicholas@rothemail.net \
--cc=sakari.ailus@linux.intel.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®