mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
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 6/8] drm/meson: select RGB plane registers by OSD index
Date: Tue, 1 Dec 2026 09:32:16 +0100	[thread overview]
Message-ID: <0a3316ae-37f9-4739-a3b7-4b521427abd2@linaro.org> (raw)
In-Reply-To: <20261130-meson-g12a-osd2-v1-6-aa982300c20e@baylibre.com>

On 11/30/26 22:57, 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  | 35 +++++++++++++++++++++--------------
>   drivers/gpu/drm/meson/meson_drv.c   |  2 +-
>   drivers/gpu/drm/meson/meson_plane.c | 37 +++++++++++++++++++++++--------------
>   drivers/gpu/drm/meson/meson_plane.h |  2 +-
>   4 files changed, 46 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c
> index 27a10508c56e..55edb8e2e1af 100644
> --- a/drivers/gpu/drm/meson/meson_crtc.c
> +++ b/drivers/gpu/drm/meson/meson_crtc.c
> @@ -145,6 +145,26 @@ 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));

Both can fit in a single line

> +	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 +337,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..dca295841728 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,12 @@ 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];
> +	bool afbcd;
>   
>   	/*
>   	 * Update Coordinates
> @@ -269,9 +271,10 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
>   	if ((meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) ||
>   	     meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) &&
>   	    fb->modifier & DRM_FORMAT_MOD_ARM_AFBC(MESON_MOD_AFBC_VALID_BITS))
> -		priv->viu.osd1_afbcd = true;
> +		afbcd = true;
>   	else
> -		priv->viu.osd1_afbcd = false;
> +		afbcd = false;
> +	priv->viu.osd1_afbcd = afbcd;

Drop this since you're rewritting it completly in patch 8, keep afbcd handling as-is for this patch

>   
>   	/* Enable OSD and BLK0, set max global alpha */
>   	osd->ctrl_stat = OSD_ENABLE |
> @@ -279,14 +282,12 @@ 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 (afbcd) {
>   		if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
>   			/* This is the internal decoding memory address */
>   			priv->viu.osd1_blk1_cfg4 = MESON_G12A_AFBCD_OUT_ADDR;
> @@ -310,7 +311,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
>   	if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXBB))
>   		osd->blk0_cfg[0] |= OSD_OUTPUT_COLOR_RGB;
>   
> -	if (priv->viu.osd1_afbcd &&
> +	if (afbcd &&
>   	    meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
>   		osd->blk0_cfg[0] |= OSD_MALI_SRC_EN |
>   			priv->afbcd.ops->fmt_to_blk_mode(fb->modifier,
> @@ -385,7 +386,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
>   	osd->height = fb->height;
>   	osd->width = fb->width;
>   
> -	if (priv->viu.osd1_afbcd) {
> +	if (afbcd) {
>   		priv->afbcd.modifier = fb->modifier;
>   		priv->afbcd.format = fb->format->format;
>   
> @@ -429,7 +430,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 +543,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 +562,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 +584,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 */
> 


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2026-12-01  8:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 21:57 [PATCH 0/8] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-11-30 21:57 ` [PATCH 1/8] drm/meson: honor framebuffer offsets for the primary plane Guillaume La Roque
2026-12-01  8:21   ` Neil Armstrong
2026-12-02 11:55     ` Guillaume La Roque
2026-11-30 21:57 ` [PATCH 2/8] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-11-30 21:57 ` [PATCH 3/8] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-11-30 21:57 ` [PATCH 4/8] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-12-01  8:28   ` Neil Armstrong
2026-12-02 11:56     ` Guillaume La Roque
2026-11-30 21:57 ` [PATCH 5/8] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-12-01  8:26   ` Neil Armstrong
2026-11-30 21:57 ` [PATCH 6/8] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-12-01  8:32   ` Neil Armstrong [this message]
2026-12-02 11:57     ` Guillaume La Roque
2026-11-30 21:57 ` [PATCH 7/8] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-11-30 22:14   ` sashiko-bot
2026-11-30 21:57 ` [PATCH 8/8] drm/meson: add a linear RGB overlay on G12A OSD2 Guillaume La Roque
2026-11-30 22:16   ` sashiko-bot

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=0a3316ae-37f9-4739-a3b7-4b521427abd2@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®