OSDN Git Service

Add tests for YUV formats.
authorjohnson.lin <johnson.lin@intel.com>
Thu, 31 Aug 2017 07:49:26 +0000 (00:49 -0700)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Thu, 31 Aug 2017 10:53:28 +0000 (03:53 -0700)
This patch adds support for testing YUV formats.

Jira: None.
Test: Build passes on Linux and Android. Test apps using
      NV12 buffers is about to show content on screen.

Signed-off-by: johnson.lin <johnson.lin@intel.com>
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
44 files changed:
Android.mk
common/compositor/nativesurface.cpp
os/android/gralloc1bufferhandler.cpp
os/android/gralloc1bufferhandler.h
os/android/grallocbufferhandler.cpp
os/android/grallocbufferhandler.h
os/android/utils_android.h
os/linux/gbmbufferhandler.cpp
os/linux/gbmbufferhandler.h
os/platformcommondefines.h
public/hwcdefs.h
public/nativebufferhandler.h
tests/Android.mk
tests/apps/jsonlayerstest.cpp
tests/common/cclayerrenderer.cpp
tests/common/cclayerrenderer.h
tests/common/glcubelayerrenderer.cpp
tests/common/glcubelayerrenderer.h
tests/common/gllayerrenderer.cpp
tests/common/gllayerrenderer.h
tests/common/imagelayerrenderer.cpp
tests/common/imagelayerrenderer.h
tests/common/jsonhandlers.h
tests/common/layerrenderer.cpp
tests/common/layerrenderer.h
tests/common/videolayerrenderer.cpp
tests/common/videolayerrenderer.h
tests/third_party/json-c/arraylist.c
tests/third_party/json-c/arraylist.h
tests/third_party/json-c/debug.c
tests/third_party/json-c/json_c_version.c
tests/third_party/json-c/json_object.c
tests/third_party/json-c/json_pointer.c
tests/third_party/json-c/json_tokener.c
tests/third_party/json-c/json_util.c
tests/third_party/json-c/json_util.h
tests/third_party/json-c/json_visit.c
tests/third_party/json-c/linkhash.c
tests/third_party/json-c/printbuf.c
tests/third_party/json-c/random_seed.c
tests/third_party/json-c/strdup_compat.h
tests/third_party/json-c/vasprintf_compat.h
wsi/drm/commondrmutils.h
wsi/drm/drmbuffer.cpp

index 5fd2141..f3a45a7 100644 (file)
@@ -184,7 +184,7 @@ endif
 #Include tests only if eng build
 ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT)))
 # Commenting for now include when ld issue is resolved
-#include $(LOCAL_PATH)/tests/third_party/json-c/Android.mk
+#include $(HWC_PATH)/tests/third_party/json-c/Android.mk
 endif
 
 endif
