Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4331365ybf; Wed, 4 Mar 2020 01:46:58 -0800 (PST) X-Google-Smtp-Source: ADFU+vtj3KoFQ0KxQb2tb2TazPWBF5mJXzDM4RmldoARGJQGhFuqdQIz6NdMhrXP4FDkOROAbzpb X-Received: by 2002:aca:ab0c:: with SMTP id u12mr1077596oie.171.1583315218255; Wed, 04 Mar 2020 01:46:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583315218; cv=none; d=google.com; s=arc-20160816; b=Mhr3oHUGngmk3z5/amEbrDhjV3ex6E5w61fVhyKxMMqbtbAUAFT/J6GI9A1sBp9yhH PtZtvkwUdC5PpG8wwTiyXCL+j22VYS7gOB0M5x4mOOBqKwN1K86gMq2CSDH948vyJQfZ habKjJa5zeOsZVDN3yte0mCze5aJOm5oZf3FzYNxJQbAXMDOMyxq4ztAmFgE3a5bAoHz wNUqjiamYknZchRfGzffvy6mTiG2DtifztELjTGkxq7MoR5P4B+5p3gTe30VOaVuzLlX CkoHC5xVLQG/bqdoTkTZaMCsvI2I0V4lOX5oP1OQINZqeKAv5hl8DaX1h8zFDcdhkppc 0MPw== 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=h0jUgYVpgQCMgyOoQ0modkrWC2/z1SGuH18gvgaXbI7S2HNvzV+vyFnTvoKElMaZZs IDoLfMd+LaqjQ5FCmnybyej8+lImvD32CslPzQzAJBXTHybY+3s++Eyn5YG1j3GHtcAS tJWmFOWzUEbkbPoS07jqyp5X7ghloVN/k+mkgt2ghfxQT1ntMU1tQgvB3HuNWBV+MEDl qUsA7VzULm0iJvXr5PtTInpFhGy/aoPtpILs2kBqrpQ45pEBwKRr90aMPyGYvnsU1aC1 +eyMlu9Ab+ecSJzvuNGNF8UPCZY617kY2u3rdv/g99Un21Z5i2Pk+fYo2Kq2hCuMFKoR uG+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=IkPXgpK4; 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 l145si965544oih.44.2020.03.04.01.46.46; Wed, 04 Mar 2020 01:46:58 -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=IkPXgpK4; 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 S1729276AbgCDJqj (ORCPT + 99 others); Wed, 4 Mar 2020 04:46:39 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35697 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729131AbgCDJqh (ORCPT ); Wed, 4 Mar 2020 04:46:37 -0500 Received: by mail-wm1-f67.google.com with SMTP id m3so1145918wmi.0 for ; Wed, 04 Mar 2020 01:46:35 -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=IkPXgpK4xQ3HN1/lwVgetOzEh4UKm3I+9vyeCcCPhYG1sgxmm/ZFGWaEZKCICJssig w3q97QiB8Uqqxfw515+wbeZRdtgSkKczNxTt5VK260CBa/OIyFD5LgXhPlbWMHlkSaxp zH3P9zMqOTvIe35eja5Mr64XZgKTgp1EC7Kph8B6J6PMWq19RaTgiFzMKEe+fBdepN4E bUmZay3pi3XOLqH6dM8Esz+Of29D57PB93+lRseLxicDlW4Tdberxde1nVkX+qLwEBKv oeCeoI5RyPCWOgbD5aazF7HM5AC4Q+y0MfZxEoTTdO5mnsYsI6jQKoVdemXxk0mKXcSZ 9jsA== 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=BlacABzQVNpqr3thsOgUNguVdTaWgEYLKwmIyGuC/b6SEh7tG4BQ4RBDW2fNZ1FJEn ShZgIIcZN/m+RMCYhsiCyHSsV8ZDjvS2cmuWlo4luTByuls8KR3tBoP5v2xMUFqVWP9g fh43+lotLE7RSpbBIIonSLfHn+kRPuQ2YVwqUrKdwpRxE7mjzv672VLNo+Fh50M1pt2d NEpPJQaxrEkEudm+TNh5HmRSHMfYB1a7RGmjYfqHOJ/AMJ7f6xiNwrTkSOB6v6P2gsDK VUncpK66q/TYIVfcx3vQgpxDAVNg9me/e3wdQSWEY8dB+ZPHamc4AUz4s5xW3+ya5Rs3 tFlg== X-Gm-Message-State: ANhLgQ33QPJo2NqbBkJPHvAaQqhZ6yAiqxqycEDzxcfJFH7kIo27A5w4 rKIOYxJo9EFWdQM2KiAK++W0DA== X-Received: by 2002:a05:600c:2241:: with SMTP id a1mr2786991wmm.59.1583315194019; Wed, 04 Mar 2020 01:46:34 -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 b10sm38696107wrw.61.2020.03.04.01.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 01:46:33 -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 v7 2/5] media: meson: vdec: add helpers for lossless framebuffer compression buffers Date: Wed, 4 Mar 2020 10:46:22 +0100 Message-Id: <20200304094625.2257-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200304094625.2257-1-narmstrong@baylibre.com> References: <20200304094625.2257-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