[libcamera-devel,1/2] media: imx258: Rectify mismatch of VTS value
diff mbox series

Message ID 20210723112233.1361319-2-umang.jain@ideasonboard.com
State Not Applicable
Headers show
Series
  • IMX258 driver fixes
Related show

Commit Message

Umang Jain July 23, 2021, 11:22 a.m. UTC
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

The frame_length_lines (0x0340) registers are hard-coded as follows:

- 4208x3118
  frame_length_lines = 0x0c50

- 2104x1560
  frame_length_lines = 0x0638

- 1048x780
  frame_length_lines = 0x034c

The driver exposes the V4L2_CID_VBLANK control in read-only mode and
sets its value to vts_def - height, where vts_def is a mode-dependent
value coming from the supported_modes array. It is set using one of
the following macros defined in the driver:

  #define IMX258_VTS_30FPS                0x0c98
  #define IMX258_VTS_30FPS_2K             0x0638
  #define IMX258_VTS_30FPS_VGA            0x034c

There's a clear mismatch in the value for the full resolution mode i.e.
IMX258_VTS_30FPS. Fix it by rectifying the macro with the value set for
the frame_length_lines register as stated above.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 drivers/media/i2c/imx258.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart July 23, 2021, 11:50 a.m. UTC | #1
Hi Umang,

Thank you for the patch.

(Expanding the CC list)

On Fri, Jul 23, 2021 at 04:52:32PM +0530, Umang Jain wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> The frame_length_lines (0x0340) registers are hard-coded as follows:
> 
> - 4208x3118
>   frame_length_lines = 0x0c50
> 
> - 2104x1560
>   frame_length_lines = 0x0638
> 
> - 1048x780
>   frame_length_lines = 0x034c
> 
> The driver exposes the V4L2_CID_VBLANK control in read-only mode and
> sets its value to vts_def - height, where vts_def is a mode-dependent
> value coming from the supported_modes array. It is set using one of
> the following macros defined in the driver:
> 
>   #define IMX258_VTS_30FPS                0x0c98
>   #define IMX258_VTS_30FPS_2K             0x0638
>   #define IMX258_VTS_30FPS_VGA            0x034c
> 
> There's a clear mismatch in the value for the full resolution mode i.e.
> IMX258_VTS_30FPS. Fix it by rectifying the macro with the value set for
> the frame_length_lines register as stated above.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/i2c/imx258.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
> index 7ab9e5f9f267..4e695096e5d0 100644
> --- a/drivers/media/i2c/imx258.c
> +++ b/drivers/media/i2c/imx258.c
> @@ -23,7 +23,7 @@
>  #define IMX258_CHIP_ID			0x0258
>  
>  /* V_TIMING internal */
> -#define IMX258_VTS_30FPS		0x0c98
> +#define IMX258_VTS_30FPS		0x0c50
>  #define IMX258_VTS_30FPS_2K		0x0638
>  #define IMX258_VTS_30FPS_VGA		0x034c
>  #define IMX258_VTS_MAX			0xffff
Bingbu Cao July 26, 2021, 2:20 a.m. UTC | #2
Umang and Laurent,

I just checked the spec, 0xc98 should be the initial value not for 4208x3118, the patch
looks good to me though I am not working on that anymore.

Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>

On 7/23/21 7:50 PM, Laurent Pinchart wrote:
> Hi Umang,
> 
> Thank you for the patch.
> 
> (Expanding the CC list)
> 
> On Fri, Jul 23, 2021 at 04:52:32PM +0530, Umang Jain wrote:
>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>
>> The frame_length_lines (0x0340) registers are hard-coded as follows:
>>
>> - 4208x3118
>>   frame_length_lines = 0x0c50
>>
>> - 2104x1560
>>   frame_length_lines = 0x0638
>>
>> - 1048x780
>>   frame_length_lines = 0x034c
>>
>> The driver exposes the V4L2_CID_VBLANK control in read-only mode and
>> sets its value to vts_def - height, where vts_def is a mode-dependent
>> value coming from the supported_modes array. It is set using one of
>> the following macros defined in the driver:
>>
>>   #define IMX258_VTS_30FPS                0x0c98
>>   #define IMX258_VTS_30FPS_2K             0x0638
>>   #define IMX258_VTS_30FPS_VGA            0x034c
>>
>> There's a clear mismatch in the value for the full resolution mode i.e.
>> IMX258_VTS_30FPS. Fix it by rectifying the macro with the value set for
>> the frame_length_lines register as stated above.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> ---
>>  drivers/media/i2c/imx258.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
>> index 7ab9e5f9f267..4e695096e5d0 100644
>> --- a/drivers/media/i2c/imx258.c
>> +++ b/drivers/media/i2c/imx258.c
>> @@ -23,7 +23,7 @@
>>  #define IMX258_CHIP_ID			0x0258
>>  
>>  /* V_TIMING internal */
>> -#define IMX258_VTS_30FPS		0x0c98
>> +#define IMX258_VTS_30FPS		0x0c50
>>  #define IMX258_VTS_30FPS_2K		0x0638
>>  #define IMX258_VTS_30FPS_VGA		0x034c
>>  #define IMX258_VTS_MAX			0xffff
>

Patch
diff mbox series

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index 7ab9e5f9f267..4e695096e5d0 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -23,7 +23,7 @@ 
 #define IMX258_CHIP_ID			0x0258
 
 /* V_TIMING internal */
-#define IMX258_VTS_30FPS		0x0c98
+#define IMX258_VTS_30FPS		0x0c50
 #define IMX258_VTS_30FPS_2K		0x0638
 #define IMX258_VTS_30FPS_VGA		0x034c
 #define IMX258_VTS_MAX			0xffff