diff options
Diffstat (limited to 'gralloc_drm_kms.c')
-rw-r--r-- | gralloc_drm_kms.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/gralloc_drm_kms.c b/gralloc_drm_kms.c index 3310807..91e7e63 100644 --- a/gralloc_drm_kms.c +++ b/gralloc_drm_kms.c @@ -73,42 +73,40 @@ static unsigned int drm_format_from_hal(int hal_format) static int resolve_drm_format(struct gralloc_drm_bo_t *bo, uint32_t *pitches, uint32_t *offsets, uint32_t *handles) { - memset(pitches, 0, 4 * sizeof(uint32_t)); - memset(offsets, 0, 4 * sizeof(uint32_t)); - memset(handles, 0, 4 * sizeof(uint32_t)); + struct gralloc_drm_t *drm = bo->drm; 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_YV12: + /* driver takes care of HW specific padding, alignment etc. */ + if (drm->drv->resolve_format) + drm->drv->resolve_format(drm->drv, bo, + pitches, offsets, handles); - // U and V stride are half of Y plane - pitches[2] = pitches[0]/2; - pitches[1] = pitches[0]/2; + return drm_format_from_hal(bo->handle->format); +} - // like I420 but U and V are in reverse order - offsets[2] = offsets[0] + - pitches[0] * bo->handle->height; - offsets[1] = offsets[2] + - pitches[2] * bo->handle->height/2; +/* + * Returns planes that are supported for a particular format + */ +unsigned int planes_for_format(struct gralloc_drm_t *drm, + int hal_format) +{ + unsigned int i, j, mask = 0; + unsigned int drm_format = drm_format_from_hal(hal_format); + struct gralloc_drm_plane_t *plane = drm->planes; - handles[1] = handles[2] = handles[0]; - break; + /* no planes available */ + if (!plane) + return 0; - case HAL_PIXEL_FORMAT_DRM_NV12: + /* iterate through planes, mark those that match format */ + for (i=0; i<drm->plane_resources->count_planes; i++, plane++) + for (j=0; j<plane->drm_plane->count_formats; j++) + if (plane->drm_plane->formats[j] == drm_format) + mask |= (2 << plane->drm_plane->plane_id); - // U and V are interleaved in 2nd plane - pitches[1] = pitches[0]; - offsets[1] = offsets[0] + - pitches[0] * bo->handle->height; - handles[1] = handles[0]; - break; - } - return format; + return mask; } /* @@ -116,9 +114,9 @@ static int resolve_drm_format(struct gralloc_drm_bo_t *bo, */ int gralloc_drm_bo_add_fb(struct gralloc_drm_bo_t *bo) { - uint32_t pitches[4]; - uint32_t offsets[4]; - uint32_t handles[4]; + uint32_t pitches[4] = { 0, 0, 0, 0 }; + uint32_t offsets[4] = { 0, 0, 0, 0 }; + uint32_t handles[4] = { 0, 0, 0, 0 }; if (bo->fb_id) return 0; |