summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2012-08-31 12:55:26 +0300
committerDaniel Leung <daniel.leung@intel.com>2012-10-12 08:20:45 -0700
commit28d19f649f276ed8302a7d3bab078f692a84e6d9 (patch)
tree144335a31277c1a48583a1759e07eb2ac7afc112
parent49ae83276a0a7e1351cedd27a1d7f7cc72ed52a0 (diff)
downloadexternal_drm_gralloc-28d19f649f276ed8302a7d3bab078f692a84e6d9.zip
external_drm_gralloc-28d19f649f276ed8302a7d3bab078f692a84e6d9.tar.gz
external_drm_gralloc-28d19f649f276ed8302a7d3bab078f692a84e6d9.tar.bz2
gralloc: split resolve_drm_format
refactored code so that drm_format_from_hal helper can be used from other parts of code. Change-Id: Ibaa3e483b2987c96d9651b2886360402e2c5642d Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
-rw-r--r--gralloc_drm_kms.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/gralloc_drm_kms.c b/gralloc_drm_kms.c
index 2d9bca1..8607285 100644
--- a/gralloc_drm_kms.c
+++ b/gralloc_drm_kms.c
@@ -44,6 +44,24 @@ int gralloc_drm_bo_need_fb(const struct gralloc_drm_bo_t *bo)
bo->drm->swap_mode != DRM_SWAP_COPY);
}
+static unsigned int drm_format_from_hal(int hal_format)
+{
+ switch(hal_format) {
+ case HAL_PIXEL_FORMAT_RGB_888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ return DRM_FORMAT_XRGB8888;
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return DRM_FORMAT_RGBA8888;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return DRM_FORMAT_RGB565;
+ case HAL_PIXEL_FORMAT_YV12:
+ return DRM_FORMAT_YUV420;
+ default:
+ return 0;
+ }
+}
+
/*
* Modify pitches, offsets and handles according to
* the format and return corresponding drm format value
@@ -58,15 +76,10 @@ static int resolve_drm_format(struct gralloc_drm_bo_t *bo,
pitches[0] = bo->handle->stride;
handles[0] = bo->fb_handle;
+ int format = drm_format_from_hal(bo->handle->format);
+
+ // handle 'special formats'
switch(bo->handle->format) {
- case HAL_PIXEL_FORMAT_RGB_888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- return DRM_FORMAT_ARGB8888;
- case HAL_PIXEL_FORMAT_RGBA_8888:
- return DRM_FORMAT_RGBA8888;
- case HAL_PIXEL_FORMAT_RGB_565:
- return DRM_FORMAT_RGB565;
case HAL_PIXEL_FORMAT_YV12:
// U and V stride are half of Y plane
@@ -80,12 +93,8 @@ static int resolve_drm_format(struct gralloc_drm_bo_t *bo,
pitches[2] * bo->handle->height/2;
handles[1] = handles[2] = handles[0];
-
- return DRM_FORMAT_YUV420;
- default:
- return 0;
}
- return 0;
+ return format;
}
/*