index 9402682..eb9eb25 100644 (file)
@@ -44,8 +44,12 @@ NativeSurface::~NativeSurface() {
 bool NativeSurface::Init(NativeBufferHandler *buffer_handler,
                          bool cursor_layer) {
   buffer_handler_ = buffer_handler;
-  buffer_handler_->CreateBuffer(width_, height_, 0, &native_handle_,
-                                cursor_layer);
+  uint32_t usage = hwcomposer::kLayerNormal;
+  if (cursor_layer) {
+    usage = hwcomposer::kLayerCursor;
+  }
+
+  buffer_handler_->CreateBuffer(width_, height_, 0, &native_handle_, usage);
   if (!native_handle_) {
     ETRACE("NativeSurface: Failed to create buffer.");
     return false;
index f1c164e..292a4d9 100644 (file)
@@ -82,8 +82,8 @@ bool Gralloc1BufferHandler::Init() {
 
 bool Gralloc1BufferHandler::CreateBuffer(uint32_t w, uint32_t h, int format,
                                          HWCNativeHandle *handle,
-                                         bool cursor_usage) {
-  return CreateGraphicsBuffer(w, h, format, handle, cursor_usage);
+                                         uint32_t layer_type) {
+  return CreateGraphicsBuffer(w, h, format, handle, layer_type);
 }
 
 bool Gralloc1BufferHandler::ReleaseBuffer(HWCNativeHandle handle) {
index 4cab451..72d2e96 100644 (file)
@@ -33,7 +33,7 @@ class Gralloc1BufferHandler : public NativeBufferHandler {
   bool Init();
 
   bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle,
-                    bool cursor_usage = false) override;
+                    uint32_t layer_type) override;
   bool ReleaseBuffer(HWCNativeHandle handle) override;
   void DestroyHandle(HWCNativeHandle handle) override;
   bool ImportBuffer(HWCNativeHandle handle, HwcBuffer *bo) override;
index 1a876b6..948a2c8 100644 (file)
@@ -72,8 +72,8 @@ bool GrallocBufferHandler::Init() {
 
 bool GrallocBufferHandler::CreateBuffer(uint32_t w, uint32_t h, int format,
                                         HWCNativeHandle *handle,
-                                        bool cursor_usage) {
-  return CreateGraphicsBuffer(w, h, format, handle, cursor_usage);
+                                        uint32_t layer_type) {
+  return CreateGraphicsBuffer(w, h, format, handle, layer_type);
 }
 
 bool GrallocBufferHandler::ReleaseBuffer(HWCNativeHandle handle) {
index f815115..9aeeeba 100644 (file)
@@ -33,7 +33,7 @@ class GrallocBufferHandler : public NativeBufferHandler {
   bool Init();
 
   bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle,
-                    bool cursor_usage = false) override;
+                    bool cursor_usage = false, uint32_t layer_type) override;
   bool ReleaseBuffer(HWCNativeHandle handle) override;
   void DestroyHandle(HWCNativeHandle handle) override;
   bool ImportBuffer(HWCNativeHandle handle, HwcBuffer *bo) override;
index 04f6cbb..a7a9cb8 100644 (file)
 #include "platformdefines.h"
 
 #ifdef USE_MINIGBM
+#define DRV_I915 1
 #include <cros_gralloc_handle.h>
 #include <cros_gralloc_helpers.h>
+#include <i915_private_android_types.h>
 #endif
 
 #include <hwcdefs.h>
 extern "C" {
 #endif
 
-#define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
-
-// minigbm specific DRM_FORMAT_YVU420_ANDROID enum
-#define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7')
-
 #define DRV_MAX_PLANES 4
 
 // Conversion from HAL to fourcc-based DRM formats
@@ -71,6 +68,110 @@ static uint32_t GetDrmFormatFromHALFormat(int format) {
   return DRM_FORMAT_NONE;
 }
 
+static uint32_t DrmFormatToHALFormat(int format) {
+  switch (format) {
+    case DRM_FORMAT_BGRA8888:
+      return HAL_PIXEL_FORMAT_RGBA_8888;
+    case DRM_FORMAT_BGRX8888:
+      return HAL_PIXEL_FORMAT_RGBX_8888;
+    case DRM_FORMAT_BGR888:
+      return HAL_PIXEL_FORMAT_RGB_888;
+    case DRM_FORMAT_BGR565:
+      return HAL_PIXEL_FORMAT_RGB_565;
+    case DRM_FORMAT_ARGB8888:
+      return HAL_PIXEL_FORMAT_BGRA_8888;
+    case DRM_FORMAT_YVU420:
+      return HAL_PIXEL_FORMAT_YV12;
+    case DRM_FORMAT_R8:
+      return HAL_PIXEL_FORMAT_Y8;
+    case DRM_FORMAT_GR88:
+    case DRM_FORMAT_R16:
+      return HAL_PIXEL_FORMAT_Y16;
+    case DRM_FORMAT_RGB332:  //('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
+      return 0;
+    case DRM_FORMAT_BGR233:  //('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
+      return 0;
+
+    case DRM_FORMAT_XRGB4444:
+    case DRM_FORMAT_XBGR4444:
+    case DRM_FORMAT_RGBX4444:
+    case DRM_FORMAT_BGRX4444:
+    case DRM_FORMAT_ARGB4444:
+    case DRM_FORMAT_ABGR4444:
+    case DRM_FORMAT_RGBA4444:
+    case DRM_FORMAT_BGRA4444:
+      return 0;
+    case DRM_FORMAT_XRGB1555:
+    case DRM_FORMAT_XBGR1555:
+    case DRM_FORMAT_RGBX5551:
+    case DRM_FORMAT_BGRX5551:
+    case DRM_FORMAT_ARGB1555:
+    case DRM_FORMAT_ABGR1555:
+    case DRM_FORMAT_RGBA5551:
+    case DRM_FORMAT_BGRA5551:
+      return 0;
+    case DRM_FORMAT_RGB565:
+      return HAL_PIXEL_FORMAT_RGB_565;
+    case DRM_FORMAT_RGB888:
+      return HAL_PIXEL_FORMAT_RGB_888;
+    case DRM_FORMAT_XRGB8888:
+    case DRM_FORMAT_XBGR8888:
+    case DRM_FORMAT_RGBX8888:
+    case DRM_FORMAT_ABGR8888:
+    case DRM_FORMAT_RGBA8888:
+      return 0;
+    case DRM_FORMAT_XRGB2101010:
+    case DRM_FORMAT_XBGR2101010:
+    case DRM_FORMAT_RGBX1010102:
+    case DRM_FORMAT_BGRX1010102:
+    case DRM_FORMAT_ARGB2101010:
+    case DRM_FORMAT_ABGR2101010:
+    case DRM_FORMAT_RGBA1010102:
+    case DRM_FORMAT_BGRA1010102:
+      return 0;
+    case DRM_FORMAT_YUYV:
+      return HAL_PIXEL_FORMAT_YCbCr_422_I;
+    case DRM_FORMAT_YVYU:
+    case DRM_FORMAT_UYVY:
+    case DRM_FORMAT_VYUY:
+    case DRM_FORMAT_AYUV:
+      return 0;
+#ifdef USE_MINIGBM
+    case DRM_FORMAT_NV12:
+      return HAL_PIXEL_FORMAT_NV12;
+#endif
+    case DRM_FORMAT_NV21:
+      return HAL_PIXEL_FORMAT_YCrCb_420_SP;
+    case DRM_FORMAT_NV16:
+    case DRM_FORMAT_NV61:
+    case DRM_FORMAT_YUV410:
+    case DRM_FORMAT_YVU410:
+    case DRM_FORMAT_YUV411:
+    case DRM_FORMAT_YVU411:
+      return 0;
+    case DRM_FORMAT_YUV420:
+      return HAL_PIXEL_FORMAT_YCbCr_420_888;
+    case DRM_FORMAT_YVU420_ANDROID:
+      return HAL_PIXEL_FORMAT_YV12;
+    case DRM_FORMAT_YUV422:
+    case DRM_FORMAT_YVU422:
+      return 0;
+    case DRM_FORMAT_YUV444:
+      return HAL_PIXEL_FORMAT_YCbCr_444_888;
+    case DRM_FORMAT_YVU444:
+      return 0;
+#ifdef USE_MINIGBM
+    case DRM_FORMAT_NV12_Y_TILED_INTEL:
+      return HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
+#endif
+    default:
+      return 0;
+      break;
+  }
+
+  return DRM_FORMAT_NONE;
+}
+
 static native_handle_t *dup_buffer_handle(buffer_handle_t handle) {
   native_handle_t *new_handle =
       native_handle_create(handle->numFds, handle->numInts);
@@ -115,17 +216,34 @@ static void DestroyBufferHandle(HWCNativeHandle handle) {
   handle = NULL;
 }
 #ifdef USE_MINIGBM
-static bool CreateGraphicsBuffer(uint32_t w, uint32_t h, int /*format*/,
-                                 HWCNativeHandle *handle, bool cursor_usage) {
+static bool CreateGraphicsBuffer(uint32_t w, uint32_t h, int format,
+                                 HWCNativeHandle *handle, uint32_t layer_type) {
   struct gralloc_handle *temp = new struct gralloc_handle();
-  uint32_t usage =
-      GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER;
-  if (cursor_usage) {
+  uint32_t usage = 0;
+  uint32_t pixel_format = 0;
+  if (format != 0) {
+    pixel_format = DrmFormatToHALFormat(format);
+  }
+
+  if (pixel_format == 0) {
+    pixel_format = android::PIXEL_FORMAT_RGBA_8888;
+  }
+
+  if (layer_type == hwcomposer::kLayerNormal) {
+    usage |= GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER |
+             GRALLOC_USAGE_HW_COMPOSER;
+  } else if (layer_type == hwcomposer::kLayerVideo) {
+    if (pixel_format == DRM_FORMAT_YUYV) {
+      usage |= GRALLOC_USAGE_HW_TEXTURE;
+    } else {
+      usage |= GRALLOC_USAGE_HW_CAMERA_WRITE | GRALLOC_USAGE_HW_CAMERA_READ |
+               GRALLOC_USAGE_HW_TEXTURE;
+    }
+  } else if (layer_type == hwcomposer::kLayerCursor) {
     usage |= GRALLOC_USAGE_CURSOR;
   }
 
-  temp->buffer_ =
-      new android::GraphicBuffer(w, h, android::PIXEL_FORMAT_RGBA_8888, usage);
+  temp->buffer_ = new android::GraphicBuffer(w, h, pixel_format, usage);
   temp->handle_ = temp->buffer_->handle;
   temp->hwc_buffer_ = true;
   *handle = temp;
index 2257ca5..e500198 100644 (file)
@@ -64,20 +64,30 @@ bool GbmBufferHandler::Init() {
 
 bool GbmBufferHandler::CreateBuffer(uint32_t w, uint32_t h, int format,
                                     HWCNativeHandle *handle,
-                                    bool cursor_usage) {
+                                    uint32_t layer_type) {
   uint32_t gbm_format = format;
   if (gbm_format == 0)
     gbm_format = GBM_FORMAT_XRGB8888;
 
-  struct gbm_bo *bo = gbm_bo_create(device_, w, h, gbm_format,
-                                    GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+  uint32_t flags = 0;
+
+  if (layer_type == kLayerNormal) {
+    flags |= (GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+  } else if (layer_type == kLayerVideo) {
+    flags |= (GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING |
+              GBM_BO_USE_CAMERA_WRITE | GBM_BO_USE_CAMERA_READ);
+  }
+
+  struct gbm_bo *bo = gbm_bo_create(device_, w, h, gbm_format, flags);
 
   if (!bo) {
-    bo = gbm_bo_create(device_, w, h, gbm_format, GBM_BO_USE_RENDERING);
-    if (!bo) {
-      ETRACE("GbmBufferHandler: failed to create gbm_bo");
-      return false;
-    }
+    flags &= ~GBM_BO_USE_SCANOUT;
+    bo = gbm_bo_create(device_, w, h, gbm_format, flags);
+  }
+
+  if (!bo) {
+    ETRACE("GbmBufferHandler: failed to create gbm_bo");
+    return false;
   }
 
   struct gbm_handle *temp = new struct gbm_handle();
index 83854fc..0f138bd 100644 (file)
@@ -33,7 +33,7 @@ class GbmBufferHandler : public NativeBufferHandler {
   bool Init();
 
   bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle,
-                    bool cursor_usage = false) override;
+                    uint32_t layer_type) override;
   bool ReleaseBuffer(HWCNativeHandle handle) override;
   void DestroyHandle(HWCNativeHandle handle) override;
   void CopyHandle(HWCNativeHandle source, HWCNativeHandle *target) override;
index 9f6482e..3109236 100644 (file)
 VkFormat NativeToVkFormat(int native_format);
 #endif
 
+#define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
+
+#define DRM_FORMAT_NV12_Y_TILED_INTEL fourcc_code('9', '9', '9', '6')
+// minigbm specific DRM_FORMAT_YVU420_ANDROID enum
+#define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7')
+
 #endif  // OS_LINUX_PLATFORMCOMMONDEFINES_H_
index 1d63715..240d4ec 100644 (file)
@@ -46,10 +46,10 @@ enum HWCTransform {
 };
 
 enum HWCLayerType {
-  kLayerNormal = 1 << 0,
-  kLayerCursor = 1 << 1,
-  kLayerProtected = 1 << 2,
-  kLayerVideo = 1 << 3
+  kLayerNormal = 0,
+  kLayerCursor = 1,
+  kLayerProtected = 2,
+  kLayerVideo = 3
 };
 
 enum class HWCDisplayAttribute : int32_t {
index 037d973..19d547d 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <hwcbuffer.h>
 #include <platformdefines.h>
+#include <hwcdefs.h>
 
 namespace hwcomposer {
 
@@ -32,8 +33,8 @@ class NativeBufferHandler {
   }
 
   virtual bool CreateBuffer(uint32_t w, uint32_t h, int format,
-                            HWCNativeHandle *handle,
-                            bool cursor_usage = false) = 0;
+                            HWCNativeHandle *handle = NULL,
+                            uint32_t layer_type = kLayerNormal) = 0;
 
   virtual bool ReleaseBuffer(HWCNativeHandle handle) = 0;
 
index 04efd46..fb59327 100644 (file)
@@ -6,7 +6,6 @@ TARGET_BOARD_PLATFORM := android_ia
 
 
 LOCAL_REQUIRED_MODULES := libjson-c \
-                          gralloc.$(TARGET_BOARD_PLATFORM) \
                           hwcomposer.$(TARGET_BOARD_PLATFORM)
 #LOCAL_LDLIBS   += -L$(PRODUCT_OUT)/vendor/lib/hw/ -l:gralloc.android_ia.so -l:hwcomposer.android_ia.so
 
@@ -39,16 +38,17 @@ LOCAL_SHARED_LIBRARIES := \
        libui \
        libutils \
        libjson-c \
-       gralloc.$(TARGET_BOARD_PLATFORM) \
-       hwcomposer.$(TARGET_BOARD_PLATFORM)
+       libhwcomposer.$(TARGET_BOARD_PLATFORM)
 
 LOCAL_C_INCLUDES := \
        system/core/include/utils \
        system/core/libsync \
        system/core/libsync/include \
-        $(LOCAL_PATH)/third_party/json-c \
-        $(LOCAL_PATH)/common \
+       $(LOCAL_PATH)/third_party/json-c \
+       $(LOCAL_PATH)/common \
        $(LOCAL_PATH)/../os/android \
+       $(LOCAL_PATH)/../os    \
+       $(LOCAL_PATH)/../wsi   \
        $(LOCAL_PATH)/../public \
        $(LOCAL_PATH)/../common/core \
        $(LOCAL_PATH)/../common/compositor \
@@ -64,6 +64,7 @@ LOCAL_SRC_FILES := \
     common/glcubelayerrenderer.cpp \
     common/videolayerrenderer.cpp \
     common/imagelayerrenderer.cpp \
+    common/cclayerrenderer.cpp \
     common/esTransform.cpp \
     common/jsonhandlers.cpp \
     apps/jsonlayerstest.cpp
index 642d434..906f40e 100644 (file)
@@ -59,6 +59,7 @@
 #include "jsonhandlers.h"
 
 #include <nativebufferhandler.h>
+#include "platformcommondefines.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
@@ -312,7 +313,10 @@ char json_path[1024];
 TEST_PARAMETERS test_parameters;
 hwcomposer::NativeBufferHandler *buffer_handler;
 
-static uint32_t layerformat2gbmformat(LAYER_FORMAT format) {
+static uint32_t layerformat2gbmformat(LAYER_FORMAT format,
+                                      uint32_t *usage_format, uint32_t *usage) {
+  *usage = 0;
+
   switch (format) {
     case LAYER_FORMAT_C8:
       return DRM_FORMAT_C8;
@@ -434,6 +438,62 @@ static uint32_t layerformat2gbmformat(LAYER_FORMAT format) {
       return DRM_FORMAT_YUV444;
     case LAYER_FORMAT_YVU444:
       return DRM_FORMAT_YVU444;
+    case LAYER_HAL_PIXEL_FORMAT_YV12:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YV12;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_YVU420;
+    case LAYER_HAL_PIXEL_FORMAT_Y8:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_Y8;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R8;
+    case LAYER_HAL_PIXEL_FORMAT_Y16:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_Y16;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R16;
+    case LAYER_HAL_PIXEL_FORMAT_YCbCr_444_888:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YCbCr_444_888;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_YUV444;
+    case LAYER_HAL_PIXEL_FORMAT_YCbCr_422_I:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YCbCr_422_I;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_YUYV;
+    case LAYER_HAL_PIXEL_FORMAT_YCbCr_422_SP:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YCbCr_422_SP;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_NV16;
+    case LAYER_HAL_PIXEL_FORMAT_YCbCr_420_888:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YCbCr_420_888;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_NV12;
+    case LAYER_HAL_PIXEL_FORMAT_YCrCb_420_SP:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_YCrCb_420_SP;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_NV21;
+    case LAYER_HAL_PIXEL_FORMAT_RAW16:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_RAW16;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R16;
+    case LAYER_HAL_PIXEL_FORMAT_RAW_OPAQUE:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_RAW_OPAQUE;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R16;
+    case LAYER_HAL_PIXEL_FORMAT_BLOB:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_BLOB;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R8;
+    case LAYER_ANDROID_SCALER_AVAILABLE_FORMATS_RAW16:
+      *usage_format = LAYER_ANDROID_SCALER_AVAILABLE_FORMATS_RAW16;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_R16;
+    case LAYER_HAL_PIXEL_FORMAT_NV12_LINEAR_CAMERA_INTEL:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_NV12_LINEAR_CAMERA_INTEL;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_NV12;
+    case LAYER_HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL:
+      *usage_format = LAYER_HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL;
+      *usage = hwcomposer::kLayerVideo;
+      return DRM_FORMAT_NV12_Y_TILED_INTEL;
     case LAYER_FORMAT_UNDEFINED:
       return (uint32_t)-1;
   }
@@ -505,7 +565,10 @@ static void init_frames(int32_t width, int32_t height) {
 
       LayerRenderer *renderer = NULL;
       hwcomposer::HwcLayer *hwc_layer = NULL;
-      uint32_t gbm_format = layerformat2gbmformat(layer_parameter.format);
+      uint32_t usage_format, usage;
+      uint64_t modificators[4];
+      uint32_t gbm_format =
+          layerformat2gbmformat(layer_parameter.format, &usage_format, &usage);
 
       switch (layer_parameter.type) {
         // todo: more GL layer categories intead of only one CubeLayer
@@ -532,7 +595,8 @@ static void init_frames(int32_t width, int32_t height) {
       }
 
       if (!renderer->Init(layer_parameter.source_width,
-                          layer_parameter.source_height, gbm_format, &gl,
+                          layer_parameter.source_height, gbm_format,
+                          usage_format, usage, &gl,
                           layer_parameter.resource_path.c_str())) {
         printf("\nrender init not successful\n");
         exit(-1);
index ab01361..e9ed469 100644 (file)
@@ -28,11 +28,13 @@ CCLayerRenderer::~CCLayerRenderer() {
 }
 
 bool CCLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
-                           glContext* gl, const char* resource_path) {
-  if (format != GBM_FORMAT_XRGB8888)
+                           uint32_t usage_format, uint32_t usage, glContext* gl,
+                           const char* resource_path) {
+  if (format != DRM_FORMAT_XRGB8888)
     return false;
 
-  if (!LayerRenderer::Init(width, height, format, gl, resource_path))
+  if (!LayerRenderer::Init(width, height, format, usage_format, usage, gl,
+                           resource_path))
     return false;
 
   return true;
index adc5660..e87ff84 100644 (file)
@@ -27,6 +27,7 @@ class CCLayerRenderer : public LayerRenderer {
   ~CCLayerRenderer() override;
 
   bool Init(uint32_t width, uint32_t height, uint32_t format,
+            uint32_t usage_format = -1, uint32_t usage = 0,
             glContext* gl = NULL, const char* resource_path = NULL) override;
   void Draw(int64_t* pfence) override;
 };
index 606825b..94a8c60 100644 (file)
@@ -139,10 +139,11 @@ GLCubeLayerRenderer::~GLCubeLayerRenderer() {
 }
 
 bool GLCubeLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
+                               uint32_t usage_format, uint32_t usage,
                                glContext *gl, const char *resource_path) {
   if (format != DRM_FORMAT_XRGB8888)
     return false;
-  if (!GLLayerRenderer::Init(width, height, format, gl))
+  if (!GLLayerRenderer::Init(width, height, format, usage_format, usage, gl))
     return false;
 
   GLuint vertex_shader, fragment_shader;
index 99db9d4..997145b 100644 (file)
@@ -32,6 +32,7 @@ class GLCubeLayerRenderer : public GLLayerRenderer {
   ~GLCubeLayerRenderer() override;
 
   bool Init(uint32_t width, uint32_t height, uint32_t format,
+            uint32_t usage_format = -1, uint32_t usage = 0,
             glContext *gl = NULL, const char *resource_path = NULL) override;
   void glDrawFrame() override;
   void UpdateStreamTexture(unsigned long usec);
index 1484c20..206cc43 100644 (file)
@@ -68,10 +68,11 @@ bool GLLayerRenderer::Init_GL(glContext* gl) {
 }
 
 bool GLLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
-                           glContext* gl, const char* resource_path) {
+                           uint32_t usage_format, uint32_t usage, glContext* gl,
+                           const char* resource_path) {
   if (format != DRM_FORMAT_XRGB8888)
     return false;
-  if (!LayerRenderer::Init(width, height, format, gl))
+  if (!LayerRenderer::Init(width, height, format, usage_format, usage, gl))
     return false;
 
   if (!Init_GL(gl)) {
index 77c0903..fce72fd 100644 (file)
@@ -28,6 +28,7 @@ class GLLayerRenderer : public LayerRenderer {
   ~GLLayerRenderer() override;
 
   bool Init(uint32_t width, uint32_t height, uint32_t format,
+            uint32_t usage_format = -1, uint32_t usage = 0,
             glContext* gl = NULL, const char* resource_path = NULL) override;
   void Draw(int64_t* pfence) override;
   virtual void glDrawFrame() = 0;
index 4736fe2..be8c034 100644 (file)
@@ -25,6 +25,7 @@ ImageLayerRenderer::~ImageLayerRenderer() {
 }
 
 bool ImageLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
+                              uint32_t usage_format, uint32_t usage,
                               glContext* gl, const char* resource_path) {
   return true;
 }
index 8012cdb..3bb5e74 100644 (file)
@@ -26,7 +26,8 @@ class ImageLayerRenderer : public LayerRenderer {
   ~ImageLayerRenderer();
 
   bool Init(uint32_t width, uint32_t height, uint32_t format,
-            glContext* gl = NULL, const char* resoruce_path = NULL) override;
+            uint32_t usage_format = -1, uint32_t usage = 0,
+            glContext* gl = NULL, const char* resourePath = NULL) override;
   void Draw(int64_t* pfence) override;
 
  private:
index a90329d..3458ec9 100644 (file)
@@ -163,8 +163,27 @@ typedef enum {
   LAYER_FORMAT_YVU444 =
       60,  // ('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
 
-  LAYER_FORMAT_UNDEFINED
+  /*Anadroid formats */
+
+  LAYER_HAL_PIXEL_FORMAT_YV12 = 61,
+  LAYER_HAL_PIXEL_FORMAT_Y8 = 62,
+  LAYER_HAL_PIXEL_FORMAT_Y16 = 63,
+  LAYER_HAL_PIXEL_FORMAT_YCbCr_444_888 = 64,
+  LAYER_HAL_PIXEL_FORMAT_YCbCr_422_I = 65,
+  LAYER_HAL_PIXEL_FORMAT_YCbCr_422_SP = 66,
+  LAYER_HAL_PIXEL_FORMAT_YCbCr_422_888 = 67,
+  LAYER_HAL_PIXEL_FORMAT_YCbCr_420_888 = 68,
+  LAYER_HAL_PIXEL_FORMAT_YCrCb_420_SP = 69,
+  LAYER_HAL_PIXEL_FORMAT_RAW16 = 70,
+  LAYER_HAL_PIXEL_FORMAT_RAW10 = 71,
+  LAYER_HAL_PIXEL_FORMAT_RAW12 = 72,
+  LAYER_HAL_PIXEL_FORMAT_RAW_OPAQUE = 73,
+  LAYER_HAL_PIXEL_FORMAT_BLOB = 74,
+  LAYER_ANDROID_SCALER_AVAILABLE_FORMATS_RAW16 = 75,
+  LAYER_HAL_PIXEL_FORMAT_NV12_LINEAR_CAMERA_INTEL = 76,
+  LAYER_HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL = 77,
 
+  LAYER_FORMAT_UNDEFINED
 } LAYER_FORMAT;
 
 typedef enum {
index 7a6d525..d49c95a 100644 (file)
@@ -30,12 +30,15 @@ LayerRenderer::~LayerRenderer() {
 }
 
 bool LayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
-                         glContext* gl, const char* resource_path) {
-  if (!buffer_handler_->CreateBuffer(width, height, format, &handle_)) {
+                         uint32_t usage_format, uint32_t usage, glContext* gl,
+                         const char* resource_path) {
+  if (!buffer_handler_->CreateBuffer(width, height, format, &handle_, usage)) {
     ETRACE("LayerRenderer: CreateBuffer failed");
     return false;
   }
 
+  buffer_handler_->CopyHandle(handle_, &handle_);
+
   if (!buffer_handler_->ImportBuffer(handle_, &bo_)) {
     ETRACE("LayerRenderer: ImportBuffer failed");
     return false;
index 8d78498..a3d7a89 100644 (file)
@@ -50,6 +50,7 @@ class LayerRenderer {
   virtual ~LayerRenderer();
 
   virtual bool Init(uint32_t width, uint32_t height, uint32_t format,
+                    uint32_t usage_format = -1, uint32_t usage = 0,
                     glContext* gl = NULL, const char* resourePath = NULL) = 0;
   virtual void Draw(int64_t* pfence) = 0;
   HWCNativeHandle GetNativeBoHandle() {
index 1366802..9fcfad5 100644 (file)
@@ -32,8 +32,10 @@ VideoLayerRenderer::~VideoLayerRenderer() {
 }
 
 bool VideoLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format,
+                              uint32_t usage_format, uint32_t usage,
                               glContext* gl, const char* resource_path) {
-  if (!LayerRenderer::Init(width, height, format, gl, resource_path))
+  if (!LayerRenderer::Init(width, height, format, usage_format, usage, gl,
+                           resource_path))
     return false;
   if (!resource_path) {
     ETRACE("resource file no provided");
@@ -61,6 +63,7 @@ static int get_bpp_from_format(uint32_t format, size_t plane) {
     case DRM_FORMAT_YVU420:
       return 8;
     case DRM_FORMAT_NV12:
+    case DRM_FORMAT_NV12_Y_TILED_INTEL:
       return (plane == 0) ? 8 : 16;
 
     case DRM_FORMAT_ABGR1555:
@@ -129,6 +132,7 @@ static uint32_t get_linewidth_from_format(uint32_t format, uint32_t width,
   if (plane != 0) {
     switch (format) {
       case DRM_FORMAT_NV12:
+      case DRM_FORMAT_NV12_Y_TILED_INTEL:
       case DRM_FORMAT_YVU420:
         stride = stride / 2;
         break;
@@ -191,6 +195,7 @@ static uint32_t get_height_from_format(uint32_t format, uint32_t height,
       return height;
     case DRM_FORMAT_YVU420:
     case DRM_FORMAT_NV12:
+    case DRM_FORMAT_NV12_Y_TILED_INTEL:
       return (plane == 0) ? height : height / 2;
   }
   ETRACE("UNKNOWN FORMAT %d", format);
@@ -231,6 +236,9 @@ void VideoLayerRenderer::Draw(int64_t* pfence) {
       pReadLoc += bo_.pitches[i];
       readHeight++;
     }
+
+    if (readHeight < planeHeight)
+      break;
   }
 
   buffer_handler_->UnMap(handle_, pOpaque);
index 6ebb747..111b3d2 100644 (file)
@@ -27,6 +27,7 @@ class VideoLayerRenderer : public LayerRenderer {
   ~VideoLayerRenderer() override;
 
   bool Init(uint32_t width, uint32_t height, uint32_t format,
+            uint32_t usage_format = -1, uint32_t usage = 0,
             glContext* gl = NULL, const char* resource_path = NULL) override;
   void Draw(int64_t* pfence) override;
 
index e859dfd..0517a74 100644 (file)
@@ -9,18 +9,11 @@
  *
  */
 
-#include "config.h"
-
 #include <limits.h>
 
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#endif /* STDC_HEADERS */
-
-#if defined(HAVE_STRINGS_H) && !defined(_STRING_H) && !defined(__USE_BSD)
-# include <strings.h>
-#endif /* HAVE_STRINGS_H */
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
 
 #if SIZEOF_SIZE_T == SIZEOF_INT
 #define SIZE_T_MAX UINT_MAX
index 57f014c..2c3e3fb 100644 (file)
@@ -17,11 +17,12 @@ extern "C" {
 #endif
 
 #define ARRAY_LIST_DEFAULT_SIZE 32
+#include <stdlib.h>
+#include <stddef.h>
 
-typedef void (array_list_free_fn) (void *data);
+typedef void(array_list_free_fn)(void *data);
 
-struct array_list
-{
+struct array_list {
   void **array;
   size_t length;
   size_t size;
index 4b5140a..a4187a4 100644 (file)
@@ -9,8 +9,6 @@
  *
  */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 9b21db4..054bac9 100644 (file)
@@ -4,7 +4,6 @@
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See COPYING for details.
  */
-#include "config.h"
 
 #include "json_c_version.h"
 
index 33cdbdd..a64c691 100644 (file)
@@ -10,8 +10,6 @@
  *
  */
 
-#include "config.h"
-
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include "math_compat.h"
 #include "strdup_compat.h"
 
-#if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
-  /* MSC has the version as _snprintf */
-# define snprintf _snprintf
-#elif !defined(HAVE_SNPRINTF)
-# error You do not have snprintf on your system.
-#endif /* HAVE_SNPRINTF */
-
 // Don't define this.  It's not thread-safe.
 /* #define REFCOUNT_DEBUG 1 */
 
index c63e106..e637f74 100644 (file)
@@ -6,8 +6,6 @@
  *
  */
 
-#include "config.h"
-
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
index e14c5eb..a620641 100644 (file)
@@ -9,12 +9,11 @@
  *
  *
  * Copyright (c) 2008-2009 Yahoo! Inc.  All rights reserved.
- * The copyrights to the contents of this file are licensed under the MIT License
+ * The copyrights to the contents of this file are licensed under the MIT
+ *License
  * (http://www.opensource.org/licenses/mit-license.php)
  */
 
-#include "config.h"
-
 #include <math.h>
 #include "math_compat.h"
 #include <stdio.h>
 #include <xlocale.h>
 #endif
 
-#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
-
-#if !HAVE_STRNCASECMP && defined(_MSC_VER)
-  /* MSC has the version as _strnicmp */
-# define strncasecmp _strnicmp
-#elif !HAVE_STRNCASECMP
-# error You do not have strncasecmp on your system.
-#endif /* HAVE_STRNCASECMP */
+#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x)&7) + 9)
 
 /* Use C99 NAN by default; if not available, nan("") should work too. */
 #ifndef NAN
index a5b642f..f1630d4 100644 (file)
@@ -9,7 +9,6 @@
  *
  */
 
-#include "config.h"
 #undef realloc
 
 #include <stdarg.h>
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
-
-#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
-#endif /* HAVE_SYS_TYPES_H */
-
-#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
-#endif /* HAVE_SYS_STAT_H */
-
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#ifdef WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# include <io.h>
-#endif /* defined(WIN32) */
-
-#if !defined(HAVE_OPEN) && defined(WIN32)
-# define open _open
-#endif
-
-#if !defined(HAVE_SNPRINTF) && defined(_MSC_VER)
-  /* MSC has the version as _snprintf */
-# define snprintf _snprintf
-#elif !defined(HAVE_SNPRINTF)
-# error You do not have snprintf on your system.
-#endif /* HAVE_SNPRINTF */
-
+#include <unistd.h>
 #include "debug.h"
 #include "printbuf.h"
 #include "json_inttypes.h"
index a913278..17f892b 100644 (file)
@@ -27,6 +27,8 @@
 extern "C" {
 #endif
 
+#include <fcntl.h>
+
 #define JSON_FILE_BUF_SIZE 4096
 
 /* utility functions */
index 3f7a0b5..d79698a 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <stdio.h>
 
-#include "config.h"
 #include "json_inttypes.h"
 #include "json_object.h"
 #include "json_visit.h"
index b7dfe73..8c1dda9 100644 (file)
@@ -10,8 +10,6 @@
  *
  */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
index 2745339..848e59d 100644 (file)
@@ -9,21 +9,15 @@
  *
  *
  * Copyright (c) 2008-2009 Yahoo! Inc.  All rights reserved.
- * The copyrights to the contents of this file are licensed under the MIT License
+ * The copyrights to the contents of this file are licensed under the MIT
+ *License
  * (http://www.opensource.org/licenses/mit-license.php)
  */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#ifdef HAVE_STDARG_H
-# include <stdarg.h>
-#else /* !HAVE_STDARG_H */
-# error Not enough var arg support!
-#endif /* HAVE_STDARG_H */
+#include <stdarg.h>
 
 #include "debug.h"
 #include "printbuf.h"
index 3b61b77..c70a3b6 100644 (file)
  */
 
 #include <stdio.h>
-#include "config.h"
 #include "random_seed.h"
 
 #define DEBUG_SEED(s)
 
-
 #if defined ENABLE_RDRAND
 
 /* cpuid */
index 51af81e..5452b35 100644 (file)
@@ -1,11 +1,4 @@
 #ifndef __strdup_compat_h
 #define __strdup_compat_h
 
-#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
-  /* MSC has the version as _strdup */
-# define strdup _strdup
-#elif !defined(HAVE_STRDUP)
-# error You do not have strdup on your system.
-#endif /* HAVE_STRDUP */
-
 #endif
index 51e234b..a13e568 100644 (file)
@@ -1,45 +1,6 @@
 #ifndef __vasprintf_compat_h
 #define __vasprintf_compat_h
 
-#if !defined(HAVE_VSNPRINTF) && defined(_MSC_VER)
-# define vsnprintf _vsnprintf
-#elif !defined(HAVE_VSNPRINTF) /* !HAVE_VSNPRINTF */
-# error Need vsnprintf!
-#endif /* !HAVE_VSNPRINTF && defined(WIN32) */
-
-#if !defined(HAVE_VASPRINTF)
-/* CAW: compliant version of vasprintf */
-static int vasprintf(char **buf, const char *fmt, va_list ap)
-{
-#ifndef WIN32
-       static char _T_emptybuffer = '\0';
-#endif /* !defined(WIN32) */
-       int chars;
-       char *b;
-
-       if(!buf) { return -1; }
-
-#ifdef WIN32
-       chars = _vscprintf(fmt, ap)+1;
-#else /* !defined(WIN32) */
-       /* CAW: RAWR! We have to hope to god here that vsnprintf doesn't overwrite
-          our buffer like on some 64bit sun systems.... but hey, its time to move on */
-       chars = vsnprintf(&_T_emptybuffer, 0, fmt, ap)+1;
-       if(chars < 0) { chars *= -1; } /* CAW: old glibc versions have this problem */
-#endif /* defined(WIN32) */
-
-       b = (char*)malloc(sizeof(char)*chars);
-       if(!b) { return -1; }
-
-       if((chars = vsprintf(b, fmt, ap)) < 0)
-       {
-               free(b);
-       } else {
-               *buf = b;
-       }
-
-       return chars;
-}
-#endif /* !HAVE_VASPRINTF */
+#include <stdarg.h>
 
 #endif /* __vasprintf_compat_h */
index d9db0b1..0597580 100644 (file)
@@ -69,6 +69,7 @@ static size_t drm_bo_get_num_planes(uint32_t format) {
     case DRM_FORMAT_YVYU:
       return 1;
     case DRM_FORMAT_NV12:
+    case DRM_FORMAT_NV12_Y_TILED_INTEL:
       return 2;
     case DRM_FORMAT_YVU420:
       return 3;
index 883ba5d..f9fbaba 100644 (file)
@@ -47,6 +47,9 @@ void DrmBuffer::Initialize(const HwcBuffer& bo) {
   }
 
   format_ = bo.format;
+  if (format_ == DRM_FORMAT_NV12_Y_TILED_INTEL)
+    format_ = DRM_FORMAT_NV12;
+
   prime_fd_ = bo.prime_fd;
   usage_ = bo.usage;
   if (usage_ & hwcomposer::kLayerCursor) {