Patch "media: i2c: Fix imx412 exposure control" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    media: i2c: Fix imx412 exposure control

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     media-i2c-fix-imx412-exposure-control.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0b45be38a913ed4f57e74889b9b0ab54239caaa9
Author: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
Date:   Thu May 9 13:53:07 2024 +0100

    media: i2c: Fix imx412 exposure control
    
    [ Upstream commit a1956bf53a2774014ee1768b484af2c38c633a25 ]
    
    Currently we have the following algorithm to calculate what value should be
    written to the exposure control of imx412.
    
    lpfr = imx412->vblank + imx412->cur_mode->height;
    shutter = lpfr - exposure;
    
    The 'shutter' value is given to IMX412_REG_EXPOSURE_CIT however, the above
    algorithm will result in the value given to IMX412_REG_EXPOSURE_CIT
    decreasing as the requested exposure value from user-space goes up.
    
    e.g.
    [ 2255.713989] imx412 20-001a: Received exp 1608, analog gain 0
    [ 2255.714002] imx412 20-001a: Set exp 1608, analog gain 0, shutter 1938, lpfr 3546
    [ 2256.302770] imx412 20-001a: Received exp 2586, analog gain 100
    [ 2256.302800] imx412 20-001a: Set exp 2586, analog gain 100, shutter 960, lpfr 3546
    [ 2256.753755] imx412 20-001a: Received exp 3524, analog gain 110
    [ 2256.753772] imx412 20-001a: Set exp 3524, analog gain 110, shutter 22, lpfr 3546
    
    This behaviour results in the image having less exposure as the requested
    exposure value from user-space increases.
    
    Other sensor drivers such as ov5675, imx218, hid556 and others take the
    requested exposure value and use the value directly.
    
    Take the example of the above cited sensor drivers and directly apply the
    requested exposure value from user-space. The 'lpfr' variable still
    functions as before but the 'shutter' variable can be dispensed with as a
    result.
    
    Once done a similar run of the test application requesting higher exposure
    looks like this, with 'exp' written directly to the sensor.
    
    [  133.207884] imx412 20-001a: Received exp 1608, analog gain 0
    [  133.207899] imx412 20-001a: Set exp 1608, analog gain 0, lpfr 3546
    [  133.905309] imx412 20-001a: Received exp 2844, analog gain 100
    [  133.905344] imx412 20-001a: Set exp 2844, analog gain 100, lpfr 3546
    [  134.241705] imx412 20-001a: Received exp 3524, analog gain 110
    [  134.241775] imx412 20-001a: Set exp 3524, analog gain 110, lpfr 3546
    
    The result is then setting the sensor exposure to lower values results in
    darker, less exposure images and vice versa with higher exposure values.
    
    Fixes: 9214e86c0cc1 ("media: i2c: Add imx412 camera sensor driver")
    Tested-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx> # qrb5165-rb5/imx577
    Reviewed-by: Jacopo Mondi <jacopo.mondi@xxxxxxxxxxxxxxxx>
    Reviewed-by: Gjorgji Rosikopulos <quic_grosikop@xxxxxxxxxxx>
    Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
    Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c
index c7e862ae4040f..8597f98a8dcf8 100644
--- a/drivers/media/i2c/imx412.c
+++ b/drivers/media/i2c/imx412.c
@@ -544,14 +544,13 @@ static int imx412_update_controls(struct imx412 *imx412,
  */
 static int imx412_update_exp_gain(struct imx412 *imx412, u32 exposure, u32 gain)
 {
-	u32 lpfr, shutter;
+	u32 lpfr;
 	int ret;
 
 	lpfr = imx412->vblank + imx412->cur_mode->height;
-	shutter = lpfr - exposure;
 
-	dev_dbg(imx412->dev, "Set exp %u, analog gain %u, shutter %u, lpfr %u",
-		exposure, gain, shutter, lpfr);
+	dev_dbg(imx412->dev, "Set exp %u, analog gain %u, lpfr %u",
+		exposure, gain, lpfr);
 
 	ret = imx412_write_reg(imx412, IMX412_REG_HOLD, 1, 1);
 	if (ret)
@@ -561,7 +560,7 @@ static int imx412_update_exp_gain(struct imx412 *imx412, u32 exposure, u32 gain)
 	if (ret)
 		goto error_release_group_hold;
 
-	ret = imx412_write_reg(imx412, IMX412_REG_EXPOSURE_CIT, 2, shutter);
+	ret = imx412_write_reg(imx412, IMX412_REG_EXPOSURE_CIT, 2, exposure);
 	if (ret)
 		goto error_release_group_hold;
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux