gralloc: add cros_gralloc_convert_map_usage
This is to unify map usage conversion for gralloc frontends. BUG=b:199524294 TEST=build Change-Id: I488213ca889a98f39a86e0340a315052cb8f624f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3171104 Tested-by: Yiwei Zhang <zzyiwei@chromium.org> Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
parent
f58616e0e3
commit
b73dd1deac
4 changed files with 17 additions and 25 deletions
|
|
@ -122,6 +122,18 @@ uint64_t cros_gralloc_convert_usage(uint64_t usage)
|
|||
return use_flags;
|
||||
}
|
||||
|
||||
uint32_t cros_gralloc_convert_map_usage(uint64_t usage)
|
||||
{
|
||||
uint32_t map_flags = BO_MAP_NONE;
|
||||
|
||||
if (usage & GRALLOC_USAGE_SW_READ_MASK)
|
||||
map_flags |= BO_MAP_READ;
|
||||
if (usage & GRALLOC_USAGE_SW_WRITE_MASK)
|
||||
map_flags |= BO_MAP_WRITE;
|
||||
|
||||
return map_flags;
|
||||
}
|
||||
|
||||
cros_gralloc_handle_t cros_gralloc_convert_handle(buffer_handle_t handle)
|
||||
{
|
||||
auto hnd = reinterpret_cast<cros_gralloc_handle_t>(handle);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ uint32_t cros_gralloc_convert_format(int32_t format);
|
|||
|
||||
uint64_t cros_gralloc_convert_usage(uint64_t usage);
|
||||
|
||||
uint32_t cros_gralloc_convert_map_usage(uint64_t usage);
|
||||
|
||||
cros_gralloc_handle_t cros_gralloc_convert_handle(buffer_handle_t handle);
|
||||
|
||||
int32_t cros_gralloc_sync_wait(int32_t fence, bool close_fence);
|
||||
|
|
|
|||
|
|
@ -61,21 +61,8 @@ enum {
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
static uint32_t gralloc0_convert_map_usage(int map_usage)
|
||||
{
|
||||
uint32_t map_flags = BO_MAP_NONE;
|
||||
|
||||
if (map_usage & GRALLOC_USAGE_SW_READ_MASK)
|
||||
map_flags |= BO_MAP_READ;
|
||||
if (map_usage & GRALLOC_USAGE_SW_WRITE_MASK)
|
||||
map_flags |= BO_MAP_WRITE;
|
||||
|
||||
return map_flags;
|
||||
}
|
||||
|
||||
static int gralloc0_droid_yuv_format(int droid_format)
|
||||
{
|
||||
|
||||
return (droid_format == HAL_PIXEL_FORMAT_YCbCr_420_888 ||
|
||||
droid_format == HAL_PIXEL_FORMAT_YV12);
|
||||
}
|
||||
|
|
@ -366,7 +353,7 @@ static int gralloc0_lock_async(struct gralloc_module_t const *module, buffer_han
|
|||
assert(w >= 0);
|
||||
assert(h >= 0);
|
||||
|
||||
map_flags = gralloc0_convert_map_usage(usage);
|
||||
map_flags = cros_gralloc_convert_map_usage(static_cast<uint64_t>(usage));
|
||||
ret = mod->driver->lock(handle, fence_fd, true, &rect, map_flags, addr);
|
||||
*vaddr = addr[0];
|
||||
return ret;
|
||||
|
|
@ -418,7 +405,7 @@ static int gralloc0_lock_async_ycbcr(struct gralloc_module_t const *module, buff
|
|||
assert(w >= 0);
|
||||
assert(h >= 0);
|
||||
|
||||
map_flags = gralloc0_convert_map_usage(usage);
|
||||
map_flags = cros_gralloc_convert_map_usage(static_cast<uint64_t>(usage));
|
||||
ret = mod->driver->lock(handle, fence_fd, true, &rect, map_flags, addr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -82,16 +82,7 @@ int convertToCrosDescriptor(const BufferDescriptorInfo& descriptor,
|
|||
}
|
||||
|
||||
int convertToMapUsage(uint64_t grallocUsage, uint32_t* outMapUsage) {
|
||||
uint32_t mapUsage = BO_MAP_NONE;
|
||||
|
||||
if (grallocUsage & BufferUsage::CPU_READ_MASK) {
|
||||
mapUsage |= BO_MAP_READ;
|
||||
}
|
||||
if (grallocUsage & BufferUsage::CPU_WRITE_MASK) {
|
||||
mapUsage |= BO_MAP_WRITE;
|
||||
}
|
||||
|
||||
*outMapUsage = mapUsage;
|
||||
*outMapUsage = cros_gralloc_convert_map_usage(grallocUsage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue