From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
Daniel Stone <daniels@collabora.com>
Subject: [PATCH 5/5] drm/i915/dumb: Handle DRM_MODE_DUMB_CURSOR
Date: Tue, 21 Oct 2025 22:44:55 +0300 [thread overview]
Message-ID: <20251021194455.24297-6-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20251021194455.24297-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Allocate the dumb buffer based on the cursor hardware capabilities
when userspace has asked for it via the DRM_MODE_DUMB_CURSOR flag.
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_cursor.c | 38 ++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_cursor.h | 3 ++
drivers/gpu/drm/i915/display/intel_display.c | 5 ++-
3 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index c47c84935871..fffb25c91146 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -998,6 +998,44 @@ static void intel_cursor_add_size_hints_property(struct intel_plane *plane)
drm_plane_add_size_hints_property(&plane->base, hints, num_hints);
}
+int intel_cursor_dumb_create(struct intel_display *display,
+ struct drm_mode_create_dumb *args)
+{
+ const struct drm_mode_config *mode_config = &display->drm->mode_config;
+ int cpp = DIV_ROUND_UP(args->bpp, 8);
+
+ if (cpp != 4)
+ return -EINVAL;
+
+ if (args->width > mode_config->cursor_width)
+ return -EINVAL;
+
+ if (args->height > mode_config->cursor_height)
+ return -EINVAL;
+
+ if (display->platform.i845g || display->platform.i865g) {
+ if (!IS_ALIGNED(args->width, 64))
+ return -EINVAL;
+
+ args->pitch = roundup_pow_of_two(args->width) * 4;
+ } else {
+ switch (args->width) {
+ case 64:
+ case 128:
+ case 256:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ args->pitch = args->width * 4;
+ }
+
+ args->size = mul_u32_u32(args->pitch, args->height);
+
+ return 0;
+}
+
struct intel_plane *
intel_cursor_plane_create(struct intel_display *display,
enum pipe pipe)
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.h b/drivers/gpu/drm/i915/display/intel_cursor.h
index 65a9e7eb88c2..cd3ae2d6042e 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.h
+++ b/drivers/gpu/drm/i915/display/intel_cursor.h
@@ -7,6 +7,7 @@
#define _INTEL_CURSOR_H_
enum pipe;
+struct drm_mode_create_dumb;
struct intel_display;
struct intel_plane;
struct kthread_work;
@@ -16,5 +17,7 @@ intel_cursor_plane_create(struct intel_display *display,
enum pipe pipe);
void intel_cursor_unpin_work(struct kthread_work *base);
+int intel_cursor_dumb_create(struct intel_display *display,
+ struct drm_mode_create_dumb *args);
#endif
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index bd4317291ba5..6772d4dd94c7 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -574,7 +574,10 @@ int intel_display_dumb_create(struct drm_device *drm,
{
struct intel_display *display = to_intel_display(drm);
- return intel_plane_dumb_create(display, args);
+ if (args->flags & DRM_MODE_DUMB_CURSOR)
+ return intel_cursor_dumb_create(display, args);
+ else
+ return intel_plane_dumb_create(display, args);
}
void intel_set_plane_visible(struct intel_crtc_state *crtc_state,
--
2.49.1
next prev parent reply other threads:[~2025-10-21 19:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 19:44 [PATCH 0/5] drm/uapi: Intoduce DRM_MODE_DUMB_CURSOR Ville Syrjala
2025-10-21 19:44 ` [PATCH 1/5] drm/uapi: Validate DRM_IOCTL_MODE_CREATE_DUMB flags Ville Syrjala
2025-10-21 19:44 ` [PATCH 2/5] drm/uapi: Introduce the DRM_MODE_DUMB_CURSOR flag Ville Syrjala
2025-10-21 19:44 ` [PATCH 3/5] drm/i915/dumb: Move the display dumb buffer stuff into the display code Ville Syrjala
2025-10-21 19:44 ` [PATCH 4/5] drm/i915/dumb: Reject dumb buffer that exceed max fb dimensions Ville Syrjala
2025-10-21 19:44 ` Ville Syrjala [this message]
2025-10-21 19:51 ` ✗ CI.checkpatch: warning for drm/uapi: Intoduce DRM_MODE_DUMB_CURSOR Patchwork
2025-10-21 19:52 ` ✓ CI.KUnit: success " Patchwork
2025-10-21 20:07 ` ✗ CI.checksparse: warning " Patchwork
2025-10-21 20:31 ` ✓ Xe.CI.BAT: success " Patchwork
2025-10-21 23:07 ` ✓ Xe.CI.Full: " Patchwork
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=20251021194455.24297-6-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.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