return (drv_get_combination(gbm->drv, format, use_flags) != NULL);
}
+PUBLIC int gbm_device_get_format_modifier_plane_count(struct gbm_device *gbm, uint32_t format,
+ uint64_t modifier)
+{
+ return 0;
+}
+
PUBLIC struct gbm_device *gbm_create_device(int fd)
{
struct gbm_device *gbm;
return surface;
}
-PUBLIC void gbm_surface_destroy(struct gbm_surface *surface)
+PUBLIC struct gbm_surface *gbm_surface_create_with_modifiers(struct gbm_device *gbm, uint32_t width,
+ uint32_t height, uint32_t format,
+ const uint64_t *modifiers,
+ const unsigned int count)
{
- free(surface);
+ if (count != 0 || modifiers != NULL)
+ return NULL;
+
+ return gbm_surface_create(gbm, width, height, format, 0);
}
PUBLIC struct gbm_bo *gbm_surface_lock_front_buffer(struct gbm_surface *surface)
{
}
+PUBLIC int gbm_surface_has_free_buffers(struct gbm_surface *surface)
+{
+ return 0;
+}
+
+PUBLIC void gbm_surface_destroy(struct gbm_surface *surface)
+{
+ free(surface);
+}
+
static struct gbm_bo *gbm_bo_new(struct gbm_device *gbm, uint32_t format)
{
struct gbm_bo *bo;
uint32_t usage)
{
struct gbm_bo *bo;
- struct drv_import_fd_data drv_data;
+ struct drv_import_fd_data drv_data = { 0 };
struct gbm_import_fd_data *fd_data = buffer;
struct gbm_import_fd_modifier_data *fd_modifier_data = buffer;
uint32_t gbm_format;
size_t num_planes, i, num_fds;
- memset(&drv_data, 0, sizeof(drv_data));
drv_data.use_flags = gbm_convert_usage(usage);
switch (type) {
case GBM_BO_IMPORT_FD:
drv_data.format = fd_data->format;
drv_data.fds[0] = fd_data->fd;
drv_data.strides[0] = fd_data->stride;
+
+ for (i = 0; i < GBM_MAX_PLANES; ++i)
+ drv_data.format_modifiers[i] = DRM_FORMAT_MOD_INVALID;
break;
case GBM_BO_IMPORT_FD_MODIFIER:
gbm_format = fd_modifier_data->format;
drv_data.width = fd_modifier_data->width;
drv_data.height = fd_modifier_data->height;
drv_data.format = fd_modifier_data->format;
- num_planes = drv_num_planes_from_format(drv_data.format);
+ num_planes = drv_num_planes_from_modifier(gbm->drv, drv_data.format,
+ fd_modifier_data->modifier);
assert(num_planes);
num_fds = fd_modifier_data->num_fds;
return bo;
}
+PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
+ uint32_t transfer_flags, uint32_t *stride, void **map_data)
+{
+ return gbm_bo_map2(bo, x, y, width, height, transfer_flags, stride, map_data, 0);
+}
+
PUBLIC void gbm_bo_unmap(struct gbm_bo *bo, void *map_data)
{
assert(bo);
return bo->gbm_format;
}
+PUBLIC uint32_t gbm_bo_get_bpp(struct gbm_bo *bo)
+{
+ return drv_bytes_per_pixel_from_format(drv_bo_get_format(bo->bo), 0);
+}
+
PUBLIC uint64_t gbm_bo_get_modifier(struct gbm_bo *bo)
{
return drv_bo_get_plane_format_modifier(bo->bo, 0);
return bo->user_data;
}
+/* The two GBM_BO_FORMAT_[XA]RGB8888 formats alias the GBM_FORMAT_*
+ * formats of the same name. We want to accept them whenever someone
+ * has a GBM format, but never return them to the user.
+ */
+static uint32_t gbm_format_canonicalize(uint32_t gbm_format)
+{
+ switch (gbm_format) {
+ case GBM_BO_FORMAT_XRGB8888:
+ return GBM_FORMAT_XRGB8888;
+ case GBM_BO_FORMAT_ARGB8888:
+ return GBM_FORMAT_ARGB8888;
+ default:
+ return gbm_format;
+ }
+}
+
+/**
+ * Returns a string representing the fourcc format name.
+ */
+PUBLIC char *gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc)
+{
+ gbm_format = gbm_format_canonicalize(gbm_format);
+
+ desc->name[0] = gbm_format;
+ desc->name[1] = gbm_format >> 8;
+ desc->name[2] = gbm_format >> 16;
+ desc->name[3] = gbm_format >> 24;
+ desc->name[4] = 0;
+
+ return desc->name;
+}
+
/*
* The following functions are not deprecated, but not in the Mesa the gbm
* header. The main difference is minigbm allows for the possibility of
return drv_bo_get_plane_fd(bo->bo, plane);
}
-PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
- uint32_t transfer_flags, uint32_t *stride, void **map_data, size_t plane)
+PUBLIC void *gbm_bo_map2(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
+ uint32_t transfer_flags, uint32_t *stride, void **map_data, int plane)
{
void *addr;
off_t offset;
offset += rect.x * drv_bytes_per_pixel_from_format(bo->gbm_format, plane);
return (void *)((uint8_t *)addr + offset);
}
-
-/*
- * The following functions are deprecated. They can be removed * once crbug.com/946907 is fixed.
- */
-PUBLIC size_t gbm_bo_get_num_planes(struct gbm_bo *bo)
-{
- return gbm_bo_get_plane_count(bo);
-}
-
-PUBLIC union gbm_bo_handle gbm_bo_get_plane_handle(struct gbm_bo *bo, size_t plane)
-{
- return gbm_bo_get_handle_for_plane(bo, plane);
-}
-
-PUBLIC uint32_t gbm_bo_get_plane_offset(struct gbm_bo *bo, size_t plane)
-{
- return gbm_bo_get_offset(bo, plane);
-}
-
-PUBLIC uint32_t gbm_bo_get_plane_stride(struct gbm_bo *bo, size_t plane)
-{
- return gbm_bo_get_stride_for_plane(bo, plane);
-}