mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Guillaume La Roque <glaroque@baylibre.com>
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>,
	 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>,
	linux-kernel@vger.kernel.org,
	 Guillaume La Roque <glaroque@baylibre.com>
Subject: [PATCH v4 1/9] drm/meson: honor framebuffer offsets for the primary plane
Date: Fri, 04 Dec 2026 09:08:02 +0100	[thread overview]
Message-ID: <20261204-meson-g12a-osd2-v4-1-ad356340dbd6@baylibre.com> (raw)
In-Reply-To: <20261204-meson-g12a-osd2-v4-0-ad356340dbd6@baylibre.com>

The canvas and AFBC decoder use the GEM object address directly. Include
the framebuffer plane offset so scanout starts at the requested offset
within the object.

Reject unaligned scanout addresses, since the canvas rounds them up and
the AFBC decoder requires aligned headers.

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
 drivers/gpu/drm/meson/meson_plane.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
index c17afe6712f9..30afeadc7e01 100644
--- a/drivers/gpu/drm/meson/meson_plane.c
+++ b/drivers/gpu/drm/meson/meson_plane.c
@@ -77,7 +77,12 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
 {
 	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
 										 plane);
+	struct meson_plane *meson_plane = to_meson_plane(plane);
+	struct drm_framebuffer *fb = new_plane_state->fb;
+	struct drm_gem_dma_object *gem;
 	struct drm_crtc_state *crtc_state;
+	u32 alignment = 8;
+	int ret;
 
 	if (!new_plane_state->crtc)
 		return 0;
@@ -92,11 +97,23 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
 	 * - Upscaling up to 5x, vertical and horizontal
 	 * - Final coordinates must match crtc size
 	 */
-	return drm_atomic_helper_check_plane_state(new_plane_state,
-						   crtc_state,
-						   FRAC_16_16(1, 5),
-						   DRM_PLANE_NO_SCALING,
-						   false, true);
+	ret = drm_atomic_helper_check_plane_state(new_plane_state,
+						  crtc_state,
+						  FRAC_16_16(1, 5),
+						  DRM_PLANE_NO_SCALING,
+						  false, true);
+	if (ret || !new_plane_state->visible)
+		return ret;
+
+	if (fb->modifier != DRM_FORMAT_MOD_LINEAR)
+		alignment = meson_vpu_is_compatible(meson_plane->priv,
+						    VPU_COMPATIBLE_G12A) ? 64 : 16;
+
+	gem = drm_fb_dma_get_gem_obj(fb, 0);
+	if (!IS_ALIGNED(gem->dma_addr + fb->offsets[0], alignment))
+		return -EINVAL;
+
+	return 0;
 }
 
 #define MESON_MOD_AFBC_VALID_BITS (AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 |	\
@@ -363,7 +380,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane,
 	/* Update Canvas with buffer address */
 	gem = drm_fb_dma_get_gem_obj(fb, 0);
 
-	priv->viu.osd1_addr = gem->dma_addr;
+	priv->viu.osd1_addr = gem->dma_addr + fb->offsets[0];
 	priv->viu.osd1_stride = fb->pitches[0];
 	priv->viu.osd1_height = fb->height;
 	priv->viu.osd1_width = fb->width;

-- 
2.34.1


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

  reply	other threads:[~2026-12-04  8:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  8:08 [PATCH v4 0/9] drm/meson: add a second RGB plane on G12A Guillaume La Roque
2026-12-04  8:08 ` Guillaume La Roque [this message]
2026-12-04  8:30   ` [PATCH v4 1/9] drm/meson: honor framebuffer offsets for the primary plane sashiko-bot
2026-12-04  8:08 ` [PATCH v4 2/9] drm/meson: isolate primary plane scaler setup Guillaume La Roque
2026-12-04  8:08 ` [PATCH v4 3/9] drm/meson: keep RGB scanout state per OSD Guillaume La Roque
2026-12-04  8:08 ` [PATCH v4 4/9] drm/meson: parameterize the G12A OSD color matrix setup Guillaume La Roque
2026-12-04  8:08 ` [PATCH v4 5/9] drm/meson: handle primary plane zpos allocation failure Guillaume La Roque
2026-12-04  8:08 ` [PATCH v4 6/9] drm/meson: select RGB plane registers by OSD index Guillaume La Roque
2026-12-04  8:08 ` [PATCH v4 7/9] drm/meson: serialize OSD state updates with the IRQ Guillaume La Roque
2026-12-04  8:30   ` sashiko-bot
2026-12-04  8:08 ` [PATCH v4 8/9] drm/meson: publish pending OSD updates with the flip event Guillaume La Roque
2026-12-04  8:41   ` sashiko-bot
2026-12-04  8:08 ` [PATCH v4 9/9] drm/meson: add a linear RGB overlay on G12A OSD2 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=20261204-meson-g12a-osd2-v4-1-ad356340dbd6@baylibre.com \
    --to=glaroque@baylibre.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --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=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®