From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE35D3A1A27; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; cv=none; b=BSnsBweSXTRdEPimaaOGiDwFgmkVX92RAHLF4GYA0ZYkfPKscnVRO4WAumNkPDaCKp0r68RxzMcyPaLf/tgM7WYtch7FJgfzaMEb3KNDR3cotCsfhXipxaA3WvlZuzbQqhmTgUbvxEbKNvkinOOGioW9crORmXKX0fox2CPagnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; c=relaxed/simple; bh=X7NyouCN65aYsOl9IfYiR8GqzCJ8zRJcFc2sniRidO0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dPycTl3oF0U78T179gEBlVQ+YV8TmjElgI1ifqNXTfv85+0butCujgRBSq+U8obUIzN4+gM3Pr91iOh7BYR7yya7KFzL9+0f1HbkjtZwf2zR09wUBGn5LF2iC2PuwCw605cwTswPuxabQwbjIY21p8FmpWQe986QZTHiVCpO3hA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xXbAOHN1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xXbAOHN1" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6AEF6C2BCF6; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=X7NyouCN65aYsOl9IfYiR8GqzCJ8zRJcFc2sniRidO0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=xXbAOHN1D3/LzC9nUQrwejxIx7mFJM2gBonZmDHyBt+oZCC69ZbfuQFWWSYrZqqJB BU5ANFgFfMv+s0W1cMM3r6gd6IROCAaJSi1jxAhlO4uqudmZbkpQjqWhjVizBFGvmJ BI0+4jpnq0G0Ev2gH6mzePeUc6OuYMR91yLSxK3s= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4822CC88E6F; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:20:58 +0200 Subject: [PATCH 01/10] media: i2c: ov9282: handle error from exposure range update Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-1-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=890; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=X7NyouCN65aYsOl9IfYiR8GqzCJ8zRJcFc2sniRidO0=; b=be6Yyk92In/WjPDuMyVaHDaTgkqGHKD3BJ8x/b7FFhUYG5RaY3+gWUmDa+snrnztju5IRIiu2 c/2OvPRkCFfBHtbvp/8dDlU8/jTDMDPrxy4wv8EkJLYgeRhdIEPvYAW X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 When setting V4L2_CID_VBLANK the V4L2 range for the exposure control is updated v4l2_ctrl_modify_range(). This range update missed a return value check, which resulted in ov9282_set_ctrl() not returning on an error from that function call. Fix this by checking the return value and returning it on error. Signed-off-by: Richard Leitner Reviewed-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 5d301660a87d8..c10b2e205834e 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -608,6 +608,8 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) ov9282->cur_mode->height - OV9282_EXPOSURE_OFFSET, 1, OV9282_EXPOSURE_DEFAULT); + if (ret) + return ret; break; } =20 --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE3FC3A1E67; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; cv=none; b=h8PPyHGTL/xh6TuuK/n8jeJDNI34TrJ0QwLz9aDGM/w9Pjyt9mzukBEZRpC6/19AZKbfLWf5TplpXif/gdcrkRJg8hPnmC2mRahRpneM1tdamXuMwOOd9vwp8pU32yXnQwOmhhC+K8uE3rBipd3/LfP6CLOyzrB6Wq+aBHw25HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; c=relaxed/simple; bh=aGlhmX7jD+MBnjOKtuwFJE1JDXZjtQZXasoYCmCS4OQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EMO4X453BLGzp/pNFfrCctthLTejmFn4Xr3h84EOAJHZbBqyPWXptkeyIjRpSSnFwmWN7JnavB/zYTM5R1SfB9dqb2uZomMA+xe6exNvdqTCXOD+gY/fvN684j+zgWv1xDOCCuVks7h9g/xcPBmo2QiJCeUxjRvBWn0ZwIFwF+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kyMRsOkn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kyMRsOkn" Received: by smtp.kernel.org (Postfix) with ESMTPS id 739DAC2BCFF; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=aGlhmX7jD+MBnjOKtuwFJE1JDXZjtQZXasoYCmCS4OQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kyMRsOknG48np14cAZFPbXUl4R7wv1vNSumVvFxjUo/JQRuydTxZ048MpiH8EBS0Q VeUIKe+tcmpzLzg4NhI74Tt0ojOvtMimX15iJEvCTol4qvQPG5sxvWfXUw4jSpP4G8 Wt3uQZTOuoBA7I/1PqjcCGTNhBG/mxXRowlvoMPI= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5673BC88E7D; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:20:59 +0200 Subject: [PATCH 02/10] media: i2c: ov9282: fix line time and exposure time calculation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-2-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=3330; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=aGlhmX7jD+MBnjOKtuwFJE1JDXZjtQZXasoYCmCS4OQ=; b=09NOCbRYWWMa4nkEoSDjjdX1ogzH3XZwHTv9qF5qOh/z8A1ku+qsPTlxSAYNsoDonNgjVY+bm sINCkAOmsoaBrxVajMBwTY4RZxhKg/bsgYiNK4U2iRO56Q8XOnshzfv X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 ov9282_exposure_to_us() divided the line length by the pixel rate control, which is the MIPI rate and not the clock HTS is counted in. The right clock is PLL2's system clock. With the PLL2 dividers left at their reset values the chain SYS_CLK =3D XVCLK / pre_div0 / pre_div * loop_div / sys_pre_div / sys_div =3D 24 / 1 / 3 * loop_div / 4 / 2 collapses to SYS_CLK =3D loop_div MHz. Fix this by introducing a new static function to calculate the current line time and use it in ov9282_exposure_to_us(). Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 46 +++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index c10b2e205834e..3f83a6cf338d8 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #include #include +#include =20 #include #include @@ -472,6 +474,41 @@ static inline struct ov9282 *to_ov9282(struct v4l2_sub= dev *subdev) return container_of(subdev, struct ov9282, sd); } =20 +/** + * ov9282_line_time_ns() - Calculate duration of one sensor line. + * @ov9282: pointer to ov9282 device + * + * The line time and therefore OV9282_REG_TIMING_HTS and the strobe frame = span + * are counted in PLL2's system clock. We assume the PLL2 dividers are at = their + * reset values, so the formula reduces to SYS_CLK =3D loop_div MHz. + * + * Return: line time in nanoseconds. + */ +static u32 ov9282_line_time_ns(struct ov9282 *ov9282) +{ + u32 hts =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + u32 sclk_rate_mhz =3D ov9282->code =3D=3D MEDIA_BUS_FMT_Y10_1X10 ? + OV9282_PLL_CTRL_0D_RAW10 : OV9282_PLL_CTRL_0D_RAW8; + + /* + * OV9282_REG_TIMING_HTS counts 2-pixel units + */ + return DIV_ROUND_CLOSEST(hts * (u32)NSEC_PER_USEC, 2 * sclk_rate_mhz); +} + +/** + * ov9282_exposure_to_us() - Convert an exposure register value to microse= conds + * @ov9282: pointer to ov9282 device + * @exposure: exposure register value to convert + * + * Return: microsecond represenation of the given exposure register value. + */ +static u32 ov9282_exposure_to_us(struct ov9282 *ov9282, u32 exposure) +{ + return div_u64((u64)exposure * ov9282_line_time_ns(ov9282), + NSEC_PER_USEC); +} + /** * ov9282_update_controls() - Update control ranges based on streaming mode * @ov9282: pointer to ov9282 device @@ -510,15 +547,6 @@ static int ov9282_update_controls(struct ov9282 *ov928= 2, mode->vblank_max, 1, mode->vblank); } =20 -static u32 ov9282_exposure_to_us(struct ov9282 *ov9282, u32 exposure) -{ - /* calculate exposure time in =C2=B5s */ - u32 frame_width =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; - u32 trow_us =3D frame_width / (ov9282->pixel_rate->val / 1000000UL); - - return exposure * trow_us; -} - /** * ov9282_update_exp_gain() - Set updated exposure and gain * @ov9282: pointer to ov9282 device --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEC223A2569; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; cv=none; b=Kd7eBS7PNQanoRBPDroqUfa+uIOpc4NapNFv8xh+W+QImdGyk573WeJ7WIf7FWjmu6CTrsoU/LDwuVP1FXOZKcFsaP84+bVykDRHBJoalT3Zo66t64w+2AtGwmoMiLaI0Nytm9DjS66QJ+Rc1defbqoc4oggKTJY4O/XMYgmK6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; c=relaxed/simple; bh=wRsep6ftLnvl73/k/AgvdYj/Y1swLSJ+eRnAI9/2x1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cAZNrGDPpx8TU2bEXTdMUYDbxJlefRRR5BXOnAFmt3HiRufUnNRL3Xt9xGQVnPnSXpWBPUIyzu8pLvVqao5+JU8HoCIih6JTiTilMdfuQPshLCtEpxzvSLlLJngZ7yt9fPSaWUl5MNlSjKhjw1TybABpb2xtZLuy0cqT50oy4M8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=K1quQJMF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="K1quQJMF" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7CB4CC2BCFC; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=wRsep6ftLnvl73/k/AgvdYj/Y1swLSJ+eRnAI9/2x1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K1quQJMFAM3Cv47tcVmycs0ezBEz1sScNE7zgSMFcMFiK4R1IudMOKiHc3qqued+E EaiKxXTzo30Q90LBxqdYA1OGghXLvPMTX/QD+1F3mvhihqcYCQiD2SYJIf1dw/YSR4 FYDZBIdOslUNyz5jc7nYKjdkFTW3VVvmOehCeQfQ= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 677FFC88E73; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:00 +0200 Subject: [PATCH 03/10] media: i2c: ov9282: fix flash duration to/from microseconds conversion Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-3-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=4054; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=wRsep6ftLnvl73/k/AgvdYj/Y1swLSJ+eRnAI9/2x1I=; b=5Q4lEYS24T3+vl53pFRvnHP9QQtLJFP4hJgNQgkoaooxsyUXLuBl1vaZAuoadYV02Kh5ersKK dUq7uTxrWi1C+r6GtD25ChEzASB7SgjXA4df+mPV8rA5Ui4Twzm5n1x X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Currently the flash duration is converted to/from microseconds using a fixed OV9282_STROBE_SPAN_FACTOR constant. This is inaccurate as it was found that the "step width of shift and span" (which is not documented further in the datasheet) scales with the line, so the span is counted in lines. Fix the conversion by dropping the constant factor and using the previously introduced ov9282_line_time_ns() helper instead. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 66 +++++++++++++++++++++++++-----------------= ---- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 3f83a6cf338d8..90a0fe542ce4a 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -133,8 +133,6 @@ #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff =20 -#define OV9282_STROBE_SPAN_FACTOR 192 - static const char * const ov9282_supply_names[] =3D { "avdd", /* Analog power */ "dovdd", /* Digital I/O power */ @@ -509,6 +507,42 @@ static u32 ov9282_exposure_to_us(struct ov9282 *ov9282= , u32 exposure) NSEC_PER_USEC); } =20 +/** + * ov9282_us_to_flash_duration() - Convert =C2=B5s to flash duration regis= ter value + * @ov9282: pointer to ov9282 device + * @value: microseconds value to convert + * + * Calculate "strobe_frame_span" increments from a given value (=C2=B5s). = According + * to the datasheet "The step width of shift and span is programmable under + * system clock domain.", but this is not documented further. Nonetheless = the + * step width was found empirically to scale with the line length, so the = span + * is counted in lines. + * + * Return: flash duration register value + */ +static u32 ov9282_us_to_flash_duration(struct ov9282 *ov9282, u32 value) +{ + return div_u64((u64)value * NSEC_PER_USEC, ov9282_line_time_ns(ov9282)); +} + +/** + * ov9282_flash_duration_to_us() - Convert flash duration register value t= o =C2=B5s + * @ov9282: pointer to ov9282 device + * @value: flash duration register value to convert + * + * Convert a given "strobe_frame_span" increment value to microseconds. Fo= r an + * explanation regarding conversion factor see the documentation of + * ov9282_us_to_flash_duration. As the calculation there uses an integer + * division round up here. + * + * Return: microseconds + */ +static u32 ov9282_flash_duration_to_us(struct ov9282 *ov9282, u32 value) +{ + return DIV_ROUND_UP_ULL((u64)value * ov9282_line_time_ns(ov9282), + NSEC_PER_USEC); +} + /** * ov9282_update_controls() - Update control ranges based on streaming mode * @ov9282: pointer to ov9282 device @@ -585,34 +619,6 @@ static int ov9282_update_exp_gain(struct ov9282 *ov928= 2, u32 exposure, u32 gain) return ret ? ret : ret_hold; } =20 -static u32 ov9282_us_to_flash_duration(struct ov9282 *ov9282, u32 value) -{ - /* - * Calculate "strobe_frame_span" increments from a given value (=C2=B5s). - * This is quite tricky as "The step width of shift and span is - * programmable under system clock domain.", but it's not documented - * how to program this step width (at least in the datasheet available - * to the author at time of writing). - * The formula below is interpolated from different modes/framerates - * and should work quite well for most settings. - */ - u32 frame_width =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; - - return value * OV9282_STROBE_SPAN_FACTOR / frame_width; -} - -static u32 ov9282_flash_duration_to_us(struct ov9282 *ov9282, u32 value) -{ - /* - * Calculate back to microseconds from "strobe_frame_span" increments. - * As the calculation in ov9282_us_to_flash_duration uses an integer - * divison round up here. - */ - u32 frame_width =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; - - return DIV_ROUND_UP(value * frame_width, OV9282_STROBE_SPAN_FACTOR); -} - static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) { struct ov9282 *ov9282 =3D --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CECC43A380C; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; cv=none; b=JwD8XuXDAPM62AICgzLzHG+V4SQnL+hPfLZYjuFGHVbDa/06mPlg08cdj35g+gdSCfPCGxquKX4pM2GJoZ2QcjdsD28OPorAMYS0uWjcNgZxxEG1IamCtFeLvlbrlTbF9/bPuz+R2l8h+bJuIDgjKMVqiVw9TUqsPKfdamtdmX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413685; c=relaxed/simple; bh=ER+zQkWzydHRzZp5pEY5WGaoGbUivQBZvblB/0wtPVM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YyScnnxCRqKCsEIHhyinf11HF2g9c0D/FJgXTjzTHdCl95G8S14qeRs01yj4Z4jeOo+A+2HqG4vB7JOfUyg1PlcscHlImeU0V9JvLRuqE1z1jdhITTX2eZSQ9uHeYKnDyjjZRQ/FjtLFl0Q2FxIHS15mOOLxJhtXQgZ/MrkOimI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qPCdmJwA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qPCdmJwA" Received: by smtp.kernel.org (Postfix) with ESMTPS id 90737C2BD05; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=ER+zQkWzydHRzZp5pEY5WGaoGbUivQBZvblB/0wtPVM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qPCdmJwAABpvamyyBgc7mlmppm55CF7lUXUVPxtNRWbg6lfMvpPySG9klzqRkenZ9 cgt9M6ofq5ZLblrQbgU+B8mN/AK1Aoc0OZgvnbmixErX8ipgigO/ZzVcl3QHNAXIk/ SQrAdPI8diCEjq1gXUTQ6DIdG8KgDnp0vfyxPHhs= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 766CBC88E7F; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:01 +0200 Subject: [PATCH 04/10] media: i2c: ov9282: update flash_duration range even when powered down Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-4-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=1346; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=ER+zQkWzydHRzZp5pEY5WGaoGbUivQBZvblB/0wtPVM=; b=koYQdyi9oc7cfHz0ZeuMXhUNtWxeq6ydv4PIYUL370PQLk5MMIKA4vGyfMUg1op2icjHT+y8n mxHUVQxPG4NAKtt+GiUPTTb8SRUbtsIgr8DzalMWhI8RcIBXdTNcNZL X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 The flash_duration range update sat inside ov9282_update_exp_gain(), which ov9282_set_ctrl() only reaches after the pm_runtime_get_if_in_use() early return. So with the sensor idle the ceiling kept whatever value it had when it last streamed. Therefore setting exposure before flash_duration while the sensor is powered down may clamp flash_duration against an outdated exposure. Fix this by moving the range update before the power check. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 90a0fe542ce4a..4c88de1965171 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -645,6 +645,19 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) if (ret) return ret; break; + case V4L2_CID_EXPOSURE: + /* + * Ensure the flash duration range is also updated on powered + * down sensors. + */ + ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, + ov9282_exposure_to_us(ov9282, + ctrl->val), + 1, + OV9282_STROBE_FRAME_SPAN_DEFAULT); + if (ret) + return ret; + break; } =20 /* Set controls only if sensor is in power on state */ --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 258D43A83B1; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=qOQcHyIHqi/qJH7BjbIIAwYzxax4Py7io2xbljwys2ODfR8lRZw3djnwKLHsOkeXtIa6YwasmrgA3sdv3MT4uWVmnlORN/xybKkwoW4RC6xPUsPaUA3gwEj3vXo+pM82DuTm/KrMZnddH6pgNETQiL4mrzLphPrCfezlL5hTKc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=WRRZv5zlWdvHmn5OUAoEkT5gk8q5459dLRB4h+01wP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EkBlMoMRB/SL3KqjkI6WdjAB4IBiBhaFosaH9KbunwHOxuOAaYwSrUkdhsI/9MkqJw66Ii0A4Q4ggCUA13uY0TDIwPE7YQE4k3Va0OHBxeVSz7QiNtsfgQEOEBVA49PiIkiLhPiX4RaNHBX5r4lHbpfNvCJ7PmoSP3DSrndxMVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=r+zXQqqL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="r+zXQqqL" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9C4EAC4AF0B; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=WRRZv5zlWdvHmn5OUAoEkT5gk8q5459dLRB4h+01wP4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r+zXQqqLgr8gWD01Rk0VaDLnn/MnaLENB3ph1AYCGAT45XSp46qAH0lC5KPezd4qu yUXW+ffpqawUkKiCs3BK59lQt19B8TMw/U1YoyvdZ9Fs3+vaXhfXaUnQVAO6Yxfcus YiRGCPm2devBdFZ7UG1ROzvXzhoqGPlfLYxk7DFE= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87474C88E7B; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:02 +0200 Subject: [PATCH 05/10] media: i2c: ov9282: add refresh of missing ranges on a mode change Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-5-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=2694; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=WRRZv5zlWdvHmn5OUAoEkT5gk8q5459dLRB4h+01wP4=; b=YCv5jeMAXcArDOaxGBVDK3QwlT/1EWgdg3v5yETaFDTPMz2hx2mwl69NDpHux2twVOsZ5iZ/x jrXP8GO2tfaClJ+QLvPlsu/A5ObPisDRuKlo8odzLvF9wk7DFEmpktm X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 ov9282_update_controls() updates the pixel rate, hblank and vblank, but currently misses the exposure range and flash_duration. Both are dependent on the line time and therefore the pixel format. Refresh both, and commit cur_mode and code in ov9282_set_pad_format() before the call so the refresh and any nested s_ctrl see the incoming format. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 4c88de1965171..e64d8343c18e9 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -557,6 +557,8 @@ static int ov9282_update_controls(struct ov9282 *ov9282, { u32 hblank_min; s64 pixel_rate; + u32 exposure_us; + u32 lpfr; int ret; =20 ret =3D __v4l2_ctrl_s_ctrl(ov9282->link_freq_ctrl, mode->link_freq_idx); @@ -577,8 +579,22 @@ static int ov9282_update_controls(struct ov9282 *ov928= 2, if (ret) return ret; =20 - return __v4l2_ctrl_modify_range(ov9282->vblank_ctrl, mode->vblank_min, - mode->vblank_max, 1, mode->vblank); + ret =3D __v4l2_ctrl_modify_range(ov9282->vblank_ctrl, mode->vblank_min, + mode->vblank_max, 1, mode->vblank); + if (ret) + return ret; + + lpfr =3D ov9282->vblank_ctrl->val + mode->height; + ret =3D __v4l2_ctrl_modify_range(ov9282->exp_ctrl, OV9282_EXPOSURE_MIN, + lpfr - OV9282_EXPOSURE_OFFSET, + OV9282_EXPOSURE_STEP, + OV9282_EXPOSURE_DEFAULT); + if (ret) + return ret; + + exposure_us =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); + return __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, exposure_us, + 1, OV9282_STROBE_FRAME_SPAN_DEFAULT); } =20 /** @@ -855,10 +871,23 @@ static int ov9282_set_pad_format(struct v4l2_subdev *= sd, framefmt =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); *framefmt =3D fmt->format; } else { + const struct ov9282_mode *old_mode =3D ov9282->cur_mode; + u32 old_code =3D ov9282->code; + + /* + * Commit before refreshing the ranges. ov9282_update_controls() + * and the nested ov9282_set_ctrl() calls it triggers derive the + * frame length and the line time from cur_mode and code, so + * they have to describe the incoming format, not the outgoing + * one. + */ + ov9282->cur_mode =3D mode; + ov9282->code =3D code; + ret =3D ov9282_update_controls(ov9282, mode, fmt); - if (!ret) { - ov9282->cur_mode =3D mode; - ov9282->code =3D code; + if (ret) { + ov9282->cur_mode =3D old_mode; + ov9282->code =3D old_code; } } =20 --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2581B3A783F; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=J1WDwYy/Lc/noHkjRI31nwmSSvkJNs9ajIhNUGvgSJWnGszcmf/bwC0ncvN0ssDlBOZyQ6pKTzW264YJIKmhYYJHiJgeAz8YtHzhtrGCUeZWsJXHdEoxLb1Z90KR2IGOFwj6FCj3cs2nmsMqSNAH1RMviuhfIp1Z00p5yDU4zbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=+9D94c2OnHxByotyk71RiVy678NF0Rq9EnxYDsY4DUE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MTnNNZehlON6suUOENN1Ss4PkR2Ekecg8yWDuEyZjCViNlRBdftZ1g+/bppKs1qJb2tnUyxG5rEKFLEwRG0W4FpIOrEGQtsLHovflx+89fbUxJpOo1mVX52CBsK/6xrpeUJDIkCjSMsH+BhMismDD0LO/VARhJ2LjEY7Wi/P6Xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=egQwLWZy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="egQwLWZy" Received: by smtp.kernel.org (Postfix) with ESMTPS id AAE21C4AF0F; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=+9D94c2OnHxByotyk71RiVy678NF0Rq9EnxYDsY4DUE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=egQwLWZyMglPRGyBR5h2X6MLH5aZJuxNppHtk1+BChHeKsnIu5Fgl5sDZVEBLEqVj 94LxkSqW/zmDQ/MdQ6hT0yFv18u1a3efzG6aB72CCGhA6+9HSRctKjyoYbRcu4cC03 TOitxpbBUCa2l2ZRteqLRiNPOgNPExlBbjL+2MA8= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97B6EC88E73; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:03 +0200 Subject: [PATCH 06/10] media: i2c: ov9282: refresh flash_duration range on an HBLANK write Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-6-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=1339; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=+9D94c2OnHxByotyk71RiVy678NF0Rq9EnxYDsY4DUE=; b=JZMY05pUX3MajCM1j9FFQ79UlIRT5svduZfkVMrNnEvqzNZy238MT6AzNBwL5QWAcgg8uqnnD RdSoL8Wu9EbDPb1Zb5bsQDN35moVeepLsqT9UU2PfDf0LSwndBOWPHK X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 The strobe ceiling is the exposure time in microseconds, so it follows the line time, and the line length sets the line time. Writing HBLANK moves it and nothing recomputes the flash_duration ceiling. Therefore add the missing flash_duration range update when HBLANK is set. The exposure range is counted in lines, so it is unaffected and does not need refreshing here. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index e64d8343c18e9..632184e76b9bd 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -674,6 +674,19 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) if (ret) return ret; break; + case V4L2_CID_HBLANK: + /* + * HBLANK affects the line time, which then affects the flash + * duration. Therefore recalculate the flash duration range + * here. + */ + exposure =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); + ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, + exposure, 1, + OV9282_STROBE_FRAME_SPAN_DEFAULT); + if (ret) + return ret; + break; } =20 /* Set controls only if sensor is in power on state */ --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 325983A8749; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=Es6AUalZiD33Ku4XE851BmauVg2s5Ky3gmxz3nP6QCZmdOQDE6INeh00r1kydSHS2H/h2XmAaVWAh+PlcK+AvIWKDe7HZ42bEKqJZ/jN92tcUy3YXtkJRZbxsSx43jlkV56jaUIG3EooICgHQXmvxnJVm3PWYZfjkufX8QM3g5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=gOLNNogmoOOUL45wHXQtYclrVHmbDfqCCG9L2KZ0nIU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q2Gw3Z7/sBWR78ZO8vEYYOvKvPMOqZkXoSzSO22Z40xbjP8W/bz5r6JVEUAPGP9adGZz7xJENFCGzKuccnCopT7nKv1G+tro+xqJPvyMdE9IxWvIgTPx5LD67Lv/YRUlQtY+qT5SUnzwnduWAPRc+ZRcPYYFzH10xGAUDpWa9f8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=X2a5Dp0H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="X2a5Dp0H" Received: by smtp.kernel.org (Postfix) with ESMTPS id DC82CC2BCFA; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413685; bh=gOLNNogmoOOUL45wHXQtYclrVHmbDfqCCG9L2KZ0nIU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X2a5Dp0H0laPCEG8lrUdiOBOMoR2sBtKhK1u61LzZXCvo7j/w2tyhcmnRdBHH9l7A nfM0nSS72df6lPuZYFUe+8O49dcx+L2Qrxb8L2e8ECrlaviuI+TANvkIMSjHUUcKvP +laRUzu/RbQqnoJULSVpa5UcqUl2bqhl+xWQw24c= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9ACEC88E6F; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:04 +0200 Subject: [PATCH 07/10] media: i2c: ov9282: drop redundant vblank field Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-7-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=2525; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=gOLNNogmoOOUL45wHXQtYclrVHmbDfqCCG9L2KZ0nIU=; b=UC0U5HwzoIhjoGvQsq/peph0ucT2991+FX2i8rB/xNgGLAYdlDCgUuUqZysXuVZK6hQyes9I6 YhrtGd6BADYCUjCTQLPWjrtLSWg2oubxi1zHtdjLagIsaSPL5F+F2eW X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 The ov9282 main struct has a dedicated vblank field which was only used to duplicate the value of the vblank v4l2 control. Therefore drop this struct field. Signed-off-by: Richard Leitner Reviewed-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 632184e76b9bd..28f8b05b4c09e 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -193,7 +193,6 @@ struct ov9282_mode { * @again_ctrl: Pointer to analog gain control * @pixel_rate: Pointer to pixel rate control * @flash_duration: Pointer to flash duration control - * @vblank: Vertical blanking in lines * @noncontinuous_clock: Selection of CSI2 noncontinuous clock mode * @cur_mode: Pointer to current selected sensor mode * @code: Mbus code currently selected @@ -216,7 +215,6 @@ struct ov9282 { }; struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *flash_duration; - u32 vblank; bool noncontinuous_clock; const struct ov9282_mode *cur_mode; u32 code; @@ -646,17 +644,13 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) =20 switch (ctrl->id) { case V4L2_CID_VBLANK: - ov9282->vblank =3D ov9282->vblank_ctrl->val; - + lpfr =3D ctrl->val + ov9282->cur_mode->height; dev_dbg(ov9282->dev, "Received vblank %u, new lpfr %u", - ov9282->vblank, - ov9282->vblank + ov9282->cur_mode->height); + ctrl->val, lpfr); =20 ret =3D __v4l2_ctrl_modify_range(ov9282->exp_ctrl, OV9282_EXPOSURE_MIN, - ov9282->vblank + - ov9282->cur_mode->height - - OV9282_EXPOSURE_OFFSET, + lpfr - OV9282_EXPOSURE_OFFSET, 1, OV9282_EXPOSURE_DEFAULT); if (ret) return ret; @@ -704,7 +698,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) ret =3D ov9282_update_exp_gain(ov9282, exposure, analog_gain); break; case V4L2_CID_VBLANK: - lpfr =3D ov9282->vblank + ov9282->cur_mode->height; + lpfr =3D ctrl->val + ov9282->cur_mode->height; ret =3D cci_write(ov9282->regmap, OV9282_REG_LPFR, lpfr, NULL); break; case V4L2_CID_HFLIP: @@ -1412,7 +1406,6 @@ static int ov9282_probe(struct i2c_client *client) /* Set default mode to first mode */ ov9282->cur_mode =3D &supported_modes[DEFAULT_MODE]; ov9282->code =3D MEDIA_BUS_FMT_Y10_1X10; - ov9282->vblank =3D ov9282->cur_mode->vblank; =20 ret =3D ov9282_init_controls(ov9282); if (ret) { --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3265B3A9014; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=dXTUryJZE1JyqCBepix6pF5Ky8/ATcyt07piwWmUfF1yy3+CH2/urlrkM1HMk430S/+rejXfYEvbk1cq/qQLAnb1xz77z9hOagldHG45yf9KRML5o0Wrmngp03qSQostmPFbou4k4CO6UJKJzmhCgZ9uWOwOTRKYjch+CHnHHno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=X/+unClTspOJekYPPWuq/bkgvMrI/GbDcnT0WppbeMM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NaxFY8Gq3mQ+6Gfs3l1NsJsMxjOIlB3LG5GqQJQwuY0phicsB2YfPpS6YluEdJv5LVbWt9//QY9QUAELmYzK2e/WWcf+UWTZmZELTV5KRAA+Vr4OcGBTbyFJYPAoCRjw5UD/esXwwBrHjkEtFsA8x0MHOz0eaWBS1xnZjHdhp18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DuPmEASU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DuPmEASU" Received: by smtp.kernel.org (Postfix) with ESMTPS id EB0EBC2BD00; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413686; bh=X/+unClTspOJekYPPWuq/bkgvMrI/GbDcnT0WppbeMM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DuPmEASUjqdIQ9hW80s3eNKCjyc1X70Yihd7TGRBxcoggYP7mZ4iDDQmLlXBGCshg f4K2LxftL2wf5P8XKwY67jHIOYCn28szYidDy5L6fXkSTCLktXcTcZ8wrbNu6BmG2I FbAKDQlTsjEs4bB8s++oEYrHA8D9ouS1AJ/CxnIU= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9509C88E7D; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:05 +0200 Subject: [PATCH 08/10] media: i2c: ov9282: harmonize dev_err_probe usage Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-8-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=4413; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=X/+unClTspOJekYPPWuq/bkgvMrI/GbDcnT0WppbeMM=; b=8nQkBVitJ5/voIL3ISwnrZDJYm67GwDuPPb5ALQx/e9KAhyqnVlBpidImRnmmgv51vHIPgpI7 Uj1oY5dakLdDb6d0eJvZGclj/lIyLQWwADEhUGBKJPRHRZngskqLaRb X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Use dev_err_probe() for all error messages during probing. This ensures there's a common "look-and-feel" in the drivers source code as well as the system log. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 28f8b05b4c09e..f728709fcf0a6 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -1109,26 +1109,25 @@ static int ov9282_parse_hw_config(struct ov9282 *ov= 9282) ov9282->reset_gpio =3D devm_gpiod_get_optional(ov9282->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ov9282->reset_gpio)) { - dev_err(ov9282->dev, "failed to get reset gpio %pe", - ov9282->reset_gpio); - return PTR_ERR(ov9282->reset_gpio); + return dev_err_probe(ov9282->dev, PTR_ERR(ov9282->reset_gpio), + "failed to get reset gpio"); } =20 /* Get sensor input clock */ ov9282->inclk =3D devm_v4l2_sensor_clk_get(ov9282->dev, NULL); if (IS_ERR(ov9282->inclk)) return dev_err_probe(ov9282->dev, PTR_ERR(ov9282->inclk), - "could not get inclk\n"); + "could not get inclk"); =20 ret =3D ov9282_configure_regulators(ov9282); if (ret) return dev_err_probe(ov9282->dev, ret, - "Failed to get power regulators\n"); + "Failed to get power regulators"); =20 rate =3D clk_get_rate(ov9282->inclk); if (rate !=3D OV9282_INCLK_RATE) { - dev_err(ov9282->dev, "inclk frequency mismatch"); - return -EINVAL; + return dev_err_probe(ov9282->dev, -EINVAL, + "inclk frequency mismatch"); } =20 ep =3D fwnode_graph_get_next_endpoint(fwnode, NULL); @@ -1144,16 +1143,15 @@ static int ov9282_parse_hw_config(struct ov9282 *ov= 9282) bus_cfg.bus.mipi_csi2.flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK; =20 if (bus_cfg.bus.mipi_csi2.num_data_lanes !=3D OV9282_NUM_DATA_LANES) { - dev_err(ov9282->dev, - "number of CSI2 data lanes %d is not supported", - bus_cfg.bus.mipi_csi2.num_data_lanes); - ret =3D -EINVAL; + ret =3D dev_err_probe(ov9282->dev, -EINVAL, + "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); goto done_endpoint_free; } =20 if (!bus_cfg.nr_of_link_frequencies) { - dev_err(ov9282->dev, "no link frequencies defined"); - ret =3D -EINVAL; + ret =3D dev_err_probe(ov9282->dev, -EINVAL, + "no link frequencies defined"); goto done_endpoint_free; } =20 @@ -1382,14 +1380,14 @@ static int ov9282_probe(struct i2c_client *client) =20 ret =3D ov9282_parse_hw_config(ov9282); if (ret) { - dev_err(ov9282->dev, "HW configuration is not supported"); - return ret; + return dev_err_probe(ov9282->dev, ret, + "HW configuration is not supported"); } =20 ov9282->regmap =3D devm_cci_regmap_init_i2c(client, 16); if (IS_ERR(ov9282->regmap)) return dev_err_probe(ov9282->dev, PTR_ERR(ov9282->regmap), - "Failed to init CCI\n"); + "Failed to init CCI"); =20 ret =3D ov9282_power_on(ov9282->dev); if (ret) @@ -1399,7 +1397,7 @@ static int ov9282_probe(struct i2c_client *client) /* Check module identity */ ret =3D ov9282_detect(ov9282); if (ret) { - dev_err(ov9282->dev, "failed to find sensor: %d", ret); + dev_err_probe(ov9282->dev, ret, "failed to find sensor"); goto error_power_off; } =20 @@ -1409,7 +1407,7 @@ static int ov9282_probe(struct i2c_client *client) =20 ret =3D ov9282_init_controls(ov9282); if (ret) { - dev_err(ov9282->dev, "failed to init controls: %d", ret); + dev_err_probe(ov9282->dev, ret, "failed to init controls"); goto error_power_off; } =20 @@ -1422,14 +1420,14 @@ static int ov9282_probe(struct i2c_client *client) ov9282->pad.flags =3D MEDIA_PAD_FL_SOURCE; ret =3D media_entity_pads_init(&ov9282->sd.entity, 1, &ov9282->pad); if (ret) { - dev_err(ov9282->dev, "failed to init entity pads: %d", ret); + dev_err_probe(ov9282->dev, ret, "failed to init entity pads"); goto error_handler_free; } =20 ov9282->sd.state_lock =3D ov9282->ctrl_handler.lock; ret =3D v4l2_subdev_init_finalize(&ov9282->sd); if (ret < 0) { - dev_err_probe(ov9282->dev, ret, "failed to init subdev\n"); + dev_err_probe(ov9282->dev, ret, "failed to init subdev"); goto error_media_entity; } =20 --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 326E53A9615; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=CVOrK5TNNmvgHRUlIVfpgzaOULxoOuSYAtp1W5cp4uye52YY1orhgIJ2sMnGrW6Fxiy67Mf9dkvs3Hvmyo91DlgH+7MYtHZsc5UHKeaKPUuDASBCaJJMeuuAcfYRzLQESIUIKPxzNsZgsy+dQO9w+o1cVHZyoqIGbDfo7/mc3Jk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=MgosDSepN/VAOdz00IAVr7J4q2hquqwEmAxEj3m5LkQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TmNuuyYPNFefe+SdFbOJ+oomyKc3045KCPqpm8AEvCeD00CiGzkaeN9ccbFkDKNullmzYGuv4K4EmAUq/YBW22eUtv0MV0EjoSr1WTN3DsIErCybe1fEV7Ec5ID99WEYfPYnHtH2AzOwjzVso3+sQ2DmtHnOV81oGQAvs844J5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=oWOTr5s/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="oWOTr5s/" Received: by smtp.kernel.org (Postfix) with ESMTPS id 05A8FC2BCFB; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413686; bh=MgosDSepN/VAOdz00IAVr7J4q2hquqwEmAxEj3m5LkQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oWOTr5s/425Fh+MZI793LJVDEf9iVAnEU7Dy3cFuVCjSxGFm4mBBuQmAjybR0DHXe SpaEQBosG1M3FsUO7HgeV0E+JT/Z38N6+d8RHyjlRLscqQtQz+tuz1bs+B2xEEPurr JnFpVWnOhDmvXPocTJPudM6+PGyfElp5pomztpR8= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA47DC88E73; Mon, 14 Sep 2026 19:21:25 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:06 +0200 Subject: [PATCH 09/10] media: i2c: ov9282: fix flash duration control range Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-9-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=4273; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=MgosDSepN/VAOdz00IAVr7J4q2hquqwEmAxEj3m5LkQ=; b=6J5T3TCPbUGlmQx6mf1lG2b/++XSje4gsjGhSx8QNPCYrmlUK9KfEYkp16qRB5+t3+Ax7BQDp reD6CCEB0v9BTnYvvJdjXdd2fk68YT3Cgu0kp+OMpVD68OY2kD3uL76 X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 When updating the flash_duration range ensure the ceiling is at least as long as the exposure time is. This may cause the calculated flash_duration register value to be rounded up. This is done by introducing a new ov9282_update_ctrl_range_flash_duration() function and using them wherever possible. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 47 +++++++++++++++++++++++++++---------------= ---- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index f728709fcf0a6..be38ecfad8c82 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -541,6 +541,29 @@ static u32 ov9282_flash_duration_to_us(struct ov9282 *= ov9282, u32 value) NSEC_PER_USEC); } =20 +/** + * ov9282_update_ctrl_range_flash_duration() - Update flash_duration contr= ol range + * @ov9282: pointer to ov9282 device + * + * This may round up the ceiling to the microseconds representation of the + * next flash_duration register value to make sure one can illuminate the = whole + * exposure time long. + * + * Return: 0 if successful, error code otherwise. + */ +static int ov9282_update_ctrl_range_flash_duration(struct ov9282 *ov9282) +{ + u32 exposure_us =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); + u32 fd_max =3D ov9282_us_to_flash_duration(ov9282, exposure_us); + u32 fd_max_us =3D ov9282_flash_duration_to_us(ov9282, fd_max); + + if (fd_max_us < exposure_us) + fd_max_us =3D ov9282_flash_duration_to_us(ov9282, fd_max + 1); + + return __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, fd_max_us, + 1, OV9282_STROBE_FRAME_SPAN_DEFAULT); +} + /** * ov9282_update_controls() - Update control ranges based on streaming mode * @ov9282: pointer to ov9282 device @@ -555,7 +578,6 @@ static int ov9282_update_controls(struct ov9282 *ov9282, { u32 hblank_min; s64 pixel_rate; - u32 exposure_us; u32 lpfr; int ret; =20 @@ -590,9 +612,7 @@ static int ov9282_update_controls(struct ov9282 *ov9282, if (ret) return ret; =20 - exposure_us =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); - return __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, exposure_us, - 1, OV9282_STROBE_FRAME_SPAN_DEFAULT); + return ov9282_update_ctrl_range_flash_duration(ov9282); } =20 /** @@ -605,11 +625,9 @@ static int ov9282_update_controls(struct ov9282 *ov928= 2, */ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32= gain) { - u32 exposure_us =3D ov9282_exposure_to_us(ov9282, exposure); int ret, ret_hold; =20 - dev_dbg(ov9282->dev, "Set exp %u (~%u us), analog gain %u", - exposure, exposure_us, gain); + dev_dbg(ov9282->dev, "Set exp %u, analog gain %u", exposure, gain); =20 ret =3D cci_write(ov9282->regmap, OV9282_REG_HOLD, 0x01, NULL); if (ret) @@ -623,9 +641,7 @@ static int ov9282_update_exp_gain(struct ov9282 *ov9282= , u32 exposure, u32 gain) if (ret) goto error_release_group_hold; =20 - ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, - 0, exposure_us, 1, - OV9282_STROBE_FRAME_SPAN_DEFAULT); + ret =3D ov9282_update_ctrl_range_flash_duration(ov9282); =20 error_release_group_hold: ret_hold =3D cci_write(ov9282->regmap, OV9282_REG_HOLD, 0, NULL); @@ -660,11 +676,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) * Ensure the flash duration range is also updated on powered * down sensors. */ - ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, - ov9282_exposure_to_us(ov9282, - ctrl->val), - 1, - OV9282_STROBE_FRAME_SPAN_DEFAULT); + ret =3D ov9282_update_ctrl_range_flash_duration(ov9282); if (ret) return ret; break; @@ -674,10 +686,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) * duration. Therefore recalculate the flash duration range * here. */ - exposure =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); - ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, - exposure, 1, - OV9282_STROBE_FRAME_SPAN_DEFAULT); + ret =3D ov9282_update_ctrl_range_flash_duration(ov9282); if (ret) return ret; break; --=20 2.53.0 From nobody Fri Sep 25 09:19:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 440DC3AAF5E; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; cv=none; b=BPL8NFo5ap80EXOtqYCEW1MreKpvCfRM9tn0U4b68sESoRjsHmUfLH11li+WDvijATz6iGcA/R8x3yOdZIjde6FegnlwGNSJ5ToTGomistcCQmjG5SYm4HZCRx8QDylM53ce1gulkSTEuH9ByksJaI1iuHyBZgRRlMHfTMdD4Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789413686; c=relaxed/simple; bh=QmfEvOE4SfAXS/MeusYKjadXdFtLLVJQBW79Ocyb2sE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AoBki104j08Iso4JKBajywqxRWXlIteN/kF8QSCqW61de3iG5EsI+79bSRX8itS+G7D5yr6ffDErh0jEi+qSPcazNbaCJTfGCjkjz5I9Go3bFukzUc/1ahXK5Fa+p1w752hV3P9D03CemsNBBjh3J0OE97p1bAvogcdDrqkvmFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ZJj/XXtD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZJj/XXtD" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1A2C4C2BCFC; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1789413686; bh=QmfEvOE4SfAXS/MeusYKjadXdFtLLVJQBW79Ocyb2sE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZJj/XXtD4/uyycZPEeGBA0Fs06w5E+6metK7nGUXuskkkTRfh+lvZ/uhbvB/yciGf 4+FOR66Q3Zcxg083BRibZkFgXnhIwi3GVfm5tiPJnjwvXpbidQLczAMmYUksECyAT3 apyhdqHVVPZOpQuvoArLt+FlpQAY1p7xprmwfg18= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06E0DC88E7F; Mon, 14 Sep 2026 19:21:26 +0000 (UTC) From: Richard Leitner Date: Mon, 14 Sep 2026 21:21:07 +0200 Subject: [PATCH 10/10] media: i2c: ov9282: clamp flash_duration default to its maximum Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260914-ov9282-fixes-v1-10-f520af59df1b@linux.dev> References: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> In-Reply-To: <20260914-ov9282-fixes-v1-0-f520af59df1b@linux.dev> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab , Martina Krasteva , "Paul J. Murphy" , Daniele Alessandrelli , Hans Verkuil Cc: Mauro Carvalho Chehab , Gyula Kelemen , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1789413683; l=1566; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=QmfEvOE4SfAXS/MeusYKjadXdFtLLVJQBW79Ocyb2sE=; b=k0eF9Jh8G8G7xgYuL6nj8uXj+T+DlDKz8Z/VilI9haV6d1DhZrUbfoOrhsfDK4b3YpJWcHh6N ur71VONOvRHCn2x7V5wUAO0m9fxwWcxK5b/FHeB+i9vSW0CySkG68Sy X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Currently the OV9282_STROBE_FRAME_SPAN_DEFAULT is always passed as default to the flash_duration v4l2 control, where the maximum is dynamically changed. This may lead to situations where the default is above the maximum. Fix this by setting the maximum value as default when OV9282_STROBE_FRAME_SPAN_DEFAULT is above the maximum value. Signed-off-by: Richard Leitner Reviewed-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index be38ecfad8c82..1c5bed85781ce 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -556,12 +557,15 @@ static int ov9282_update_ctrl_range_flash_duration(st= ruct ov9282 *ov9282) u32 exposure_us =3D ov9282_exposure_to_us(ov9282, ov9282->exp_ctrl->val); u32 fd_max =3D ov9282_us_to_flash_duration(ov9282, exposure_us); u32 fd_max_us =3D ov9282_flash_duration_to_us(ov9282, fd_max); + u32 fd_default; =20 if (fd_max_us < exposure_us) fd_max_us =3D ov9282_flash_duration_to_us(ov9282, fd_max + 1); =20 + fd_default =3D min_t(u32, OV9282_STROBE_FRAME_SPAN_DEFAULT, fd_max_us); + return __v4l2_ctrl_modify_range(ov9282->flash_duration, 0, fd_max_us, - 1, OV9282_STROBE_FRAME_SPAN_DEFAULT); + 1, fd_default); } =20 /** --=20 2.53.0