OSDN Git Service

[automerger skipped] Adds Android.bp files back after merge. am: 1e4aff7321 -s ours
[android-x86/external-minigbm.git] / helpers.c
index fed4af9..17b1765 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -10,6 +10,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <xf86drm.h>
 
 #include "drv_priv.h"
@@ -92,6 +94,9 @@ static const struct planar_layout *layout_from_format(uint32_t format)
        case DRM_FORMAT_RGB332:
                return &packed_1bpp_layout;
 
+       case DRM_FORMAT_R16:
+               return &packed_2bpp_layout;
+
        case DRM_FORMAT_YVU420:
        case DRM_FORMAT_YVU420_ANDROID:
                return &triplanar_yuv_420_layout;
@@ -312,6 +317,11 @@ int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32
        aligned_width = width;
        aligned_height = height;
        switch (format) {
+       case DRM_FORMAT_R16:
+               /* HAL_PIXEL_FORMAT_Y16 requires that the buffer's width be 16 pixel
+                * aligned. See hardware/interfaces/graphics/common/1.0/types.hal. */
+               aligned_width = ALIGN(width, 16);
+               break;
        case DRM_FORMAT_YVU420_ANDROID:
                /* HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not
                 * be aligned. Update 'height' so that drv_bo_from_format below
@@ -327,6 +337,7 @@ int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32
                break;
        case DRM_FORMAT_YVU420:
        case DRM_FORMAT_NV12:
+       case DRM_FORMAT_NV21:
                /* Adjust the height to include room for chroma planes */
                aligned_height = 3 * DIV_ROUND_UP(height, 2);
                break;