-I$(top_srcdir)/include \
-I$(top_srcdir)/src/gbm/main \
$(LIBUDEV_CFLAGS) \
+ $(LIBKMS_CFLAGS) \
$(DLOPEN_CFLAGS) \
$(DEFINES)
main/backend.c \
main/common.c
libgbm_la_LDFLAGS = -version-info 1:0
-libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(DLOPEN_LIBS)
+libgbm_la_LIBADD = $(LIBUDEV_LIBS) $(LIBKMS_LIBS) $(DLOPEN_LIBS)
if HAVE_EGL_PLATFORM_WAYLAND
AM_CPPFLAGS = -DHAVE_WAYLAND_PLATFORM
static int
gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count)
{
- struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+ void *ptr;
+ int ret;
+
+ if (bo->bo == NULL)
+ return -1;
- if (dri->image->base.version < 4)
+ ret = kms_bo_map(bo->bo, &ptr);
+ if (ret < 0)
return -1;
- return dri->image->write(bo->image, buf, count);
+ memcpy(ptr, buf, count);
+
+ kms_bo_unmap(bo->bo);
+ return 0;
}
static void
struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
- dri->image->destroyImage(bo->image);
+ if (bo->image != NULL)
+ dri->image->destroyImage(bo->image);
+ if (bo->bo != NULL)
+ kms_bo_destroy(&bo->bo);
free(bo);
}
int dri_format;
unsigned dri_use = 0;
- if (dri->image->base.version < 4 && (usage & GBM_BO_USE_WRITE))
- return NULL;
-
bo = calloc(1, sizeof *bo);
if (bo == NULL)
return NULL;
bo->base.base.width = width;
bo->base.base.height = height;
+ if (usage & GBM_BO_USE_WRITE) {
+ int ret;
+ unsigned attrs[7] = {
+ KMS_WIDTH, 64,
+ KMS_HEIGHT, 64,
+ KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8,
+ KMS_TERMINATE_PROP_LIST,
+ };
+
+ if (!(usage & GBM_BO_USE_CURSOR_64X64))
+ return NULL;
+
+ if (dri->kms == NULL)
+ return NULL;
+
+ ret = kms_bo_create(dri->kms, attrs, &bo->bo);
+ if (ret < 0) {
+ free(bo);
+ return NULL;
+ }
+
+ kms_bo_get_prop(bo->bo, KMS_PITCH, &bo->base.base.stride);
+ kms_bo_get_prop(bo->bo, KMS_HANDLE, (unsigned*)&bo->base.base.handle);
+
+ return &bo->base.base;
+ }
+
switch (format) {
case GBM_FORMAT_RGB565:
dri_format =__DRI_IMAGE_FORMAT_RGB565;
dri->base.type = GBM_DRM_DRIVER_TYPE_DRI;
dri->base.base.name = "drm";
+ kms_create(fd, &dri->kms);
+ if (dri->kms == NULL)
+ goto err_kms;
+
ret = dri_screen_create(dri);
- if (ret) {
- free(dri);
- return NULL;
- }
+ if (ret)
+ goto err_dri;
return &dri->base.base;
+
+err_dri:
+ kms_destroy(&dri->kms);
+err_kms:
+ free(dri);
+ return NULL;
}
struct gbm_backend gbm_dri_backend = {