From: Ao Xu via B4 Relay <devnull+ao.xu.amlogic.com@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: dri-devel@lists.freedesktop.org,
linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Ao Xu <ao.xu@amlogic.com>
Subject: [PATCH 04/11] drm: meson: add primary and overlay plane support for S4
Date: Fri, 10 Jan 2025 13:39:54 +0800 [thread overview]
Message-ID: <20250110-drm-s4-v1-4-cbc2d5edaae8@amlogic.com> (raw)
In-Reply-To: <20250110-drm-s4-v1-0-cbc2d5edaae8@amlogic.com>
From: Ao Xu <ao.xu@amlogic.com>
Update plane register configurations in the Meson DRM driver
to support the Amlogic S4 SoC. These adjustments ensure proper
handling of display planes with S4-specific hardware requirements.
Signed-off-by: Ao Xu <ao.xu@amlogic.com>
---
drivers/gpu/drm/meson/meson_crtc.c | 90 +++++++++++++++++++++++----------
drivers/gpu/drm/meson/meson_overlay.c | 7 ++-
drivers/gpu/drm/meson/meson_plane.c | 24 ++++++---
drivers/gpu/drm/meson/meson_registers.h | 16 ++++++
4 files changed, 102 insertions(+), 35 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
index d70616da8ce2fd974b57af6aadca5c98fbb88fce..64c7450b7f688d8997e8ad23947bff3ec6484aff 100644
--- a/drivers/gpu/drm/meson/meson_crtc.c
+++ b/drivers/gpu/drm/meson/meson_crtc.c
@@ -28,6 +28,7 @@
#include "meson_osd_afbcd.h"
#define MESON_G12A_VIU_OFFSET 0x5ec0
+#define MESON_S4_VIU_OFFSET 0xb6c0
/* CRTC definition */
@@ -479,21 +480,60 @@ void meson_crtc_irq(struct meson_drm *priv)
writel_relaxed(priv->viu.vd1_if0_gen_reg,
priv->io_base + meson_crtc->viu_offset +
_REG(VD2_IF0_GEN_REG));
- writel_relaxed(priv->viu.vd1_if0_gen_reg2,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VD1_IF0_GEN_REG2));
- writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VIU_VD1_FMT_CTRL));
- writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VIU_VD2_FMT_CTRL));
- writel_relaxed(priv->viu.viu_vd1_fmt_w,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VIU_VD1_FMT_W));
- writel_relaxed(priv->viu.viu_vd1_fmt_w,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VIU_VD2_FMT_W));
+
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) {
+ writel_relaxed(priv->viu.vd1_if0_gen_reg2,
+ priv->io_base +
+ _REG(VD1_IF0_GEN_REG2_S4));
+ writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
+ priv->io_base +
+ _REG(VIU_VD1_FMT_CTRL_S4));
+ writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
+ priv->io_base +
+ _REG(VIU_VD2_FMT_CTRL_S4));
+ writel_relaxed(priv->viu.viu_vd1_fmt_w,
+ priv->io_base +
+ _REG(VIU_VD1_FMT_W_S4));
+ writel_relaxed(priv->viu.viu_vd1_fmt_w,
+ priv->io_base +
+ _REG(VIU_VD2_FMT_W_S4));
+
+ writel_relaxed(priv->viu.vd1_range_map_y,
+ priv->io_base +
+ _REG(VD1_IF0_RANGE_MAP_Y_S4));
+ writel_relaxed(priv->viu.vd1_range_map_cb,
+ priv->io_base +
+ _REG(VD1_IF0_RANGE_MAP_CB_S4));
+ writel_relaxed(priv->viu.vd1_range_map_cr,
+ priv->io_base +
+ _REG(VD1_IF0_RANGE_MAP_CR_S4));
+ } else {
+ writel_relaxed(priv->viu.vd1_if0_gen_reg2,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VD1_IF0_GEN_REG2));
+ writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VIU_VD1_FMT_CTRL));
+ writel_relaxed(priv->viu.viu_vd1_fmt_ctrl,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VIU_VD2_FMT_CTRL));
+ writel_relaxed(priv->viu.viu_vd1_fmt_w,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VIU_VD1_FMT_W));
+ writel_relaxed(priv->viu.viu_vd1_fmt_w,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VIU_VD2_FMT_W));
+
+ writel_relaxed(priv->viu.vd1_range_map_y,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VD1_IF0_RANGE_MAP_Y));
+ writel_relaxed(priv->viu.vd1_range_map_cb,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VD1_IF0_RANGE_MAP_CB));
+ writel_relaxed(priv->viu.vd1_range_map_cr,
+ priv->io_base + meson_crtc->viu_offset +
+ _REG(VD1_IF0_RANGE_MAP_CR));
+ }
writel_relaxed(priv->viu.vd1_if0_canvas0,
priv->io_base + meson_crtc->viu_offset +
_REG(VD1_IF0_CANVAS0));
@@ -592,15 +632,7 @@ void meson_crtc_irq(struct meson_drm *priv)
_REG(VD2_IF0_LUMA_PSEL));
writel_relaxed(0, priv->io_base + meson_crtc->viu_offset +
_REG(VD2_IF0_CHROMA_PSEL));
- writel_relaxed(priv->viu.vd1_range_map_y,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VD1_IF0_RANGE_MAP_Y));
- writel_relaxed(priv->viu.vd1_range_map_cb,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VD1_IF0_RANGE_MAP_CB));
- writel_relaxed(priv->viu.vd1_range_map_cr,
- priv->io_base + meson_crtc->viu_offset +
- _REG(VD1_IF0_RANGE_MAP_CR));
+
writel_relaxed(VPP_VSC_BANK_LENGTH(4) |
VPP_HSC_BANK_LENGTH(4) |
VPP_SC_VD_EN_ENABLE |
@@ -692,10 +724,16 @@ int meson_crtc_create(struct meson_drm *priv)
return ret;
}
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) {
meson_crtc->enable_osd1 = meson_g12a_crtc_enable_osd1;
meson_crtc->enable_vd1 = meson_g12a_crtc_enable_vd1;
- meson_crtc->viu_offset = MESON_G12A_VIU_OFFSET;
+
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))
+ meson_crtc->viu_offset = MESON_S4_VIU_OFFSET;
+ else
+ meson_crtc->viu_offset = MESON_G12A_VIU_OFFSET;
+
meson_crtc->enable_osd1_afbc =
meson_crtc_g12a_enable_osd1_afbc;
meson_crtc->disable_osd1_afbc =
diff --git a/drivers/gpu/drm/meson/meson_overlay.c b/drivers/gpu/drm/meson/meson_overlay.c
index 7f98de38842bf932ca3388707ec3e2f2c38d97e3..3cf2efa407849d6af9b010a5ad53e611155b6c9f 100644
--- a/drivers/gpu/drm/meson/meson_overlay.c
+++ b/drivers/gpu/drm/meson/meson_overlay.c
@@ -733,7 +733,12 @@ static void meson_overlay_atomic_disable(struct drm_plane *plane,
priv->viu.vd1_enabled = false;
/* Disable VD1 */
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) {
+ writel_relaxed(0, priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
+ writel_relaxed(0, priv->io_base + _REG(VD2_BLEND_SRC_CTRL));
+ writel_relaxed(0, priv->io_base + _REG(VD1_IF0_GEN_REG + 0x2db0));
+ writel_relaxed(0, priv->io_base + _REG(VD2_IF0_GEN_REG + 0x2db0));
+ } else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
writel_relaxed(0, priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
writel_relaxed(0, priv->io_base + _REG(VD2_BLEND_SRC_CTRL));
writel_relaxed(0, priv->io_base + _REG(VD1_IF0_GEN_REG + 0x17b0));
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index b43ac61201f3123e58effa9c4b734c23cfd3d5df..79cfa42af00f34f23993ab4b7af8b7bdfb23abce 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -161,7 +161,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
/* Check if AFBC decoder is required for this buffer */
if ((meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) ||
- meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) &&
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) &&
fb->modifier & DRM_FORMAT_MOD_ARM_AFBC(MESON_MOD_AFBC_VALID_BITS))
priv->viu.osd1_afbcd = true;
else
@@ -181,7 +182,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
priv->viu.osd1_blk0_cfg[0] = canvas_id_osd1 << OSD_CANVAS_SEL;
if (priv->viu.osd1_afbcd) {
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) {
/* This is the internal decoding memory address */
priv->viu.osd1_blk1_cfg4 = MESON_G12A_AFBCD_OUT_ADDR;
priv->viu.osd1_blk0_cfg[0] |= OSD_ENDIANNESS_BE;
@@ -205,7 +207,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
priv->viu.osd1_blk0_cfg[0] |= OSD_OUTPUT_COLOR_RGB;
if (priv->viu.osd1_afbcd &&
- meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
+ (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))) {
priv->viu.osd1_blk0_cfg[0] |= OSD_MALI_SRC_EN |
priv->afbcd.ops->fmt_to_blk_mode(fb->modifier,
fb->format->format);
@@ -357,7 +360,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
priv->viu.osd1_blk0_cfg[3] = ((dest.x2 - 1) << 16) | dest.x1;
priv->viu.osd1_blk0_cfg[4] = ((dest.y2 - 1) << 16) | dest.y1;
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4)) {
priv->viu.osd_blend_din0_scope_h = ((dest.x2 - 1) << 16) | dest.x1;
priv->viu.osd_blend_din0_scope_v = ((dest.y2 - 1) << 16) | dest.y1;
priv->viu.osb_blend0_size = dst_h << 16 | dst_w;
@@ -377,7 +381,8 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
priv->afbcd.format = fb->format->format;
/* Calculate decoder write stride */
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))
priv->viu.osd1_blk2_cfg4 =
meson_g12a_afbcd_line_stride(priv);
}
@@ -408,7 +413,8 @@ static void meson_plane_atomic_disable(struct drm_plane *plane,
}
/* Disable OSD1 */
- if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
+ if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))
writel_bits_relaxed(VIU_OSD1_POSTBLD_SRC_OSD1, 0,
priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
else
@@ -439,7 +445,8 @@ static bool meson_plane_format_mod_supported(struct drm_plane *plane,
return true;
if (!meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) &&
- !meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
+ !meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) &&
+ !meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))
return false;
if (modifier & ~DRM_FORMAT_MOD_ARM_AFBC(MESON_MOD_AFBC_VALID_BITS))
@@ -546,7 +553,8 @@ int meson_plane_create(struct meson_drm *priv)
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM))
format_modifiers = format_modifiers_afbc_gxm;
- else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
+ else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A) ||
+ meson_vpu_is_compatible(priv, VPU_COMPATIBLE_S4))
format_modifiers = format_modifiers_afbc_g12a;
ret = drm_universal_plane_init(priv->drm, plane, 0xFF,
diff --git a/drivers/gpu/drm/meson/meson_registers.h b/drivers/gpu/drm/meson/meson_registers.h
index 3d73d00a1f4c64cb90d2ab78f74133311d028197..c62ee8bac272be035e92dbc8e743b2d4f864bc55 100644
--- a/drivers/gpu/drm/meson/meson_registers.h
+++ b/drivers/gpu/drm/meson/meson_registers.h
@@ -328,6 +328,22 @@
#define VIU_VD2_FMT_CTRL 0x1a88
#define VIU_VD2_FMT_W 0x1a89
+#define VD1_IF0_RANGE_MAP_Y_S4 0x4816
+#define VD1_IF0_RANGE_MAP_CB_S4 0x4817
+#define VD1_IF0_RANGE_MAP_CR_S4 0x4818
+#define VD1_IF0_GEN_REG2_S4 0x4819
+#define VD1_IF0_GEN_REG3_S4 0x481c
+#define VIU_VD1_FMT_CTRL_S4 0x481d
+#define VIU_VD1_FMT_W_S4 0x481e
+
+#define VD2_IF0_RANGE_MAP_Y_S4 0x4896
+#define VD2_IF0_RANGE_MAP_CB_S4 0x4897
+#define VD2_IF0_RANGE_MAP_CR_S4 0x4898
+#define VD2_IF0_GEN_REG2_S4 0x4899
+#define VD2_IF0_GEN_REG3_S4 0x489c
+#define VIU_VD2_FMT_CTRL_S4 0x489d
+#define VIU_VD2_FMT_W_S4 0x489e
+
/* VIU Matrix Registers */
#define VIU_OSD1_MATRIX_CTRL 0x1a90
#define VIU_OSD1_MATRIX_COEF00_01 0x1a91
--
2.43.0
next prev parent reply other threads:[~2025-01-10 5:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 5:39 [PATCH 00/11] Subject: [PATCH 00/11] Add DRM support for Amlogic S4 Ao Xu via B4 Relay
2025-01-10 5:39 ` [PATCH 01/11] dt-bindings: display: meson-dw-hdmi: Add compatible for S4 HDMI controller Ao Xu via B4 Relay
2025-01-11 10:17 ` Krzysztof Kozlowski
2025-11-18 14:50 ` Piotr Oniszczuk
2025-11-19 2:57 ` Chuan Liu
2025-11-19 10:27 ` Piotr Oniszczuk
2025-11-21 2:55 ` Ao Xu
2025-11-21 9:54 ` Piotr Oniszczuk
2025-12-02 8:29 ` Piotr Oniszczuk
2025-12-03 5:56 ` Ao Xu
2025-12-05 7:09 ` Ao Xu
2025-12-05 10:03 ` Piotr Oniszczuk
2025-01-10 5:39 ` [PATCH 02/11] dt-bindings: display: meson-vpu: Add compatible for S4 display controller Ao Xu via B4 Relay
2025-01-10 14:07 ` Krzysztof Kozlowski
2025-01-10 5:39 ` [PATCH 03/11] drm: meson: add S4 compatible for DRM driver Ao Xu via B4 Relay
2025-01-10 13:36 ` Jerome Brunet
2025-01-11 6:40 ` kernel test robot
2025-01-11 7:47 ` kernel test robot
2025-01-10 5:39 ` Ao Xu via B4 Relay [this message]
2025-01-10 5:39 ` [PATCH 05/11] drm: meson: update VIU and VPP support for S4 Ao Xu via B4 Relay
2025-01-10 5:39 ` [PATCH 06/11] drm: meson: add meson_dw_hdmi " Ao Xu via B4 Relay
2025-01-10 14:08 ` Krzysztof Kozlowski
2025-01-10 5:39 ` [PATCH 07/11] drm: meson: change api call parameter Ao Xu via B4 Relay
2025-01-10 5:39 ` [PATCH 08/11] drm: meson: add hdmitx vmode timing support for S4 Ao Xu via B4 Relay
2025-01-10 5:39 ` [PATCH 09/11] drm: meson: add vpu clk setting " Ao Xu via B4 Relay
2025-01-10 5:40 ` [PATCH 10/11] drm: meson: add CVBS support " Ao Xu via B4 Relay
2025-01-10 5:40 ` [PATCH 11/11] arm64: dts: amlogic: s4: add DRM support [1/1] Ao Xu via B4 Relay
2025-01-10 10:10 ` [PATCH 00/11] Subject: [PATCH 00/11] Add DRM support for Amlogic S4 Neil Armstrong
2025-01-10 22:43 ` Rob Herring (Arm)
2025-01-12 22:44 ` Martin Blumenstingl
2025-01-14 17:50 ` Jerome Brunet
2025-01-15 6:15 ` Ao Xu
2025-01-22 9:50 ` Ao Xu
2025-01-22 10:38 ` Jerome Brunet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250110-drm-s4-v1-4-cbc2d5edaae8@amlogic.com \
--to=devnull+ao.xu.amlogic.com@kernel.org \
--cc=airlied@gmail.com \
--cc=ao.xu@amlogic.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®