diff mbox

[16/16] rcar-vin: fix bug in pixelformat selection

Message ID 20170314185957.25253-17-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State New, archived
Headers show

Commit Message

Niklas Söderlund March 14, 2017, 6:59 p.m. UTC
If the requested pixelformat is not supported only revert to the current
pixelformat, do not revert the entire format. Also if the pixelformat
needs to be reverted the pixel information needs to be fetched once
more.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/platform/rcar-vin/rcar-v4l2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart May 10, 2017, 1:39 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Tuesday 14 Mar 2017 19:59:57 Niklas Söderlund wrote:
> If the requested pixelformat is not supported only revert to the current
> pixelformat, do not revert the entire format. Also if the pixelformat
> needs to be reverted the pixel information needs to be fetched once
> more.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c index
> 956092ba6ef9bc6f..27b7733e96afe3e9 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -226,9 +226,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
>  	if (!info) {
>  		vin_dbg(vin, "Format %x not found, keeping %x\n",
>  			pix->pixelformat, vin->format.pixelformat);
> -		*pix = vin->format;
> -		pix->width = rwidth;
> -		pix->height = rheight;
> +		pix->pixelformat = vin->format.pixelformat;

You should set a fixed default in this case to achieve a more deterministic 
behaviour. You can for instance pick the first entry of, which will also save 
you from calling rvin_format_from_pixel() as you can then replace it with 
&rvin_formats[0].

> +		info = rvin_format_from_pixel(pix->pixelformat);
>  	}
> 
>  	/* Always recalculate */
diff mbox

Patch

diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 956092ba6ef9bc6f..27b7733e96afe3e9 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -226,9 +226,8 @@  static int __rvin_try_format(struct rvin_dev *vin,
 	if (!info) {
 		vin_dbg(vin, "Format %x not found, keeping %x\n",
 			pix->pixelformat, vin->format.pixelformat);
-		*pix = vin->format;
-		pix->width = rwidth;
-		pix->height = rheight;
+		pix->pixelformat = vin->format.pixelformat;
+		info = rvin_format_from_pixel(pix->pixelformat);
 	}
 
 	/* Always recalculate */