Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp787332ybh; Wed, 11 Mar 2020 10:48:00 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvDSXPeE1Z18t8VXuyEzGazdfA5walLftCzNhMVVMQnShOOLmhGGayzmXFAOZzGG5L3LeL3 X-Received: by 2002:a4a:bb96:: with SMTP id h22mr1110531oop.9.1583948880637; Wed, 11 Mar 2020 10:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583948880; cv=none; d=google.com; s=arc-20160816; b=soOe/uQEAdkCmoKHaResL6Hb3d38qi998YR8vEvl7UsWO+Wlb2jpM5MlvtDROyPm4M sRrbva20500p7PIgD/8YzYeGJnCM8m7LVJeQ4yRTlTXQ/OQuqTiZV6dHbjw7/ZxYEXW0 tMgnmvZqLeCgGAPpfMIrrbF4h7H0rJBgAdpnXN+eVUHj0FTG8QQDyNuxtACKnh/wpAWf /PqjGQ8VEVbK4k/wGKIPZyYzqv492wjAnu7v6HbnJiHHTgQ9jnoSFBE7ZMFX4gNJsIrh Elq2GjX9mVWOAtLRTh7BMYbnq6ENHAi/wiwEtq1NwViH/NzOKH06wSsXIAryH1nxSi0Z QIIQ== 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=WkxbTBFPoN5juC3C7SIxxKN93fPh1ZlEVa64X6EBoWA=; b=qgCdHCNJTDFp6c+OU9kE54P2hAsnm/oTelEuDCleYbi/JKcycEhXIlSrNSGJT2CX76 ytp7AvNUFxYFg4u52oUSqeXz7fJOTuR1YMkkIwBF9SyOgcaXl6fBRKTWoMLcXejDHHxA XzK40NzFYQvzo3gln8h6vM82Y8FeI+1+0rC0uQ+GaHC4o7hwoXLryBAzRV39izJysWHK FDSeVBmRUSyXe5CstexWAVvV/FCIotDRIkoNCfyf9O2nVJRu7uk81oxcb7TG2vzozU62 D4GFQty8k6TLbQ0201PiQ0UVpdCeTXPG1+AEi9yPtsJJfNulsz6XpL22XQhROU/R++X6 qT9Q== 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 i8si478138oou.32.2020.03.11.10.47.49; Wed, 11 Mar 2020 10:48:00 -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 S1730690AbgCKRrT (ORCPT + 99 others); Wed, 11 Mar 2020 13:47:19 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33070 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730645AbgCKRrS (ORCPT ); Wed, 11 Mar 2020 13:47:18 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 1BB3F2912DA 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 , Ezequiel Garcia Subject: [PATCH 2/6] hantro: Set buffers' zeroth plane payload in .buf_prepare Date: Wed, 11 Mar 2020 14:42:56 -0300 Message-Id: <20200311174300.19407-3-ezequiel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200311174300.19407-1-ezequiel@collabora.com> References: <20200311174300.19407-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.25.0