Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1044228ybb; Wed, 25 Mar 2020 14:36:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtCvOkjO20OpEorOkcCz7puWFjTJgEhObDzdyLOK09BqoR5Lg5vPQordpRnPV29629grUED X-Received: by 2002:a54:4614:: with SMTP id p20mr3830696oip.48.1585172213911; Wed, 25 Mar 2020 14:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585172213; cv=none; d=google.com; s=arc-20160816; b=ZJG5fnPc9RQTL+16tjQG1mDCixn4KbP8AfvUyenvkA+JfCI9L7EVBrU7G7qFfDHzOD 3ZYKg9BwJO5u1S5r+w8QbgG9UUr6IHzuT5a5/WF+PHxur4VTkpz4NmqTWCa8aS/Ih25v yZ1oMGgyRMKJQjHysuOIU0+zZlx85f2yeUQSScze5BMpKL9pvgRlIc+AEBet21zVaYiK TjV/N1Yk7sPwQuSN1qshzq4JFBTJRpdLlpag4T3d4RiDmKPoDFZ1HMRe6ICb4QEGCKfa mO81uXDWNbyNErUmrLt5bEiryLu906cL50af+4tKvSThnQ0TBJT5M96EQxAiOu83jCtS 7ONQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uCnTPY9Lh7q8hyiGqI33k6nhOP6uMlxfmQ8erbb6fZc=; b=dF9RjvDb3rBRmBpJ7j1zuWSVtXpVn0O7ey+VaMopt/WSENTn+gcuUgZ2f7BIn+o4e/ WDtJouVUSPElBMQagMZP5bCVVUn4ekVeMnzWW6xeDvCR3K+UDnRIAqHlSvrfdHYZMZPq oZSzmAOBWHYJuu/r+JPrdRxxphTkhYl1vtMsBwZbNd/IVMrR8TypYpECmeyNl1UV84IG /6IaYpxZmqCBTIjijBwrgojs+hlEU2UyTEx41imQU862nggXK7IcNYG8xjarBb1fXJm6 U4B4jKYmxfrCe4W6FuAmQ8OpDzcRilTxrz7vsm3jpnppCnNEAZTNLVozWJ9R+GLt3yyz j6Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si103807oih.231.2020.03.25.14.36.41; Wed, 25 Mar 2020 14:36:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbgCYVfI (ORCPT + 99 others); Wed, 25 Mar 2020 17:35:08 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39854 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgCYVfH (ORCPT ); Wed, 25 Mar 2020 17:35:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 097D0293EA8 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , Nicolas Dufresne , kernel@collabora.com, Jonas Karlman , Heiko Stuebner , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, Ezequiel Garcia Subject: [PATCH v3 2/7] hantro: Set buffers' zeroth plane payload in .buf_prepare Date: Wed, 25 Mar 2020 18:34:33 -0300 Message-Id: <20200325213439.16509-3-ezequiel@collabora.com> X-Mailer: git-send-email 2.26.0.rc2 In-Reply-To: <20200325213439.16509-1-ezequiel@collabora.com> References: <20200325213439.16509-1-ezequiel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Buffers' zeroth plane payload size is calculated at format negotiation time, and so it can be set in .buf_prepare. Keep in mind that, to make this change easier, hantro_buf_prepare is refactored, using the cedrus driver as reference. This results in cleaner code as byproduct. Signed-off-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro_v4l2.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c index f4ae2cee0f18..3142ab6697d5 100644 --- a/drivers/staging/media/hantro/hantro_v4l2.c +++ b/drivers/staging/media/hantro/hantro_v4l2.c @@ -608,7 +608,7 @@ hantro_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, } static int -hantro_buf_plane_check(struct vb2_buffer *vb, const struct hantro_fmt *vpu_fmt, +hantro_buf_plane_check(struct vb2_buffer *vb, struct v4l2_pix_format_mplane *pixfmt) { unsigned int sz; @@ -630,12 +630,18 @@ static int hantro_buf_prepare(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; struct hantro_ctx *ctx = vb2_get_drv_priv(vq); + struct v4l2_pix_format_mplane *pix_fmt; + int ret; if (V4L2_TYPE_IS_OUTPUT(vq->type)) - return hantro_buf_plane_check(vb, ctx->vpu_src_fmt, - &ctx->src_fmt); - - return hantro_buf_plane_check(vb, ctx->vpu_dst_fmt, &ctx->dst_fmt); + pix_fmt = &ctx->src_fmt; + else + pix_fmt = &ctx->dst_fmt; + ret = hantro_buf_plane_check(vb, pix_fmt); + if (ret) + return ret; + vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage); + return 0; } static void hantro_buf_queue(struct vb2_buffer *vb) -- 2.26.0.rc2