From patchwork Wed Jan 11 16:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 42098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3433168wrt; Wed, 11 Jan 2023 09:04:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXses7Za/TGdSgY+eYyV41IOgQwav7ijKmZZgJUSpSJ6u/s+vakVruxc0UyL5uo6ECC5+eE9 X-Received: by 2002:aa7:d646:0:b0:499:b4e4:8a83 with SMTP id v6-20020aa7d646000000b00499b4e48a83mr10213403edr.21.1673456647980; Wed, 11 Jan 2023 09:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673456647; cv=none; d=google.com; s=arc-20160816; b=DpRs7ehazrXhk65HoBzL40IuNx0+D9EHczuiiWifpkiY+v4yPrKEMdXa1m8Ng0FgP4 2fiOsZ1VH5zbcc4Ohb+2tGzGo1ELbLIDU3TGC80FAUAh56mYA7GhzMqiDwhklfVGwtx7 vgXJO8jx2CX+0RAKsPpslw31Uju/PiQKvUE4Qd+t0Hd7KWJPhVLjeDbvJ2cWDvavDEWK Pcf8m0YaQYYr3h6CPdwRsUS0oyUVGIGUGJ4lyapGW03rN1dush7NpBjHr5Ad2HSwtZX4 VkqW4S7BviuDldh/c7qM8vVxc9FhRhAlyCRZWI95tLLZBH0I3Graae7FW3zqgQcthnRc Kw5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4I+WRcXf1zOxs+1XS+mzg+A8vzQ28fCiH9AYZqLsLSU=; b=ELdUpPL/pdV4+CRodnlIk7P5nm9nlrKmHH7SKf0OwgqeofGwQsg8tmOV+TPojB/TAU JVRMxka3r6PF9qRC/XeVVHyCEC3olaE5aCXR12nJoWW44Wh+UzNo5nQsVSf2gPk9qsGt 8YHY9VIrMPNGaeYpxRl3nu1f21Vj608dGaN81FgTDvKYnHy6Z3P/a3K0ZQoXvcA1n4SQ CilaUaOr++ziiYBbl5wS7Coj/DTE0i+m9taWba1SoRiRSxkx2kN+erGVU2GFYD26STHD 1hKlcXbwyllH1guVPtfEj51xUwsWxbJtiItLYRRGdmYUtRT8IvR7ZOZUgXwzm88z6xGs 0/Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ciFASSAs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a056402428200b004885f068e3bsi15057665edc.138.2023.01.11.09.03.43; Wed, 11 Jan 2023 09:04:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ciFASSAs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239512AbjAKRAi (ORCPT + 99 others); Wed, 11 Jan 2023 12:00:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238344AbjAKQ7q (ORCPT ); Wed, 11 Jan 2023 11:59:46 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18099186A1; Wed, 11 Jan 2023 08:59:44 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:1ee3:efce:e4f6:17a3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 3F7F56602D9F; Wed, 11 Jan 2023 16:59:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1673456383; bh=LGv40PaIQDqq/J5jDhdeIwK7Nftqoy1jclkArRF3dv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ciFASSAs/Gh3iWmya91novhFsuG+CQ0gpoqW3LpzK8Oj3tcYZXgGr3SPVBPBbVaGj uC3/SZpuJdLAB5oEjYCmZGBfdG5EZ9TtCBm3CaIIwa9DHb3nXfUst9/qCW76VIBIu8 w4WX9OFeipG4jw5+cgvU3Wfzj6MhJfFoo3evVqrGSftXxmZUdq2FbN8vT8zDKTRnD7 jO6tUSCfdN78+eGAKJHIw3Oak0jVH2DBPjMhkMNJJ6wFA9/0cCdT7FiJ1FbSplkDg0 mRSvfdZhJ7r007EcL2yKe3mSLeUAODJcZK1MWcjYwI4a6A2Pme4iSsIcAMcy7K2TAP 4pDG+Ik+bVuLw== From: Benjamin Gaignard To: ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, mchehab@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, heiko@sntech.de, daniel.almeida@collabora.com, nicolas.dufresne@collabora.co.uk Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v3 08/13] media: verisilicon: Compute motion vectors size for AV1 frames Date: Wed, 11 Jan 2023 17:59:26 +0100 Message-Id: <20230111165931.753763-9-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111165931.753763-1-benjamin.gaignard@collabora.com> References: <20230111165931.753763-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754746478000790882?= X-GMAIL-MSGID: =?utf-8?q?1754746478000790882?= Compute the additional space required to store motion vectors at the end of the frames buffers. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_hw.h | 13 +++++++++++++ .../media/platform/verisilicon/hantro_postproc.c | 3 +++ drivers/media/platform/verisilicon/hantro_v4l2.c | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h index e83f0c523a30..201f8679ca11 100644 --- a/drivers/media/platform/verisilicon/hantro_hw.h +++ b/drivers/media/platform/verisilicon/hantro_hw.h @@ -417,6 +417,19 @@ hantro_hevc_mv_size(unsigned int width, unsigned int height) return width * height / 16; } +static inline unsigned short hantro_av1_num_sbs(unsigned short dimension) +{ + return DIV_ROUND_UP(dimension, 64); +} + +static inline size_t +hantro_av1_mv_size(unsigned int width, unsigned int height) +{ + size_t num_sbs = hantro_av1_num_sbs(width) * hantro_av1_num_sbs(height); + + return ALIGN(num_sbs * 384, 16) + 512; +} + int hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx); int rockchip_vpu2_mpeg2_dec_run(struct hantro_ctx *ctx); void hantro_mpeg2_dec_copy_qtable(u8 *qtable, diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c b/drivers/media/platform/verisilicon/hantro_postproc.c index 09d8cf942689..7dc39519a2ee 100644 --- a/drivers/media/platform/verisilicon/hantro_postproc.c +++ b/drivers/media/platform/verisilicon/hantro_postproc.c @@ -213,6 +213,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx) else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_HEVC_SLICE) buf_size += hantro_hevc_mv_size(pix_mp.width, pix_mp.height); + else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_AV1_FRAME) + buf_size += hantro_av1_mv_size(pix_mp.width, + pix_mp.height); for (i = 0; i < num_buffers; ++i) { struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i]; diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c index 162110ac118d..bbe79dbd2cd9 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -335,6 +335,11 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, pix_mp->plane_fmt[0].sizeimage += hantro_hevc_mv_size(pix_mp->width, pix_mp->height); + else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_AV1_FRAME && + !hantro_needs_postproc(ctx, fmt)) + pix_mp->plane_fmt[0].sizeimage += + hantro_av1_mv_size(pix_mp->width, + pix_mp->height); } else if (!pix_mp->plane_fmt[0].sizeimage) { /* * For coded formats the application can specify