diff mbox series

[v1] media: imx-jpeg: use NV12M to represent non contiguous NV12

Message ID 20211224030241.4624-1-ming.qian@nxp.com
State Accepted
Commit 784a1883cff07e7510a81ad3041d6ec443d51944
Headers show
Series [v1] media: imx-jpeg: use NV12M to represent non contiguous NV12 | expand

Commit Message

Ming Qian Dec. 24, 2021, 3:02 a.m. UTC
V4L2_PIX_FMT_NV12 requires num_planes equals to 1,
V4L2_PIX_FMT_NV12M requires num_planes equals to 2.
and mxc-jpeg supports 2 planes for nv12,
so we should use 4L2_PIX_FMT_NV12M instead of V4L2_PIX_FMT_NV12,
otherwise it will confuses gstreamer and prevent encoding and decoding.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
---
 drivers/media/platform/imx-jpeg/mxc-jpeg.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)


base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c

Comments

Mirela Rabulea OSS Jan. 12, 2022, 2:09 a.m. UTC | #1
Hi Ming,

On 24.12.2021 05:02, Ming Qian wrote:
> V4L2_PIX_FMT_NV12 requires num_planes equals to 1,
> V4L2_PIX_FMT_NV12M requires num_planes equals to 2.
> and mxc-jpeg supports 2 planes for nv12,
> so we should use 4L2_PIX_FMT_NV12M instead of V4L2_PIX_FMT_NV12,
> otherwise it will confuses gstreamer and prevent encoding and decoding.

I missed some typos here:
and mxc-jpeg supports => Since mxc-jpeg supports
4L2_PIX_FMT_NV12M => V4L2_PIX_FMT_NV12M
will confuses => will confuse

For the patch contents: Reviewed-by: Mirela Rabulea 
<mirela.rabulea@oss.nxp.com>

Regards,
Mirela

