[v3] media: ov5640: fix low resolution image abnormal issue

Message ID 20230612024340.313662-1-guoniu.zhou@oss.nxp.com (mailing list archive)
State Accepted
Delegated to: Sakari Ailus
Headers
Series [v3] media: ov5640: fix low resolution image abnormal issue |

Commit Message

G.N. Zhou (OSS) June 12, 2023, 2:43 a.m. UTC
  From: "Guoniu.zhou" <guoniu.zhou@nxp.com>

OV5640 will output abnormal image data when work at low resolution
(320x240, 176x144 and 160x120) after switching from high resolution,
such as 1080P, the time interval between high and low switching must
be less than 1000ms in order to OV5640 don't enter suspend state during
the time.

The reason is by 0x3824 value don't restore to initialize value when
do resolution switching. In high resolution setting array, 0x3824 is
set to 0x04, but low resolution setting array remove 0x3824 in commit
db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So
when do resolution switching from high to low, such as 1080P to 320x240,
and the time interval is less than auto suspend delay time which means
global initialize setting array will not be loaded, the output image
data are abnormal. Hence move 0x3824 from ov5640_init_setting[] table
to ov5640_setting_low_res[] table and also move 0x4407 0x460b, 0x460c
to avoid same issue.

Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
---
v2->v3:
  add "Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")" in commit log
---
 drivers/media/i2c/ov5640.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Comments

Jacopo Mondi June 12, 2023, 6:25 a.m. UTC | #1
Hello Guoniu Zhou

On Mon, Jun 12, 2023 at 10:43:40AM +0800, guoniu.zhou@oss.nxp.com wrote:
> From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
>
> OV5640 will output abnormal image data when work at low resolution
> (320x240, 176x144 and 160x120) after switching from high resolution,
> such as 1080P, the time interval between high and low switching must
> be less than 1000ms in order to OV5640 don't enter suspend state during
> the time.
>
> The reason is by 0x3824 value don't restore to initialize value when
> do resolution switching. In high resolution setting array, 0x3824 is
> set to 0x04, but low resolution setting array remove 0x3824 in commit
> db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So
> when do resolution switching from high to low, such as 1080P to 320x240,
> and the time interval is less than auto suspend delay time which means
> global initialize setting array will not be loaded, the output image
> data are abnormal. Hence move 0x3824 from ov5640_init_setting[] table
> to ov5640_setting_low_res[] table and also move 0x4407 0x460b, 0x460c
> to avoid same issue.
>
> Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")
> Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>

Thank you, it was probably not necessary to send a new version as the
tag could be added by maintainers when collecting the patch (I'm
speaking for Sakari here :)

