From: Neil Armstrong <neil.armstrong@linaro.org>
To: Guillaume La Roque <glaroque@baylibre.com>,
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>,
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,
linux-arm-kernel@lists.infradead.org,
Simona Vetter <simona.vetter@ffwll.ch>
Subject: Re: [PATCH v2 6/9] drm/meson: select RGB plane registers by OSD index
Date: Thu, 3 Dec 2026 20:33:10 +0100 [thread overview]
Message-ID: <4838252c-e270-4528-8c21-ff400639679f@linaro.org> (raw)
In-Reply-To: <20261203-meson-g12a-osd2-v2-6-8a4a57d32e20@baylibre.com>
On 12/3/26 20:21, Guillaume La Roque wrote:
> Pass the OSD index through plane creation and use it to select the scanout
> cache, canvas and control registers. Move the common register writes to
> meson_crtc_flush_osd() so OSD2 can reuse them.
>
> Keep OSD1 as the only registered RGB plane and preserve its AFBC test and
> hardware programming order.
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> drivers/gpu/drm/meson/meson_crtc.c | 33 +++++++++++++++++++--------------
> drivers/gpu/drm/meson/meson_drv.c | 2 +-
> drivers/gpu/drm/meson/meson_plane.c | 25 ++++++++++++++++---------
> drivers/gpu/drm/meson/meson_plane.h | 2 +-
> 4 files changed, 37 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
> index 27a10508c56e..71efaa58c183 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c
> @@ -145,6 +145,24 @@ static void meson_crtc_atomic_enable(struct drm_crtc *crtc,
> drm_crtc_vblank_on(crtc);
> }
>
> +static void meson_crtc_flush_osd(struct meson_drm *priv, unsigned int index)
> +{
> + struct meson_osd_state *osd = &priv->viu.osd[index];
> + u32 ctrl_stat = index ? VIU_OSD2_CTRL_STAT : VIU_OSD1_CTRL_STAT;
> + u32 ctrl_stat2 = index ? VIU_OSD2_CTRL_STAT2 : VIU_OSD1_CTRL_STAT2;
> + u32 blk0_cfg = index ? VIU_OSD2_BLK0_CFG_W0 : VIU_OSD1_BLK0_CFG_W0;
> + u32 blk0_cfg4 = index ? VIU_OSD2_BLK0_CFG_W4 : VIU_OSD1_BLK0_CFG_W4;
> + unsigned int i;
> +
> + writel_relaxed(osd->ctrl_stat, priv->io_base + _REG(ctrl_stat));
> + writel_relaxed(osd->ctrl_stat2, priv->io_base + _REG(ctrl_stat2));
> + for (i = 0; i < 4; i++)
> + writel_relaxed(osd->blk0_cfg[i],
> + priv->io_base + _REG(blk0_cfg + i));
> +
> + writel_relaxed(osd->blk0_cfg[4], priv->io_base + _REG(blk0_cfg4));
> +}
> +
> static void meson_g12a_crtc_atomic_disable(struct drm_crtc *crtc,
> struct drm_atomic_commit *state)
> {
> @@ -317,20 +335,7 @@ void meson_crtc_irq(struct meson_drm *priv)
>
> /* Update the OSD registers */
> if (priv->viu.osd[0].enabled && priv->viu.osd[0].commit) {
> - writel_relaxed(priv->viu.osd[0].ctrl_stat,
> - priv->io_base + _REG(VIU_OSD1_CTRL_STAT));
> - writel_relaxed(priv->viu.osd[0].ctrl_stat2,
> - priv->io_base + _REG(VIU_OSD1_CTRL_STAT2));
> - writel_relaxed(priv->viu.osd[0].blk0_cfg[0],
> - priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W0));
> - writel_relaxed(priv->viu.osd[0].blk0_cfg[1],
> - priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W1));
> - writel_relaxed(priv->viu.osd[0].blk0_cfg[2],
> - priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W2));
> - writel_relaxed(priv->viu.osd[0].blk0_cfg[3],
> - priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W3));
> - writel_relaxed(priv->viu.osd[0].blk0_cfg[4],
> - priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W4));
> + meson_crtc_flush_osd(priv, 0);
>
> if (priv->viu.osd1_afbcd) {
> if (meson_crtc->enable_osd1_afbc)
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index 94d100d8963c..1a3215bf239c 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -328,7 +328,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
> goto exit_afbcd;
> }
>
> - ret = meson_plane_create(priv);
> + ret = meson_plane_create(priv, 0);
> if (ret)
> goto exit_afbcd;
>
> diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
> index 1c65aedd3926..4d8580263d36 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -66,6 +66,7 @@
> struct meson_plane {
> struct drm_plane base;
> struct meson_drm *priv;
> + unsigned int index;
> bool enabled;
> };
> #define to_meson_plane(x) container_of(x, struct meson_plane, base)
> @@ -251,11 +252,11 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> plane);
> struct drm_rect dest = drm_plane_state_dest(new_state);
> struct meson_drm *priv = meson_plane->priv;
> - struct meson_osd_state *osd = &priv->viu.osd[0];
> struct drm_framebuffer *fb = new_state->fb;
> struct drm_gem_dma_object *gem;
> unsigned long flags;
> - u8 canvas_id_osd1;
> + unsigned int index = meson_plane->index;
> + struct meson_osd_state *osd = &priv->viu.osd[index];
>
> /*
> * Update Coordinates
> @@ -279,12 +280,10 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
> OSD_BLK0_ENABLE;
>
> osd->ctrl_stat2 = readl(priv->io_base +
> - _REG(VIU_OSD1_CTRL_STAT2));
> -
> - canvas_id_osd1 = priv->canvas_id_osd[0];
> + _REG(index ? VIU_OSD2_CTRL_STAT2 : VIU_OSD1_CTRL_STAT2));
>
> /* Set up BLK0 to point to the right canvas */
> - osd->blk0_cfg[0] = canvas_id_osd1 << OSD_CANVAS_SEL;
> + osd->blk0_cfg[0] = priv->canvas_id_osd[index] << OSD_CANVAS_SEL;
>
> if (priv->viu.osd1_afbcd) {
> if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
> @@ -429,7 +428,7 @@ static void meson_plane_atomic_disable(struct drm_plane *plane,
> priv->io_base + _REG(VPP_MISC));
>
> meson_plane->enabled = false;
> - priv->viu.osd[0].enabled = false;
> + priv->viu.osd[meson_plane->index].enabled = false;
> }
>
> static const struct drm_plane_helper_funcs meson_plane_helper_funcs = {
> @@ -542,7 +541,14 @@ static const uint64_t format_modifiers_default[] = {
> DRM_FORMAT_MOD_INVALID,
> };
>
> -int meson_plane_create(struct meson_drm *priv)
> +/**
> + * meson_plane_create - Register an RGB plane
> + * @priv: Meson DRM device
> + * @index: Zero-based OSD index
> + *
> + * Return: 0 on success or a negative error code.
> + */
> +int meson_plane_create(struct meson_drm *priv, unsigned int index)
> {
> struct meson_plane *meson_plane;
> struct drm_plane *plane;
> @@ -554,6 +560,7 @@ int meson_plane_create(struct meson_drm *priv)
> return -ENOMEM;
>
> meson_plane->priv = priv;
> + meson_plane->index = index;
> plane = &meson_plane->base;
>
> if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM))
> @@ -575,7 +582,7 @@ int meson_plane_create(struct meson_drm *priv)
> drm_plane_helper_add(plane, &meson_plane_helper_funcs);
>
> /* For now, OSD Primary plane is always on the front */
> - ret = drm_plane_create_zpos_immutable_property(plane, 1);
> + ret = drm_plane_create_zpos_immutable_property(plane, index + 1);
> if (ret) {
> drm_plane_cleanup(plane);
> return ret;
> diff --git a/drivers/gpu/drm/meson/meson_plane.h b/drivers/gpu/drm/meson/meson_plane.h
> index 1460e182cd22..6e891d54bb63 100644
> --- a/drivers/gpu/drm/meson/meson_plane.h
> +++ b/drivers/gpu/drm/meson/meson_plane.h
> @@ -13,6 +13,6 @@
>
> #include "meson_drv.h"
>
> -int meson_plane_create(struct meson_drm *priv);
> +int meson_plane_create(struct meson_drm *priv, unsigned int index);
>
> #endif /* __MESON_PLANE_H */
>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Thanks,
Neil
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-12-03 21:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 19:21 [PATCH v2 0/9] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 1/9] drm/meson: honor framebuffer offsets for the primary plane Guillaume La Roque
2026-12-03 19:31 ` Neil Armstrong
2026-12-03 19:43 ` sashiko-bot
2026-12-03 19:21 ` [PATCH v2 2/9] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-12-03 19:32 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 3/9] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-12-03 19:32 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 4/9] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 5/9] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-12-03 19:21 ` [PATCH v2 6/9] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong [this message]
2026-12-03 19:21 ` [PATCH v2 7/9] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 8/9] drm/meson: clear pending primary updates while disabled Guillaume La Roque
2026-12-03 19:33 ` Neil Armstrong
2026-12-03 19:21 ` [PATCH v2 9/9] drm/meson: add a linear RGB overlay on G12A OSD2 Guillaume La Roque
2026-12-03 19:34 ` Neil Armstrong
2026-12-03 19:38 ` [PATCH v2 0/9] drm/meson: add a second RGB plane on G12A Neil Armstrong
2026-12-03 19:58 ` Guillaume La Roque
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=4838252c-e270-4528-8c21-ff400639679f@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=glaroque@baylibre.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=mripard@kernel.org \
--cc=simona.vetter@ffwll.ch \
--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®