summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--simple-yuv.c42
-rw-r--r--wayland-drm-client-protocol.h43
-rw-r--r--wayland-drm-protocol.c20
3 files changed, 88 insertions, 17 deletions
diff --git a/simple-yuv.c b/simple-yuv.c
index 31a7ba4..4051b85 100644
--- a/simple-yuv.c
+++ b/simple-yuv.c
@@ -42,6 +42,7 @@
struct display {
struct wl_display *display;
+ struct wl_registry *registry;
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_drm *drm;
@@ -264,6 +265,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
window->callback = wl_surface_frame(window->surface);
wl_callback_add_listener(window->callback, &frame_listener, window);
+
+ wl_surface_commit(window->surface);
}
static const struct wl_callback_listener frame_listener = {
@@ -535,25 +538,40 @@ static const struct wl_seat_listener seat_listener = {
};
static void
-display_handle_global(struct wl_display *display, uint32_t id,
- const char *interface, uint32_t version, void *data)
+registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
+ const char *interface, uint32_t version)
{
struct display *d = data;
if (strcmp(interface, "wl_compositor") == 0) {
d->compositor =
- wl_display_bind(display, id, &wl_compositor_interface);
+ wl_registry_bind(d->registry, id,
+ &wl_compositor_interface, 1);
} else if (strcmp(interface, "wl_shell") == 0) {
- d->shell = wl_display_bind(display, id, &wl_shell_interface);
+ d->shell = wl_registry_bind(d->registry, id,
+ &wl_shell_interface, 1);
} else if (strcmp(interface, "wl_drm") == 0) {
- d->drm = wl_display_bind(display, id, &wl_drm_interface);
+ d->drm = wl_registry_bind(d->registry, id,
+ &wl_drm_interface, 1);
wl_drm_add_listener(d->drm, &drm_listener, d);
} else if (strcmp(interface, "wl_seat") == 0) {
- d->seat = wl_display_bind(display, id, &wl_seat_interface);
+ d->seat = wl_registry_bind(d->registry,
+ id, &wl_seat_interface, 1);
wl_seat_add_listener(d->seat, &seat_listener, d);
}
}
+static void
+registry_handle_global_remove(void *data, struct wl_registry *registry,
+ uint32_t name)
+{
+}
+
+static const struct wl_registry_listener registry_listener = {
+ registry_handle_global,
+ registry_handle_global_remove
+};
+
static struct display *
create_display(void)
{
@@ -563,9 +581,9 @@ create_display(void)
memset(display, 0, sizeof *display);
display->display = wl_display_connect(NULL);
assert(display->display);
-
- wl_display_add_global_listener(display->display,
- display_handle_global, display);
+ display->registry = wl_display_get_registry(display->display);
+ wl_registry_add_listener(display->registry,
+ &registry_listener, display);
return display;
}
@@ -681,10 +699,8 @@ main(int argc, char **argv)
fullscreen_window(window);
redraw(window, NULL, 0);
- while (1) {
- wl_display_flush(display->display);
- wl_display_iterate(display->display, WL_DISPLAY_READABLE);
- }
+ while (1)
+ wl_display_dispatch(display->display);
destroy_window(window);
destroy_display(display);
diff --git a/wayland-drm-client-protocol.h b/wayland-drm-client-protocol.h
index 7ddb614..8eae58f 100644
--- a/wayland-drm-client-protocol.h
+++ b/wayland-drm-client-protocol.h
@@ -33,7 +33,7 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>
-#include "wayland-util.h"
+#include "wayland-client.h"
struct wl_client;
struct wl_resource;
@@ -115,10 +115,24 @@ enum wl_drm_format {
};
#endif /* WL_DRM_FORMAT_ENUM */
+#ifndef WL_DRM_CAPABILITY_ENUM
+#define WL_DRM_CAPABILITY_ENUM
+/**
+ * wl_drm_capability - wl_drm capability bitmask
+ * @WL_DRM_CAPABILITY_PRIME: wl_drm prime available
+ *
+ * Bitmask of capabilities.
+ */
+enum wl_drm_capability {
+ WL_DRM_CAPABILITY_PRIME = 1,
+};
+#endif /* WL_DRM_CAPABILITY_ENUM */
+
struct wl_drm_listener {
/**
* device - (none)
* @name: (none)
+ * @since: 2
*/
void (*device)(void *data,
struct wl_drm *wl_drm,
@@ -126,15 +140,25 @@ struct wl_drm_listener {
/**
* format - (none)
* @format: (none)
+ * @since: 2
*/
void (*format)(void *data,
struct wl_drm *wl_drm,
uint32_t format);
/**
* authenticated - (none)
+ * @since: 2
*/
void (*authenticated)(void *data,
struct wl_drm *wl_drm);
+ /**
+ * capabilities - (none)
+ * @value: (none)
+ * @since: 2
+ */
+ void (*capabilities)(void *data,
+ struct wl_drm *wl_drm,
+ uint32_t value);
};
static inline int
@@ -148,6 +172,7 @@ wl_drm_add_listener(struct wl_drm *wl_drm,
#define WL_DRM_AUTHENTICATE 0
#define WL_DRM_CREATE_BUFFER 1
#define WL_DRM_CREATE_PLANAR_BUFFER 2
+#define WL_DRM_CREATE_PRIME_BUFFER 3
static inline void
wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
@@ -206,6 +231,22 @@ wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width,
return (struct wl_buffer *) id;
}
+static inline struct wl_buffer *
+wl_drm_create_prime_buffer(struct wl_drm *wl_drm, int32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_create((struct wl_proxy *) wl_drm,
+ &wl_buffer_interface);
+ if (!id)
+ return NULL;
+
+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
+ WL_DRM_CREATE_PRIME_BUFFER, id, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
+
+ return (struct wl_buffer *) id;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/wayland-drm-protocol.c b/wayland-drm-protocol.c
index 98e98ef..1dd9732 100644
--- a/wayland-drm-protocol.c
+++ b/wayland-drm-protocol.c
@@ -30,6 +30,7 @@
extern const struct wl_interface wl_buffer_interface;
extern const struct wl_interface wl_buffer_interface;
+extern const struct wl_interface wl_buffer_interface;
static const struct wl_interface *types[] = {
NULL,
@@ -50,23 +51,36 @@ static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
+ &wl_buffer_interface,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
};
static const struct wl_message wl_drm_requests[] = {
{ "authenticate", "u", types + 0 },
{ "create_buffer", "nuiiuu", types + 1 },
{ "create_planar_buffer", "nuiiuiiiiii", types + 7 },
+ { "create_prime_buffer", "nhiiuiiiiii", types + 18 },
};
static const struct wl_message wl_drm_events[] = {
{ "device", "s", types + 0 },
{ "format", "u", types + 0 },
{ "authenticated", "", types + 0 },
+ { "capabilities", "u", types + 0 },
};
WL_EXPORT const struct wl_interface wl_drm_interface = {
- "wl_drm", 1,
- ARRAY_LENGTH(wl_drm_requests), wl_drm_requests,
- ARRAY_LENGTH(wl_drm_events), wl_drm_events,
+ "wl_drm", 2,
+ 4, wl_drm_requests,
+ 4, wl_drm_events,
};