From a8f0334ef5706875f2c73a2690a2f1fc3e5fee27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Fri, 18 Jan 2013 15:01:43 +0200 Subject: gralloc: implement yuv offset query as hw specific function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch reverts earlier cca14cfd... and introduces a new hw specific hook to query yuv components offsets which can vary between different hw, decoders, cameras etc. Change-Id: Ib60bc8ee28df7bc9425b6d7934294fe36fc55354 Depends-Change-Id: I1aa5368b21e588d5d711c1005fff2a5296e143a0 Signed-off-by: Tapani Pälli --- gralloc_drm_intel.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'gralloc_drm_intel.c') diff --git a/gralloc_drm_intel.c b/gralloc_drm_intel.c index 649c6ff..725334e 100644 --- a/gralloc_drm_intel.c +++ b/gralloc_drm_intel.c @@ -190,6 +190,52 @@ batch_init(struct intel_info *info) return ret; } +static void intel_resolve_format(struct gralloc_drm_drv_t *drv, + struct gralloc_drm_bo_t *bo, + uint32_t *pitches, uint32_t *offsets, uint32_t *handles) +{ + /* + * TODO - should take account hw specific padding, alignment + * for camera, video decoder etc. + */ + + struct intel_buffer *ib = (struct intel_buffer *) bo; + + memset(pitches, 0, 4 * sizeof(uint32_t)); + memset(offsets, 0, 4 * sizeof(uint32_t)); + memset(handles, 0, 4 * sizeof(uint32_t)); + + pitches[0] = ib->base.handle->stride; + handles[0] = ib->base.fb_handle; + + switch(ib->base.handle->format) { + case HAL_PIXEL_FORMAT_YV12: + + // U and V stride are half of Y plane + pitches[2] = pitches[0]/2; + pitches[1] = pitches[0]/2; + + // like I420 but U and V are in reverse order + offsets[2] = offsets[0] + + pitches[0] * ib->base.handle->height; + offsets[1] = offsets[2] + + pitches[2] * ib->base.handle->height/2; + + handles[1] = handles[2] = handles[0]; + break; + + case HAL_PIXEL_FORMAT_DRM_NV12: + + // U and V are interleaved in 2nd plane + pitches[1] = pitches[0]; + offsets[1] = offsets[0] + + pitches[0] * ib->base.handle->height; + + handles[1] = handles[0]; + break; + } +} + static void intel_copy(struct gralloc_drm_drv_t *drv, struct gralloc_drm_bo_t *dst, struct gralloc_drm_bo_t *src, @@ -593,6 +639,7 @@ struct gralloc_drm_drv_t *gralloc_drm_drv_create_for_intel(int fd) info->base.map = intel_map; info->base.unmap = intel_unmap; info->base.copy = intel_copy; + info->base.resolve_format = intel_resolve_format; return &info->base; } -- cgit v1.1