hikey: gralloc: Add union alias and additional fields to improve interop w/ hikey960 gralloc
Since we use the gralloc_priv.h for hikey960 and hikey, try to
align the variable names a bit using a union. This allows
drm_hwcomposer importer to need less conditionally built code.
Also add logic to provide a byte_stride value, which the
hikey960 gralloc and drm_hwcomposer uses.
Change-Id: I9a26cd244b1790afbf74138504bb0eedd44d94d4
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index fe3f14f..397f95e 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -437,6 +437,7 @@
size_t size;
size_t stride;
+ int bpp = 1;
if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP || format == HAL_PIXEL_FORMAT_YV12
/* HAL_PIXEL_FORMAT_YCbCr_420_SP, HAL_PIXEL_FORMAT_YCbCr_420_P, HAL_PIXEL_FORMAT_YCbCr_422_I are not defined in Android.
@@ -488,7 +489,6 @@
}
else
{
- int bpp = 0;
switch (format)
{
@@ -589,7 +589,7 @@
hnd->height = h;
hnd->format = format;
hnd->stride = stride;
-
+ hnd->byte_stride = GRALLOC_ALIGN(w*bpp,64);
*pStride = stride;
return 0;
}
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 40ca94f..a5f8c8b 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -166,7 +166,10 @@
int size;
int width;
int height;
- int format;
+ union {
+ int format;
+ int req_format; /* same name as gralloc960 */
+ };
int stride;
union
{
@@ -193,10 +196,10 @@
void *fb_paddr;
uint64_t fb_paddr_padding;
};
+ int byte_stride;
#if GRALLOC_ARM_DMA_BUF_MODULE
ion_user_handle_t ion_hnd;
#endif
-
#if GRALLOC_ARM_DMA_BUF_MODULE
#define GRALLOC_ARM_NUM_FDS 1
#else