aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-12-02 10:37:07 +0100
committerSimon Ser <contact@emersion.fr>2021-06-02 11:08:52 +0200
commit9e9be83a58382b61caa86b1aeca77b8794099569 (patch)
tree9f07899e1a764ef06b566541c3d20e318ba459a2 /backend/drm/drm.c
parentde51df277010e9f67d8e87cfdda0ca0a01e9ef0a (diff)
backend/drm: implement get_cursor_formats and get_cursor_size
Diffstat (limited to 'backend/drm/drm.c')
-rw-r--r--backend/drm/drm.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 2c9560f1..9e2c870b 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -26,9 +26,17 @@
#include "backend/drm/util.h"
#include "render/pixel_format.h"
#include "render/swapchain.h"
+#include "types/wlr_buffer.h"
#include "util/signal.h"
bool check_drm_features(struct wlr_drm_backend *drm) {
+ if (drmGetCap(drm->fd, DRM_CAP_CURSOR_WIDTH, &drm->cursor_width)) {
+ drm->cursor_width = 64;
+ }
+ if (drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &drm->cursor_height)) {
+ drm->cursor_height = 64;
+ }
+
uint64_t cap;
if (drmGetCap(drm->fd, DRM_CAP_PRIME, &cap) ||
!(cap & DRM_PRIME_CAP_IMPORT)) {
@@ -1004,6 +1012,32 @@ static void drm_connector_destroy_output(struct wlr_output *output) {
memset(&conn->output, 0, sizeof(struct wlr_output));
}
+static const struct wlr_drm_format_set *drm_connector_get_cursor_formats(
+ struct wlr_output *output, uint32_t buffer_caps) {
+ if (!(buffer_caps & WLR_BUFFER_CAP_DMABUF)) {
+ return NULL;
+ }
+ struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
+ if (!conn->crtc) {
+ return false;
+ }
+ struct wlr_drm_plane *plane = conn->crtc->cursor;
+ if (!plane) {
+ return false;
+ }
+ if (conn->backend->parent) {
+ return &conn->backend->mgpu_formats;
+ }
+ return &plane->formats;
+}
+
+static void drm_connector_get_cursor_size(struct wlr_output *output,
+ int *width, int *height) {
+ struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
+ *width = (int)drm->cursor_width;
+ *height = (int)drm->cursor_height;
+}
+
static const struct wlr_output_impl output_impl = {
.set_cursor = drm_connector_set_cursor,
.move_cursor = drm_connector_move_cursor,
@@ -1014,6 +1048,8 @@ static const struct wlr_output_impl output_impl = {
.rollback_render = drm_connector_rollback_render,
.get_gamma_size = drm_connector_get_gamma_size,
.export_dmabuf = drm_connector_export_dmabuf,
+ .get_cursor_formats = drm_connector_get_cursor_formats,
+ .get_cursor_size = drm_connector_get_cursor_size,
};
bool wlr_output_is_drm(struct wlr_output *output) {