diff options
author | Dale Stimson <dale.b.stimson@intel.com> | 2014-09-09 08:23:45 +0800 |
---|---|---|
committer | Ed Tam <etam@google.com> | 2014-11-22 15:03:29 -0800 |
commit | 7f1c4d0835202abcb6f7bf42a3a8813dc48a8e0c (patch) | |
tree | a61483ca406cf3e45c8dfbd450eaf45a59eef1d7 | |
parent | e315a136a27cacc173c00e01cb87193262f1d0cd (diff) | |
download | psb_video-7f1c4d0835202abcb6f7bf42a3a8813dc48a8e0c.tar.gz |
ION support in psb_video
when ion is enabled as backend of gralloc.
video driver needs to pass down fd of graphics buffer
when creat surface from it.
Orig-Author: Randy Xu <randy.xu@intel.com>
BZ: 224134
Bug: 17316531
Depends-on: Ife9513fe58e06ea2829987f328668f975a44b4e0
Depends-on: I4b8422d48b06419af6e48b631bacbe6c7169574e
Depends-on: Ia4c5bc80df952024a0973f2bacc42992301dfbf9
Depends-on: I172cdcb8cc86fd6fa3d3adadbab19b6fd3e6a18e
Depends-on: I2a2e721719349f755033c15bdeb732e7fb5c89ac
Depends-on: I48deabb107cc3abfa59eff5e012b51293fe6d74f
Depends-on: If2be266fc9063d7a2b701f85e8ace26aaf484ff5
Change-Id: I0ca0f06491e3fb498b3b41b70cbe1b6cf39e1918
Signed-off-by: mahongpe <hongpeng.ma@intel.com>
-rw-r--r-- | src/android/psb_gralloc.cpp | 9 | ||||
-rw-r--r-- | src/android/psb_gralloc.h | 3 | ||||
-rw-r--r-- | src/android/psb_surface_gralloc.c | 6 | ||||
-rw-r--r-- | src/psb_buffer.c | 12 | ||||
-rw-r--r-- | src/psb_buffer.h | 4 | ||||
-rw-r--r-- | src/psb_surface_attrib.c | 11 | ||||
-rw-r--r-- | src/psb_surface_attrib.h | 1 |
7 files changed, 33 insertions, 13 deletions
diff --git a/src/android/psb_gralloc.cpp b/src/android/psb_gralloc.cpp index e231a62..a6a934b 100644 --- a/src/android/psb_gralloc.cpp +++ b/src/android/psb_gralloc.cpp @@ -37,6 +37,10 @@ #ifdef BAYTRAIL #include <ufo/gralloc.h> #endif +#ifndef BAYTRAIL +#include <hal/hal_public.h> +#endif + using namespace android; #ifdef LOG_TAG @@ -161,3 +165,8 @@ int gralloc_getdisplaystatus(buffer_handle_t handle, int* status) return err; } + +int gralloc_getbuffd(buffer_handle_t handle) +{ + return ((IMG_native_handle_t*)handle)->fd[0]; +} diff --git a/src/android/psb_gralloc.h b/src/android/psb_gralloc.h index 1d0e550..461070d 100644 --- a/src/android/psb_gralloc.h +++ b/src/android/psb_gralloc.h @@ -44,6 +44,9 @@ int gralloc_unlock(buffer_handle_t handle); int gralloc_init(void); int gralloc_getdisplaystatus(buffer_handle_t handle, int* status); + +int gralloc_getbuffd(buffer_handle_t handle); + #ifdef __cplusplus } #endif diff --git a/src/android/psb_surface_gralloc.c b/src/android/psb_surface_gralloc.c index 94554ff..7dc0007 100644 --- a/src/android/psb_surface_gralloc.c +++ b/src/android/psb_surface_gralloc.c @@ -199,9 +199,10 @@ VAStatus psb_CreateSurfacesFromGralloc( vaStatus = VA_STATUS_ERROR_UNKNOWN; } else { int cache_flag = PSB_USER_BUFFER_UNCACHED; + int buf_fd = gralloc_getbuffd(handle); vaStatus = psb_surface_create_from_ub(driver_data, width, height, fourcc, - external_buffers, psb_surface, vaddr, + external_buffers, psb_surface, vaddr, buf_fd, cache_flag); psb_surface->buf.handle = handle; @@ -367,12 +368,13 @@ VAStatus psb_CreateSurfacesFromGralloc( vaStatus = VA_STATUS_ERROR_UNKNOWN; } else { int cache_flag = PSB_USER_BUFFER_UNCACHED; + int buf_fd = gralloc_getbuffd((buffer_handle_t)handle); #ifdef PSBVIDEO_MRFL cache_flag = 0; #endif vaStatus = psb_surface_create_from_ub(driver_data, width, height, fourcc, (VASurfaceAttributeTPI *)external_buffers, psb_surface, - vaddr[GRALLOC_SUB_BUFFER0], cache_flag); + vaddr[GRALLOC_SUB_BUFFER0], buf_fd, cache_flag); psb_surface->buf.handle = (void *)handle; obj_surface->share_info = NULL; diff --git a/src/psb_buffer.c b/src/psb_buffer.c index 38ba4ef..64ef263 100644 --- a/src/psb_buffer.c +++ b/src/psb_buffer.c @@ -206,6 +206,7 @@ VAStatus psb_buffer_create_from_ub(psb_driver_data_p driver_data, psb_buffer_type_t type, psb_buffer_p buf, void * vaddr, + int fd, unsigned int flags ) { @@ -221,6 +222,7 @@ VAStatus psb_buffer_create_from_ub(psb_driver_data_p driver_data, buf->type = type; buf->driver_data = driver_data; /* only for RAR buffers */ buf->user_ptr = vaddr; + buf->fd = fd; /* Xvideo will share surface buffer, set SHARED flag */ @@ -259,16 +261,16 @@ VAStatus psb_buffer_create_from_ub(psb_driver_data_p driver_data, } /* here use the placement when gen buffer setted */ - drv_debug_msg(VIDEO_DEBUG_GENERAL, "Create BO from user buffer %p, size=%d\n", vaddr, size); + drv_debug_msg(VIDEO_DEBUG_GENERAL, "Create BO from user buffer %p, size=%d, fd = %d\n", vaddr, size, fd); - ret = wsbmBODataUB(buf->drm_buf, size, NULL, NULL, 0, vaddr); + ret = wsbmBODataUB(buf->drm_buf, size, NULL, NULL, 0, vaddr, fd); if (ret) { - drv_debug_msg(VIDEO_DEBUG_ERROR, "Failed to alloc wsbm buffers, buf->drm_buf is 0x%x, size is %d, vaddr is 0x%x\n", buf->drm_buf, size, vaddr); + drv_debug_msg(VIDEO_DEBUG_ERROR, "Failed to alloc wsbm buffers, buf->drm_buf is 0x%x, size is %d, vaddr is 0x%x, fd=%d\n", buf->drm_buf, size, vaddr, fd); return 1; } - drv_debug_msg(VIDEO_DEBUG_GENERAL, "Create BO from user buffer 0x%08x (%d byte),BO GPU offset hint=0x%08x\n", - vaddr, size, wsbmBOOffsetHint(buf->drm_buf)); + drv_debug_msg(VIDEO_DEBUG_GENERAL, "Create BO from user buffer 0x%08x (%d byte), fd=%d, BO GPU offset hint=0x%08x\n", + vaddr, size, fd, wsbmBOOffsetHint(buf->drm_buf)); buf->pl_flags = placement; buf->status = psb_bs_ready; diff --git a/src/psb_buffer.h b/src/psb_buffer.h index ad05068..b4aeb3f 100644 --- a/src/psb_buffer.h +++ b/src/psb_buffer.h @@ -77,10 +77,11 @@ struct psb_buffer_s { unsigned int buffer_ofs; /* several buffers may share one BO (camera/RAR), and use offset to distinguish it */ struct psb_buffer_s *next; unsigned char *user_ptr; /* user pointer for user buffers */ + int fd; /* fd of user buffers if it is from GFX; else it is -1*/ psb_driver_data_p driver_data; /* for RAR buffer release */ uint32_t size; void *handle; - unsigned char *virtual_addr; + unsigned char *virtual_addr; int unfence_flag; }; @@ -103,6 +104,7 @@ VAStatus psb_buffer_create_from_ub(psb_driver_data_p driver_data, psb_buffer_type_t type, psb_buffer_p buf, void * vaddr, + int fd, unsigned int flags ); diff --git a/src/psb_surface_attrib.c b/src/psb_surface_attrib.c index 492891f..f30819b 100644 --- a/src/psb_surface_attrib.c +++ b/src/psb_surface_attrib.c @@ -55,6 +55,7 @@ VAStatus psb_surface_create_from_ub( VASurfaceAttributeTPI *graphic_buffers, psb_surface_p psb_surface, /* out */ void *vaddr, + int fd, unsigned flags ) { @@ -118,12 +119,12 @@ VAStatus psb_surface_create_from_ub( if (graphic_buffers->tiling) ret = psb_buffer_create_from_ub(driver_data, psb_surface->size, psb_bt_mmu_tiling, &psb_surface->buf, - vaddr, 0); + vaddr, fd, 0); else #endif ret = psb_buffer_create_from_ub(driver_data, psb_surface->size, psb_bt_surface, &psb_surface->buf, - vaddr, flags); + vaddr, fd, flags); return ret ? VA_STATUS_ERROR_ALLOCATION_FAILED : VA_STATUS_SUCCESS; } @@ -601,10 +602,10 @@ VAStatus psb_CreateSurfaceFromUserspace( if (attribute_tpi->type == VAExternalMemoryNoneCacheUserPointer) vaStatus = psb_surface_create_from_ub(driver_data, width, height, fourcc, - attribute_tpi, psb_surface, vaddr, PSB_USER_BUFFER_UNCACHED); + attribute_tpi, psb_surface, vaddr, -1, PSB_USER_BUFFER_UNCACHED); else vaStatus = psb_surface_create_from_ub(driver_data, width, height, fourcc, - attribute_tpi, psb_surface, vaddr, 0); + attribute_tpi, psb_surface, vaddr, -1, 0); obj_surface->psb_surface = psb_surface; if (VA_STATUS_SUCCESS != vaStatus) { @@ -721,7 +722,7 @@ VAStatus psb_CreateSurfaceFromION( } vaStatus = psb_surface_create_from_ub(driver_data, width, height, fourcc, - attribute_tpi, psb_surface, vaddr, 0); + attribute_tpi, psb_surface, vaddr, ion_source_share.fd, 0); obj_surface->psb_surface = psb_surface; if (VA_STATUS_SUCCESS != vaStatus) { diff --git a/src/psb_surface_attrib.h b/src/psb_surface_attrib.h index 9b1dee5..220d471 100644 --- a/src/psb_surface_attrib.h +++ b/src/psb_surface_attrib.h @@ -39,6 +39,7 @@ VAStatus psb_surface_create_from_ub( int width, int height, int fourcc, VASurfaceAttributeTPI *graphic_buffers, psb_surface_p psb_surface, /* out */ void *vaddr, + int fd, unsigned int flags ); |