OSDN Git Service

minigbm: cros_gralloc: Do not lock gralloc_close
[android-x86/external-minigbm.git] / cros_gralloc / cros_gralloc_helpers.cc
index afb1a96..280e5f8 100644 (file)
@@ -17,27 +17,27 @@ uint64_t cros_gralloc_convert_flags(int flags)
 
        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_RENDERING;
+               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)
-       /* HWC wants to use display hardware, but can defer to OpenGL. */
+               /* 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 |= BO_USE_SCANOUT | BO_USE_RENDERING;
+               usage |= BO_USE_NONE;
        if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
-       /* We're ignoring this flag until we decide what to with display link */
+               /* We're ignoring this flag until we decide what to with display link */
                usage |= BO_USE_NONE;
        if (flags & GRALLOC_USAGE_PROTECTED)
                usage |= BO_USE_PROTECTED;
@@ -51,7 +51,8 @@ uint64_t cros_gralloc_convert_flags(int flags)
        if (flags & GRALLOC_USAGE_HW_CAMERA_ZSL)
                usage |= BO_USE_HW_CAMERA_ZSL;
        if (flags & GRALLOC_USAGE_RENDERSCRIPT)
-               usage |= BO_USE_RENDERSCRIPT;
+               /* We use CPU for compute. */
+               usage |= BO_USE_LINEAR;
 
        return usage;
 }
@@ -79,14 +80,20 @@ uint32_t cros_gralloc_convert_format(int format)
        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 *undesired)
+static int32_t cros_gralloc_query_rendernode(struct driver **drv, const char *undesired)
 {
        /*
         * Create a driver from rendernode while filtering out
@@ -147,14 +154,13 @@ int32_t cros_gralloc_rendernode_open(struct driver **drv)
 
 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);