From: Jernej Skrabec <jernej.skrabec@gmail.com>
To: Chen-Yu Tsai <wens@kernel.org>, Samuel Holland <samuel@sholland.org>
Cc: mripard@kernel.org, maarten.lankhorst@linux.intel.com,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
Andre Przywara <andre.przywara@arm.com>,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v4 1/5] drm/sun4i: Reject fractional source coordinates without scaler
Date: Thu, 19 Nov 2026 18:54:33 +0100 [thread overview]
Message-ID: <20261119175437.2520400-2-jernej.skrabec@gmail.com> (raw)
In-Reply-To: <20261119175437.2520400-1-jernej.skrabec@gmail.com>
The layer code programs the scaler whenever the source rectangle has a
fractional offset, since only the scaler can apply a sub-pixel phase.
drm_atomic_helper_check_plane_state() with DRM_PLANE_NO_SCALING doesn't
catch that: it only compares the scaling factor, which may still be
exactly 1.0 with fractional source coordinates.
Channels without a scaler would thus have the non-existent scaler
programmed instead of an error being returned. Reject fractional source
coordinates on such channels.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 24 ++++++++++++++++++++----
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 24 ++++++++++++++++++++----
2 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
index cf66f676824e..f9c7f28f9fa2 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
@@ -179,10 +179,26 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane,
max_scale = SUN8I_UI_SCALER_SCALE_MAX;
}
- return drm_atomic_helper_check_plane_state(new_plane_state,
- crtc_state,
- min_scale, max_scale,
- true, true);
+ ret = drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ min_scale, max_scale,
+ true, true);
+ if (ret)
+ return ret;
+
+ /*
+ * Fractional source coordinates can only be handled by the scaler,
+ * so reject them on channels without one.
+ */
+ if (new_plane_state->visible &&
+ !(layer->cfg->scaler_mask & BIT(layer->channel)) &&
+ ((new_plane_state->src.x1 | new_plane_state->src.y1 |
+ new_plane_state->src.x2 | new_plane_state->src.y2) & 0xffff)) {
+ DRM_DEBUG_DRIVER("Fractional source coordinates need scaler\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
index 09d94f7f9977..4d3fc03f9877 100644
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
@@ -259,10 +259,26 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane,
max_scale = SUN8I_VI_SCALER_SCALE_MAX;
}
- return drm_atomic_helper_check_plane_state(new_plane_state,
- crtc_state,
- min_scale, max_scale,
- true, true);
+ ret = drm_atomic_helper_check_plane_state(new_plane_state,
+ crtc_state,
+ min_scale, max_scale,
+ true, true);
+ if (ret)
+ return ret;
+
+ /*
+ * Fractional source coordinates can only be handled by the scaler,
+ * so reject them on channels without one.
+ */
+ if (new_plane_state->visible &&
+ !(layer->cfg->scaler_mask & BIT(layer->channel)) &&
+ ((new_plane_state->src.x1 | new_plane_state->src.y1 |
+ new_plane_state->src.x2 | new_plane_state->src.y2) & 0xffff)) {
+ DRM_DEBUG_DRIVER("Fractional source coordinates need scaler\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,
--
2.43.0
next prev parent reply other threads:[~2026-11-19 17:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 17:54 [PATCH v4 0/5] drm/sun4i: update DE33 support Jernej Skrabec
2026-11-19 17:54 ` Jernej Skrabec [this message]
2026-11-19 17:54 ` [PATCH v4 2/5] dt-bindings: display: allwinner: Add DE33 planes Jernej Skrabec
2026-11-19 17:54 ` [PATCH v4 3/5] drm/sun4i: Add DE33 shared plane driver Jernej Skrabec
2026-11-19 17:54 ` [PATCH v4 4/5] dt-bindings: display: allwinner: Split H616 DE33 layer reg space Jernej Skrabec
2026-11-19 17:54 ` [PATCH v4 5/5] drm/sun4i: Switch DE33 to split plane bindings Jernej Skrabec
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=20261119175437.2520400-2-jernej.skrabec@gmail.com \
--to=jernej.skrabec@gmail.com \
--cc=airlied@gmail.com \
--cc=andre.przywara@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=wens@kernel.org \
/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