Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3473325ybf; Tue, 3 Mar 2020 06:40:07 -0800 (PST) X-Google-Smtp-Source: ADFU+vtklEMO8II5EE/Vq3NVpCB3AZjvpqHBTi25aYcUcSc9LmBX20yOshTn7ipFsGVekCORWG6K X-Received: by 2002:a9d:6c01:: with SMTP id f1mr3469427otq.133.1583246407452; Tue, 03 Mar 2020 06:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583246407; cv=none; d=google.com; s=arc-20160816; b=NxDvVglsyZkzjtS4cPG1fUnOk+hofXzPsoANX4LtGRL5cDkPmpuT09mcZbXbNmnzbS l9PE8IE/ARJnQozGckEnhI30pWtKtSCdIPYfux6Klso0qn5VTqzzeGwlFxPUj7/Hap6E QWbbKjjpVYW+LPWJCas8EDLE1bjyg3M+4BNa+ViG++nwqSFOGGA96RasWn4tDm7vG47L eSN+nOwJCngXwJRr2S5ebAbxv08CZnY7wPvtghVp46BjrQcA9khLftW7mpydz8miI1eZ OeKT2F24wp9Q464CbNu/xNAEIkwqPh4clqlTFgN3pAHNOka5zbpDrbRV/4hciItEgyWP ECtQ== 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 :dkim-signature; bh=jIQVieVu7UoENPR4ohx8RO9hyM5Q2LpZgT/s7fhmTzY=; b=QyEfEorRiG7mbuvP9LpD/n0KvvwC2BouhcABSf3KXzIVMoqde7xxZUamS16KfOA+kj RkE573IIlgGdAkx1clmdA2jmVJ5Z+0vaovXf22WCE9wZV1YsowsdMnXf44MKmB+oVQBA PAzuAzz9tgbuNDxt4LBvieEOZUERE6EopBLplNLC+U5uVJfynExpuo17a40pVQcUNROG GT9tV7X2uhIbTcCyoGdO62OWXTGTmnMOA5rC+noMt7Ytdrgt4RMjNqz1oH1wwknGj/nc LXmtA/txvXCde/Dl5nIGIaWDztagltBmCssSTFk6r892qGJte5WSTOJ50j0Vfyg0IaKO nLCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BrG61wk4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si7184483oiy.68.2020.03.03.06.39.55; Tue, 03 Mar 2020 06:40:07 -0800 (PST) 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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BrG61wk4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729725AbgCCOhz (ORCPT + 99 others); Tue, 3 Mar 2020 09:37:55 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39769 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729068AbgCCOhh (ORCPT ); Tue, 3 Mar 2020 09:37:37 -0500 Received: by mail-wr1-f68.google.com with SMTP id y17so4634547wrn.6 for ; Tue, 03 Mar 2020 06:37:36 -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=jIQVieVu7UoENPR4ohx8RO9hyM5Q2LpZgT/s7fhmTzY=; b=BrG61wk4/LRRSyrFsuQZ2h3PGNH57U6RMOxCT1ivsgHVIHQWGtD0qd1sEtOgJhNktE sDrudfZiczmO6+LIcx+LQH2iEUadTyz2FeG9Nf/wQTYdSXPJxe9+mcTGRsMflfCrdeqa Rh7ApqPerAUd6vv2l3k6MztLeJUPUzypS1AgKRhCsI9fgNHk2CAp3bLkNqZCiB59MX4a u2xK8TLmk7fyjxzmlYDP+DRfAGgLK0oWk08VPezSPFgELqoXCZzMPq72rtPj3Cr+h8ax by0vnBk18YXfajEalDXapkkB18X4tMLwUc1AGl+bBK4B1EssmkUGShkLckdFDEKjUps0 vB7Q== 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=jIQVieVu7UoENPR4ohx8RO9hyM5Q2LpZgT/s7fhmTzY=; b=N4KyfTZUF09c2FTbyJTG9T257Lg2J8ivrzdvVIY1GZ2CS/SHKhxS438bR6wIXEHzK0 SYDsa8/kFRm0NyeFQ0hCUB+XY0nm7XyTNJpWF8Vq4rEK3L2e6wARuOy7rhyPNT19D6xo UMU/rz7deuw+XezzlZrX6gCy65ZjXRw6HjpFQ+Dkw4W6Ygq/tr9+u+4QE3W0giD7tEip 5auIYND5g/7wCw6p3VWYZ3Md3RR1QocCf9BblkYHeuH90E5KP6gZSiweBZ4w7aTYYT9H EUVsZDf47r59qJyG9vmU/Qfo3lwhhjbn4QfhPc4Fdi6QtHuIl0GwEXcCcYYAbly34POz NBMQ== X-Gm-Message-State: ANhLgQ32m7G27kTwulYDz09sTN/1h4vNh2F0vqK1T8YUTuPl9iaoBP2x NbMZaPKhy/Ewi3K6H3yUTncAlBPlInHSug== X-Received: by 2002:adf:df82:: with SMTP id z2mr5571677wrl.46.1583246255956; Tue, 03 Mar 2020 06:37:35 -0800 (PST) Received: from bender.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id l4sm4652779wmf.38.2020.03.03.06.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 06:37:35 -0800 (PST) From: Neil Armstrong To: mchehab@kernel.org, hans.verkuil@cisco.com Cc: Maxime Jourdan , linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Neil Armstrong , Kevin Hilman Subject: [PATCH v6 2/5] media: meson: vdec: add helpers for lossless framebuffer compression buffers Date: Tue, 3 Mar 2020 15:37:29 +0100 Message-Id: <20200303143732.762-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200303143732.762-1-narmstrong@baylibre.com> References: <20200303143732.762-1-narmstrong@baylibre.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 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 Tested-by: Kevin Hilman --- .../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 * -- 2.22.0