From patchwork Wed Feb 19 14:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11391555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A37CD138D for ; Wed, 19 Feb 2020 14:10:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8013A20801 for ; Wed, 19 Feb 2020 14:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uuVcH/L/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="cQecad2r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8013A20801 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t+Rv5JjoClJ1lY2VNfAIUtPRfmTuTOt9HywKvEv2ujw=; b=uuVcH/L/tmaR9D 5AK0+vMVwTahoCxRmIwyfr98ajvfcUnAAgEuX6GT89By1jHDgaFfmuvzl4TqizJh+TKyxEf0OVBS1 njhVtMTj2NqKkudqAOCaPYJX+digtdm8+w25o8NRrgvDBRI1zCe4shw6IsLR/icuD2K5wBaNzbwvE QO0fyw7Tiw4Bz1g4FH/WOje2WTr4JV8jYNfrvjwr+pS3LpTxqdfQHBFtYNNVrGspq9ZA2dteRbpsd SpnqfdwK7scbSutLZGU1j2zybxXqPQAy4u/w7O9ipOWlibzTDWr0H4yw70gpQEBKDEm2j9s0Fw8Zs 7N2RuLFatq29Jopqb6+w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4Q3p-0005vf-15; Wed, 19 Feb 2020 14:10:45 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4Q3D-0004x9-1B for linux-amlogic@lists.infradead.org; Wed, 19 Feb 2020 14:10:09 +0000 Received: by mail-wr1-x442.google.com with SMTP id m16so661519wrx.11 for ; Wed, 19 Feb 2020 06:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WxgSke1xqqIbUm6aWbWsjJ4dv5wN++i4U64IM8ckXcg=; b=cQecad2r6kPfGlZxEE39qCCU7kFN4oA7oUWh5y+PgdsQzPhqzKEJL9e/qmlNZLD4gU PxXSLbvl59PjnFaGXIB7HLvSCub08dqePDgCdwQIHZI7u5gpls9I9bNGSguOFr1nnBMs Wt77dMf22WAaaanEA52eva9HSLPfDcrW7m0bLawoH0FcYHtShFBaZbIhMFcvLVSukPTC AIvZ6X6lI1OsYkh1pU+vgO/XMQ3ZXMaz1Zwmr3o19ORkUCyPQAnqMBo/3ntu6JIX6z6C OGYRDlbFB7jCiWWcJGcQWz3H1546cod0PUCz77rBC3h6Tr2z//dWo06mmkYFqEZS/jHT geOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WxgSke1xqqIbUm6aWbWsjJ4dv5wN++i4U64IM8ckXcg=; b=AsQugqKt4aYQqXs27BWWWgGEoQhQd+UC7lWopxgjf68jBwIAoUkdoMEg7ZGm2dK11s uAqN/0NyU/HCHyx+ejCZBwnJ/WkyHxL2BxYEafdUl0EKpf/M7ZiLYsq/2Dyes3qtKlL4 6pziY8Viwdn03Smw+5LGvdM8pSzkS3eS/MrZnnXLG8bDMCva8KB9gReDXKLoNtv/NZIz 50lWg4av8br5Ct7xeOpy55a3c10mMIevsExY8jrv5aLVvG61phq3hY1opr7/JGLZKiHU wRYWXQfMQaVvVvtFqF5GGTy3N/P1EwK3TmIvd7LG4SQiYdBJV4EIdwda82j/uWp8v811 dZEw== X-Gm-Message-State: APjAAAWcHKrXpJi4SzyaI1D+49zMNz8qhZ16yZoZUq/+rVxc5/Fg3UkL rX1LP7JNWqZhMMb++nLgUXsUCA== X-Google-Smtp-Source: APXvYqxQYcrHP4DtfOJSIB4qclkpgmBXqO7WgESiSsSsVuhHumDrXVD7VhC0jXnO/QtvKP4HqctzvQ== X-Received: by 2002:adf:f491:: with SMTP id l17mr38900219wro.149.1582121405593; Wed, 19 Feb 2020 06:10:05 -0800 (PST) Received: from bender.baylibre.local ([2a01:e35:2ec0:82b0:4ca8:b25b:98e4:858]) by smtp.gmail.com with ESMTPSA id m68sm3182789wme.48.2020.02.19.06.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 06:10:04 -0800 (PST) From: Neil Armstrong To: mchehab@kernel.org, hans.verkuil@cisco.com Subject: [PATCH v5 2/5] media: meson: vdec: add helpers for lossless framebuffer compression buffers Date: Wed, 19 Feb 2020 15:09:55 +0100 Message-Id: <20200219140958.23542-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200219140958.23542-1-narmstrong@baylibre.com> References: <20200219140958.23542-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200219_061007_120039_C27AF8C1 X-CRM114-Status: UNSURE ( 9.43 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Jourdan , Neil Armstrong , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org From: Maxime Jourdan Add helpers to support the lossless framebuffer compression format that will be used in HEVC & VP9 decoders when decoding 10bit content for downsampling to 8bit NV12 and later proper compressed buffer support. Signed-off-by: Maxime Jourdan Signed-off-by: Neil Armstrong --- .../staging/media/meson/vdec/vdec_helpers.c | 27 +++++++++++++++++++ .../staging/media/meson/vdec/vdec_helpers.h | 4 +++ 2 files changed, 31 insertions(+) diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c index 3f7929c54dc6..caec0fb60338 100644 --- a/drivers/staging/media/meson/vdec/vdec_helpers.c +++ b/drivers/staging/media/meson/vdec/vdec_helpers.c @@ -50,6 +50,33 @@ void amvdec_write_parser(struct amvdec_core *core, u32 reg, u32 val) } EXPORT_SYMBOL_GPL(amvdec_write_parser); +/* 4 KiB per 64x32 block */ +u32 amvdec_am21c_body_size(u32 width, u32 height) +{ + u32 width_64 = ALIGN(width, 64) / 64; + u32 height_32 = ALIGN(height, 32) / 32; + + return SZ_4K * width_64 * height_32; +} +EXPORT_SYMBOL_GPL(amvdec_am21c_body_size); + +/* 32 bytes per 128x64 block */ +u32 amvdec_am21c_head_size(u32 width, u32 height) +{ + u32 width_128 = ALIGN(width, 128) / 128; + u32 height_64 = ALIGN(height, 64) / 64; + + return 32 * width_128 * height_64; +} +EXPORT_SYMBOL_GPL(amvdec_am21c_head_size); + +u32 amvdec_am21c_size(u32 width, u32 height) +{ + return ALIGN(amvdec_am21c_body_size(width, height) + + amvdec_am21c_head_size(width, height), SZ_64K); +} +EXPORT_SYMBOL_GPL(amvdec_am21c_size); + static int canvas_alloc(struct amvdec_session *sess, u8 *canvas_id) { int ret; diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.h b/drivers/staging/media/meson/vdec/vdec_helpers.h index 165e6293ffba..cfaed52ab526 100644 --- a/drivers/staging/media/meson/vdec/vdec_helpers.h +++ b/drivers/staging/media/meson/vdec/vdec_helpers.h @@ -27,6 +27,10 @@ void amvdec_clear_dos_bits(struct amvdec_core *core, u32 reg, u32 val); u32 amvdec_read_parser(struct amvdec_core *core, u32 reg); void amvdec_write_parser(struct amvdec_core *core, u32 reg, u32 val); +u32 amvdec_am21c_body_size(u32 width, u32 height); +u32 amvdec_am21c_head_size(u32 width, u32 height); +u32 amvdec_am21c_size(u32 width, u32 height); + /** * amvdec_dst_buf_done_idx() - Signal that a buffer is done decoding *