minigbm: standardize naming of buffer creation flags
We use the terms "flags" and "usage" interchangeably in this repo,
since they essentally mean the same thing. However, let's be a
little more consistent since it's kind of confusing, especially
when buffer map flags come to play. Let's:
- refer to everything in the drv_* layer as use_flags
- refer to everything in the gbm/gralloc layers as
usages
BUG=chromium:764871
TEST=emerge-eve {arc-cros-gralloc, minigbm}
Change-Id: If987d72369b895f38cde87e50ce1080f78f2a084
Reviewed-on: https://chromium-review.googlesource.com/691423
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
This commit is contained in:
parent
60ee5833b1
commit
a1892b2800
21 changed files with 190 additions and 187 deletions
33
amdgpu.c
33
amdgpu.c
|
|
@ -135,7 +135,7 @@ static ADDR_E_RETURNCODE ADDR_API free_sys_mem(const ADDR_FREESYSMEM_INPUT *in)
|
|||
}
|
||||
|
||||
static int amdgpu_addrlib_compute(void *addrlib, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t usage, uint32_t *tiling_flags,
|
||||
uint64_t use_flags, uint32_t *tiling_flags,
|
||||
ADDR_COMPUTE_SURFACE_INFO_OUTPUT *addr_out)
|
||||
{
|
||||
ADDR_COMPUTE_SURFACE_INFO_INPUT addr_surf_info_in = { 0 };
|
||||
|
|
@ -147,7 +147,8 @@ static int amdgpu_addrlib_compute(void *addrlib, uint32_t width, uint32_t height
|
|||
|
||||
/* Set the requested tiling mode. */
|
||||
addr_surf_info_in.tileMode = ADDR_TM_2D_TILED_THIN1;
|
||||
if (usage & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
|
||||
if (use_flags &
|
||||
(BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
|
||||
addr_surf_info_in.tileMode = ADDR_TM_LINEAR_ALIGNED;
|
||||
else if (width <= 16 || height <= 16)
|
||||
addr_surf_info_in.tileMode = ADDR_TM_1D_TILED_THIN1;
|
||||
|
|
@ -166,7 +167,7 @@ static int amdgpu_addrlib_compute(void *addrlib, uint32_t width, uint32_t height
|
|||
addr_surf_info_in.flags.noStencil = 1;
|
||||
|
||||
/* Set the micro tile type. */
|
||||
if (usage & BO_USE_SCANOUT)
|
||||
if (use_flags & BO_USE_SCANOUT)
|
||||
addr_surf_info_in.tileType = ADDR_DISPLAYABLE;
|
||||
else
|
||||
addr_surf_info_in.tileType = ADDR_NON_DISPLAYABLE;
|
||||
|
|
@ -273,7 +274,7 @@ static int amdgpu_init(struct driver *drv)
|
|||
int ret;
|
||||
void *addrlib;
|
||||
struct format_metadata metadata;
|
||||
uint64_t flags = BO_USE_RENDER_MASK;
|
||||
uint64_t use_flags = BO_USE_RENDER_MASK;
|
||||
|
||||
addrlib = amdgpu_addrlib_init(drv_get_fd(drv));
|
||||
if (!addrlib)
|
||||
|
|
@ -294,7 +295,7 @@ static int amdgpu_init(struct driver *drv)
|
|||
metadata.modifier = DRM_FORMAT_MOD_NONE;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -307,19 +308,19 @@ static int amdgpu_init(struct driver *drv)
|
|||
metadata.modifier = DRM_FORMAT_MOD_NONE;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
flags &= ~BO_USE_LINEAR;
|
||||
use_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
use_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
use_flags &= ~BO_USE_LINEAR;
|
||||
|
||||
metadata.tiling = ADDR_DISPLAYABLE << 16 | ADDR_TM_2D_TILED_THIN1;
|
||||
metadata.priority = 4;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -331,7 +332,7 @@ static int amdgpu_init(struct driver *drv)
|
|||
metadata.priority = 5;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -345,7 +346,7 @@ static void amdgpu_close(struct driver *drv)
|
|||
}
|
||||
|
||||
static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t usage)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
void *addrlib = bo->drv->priv;
|
||||
union drm_amdgpu_gem_create gem_create;
|
||||
|
|
@ -359,7 +360,7 @@ static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint
|
|||
if (format == DRM_FORMAT_NV12 || format == DRM_FORMAT_NV21) {
|
||||
drv_bo_from_format(bo, ALIGN(width, 64), height, format);
|
||||
} else {
|
||||
if (amdgpu_addrlib_compute(addrlib, width, height, format, usage, &tiling_flags,
|
||||
if (amdgpu_addrlib_compute(addrlib, width, height, format, use_flags, &tiling_flags,
|
||||
&addr_out) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -370,8 +371,8 @@ static int amdgpu_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint
|
|||
bo->strides[0] = addr_out.pixelPitch * DIV_ROUND_UP(addr_out.pixelBits, 8);
|
||||
}
|
||||
|
||||
if (usage & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN |
|
||||
BO_USE_SW_WRITE_RARELY | BO_USE_SW_READ_RARELY))
|
||||
if (use_flags & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN |
|
||||
BO_USE_SW_WRITE_OFTEN | BO_USE_SW_WRITE_RARELY | BO_USE_SW_READ_RARELY))
|
||||
gem_create_flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
|
||||
else
|
||||
gem_create_flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
|
||||
|
|
@ -418,7 +419,7 @@ static void *amdgpu_bo_map(struct bo *bo, struct map_info *data, size_t plane, i
|
|||
return mmap(0, bo->total_size, prot, MAP_SHARED, bo->drv->fd, gem_map.out.addr_ptr);
|
||||
}
|
||||
|
||||
static uint32_t amdgpu_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t amdgpu_resolve_format(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_YCbCr_420_888:
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ bool cros_gralloc_driver::is_supported(const struct cros_gralloc_buffer_descript
|
|||
{
|
||||
struct combination *combo;
|
||||
uint32_t resolved_format;
|
||||
resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->drv_usage);
|
||||
combo = drv_get_combination(drv_, resolved_format, descriptor->drv_usage);
|
||||
resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags);
|
||||
combo = drv_get_combination(drv_, resolved_format, descriptor->use_flags);
|
||||
return (combo != nullptr);
|
||||
}
|
||||
|
||||
|
|
@ -94,9 +94,9 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
|
|||
struct bo *bo;
|
||||
struct cros_gralloc_handle *hnd;
|
||||
|
||||
resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->drv_usage);
|
||||
resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags);
|
||||
bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format,
|
||||
descriptor->drv_usage);
|
||||
descriptor->use_flags);
|
||||
if (!bo) {
|
||||
cros_gralloc_error("Failed to create bo.");
|
||||
return -ENOMEM;
|
||||
|
|
@ -133,8 +133,8 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
|
|||
hnd->width = drv_bo_get_width(bo);
|
||||
hnd->height = drv_bo_get_height(bo);
|
||||
hnd->format = drv_bo_get_format(bo);
|
||||
hnd->flags[0] = static_cast<uint32_t>(descriptor->drv_usage >> 32);
|
||||
hnd->flags[1] = static_cast<uint32_t>(descriptor->drv_usage);
|
||||
hnd->use_flags[0] = static_cast<uint32_t>(descriptor->use_flags >> 32);
|
||||
hnd->use_flags[1] = static_cast<uint32_t>(descriptor->use_flags);
|
||||
hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
|
||||
hnd->magic = cros_gralloc_magic;
|
||||
hnd->droid_format = descriptor->droid_format;
|
||||
|
|
@ -182,8 +182,8 @@ int32_t cros_gralloc_driver::retain(buffer_handle_t handle)
|
|||
data.format = hnd->format;
|
||||
data.width = hnd->width;
|
||||
data.height = hnd->height;
|
||||
data.flags = static_cast<uint64_t>(hnd->flags[0]) << 32;
|
||||
data.flags |= hnd->flags[1];
|
||||
data.use_flags = static_cast<uint64_t>(hnd->use_flags[0]) << 32;
|
||||
data.use_flags |= hnd->use_flags[1];
|
||||
|
||||
memcpy(data.fds, hnd->fds, sizeof(data.fds));
|
||||
memcpy(data.strides, hnd->strides, sizeof(data.strides));
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ struct cros_gralloc_handle {
|
|||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format; /* DRM format */
|
||||
uint32_t flags[2]; /* driver creation time flags */
|
||||
uint32_t use_flags[2]; /* Buffer creation flags */
|
||||
uint32_t magic;
|
||||
uint32_t pixel_stride;
|
||||
int32_t droid_format;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ struct cros_gralloc_buffer_descriptor {
|
|||
uint32_t producer_usage;
|
||||
uint32_t droid_format;
|
||||
uint32_t drm_format;
|
||||
uint64_t drv_usage;
|
||||
uint64_t use_flags;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,50 +32,50 @@ enum {
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
static int64_t gralloc0_convert_flags(int flags)
|
||||
static uint64_t gralloc0_convert_usage(int usage)
|
||||
{
|
||||
uint64_t usage = BO_USE_NONE;
|
||||
uint64_t use_flags = BO_USE_NONE;
|
||||
|
||||
if (flags & GRALLOC_USAGE_CURSOR)
|
||||
usage |= BO_USE_NONE;
|
||||
if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
|
||||
usage |= BO_USE_SW_READ_RARELY;
|
||||
if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
|
||||
usage |= BO_USE_SW_READ_OFTEN;
|
||||
if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
|
||||
usage |= BO_USE_SW_WRITE_RARELY;
|
||||
if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
|
||||
usage |= BO_USE_SW_WRITE_OFTEN;
|
||||
if (flags & GRALLOC_USAGE_HW_TEXTURE)
|
||||
usage |= BO_USE_TEXTURE;
|
||||
if (flags & GRALLOC_USAGE_HW_RENDER)
|
||||
usage |= BO_USE_RENDERING;
|
||||
if (flags & GRALLOC_USAGE_HW_2D)
|
||||
usage |= BO_USE_RENDERING;
|
||||
if (flags & GRALLOC_USAGE_HW_COMPOSER)
|
||||
if (usage & GRALLOC_USAGE_CURSOR)
|
||||
use_flags |= BO_USE_NONE;
|
||||
if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
|
||||
use_flags |= BO_USE_SW_READ_RARELY;
|
||||
if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
|
||||
use_flags |= BO_USE_SW_READ_OFTEN;
|
||||
if ((usage & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
|
||||
use_flags |= BO_USE_SW_WRITE_RARELY;
|
||||
if ((usage & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
|
||||
use_flags |= BO_USE_SW_WRITE_OFTEN;
|
||||
if (usage & GRALLOC_USAGE_HW_TEXTURE)
|
||||
use_flags |= BO_USE_TEXTURE;
|
||||
if (usage & GRALLOC_USAGE_HW_RENDER)
|
||||
use_flags |= BO_USE_RENDERING;
|
||||
if (usage & GRALLOC_USAGE_HW_2D)
|
||||
use_flags |= BO_USE_RENDERING;
|
||||
if (usage & GRALLOC_USAGE_HW_COMPOSER)
|
||||
/* HWC wants to use display hardware, but can defer to OpenGL. */
|
||||
usage |= BO_USE_SCANOUT | BO_USE_TEXTURE;
|
||||
if (flags & GRALLOC_USAGE_HW_FB)
|
||||
usage |= BO_USE_NONE;
|
||||
if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
|
||||
use_flags |= BO_USE_SCANOUT | BO_USE_TEXTURE;
|
||||
if (usage & GRALLOC_USAGE_HW_FB)
|
||||
use_flags |= BO_USE_NONE;
|
||||
if (usage & GRALLOC_USAGE_EXTERNAL_DISP)
|
||||
/*
|
||||
* This flag potentially covers external display for the normal drivers (i915,
|
||||
* rockchip) and usb monitors (evdi/udl). It's complicated so ignore it.
|
||||
* */
|
||||
usage |= BO_USE_NONE;
|
||||
if (flags & GRALLOC_USAGE_PROTECTED)
|
||||
usage |= BO_USE_PROTECTED;
|
||||
if (flags & GRALLOC_USAGE_HW_VIDEO_ENCODER)
|
||||
use_flags |= BO_USE_NONE;
|
||||
if (usage & GRALLOC_USAGE_PROTECTED)
|
||||
use_flags |= BO_USE_PROTECTED;
|
||||
if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
|
||||
/*HACK: See b/30054495 */
|
||||
usage |= BO_USE_SW_READ_OFTEN;
|
||||
if (flags & GRALLOC_USAGE_HW_CAMERA_WRITE)
|
||||
usage |= BO_USE_CAMERA_WRITE;
|
||||
if (flags & GRALLOC_USAGE_HW_CAMERA_READ)
|
||||
usage |= BO_USE_CAMERA_READ;
|
||||
if (flags & GRALLOC_USAGE_RENDERSCRIPT)
|
||||
usage |= BO_USE_RENDERSCRIPT;
|
||||
use_flags |= BO_USE_SW_READ_OFTEN;
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE)
|
||||
use_flags |= BO_USE_CAMERA_WRITE;
|
||||
if (usage & GRALLOC_USAGE_HW_CAMERA_READ)
|
||||
use_flags |= BO_USE_CAMERA_READ;
|
||||
if (usage & GRALLOC_USAGE_RENDERSCRIPT)
|
||||
use_flags |= BO_USE_RENDERSCRIPT;
|
||||
|
||||
return usage;
|
||||
return use_flags;
|
||||
}
|
||||
|
||||
static int gralloc0_alloc(alloc_device_t *dev, int w, int h, int format, int usage,
|
||||
|
|
@ -91,19 +91,19 @@ static int gralloc0_alloc(alloc_device_t *dev, int w, int h, int format, int usa
|
|||
descriptor.droid_format = format;
|
||||
descriptor.producer_usage = descriptor.consumer_usage = usage;
|
||||
descriptor.drm_format = cros_gralloc_convert_format(format);
|
||||
descriptor.drv_usage = gralloc0_convert_flags(usage);
|
||||
descriptor.use_flags = gralloc0_convert_usage(usage);
|
||||
|
||||
supported = mod->driver->is_supported(&descriptor);
|
||||
if (!supported && (usage & GRALLOC_USAGE_HW_COMPOSER)) {
|
||||
descriptor.drv_usage &= ~BO_USE_SCANOUT;
|
||||
descriptor.use_flags &= ~BO_USE_SCANOUT;
|
||||
supported = mod->driver->is_supported(&descriptor);
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
cros_gralloc_error("Unsupported combination -- HAL format: %u, HAL flags: %u, "
|
||||
"drv_format: %4.4s, drv_flags: %llu",
|
||||
cros_gralloc_error("Unsupported combination -- HAL format: %u, HAL usage: %u, "
|
||||
"drv_format: %4.4s, use_flags: %llu",
|
||||
format, usage, reinterpret_cast<char *>(&descriptor.drm_format),
|
||||
static_cast<unsigned long long>(descriptor.drv_usage));
|
||||
static_cast<unsigned long long>(descriptor.use_flags));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ static int gralloc0_lock_async(struct gralloc_module_t const *module, buffer_han
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
flags = gralloc0_convert_flags(usage);
|
||||
flags = gralloc0_convert_usage(usage);
|
||||
ret = mod->driver->lock(handle, fence_fd, flags, addr);
|
||||
*vaddr = addr[0];
|
||||
return ret;
|
||||
|
|
@ -332,7 +332,7 @@ static int gralloc0_lock_async_ycbcr(struct gralloc_module_t const *module, buff
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
flags = gralloc0_convert_flags(usage);
|
||||
flags = gralloc0_convert_usage(usage);
|
||||
ret = mod->driver->lock(handle, fence_fd, flags, addr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
22
drv.c
22
drv.c
|
|
@ -194,18 +194,18 @@ const char *drv_get_name(struct driver *drv)
|
|||
return drv->backend->name;
|
||||
}
|
||||
|
||||
struct combination *drv_get_combination(struct driver *drv, uint32_t format, uint64_t usage)
|
||||
struct combination *drv_get_combination(struct driver *drv, uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
struct combination *curr, *best;
|
||||
|
||||
if (format == DRM_FORMAT_NONE || usage == BO_USE_NONE)
|
||||
if (format == DRM_FORMAT_NONE || use_flags == BO_USE_NONE)
|
||||
return 0;
|
||||
|
||||
best = NULL;
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv->combos.size; i++) {
|
||||
curr = &drv->combos.data[i];
|
||||
if ((format == curr->format) && usage == (curr->usage & usage))
|
||||
if ((format == curr->format) && use_flags == (curr->use_flags & use_flags))
|
||||
if (!best || best->metadata.priority < curr->metadata.priority)
|
||||
best = curr;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ struct combination *drv_get_combination(struct driver *drv, uint32_t format, uin
|
|||
}
|
||||
|
||||
struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
|
||||
struct bo *bo;
|
||||
|
|
@ -227,7 +227,7 @@ struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint3
|
|||
bo->width = width;
|
||||
bo->height = height;
|
||||
bo->format = format;
|
||||
bo->flags = flags;
|
||||
bo->use_flags = use_flags;
|
||||
bo->num_planes = drv_num_planes_from_format(format);
|
||||
|
||||
if (!bo->num_planes) {
|
||||
|
|
@ -239,18 +239,18 @@ struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint3
|
|||
}
|
||||
|
||||
struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
size_t plane;
|
||||
struct bo *bo;
|
||||
|
||||
bo = drv_bo_new(drv, width, height, format, flags);
|
||||
bo = drv_bo_new(drv, width, height, format, use_flags);
|
||||
|
||||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
ret = drv->backend->bo_create(bo, width, height, format, flags);
|
||||
ret = drv->backend->bo_create(bo, width, height, format, use_flags);
|
||||
|
||||
if (ret) {
|
||||
free(bo);
|
||||
|
|
@ -331,7 +331,7 @@ struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data)
|
|||
size_t plane;
|
||||
struct bo *bo;
|
||||
|
||||
bo = drv_bo_new(drv, data->width, data->height, data->format, data->flags);
|
||||
bo = drv_bo_new(drv, data->width, data->height, data->format, data->use_flags);
|
||||
|
||||
if (!bo)
|
||||
return NULL;
|
||||
|
|
@ -509,10 +509,10 @@ uint32_t drv_bo_get_format(struct bo *bo)
|
|||
return bo->format;
|
||||
}
|
||||
|
||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t usage)
|
||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
if (drv->backend->resolve_format)
|
||||
return drv->backend->resolve_format(format, usage);
|
||||
return drv->backend->resolve_format(format, use_flags);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
|
|
|||
10
drv.h
10
drv.h
|
|
@ -75,7 +75,7 @@ struct drv_import_fd_data {
|
|||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint64_t flags;
|
||||
uint64_t use_flags;
|
||||
};
|
||||
|
||||
struct map_info {
|
||||
|
|
@ -94,13 +94,13 @@ int drv_get_fd(struct driver *drv);
|
|||
|
||||
const char *drv_get_name(struct driver *drv);
|
||||
|
||||
struct combination *drv_get_combination(struct driver *drv, uint32_t format, uint64_t usage);
|
||||
struct combination *drv_get_combination(struct driver *drv, uint32_t format, uint64_t use_flags);
|
||||
|
||||
struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags);
|
||||
uint64_t use_flags);
|
||||
|
||||
struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags);
|
||||
uint64_t use_flags);
|
||||
|
||||
struct bo *drv_bo_create_with_modifiers(struct driver *drv, uint32_t width, uint32_t height,
|
||||
uint32_t format, const uint64_t *modifiers, uint32_t count);
|
||||
|
|
@ -140,7 +140,7 @@ uint32_t drv_bo_get_format(struct bo *bo);
|
|||
|
||||
uint32_t drv_bo_get_stride_in_pixels(struct bo *bo);
|
||||
|
||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t usage);
|
||||
uint32_t drv_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags);
|
||||
|
||||
size_t drv_num_planes_from_format(uint32_t format);
|
||||
|
||||
|
|
|
|||
10
drv_priv.h
10
drv_priv.h
|
|
@ -26,7 +26,7 @@ struct bo {
|
|||
uint32_t sizes[DRV_MAX_PLANES];
|
||||
uint32_t strides[DRV_MAX_PLANES];
|
||||
uint64_t format_modifiers[DRV_MAX_PLANES];
|
||||
uint64_t flags;
|
||||
uint64_t use_flags;
|
||||
size_t total_size;
|
||||
void *priv;
|
||||
};
|
||||
|
|
@ -34,7 +34,7 @@ struct bo {
|
|||
struct kms_item {
|
||||
uint32_t format;
|
||||
uint64_t modifier;
|
||||
uint64_t usage;
|
||||
uint64_t use_flags;
|
||||
};
|
||||
|
||||
struct format_metadata {
|
||||
|
|
@ -46,7 +46,7 @@ struct format_metadata {
|
|||
struct combination {
|
||||
uint32_t format;
|
||||
struct format_metadata metadata;
|
||||
uint64_t usage;
|
||||
uint64_t use_flags;
|
||||
};
|
||||
|
||||
struct combinations {
|
||||
|
|
@ -70,7 +70,7 @@ struct backend {
|
|||
int (*init)(struct driver *drv);
|
||||
void (*close)(struct driver *drv);
|
||||
int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags);
|
||||
uint64_t use_flags);
|
||||
int (*bo_create_with_modifiers)(struct bo *bo, uint32_t width, uint32_t height,
|
||||
uint32_t format, const uint64_t *modifiers, uint32_t count);
|
||||
int (*bo_destroy)(struct bo *bo);
|
||||
|
|
@ -78,7 +78,7 @@ struct backend {
|
|||
void *(*bo_map)(struct bo *bo, struct map_info *data, size_t plane, int prot);
|
||||
int (*bo_unmap)(struct bo *bo, struct map_info *data);
|
||||
int (*bo_flush)(struct bo *bo, struct map_info *data);
|
||||
uint32_t (*resolve_format)(uint32_t format, uint64_t usage);
|
||||
uint32_t (*resolve_format)(uint32_t format, uint64_t use_flags);
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
|
|
|
|||
2
exynos.c
2
exynos.c
|
|
@ -40,7 +40,7 @@ static int exynos_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int exynos_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
size_t plane;
|
||||
|
||||
|
|
|
|||
16
gbm.c
16
gbm.c
|
|
@ -30,14 +30,14 @@ PUBLIC const char *gbm_device_get_backend_name(struct gbm_device *gbm)
|
|||
|
||||
PUBLIC int gbm_device_is_format_supported(struct gbm_device *gbm, uint32_t format, uint32_t usage)
|
||||
{
|
||||
uint64_t drv_usage;
|
||||
uint64_t use_flags;
|
||||
|
||||
if (usage & GBM_BO_USE_CURSOR && usage & GBM_BO_USE_RENDERING)
|
||||
return 0;
|
||||
|
||||
drv_usage = gbm_convert_flags(usage);
|
||||
use_flags = gbm_convert_usage(usage);
|
||||
|
||||
return (drv_get_combination(gbm->drv, format, drv_usage) != NULL);
|
||||
return (drv_get_combination(gbm->drv, format, use_flags) != NULL);
|
||||
}
|
||||
|
||||
PUBLIC struct gbm_device *gbm_create_device(int fd)
|
||||
|
|
@ -65,7 +65,7 @@ PUBLIC void gbm_device_destroy(struct gbm_device *gbm)
|
|||
}
|
||||
|
||||
PUBLIC struct gbm_surface *gbm_surface_create(struct gbm_device *gbm, uint32_t width,
|
||||
uint32_t height, uint32_t format, uint32_t flags)
|
||||
uint32_t height, uint32_t format, uint32_t usage)
|
||||
{
|
||||
struct gbm_surface *surface = (struct gbm_surface *)malloc(sizeof(*surface));
|
||||
|
||||
|
|
@ -104,11 +104,11 @@ static struct gbm_bo *gbm_bo_new(struct gbm_device *gbm, uint32_t format)
|
|||
}
|
||||
|
||||
PUBLIC struct gbm_bo *gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height,
|
||||
uint32_t format, uint32_t flags)
|
||||
uint32_t format, uint32_t usage)
|
||||
{
|
||||
struct gbm_bo *bo;
|
||||
|
||||
if (!gbm_device_is_format_supported(gbm, format, flags))
|
||||
if (!gbm_device_is_format_supported(gbm, format, usage))
|
||||
return NULL;
|
||||
|
||||
bo = gbm_bo_new(gbm, format);
|
||||
|
|
@ -116,7 +116,7 @@ PUBLIC struct gbm_bo *gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint
|
|||
if (!bo)
|
||||
return NULL;
|
||||
|
||||
bo->bo = drv_bo_create(gbm->drv, width, height, format, gbm_convert_flags(flags));
|
||||
bo->bo = drv_bo_create(gbm->drv, width, height, format, gbm_convert_usage(usage));
|
||||
|
||||
if (!bo->bo) {
|
||||
free(bo);
|
||||
|
|
@ -170,7 +170,7 @@ PUBLIC struct gbm_bo *gbm_bo_import(struct gbm_device *gbm, uint32_t type, void
|
|||
size_t num_planes, i;
|
||||
|
||||
memset(&drv_data, 0, sizeof(drv_data));
|
||||
drv_data.flags = gbm_convert_flags(usage);
|
||||
drv_data.use_flags = gbm_convert_usage(usage);
|
||||
switch (type) {
|
||||
case GBM_BO_IMPORT_FD:
|
||||
gbm_format = fd_data->format;
|
||||
|
|
|
|||
|
|
@ -10,26 +10,26 @@
|
|||
#include "drv.h"
|
||||
#include "gbm.h"
|
||||
|
||||
uint64_t gbm_convert_flags(uint32_t flags)
|
||||
uint64_t gbm_convert_usage(uint32_t usage)
|
||||
{
|
||||
uint64_t usage = BO_USE_NONE;
|
||||
uint64_t use_flags = BO_USE_NONE;
|
||||
|
||||
if (flags & GBM_BO_USE_SCANOUT)
|
||||
usage |= BO_USE_SCANOUT;
|
||||
if (flags & GBM_BO_USE_CURSOR)
|
||||
usage |= BO_USE_CURSOR;
|
||||
if (flags & GBM_BO_USE_CURSOR_64X64)
|
||||
usage |= BO_USE_CURSOR_64X64;
|
||||
if (flags & GBM_BO_USE_RENDERING)
|
||||
usage |= BO_USE_RENDERING;
|
||||
if (flags & GBM_BO_USE_TEXTURING)
|
||||
usage |= BO_USE_TEXTURE;
|
||||
if (flags & GBM_BO_USE_LINEAR)
|
||||
usage |= BO_USE_LINEAR;
|
||||
if (flags & GBM_BO_USE_CAMERA_WRITE)
|
||||
usage |= BO_USE_CAMERA_WRITE;
|
||||
if (flags & GBM_BO_USE_CAMERA_READ)
|
||||
usage |= BO_USE_CAMERA_READ;
|
||||
if (usage & GBM_BO_USE_SCANOUT)
|
||||
use_flags |= BO_USE_SCANOUT;
|
||||
if (usage & GBM_BO_USE_CURSOR)
|
||||
use_flags |= BO_USE_CURSOR;
|
||||
if (usage & GBM_BO_USE_CURSOR_64X64)
|
||||
use_flags |= BO_USE_CURSOR_64X64;
|
||||
if (usage & GBM_BO_USE_RENDERING)
|
||||
use_flags |= BO_USE_RENDERING;
|
||||
if (usage & GBM_BO_USE_TEXTURING)
|
||||
use_flags |= BO_USE_TEXTURE;
|
||||
if (usage & GBM_BO_USE_LINEAR)
|
||||
use_flags |= BO_USE_LINEAR;
|
||||
if (usage & GBM_BO_USE_CAMERA_WRITE)
|
||||
use_flags |= BO_USE_CAMERA_WRITE;
|
||||
if (usage & GBM_BO_USE_CAMERA_READ)
|
||||
use_flags |= BO_USE_CAMERA_READ;
|
||||
|
||||
return usage;
|
||||
return use_flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@
|
|||
#ifndef GBM_HELPERS_H
|
||||
#define GBM_HELPERS_H
|
||||
|
||||
uint64_t gbm_convert_flags(uint32_t flags);
|
||||
uint64_t gbm_convert_usage(uint32_t usage);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
32
helpers.c
32
helpers.c
|
|
@ -182,7 +182,7 @@ int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height,
|
|||
}
|
||||
|
||||
int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
size_t plane;
|
||||
|
|
@ -406,7 +406,7 @@ uint32_t drv_log_base2(uint32_t value)
|
|||
}
|
||||
|
||||
int drv_add_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata,
|
||||
uint64_t usage)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
struct combinations *combos = &drv->combos;
|
||||
if (combos->size >= combos->allocations) {
|
||||
|
|
@ -423,18 +423,18 @@ int drv_add_combination(struct driver *drv, uint32_t format, struct format_metad
|
|||
combos->data[combos->size].metadata.priority = metadata->priority;
|
||||
combos->data[combos->size].metadata.tiling = metadata->tiling;
|
||||
combos->data[combos->size].metadata.modifier = metadata->modifier;
|
||||
combos->data[combos->size].usage = usage;
|
||||
combos->data[combos->size].use_flags = use_flags;
|
||||
combos->size++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drv_add_combinations(struct driver *drv, const uint32_t *formats, uint32_t num_formats,
|
||||
struct format_metadata *metadata, uint64_t usage)
|
||||
struct format_metadata *metadata, uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
uint32_t i;
|
||||
for (i = 0; i < num_formats; i++) {
|
||||
ret = drv_add_combination(drv, formats[i], metadata, usage);
|
||||
ret = drv_add_combination(drv, formats[i], metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -443,23 +443,23 @@ int drv_add_combinations(struct driver *drv, const uint32_t *formats, uint32_t n
|
|||
}
|
||||
|
||||
void drv_modify_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata,
|
||||
uint64_t usage)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
uint32_t i;
|
||||
struct combination *combo;
|
||||
/* Attempts to add the specified usage to an existing combination. */
|
||||
/* Attempts to add the specified flags to an existing combination. */
|
||||
for (i = 0; i < drv->combos.size; i++) {
|
||||
combo = &drv->combos.data[i];
|
||||
if (combo->format == format && combo->metadata.tiling == metadata->tiling &&
|
||||
combo->metadata.modifier == metadata->modifier)
|
||||
combo->usage |= usage;
|
||||
combo->use_flags |= use_flags;
|
||||
}
|
||||
}
|
||||
|
||||
struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items)
|
||||
{
|
||||
uint64_t flag, usage;
|
||||
struct kms_item *items;
|
||||
uint64_t plane_type, use_flag;
|
||||
uint32_t i, j, k, allocations, item_size;
|
||||
|
||||
drmModePlanePtr plane;
|
||||
|
|
@ -501,20 +501,20 @@ struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items)
|
|||
prop = drmModeGetProperty(drv->fd, props->props[j]);
|
||||
if (prop) {
|
||||
if (strcmp(prop->name, "type") == 0) {
|
||||
flag = props->prop_values[j];
|
||||
plane_type = props->prop_values[j];
|
||||
}
|
||||
|
||||
drmModeFreeProperty(prop);
|
||||
}
|
||||
}
|
||||
|
||||
switch (flag) {
|
||||
switch (plane_type) {
|
||||
case DRM_PLANE_TYPE_OVERLAY:
|
||||
case DRM_PLANE_TYPE_PRIMARY:
|
||||
usage = BO_USE_SCANOUT;
|
||||
use_flag = BO_USE_SCANOUT;
|
||||
break;
|
||||
case DRM_PLANE_TYPE_CURSOR:
|
||||
usage = BO_USE_CURSOR;
|
||||
use_flag = BO_USE_CURSOR;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -525,7 +525,7 @@ struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items)
|
|||
for (k = 0; k < item_size; k++) {
|
||||
if (items[k].format == plane->formats[j] &&
|
||||
items[k].modifier == DRM_FORMAT_MOD_NONE) {
|
||||
items[k].usage |= usage;
|
||||
items[k].use_flags |= use_flag;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -546,7 +546,7 @@ struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items)
|
|||
if (!found) {
|
||||
items[item_size].format = plane->formats[j];
|
||||
items[item_size].modifier = DRM_FORMAT_MOD_NONE;
|
||||
items[item_size].usage = usage;
|
||||
items[item_size].use_flags = use_flag;
|
||||
item_size++;
|
||||
}
|
||||
}
|
||||
|
|
@ -592,7 +592,7 @@ int drv_modify_linear_combinations(struct driver *drv)
|
|||
for (j = 0; j < drv->combos.size; j++) {
|
||||
combo = &drv->combos.data[j];
|
||||
if (items[i].format == combo->format)
|
||||
combo->usage |= BO_USE_SCANOUT;
|
||||
combo->use_flags |= BO_USE_SCANOUT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ uint32_t drv_stride_from_format(uint32_t format, uint32_t width, size_t plane);
|
|||
uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
|
||||
int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height, uint32_t format);
|
||||
int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags);
|
||||
uint64_t use_flags);
|
||||
int drv_dumb_bo_destroy(struct bo *bo);
|
||||
int drv_map_info_destroy(struct bo *bo);
|
||||
int drv_gem_bo_destroy(struct bo *bo);
|
||||
|
|
|
|||
52
i915.c
52
i915.c
|
|
@ -70,11 +70,11 @@ static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
|
|||
* buffers, so let's add this to our combinations, except for
|
||||
* cursor, which must not be tiled.
|
||||
*/
|
||||
combo->usage |= item->usage & ~BO_USE_CURSOR;
|
||||
combo->use_flags |= item->use_flags & ~BO_USE_CURSOR;
|
||||
}
|
||||
|
||||
if (combo->metadata.modifier == item->modifier)
|
||||
combo->usage |= item->usage;
|
||||
combo->use_flags |= item->use_flags;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -86,28 +86,28 @@ static int i915_add_combinations(struct driver *drv)
|
|||
uint32_t i, num_items;
|
||||
struct kms_item *items;
|
||||
struct format_metadata metadata;
|
||||
uint64_t render_flags, texture_flags;
|
||||
uint64_t render_use_flags, texture_use_flags;
|
||||
|
||||
render_flags = BO_USE_RENDER_MASK;
|
||||
texture_flags = BO_USE_TEXTURE_MASK;
|
||||
render_use_flags = BO_USE_RENDER_MASK;
|
||||
texture_use_flags = BO_USE_TEXTURE_MASK;
|
||||
|
||||
metadata.tiling = I915_TILING_NONE;
|
||||
metadata.priority = 1;
|
||||
metadata.modifier = DRM_FORMAT_MOD_NONE;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, render_flags);
|
||||
&metadata, render_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
|
||||
&metadata, texture_flags);
|
||||
&metadata, texture_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = drv_add_combinations(drv, tileable_texture_source_formats,
|
||||
ARRAY_SIZE(tileable_texture_source_formats), &metadata,
|
||||
texture_flags);
|
||||
texture_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -124,28 +124,28 @@ static int i915_add_combinations(struct driver *drv)
|
|||
drv_modify_combination(drv, DRM_FORMAT_R8, &metadata,
|
||||
BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
|
||||
|
||||
render_flags &= ~BO_USE_RENDERSCRIPT;
|
||||
render_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
render_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
render_flags &= ~BO_USE_LINEAR;
|
||||
render_use_flags &= ~BO_USE_RENDERSCRIPT;
|
||||
render_use_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
render_use_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
render_use_flags &= ~BO_USE_LINEAR;
|
||||
|
||||
texture_flags &= ~BO_USE_RENDERSCRIPT;
|
||||
texture_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
texture_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
texture_flags &= ~BO_USE_LINEAR;
|
||||
texture_use_flags &= ~BO_USE_RENDERSCRIPT;
|
||||
texture_use_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
texture_use_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
texture_use_flags &= ~BO_USE_LINEAR;
|
||||
|
||||
metadata.tiling = I915_TILING_X;
|
||||
metadata.priority = 2;
|
||||
metadata.modifier = I915_FORMAT_MOD_X_TILED;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, render_flags);
|
||||
&metadata, render_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = drv_add_combinations(drv, tileable_texture_source_formats,
|
||||
ARRAY_SIZE(tileable_texture_source_formats), &metadata,
|
||||
texture_flags);
|
||||
texture_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -154,13 +154,13 @@ static int i915_add_combinations(struct driver *drv)
|
|||
metadata.modifier = I915_FORMAT_MOD_Y_TILED;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, render_flags);
|
||||
&metadata, render_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = drv_add_combinations(drv, tileable_texture_source_formats,
|
||||
ARRAY_SIZE(tileable_texture_source_formats), &metadata,
|
||||
texture_flags);
|
||||
texture_use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ static int i915_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
size_t plane;
|
||||
|
|
@ -306,7 +306,7 @@ static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32
|
|||
struct drm_i915_gem_set_tiling gem_set_tiling;
|
||||
struct combination *combo;
|
||||
|
||||
combo = drv_get_combination(bo->drv, format, flags);
|
||||
combo = drv_get_combination(bo->drv, format, use_flags);
|
||||
if (!combo)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -430,7 +430,7 @@ static void *i915_bo_map(struct bo *bo, struct map_info *data, size_t plane, int
|
|||
struct drm_i915_gem_mmap gem_map;
|
||||
memset(&gem_map, 0, sizeof(gem_map));
|
||||
|
||||
if ((bo->flags & BO_USE_SCANOUT) && !(bo->flags & BO_USE_RENDERSCRIPT))
|
||||
if ((bo->use_flags & BO_USE_SCANOUT) && !(bo->use_flags & BO_USE_RENDERSCRIPT))
|
||||
gem_map.flags = I915_MMAP_WC;
|
||||
|
||||
gem_map.handle = bo->handles[0].u32;
|
||||
|
|
@ -488,18 +488,18 @@ static int i915_bo_flush(struct bo *bo, struct map_info *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t i915_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t i915_resolve_format(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
/* KBL camera subsystem requires NV12. */
|
||||
if (usage & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
if (use_flags & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
return DRM_FORMAT_NV12;
|
||||
/*HACK: See b/28671744 */
|
||||
return DRM_FORMAT_XBGR8888;
|
||||
case DRM_FORMAT_FLEX_YCbCr_420_888:
|
||||
/* KBL camera subsystem requires NV12. */
|
||||
if (usage & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
if (use_flags & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
return DRM_FORMAT_NV12;
|
||||
return DRM_FORMAT_YVU420;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static int mediatek_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int mediatek_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
size_t plane;
|
||||
|
|
@ -97,7 +97,7 @@ static void *mediatek_bo_map(struct bo *bo, struct map_info *data, size_t plane,
|
|||
|
||||
data->length = bo->total_size;
|
||||
|
||||
if (bo->flags & BO_USE_RENDERSCRIPT) {
|
||||
if (bo->use_flags & BO_USE_RENDERSCRIPT) {
|
||||
priv = calloc(1, sizeof(*priv));
|
||||
priv->cached_addr = calloc(1, bo->total_size);
|
||||
priv->gem_addr = addr;
|
||||
|
|
@ -131,7 +131,7 @@ static int mediatek_bo_flush(struct bo *bo, struct map_info *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t mediatek_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t mediatek_resolve_format(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
|
|
|
|||
19
rockchip.c
19
rockchip.c
|
|
@ -78,7 +78,7 @@ static int rockchip_add_kms_item(struct driver *drv, const struct kms_item *item
|
|||
{
|
||||
int ret;
|
||||
uint32_t i, j;
|
||||
uint64_t flags;
|
||||
uint64_t use_flags;
|
||||
struct combination *combo;
|
||||
struct format_metadata metadata;
|
||||
|
||||
|
|
@ -86,21 +86,22 @@ static int rockchip_add_kms_item(struct driver *drv, const struct kms_item *item
|
|||
combo = &drv->combos.data[i];
|
||||
if (combo->format == item->format) {
|
||||
if (item->modifier == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) {
|
||||
flags = BO_USE_RENDERING | BO_USE_SCANOUT | BO_USE_TEXTURE;
|
||||
use_flags = BO_USE_RENDERING | BO_USE_SCANOUT | BO_USE_TEXTURE;
|
||||
metadata.modifier = item->modifier;
|
||||
metadata.tiling = 0;
|
||||
metadata.priority = 2;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(texture_source_formats); j++) {
|
||||
if (item->format == texture_source_formats[j])
|
||||
flags &= ~BO_USE_RENDERING;
|
||||
use_flags &= ~BO_USE_RENDERING;
|
||||
}
|
||||
|
||||
ret = drv_add_combination(drv, item[i].format, &metadata, flags);
|
||||
ret =
|
||||
drv_add_combination(drv, item[i].format, &metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
combo->usage |= item->usage;
|
||||
combo->use_flags |= item->use_flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -231,7 +232,7 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint
|
|||
}
|
||||
|
||||
static int rockchip_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
uint64_t modifiers[] = { DRM_FORMAT_MOD_NONE };
|
||||
return rockchip_bo_create_with_modifiers(bo, width, height, format, modifiers,
|
||||
|
|
@ -262,7 +263,7 @@ static void *rockchip_bo_map(struct bo *bo, struct map_info *data, size_t plane,
|
|||
|
||||
data->length = bo->total_size;
|
||||
|
||||
if (bo->flags & BO_USE_RENDERSCRIPT) {
|
||||
if (bo->use_flags & BO_USE_RENDERSCRIPT) {
|
||||
priv = calloc(1, sizeof(*priv));
|
||||
priv->cached_addr = calloc(1, bo->total_size);
|
||||
priv->gem_addr = addr;
|
||||
|
|
@ -296,12 +297,12 @@ static int rockchip_bo_flush(struct bo *bo, struct map_info *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t rockchip_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t rockchip_resolve_format(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
/* Camera subsystem requires NV12. */
|
||||
if (usage & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
if (use_flags & (BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))
|
||||
return DRM_FORMAT_NV12;
|
||||
/*HACK: See b/28671744 */
|
||||
return DRM_FORMAT_XBGR8888;
|
||||
|
|
|
|||
17
tegra.c
17
tegra.c
|
|
@ -182,29 +182,29 @@ static int tegra_init(struct driver *drv)
|
|||
{
|
||||
int ret;
|
||||
struct format_metadata metadata;
|
||||
uint64_t flags = BO_USE_RENDER_MASK;
|
||||
uint64_t use_flags = BO_USE_RENDER_MASK;
|
||||
|
||||
metadata.tiling = NV_MEM_KIND_PITCH;
|
||||
metadata.priority = 1;
|
||||
metadata.modifier = DRM_FORMAT_MOD_NONE;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
|
||||
drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
|
||||
|
||||
flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
flags &= ~BO_USE_LINEAR;
|
||||
use_flags &= ~BO_USE_SW_WRITE_OFTEN;
|
||||
use_flags &= ~BO_USE_SW_READ_OFTEN;
|
||||
use_flags &= ~BO_USE_LINEAR;
|
||||
|
||||
metadata.tiling = NV_MEM_KIND_C32_2CRA;
|
||||
metadata.priority = 2;
|
||||
|
||||
ret = drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
|
||||
&metadata, flags);
|
||||
&metadata, use_flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -214,14 +214,15 @@ static int tegra_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int tegra_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
uint32_t size, stride, block_height_log2 = 0;
|
||||
enum nv_mem_kind kind = NV_MEM_KIND_PITCH;
|
||||
struct drm_tegra_gem_create gem_create;
|
||||
int ret;
|
||||
|
||||
if (flags & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
|
||||
if (use_flags &
|
||||
(BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
|
||||
compute_layout_linear(width, height, format, &stride, &size);
|
||||
else
|
||||
compute_layout_blocklinear(width, height, format, &kind, &block_height_log2,
|
||||
|
|
|
|||
2
vc4.c
2
vc4.c
|
|
@ -31,7 +31,7 @@ static int vc4_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int vc4_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
int ret;
|
||||
size_t plane;
|
||||
|
|
|
|||
2
vgem.c
2
vgem.c
|
|
@ -47,7 +47,7 @@ static int vgem_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32
|
|||
return drv_dumb_bo_create(bo, width, height, format, flags);
|
||||
}
|
||||
|
||||
static uint32_t vgem_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t vgem_resolve_format(uint32_t format, uint64_t flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ static int virtio_gpu_init(struct driver *drv)
|
|||
}
|
||||
|
||||
static int virtio_gpu_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
|
||||
uint64_t flags)
|
||||
uint64_t use_flags)
|
||||
{
|
||||
width = ALIGN(width, MESA_LLVMPIPE_TILE_SIZE);
|
||||
height = ALIGN(height, MESA_LLVMPIPE_TILE_SIZE);
|
||||
|
|
@ -44,10 +44,10 @@ static int virtio_gpu_bo_create(struct bo *bo, uint32_t width, uint32_t height,
|
|||
if (bo->format == DRM_FORMAT_YVU420_ANDROID)
|
||||
height = bo->height;
|
||||
|
||||
return drv_dumb_bo_create(bo, width, height, format, flags);
|
||||
return drv_dumb_bo_create(bo, width, height, format, use_flags);
|
||||
}
|
||||
|
||||
static uint32_t virtio_gpu_resolve_format(uint32_t format, uint64_t usage)
|
||||
static uint32_t virtio_gpu_resolve_format(uint32_t format, uint64_t use_flags)
|
||||
{
|
||||
switch (format) {
|
||||
case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue