[PATCH v1 1/3] media: ti: cal: Add support for 1X16 mbus formats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For legacy reasons the CAL driver uses 2X8 mbus formats for the CSI-2
link (e.g. MEDIA_BUS_FMT_YUYV8_2X8). 1X16 formats are more correct and
used by many drivers, so add 1X16 support to CAL.

We keep the 2X8 formats for backward compatibility.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx>
---
 drivers/media/platform/ti/cal/cal-video.c | 16 ++++++++++++++-
 drivers/media/platform/ti/cal/cal.c       | 25 +++++++++++++++++++++++
 drivers/media/platform/ti/cal/cal.h       |  1 +
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
index 4eade409d5d3..87db8761d94d 100644
--- a/drivers/media/platform/ti/cal/cal-video.c
+++ b/drivers/media/platform/ti/cal/cal-video.c
@@ -446,6 +446,15 @@ static int cal_mc_enum_fmt_vid_cap(struct file *file, void  *priv,
 		if (f->mbus_code && cal_formats[i].code != f->mbus_code)
 			continue;
 
+		/*
+		 * Skip legacy formats so that we don't return duplicate fourccs,
+		 * except in the case that the user explicitly asked for an
+		 * mbus_code which matches this legacy format.
+		 */
+		if (cal_formats[i].legacy &&
+		    (!f->mbus_code || cal_formats[i].code != f->mbus_code))
+			continue;
+
 		if (idx == f->index) {
 			f->pixelformat = cal_formats[i].fourcc;
 			f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -683,6 +692,7 @@ static void cal_release_buffers(struct cal_ctx *ctx,
 
 static int cal_video_check_format(struct cal_ctx *ctx)
 {
+	const struct cal_format_info *rx_fmtinfo;
 	const struct v4l2_mbus_framefmt *format;
 	struct media_pad *remote_pad;
 
@@ -692,7 +702,11 @@ static int cal_video_check_format(struct cal_ctx *ctx)
 
 	format = &ctx->phy->formats[remote_pad->index];
 
-	if (ctx->fmtinfo->code != format->code ||
+	rx_fmtinfo = cal_format_by_code(format->code);
+	if (!rx_fmtinfo)
+		return -EINVAL;
+
+	if (ctx->fmtinfo->fourcc != rx_fmtinfo->fourcc ||
 	    ctx->v_fmt.fmt.pix.height != format->height ||
 	    ctx->v_fmt.fmt.pix.width != format->width ||
 	    ctx->v_fmt.fmt.pix.field != format->field)
diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c
index 1236215ec70e..053bf1030af0 100644
--- a/drivers/media/platform/ti/cal/cal.c
+++ b/drivers/media/platform/ti/cal/cal.c
@@ -59,22 +59,47 @@ MODULE_PARM_DESC(mc_api, "activates the MC API");
  */
 
 const struct cal_format_info cal_formats[] = {
+	/*
+	 * 2X8 entries are legacy codes. All new drivers should use 1X16 modes.
+	 * The 2X8 modes must be before 1X16 in this list so that the driver
+	 * behavior for non-MC mode doesn't change.
+	 */
 	{
 		.fourcc		= V4L2_PIX_FMT_YUYV,
 		.code		= MEDIA_BUS_FMT_YUYV8_2X8,
 		.bpp		= 16,
+		.legacy		= true,
 	}, {
 		.fourcc		= V4L2_PIX_FMT_UYVY,
 		.code		= MEDIA_BUS_FMT_UYVY8_2X8,
 		.bpp		= 16,
+		.legacy		= true,
 	}, {
 		.fourcc		= V4L2_PIX_FMT_YVYU,
 		.code		= MEDIA_BUS_FMT_YVYU8_2X8,
 		.bpp		= 16,
+		.legacy		= true,
 	}, {
 		.fourcc		= V4L2_PIX_FMT_VYUY,
 		.code		= MEDIA_BUS_FMT_VYUY8_2X8,
 		.bpp		= 16,
+		.legacy		= true,
+	}, {
+		.fourcc		= V4L2_PIX_FMT_YUYV,
+		.code		= MEDIA_BUS_FMT_YUYV8_1X16,
+		.bpp		= 16,
+	}, {
+		.fourcc		= V4L2_PIX_FMT_UYVY,
+		.code		= MEDIA_BUS_FMT_UYVY8_1X16,
+		.bpp		= 16,
+	}, {
+		.fourcc		= V4L2_PIX_FMT_YVYU,
+		.code		= MEDIA_BUS_FMT_YVYU8_1X16,
+		.bpp		= 16,
+	}, {
+		.fourcc		= V4L2_PIX_FMT_VYUY,
+		.code		= MEDIA_BUS_FMT_VYUY8_1X16,
+		.bpp		= 16,
 	}, {
 		.fourcc		= V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
 		.code		= MEDIA_BUS_FMT_RGB565_2X8_LE,
diff --git a/drivers/media/platform/ti/cal/cal.h b/drivers/media/platform/ti/cal/cal.h
index de73d6d21b6f..44ecae8a273a 100644
--- a/drivers/media/platform/ti/cal/cal.h
+++ b/drivers/media/platform/ti/cal/cal.h
@@ -89,6 +89,7 @@ struct cal_format_info {
 	/* Bits per pixel */
 	u8	bpp;
 	bool	meta;
+	bool	legacy;
 };
 
 /* buffer for one video frame */
-- 
2.34.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux