OSDN Git Service

Distinguish COMPOSER_TARGET_BUFFER
authorRoman Stratiienko <r.stratiienko@gmail.com>
Thu, 24 Dec 2020 15:30:51 +0000 (17:30 +0200)
committerRoman Stratiienko <r.stratiienko@gmail.com>
Tue, 29 Dec 2020 10:36:43 +0000 (12:36 +0200)
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: Id024d7b0296ef39755bba39ac0fbb41fba1e7520

cros_gralloc/gralloc0/gralloc0.cc
cros_gralloc/gralloc3/CrosGralloc3Allocator.cc
cros_gralloc/gralloc4/CrosGralloc4Allocator.cc
cros_gralloc/gralloc4/CrosGralloc4Mapper.cc
cros_gralloc/gralloc4/CrosGralloc4Utils.cc
dri.c
dri_generic_driver.c
drv.h
helpers.c

index c00db2a..b8ef8f7 100644 (file)
@@ -74,7 +74,7 @@ static uint64_t gralloc0_convert_usage(int usage)
                /* HWC wants to use display hardware, but can defer to OpenGL. */
                use_flags |= BO_USE_SCANOUT | BO_USE_TEXTURE;
        if (usage & GRALLOC_USAGE_HW_FB)
-               use_flags |= BO_USE_NONE;
+               use_flags |= BO_USE_COMPOSER_TARGET;
        if (usage & GRALLOC_USAGE_EXTERNAL_DISP)
                /*
                 * This flag potentially covers external display for the normal drivers (i915,
@@ -138,7 +138,7 @@ static int gralloc0_alloc(alloc_device_t *dev, int w, int h, int format, int usa
 
        supported = mod->driver->is_supported(&descriptor);
        if (!supported && (usage & GRALLOC_USAGE_HW_COMPOSER)) {
-               descriptor.use_flags &= ~BO_USE_SCANOUT;
+               descriptor.use_flags &= ~(BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
                supported = mod->driver->is_supported(&descriptor);
        }
        if (!supported && (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) &&
index 57c49e9..ddb5a81 100644 (file)
@@ -49,7 +49,7 @@ Error CrosGralloc3Allocator::allocate(const BufferDescriptorInfo& descriptor, ui
 
     bool supported = mDriver->is_supported(&crosDescriptor);
     if (!supported && (descriptor.usage & BufferUsage::COMPOSER_OVERLAY)) {
-        crosDescriptor.use_flags &= ~BO_USE_SCANOUT;
+        crosDescriptor.use_flags &= ~(BO_USE_SCANOUT & BO_USE_CLIENT_TARGET);
         supported = mDriver->is_supported(&crosDescriptor);
     }
 
index e7e5f3a..7bf8234 100644 (file)
@@ -48,7 +48,7 @@ Error CrosGralloc4Allocator::allocate(const BufferDescriptorInfo& descriptor, ui
 
     bool supported = mDriver->is_supported(&crosDescriptor);
     if (!supported && (descriptor.usage & BufferUsage::COMPOSER_OVERLAY)) {
-        crosDescriptor.use_flags &= ~BO_USE_SCANOUT;
+        crosDescriptor.use_flags &= ~(BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
         supported = mDriver->is_supported(&crosDescriptor);
     }
 
index b3a85b2..e11450a 100644 (file)
@@ -401,7 +401,7 @@ Return<void> CrosGralloc4Mapper::isSupported(const BufferDescriptorInfo& descrip
 
     bool supported = mDriver->is_supported(&crosDescriptor);
     if (!supported) {
-        crosDescriptor.use_flags &= ~BO_USE_SCANOUT;
+        crosDescriptor.use_flags &= ~(BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
         supported = mDriver->is_supported(&crosDescriptor);
     }
 
index 1296b07..0e0c572 100644 (file)
@@ -113,6 +113,10 @@ std::string getUsageString(hidl_bitfield<BufferUsage> bufferUsage) {
         usage &= ~static_cast<Underlying>(BufferUsage::COMPOSER_OVERLAY);
         usages.push_back("BufferUsage::COMPOSER_OVERLAY");
     }
+    if (usage & BufferUsage::COMPOSER_CLIENT_TARGET) {
+        usage &= ~static_cast<Underlying>(BufferUsage::COMPOSER_CLIENT_TARGET);
+        usages.push_back("BufferUsage::COMPOSER_CLIENT_TARGET");
+    }
     if (usage & BufferUsage::CPU_READ_OFTEN) {
         usage &= ~static_cast<Underlying>(BufferUsage::CPU_READ_OFTEN);
         usages.push_back("BufferUsage::CPU_READ_OFTEN");
@@ -282,6 +286,10 @@ int convertToBufferUsage(uint64_t grallocUsage, uint64_t* outBufferUsage) {
         /* HWC wants to use display hardware, but can defer to OpenGL. */
         bufferUsage |= BO_USE_SCANOUT | BO_USE_TEXTURE;
     }
+    if (grallocUsage & BufferUsage::COMPOSER_CLIENT_TARGET) {
+        /* GPU composition target buffer */
+        bufferUsage |= BO_USE_COMPOSER_TARGET;
+    }
     /* Map this flag to linear until real HW protection is available on Android. */
     if (grallocUsage & BufferUsage::PROTECTED) {
         bufferUsage |= BO_USE_LINEAR;
diff --git a/dri.c b/dri.c
index 0071bef..1dde121 100644 (file)
--- a/dri.c
+++ b/dri.c
@@ -41,6 +41,8 @@ static const struct {
        { DRM_FORMAT_XBGR2101010, __DRI_IMAGE_FORMAT_XBGR2101010 },
        { DRM_FORMAT_ARGB2101010, __DRI_IMAGE_FORMAT_ARGB2101010 },
        { DRM_FORMAT_ABGR2101010, __DRI_IMAGE_FORMAT_ABGR2101010 },
+       { DRM_FORMAT_ARGB4444, __DRI_IMAGE_FORMAT_RGB565 },
+
 };
 
 static int drm_format_to_dri_format(uint32_t drm_format)
index 135803d..959ff16 100644 (file)
@@ -39,7 +39,7 @@ static int dri_generic_init(struct driver *drv)
        }
 
        drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
-                            &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT);
+                            &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
 
        drv_add_combinations(drv, texture_only_formats, ARRAY_SIZE(texture_only_formats),
                             &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
diff --git a/drv.h b/drv.h
index 88c4a67..47940b5 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -38,6 +38,7 @@ extern "C" {
 #define BO_USE_HW_VIDEO_ENCODER         (1ull << 14)
 #define BO_USE_TEST_ALLOC              (1ull << 15)
 #define BO_USE_RENDERSCRIPT            (1ull << 16)
+#define BO_USE_COMPOSER_TARGET         (1ull << 17)
 
 /* Quirks for allocating a buffer. */
 #define BO_QUIRK_NONE                  0
index 326dddf..f1a74c7 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -601,9 +601,9 @@ int drv_modify_linear_combinations(struct driver *drv)
         * plane and as a cursor.
         */
        drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &LINEAR_METADATA,
-                              BO_USE_CURSOR | BO_USE_SCANOUT);
+                              BO_USE_CURSOR | BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
        drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &LINEAR_METADATA,
-                              BO_USE_CURSOR | BO_USE_SCANOUT);
+                              BO_USE_CURSOR | BO_USE_SCANOUT | BO_USE_COMPOSER_TARGET);
        return 0;
 }