From patchwork Fri Dec 9 16:59:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 9468749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6E59F607D8 for ; Fri, 9 Dec 2016 16:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F85028658 for ; Fri, 9 Dec 2016 16:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5466228663; Fri, 9 Dec 2016 16:59:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59C628658 for ; Fri, 9 Dec 2016 16:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933378AbcLIQ7b (ORCPT ); Fri, 9 Dec 2016 11:59:31 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:42325 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933547AbcLIQ71 (ORCPT ); Fri, 9 Dec 2016 11:59:27 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cFOW6-0001Gd-6A; Fri, 09 Dec 2016 17:59:26 +0100 Received: from mtr by dude.hi.pengutronix.de with local (Exim 4.88) (envelope-from ) id 1cFOW5-0000M6-UC; Fri, 09 Dec 2016 17:59:25 +0100 From: Michael Tretter To: linux-media@vger.kernel.org Cc: Philipp Zabel , devicetree@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Michael Tretter Subject: [PATCH v2 7/7] [media] coda: support YUYV output if VDOA is used Date: Fri, 9 Dec 2016 17:59:03 +0100 Message-Id: <20161209165903.1293-8-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161209165903.1293-1-m.tretter@pengutronix.de> References: <20161209165903.1293-1-m.tretter@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The VDOA is able to transform the NV12 custom macroblock tiled format of the CODA to YUYV format. If and only if the VDOA is available, the driver can also provide YUYV support. While the driver is configured to produce YUYV output, the CODA must be configured to produce NV12 macroblock tiled frames and the VDOA must transform the intermediate result into the final YUYV output. Signed-off-by: Michael Tretter Reviewed-by: Philipp Zabel --- drivers/media/platform/coda/coda-bit.c | 7 +++++-- drivers/media/platform/coda/coda-common.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index f608de4..466a44e 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -759,7 +759,7 @@ static void coda9_set_frame_cache(struct coda_ctx *ctx, u32 fourcc) cache_config = 1 << CODA9_CACHE_PAGEMERGE_OFFSET; } coda_write(ctx->dev, cache_size, CODA9_CMD_SET_FRAME_CACHE_SIZE); - if (fourcc == V4L2_PIX_FMT_NV12) { + if (fourcc == V4L2_PIX_FMT_NV12 || fourcc == V4L2_PIX_FMT_YUYV) { cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET | 16 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET | 0 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET; @@ -1537,7 +1537,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 << 9) | CODA9_FRAME_TILED2LINEAR); - if (dst_fourcc == V4L2_PIX_FMT_NV12) + if (dst_fourcc == V4L2_PIX_FMT_NV12 || dst_fourcc == V4L2_PIX_FMT_YUYV) ctx->frame_mem_ctrl |= CODA_FRAME_CHROMA_INTERLEAVE; if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP) ctx->frame_mem_ctrl |= (0x3 << 9) | @@ -2079,6 +2079,9 @@ static void coda_finish_decode(struct coda_ctx *ctx) trace_coda_dec_rot_done(ctx, dst_buf, meta); switch (q_data_dst->fourcc) { + case V4L2_PIX_FMT_YUYV: + payload = width * height * 2; + break; case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_NV12: diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index c09cafd..43af428 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -95,6 +95,8 @@ void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data, u32 base_cb, base_cr; switch (q_data->fourcc) { + case V4L2_PIX_FMT_YUYV: + /* Fallthrough: IN -H264-> CODA -NV12 MB-> VDOA -YUYV-> OUT */ case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_YUV420: default: @@ -201,6 +203,11 @@ static const struct coda_video_device coda_bit_decoder = { V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_YVU420, + /* + * If V4L2_PIX_FMT_YUYV should be default, + * set_default_params() must be adjusted. + */ + V4L2_PIX_FMT_YUYV, }, }; @@ -246,6 +253,7 @@ static u32 coda_format_normalize_yuv(u32 fourcc) case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_YUV422P: + case V4L2_PIX_FMT_YUYV: return V4L2_PIX_FMT_YUV420; default: return fourcc; @@ -434,6 +442,11 @@ static int coda_try_pixelformat(struct coda_ctx *ctx, struct v4l2_format *f) return -EINVAL; for (i = 0; i < CODA_MAX_FORMATS; i++) { + /* Skip YUYV if the vdoa is not available */ + if (!ctx->vdoa && f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && + formats[i] == V4L2_PIX_FMT_YUYV) + continue; + if (formats[i] == f->fmt.pix.pixelformat) { f->fmt.pix.pixelformat = formats[i]; return 0; @@ -520,6 +533,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_YUYV: + f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16) * 2; + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * + f->fmt.pix.height; + 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 * @@ -593,6 +611,15 @@ static int coda_try_fmt_vid_cap(struct file *file, void *priv, ret = coda_try_fmt_vdoa(ctx, f, &use_vdoa); if (ret < 0) return ret; + + if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) { + if (!use_vdoa) + return -EINVAL; + + f->fmt.pix.bytesperline = round_up(f->fmt.pix.width, 16) * 2; + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * + f->fmt.pix.height; + } } return 0; @@ -662,6 +689,9 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f, } switch (f->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_YUYV: + ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP; + break; case V4L2_PIX_FMT_NV12: ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP; if (!disable_tiling)