summaryrefslogtreecommitdiff
path: root/gralloc960/gralloc_module_ion.cpp
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2018-02-22 16:02:49 -0800
committerDmitry Shmidt <dimitrysh@google.com>2018-03-29 15:06:07 -0700
commit18814f6bf3507291d1f2f5b57509cd92e5d20249 (patch)
tree1012d746fa9b8a8d17a78ed25d8b66ded10767ce /gralloc960/gralloc_module_ion.cpp
parent9b2761dac62ef47645626024d1e537bf1b2c8337 (diff)
downloadhikey-18814f6bf3507291d1f2f5b57509cd92e5d20249.tar.gz
gralloc960: Update to the r9p0 gralloc release
This is necessary in order to support r9p0 libGLES_mali.so binaries. NOTE: This unfortunately drops recent changes like v4.12+ ION abi compatibility, which will need to be re-implemented and re-added. NOTE: This change requires both kernel changes for the r9p0 driver as well as binariy r9p0 libGLES_mali.so libraries. Don't merge until those are all lined up to land. Change-Id: I6c7fdf7585edea08196d1a323db3ec0629883311 Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'gralloc960/gralloc_module_ion.cpp')
-rw-r--r--gralloc960/gralloc_module_ion.cpp132
1 files changed, 0 insertions, 132 deletions
diff --git a/gralloc960/gralloc_module_ion.cpp b/gralloc960/gralloc_module_ion.cpp
deleted file mode 100644
index 49a17a05..00000000
--- a/gralloc960/gralloc_module_ion.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2013 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <string.h>
-
-#include <cutils/log.h>
-#include <cutils/atomic.h>
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-#include "gralloc_priv.h"
-#include "alloc_device.h"
-#include "framebuffer_device.h"
-#include "ion_4.12.h"
-
-#include <linux/ion.h>
-#include <ion/ion.h>
-#include <sys/mman.h>
-
-int gralloc_backend_register(private_handle_t* hnd)
-{
- int retval = -EINVAL;
-
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- unsigned char *mappedAddress;
- size_t size = hnd->size;
- hw_module_t * pmodule = NULL;
- private_module_t *m=NULL;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
- {
- m = reinterpret_cast<private_module_t *>(pmodule);
- }
- else
- {
- AERR("Could not get gralloc module for handle: %p", hnd);
- retval = -errno;
- break;
- }
- /* the test condition is set to m->ion_client <= 0 here, because:
- * 1) module structure are initialized to 0 if no initial value is applied
- * 2) a second user process should get a ion fd greater than 0.
- */
- if (m->ion_client <= 0)
- {
- /* a second user process must obtain a client handle first via ion_open before it can obtain the shared ion buffer*/
- m->ion_client = ion_open();
-
- if (m->ion_client < 0)
- {
- AERR( "Could not open ion device for handle: %p", hnd );
- retval = -errno;
- break;
- }
- }
-
- mappedAddress = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED, hnd->share_fd, 0 );
-
- if ( MAP_FAILED == mappedAddress )
- {
- AERR( "mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror( errno ) );
- retval = -errno;
- break;
- }
-
- hnd->base = (void*)(uintptr_t(mappedAddress) + hnd->offset);
- retval = 0;
- break;
- }
-
- return retval;
-}
-
-void gralloc_backend_unregister(private_handle_t* hnd)
-{
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- void* base = (void*)hnd->base;
- size_t size = hnd->size;
-
- if ( munmap( base,size ) < 0 )
- {
- AERR("Could not munmap base:%p size:%zd '%s'", base, size, strerror(errno));
- }
- break;
- }
-}
-
-void gralloc_backend_sync(private_handle_t* hnd)
-{
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- hw_module_t * pmodule = NULL;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
- {
- private_module_t *m = reinterpret_cast<private_module_t *>(pmodule);
- if (m->gralloc_legacy_ion)
- {
- if(!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP))
- {
- ion_sync_fd(m->ion_client, hnd->share_fd);
- }
- }
- }
- else
- {
- AERR("Could not get gralloc module for handle %p\n", hnd);
- }
- break;
- }
-}