#include <xf86drm.h>
#include <xf86drmMode.h>
+#include <gbm.h>
+
#include "compositor.h"
struct drm_compositor {
struct {
int fd;
} drm;
+ struct gbm_device *gbm;
uint32_t crtc_allocator;
uint32_t connector_allocator;
struct tty *tty;
-
- PFNEGLCREATEDRMIMAGEMESA create_drm_image;
- PFNEGLEXPORTDRMIMAGEMESA export_drm_image;
};
struct drm_mode {
GLuint rbo[2];
uint32_t fb_id[2];
EGLImageKHR image[2];
+ struct gbm_bo *bo[2];
uint32_t current;
struct wlsc_surface *scanout_surface;
EGLint handle, stride;
int ret;
uint32_t fb_id = 0;
+ struct gbm_bo *bo;
if (es->x != output->base.x ||
es->y != output->base.y ||
es->image == EGL_NO_IMAGE_KHR)
return -1;
- c->export_drm_image(c->base.display,
- es->image, NULL, &handle, &stride);
+ bo = gbm_bo_create_from_egl_image(c->gbm,
+ c->base.display, es->image,
+ es->width, es->height,
+ GBM_BO_USE_SCANOUT);
+
+ handle = gbm_bo_get_handle(bo).s32;
+ stride = gbm_bo_get_pitch(bo);
+
+ gbm_bo_destroy(bo);
if (handle == 0)
return -1;
EGLint handle, stride;
int ret = -1;
pixman_region32_t cursor_region;
+ struct gbm_bo *bo;
if (eid == NULL) {
drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
if (eid->sprite->width > 64 || eid->sprite->height > 64)
goto out;
- c->export_drm_image(c->base.display, eid->sprite->image,
- NULL, &handle, &stride);
+ bo = gbm_bo_create_from_egl_image(c->gbm,
+ c->base.display,
+ eid->sprite->image, 64, 64,
+ GBM_BO_USE_CURSOR_64X64);
+
+ handle = gbm_bo_get_handle(bo).s32;
+ stride = gbm_bo_get_pitch(bo);
+
+ gbm_bo_destroy(bo);
if (stride != 64 * 4) {
fprintf(stderr, "info: cursor stride is != 64\n");
setenv("EGL_PLATFORM", "drm", 1);
ec->drm.fd = fd;
- ec->base.display = eglGetDisplay(FD_TO_EGL_NATIVE_DPY(ec->drm.fd));
+ ec->gbm = gbm_create_device(ec->drm.fd);
+ ec->base.display = eglGetDisplay(ec->gbm);
if (ec->base.display == NULL) {
fprintf(stderr, "failed to create display\n");
return -1;
struct drm_mode *drm_mode;
drmModeEncoder *encoder;
int i, ret;
- EGLint handle, stride, attribs[] = {
- EGL_WIDTH, 0,
- EGL_HEIGHT, 0,
- EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
- EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SCANOUT_MESA,
- EGL_NONE
- };
+ unsigned handle, stride;
encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[0]);
if (encoder == NULL) {
for (i = 0; i < 2; i++) {
glBindRenderbuffer(GL_RENDERBUFFER, output->rbo[i]);
- attribs[1] = output->base.current->width;
- attribs[3] = output->base.current->height;
- output->image[i] =
- ec->create_drm_image(ec->base.display, attribs);
+ output->bo[i] =
+ gbm_bo_create(ec->gbm,
+ output->base.current->width,
+ output->base.current->height,
+ GBM_BO_FORMAT_XRGB8888,
+ GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+ output->image[i] = ec->base.create_image(ec->base.display,
+ NULL,
+ EGL_NATIVE_PIXMAP_KHR,
+ output->bo[i], NULL);
+
+
ec->base.image_target_renderbuffer_storage(GL_RENDERBUFFER,
output->image[i]);
- ec->export_drm_image(ec->base.display, output->image[i],
- NULL, &handle, &stride);
+ stride = gbm_bo_get_pitch(output->bo[i]);
+ handle = gbm_bo_get_handle(output->bo[i]).u32;
ret = drmModeAddFB(ec->drm.fd,
output->base.current->width,
drm_compositor_create_cursor_image(struct wlsc_compositor *ec,
int32_t width, int32_t height)
{
- static const EGLint image_attribs[] = {
- EGL_WIDTH, 64,
- EGL_HEIGHT, 64,
- EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
- EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_CURSOR_MESA,
- EGL_NONE
- };
struct drm_compositor *c = (struct drm_compositor *) ec;
+ struct gbm_bo *bo;
+ EGLImageKHR image;
if (width > 64 || height > 64)
return EGL_NO_IMAGE_KHR;
- return c->create_drm_image(ec->display, image_attribs);
+ bo = gbm_bo_create(c->gbm,
+ /* width, height, */ 64, 64,
+ GBM_BO_FORMAT_ARGB8888,
+ GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_RENDERING);
+
+ image = ec->create_image(c->base.display, NULL,
+ EGL_NATIVE_PIXMAP_KHR, bo, NULL);
+ gbm_bo_destroy(bo);
+
+ return image;
}
static void
glGenFramebuffers(1, &ec->base.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo);
- ec->create_drm_image =
- (void *) eglGetProcAddress("eglCreateDRMImageMESA");
- ec->export_drm_image =
- (void *) eglGetProcAddress("eglExportDRMImageMESA");
-
/* Can't init base class until we have a current egl context */
if (wlsc_compositor_init(&ec->base, display) < 0)
return NULL;
#include <WF/wfd.h>
#include <WF/wfdext.h>
+#include <gbm.h>
+
#include "compositor.h"
struct wfd_compositor {
struct wlsc_compositor base;
struct udev *udev;
+ struct gbm_device *gbm;
WFDDevice dev;
WFDEvent event;
uint32_t start_time;
uint32_t used_pipelines;
-
- PFNEGLCREATEDRMIMAGEMESA create_drm_image;
- PFNEGLEXPORTDRMIMAGEMESA export_drm_image;
};
struct wfd_output {
WFDPortMode mode;
WFDSource source[2];
+ struct gbm_bo *bo[2];
EGLImageKHR image[2];
GLuint rbo[2];
uint32_t current;
ec->wfd_fd = fd;
setenv("EGL_PLATFORM", "drm", 1);
- ec->base.display = eglGetDisplay(FD_TO_EGL_NATIVE_DPY(ec->wfd_fd));
+ ec->gbm = gbm_create_device(ec->wfd_fd);
+ ec->base.display = eglGetDisplay(ec->gbm);
if (ec->base.display == NULL) {
fprintf(stderr, "failed to create display\n");
return -1;
{
struct wfd_output *output;
int i;
- EGLint attribs[] = {
- EGL_WIDTH, 0,
- EGL_HEIGHT, 0,
- EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
- EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SCANOUT_MESA,
- EGL_NONE
- };
WFDint num_pipelines, *pipelines;
WFDint num_modes;
WFDint rect[4] = { 0, 0, 0, 0 };
for (i = 0; i < 2; i++) {
glBindRenderbuffer(GL_RENDERBUFFER, output->rbo[i]);
- attribs[1] = output->base.current->width;
- attribs[3] = output->base.current->height;
- output->image[i] =
- ec->create_drm_image(ec->base.display, attribs);
+ output->bo[i] =
+ gbm_bo_create(ec->gbm,
+ output->base.current->width,
+ output->base.current->height,
+ GBM_BO_FORMAT_XRGB8888,
+ GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+ output->image[i] = ec->base.create_image(ec->base.display,
+ NULL,
+ EGL_NATIVE_PIXMAP_KHR,
+ output->bo[i], NULL);
printf("output->image[i]: %p\n", output->image[i]);
ec->base.image_target_renderbuffer_storage(GL_RENDERBUFFER,
output->image[i]);
- int handle;
- ec->export_drm_image(ec->base.display, output->image[i],
- NULL, &handle, NULL);
- printf("handle: %d\n", handle);
output->source[i] =
wfdCreateSourceFromImage(ec->dev, output->pipeline,
output->image[i], NULL);
for (i = 0; i < 2; i++) {
ec->base.destroy_image(ec->base.display, output->image[i]);
+ gbm_bo_destroy(output->bo[i]);
wfdDestroySource(ec->dev, output->source[i]);
}
if (wlsc_compositor_init(&ec->base, display) < 0)
return NULL;
- ec->create_drm_image =
- (void *) eglGetProcAddress("eglCreateDRMImageMESA");
- ec->export_drm_image =
- (void *) eglGetProcAddress("eglExportDRMImageMESA");
-
if (create_outputs(ec, connector) < 0) {
fprintf(stderr, "failed to create outputs\n");
return NULL;