summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gralloc_drm.h38
-rw-r--r--gralloc_drm_intel.c14
-rw-r--r--gralloc_drm_nouveau.c8
-rw-r--r--gralloc_drm_pipe.c3
-rw-r--r--gralloc_drm_radeon.c13
5 files changed, 62 insertions, 14 deletions
diff --git a/gralloc_drm.h b/gralloc_drm.h
index b9c0de8..85e3675 100644
--- a/gralloc_drm.h
+++ b/gralloc_drm.h
@@ -61,8 +61,15 @@ static inline int gralloc_drm_get_bpp(int format)
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
bpp = 2;
break;
+ /* planar; only Y is considered */
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ bpp = 1;
+ break;
default:
bpp = 0;
break;
@@ -71,6 +78,37 @@ static inline int gralloc_drm_get_bpp(int format)
return bpp;
}
+static inline void gralloc_drm_align_geometry(int format, int *width, int *height)
+{
+ int align_w = 1, align_h = 1, extra_height_div = 0;
+
+ switch (format) {
+ case HAL_PIXEL_FORMAT_YV12:
+ align_w = 32;
+ align_h = 2;
+ extra_height_div = 2;
+ break;
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ align_w = 2;
+ extra_height_div = 1;
+ break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ align_w = 2;
+ align_h = 2;
+ extra_height_div = 2;
+ break;
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ align_w = 2;
+ break;
+ }
+
+ *width = (*width + align_w - 1) & ~(align_w - 1);
+ *height = (*height + align_h - 1) & ~(align_h - 1);
+
+ if (extra_height_div)
+ *height += *height / extra_height_div;
+}
+
int gralloc_drm_handle_register(buffer_handle_t handle, struct gralloc_drm_t *drm);
int gralloc_drm_handle_unregister(buffer_handle_t handle);
diff --git a/gralloc_drm_intel.c b/gralloc_drm_intel.c
index 6185fd4..2bf9524 100644
--- a/gralloc_drm_intel.c
+++ b/gralloc_drm_intel.c
@@ -309,6 +309,11 @@ static drm_intel_bo *alloc_ibo(struct intel_info *info,
return NULL;
}
+ aligned_width = handle->width;
+ aligned_height = handle->height;
+ gralloc_drm_align_geometry(handle->format,
+ &aligned_width, &aligned_height);
+
if (handle->usage & GRALLOC_USAGE_HW_FB) {
unsigned long max_stride;
@@ -319,8 +324,7 @@ static drm_intel_bo *alloc_ibo(struct intel_info *info,
max_stride /= 2;
name = "gralloc-fb";
- aligned_width = (handle->width + 63) & ~63;
- aligned_height = handle->height;
+ aligned_width = (aligned_width + 63) & ~63;
flags = BO_ALLOC_FOR_RENDER;
*tiling = I915_TILING_X;
@@ -368,13 +372,11 @@ static drm_intel_bo *alloc_ibo(struct intel_info *info,
if (handle->usage & GRALLOC_USAGE_HW_TEXTURE) {
name = "gralloc-texture";
/* see 2D texture layout of DRI drivers */
- aligned_width = (handle->width + 3) & ~3;
- aligned_height = (handle->height + 1) & ~1;
+ aligned_width = (aligned_width + 3) & ~3;
+ aligned_height = (aligned_height + 1) & ~1;
}
else {
name = "gralloc-buffer";
- aligned_width = handle->width;
- aligned_height = handle->height;
}
if (handle->usage & GRALLOC_USAGE_HW_RENDER)
diff --git a/gralloc_drm_nouveau.c b/gralloc_drm_nouveau.c
index 8f347a1..a3ef333 100644
--- a/gralloc_drm_nouveau.c
+++ b/gralloc_drm_nouveau.c
@@ -198,9 +198,13 @@ nouveau_alloc(struct gralloc_drm_drv_t *drv, struct gralloc_drm_handle_t *handle
}
}
else {
- int pitch;
+ int width, height, pitch;
- nb->bo = alloc_bo(info, handle->width, handle->height,
+ width = handle->width;
+ height = handle->height;
+ gralloc_drm_align_geometry(handle->format, &width, &height);
+
+ nb->bo = alloc_bo(info, width, height,
cpp, handle->usage, &pitch);
if (!nb->bo) {
LOGE("failed to allocate nouveau bo %dx%dx%d",
diff --git a/gralloc_drm_pipe.c b/gralloc_drm_pipe.c
index 2b39815..a66ce1a 100644
--- a/gralloc_drm_pipe.c
+++ b/gralloc_drm_pipe.c
@@ -76,6 +76,9 @@ static enum pipe_format get_pipe_format(int format)
break;
case HAL_PIXEL_FORMAT_RGBA_5551:
case HAL_PIXEL_FORMAT_RGBA_4444:
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
default:
fmt = PIPE_FORMAT_NONE;
break;
diff --git a/gralloc_drm_radeon.c b/gralloc_drm_radeon.c
index c8cfb8c..8d27bf9 100644
--- a/gralloc_drm_radeon.c
+++ b/gralloc_drm_radeon.c
@@ -201,16 +201,17 @@ static struct radeon_bo *radeon_alloc(struct radeon_info *info,
tiling = radeon_get_tiling(info, handle);
domain = RADEON_GEM_DOMAIN_VRAM;
+ aligned_width = handle->width;
+ aligned_height = handle->height;
+ gralloc_drm_align_geometry(handle->format,
+ &aligned_width, &aligned_height);
+
if (handle->usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_TEXTURE)) {
- aligned_width = ALIGN(handle->width,
+ aligned_width = ALIGN(aligned_width,
radeon_get_pitch_align(info, cpp, tiling));
- aligned_height = ALIGN(handle->height,
+ aligned_height = ALIGN(aligned_height,
radeon_get_height_align(info, tiling));
}
- else {
- aligned_width = handle->width;
- aligned_height = handle->height;
- }
if (!(handle->usage & (GRALLOC_USAGE_HW_FB |
GRALLOC_USAGE_HW_RENDER)) &&