minigbm: gbm.h: organize our downstream patches
This patch series is not bisectable. BUG=b:145747113 TEST=compile Change-Id: I447e554f27e55e43a4f5d3ca8f1725eda46852fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1963001 Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
555ed29571
commit
e32ec0be67
4 changed files with 142 additions and 111 deletions
5
drv.c
5
drv.c
|
|
@ -542,11 +542,6 @@ uint32_t drv_bo_get_height(struct bo *bo)
|
|||
return bo->meta.height;
|
||||
}
|
||||
|
||||
uint32_t drv_bo_get_stride_or_tiling(struct bo *bo)
|
||||
{
|
||||
return bo->meta.tiling ? bo->meta.tiling : drv_bo_get_plane_stride(bo, 0);
|
||||
}
|
||||
|
||||
size_t drv_bo_get_num_planes(struct bo *bo)
|
||||
{
|
||||
return bo->meta.num_planes;
|
||||
|
|
|
|||
2
drv.h
2
drv.h
|
|
@ -149,8 +149,6 @@ uint32_t drv_bo_get_width(struct bo *bo);
|
|||
|
||||
uint32_t drv_bo_get_height(struct bo *bo);
|
||||
|
||||
uint32_t drv_bo_get_stride_or_tiling(struct bo *bo);
|
||||
|
||||
size_t drv_bo_get_num_planes(struct bo *bo);
|
||||
|
||||
union bo_handle drv_bo_get_plane_handle(struct bo *bo, size_t plane);
|
||||
|
|
|
|||
163
gbm.c
163
gbm.c
|
|
@ -174,7 +174,6 @@ PUBLIC struct gbm_bo *gbm_bo_import(struct gbm_device *gbm, uint32_t type, void
|
|||
struct gbm_bo *bo;
|
||||
struct drv_import_fd_data drv_data;
|
||||
struct gbm_import_fd_data *fd_data = buffer;
|
||||
struct gbm_import_fd_planar_data *fd_planar_data = buffer;
|
||||
struct gbm_import_fd_modifier_data *fd_modifier_data = buffer;
|
||||
uint32_t gbm_format;
|
||||
size_t num_planes, i, num_fds;
|
||||
|
|
@ -212,26 +211,6 @@ PUBLIC struct gbm_bo *gbm_bo_import(struct gbm_device *gbm, uint32_t type, void
|
|||
drv_data.format_modifiers[i] = fd_modifier_data->modifier;
|
||||
}
|
||||
|
||||
for (i = num_planes; i < GBM_MAX_PLANES; i++)
|
||||
drv_data.fds[i] = -1;
|
||||
|
||||
break;
|
||||
case GBM_BO_IMPORT_FD_PLANAR:
|
||||
gbm_format = fd_planar_data->format;
|
||||
drv_data.width = fd_planar_data->width;
|
||||
drv_data.height = fd_planar_data->height;
|
||||
drv_data.format = fd_planar_data->format;
|
||||
num_planes = drv_num_planes_from_format(drv_data.format);
|
||||
|
||||
assert(num_planes);
|
||||
|
||||
for (i = 0; i < num_planes; i++) {
|
||||
drv_data.fds[i] = fd_planar_data->fds[i];
|
||||
drv_data.offsets[i] = fd_planar_data->offsets[i];
|
||||
drv_data.strides[i] = fd_planar_data->strides[i];
|
||||
drv_data.format_modifiers[i] = fd_planar_data->format_modifiers[i];
|
||||
}
|
||||
|
||||
for (i = num_planes; i < GBM_MAX_PLANES; i++)
|
||||
drv_data.fds[i] = -1;
|
||||
|
||||
|
|
@ -258,30 +237,6 @@ PUBLIC struct gbm_bo *gbm_bo_import(struct gbm_device *gbm, uint32_t type, void
|
|||
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, size_t plane)
|
||||
{
|
||||
void *addr;
|
||||
off_t offset;
|
||||
uint32_t map_flags;
|
||||
struct rectangle rect = { .x = x, .y = y, .width = width, .height = height };
|
||||
if (!bo || width == 0 || height == 0 || !stride || !map_data)
|
||||
return NULL;
|
||||
|
||||
map_flags = (transfer_flags & GBM_BO_TRANSFER_READ) ? BO_MAP_READ : BO_MAP_NONE;
|
||||
map_flags |= (transfer_flags & GBM_BO_TRANSFER_WRITE) ? BO_MAP_WRITE : BO_MAP_NONE;
|
||||
|
||||
addr = drv_bo_map(bo->bo, &rect, map_flags, (struct mapping **)map_data, plane);
|
||||
if (addr == MAP_FAILED)
|
||||
return MAP_FAILED;
|
||||
|
||||
*stride = ((struct mapping *)*map_data)->vma->map_strides[plane];
|
||||
|
||||
offset = *stride * rect.y;
|
||||
offset += rect.x * drv_bytes_per_pixel_from_format(bo->gbm_format, plane);
|
||||
return (void *)((uint8_t *)addr + offset);
|
||||
}
|
||||
|
||||
PUBLIC void gbm_bo_unmap(struct gbm_bo *bo, void *map_data)
|
||||
{
|
||||
assert(bo);
|
||||
|
|
@ -303,24 +258,14 @@ PUBLIC uint32_t gbm_bo_get_stride(struct gbm_bo *bo)
|
|||
return gbm_bo_get_stride_for_plane(bo, 0);
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_stride_or_tiling(struct gbm_bo *bo)
|
||||
{
|
||||
return drv_bo_get_stride_or_tiling(bo->bo);
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_format(struct gbm_bo *bo)
|
||||
{
|
||||
return bo->gbm_format;
|
||||
}
|
||||
|
||||
PUBLIC uint64_t gbm_bo_get_format_modifier(struct gbm_bo *bo)
|
||||
{
|
||||
return gbm_bo_get_modifier(bo);
|
||||
}
|
||||
|
||||
PUBLIC uint64_t gbm_bo_get_modifier(struct gbm_bo *bo)
|
||||
{
|
||||
return gbm_bo_get_plane_format_modifier(bo, 0);
|
||||
return drv_bo_get_plane_format_modifier(bo->bo, 0);
|
||||
}
|
||||
|
||||
PUBLIC struct gbm_device *gbm_bo_get_device(struct gbm_bo *bo)
|
||||
|
|
@ -338,59 +283,24 @@ PUBLIC int gbm_bo_get_fd(struct gbm_bo *bo)
|
|||
return gbm_bo_get_plane_fd(bo, 0);
|
||||
}
|
||||
|
||||
PUBLIC size_t gbm_bo_get_num_planes(struct gbm_bo *bo)
|
||||
{
|
||||
return gbm_bo_get_plane_count(bo);
|
||||
}
|
||||
|
||||
PUBLIC size_t gbm_bo_get_plane_count(struct gbm_bo *bo)
|
||||
PUBLIC int gbm_bo_get_plane_count(struct gbm_bo *bo)
|
||||
{
|
||||
return drv_bo_get_num_planes(bo->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 union gbm_bo_handle gbm_bo_get_handle_for_plane(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return (union gbm_bo_handle)drv_bo_get_plane_handle(bo->bo, plane).u64;
|
||||
}
|
||||
|
||||
PUBLIC int gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_fd(bo->bo, plane);
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_plane_offset(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return gbm_bo_get_offset(bo, plane);
|
||||
return (union gbm_bo_handle)drv_bo_get_plane_handle(bo->bo, (size_t)plane).u64;
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_offset(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_offset(bo->bo, plane);
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_plane_size(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_size(bo->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);
|
||||
return drv_bo_get_plane_offset(bo->bo, (size_t)plane);
|
||||
}
|
||||
|
||||
PUBLIC uint32_t gbm_bo_get_stride_for_plane(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_stride(bo->bo, plane);
|
||||
}
|
||||
|
||||
PUBLIC uint64_t gbm_bo_get_plane_format_modifier(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_format_modifier(bo->bo, plane);
|
||||
return drv_bo_get_plane_stride(bo->bo, (size_t)plane);
|
||||
}
|
||||
|
||||
PUBLIC void gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
|
||||
|
|
@ -404,3 +314,66 @@ PUBLIC void *gbm_bo_get_user_data(struct gbm_bo *bo)
|
|||
{
|
||||
return bo->user_data;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are not deprecated, but not in the Mesa the gbm
|
||||
* header. The main difference is minigbm allows for the possibility of
|
||||
* disjoint YUV images, while Mesa GBM does not.
|
||||
*/
|
||||
PUBLIC uint32_t gbm_bo_get_plane_size(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
return drv_bo_get_plane_size(bo->bo, plane);
|
||||
}
|
||||
|
||||
PUBLIC int gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane)
|
||||
{
|
||||
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)
|
||||
{
|
||||
void *addr;
|
||||
off_t offset;
|
||||
uint32_t map_flags;
|
||||
plane = (size_t)plane;
|
||||
struct rectangle rect = { .x = x, .y = y, .width = width, .height = height };
|
||||
if (!bo || width == 0 || height == 0 || !stride || !map_data)
|
||||
return NULL;
|
||||
|
||||
map_flags = (transfer_flags & GBM_BO_TRANSFER_READ) ? BO_MAP_READ : BO_MAP_NONE;
|
||||
map_flags |= (transfer_flags & GBM_BO_TRANSFER_WRITE) ? BO_MAP_WRITE : BO_MAP_NONE;
|
||||
|
||||
addr = drv_bo_map(bo->bo, &rect, map_flags, (struct mapping **)map_data, plane);
|
||||
if (addr == MAP_FAILED)
|
||||
return MAP_FAILED;
|
||||
|
||||
*stride = ((struct mapping *)*map_data)->vma->map_strides[plane];
|
||||
|
||||
offset = *stride * rect.y;
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
83
gbm.h
83
gbm.h
|
|
@ -238,6 +238,39 @@ enum gbm_bo_flags {
|
|||
* Buffer is linear, i.e. not tiled.
|
||||
*/
|
||||
GBM_BO_USE_LINEAR = (1 << 4),
|
||||
/**
|
||||
* The buffer will be used as a texture that will be sampled from.
|
||||
*/
|
||||
GBM_BO_USE_TEXTURING = (1 << 5),
|
||||
/**
|
||||
* The buffer will be written to by a camera subsystem.
|
||||
*/
|
||||
GBM_BO_USE_CAMERA_WRITE = (1 << 6),
|
||||
/**
|
||||
* The buffer will be read from by a camera subsystem.
|
||||
*/
|
||||
GBM_BO_USE_CAMERA_READ = (1 << 7),
|
||||
/**
|
||||
* Buffer inaccessible to unprivileged users.
|
||||
*/
|
||||
GBM_BO_USE_PROTECTED = (1 << 8),
|
||||
/**
|
||||
* These flags specify the frequency of software access. These flags do not
|
||||
* guarantee the buffer is linear, but do guarantee gbm_bo_map(..) will
|
||||
* present a linear view.
|
||||
*/
|
||||
GBM_BO_USE_SW_READ_OFTEN = (1 << 9),
|
||||
GBM_BO_USE_SW_READ_RARELY = (1 << 10),
|
||||
GBM_BO_USE_SW_WRITE_OFTEN = (1 << 11),
|
||||
GBM_BO_USE_SW_WRITE_RARELY = (1 << 12),
|
||||
/**
|
||||
* The buffer will be written by a video decode accelerator.
|
||||
*/
|
||||
GBM_BO_USE_HW_VIDEO_DECODER = (1 << 13),
|
||||
/**
|
||||
* The buffer will be read by a video encode accelerator.
|
||||
*/
|
||||
GBM_BO_USE_HW_VIDEO_ENCODER = (1 << 14),
|
||||
};
|
||||
|
||||
int
|
||||
|
|
@ -275,7 +308,9 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
|
|||
#define GBM_BO_IMPORT_WL_BUFFER 0x5501
|
||||
#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
|
||||
#define GBM_BO_IMPORT_FD 0x5503
|
||||
#define GBM_BO_IMPORT_FD_MODIFIER 0x5504
|
||||
// Deprecated. Use GBM_BO_IMPORT_FD_MODIFIER instead.
|
||||
#define GBM_BO_IMPORT_FD_PLANAR 0x5504
|
||||
#define GBM_BO_IMPORT_FD_MODIFIER 0x5505
|
||||
|
||||
struct gbm_import_fd_data {
|
||||
int fd;
|
||||
|
|
@ -329,11 +364,6 @@ enum gbm_bo_transfer_flags {
|
|||
GBM_BO_TRANSFER_READ_WRITE = (GBM_BO_TRANSFER_READ | GBM_BO_TRANSFER_WRITE),
|
||||
};
|
||||
|
||||
void *
|
||||
gbm_bo_map(struct gbm_bo *bo,
|
||||
uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data);
|
||||
|
||||
void
|
||||
gbm_bo_unmap(struct gbm_bo *bo, void *map_data);
|
||||
|
||||
|
|
@ -347,7 +377,7 @@ uint32_t
|
|||
gbm_bo_get_stride(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane);
|
||||
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_format(struct gbm_bo *bo);
|
||||
|
|
@ -356,7 +386,7 @@ uint32_t
|
|||
gbm_bo_get_bpp(struct gbm_bo *bo);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_offset(struct gbm_bo *bo, int plane);
|
||||
gbm_bo_get_offset(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
struct gbm_device *
|
||||
gbm_bo_get_device(struct gbm_bo *bo);
|
||||
|
|
@ -374,7 +404,7 @@ int
|
|||
gbm_bo_get_plane_count(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane);
|
||||
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
int
|
||||
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
|
||||
|
|
@ -416,6 +446,41 @@ gbm_surface_destroy(struct gbm_surface *surface);
|
|||
char *
|
||||
gbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc);
|
||||
|
||||
|
||||
#ifndef MINIGBM
|
||||
#define MINIGBM
|
||||
#endif
|
||||
/*
|
||||
* The following functions are not deprecated, but not in the Mesa the gbm
|
||||
* header. The main difference is minigbm allows for the possibility of
|
||||
* disjoint YUV images, while Mesa GBM does not.
|
||||
*/
|
||||
uint32_t
|
||||
gbm_bo_get_plane_size(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
int
|
||||
gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
void *
|
||||
gbm_bo_map(struct gbm_bo *bo,
|
||||
uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint32_t flags, uint32_t *stride, void **map_data, size_t plane);
|
||||
|
||||
/*
|
||||
* The following functions are deprecated. They can be removed * once crbug.com/946907 is fixed.
|
||||
*/
|
||||
size_t
|
||||
gbm_bo_get_num_planes(struct gbm_bo *bo);
|
||||
|
||||
union gbm_bo_handle
|
||||
gbm_bo_get_plane_handle(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_plane_offset(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
uint32_t
|
||||
gbm_bo_get_plane_stride(struct gbm_bo *bo, size_t plane);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue