This patch adds support for the three-plane YUV422P format with one luma plane
and two horizontally subsampled chroma planes.

Signed-off-by: Philipp Zabel <p.za...@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c    | 14 +++++++++++++-
 drivers/media/platform/coda/coda-common.c | 13 +++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index fde7775..746a615 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1591,6 +1591,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
        struct coda_q_data *q_data_dst;
        struct vb2_buffer *dst_buf;
        struct coda_timestamp *ts;
+       unsigned long payload;
        int width, height;
        int decoded_idx;
        int display_idx;
@@ -1776,7 +1777,18 @@ static void coda_finish_decode(struct coda_ctx *ctx)
                dst_buf->v4l2_buf.timecode = ts->timecode;
                dst_buf->v4l2_buf.timestamp = ts->timestamp;
 
-               vb2_set_plane_payload(dst_buf, 0, width * height * 3 / 2);
+               switch (q_data_dst->fourcc) {
+               case V4L2_PIX_FMT_YUV420:
+               case V4L2_PIX_FMT_YVU420:
+               case V4L2_PIX_FMT_NV12:
+               default:
+                       payload = width * height * 3 / 2;
+                       break;
+               case V4L2_PIX_FMT_YUV422P:
+                       payload = width * height * 2;
+                       break;
+               }
+               vb2_set_plane_payload(dst_buf, 0, payload);
 
                v4l2_m2m_buf_done(dst_buf, ctx->frame_errors[display_idx] ?
                                  VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 02d47fa..48be973 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -100,6 +100,9 @@ void coda_write_base(struct coda_ctx *ctx, struct 
coda_q_data *q_data,
                base_cb = base_y + q_data->bytesperline * q_data->height;
                base_cr = base_cb + q_data->bytesperline * q_data->height / 4;
                break;
+       case V4L2_PIX_FMT_YUV422P:
+               base_cb = base_y + q_data->bytesperline * q_data->height;
+               base_cr = base_cb + q_data->bytesperline * q_data->height / 2;
        }
 
        coda_write(ctx->dev, base_y, reg_y);
@@ -124,6 +127,10 @@ static const struct coda_fmt coda_formats[] = {
                .fourcc = V4L2_PIX_FMT_NV12,
        },
        {
+               .name = "YUV 4:2:2 Planar, YCbCr",
+               .fourcc = V4L2_PIX_FMT_YUV422P,
+       },
+       {
                .name = "H264 Encoded Stream",
                .fourcc = V4L2_PIX_FMT_H264,
        },
@@ -168,6 +175,7 @@ static bool coda_format_is_yuv(u32 fourcc)
        case V4L2_PIX_FMT_YUV420:
        case V4L2_PIX_FMT_YVU420:
        case V4L2_PIX_FMT_NV12:
+       case V4L2_PIX_FMT_YUV422P:
                return true;
        default:
                return false;
@@ -393,6 +401,11 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct 
coda_codec *codec,
                f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
                                        f->fmt.pix.height * 3 / 2;
                break;
+       case V4L2_PIX_FMT_YUV422P:
+               f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16);
+               f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
+                                       f->fmt.pix.height * 2;
+               break;
        case V4L2_PIX_FMT_H264:
        case V4L2_PIX_FMT_MPEG4:
        case V4L2_PIX_FMT_JPEG:
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to