From patchwork Mon Feb 13 13:06:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Parrot X-Patchwork-Id: 9569573 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 85169601E7 for ; Mon, 13 Feb 2017 13:07:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6932226E81 for ; Mon, 13 Feb 2017 13:07:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CD6627F60; Mon, 13 Feb 2017 13:07:48 +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=unavailable 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 187FB26E81 for ; Mon, 13 Feb 2017 13:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753570AbdBMNHM (ORCPT ); Mon, 13 Feb 2017 08:07:12 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:10277 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753551AbdBMNHJ (ORCPT ); Mon, 13 Feb 2017 08:07:09 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v1DD77wQ004933; Mon, 13 Feb 2017 07:07:07 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v1DD77pS007131; Mon, 13 Feb 2017 07:07:07 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Mon, 13 Feb 2017 07:07:06 -0600 Received: from uda0869644a.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v1DD71XQ008199; Mon, 13 Feb 2017 07:07:06 -0600 From: Benoit Parrot To: Hans Verkuil , Mauro Carvalho Chehab , CC: , Tomi Valkeinen , Jyri Sarha , Peter Ujfalusi Subject: [Patch 2/2] media: ti-vpe: vpe: allow use of user specified stride Date: Mon, 13 Feb 2017 07:06:58 -0600 Message-ID: <20170213130658.31907-3-bparrot@ti.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170213130658.31907-1-bparrot@ti.com> References: <20170213130658.31907-1-bparrot@ti.com> MIME-Version: 1.0 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 Bytesperline/stride was always overwritten by VPE to the most adequate value based on needed alignment. However in order to make use of arbitrary size DMA buffer it is better to use the user space provide stride instead. The driver will still calculate an appropriate stride but will use the provided one when it is larger than the calculated one. Signed-off-by: Benoit Parrot --- drivers/media/platform/ti-vpe/vpe.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index 2dd67232b3bc..c47151495b6f 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1597,6 +1597,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, struct v4l2_plane_pix_format *plane_fmt; unsigned int w_align; int i, depth, depth_bytes, height; + unsigned int stride = 0; if (!fmt || !(fmt->types & type)) { vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n", @@ -1683,16 +1684,27 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, plane_fmt = &pix->plane_fmt[i]; depth = fmt->vpdma_fmt[i]->depth; - if (i == VPE_LUMA) - plane_fmt->bytesperline = (pix->width * depth) >> 3; - else - plane_fmt->bytesperline = pix->width; + stride = (pix->width * fmt->vpdma_fmt[VPE_LUMA]->depth) >> 3; + if (stride > plane_fmt->bytesperline) + plane_fmt->bytesperline = stride; + + plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline, + VPDMA_STRIDE_ALIGN); - if (pix->num_planes == 1 && fmt->coplanar) - depth += fmt->vpdma_fmt[VPE_CHROMA]->depth; - plane_fmt->sizeimage = - (pix->height * pix->width * depth) >> 3; + if (i == VPE_LUMA) { + plane_fmt->sizeimage = pix->height * + plane_fmt->bytesperline; + if (pix->num_planes == 1 && fmt->coplanar) + plane_fmt->sizeimage += pix->height * + plane_fmt->bytesperline * + fmt->vpdma_fmt[VPE_CHROMA]->depth >> 3; + + } else { /* i == VIP_CHROMA */ + plane_fmt->sizeimage = (pix->height * + plane_fmt->bytesperline * + depth) >> 3; + } memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); }