From patchwork Fri Jul 3 08:07:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11641107 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 9864B13BD for ; Fri, 3 Jul 2020 08:07:55 +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 74B8220836 for ; Fri, 3 Jul 2020 08:07:55 +0000 (UTC) Authentication-Results: mail.kernel.org; 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="PyLrch+f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74B8220836 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 8FA096EAB4; Fri, 3 Jul 2020 08:07:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88FB86EABB for ; Fri, 3 Jul 2020 08:07:46 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id k6so31703402wrn.3 for ; Fri, 03 Jul 2020 01:07:46 -0700 (PDT) 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=/ng/jUwloNmcdfo+1PiIEF30ni1dXh2rT+0xtNGPS4s=; b=PyLrch+fX/y3on1e2GaZG7BbOXo3AxtFqG3wdXsEOSq2iC38M5weP7wSyKmLRJWcCc F3ovW8aquYh2TDG8N7rWl5GEK5lpKOs1QgLKxfFg715G8DcIcV3uYSOqKDkz0kaPNJFP a867mkMngjEdS9w4S/KEOUG9T3gXA62ZonFMi2soZEyW6CLDDXiuKeHUDRS48dvcQTeH EaT71E5n+v6C5r3yMt4S+9gkoISwt0XraBFa2+3885t7ljkzyRWC8w4kTl8H14Z1W6oL xHQVTvHtX4ooAqOUt+3CRepyul/8hK/WDp3a710K7pwq5UcOXGvLZ4rAz2zOjjFsb70j FlVg== 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=/ng/jUwloNmcdfo+1PiIEF30ni1dXh2rT+0xtNGPS4s=; b=cLr2V4cxEt2x77VoHuvH1XZucyuErHSeI++w0e1F2Fc6644QAC6MOz6za1GlmLLOYQ fx1rxr7DvUAx/+M+yYGUvhCOsv0YdD4FOtFkeKrmymwxlN+rO+D4HK16C9WtPgigqc/r zC29FX21p0682q7xoWcJi/FEIfJOzZWQNuEJ/hVOTKvQW+1ATkUkEsQpm4VNnjjnELPJ lQV6Q3UjgzJ0It6JvA9U8A/I6vwWaMxccqnITa5s8SiXyOH6a9UkzBZk3tRla4Ob0JbL LK0toG35ZqChcDvvP9dYwdoWzmhYL1jtV6UpfO+8/LJAJrM1xjK1vVjl6VlFJ8ojKtY8 44tg== X-Gm-Message-State: AOAM533LCN3CC1xQ5VR9bwx5mTT029n1lpTH/Pt1+SD9LfHbjzyy1J+E l54ehELALPQ+0VeU0t4WvqvRHQ== X-Google-Smtp-Source: ABdhPJwUXFlxviRDdo8T8RyU2xfFfWIniJJPgGGQKHZ5n/u/fWnGMblZd1yorghXWb7RlCzqeH+T9Q== X-Received: by 2002:a5d:6ac7:: with SMTP id u7mr7285462wrw.25.1593763665073; Fri, 03 Jul 2020 01:07:45 -0700 (PDT) Received: from bender.baylibre.local ([2a01:e35:2ec0:82b0:6959:e617:6562:cabf]) by smtp.gmail.com with ESMTPSA id 1sm12682403wmf.0.2020.07.03.01.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 01:07:44 -0700 (PDT) From: Neil Armstrong To: daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH v9 5/6] drm/meson: overlay: setup overlay for Amlogic FBC Scatter Memory layout Date: Fri, 3 Jul 2020 10:07:27 +0200 Message-Id: <20200703080728.25207-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200703080728.25207-1-narmstrong@baylibre.com> References: <20200703080728.25207-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jianxin.pan@amlogic.com, Neil Armstrong , Kevin Hilman , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Setup the Amlogic FBC decoder for the VD1 video overlay plane to use read the FBC header as Scatter Memory layout reference. Tested-by: Kevin Hilman Signed-off-by: Neil Armstrong Reviewed-by: Kevin Hilman --- drivers/gpu/drm/meson/meson_overlay.c | 53 ++++++++++++++++++--------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_overlay.c b/drivers/gpu/drm/meson/meson_overlay.c index 1566a887d482..1f7b2055e012 100644 --- a/drivers/gpu/drm/meson/meson_overlay.c +++ b/drivers/gpu/drm/meson/meson_overlay.c @@ -490,6 +490,10 @@ static void meson_overlay_atomic_update(struct drm_plane *plane, AMLOGIC_FBC_OPTION_MEM_SAVING)) priv->viu.vd1_afbc_mode |= AFBC_BLK_MEM_MODE; + if ((fb->modifier & __fourcc_mod_amlogic_layout_mask) == + AMLOGIC_FBC_LAYOUT_SCATTER) + priv->viu.vd1_afbc_mode |= AFBC_SCATTER_MODE; + priv->viu.vd1_afbc_en = 0x1600 | AFBC_DEC_ENABLE; priv->viu.vd1_afbc_conv_ctrl = AFBC_CONV_LBUF_LEN(256); @@ -675,23 +679,32 @@ static void meson_overlay_atomic_update(struct drm_plane *plane, } if (priv->viu.vd1_afbc) { - /* Default mode is 4k per superblock */ - unsigned long block_size = 4096; - unsigned long body_size; - - /* 8bit mem saving mode is 3072bytes per superblock */ - if (priv->viu.vd1_afbc_mode & AFBC_BLK_MEM_MODE) - block_size = 3072; - - body_size = (ALIGN(priv->viu.vd1_stride0, 64) / 64) * - (ALIGN(priv->viu.vd1_height0, 32) / 32) * - block_size; - - priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >> 4; - - /* Header is after body content */ - priv->viu.vd1_afbc_head_addr = (priv->viu.vd1_addr0 + - body_size) >> 4; + if (priv->viu.vd1_afbc_mode & AFBC_SCATTER_MODE) { + /* + * In Scatter mode, the header contains the physical + * body content layout, thus the body content + * size isn't needed. + */ + priv->viu.vd1_afbc_head_addr = priv->viu.vd1_addr0 >> 4; + priv->viu.vd1_afbc_body_addr = 0; + } else { + /* Default mode is 4k per superblock */ + unsigned long block_size = 4096; + unsigned long body_size; + + /* 8bit mem saving mode is 3072bytes per superblock */ + if (priv->viu.vd1_afbc_mode & AFBC_BLK_MEM_MODE) + block_size = 3072; + + body_size = (ALIGN(priv->viu.vd1_stride0, 64) / 64) * + (ALIGN(priv->viu.vd1_height0, 32) / 32) * + block_size; + + priv->viu.vd1_afbc_body_addr = priv->viu.vd1_addr0 >> 4; + /* Header is after body content */ + priv->viu.vd1_afbc_head_addr = (priv->viu.vd1_addr0 + + body_size) >> 4; + } } priv->viu.vd1_enabled = true; @@ -754,7 +767,8 @@ static bool meson_overlay_format_mod_supported(struct drm_plane *plane, return false; } - if (layout != AMLOGIC_FBC_LAYOUT_BASIC) { + if (layout != AMLOGIC_FBC_LAYOUT_BASIC && + layout != AMLOGIC_FBC_LAYOUT_SCATTER) { DRM_DEBUG_KMS("%llx invalid layout %x\n", modifier, layout); return false; @@ -800,8 +814,11 @@ static const uint32_t supported_drm_formats[] = { }; static const uint64_t format_modifiers[] = { + DRM_FORMAT_MOD_AMLOGIC_FBC(AMLOGIC_FBC_LAYOUT_SCATTER, + AMLOGIC_FBC_OPTION_MEM_SAVING), DRM_FORMAT_MOD_AMLOGIC_FBC(AMLOGIC_FBC_LAYOUT_BASIC, AMLOGIC_FBC_OPTION_MEM_SAVING), + DRM_FORMAT_MOD_AMLOGIC_FBC(AMLOGIC_FBC_LAYOUT_SCATTER, 0), DRM_FORMAT_MOD_AMLOGIC_FBC(AMLOGIC_FBC_LAYOUT_BASIC, 0), DRM_FORMAT_MOD_LINEAR, DRM_FORMAT_MOD_INVALID,