[media] coda: add support for planar YCbCr 4:2:2 (YUV422P) format
authorPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 2 Oct 2014 17:08:26 +0000 (14:08 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Oct 2014 16:59:39 +0000 (14:59 -0200)
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.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/coda/coda-bit.c
drivers/media/platform/coda/coda-common.c

index fde777573f7becec53d8ee8f49e1a919a81ae1e8..746a6158ccd0f2b0e22303016bbcb1c2eecbe605 100644 (file)
@@ -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);
index 02d47fabae651280de3bac79b5def063905ed4b3..48be97330ee108afe1c1790ac89b3619ef67f86c 100644 (file)
@@ -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);
@@ -123,6 +126,10 @@ static const struct coda_fmt coda_formats[] = {
                .name = "YUV 4:2:0 Partial interleaved Y/CbCr",
                .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: