From 4988770424a06952dd40cd6df22ab8bf89b37e08 Mon Sep 17 00:00:00 2001 From: Sahaj Sarup Date: Tue, 11 Jul 2017 14:54:38 +0530 Subject: hikey960: Enable Vulkan API Support hikey960/device-hikey960.mk: Changes to define Vulkan Hardware Level 0 and Vulkan Version 1.0.3 self-extractors_hikey960/arm/staging/device-partial.mk: Changes to copy libGLES_mali.so binaries as vulkan.hikey960.so vendor_owner_info.txt: Update to include vulkan binaries Test: Demos from https://github.com/SaschaWillems/Vulkan Change-Id: I3bea2de62737d29b325ec228f79d310e68db346c Signed-off-by: Sahaj Sarup --- hikey960/device-hikey960.mk | 4 +++- self-extractors_hikey960/arm/staging/device-partial.mk | 4 +++- vendor_owner_info.txt | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk index 6098480f..2645e2d6 100644 --- a/hikey960/device-hikey960.mk +++ b/hikey960/device-hikey960.mk @@ -22,7 +22,9 @@ PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.hikey960:root/fstab.hikey960 \ device/linaro/hikey/init.hikey960.power.rc:root/init.hikey960.power.rc \ device/linaro/hikey/init.common.usb.rc:root/init.hikey960.usb.rc \ device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey960.rc \ - device/linaro/hikey/common.kl:system/usr/keylayout/hikey960.kl + device/linaro/hikey/common.kl:system/usr/keylayout/hikey960.kl \ + frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:system/etc/permissions/android.hardware.vulkan.level.xml \ + frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml # Build HiKey960 HDMI audio HAL. Experimental only may not work. FIXME PRODUCT_PACKAGES += audio.primary.hikey960 diff --git a/self-extractors_hikey960/arm/staging/device-partial.mk b/self-extractors_hikey960/arm/staging/device-partial.mk index 8e667d77..8af8e9c9 100644 --- a/self-extractors_hikey960/arm/staging/device-partial.mk +++ b/self-extractors_hikey960/arm/staging/device-partial.mk @@ -15,4 +15,6 @@ # Linaro blob(s) necessary for Hikey hardware PRODUCT_COPY_FILES := \ vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/lib64/egl/libGLES_mali.so:linaro \ - vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/lib/egl/libGLES_mali.so:linaro + vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/lib/egl/libGLES_mali.so:linaro \ + vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/vendor/lib64/hw/vulkan.hikey960.so:linaro \ + vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/vendor/lib/hw/vulkan.hikey960.so:linaro diff --git a/vendor_owner_info.txt b/vendor_owner_info.txt index da8d27f8..85519d6d 100644 --- a/vendor_owner_info.txt +++ b/vendor_owner_info.txt @@ -1,2 +1,4 @@ system/vendor/lib64/egl/libGLES_mali.so:linaro system/vendor/lib/egl/libGLES_mali.so:linaro +system/vendor/lib/hw/vulkan.hikey960.so:linaro +system/vendor/lib64/hw/vulkan.hikey960.so:linaro -- cgit v1.2.3 From 5f82a37fdbcaf3ebb64f0f20bcb04cb53e517c54 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 8 May 2017 12:50:36 -0700 Subject: gralloc960: make fbdev fd a shallow copy We never free private_module_t::framebuffer once it is initialized. We can use a shallow copy of the fbdev fd. Bug: 62222821 Test: boots Change-Id: Id35641fa183993ce36a3c0ec7b7f4121bfdf36c4 --- gralloc960/alloc_device.cpp | 3 +-- gralloc960/alloc_ion.cpp | 2 +- gralloc960/framebuffer_device.cpp | 13 +++++++------ gralloc960/gralloc_priv.h | 4 ++-- gralloc960/gralloc_vsync_default.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gralloc960/alloc_device.cpp b/gralloc960/alloc_device.cpp index 8614ae54..9a3ff8ca 100644 --- a/gralloc960/alloc_device.cpp +++ b/gralloc960/alloc_device.cpp @@ -117,7 +117,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, in // The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory private_handle_t* hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, size, - (void*)framebufferVaddr, 0, dup(m->framebuffer->fd), + (void*)framebufferVaddr, 0, m->framebuffer->shallow_fbdev_fd, (framebufferVaddr - (uintptr_t)m->framebuffer->base)); /* @@ -1234,7 +1234,6 @@ static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle) const size_t bufferSize = m->finfo.line_length * m->info.yres; int index = ((uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base) / bufferSize; m->bufferMask &= ~(1 << index); - close(hnd->fd); } gralloc_buffer_attr_free( (private_handle_t *) hnd ); diff --git a/gralloc960/alloc_ion.cpp b/gralloc960/alloc_ion.cpp index 2f9efc05..954c5382 100644 --- a/gralloc960/alloc_ion.cpp +++ b/gralloc960/alloc_ion.cpp @@ -307,7 +307,7 @@ int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) { struct fb_dmabuf_export fb_dma_buf; int res; - res = ioctl( m->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf ); + res = ioctl( m->framebuffer->shallow_fbdev_fd, FBIOGET_DMABUF, &fb_dma_buf ); if(res == 0) { hnd->share_fd = fb_dma_buf.fd; diff --git a/gralloc960/framebuffer_device.cpp b/gralloc960/framebuffer_device.cpp index 873b5f4c..fa60eb5b 100644 --- a/gralloc960/framebuffer_device.cpp +++ b/gralloc960/framebuffer_device.cpp @@ -92,24 +92,25 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) m->info.activate = FB_ACTIVATE_VBL; m->info.yoffset = offset / m->finfo.line_length; + int fbdev_fd = m->framebuffer->shallow_fbdev_fd; #ifdef STANDARD_LINUX_SCREEN - if (ioctl(m->framebuffer->fd, FBIOPAN_DISPLAY, &m->info) == -1) + if (ioctl(fbdev_fd, FBIOPAN_DISPLAY, &m->info) == -1) { - AERR( "FBIOPAN_DISPLAY failed for fd: %d", m->framebuffer->fd ); + AERR( "FBIOPAN_DISPLAY failed for fd: %d", fbdev_fd ); m->base.unlock(&m->base, buffer); return -errno; } #else /*Standard Android way*/ - if (ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) == -1) + if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &m->info) == -1) { - AERR( "FBIOPUT_VSCREENINFO failed for fd: %d", m->framebuffer->fd ); + AERR( "FBIOPUT_VSCREENINFO failed for fd: %d", fbdev_fd ); m->base.unlock(&m->base, buffer); return -errno; } #endif if ( 0 != gralloc_wait_for_vsync(dev) ) { - AERR( "Gralloc wait for vsync failed for fd: %d", m->framebuffer->fd ); + AERR( "Gralloc wait for vsync failed for fd: %d", fbdev_fd ); m->base.unlock(&m->base, buffer); return -errno; } @@ -365,7 +366,7 @@ int init_frame_buffer_locked(struct private_module_t* module) // Create a "fake" buffer object for the entire frame buffer memory, and store it in the module module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, GRALLOC_USAGE_HW_FB, fbSize, vaddr, - 0, dup(fd), 0); + 0, fd, 0); module->numBuffers = info.yres_virtual / info.yres; module->bufferMask = 0; diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h index a9453549..51089ddc 100644 --- a/gralloc960/gralloc_priv.h +++ b/gralloc960/gralloc_priv.h @@ -194,7 +194,7 @@ struct private_handle_t mali_gralloc_yuv_info yuv_info; // Following members is for framebuffer only - int fd; + int shallow_fbdev_fd; // shallow copy, not dup'ed union { off_t offset; uint64_t padding4; @@ -235,7 +235,7 @@ struct private_handle_t pid(getpid()), attr_base(MAP_FAILED), yuv_info(MALI_YUV_NO_INFO), - fd(fb_file), + shallow_fbdev_fd(fb_file), offset(fb_offset) { version = sizeof(native_handle); diff --git a/gralloc960/gralloc_vsync_default.cpp b/gralloc960/gralloc_vsync_default.cpp index 40f66999..3ce7f0e8 100644 --- a/gralloc960/gralloc_vsync_default.cpp +++ b/gralloc960/gralloc_vsync_default.cpp @@ -49,7 +49,7 @@ int gralloc_wait_for_vsync(framebuffer_device_t *dev) { int crtc = 0; gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT); - if(ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0) + if(ioctl(m->framebuffer->shallow_fbdev_fd, FBIO_WAITFORVSYNC, &crtc) < 0) { gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT); return -errno; -- cgit v1.2.3 From a3db107cbcc0af586bef2ffb04172250c97f6201 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 8 May 2017 12:55:28 -0700 Subject: gralloc960: do not use private_handle_t::{ion_hnd,pid} This makes private_handle_t native_handle_clone friendly. Bug: 62222821 Test: boots Change-Id: I658a0448efd61a4ce8ec60b1e10e582bb5678c0e --- gralloc960/alloc_ion.cpp | 13 ++++++++----- gralloc960/gralloc_module.cpp | 15 +-------------- gralloc960/gralloc_priv.h | 8 ++++---- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/gralloc960/alloc_ion.cpp b/gralloc960/alloc_ion.cpp index 954c5382..2af9d945 100644 --- a/gralloc960/alloc_ion.cpp +++ b/gralloc960/alloc_ion.cpp @@ -248,6 +248,13 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand return -1; } + // we do not need ion_hnd once we have shared_fd + if (0 != ion_free(m->ion_client, ion_hnd)) + { + AWAR("ion_free( %d ) failed", m->ion_client); + } + ion_hnd = -1; + if (!(usage & GRALLOC_USAGE_PROTECTED)) { cpu_ptr = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0 ); @@ -255,7 +262,6 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand if ( MAP_FAILED == cpu_ptr ) { AERR( "ion_map( %d ) failed", m->ion_client ); - if ( 0 != ion_free( m->ion_client, ion_hnd ) ) AERR( "ion_free( %d ) failed", m->ion_client ); close( shared_fd ); return -1; } @@ -280,7 +286,6 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand if ( NULL != hnd ) { hnd->share_fd = shared_fd; - hnd->ion_hnd = ion_hnd; hnd->min_pgsz = min_pgsz; *pHandle = hnd; return 0; @@ -298,8 +303,6 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand if ( 0 != ret ) AERR( "munmap failed for base:%p size: %zd", cpu_ptr, size ); } - ret = ion_free( m->ion_client, ion_hnd ); - if ( 0 != ret ) AERR( "ion_free( %d ) failed", m->ion_client ); return -1; } @@ -322,6 +325,7 @@ int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd) void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m) { + (void) m; if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { return; @@ -334,7 +338,6 @@ void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m) if ( 0 != munmap( (void*)hnd->base, hnd->size ) ) AERR( "Failed to munmap handle %p", hnd ); } close( hnd->share_fd ); - if ( 0 != ion_free( m->ion_client, hnd->ion_hnd ) ) AERR( "Failed to ion_free( ion_client: %d ion_hnd: %d )", m->ion_client, hnd->ion_hnd ); memset( (void*)hnd, 0, sizeof( *hnd ) ); } } diff --git a/gralloc960/gralloc_module.cpp b/gralloc960/gralloc_module.cpp index 232ecc12..28d361d4 100644 --- a/gralloc960/gralloc_module.cpp +++ b/gralloc960/gralloc_module.cpp @@ -66,19 +66,10 @@ static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle // if this handle was created in this process, then we keep it as is. private_handle_t* hnd = (private_handle_t*)handle; - if (hnd->pid == getpid()) - { - // If the handle is created and registered in the same process this is valid, - // but it could also be that application is registering twice which is illegal. - AWAR("Registering handle %p coming from the same process: %d.", hnd, hnd->pid); - } - int retval = -EINVAL; pthread_mutex_lock(&s_map_lock); - hnd->pid = getpid(); - if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { AERR( "Can't register buffer %p as it is a framebuffer", handle ); @@ -114,7 +105,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand { AERR( "Can't unregister buffer %p as it is a framebuffer", handle ); } - else if (hnd->pid == getpid()) // never unmap buffers that were not created in this process + else { pthread_mutex_lock(&s_map_lock); @@ -142,10 +133,6 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand pthread_mutex_unlock(&s_map_lock); } - else - { - AERR( "Trying to unregister buffer %p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid()); - } return 0; } diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h index 51089ddc..7c4b8359 100644 --- a/gralloc960/gralloc_priv.h +++ b/gralloc960/gralloc_priv.h @@ -162,7 +162,7 @@ struct private_handle_t int share_fd; int share_attr_fd; - ion_user_handle_t ion_hnd; + ion_user_handle_t ion_hnd_UNUSED; // ints int magic; @@ -183,7 +183,7 @@ struct private_handle_t }; int lockState; int writeOwner; - int pid; + int pid_UNUSED; // locally mapped shared attribute area union { @@ -221,7 +221,7 @@ struct private_handle_t private_handle_t(int _flags, int _usage, int _size, void *_base, int lock_state, int fb_file, off_t fb_offset): share_fd(-1), share_attr_fd(-1), - ion_hnd(-1), + ion_hnd_UNUSED(-1), magic(sMagic), flags(_flags), usage(_usage), @@ -232,7 +232,7 @@ struct private_handle_t base(_base), lockState(lock_state), writeOwner(0), - pid(getpid()), + pid_UNUSED(-1), attr_base(MAP_FAILED), yuv_info(MALI_YUV_NO_INFO), shallow_fbdev_fd(fb_file), -- cgit v1.2.3 From 8853aaea50b0b4bbd216130bbb0f2656db707ff6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 14 Jul 2017 08:34:25 -0700 Subject: gralloc960: make register framebuffer no-op Bug: 62222821 Test: boots Change-Id: I61ae68b3772b22e174aa8a0f7114ecf5f3a2dc14 --- gralloc960/gralloc_module.cpp | 3 ++- gralloc960/gralloc_priv.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gralloc960/gralloc_module.cpp b/gralloc960/gralloc_module.cpp index 28d361d4..df2d82e3 100644 --- a/gralloc960/gralloc_module.cpp +++ b/gralloc960/gralloc_module.cpp @@ -72,7 +72,8 @@ static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { - AERR( "Can't register buffer %p as it is a framebuffer", handle ); + AINF("Register framebuffer 0x%p is no-op", handle); + retval = 0; } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h index 7c4b8359..55feb67e 100644 --- a/gralloc960/gralloc_priv.h +++ b/gralloc960/gralloc_priv.h @@ -209,7 +209,8 @@ struct private_handle_t #ifdef __cplusplus /* * We track the number of integers in the structure. There are 16 unconditional - * integers (magic - pid, yuv_info, fd and offset). Note that the fd element is + * integers (magic - pid, yuv_info, shallow_fbdev_fd and offset). + * Note that the shallow_fbdev_fd element is * considered an int not an fd because it is not intended to be used outside the * surface flinger process. The GRALLOC_ARM_NUM_INTS variable is used to track the * number of integers that are conditionally included. Similar considerations apply -- cgit v1.2.3