From patchwork Mon Nov 4 22:12:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11226613 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 2C108139A for ; Mon, 4 Nov 2019 22:12:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 142D4214D8 for ; Mon, 4 Nov 2019 22:12:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 142D4214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 35D196E8A3; Mon, 4 Nov 2019 22:12:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B9E56E8A1 for ; Mon, 4 Nov 2019 22:12:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id A420228BA72 From: Andrzej Pietrasiewicz To: dri-devel@lists.freedesktop.org Subject: [PATCHv2 3/4] drm/komeda: use afbc helpers Date: Mon, 4 Nov 2019 23:12:27 +0100 Message-Id: <20191104221228.3588-4-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191104221228.3588-1-andrzej.p@collabora.com> References: <2485717.1SzL54aMiy@e123338-lin> <20191104221228.3588-1-andrzej.p@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ayan Halder , kernel@collabora.com, David Airlie , Liviu Dudau , linux-rockchip@lists.infradead.org, James Wang , Mihail Atanassov , Sean Paul MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There are afbc helpers available. Signed-off-by: Andrzej Pietrasiewicz --- .../arm/display/komeda/komeda_format_caps.h | 1 - .../arm/display/komeda/komeda_framebuffer.c | 44 +++++++------------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h index 32273cf18f7c..607eea80e60c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h @@ -33,7 +33,6 @@ #define AFBC_TH_LAYOUT_ALIGNMENT 8 #define AFBC_HEADER_SIZE 16 -#define AFBC_SUPERBLK_ALIGNMENT 128 #define AFBC_SUPERBLK_PIXELS 256 #define AFBC_BODY_START_ALIGNMENT 1024 #define AFBC_TH_BODY_START_ALIGNMENT 4096 diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c index 1b01a625f40e..e9c87551a5b8 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c @@ -4,6 +4,7 @@ * Author: James.Qian.Wang * */ +#include #include #include #include @@ -43,8 +44,7 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file, struct drm_framebuffer *fb = &kfb->base; const struct drm_format_info *info = fb->format; struct drm_gem_object *obj; - u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks, bpp; - u64 min_size; + u32 alignment_w = 0, alignment_h = 0, alignment_header, bpp; obj = drm_gem_object_lookup(file, mode_cmd->handles[0]); if (!obj) { @@ -52,19 +52,15 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file, return -ENOENT; } - switch (fb->modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) { - case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8: - alignment_w = 32; - alignment_h = 8; - break; - case AFBC_FORMAT_MOD_BLOCK_SIZE_16x16: - alignment_w = 16; - alignment_h = 16; - break; - default: - WARN(1, "Invalid AFBC_FORMAT_MOD_BLOCK_SIZE: %lld.\n", - fb->modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK); - break; + if (!drm_afbc_get_superblk_wh(fb->modifier, &alignment_w, &alignment_h)) + return -EINVAL; + + if ((alignment_w != 16 || alignment_h != 16) && + (alignment_w != 32 || alignment_h != 8)) { + DRM_DEBUG_KMS("Unsupported afbc tile w/h [%d/%d]\n", + alignment_w, alignment_h); + + return -EINVAL; } /* tiled header afbc */ @@ -84,20 +80,14 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file, goto check_failed; } - n_blocks = (kfb->aligned_w * kfb->aligned_h) / AFBC_SUPERBLK_PIXELS; - kfb->offset_payload = ALIGN(n_blocks * AFBC_HEADER_SIZE, - alignment_header); - bpp = komeda_get_afbc_format_bpp(info, fb->modifier); - kfb->afbc_size = kfb->offset_payload + n_blocks * - ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8, - AFBC_SUPERBLK_ALIGNMENT); - min_size = kfb->afbc_size + fb->offsets[0]; - if (min_size > obj->size) { - DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n", - obj->size, min_size); + + if (!drm_afbc_check_fb_size(mode_cmd->pitches[0], bpp, + mode_cmd->width, mode_cmd->height, + alignment_w, alignment_h, + obj->size, mode_cmd->offsets[0], + AFBC_SUPERBLK_ALIGNMENT)) goto check_failed; - } fb->obj[0] = obj; return 0;