hnd->base.version = sizeof(hnd->base);
hnd->base.numFds = num_planes;
- hnd->base.numInts = num_ints_handle() - num_planes;
+ hnd->base.numInts = num_ints_handle - num_planes;
for (size_t p = 0; p < num_planes; p++) {
hnd->fds[p] = drv_bo_get_plane_fd(bo, p);
hnd->format = drv_bo_get_format(bo);
hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
- hnd->magic = cros_gralloc_magic();
+ hnd->magic = cros_gralloc_magic;
return hnd;
}
if (flags & GRALLOC_USAGE_CURSOR)
usage |= BO_USE_NONE;
- if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_RARELY)
+ if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
usage |= BO_USE_SW_READ_RARELY;
- if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_OFTEN)
+ if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
usage |= BO_USE_SW_READ_OFTEN;
- if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_RARELY)
+ if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
usage |= BO_USE_SW_WRITE_RARELY;
- if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_OFTEN)
+ 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;
int32_t cros_gralloc_validate_handle(struct cros_gralloc_handle *hnd)
{
- if (!hnd || hnd->magic != cros_gralloc_magic())
+ if (!hnd || hnd->magic != cros_gralloc_magic)
return CROS_GRALLOC_ERROR_BAD_HANDLE;
return CROS_GRALLOC_ERROR_NONE;
};
// clang-format on
-constexpr uint32_t cros_gralloc_magic(void)
-{
- return 0xABCDDCBA;
-}
+constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
-constexpr uint32_t num_ints_handle()
-{
- return ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
-}
+constexpr uint32_t num_ints_handle = ((sizeof(struct cros_gralloc_handle)) / sizeof(int));
-constexpr uint32_t sw_access(void)
-{
- return GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
-}
-
-constexpr uint32_t sw_read(void)
-{
- return GRALLOC_USAGE_SW_READ_MASK;
-}
-
-constexpr uint32_t sw_write(void)
-{
- return GRALLOC_USAGE_SW_WRITE_MASK;
-}
+constexpr uint32_t sw_access = GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK;
uint64_t cros_gralloc_convert_flags(int flags);
return CROS_GRALLOC_ERROR_BAD_HANDLE;
}
- if (sw_access() & usage) {
+ if (sw_access & usage) {
if (bo->map_data) {
*vaddr = bo->map_data->addr;
} else {
return CROS_GRALLOC_ERROR_BAD_HANDLE;
}
- if (sw_access() & usage) {
+ if (sw_access & usage) {
void *vaddr;
if (bo->map_data) {
vaddr = bo->map_data->addr;