> 
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> Signed-off-by: Shijie Qin <shijie.qin@nxp.com>
> Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
> Reviewed-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
> ---
>   drivers/media/platform/imx-jpeg/mxc-jpeg.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> index 4ca96cf9def7..7c0366f5f801 100644
> --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> @@ -96,7 +96,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = {
>   	},
>   	{
>   		.name		= "YUV420", /* 1st plane = Y, 2nd plane = UV */
> -		.fourcc		= V4L2_PIX_FMT_NV12,
> +		.fourcc		= V4L2_PIX_FMT_NV12M,
>   		.subsampling	= V4L2_JPEG_CHROMA_SUBSAMPLING_420,
>   		.nc		= 3,
>   		.depth		= 12, /* 6 bytes (4Y + UV) for 4 pixels */
> @@ -404,7 +404,7 @@ static enum mxc_jpeg_image_format mxc_jpeg_fourcc_to_imgfmt(u32 fourcc)
>   		return MXC_JPEG_GRAY;
>   	case V4L2_PIX_FMT_YUYV:
>   		return MXC_JPEG_YUV422;
> -	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV12M:
>   		return MXC_JPEG_YUV420;
>   	case V4L2_PIX_FMT_YUV24:
>   		return MXC_JPEG_YUV444;
> @@ -673,7 +673,7 @@ static int mxc_jpeg_fixup_sof(struct mxc_jpeg_sof *sof,
>   	_bswap16(&sof->width);
>   
>   	switch (fourcc) {
> -	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV12M:
>   		sof->components_no = 3;
>   		sof->comp[0].v = 0x2;
>   		sof->comp[0].h = 0x2;
> @@ -709,7 +709,7 @@ static int mxc_jpeg_fixup_sos(struct mxc_jpeg_sos *sos,
>   	u8 *sof_u8 = (u8 *)sos;
>   
>   	switch (fourcc) {
> -	case V4L2_PIX_FMT_NV12:
> +	case V4L2_PIX_FMT_NV12M:
>   		sos->components_no = 3;
>   		break;
>   	case V4L2_PIX_FMT_YUYV:
> @@ -1183,7 +1183,7 @@ static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q,
>   		/* bytesperline unused for compressed formats */
>   		q->bytesperline[0] = 0;
>   		q->bytesperline[1] = 0;
> -	} else if (q->fmt->fourcc == V4L2_PIX_FMT_NV12) {
> +	} else if (q->fmt->fourcc == V4L2_PIX_FMT_NV12M) {
>   		/* When the image format is planar the bytesperline value
>   		 * applies to the first plane and is divided by the same factor
>   		 * as the width field for the other planes
> @@ -1215,7 +1215,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q)
>   	} else {
>   		q->sizeimage[0] = q->bytesperline[0] * q->h;
>   		q->sizeimage[1] = 0;
> -		if (q->fmt->fourcc == V4L2_PIX_FMT_NV12)
> +		if (q->fmt->fourcc == V4L2_PIX_FMT_NV12M)
>   			q->sizeimage[1] = q->sizeimage[0] / 2;
>   	}
>   }
> 
> base-commit: 68b9bcc8a534cd11fe55f8bc82f948aae7d81b3c
>
diff mbox series

Patch

diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
index 4ca96cf9def7..7c0366f5f801 100644
--- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
@@ -96,7 +96,7 @@  static const struct mxc_jpeg_fmt mxc_formats[] = {
 	},
 	{
 		.name		= "YUV420", /* 1st plane = Y, 2nd plane = UV */
-		.fourcc		= V4L2_PIX_FMT_NV12,
+		.fourcc		= V4L2_PIX_FMT_NV12M,
 		.subsampling	= V4L2_JPEG_CHROMA_SUBSAMPLING_420,
 		.nc		= 3,
 		.depth		= 12, /* 6 bytes (4Y + UV) for 4 pixels */
@@ -404,7 +404,7 @@  static enum mxc_jpeg_image_format mxc_jpeg_fourcc_to_imgfmt(u32 fourcc)
 		return MXC_JPEG_GRAY;
 	case V4L2_PIX_FMT_YUYV:
 		return MXC_JPEG_YUV422;
-	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV12M:
 		return MXC_JPEG_YUV420;
 	case V4L2_PIX_FMT_YUV24:
 		return MXC_JPEG_YUV444;
@@ -673,7 +673,7 @@  static int mxc_jpeg_fixup_sof(struct mxc_jpeg_sof *sof,
 	_bswap16(&sof->width);
 
 	switch (fourcc) {
-	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV12M:
 		sof->components_no = 3;
 		sof->comp[0].v = 0x2;
 		sof->comp[0].h = 0x2;
@@ -709,7 +709,7 @@  static int mxc_jpeg_fixup_sos(struct mxc_jpeg_sos *sos,
 	u8 *sof_u8 = (u8 *)sos;
 
 	switch (fourcc) {
-	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV12M:
 		sos->components_no = 3;
 		break;
 	case V4L2_PIX_FMT_YUYV:
@@ -1183,7 +1183,7 @@  static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q,
 		/* bytesperline unused for compressed formats */
 		q->bytesperline[0] = 0;
 		q->bytesperline[1] = 0;
-	} else if (q->fmt->fourcc == V4L2_PIX_FMT_NV12) {
+	} else if (q->fmt->fourcc == V4L2_PIX_FMT_NV12M) {
 		/* When the image format is planar the bytesperline value
 		 * applies to the first plane and is divided by the same factor
 		 * as the width field for the other planes
@@ -1215,7 +1215,7 @@  static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q)
 	} else {
 		q->sizeimage[0] = q->bytesperline[0] * q->h;
 		q->sizeimage[1] = 0;
-		if (q->fmt->fourcc == V4L2_PIX_FMT_NV12)
+		if (q->fmt->fourcc == V4L2_PIX_FMT_NV12M)
 			q->sizeimage[1] = q->sizeimage[0] / 2;
 	}
 }