diff mbox series

[v1,3/6] media: imx-pxp: Pass pixel format value to find_format()

Message ID 20230106133227.13685-4-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series media: imx-pxp: Miscellaneous enhancements | expand

Commit Message

Laurent Pinchart Jan. 6, 2023, 1:32 p.m. UTC
The find_format() function looks up format information for a given pixel
format. It takes a v4l2_format pointer, but only uses the contained
pixel format value. To prepare it for being used by callers that don't
have v4l2_format, modify it to take the pixel format value directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/nxp/imx-pxp.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Michael Tretter Jan. 12, 2023, 1:59 p.m. UTC | #1
On Fri, 06 Jan 2023 15:32:24 +0200, Laurent Pinchart wrote:
> The find_format() function looks up format information for a given pixel
> format. It takes a v4l2_format pointer, but only uses the contained
> pixel format value. To prepare it for being used by callers that don't
> have v4l2_format, modify it to take the pixel format value directly.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

> ---
>  drivers/media/platform/nxp/imx-pxp.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
> index 132065c8b8b4..fd4c055c01eb 100644
> --- a/drivers/media/platform/nxp/imx-pxp.c
> +++ b/drivers/media/platform/nxp/imx-pxp.c
> @@ -176,14 +176,14 @@ enum {
>  	V4L2_M2M_DST = 1,
>  };
>  
> -static struct pxp_fmt *find_format(struct v4l2_format *f)
> +static struct pxp_fmt *find_format(unsigned int pixelformat)
>  {
>  	struct pxp_fmt *fmt;
>  	unsigned int k;
>  
>  	for (k = 0; k < NUM_FORMATS; k++) {
>  		fmt = &formats[k];
> -		if (fmt->fourcc == f->fmt.pix.pixelformat)
> +		if (fmt->fourcc == pixelformat)
>  			break;
>  	}
>  
> @@ -1268,10 +1268,10 @@ static int pxp_try_fmt_vid_cap(struct file *file, void *priv,
>  	struct pxp_fmt *fmt;
>  	struct pxp_ctx *ctx = file2ctx(file);
>  
> -	fmt = find_format(f);
> +	fmt = find_format(f->fmt.pix.pixelformat);
>  	if (!fmt) {
>  		f->fmt.pix.pixelformat = formats[0].fourcc;
> -		fmt = find_format(f);
> +		fmt = find_format(f->fmt.pix.pixelformat);
>  	}
>  	if (!(fmt->types & MEM2MEM_CAPTURE)) {
>  		v4l2_err(&ctx->dev->v4l2_dev,
> @@ -1296,10 +1296,10 @@ static int pxp_try_fmt_vid_out(struct file *file, void *priv,
>  	struct pxp_fmt *fmt;
>  	struct pxp_ctx *ctx = file2ctx(file);
>  
> -	fmt = find_format(f);
> +	fmt = find_format(f->fmt.pix.pixelformat);
>  	if (!fmt) {
>  		f->fmt.pix.pixelformat = formats[0].fourcc;
> -		fmt = find_format(f);
> +		fmt = find_format(f->fmt.pix.pixelformat);
>  	}
>  	if (!(fmt->types & MEM2MEM_OUTPUT)) {
>  		v4l2_err(&ctx->dev->v4l2_dev,
> @@ -1332,7 +1332,7 @@ static int pxp_s_fmt(struct pxp_ctx *ctx, struct v4l2_format *f)
>  		return -EBUSY;
>  	}
>  
> -	q_data->fmt		= find_format(f);
> +	q_data->fmt		= find_format(f->fmt.pix.pixelformat);
>  	q_data->width		= f->fmt.pix.width;
>  	q_data->height		= f->fmt.pix.height;
>  	q_data->bytesperline	= f->fmt.pix.bytesperline;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
>
diff mbox series

Patch

diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index 132065c8b8b4..fd4c055c01eb 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -176,14 +176,14 @@  enum {
 	V4L2_M2M_DST = 1,
 };
 
-static struct pxp_fmt *find_format(struct v4l2_format *f)
+static struct pxp_fmt *find_format(unsigned int pixelformat)
 {
 	struct pxp_fmt *fmt;
 	unsigned int k;
 
 	for (k = 0; k < NUM_FORMATS; k++) {
 		fmt = &formats[k];
-		if (fmt->fourcc == f->fmt.pix.pixelformat)
+		if (fmt->fourcc == pixelformat)
 			break;
 	}
 
@@ -1268,10 +1268,10 @@  static int pxp_try_fmt_vid_cap(struct file *file, void *priv,
 	struct pxp_fmt *fmt;
 	struct pxp_ctx *ctx = file2ctx(file);
 
-	fmt = find_format(f);
+	fmt = find_format(f->fmt.pix.pixelformat);
 	if (!fmt) {
 		f->fmt.pix.pixelformat = formats[0].fourcc;
-		fmt = find_format(f);
+		fmt = find_format(f->fmt.pix.pixelformat);
 	}
 	if (!(fmt->types & MEM2MEM_CAPTURE)) {
 		v4l2_err(&ctx->dev->v4l2_dev,
@@ -1296,10 +1296,10 @@  static int pxp_try_fmt_vid_out(struct file *file, void *priv,
 	struct pxp_fmt *fmt;
 	struct pxp_ctx *ctx = file2ctx(file);
 
-	fmt = find_format(f);
+	fmt = find_format(f->fmt.pix.pixelformat);
 	if (!fmt) {
 		f->fmt.pix.pixelformat = formats[0].fourcc;
-		fmt = find_format(f);
+		fmt = find_format(f->fmt.pix.pixelformat);
 	}
 	if (!(fmt->types & MEM2MEM_OUTPUT)) {
 		v4l2_err(&ctx->dev->v4l2_dev,
@@ -1332,7 +1332,7 @@  static int pxp_s_fmt(struct pxp_ctx *ctx, struct v4l2_format *f)
 		return -EBUSY;
 	}
 
-	q_data->fmt		= find_format(f);
+	q_data->fmt		= find_format(f->fmt.pix.pixelformat);
 	q_data->width		= f->fmt.pix.width;
 	q_data->height		= f->fmt.pix.height;
 	q_data->bytesperline	= f->fmt.pix.bytesperline;