Please don't forget to add the tags you receive when you send a new
version

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
> v2->v3:
>   add "Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")" in commit log
> ---
>  drivers/media/i2c/ov5640.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index 1536649b9e90..1bc4d72a906e 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -568,9 +568,7 @@ static const struct reg_value ov5640_init_setting[] = {
>  	{0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0},
>  	{0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0},
>  	{0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0},
> -	{0x501f, 0x00, 0, 0}, {0x4407, 0x04, 0, 0},
> -	{0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
> -	{0x4837, 0x0a, 0, 0}, {0x3824, 0x02, 0, 0},
> +	{0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0},
>  	{0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0},
>  	{0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0},
>  	{0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0},
> @@ -634,7 +632,8 @@ static const struct reg_value ov5640_setting_low_res[] = {
>  	{0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0},
>  	{0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0},
>  	{0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0},
> -	{0x4407, 0x04, 0, 0}, {0x5001, 0xa3, 0, 0},
> +	{0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
> +	{0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0},
>  };
>
>  static const struct reg_value ov5640_setting_720P_1280_720[] = {
> --
> 2.37.1
>
  
G.N. Zhou (OSS) June 12, 2023, 8:49 a.m. UTC | #2
Got it, thanks.

> -----Original Message-----
> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Sent: 2023年6月12日 14:25
> To: G.N. Zhou (OSS) <guoniu.zhou@oss.nxp.com>
> Cc: linux-media@vger.kernel.org; jacopo.mondi@ideasonboard.com;
> sakari.ailus@linux.intel.com; mchehab@kernel.org; slongerbeam@gmail.com;
> laurent.pinchart@ideasonboard.com; jacopo@jmondi.org
> Subject: Re: [PATCH v3] media: ov5640: fix low resolution image abnormal issue
> 
> Caution: This is an external email. Please take care when clicking links or opening
> attachments. When in doubt, report the message using the 'Report this email'
> button
> 
> 
> Hello Guoniu Zhou
> 
> On Mon, Jun 12, 2023 at 10:43:40AM +0800, guoniu.zhou@oss.nxp.com wrote:
> > From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
> >
> > OV5640 will output abnormal image data when work at low resolution
> > (320x240, 176x144 and 160x120) after switching from high resolution,
> > such as 1080P, the time interval between high and low switching must
> > be less than 1000ms in order to OV5640 don't enter suspend state
> > during the time.
> >
> > The reason is by 0x3824 value don't restore to initialize value when
> > do resolution switching. In high resolution setting array, 0x3824 is
> > set to 0x04, but low resolution setting array remove 0x3824 in commit
> > db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So
> > when do resolution switching from high to low, such as 1080P to
> > 320x240, and the time interval is less than auto suspend delay time
> > which means global initialize setting array will not be loaded, the
> > output image data are abnormal. Hence move 0x3824 from
> > ov5640_init_setting[] table to ov5640_setting_low_res[] table and also
> > move 0x4407 0x460b, 0x460c to avoid same issue.
> >
> > Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")
> > Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
> 
> Thank you, it was probably not necessary to send a new version as the tag could
> be added by maintainers when collecting the patch (I'm speaking for Sakari
> here :)
> 
> Please don't forget to add the tags you receive when you send a new version
> 
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> 
> Thanks
>   j
> 
> > ---
> > v2->v3:
> >   add "Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode
> > settings")" in commit log
> > ---
> >  drivers/media/i2c/ov5640.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> > index 1536649b9e90..1bc4d72a906e 100644
> > --- a/drivers/media/i2c/ov5640.c
> > +++ b/drivers/media/i2c/ov5640.c
> > @@ -568,9 +568,7 @@ static const struct reg_value ov5640_init_setting[] = {
> >       {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0},
> >       {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0},
> >       {0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0},
> > -     {0x501f, 0x00, 0, 0}, {0x4407, 0x04, 0, 0},
> > -     {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
> > -     {0x4837, 0x0a, 0, 0}, {0x3824, 0x02, 0, 0},
> > +     {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0,
> > + 0},
> >       {0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0},
> >       {0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0},
> >       {0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0,
> > 0}, @@ -634,7 +632,8 @@ static const struct reg_value
> ov5640_setting_low_res[] = {
> >       {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0},
> >       {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0},
> >       {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0},
> > -     {0x4407, 0x04, 0, 0}, {0x5001, 0xa3, 0, 0},
> > +     {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
> > +     {0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0},
> >  };
> >
> >  static const struct reg_value ov5640_setting_720P_1280_720[] = {
> > --
> > 2.37.1
> >
  

Patch

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 1536649b9e90..1bc4d72a906e 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -568,9 +568,7 @@  static const struct reg_value ov5640_init_setting[] = {
 	{0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0},
 	{0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0},
 	{0x302e, 0x08, 0, 0}, {0x4300, 0x3f, 0, 0},
-	{0x501f, 0x00, 0, 0}, {0x4407, 0x04, 0, 0},
-	{0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
-	{0x4837, 0x0a, 0, 0}, {0x3824, 0x02, 0, 0},
+	{0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x4837, 0x0a, 0, 0},
 	{0x5000, 0xa7, 0, 0}, {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0},
 	{0x5181, 0xf2, 0, 0}, {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0},
 	{0x5184, 0x25, 0, 0}, {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0},
@@ -634,7 +632,8 @@  static const struct reg_value ov5640_setting_low_res[] = {
 	{0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0},
 	{0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0},
 	{0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0},
-	{0x4407, 0x04, 0, 0}, {0x5001, 0xa3, 0, 0},
+	{0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0},
+	{0x3824, 0x02, 0, 0}, {0x5001, 0xa3, 0, 0},
 };
 
 static const struct reg_value ov5640_setting_720P_1280_720[] = {