uint64_t cros_gralloc_convert_flags(int flags)
{
- uint64_t usage = DRV_BO_USE_NONE;
+ uint64_t usage = BO_USE_NONE;
if (flags & GRALLOC_USAGE_CURSOR)
- usage |= DRV_BO_USE_CURSOR;
- if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_RARELY)
- usage |= DRV_BO_USE_SW_READ_RARELY;
- if ((flags & sw_read()) == GRALLOC_USAGE_SW_READ_OFTEN)
- usage |= DRV_BO_USE_SW_READ_OFTEN;
- if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_RARELY)
- usage |= DRV_BO_USE_SW_WRITE_RARELY;
- if ((flags & sw_write()) == GRALLOC_USAGE_SW_WRITE_OFTEN)
- usage |= DRV_BO_USE_SW_WRITE_OFTEN;
+ 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 |= DRV_BO_USE_RENDERING;
+ usage |= BO_USE_TEXTURE;
if (flags & GRALLOC_USAGE_HW_RENDER)
- usage |= DRV_BO_USE_RENDERING;
+ usage |= BO_USE_RENDERING;
if (flags & GRALLOC_USAGE_HW_2D)
- usage |= DRV_BO_USE_RENDERING;
+ usage |= BO_USE_RENDERING;
if (flags & GRALLOC_USAGE_HW_COMPOSER)
- /* HWC wants to use display hardware, but can defer to OpenGL. */
- usage |= DRV_BO_USE_SCANOUT | DRV_BO_USE_RENDERING;
+ /* HWC wants to use display hardware, but can defer to OpenGL. */
+ usage |= BO_USE_SCANOUT | BO_USE_RENDERING;
if (flags & GRALLOC_USAGE_HW_FB)
- usage |= DRV_BO_USE_SCANOUT;
+ usage |= BO_USE_NONE;
if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
- /* We're ignoring this flag until we decide what to with display link */
- usage |= DRV_BO_USE_NONE;
+ /* We're ignoring this flag until we decide what to with display link */
+ usage |= BO_USE_NONE;
if (flags & GRALLOC_USAGE_PROTECTED)
- usage |= DRV_BO_USE_PROTECTED;
+ usage |= BO_USE_PROTECTED;
if (flags & GRALLOC_USAGE_HW_VIDEO_ENCODER)
/*HACK: See b/30054495 */
- usage |= DRV_BO_USE_SW_READ_OFTEN;
+ usage |= BO_USE_SW_READ_OFTEN;
if (flags & GRALLOC_USAGE_HW_CAMERA_WRITE)
- usage |= DRV_BO_USE_HW_CAMERA_WRITE;
+ usage |= BO_USE_HW_CAMERA_WRITE;
if (flags & GRALLOC_USAGE_HW_CAMERA_READ)
- usage |= DRV_BO_USE_HW_CAMERA_READ;
+ usage |= BO_USE_HW_CAMERA_READ;
if (flags & GRALLOC_USAGE_HW_CAMERA_ZSL)
- usage |= DRV_BO_USE_HW_CAMERA_ZSL;
+ usage |= BO_USE_HW_CAMERA_ZSL;
if (flags & GRALLOC_USAGE_RENDERSCRIPT)
- usage |= DRV_BO_USE_RENDERSCRIPT;
+ /* We use CPU for compute. */
+ usage |= BO_USE_LINEAR;
return usage;
}
case HAL_PIXEL_FORMAT_YCbCr_420_888:
return DRM_FORMAT_FLEX_YCbCr_420_888;
case HAL_PIXEL_FORMAT_YV12:
- return DRM_FORMAT_YVU420;
+ return DRM_FORMAT_YVU420_ANDROID;
+ /*
+ * Choose DRM_FORMAT_R8 because <system/graphics.h> requires the buffers
+ * with a format HAL_PIXEL_FORMAT_BLOB have a height of 1, and width
+ * equal to their size in bytes.
+ */
+ case HAL_PIXEL_FORMAT_BLOB:
+ return DRM_FORMAT_R8;
}
return DRM_FORMAT_NONE;
}
-static int32_t cros_gralloc_query_rendernode(struct driver **drv,
- const char *name)
+static int32_t cros_gralloc_query_rendernode(struct driver **drv, const char *undesired)
{
- /* TODO(gsingh): Enable render nodes on udl/evdi. */
+ /*
+ * Create a driver from rendernode while filtering out
+ * the specified undesired driver.
+ *
+ * TODO(gsingh): Enable render nodes on udl/evdi.
+ */
+
int fd;
drmVersionPtr version;
char const *str = "%s/renderD%d";
continue;
version = drmGetVersion(fd);
+ if (!version)
+ continue;
- if (version && name && !strcmp(version->name, name)) {
+ if (undesired && !strcmp(version->name, undesired)) {
drmFreeVersion(version);
continue;
}
int32_t cros_gralloc_rendernode_open(struct driver **drv)
{
int32_t ret;
- ret = cros_gralloc_query_rendernode(drv, NULL);
+ ret = cros_gralloc_query_rendernode(drv, "vgem");
- /* Look for vgem driver if no hardware is found. */
+ /* Allow vgem driver if no hardware is found. */
if (ret)
- ret = cros_gralloc_query_rendernode(drv, "vgem");
+ ret = cros_gralloc_query_rendernode(drv, NULL);
return ret;
}
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;
}
-void cros_gralloc_log(const char *prefix, const char *file, int line,
- const char *format, ...)
+void cros_gralloc_log(const char *prefix, const char *file, int line, const char *format, ...)
{
+ char buf[50];
+ snprintf(buf, sizeof(buf), "[%s:%s(%d)]", prefix, basename(file), line);
+
va_list args;
va_start(args, format);
- ALOGE("%s - [%s(%d)]", prefix, basename(file), line);
- __android_log_vprint(ANDROID_LOG_ERROR, prefix, format, args);
+ __android_log_vprint(ANDROID_LOG_ERROR, buf, format, args);
va_end(args);
}