Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp630199ybh; Wed, 18 Mar 2020 06:22:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvNITs/ML+JrC5dOgbPJg6XR1DjIE09YInzXQ0P2uOGjvxsHrpfFXpkR531tulcjSvu65sz X-Received: by 2002:aca:cf48:: with SMTP id f69mr2926637oig.122.1584537754508; Wed, 18 Mar 2020 06:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584537754; cv=none; d=google.com; s=arc-20160816; b=stjC0v8/5CnSVx2IpbXv9z+LW3TFcLTl6vPKAkXI9lNrWmqZpMVtL4NSCZbHDAlmb0 zdPT+irdzNtyep/Za5lvQLAOHvelqgeUsBqLx63W6m2JL9E7W9NlgoqcRP8Uv+tUR5rz 1PitLta7RyR2vK8o+xwkcVR9JQg/tfUgM1PaJWtMlh1czAFdl+DWGlV0X68L7KU3jAte XmjWED651liy8E4Aw+cgqKOK2CTLkIYI4uEpvT0HvGhKd7g0Lf4qq0WuPfHBdligQ1B+ ikncWjAB0uBPTU/LfIeMVPJ/1MyCfAzCwAG+o4gRLdnxlbdo7IZbvOP5ZRuZoIeizAdk 8ORQ== 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=g+m6ndohotITWGHTBE2KDxVpK9u7xkdHsyxC3of1xWJvCKW1aYodtHe9mCitYdDyrv eDZxM2on05qj31bp0H1DAPpqvVETncMYCg0jtdE1cNgVHYaS3a1S8njJUNFBOLFBHTt6 DEfeSF8YqHvkiShgkpzPa4ZpP4mHiy7NXMMD5jUUP1TdZAFYpfdSfOx1N+BaxQkBpXw9 3ankwcWrx4vv3oVucy6B64C4/xNdKlQ4FHK4Tni7yX29N3Mi1tCcEf3VEhKnH3LUFKLd TFWzkRMj8K/q8j/RXnmBIDwOJCQImXncqf6fH+vjGYpa03b44TOsC2DyLgnIJLKqcu2K lezw== 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 f36si3536850otf.201.2020.03.18.06.22.23; Wed, 18 Mar 2020 06:22:34 -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 S1727092AbgCRNV6 (ORCPT + 99 others); Wed, 18 Mar 2020 09:21:58 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:44472 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbgCRNV5 (ORCPT ); Wed, 18 Mar 2020 09:21:57 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 72251296622 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 , Ezequiel Garcia Subject: [PATCH v2 2/8] hantro: Set buffers' zeroth plane payload in .buf_prepare Date: Wed, 18 Mar 2020 10:21:02 -0300 Message-Id: <20200318132108.21873-3-ezequiel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200318132108.21873-1-ezequiel@collabora.com> References: <20200318132108.21873-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