Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2724840rwj; Mon, 19 Dec 2022 08:07:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6SRFF6hwNBDsB713ue76+FI11sphegj9acHJIvx6mZPc3gyhkP9CRRVXgod0tOZ4KFkbaW X-Received: by 2002:a17:906:e256:b0:7c0:edb6:e55f with SMTP id gq22-20020a170906e25600b007c0edb6e55fmr34210995ejb.37.1671466035365; Mon, 19 Dec 2022 08:07:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671466035; cv=none; d=google.com; s=arc-20160816; b=olO4Jmnv2fwf6ukbMeIGdHHDUGZtFq7BtKmObonOxoH+Lt0KfVIBoK4LqiEwLn9jaf uta1zmUVwTHr+RyOqmormx6z61lNKhC12gImJ+xQ1tE/R/SX1Ogc6lR+CBaute3i1WfR raj/KdT+hQzvO/c2d12v4DSNTD3IFnYYosFFd73x1O/3J409sLa3hUzxUDaNxFOzvdyt UqsWGSVcVWYSUTXzC5BCfLjs6aHZWDSeBIm5Riw696AOwLkEOY1KEaj27oYzaArOfbay sLgB88+IcG0L7E8yzbvL4J/P2rETKFFkD5ZIEtf3X9kWiZwnvRxOSKkWAmkCvIruVujo SBcQ== 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=pbAByURa7pHd26A41MTdZAiDtMeJilsQtip0DarFYgY=; b=SW5m2oOpQmuNox9chTGcVmhCyQ/vpQZTU9FvrOKW9QWx7JdwMfApYGRI4R5f5IeD4U nE0/ciCoyUAixpD8Y4LpNSkIIqAyYVVae/EOD++DBVYypOvRD4brKyniiLBUZu4F1l5v +LzsyxSW5eY8yYrNNaNs4UT3l6z0z8D28q4sNhbaJbC4904mFasYmAH+wxs/WW2Qk4yu ajxe9YIMLjMTF058pbpRLolwuif1XnK4CdERD2Vx8f2QW/4NYhRex1er5Ne3WS489iFO hWYz5kzenBxqd9kXNSkF9g2VUmCqqSsAnUo9C/QA+IOaP6Pdlm0CZjLYxOlNu31Dvrj5 SErw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ejztEOp6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id va28-20020a17090711dc00b0073d9f16e5b3si7654260ejb.258.2022.12.19.08.06.55; Mon, 19 Dec 2022 08:07:15 -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=ejztEOp6; 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 S232701AbiLSP5G (ORCPT + 71 others); Mon, 19 Dec 2022 10:57:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbiLSP4a (ORCPT ); Mon, 19 Dec 2022 10:56:30 -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 E56BA9FE8; Mon, 19 Dec 2022 07:56:28 -0800 (PST) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:f69c:5603:d4ce:7aa2]) (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 017176602CA6; Mon, 19 Dec 2022 15:56:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671465386; bh=JP0ZOeme9Q4m/y2OT/XWBdUdu+lDTKM4GJ0tmfQWtnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejztEOp6yUa75oohHIt4ndHrP2zZinL88kj7yNFS3UwUQkXMIx3/mBX1fXAlM4BfB Ms9DOhMjsyGaQ/EOBm6bpnMqC1sc2VWqHnG2MZTdXdXn7SSHFaSL6zAuY2oXB25w9V 9ooIIW2rE7CjjT/j9upbDLRMNMKpXRl18bpuCrS1EwLgJR2cOrs0ojeAnRKpWXP9LU aRaiAZFsYZvaA5NP/NBAp0cLJhHhks4rVFe2LK/c8mhWds7I2JJV8T9nTrP30N48sa MHS9YaHapiiZxTmgQNudgYcjUkvQsWkVzJsb44s8NxEjT+ur6jddvAR9YkU8KCeylQ AbFg7y6dCrKog== 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 v1 5/9] media: verisilicon: Compute motion vectors size for AV1 frames Date: Mon, 19 Dec 2022 16:56:12 +0100 Message-Id: <20221219155616.848690-6-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221219155616.848690-1-benjamin.gaignard@collabora.com> References: <20221219155616.848690-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Compute the additional 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..8b3bc7e31395 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) + 1; +} + +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 2c7a805289e7..d41dcb108a6d 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -334,6 +334,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 -- 2.34.1