[Mesa-dev] [Patch 2/4] Improve wayland-drm basing on gbm to act as generic buffer manager for wayland

Zhao, Halley halley.zhao at intel.com
Thu Apr 19 03:20:44 PDT 2012


Send half of the first patch.
This patch is just term change from drm to gbm in source files.

By the way:
I still got the message of "Message body is too big: 164397 bytes with a limit of 128 KB", though the total size of my patch is 38K.
Anyway, try to send it first.


diff --git a/src/gallium/state_trackers/egl/drm/native_drm.h b/src/gallium/state_trackers/egl/drm/native_drm.h
index 18cebf4..2ef98db 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.h
+++ b/src/gallium/state_trackers/egl/drm/native_drm.h
@@ -70,7 +70,7 @@ struct drm_display {
    struct drm_crtc *saved_crtcs;
 #ifdef HAVE_WAYLAND_BACKEND
-   struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+   struct wl_gbm *wl_server_gbm; /* for EGL_WL_bind_wayland_display */
#endif
};
diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c
old mode 100644
new mode 100755
index e3bd628..6b011ce
--- a/src/gallium/state_trackers/egl/wayland/native_drm.c
+++ b/src/gallium/state_trackers/egl/wayland/native_drm.c
@@ -53,8 +53,8 @@ struct wayland_drm_display {
    const struct native_event_handler *event_handler;
-   struct wl_drm *wl_drm;
-   struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+   struct wl_gbm *wl_gbm;
+   struct wl_gbm *wl_server_gbm; /* for EGL_WL_bind_wayland_display */
    int fd;
    char *device_name;
    boolean authenticated;
@@ -73,8 +73,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
    if (drmdpy->fd)
       close(drmdpy->fd);
-   if (drmdpy->wl_drm)
-      wl_drm_destroy(drmdpy->wl_drm);
+   if (drmdpy->wl_gbm)
+      wl_gbm_destroy(drmdpy->wl_gbm);
    if (drmdpy->device_name)
      FREE(drmdpy->device_name);
    if (drmdpy->base.configs)
@@ -97,7 +97,7 @@ wayland_create_drm_buffer(struct wayland_display *display,
    struct pipe_resource *resource;
    struct winsys_handle wsh;
    uint width, height;
-   enum wl_drm_format format;
+   enum wl_gbm_format format;
    resource = resource_surface_get_single_resource(surface->rsurf, attachment);
    resource_surface_get_size(surface->rsurf, &width, &height);
@@ -109,22 +109,22 @@ wayland_create_drm_buffer(struct wayland_display *display,
    switch (surface->color_format) {
    case PIPE_FORMAT_B8G8R8A8_UNORM:
-      format = WL_DRM_FORMAT_ARGB8888;
+      format = WL_GBM_FORMAT_ARGB8888;
       break;
    case PIPE_FORMAT_B8G8R8X8_UNORM:
-      format = WL_DRM_FORMAT_XRGB8888;
+      format = WL_GBM_FORMAT_XRGB8888;
       break;
    default:
       return NULL;
       break;
    }
-   return wl_drm_create_buffer(drmdpy->wl_drm, wsh.handle,
+   return wl_gbm_create_buffer(drmdpy->wl_gbm, wsh.handle,
                                width, height, wsh.stride, format);
}
 static void
-drm_handle_device(void *data, struct wl_drm *drm, const char *device)
+drm_handle_device(void *data, struct wl_gbm *drm, const char *device)
{
    struct wayland_drm_display *drmdpy = data;
    drm_magic_t magic;
@@ -149,33 +149,33 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
    }
    drmGetMagic(drmdpy->fd, &magic);
-   wl_drm_authenticate(drmdpy->wl_drm, magic);
+   wl_gbm_authenticate(drmdpy->wl_gbm, magic);
}
 static void
-drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+drm_handle_format(void *data, struct wl_gbm *drm, uint32_t format)
{
    struct wayland_drm_display *drmdpy = data;
    switch (format) {
-   case WL_DRM_FORMAT_ARGB8888:
+   case WL_GBM_FORMAT_ARGB8888:
       drmdpy->base.formats |= HAS_ARGB8888;
       break;
-   case WL_DRM_FORMAT_XRGB8888:
+   case WL_GBM_FORMAT_XRGB8888:
       drmdpy->base.formats |= HAS_XRGB8888;
       break;
    }
}
 static void
-drm_handle_authenticated(void *data, struct wl_drm *drm)
+drm_handle_authenticated(void *data, struct wl_gbm *drm)
{
    struct wayland_drm_display *drmdpy = data;
    drmdpy->authenticated = true;
}
-static const struct wl_drm_listener drm_listener = {
+static const struct wl_gbm_listener drm_listener = {
    drm_handle_device,
    drm_handle_format,
    drm_handle_authenticated
@@ -187,18 +187,18 @@ wayland_drm_display_init_screen(struct native_display *ndpy)
    struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
    uint32_t id;
-   id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
+   id = wl_display_get_global(drmdpy->base.dpy, "wl_gbm", 1);
    if (id == 0)
       wl_display_roundtrip(drmdpy->base.dpy);
-   id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
+   id = wl_display_get_global(drmdpy->base.dpy, "wl_gbm", 1);
    if (id == 0)
       return FALSE;
-   drmdpy->wl_drm = wl_display_bind(drmdpy->base.dpy, id, &wl_drm_interface);
-   if (!drmdpy->wl_drm)
+   drmdpy->wl_gbm = wl_display_bind(drmdpy->base.dpy, id, &wl_gbm_interface);
+   if (!drmdpy->wl_gbm)
       return FALSE;
-   wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy);
+   wl_gbm_add_listener(drmdpy->wl_gbm, &drm_listener, drmdpy);
    wl_display_roundtrip(drmdpy->base.dpy);
    if (drmdpy->fd == -1)
       return FALSE;
@@ -238,7 +238,7 @@ wayland_drm_display_authenticate(void *user_data, uint32_t magic)
    current_authenticate = drmdpy->authenticated;
-   wl_drm_authenticate(drmdpy->wl_drm, magic);
+   wl_gbm_authenticate(drmdpy->wl_gbm, magic);
    wl_display_roundtrip(drmdpy->base.dpy);
    authenticated = drmdpy->authenticated;
@@ -247,10 +247,10 @@ wayland_drm_display_authenticate(void *user_data, uint32_t magic)
    return authenticated ? 0 : -1;
}
-static struct wayland_drm_callbacks wl_drm_callbacks = {
+static struct wayland_gbm_callbacks wl_gbm_callbacks = {
    wayland_drm_display_authenticate,
-   egl_g3d_wl_drm_helper_reference_buffer,
-   egl_g3d_wl_drm_helper_unreference_buffer
+   egl_g3d_wl_gbm_helper_reference_buffer,
+   egl_g3d_wl_gbm_helper_unreference_buffer
};
 static boolean
@@ -259,14 +259,14 @@ wayland_drm_display_bind_wayland_display(struct native_display *ndpy,
{
    struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
-   if (drmdpy->wl_server_drm)
+   if (drmdpy->wl_server_gbm)
       return FALSE;
-   drmdpy->wl_server_drm =
-      wayland_drm_init(wl_dpy, drmdpy->device_name,
-                       &wl_drm_callbacks, ndpy);
+   drmdpy->wl_server_gbm =
+      wayland_gbm_init(wl_dpy, drmdpy->device_name,
+                       &wl_gbm_callbacks, ndpy);
-   if (!drmdpy->wl_server_drm)
+   if (!drmdpy->wl_server_gbm)
       return FALSE;

    return TRUE;
@@ -278,11 +278,11 @@ wayland_drm_display_unbind_wayland_display(struct native_display *ndpy,
{
    struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
-   if (!drmdpy->wl_server_drm)
+   if (!drmdpy->wl_server_gbm)
       return FALSE;
-   wayland_drm_uninit(drmdpy->wl_server_drm);
-   drmdpy->wl_server_drm = NULL;
+   wayland_gbm_uninit(drmdpy->wl_server_gbm);
+   drmdpy->wl_server_gbm = NULL;
    return TRUE;
}
@@ -290,7 +290,7 @@ wayland_drm_display_unbind_wayland_display(struct native_display *ndpy,
static struct native_display_wayland_bufmgr wayland_drm_display_wayland_bufmgr = {
    wayland_drm_display_bind_wayland_display,
    wayland_drm_display_unbind_wayland_display,
-   egl_g3d_wl_drm_common_wl_buffer_get_resource
+   egl_g3d_wl_gbm_common_wl_buffer_get_resource
};

diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 5d7d379..75ef09b 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -62,7 +62,7 @@ struct dri2_display {
    struct util_hash_table *surfaces;
#ifdef HAVE_WAYLAND_BACKEND
-   struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+   struct wl_gbm *wl_server_gbm; /* for EGL_WL_bind_wayland_display */
#endif
};
@@ -847,10 +847,10 @@ dri2_display_authenticate(void *user_data, uint32_t magic)
    return x11_screen_authenticate(dri2dpy->xscr, magic);
}
-static struct wayland_drm_callbacks wl_drm_callbacks = {
+static struct wayland_gbm_callbacks wl_gbm_callbacks = {
    dri2_display_authenticate,
-   egl_g3d_wl_drm_helper_reference_buffer,
-   egl_g3d_wl_drm_helper_unreference_buffer
+   egl_g3d_wl_gbm_helper_reference_buffer,
+   egl_g3d_wl_gbm_helper_unreference_buffer
};
 static boolean
@@ -859,14 +859,14 @@ dri2_display_bind_wayland_display(struct native_display *ndpy,
{
    struct dri2_display *dri2dpy = dri2_display(ndpy);
-   if (dri2dpy->wl_server_drm)
+   if (dri2dpy->wl_server_gbm)
       return FALSE;
-   dri2dpy->wl_server_drm = wayland_drm_init(wl_dpy,
+   dri2dpy->wl_server_gbm = wayland_gbm_init(wl_dpy,
          x11_screen_get_device_name(dri2dpy->xscr),
-         &wl_drm_callbacks, ndpy);
+         &wl_gbm_callbacks, ndpy);
-   if (!dri2dpy->wl_server_drm)
+   if (!dri2dpy->wl_server_gbm)
       return FALSE;

    return TRUE;
@@ -878,11 +878,11 @@ dri2_display_unbind_wayland_display(struct native_display *ndpy,
{
    struct dri2_display *dri2dpy = dri2_display(ndpy);
-   if (!dri2dpy->wl_server_drm)
+   if (!dri2dpy->wl_server_gbm)
       return FALSE;
-   wayland_drm_uninit(dri2dpy->wl_server_drm);
-   dri2dpy->wl_server_drm = NULL;
+   wayland_gbm_uninit(dri2dpy->wl_server_gbm);
+   dri2dpy->wl_server_gbm = NULL;
    return TRUE;
}
@@ -890,7 +890,7 @@ dri2_display_unbind_wayland_display(struct native_display *ndpy,
static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
    dri2_display_bind_wayland_display,
    dri2_display_unbind_wayland_display,
-   egl_g3d_wl_drm_common_wl_buffer_get_resource
+   egl_g3d_wl_gbm_common_wl_buffer_get_resource
};
 #endif /* HAVE_WAYLAND_BACKEND */
--
1.7.5.4

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120419/e01ed82f/attachment-0001.html>


More information about the mesa-dev mailing list