Re: [PATCH 11/13] media: i2c: os05b10: Update active format before adjusting framing controls

From: Tarang Raval

Date: Tue Mar 24 2026 - 12:41:25 EST


 
Hi Sakari,

> os05b10_set_pad_format() calls os05b10_set_framing_limits() before updating
> the ACTIVE format. As a result, the VBLANK control handler uses the old
> height when recalculating exposure limits, causing -ERANGE when switching
> to a larger resolution.
>
> Update the ACTIVE format before adjusting framing controls so control
> callbacks use the correct dimensions.
>
> Signed-off-by: Tarang Raval <tarang.raval@xxxxxxxxxxxxxxxxx>
> ---
>  drivers/media/i2c/os05b10.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 4601e33b7e8f..476dbcb49351 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -902,14 +902,14 @@ static int os05b10_set_pad_format(struct v4l2_subdev *sd,
>  
>          format = v4l2_subdev_state_get_format(sd_state, 0);
>  
> +       *format = fmt->format;
> +

This is the final analysis without this patch.

Please check the logs in the attached file.

When switching the resolution from 1280x720 to 2592x1944, the logs show that
while configuring the 1280 mode from the 2592 mode, the maximum exposure value
is calculated as 2219 (fmt->height + ctrl->val - exposure margin).

However, after switching to the 2592 mode, the maximum exposure value is 774.

>From both cases, it is evident that fmt->height is being calculated incorrectly
It is still using the previous height instead of updating to the new resolution.

Please share your thoughts. Am I heading in the right direction?

Best Regards,
Tarang

######################## 2592x1944 --> 1280x720 ########################

debix@imx8mp-debix:~$
->'csis-32e40000.csi':0[1]"-ctl --device /dev/media0 --links "'os05b10 1-0036':0
r:none ycbcr:601 quantization:full-range]"
media-ctl -v -d /dev/media0 -V "'csis-32e40000.csi':1 [fmt:SBGGR12_1X12/1280x720 field:none colorspace:rec709 xfer:none ycbcr:601 quantization:full-range]"
media-ctl -d /dev/media0 -V '"rkisp1_isp":0 [crop:(0,0)/1280x720]'
media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [crop:(0,0)/1280x720]'
media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [fmt:YUYV8_2X8/1280x720]'
media-ctl -d /dev/media0 -V '"rkisp1_resizer_mainpath":0 [crop:(0,0)/1280x720]'debix@imx8mp-debix:~$ media-ctl -v -d /dev/media0 -V "'os05b10 1-0036':0 [fmt:SBGGR12_1X12/12"
Opening media device /dev/media0
Enumerating entities
l[ 146.666065] TDEBUG max: 2219, exp: 1944
ooking up device: 81:3
looking up device: 81:4
looking up device: 81:0
looking up device: 81:1
looking up device: 81:2
looking up device: 81:5
looking up device: 81:6
Found 7 entities
Enumerating pads and links
Setting up format SBGGR12_1X12 1280x720 on pad os05b10 1-0036/0/0
Format set: SBGGR12_1X12 1280x720
Setting up format SBGGR12_1X12 1280x720 on pad csis-32e40000.csi/0/0
Format set: SBGGR12_1X12 1280x720
debix@imx8mp-debix:~$ media-ctl -v -d /dev/media0 -V "'csis-32e40000.csi':1 [fmt:SBGGR12_1X12/1280x720 field:none colorspace:rec709 xfer:none ycbcr:601 quantization:full-ra"
Opening media device /dev/media0
Enumerating entities
looking up device: 81:3
looking up device: 81:4
looking up device: 81:0
looking up device: 81:1
looking up device: 81:2
looking up device: 81:5
looking up device: 81:6
Found 7 entities
Enumerating pads and links
Setting up format SBGGR12_1X12 1280x720 on pad csis-32e40000.csi/1/0
Format set: SBGGR12_1X12 1280x720
Setting up format SBGGR12_1X12 1280x720 on pad rkisp1_isp/0/0
Format set: SBGGR12_1X12 1280x720
debix@imx8mp-debix:~$ media-ctl -d /dev/media0 -V '"rkisp1_isp":0 [crop:(0,0)/1280x720]'
debix@imx8mp-debix:~$ media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [crop:(0,0)/1280x720]'
debix@imx8mp-debix:~$ media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [fmt:YUYV8_2X8/1280x720]'
debix@imx8mp-debix:~$ media-ctl -d /dev/media0 -V '"rkisp1_resizer_mainpath":0 [crop:(0,0)/1280x720]'
debix@imx8mp-debix:~$
debix@imx8mp-debix:~$
debix@imx8mp-debix:~$
debix@imx8mp-debix:~$


######################## 1280x720 --> 2592x1944 ########################

debix@imx8mp-debix:~$
->'csis-32e40000.csi':0[1]"-ctl --device /dev/media0 --links "'os05b10 1-0036':0
:none colorspace:raw xfer:none ycbcr:601 quantization:full-range]"
media-ctl -v -d /dev/media0 -V "'csis-32e40000.csi':1 [fmt:SBGGR10_1X10/2592x1944 field:none colorspace:raw xfer:none ycbcr:601 quantization:full-range]"
media-ctl -d /dev/media0 -V '"rkisp1_isp":0 [crop:(0,0)/2592x1944]'
media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [crop:(0,0)/2592x1944]'
media-ctl -d /dev/media0 -V '"rkisp1_isp":2 [fmt:YUYV8_2X8/2592x1944]'
media-ctl -d /dev/media0 -V '"rkisp1_resizer_mainpath":0 [crop:(0,0)/2592x1944]'debix@imx8mp-debix:~$ media-ctl -v -d /dev/media0 -V "'os05b10 1-0036':0 [fmt:SBGGR10_1X10/2"
[ 172.714562] TDEBUG max: 774, exp: 970

Enumerating entities
looking up[ 172.714590] TDEBUG vblank: 62, vblank_max: 30823
device: 81:3
looking up device: 81:4
looking up device: 81:0
looking up device: 81:1
looking up device: 81:2
looking up device: 81:5
looking up device: 81:6
Found 7 entities
Enumerating pads and links
Setting up format SBGGR10_1X10 2592x1944 on pad os05b10 1-0036/0/0
Unable to set format: Numerical result out of range (-34)
Unable to setup formats: Numerical result out of range (34)