[PATCH] add simple-drm test
Zhao Halley
halley.zhao at intel.com
Thu Jun 7 19:11:16 PDT 2012
wayland-drm is a protocol to share buffer between wayland server and client.
it is a simple case to demonstrate how it works.
when I prepares some patches for mesa to extends buffer format supported by
wayland-drm, a test case is asked. then it does.
---
clients/Makefile.am | 10 +-
clients/simple-drm.c | 456 +++++++++++++++++++++++++++++++++
clients/wayland-drm-client-protocol.h | 196 ++++++++++++++
configure.ac | 8 +-
4 files changed, 667 insertions(+), 3 deletions(-)
create mode 100755 clients/simple-drm.c
create mode 100644 clients/wayland-drm-client-protocol.h
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 2377189..f6bb009 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -4,7 +4,8 @@ bin_PROGRAMS = \
noinst_PROGRAMS = \
$(clients_programs) \
$(poppler_programs) \
- $(simple_clients_programs)
+ $(simple_clients_programs) \
+ $(simple_drm_programs)
libexec_PROGRAMS = \
$(desktop_shell) \
@@ -34,6 +35,13 @@ simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS)
simple_touch_SOURCES = simple-touch.c
simple_touch_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
simple_touch_LDADD = $(SIMPLE_CLIENT_LIBS)
+
+if ENABLE_DRM_COMPOSITOR
+simple_drm_programs = simple-drm
+simple_drm_SOURCES = simple-drm.c wayland-drm-client-protocol.h
+simple_drm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) $(LIBDRM_CFLAGS) $(LIBGBM_CFLAGS)
+simple_drm_LDADD = $(SIMPLE_CLIENT_LIBS) $(LIBDRM_LIBS) $(LIBGBM_LIBS)
+endif
endif
if BUILD_CLIENTS
diff --git a/clients/simple-drm.c b/clients/simple-drm.c
new file mode 100755
index 0000000..05893ad
--- /dev/null
+++ b/clients/simple-drm.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright © 2012 Halley Zhao
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Halley Zhao <halley.zhao at intel.com>
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <assert.h>
+#include <xf86drm.h>
+#include <gbm.h>
+#include <wayland-client.h>
+#include <wayland-client-protocol.h>
+#include "wayland-drm-client-protocol.h"
+
+int win_width = 256, win_height = 256;
+int drm_fd = -1;
+int wayland_server_support_yuyv = 0;
+struct wl_drm *wl_drm;
+
+struct display {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct wl_shell *shell;
+ struct wl_input_device *input;
+ uint32_t mask;
+ struct gbm_device *gbm;
+};
+
+struct window {
+ struct display *display;
+ struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
+ struct wl_callback *callback;
+ struct {
+ int width, height;
+ } geometry;
+ unsigned int format;
+ struct wl_buffer *buffer;
+ struct gbm_bo *gbm_bo;
+ unsigned int bo_pitch;
+};
+
+void fill_window_XRGB(struct window *win);
+void fill_window_YUYV(struct window *win);
+int wayland_drm_init(struct wl_display *wl_dpy);
+void wayland_drm_destroy(void);
+void redraw(void *data, struct wl_callback *callback, uint32_t time);
+
+void fill_window_XRGB(struct window *win)
+{
+ unsigned char *mem = malloc (win->bo_pitch * win_height);
+ static int color_index = 0;
+ static unsigned int color_arr[4] = {0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff};
+ unsigned int color;
+ int i;
+ unsigned int *i_ptr;
+ unsigned char *c_ptr;
+
+ color = color_arr[color_index];
+ i_ptr = (unsigned int *)mem;
+ for (i=0; i<win_width/2; i++) {
+ *(i_ptr+i) = color;
+ }
+ color = color_arr[(color_index+1)%4];
+ for (i=win_width/2+1; i<win_width; i++) {
+ *(i_ptr+i) = color;
+ }
+
+ c_ptr = mem + win->bo_pitch;
+ for (i = 1; i<win_height/2; i++) {
+ memcpy (c_ptr, i_ptr, win_width*4);
+ c_ptr += win->bo_pitch;
+ }
+
+ color = color_arr[(color_index+2)%4];
+ i_ptr = (unsigned int *)c_ptr;
+ for (i=0; i<win_width/2; i++) {
+ *(i_ptr+i) = color;
+ }
+ color = color_arr[(color_index+3)%4];
+ for (i=win_width/2+1; i<win_width; i++) {
+ *(i_ptr+i) = color;
+ }
+
+ c_ptr += win->bo_pitch;
+ for (i = win_height/2+2; i<win_height; i++) {
+ memcpy (c_ptr, i_ptr, win_width*4);
+ c_ptr += win->bo_pitch;
+ }
+
+ gbm_bo_write(win->gbm_bo, mem, win->bo_pitch * win_height);
+ free(mem);
+ color_index = (color_index+1) % 4;
+
+}
+
+void fill_window_YUYV(struct window *win)
+{
+ unsigned char *mem = malloc (win->bo_pitch * win_height);
+
+ static unsigned int color_arr[4] = {0x00ff00ff, 0x80ff00ff, 0x00ff80ff, 0x80ff80ff};
+ static int color_index = 0;
+ unsigned int color;
+ int i;
+ unsigned int *i_ptr;
+ unsigned char *c_ptr;
+
+ i_ptr = (unsigned int *)mem;
+ color = color_arr[color_index];
+ for (i=0; i<win_width/4; i++) {
+ *(i_ptr+i) = color;
+ }
+ color = color_arr[(color_index+1)%4];
+ for (i=win_width/4+1; i<win_width/2; i++) {
+ *(i_ptr+i) = color;
+ }
+
+ c_ptr = mem + win->bo_pitch;
+ for (i = 1; i<win_height/2; i++) {
+ memcpy (c_ptr, (unsigned char*)i_ptr, win_width*2);
+ c_ptr += win->bo_pitch;
+ }
+
+ i_ptr = (unsigned int *) c_ptr;
+ color = color_arr[(color_index+2)%4];
+ for (i=0; i<win_width/4; i++) {
+ *(i_ptr+i) = color;
+ }
+ color = color_arr[(color_index+3)%4];
+ for (i=win_width/4+1; i<win_width/2; i++) {
+ *(i_ptr+i) = color;
+ }
+
+ c_ptr += win->bo_pitch;
+ for (i = win_height/2+2; i<win_height; i++) {
+ memcpy (c_ptr, (unsigned char*)i_ptr, win_width*2);
+ c_ptr += win->bo_pitch;
+ }
+
+ gbm_bo_write(win->gbm_bo, mem, win->bo_pitch * win_height);
+ free(mem);
+
+ color_index = (color_index+1) % 4;
+}
+
+static void
+drm_handle_device(void *data, struct wl_drm *drm, const char *device)
+{
+ drm_magic_t magic;
+ struct stat st;
+
+ if (stat(device, &st) < 0) {
+ printf("failed to identify %s (errno %d)",
+ device, errno);
+ return;
+ }
+
+ if (!S_ISCHR(st.st_mode)) {
+ printf("%s is not a device", device);
+ return;
+ }
+ drm_fd = open(device, O_RDWR);
+ if (drm_fd < 0) {
+ printf("failed to open %s (errno %d)",
+ device, errno);
+ return;
+ }
+
+ drmGetMagic(drm_fd, &magic);
+ wl_drm_authenticate(wl_drm, magic);
+}
+
+static void
+drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+{
+ if (format == WL_DRM_FORMAT_YUYV) {
+ wayland_server_support_yuyv = 1;
+ }
+
+}
+
+static void
+drm_handle_authenticated(void *data, struct wl_drm *drm)
+{
+
+}
+
+static const struct wl_drm_listener drm_listener = {
+ drm_handle_device,
+ drm_handle_format,
+ drm_handle_authenticated
+};
+
+static void
+wayland_drm_finalize(void)
+{
+
+ if (wl_drm) {
+ wl_drm_destroy(wl_drm);
+ wl_drm = NULL;
+ }
+
+ if (drm_fd >= 0) {
+ close(drm_fd);
+ drm_fd = -1;
+ }
+}
+
+int
+wayland_drm_init(struct wl_display *wl_dpy)
+{
+ uint32_t id;
+
+ assert(wl_dpy);
+
+ id = wl_display_get_global(wl_dpy, "wl_drm", 1);
+ if (!id) {
+ wl_display_roundtrip(wl_dpy);
+ id = wl_display_get_global(wl_dpy, "wl_drm", 1);
+ if (!id)
+ return -1;
+ }
+
+ wl_drm = wl_display_bind(wl_dpy, id, &wl_drm_interface);
+ if (!wl_drm)
+ return -1;
+
+ wl_drm_add_listener(wl_drm, &drm_listener, NULL);
+ wl_display_roundtrip(wl_dpy);
+ if (drm_fd < 0)
+ return -1;
+
+ wl_display_roundtrip(wl_dpy);
+
+ return 0;
+}
+
+static const struct wl_callback_listener frame_listener;
+
+void
+redraw(void *data, struct wl_callback *callback, uint32_t time)
+{
+ struct window *window = data;
+ if (callback)
+ wl_callback_destroy(callback);
+
+ if (window->format == WL_DRM_FORMAT_XRGB8888) {
+ fill_window_XRGB(window);
+ }
+ else {
+ fill_window_YUYV(window);
+ }
+
+ // update
+ wl_surface_attach(
+ window->surface,
+ window->buffer,
+ 0, 0
+ );
+ wl_surface_damage(
+ window->surface,
+ 0, 0, win_width, win_height
+ );
+
+ window->callback = wl_surface_frame(window->surface);
+ wl_callback_add_listener(window->callback, &frame_listener, window);
+ sleep(1);
+}
+
+
+static const struct wl_callback_listener frame_listener = {
+ redraw
+};
+
+static void
+display_handle_global(struct wl_display *display, uint32_t id,
+ const char *interface, uint32_t version, void *data)
+{
+ struct display *d = data;
+
+ if (strcmp(interface, "wl_compositor") == 0) {
+ d->compositor =
+ wl_display_bind(display, id, &wl_compositor_interface);
+ } else if (strcmp(interface, "wl_shell") == 0) {
+ d->shell = wl_display_bind(display, id, &wl_shell_interface);
+ } else if (strcmp(interface, "wl_input_device") == 0) {
+ d->input = wl_display_bind(display, id, &wl_input_device_interface);
+ // wl_input_device_add_listener(d->input, &input_listener, d);
+ }
+}
+
+static void
+handle_ping(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t serial)
+{
+ wl_shell_surface_pong(shell_surface, serial);
+}
+
+static void
+handle_configure(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t edges, int32_t width, int32_t height)
+{
+ struct window *window = data;
+
+ window->geometry.width = width;
+ window->geometry.height = height;
+}
+
+static void
+handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static const struct wl_shell_surface_listener shell_surface_listener = {
+ handle_ping,
+ handle_configure,
+ handle_popup_done
+};
+
+static int
+event_mask_update(uint32_t mask, void *data)
+{
+ struct display *d = data;
+
+ d->mask = mask;
+
+ return 0;
+}
+int main(int argc, char **argv)
+{
+
+ struct display dpy;
+ struct window win;
+ int running = 1;
+ win.format = WL_DRM_FORMAT_XRGB8888;
+ char c=0;
+
+ while ((c =getopt(argc,argv,"c:w:h:?") ) != EOF) {
+ switch (c) {
+ case '?':
+ printf("./wayland_drm_test -c (XRGB/YUYV) -w window_width -h window_height\n");
+ exit(0);
+ break;
+ case 'c':
+ if (!strcmp(optarg, "YUYV")) {
+ win.format = WL_DRM_FORMAT_YUYV;
+ }
+ break;
+ case 'w':
+ win_width = atoi(optarg);
+ break;
+ case 'h':
+ win_height = atoi(optarg);
+ break;
+ default:
+ printf("./wayland_drm_test -c (XRGB/YUYV) -w window_width -h window_height\n");
+ exit(0);
+ break;
+ }
+ }
+
+ win.geometry.width = win_width;
+ win.geometry.height = win_height;
+
+ // wl_display connection
+ dpy.display = wl_display_connect(NULL);
+ assert(dpy.display);
+
+ wl_display_add_global_listener(dpy.display,
+ display_handle_global, &dpy);
+
+ wl_display_get_fd(dpy.display, event_mask_update, &dpy);
+ wl_display_iterate(dpy.display, WL_DISPLAY_READABLE);
+
+ // create wl_surface
+ win.surface = wl_compositor_create_surface(dpy.compositor);
+ win.shell_surface = wl_shell_get_shell_surface(dpy.shell,
+ win.surface);
+
+ wl_shell_surface_add_listener(win.shell_surface, &shell_surface_listener, &win);
+
+ wl_shell_surface_set_toplevel(win.shell_surface);
+
+ // wayland drm initialization
+ wayland_drm_init(dpy.display);
+ if(!wayland_server_support_yuyv) {
+ win.format = WL_DRM_FORMAT_XRGB8888;
+ }
+
+ // create buffer object
+ dpy.gbm = gbm_create_device(drm_fd);
+ win.gbm_bo = gbm_bo_create(dpy.gbm, win_width, win_height, win.format, GBM_BO_USE_RENDERING|GBM_BO_USE_WRITE);
+ win.bo_pitch = gbm_bo_get_pitch(win.gbm_bo);
+
+ unsigned int buf_name = gbm_bo_get_handle2(win.gbm_bo).u32;
+
+ // create wl_buffer
+ struct wl_buffer *buffer = wl_drm_create_buffer(wl_drm, buf_name, win_width, win_height, win.bo_pitch, win.format);
+ win.buffer = buffer;
+ redraw (&win, NULL, 0);
+
+ while (running) {
+ wl_display_iterate(dpy.display, dpy.mask);
+ sleep(0.3);
+ }
+
+ wayland_drm_finalize();
+
+ gbm_bo_destroy(win.gbm_bo);
+
+ wl_shell_surface_destroy(win.shell_surface);
+ wl_surface_destroy(win.surface);
+
+ if (win.callback)
+ wl_callback_destroy(win.callback);
+
+ if (dpy.shell)
+ wl_shell_destroy(dpy.shell);
+
+ if (dpy.compositor)
+ wl_compositor_destroy(dpy.compositor);
+
+ wl_display_flush(dpy.display);
+ wl_display_disconnect(dpy.display);
+
+ return 0;
+}
+
diff --git a/clients/wayland-drm-client-protocol.h b/clients/wayland-drm-client-protocol.h
new file mode 100644
index 0000000..453da9b
--- /dev/null
+++ b/clients/wayland-drm-client-protocol.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright © 2008-2011 Kristian Høgsberg
+ * Copyright © 2010-2011 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#ifndef DRM_CLIENT_PROTOCOL_H
+#define DRM_CLIENT_PROTOCOL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-util.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct wl_drm;
+
+extern const struct wl_interface wl_drm_interface;
+
+#ifndef WL_DRM_ERROR_ENUM
+#define WL_DRM_ERROR_ENUM
+enum wl_drm_error {
+ WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
+ WL_DRM_ERROR_INVALID_FORMAT = 1,
+ WL_DRM_ERROR_INVALID_NAME = 2,
+};
+#endif /* WL_DRM_ERROR_ENUM */
+
+#ifndef WL_DRM_FORMAT_ENUM
+#define WL_DRM_FORMAT_ENUM
+enum wl_drm_format {
+ WL_DRM_FORMAT_C8 = 0x20203843,
+ WL_DRM_FORMAT_RGB332 = 0x38424752,
+ WL_DRM_FORMAT_BGR233 = 0x38524742,
+ WL_DRM_FORMAT_XRGB4444 = 0x32315258,
+ WL_DRM_FORMAT_XBGR4444 = 0x32314258,
+ WL_DRM_FORMAT_RGBX4444 = 0x32315852,
+ WL_DRM_FORMAT_BGRX4444 = 0x32315842,
+ WL_DRM_FORMAT_ARGB4444 = 0x32315241,
+ WL_DRM_FORMAT_ABGR4444 = 0x32314241,
+ WL_DRM_FORMAT_RGBA4444 = 0x32314152,
+ WL_DRM_FORMAT_BGRA4444 = 0x32314142,
+ WL_DRM_FORMAT_XRGB1555 = 0x35315258,
+ WL_DRM_FORMAT_XBGR1555 = 0x35314258,
+ WL_DRM_FORMAT_RGBX5551 = 0x35315852,
+ WL_DRM_FORMAT_BGRX5551 = 0x35315842,
+ WL_DRM_FORMAT_ARGB1555 = 0x35315241,
+ WL_DRM_FORMAT_ABGR1555 = 0x35314241,
+ WL_DRM_FORMAT_RGBA5551 = 0x35314152,
+ WL_DRM_FORMAT_BGRA5551 = 0x35314142,
+ WL_DRM_FORMAT_RGB565 = 0x36314752,
+ WL_DRM_FORMAT_BGR565 = 0x36314742,
+ WL_DRM_FORMAT_RGB888 = 0x34324752,
+ WL_DRM_FORMAT_BGR888 = 0x34324742,
+ WL_DRM_FORMAT_XRGB8888 = 0x34325258,
+ WL_DRM_FORMAT_XBGR8888 = 0x34324258,
+ WL_DRM_FORMAT_RGBX8888 = 0x34325852,
+ WL_DRM_FORMAT_BGRX8888 = 0x34325842,
+ WL_DRM_FORMAT_ARGB8888 = 0x34325241,
+ WL_DRM_FORMAT_ABGR8888 = 0x34324241,
+ WL_DRM_FORMAT_RGBA8888 = 0x34324152,
+ WL_DRM_FORMAT_BGRA8888 = 0x34324142,
+ WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
+ WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
+ WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
+ WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
+ WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
+ WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
+ WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
+ WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
+ WL_DRM_FORMAT_YUYV = 0x56595559,
+ WL_DRM_FORMAT_YVYU = 0x55595659,
+ WL_DRM_FORMAT_UYVY = 0x59565955,
+ WL_DRM_FORMAT_VYUY = 0x59555956,
+ WL_DRM_FORMAT_AYUV = 0x56555941,
+ WL_DRM_FORMAT_NV12 = 0x3231564e,
+ WL_DRM_FORMAT_NV21 = 0x3132564e,
+ WL_DRM_FORMAT_NV16 = 0x3631564e,
+ WL_DRM_FORMAT_NV61 = 0x3136564e,
+ WL_DRM_FORMAT_YUV410 = 0x39565559,
+ WL_DRM_FORMAT_YVU410 = 0x39555659,
+ WL_DRM_FORMAT_YUV411 = 0x31315559,
+ WL_DRM_FORMAT_YVU411 = 0x31315659,
+ WL_DRM_FORMAT_YUV420 = 0x32315559,
+ WL_DRM_FORMAT_YVU420 = 0x32315659,
+ WL_DRM_FORMAT_YUV422 = 0x36315559,
+ WL_DRM_FORMAT_YVU422 = 0x36315659,
+ WL_DRM_FORMAT_YUV444 = 0x34325559,
+ WL_DRM_FORMAT_YVU444 = 0x34325659,
+};
+#endif /* WL_DRM_FORMAT_ENUM */
+
+struct wl_drm_listener {
+ /**
+ * device - device
+ * @name: name
+ */
+ void (*device)(void *data,
+ struct wl_drm *wl_drm,
+ const char *name);
+ /**
+ * format - format
+ * @format: format
+ */
+ void (*format)(void *data,
+ struct wl_drm *wl_drm,
+ uint32_t format);
+ /**
+ * authenticated - authenticated
+ */
+ void (*authenticated)(void *data,
+ struct wl_drm *wl_drm);
+};
+
+static inline int
+wl_drm_add_listener(struct wl_drm *wl_drm,
+ const struct wl_drm_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DRM_AUTHENTICATE 0
+#define WL_DRM_CREATE_BUFFER 1
+
+static inline void
+wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
+}
+
+static inline void *
+wl_drm_get_user_data(struct wl_drm *wl_drm)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_destroy(struct wl_drm *wl_drm)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
+{
+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
+ WL_DRM_AUTHENTICATE, id);
+}
+
+static inline struct wl_buffer *
+wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
+{
+ 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_BUFFER, id, name, width, height, stride, format);
+
+ return (struct wl_buffer *) id;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/configure.ac b/configure.ac
index 9a029f1..5e0cd0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes)
if test x$enable_drm_compositor = xyes; then
AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm mtdev >= 1.1.0])
+ PKG_CHECK_MODULES(LIBGBM, [gbm])
fi
@@ -154,7 +155,7 @@ fi
AC_ARG_ENABLE(weston-launch, [ --enable-weston-launch],, enable_weston_launch=yes)
AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
if test x$enable_weston_launch == xyes; then
- PKG_CHECK_MODULES(WESTON_LAUNCH, [libdrm])
+ PKG_CHECK_MODULES(LIBDRM, [libdrm])
PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login],
[have_systemd_login=yes], [have_systemd_login=no])
AS_IF([test "x$have_systemd_login" = "xyes"],
@@ -164,7 +165,10 @@ if test x$enable_weston_launch == xyes; then
if test x$have_pam == xno; then
AC_ERROR([weston-launch requires pam])
fi
- WESTON_LAUNCH_LIBS="$WESTON_LAUNCH_LIBS -lpam"
+ WESTON_LAUNCH_LIBS="$LIBDRM_LIBS -lpam"
+ WESTON_LAUNCH_CFLAGS="$LIBDRM_CFLAGS"
+ AC_SUBST(WESTON_LAUNCH_LIBS)
+ AC_SUBST(WESTON_LAUNCH_CFLAGS)
fi
AM_CONDITIONAL(HAVE_POPPLER, test "x$have_poppler" = "xyes")
--
1.7.5.4
More information about the wayland-devel
mailing list