summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-08-22 19:44:28 -0700
committerAndreas Schneider <asn@cryptomilk.org>2015-07-07 13:14:12 +0200
commit2f0629ec7b95de5642d6ebf06eeba251754e4e2b (patch)
tree19b17123492fc0152010d03b542f9d82c1e9dec5
parentad5e18997d4154593e0f01d0aac59d983570b133 (diff)
downloadandroid_hardware_samsung_slsi_exynos5430-2f0629ec7b95de5642d6ebf06eeba251754e4e2b.tar.gz
android_hardware_samsung_slsi_exynos5430-2f0629ec7b95de5642d6ebf06eeba251754e4e2b.tar.xz
android_hardware_samsung_slsi_exynos5430-2f0629ec7b95de5642d6ebf06eeba251754e4e2b.zip
gralloc: register buffers in alloc
gralloc_alloc was creating buffers with ion_alloc_fd, which results in a dmabuf but no ion handle. This makes it hard to track buffers that are never registered with another process, or ones that are unregistered from their process like the wallpaper. Call gralloc_register_buffer from inside alloc to convert the dmabufs to ion handles, and gralloc_unregister_buffer inside free. gralloc_register_buffer currently unnecissarily maps the buffer as well, which gralloc_lock will do as necessary, so remove the map. gralloc_unregister_buffer will unmap if necesssary, so remove the call to grallocUnmap in gralloc_free. That leaves no callers to grallocUnmap (and there weren't any callers to grallocMap), so remove them and gr.h. Change-Id: I959feb48e6899ba28028c2e17d304ddf76346fd3
-rw-r--r--gralloc/framebuffer.cpp5
-rw-r--r--gralloc/gr.h43
-rw-r--r--gralloc/gralloc.cpp5
-rw-r--r--gralloc/mapper.cpp15
4 files changed, 7 insertions, 61 deletions
diff --git a/gralloc/framebuffer.cpp b/gralloc/framebuffer.cpp
index e3ff9f1..f025d9a 100644
--- a/gralloc/framebuffer.cpp
+++ b/gralloc/framebuffer.cpp
@@ -40,7 +40,10 @@
#endif
#include "gralloc_priv.h"
-#include "gr.h"
+
+inline size_t roundUpToPageSize(size_t x) {
+ return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
+}
/*****************************************************************************/
diff --git a/gralloc/gr.h b/gralloc/gr.h
deleted file mode 100644
index 6fe26b6..0000000
--- a/gralloc/gr.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#ifndef GR_H_
-#define GR_H_
-
-#include <stdint.h>
-#include <limits.h>
-#include <sys/cdefs.h>
-#include <hardware/gralloc.h>
-#include <pthread.h>
-#include <errno.h>
-
-#include <cutils/native_handle.h>
-
-/*****************************************************************************/
-
-struct private_module_t;
-struct private_handle_t;
-
-#ifndef SUPPORT_DIRECT_FB
-inline size_t roundUpToPageSize(size_t x) {
- return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
-}
-#endif
-
-int grallocMap(gralloc_module_t const* module, private_handle_t *hnd);
-int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd);
-
-#endif /* GR_H_ */
diff --git a/gralloc/gralloc.cpp b/gralloc/gralloc.cpp
index 764a1b9..20f24bc 100644
--- a/gralloc/gralloc.cpp
+++ b/gralloc/gralloc.cpp
@@ -42,7 +42,6 @@
#include "gralloc_priv.h"
#include "exynos_format.h"
-#include "gr.h"
#define ION_HEAP_EXYNOS_CONTIG_MASK (1 << 4)
#define ION_EXYNOS_FIMD_VIDEO_MASK (1 << 28)
@@ -399,8 +398,8 @@ static int gralloc_free(alloc_device_t* dev,
private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle);
gralloc_module_t* module = reinterpret_cast<gralloc_module_t*>(
dev->common.module);
- if (hnd->base)
- grallocUnmap(module, const_cast<private_handle_t*>(hnd));
+
+ gralloc_unregister_buffer(module, hnd);
close(hnd->fd);
if (hnd->fd1 >= 0)
diff --git a/gralloc/mapper.cpp b/gralloc/mapper.cpp
index 915b540..e89c0e3 100644
--- a/gralloc/mapper.cpp
+++ b/gralloc/mapper.cpp
@@ -146,16 +146,6 @@ static int gralloc_unmap(gralloc_module_t const* module, buffer_handle_t handle)
/*****************************************************************************/
-int grallocMap(gralloc_module_t const* module, private_handle_t *hnd)
-{
- return gralloc_map(module, hnd);
-}
-
-int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd)
-{
- return gralloc_unmap(module, hnd);
-}
-
int getIonFd(gralloc_module_t const *module)
{
private_module_t* m = const_cast<private_module_t*>(reinterpret_cast<const private_module_t*>(module));
@@ -171,12 +161,9 @@ static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER;
int gralloc_register_buffer(gralloc_module_t const* module,
buffer_handle_t handle)
{
- int err;
if (private_handle_t::validate(handle) < 0)
return -EINVAL;
- err = gralloc_map(module, handle);
-
private_handle_t* hnd = (private_handle_t*)handle;
ALOGV("%s: base %p %d %d %d %d\n", __func__, hnd->base, hnd->size,
hnd->width, hnd->height, hnd->stride);
@@ -196,7 +183,7 @@ int gralloc_register_buffer(gralloc_module_t const* module,
ALOGE("error importing handle2 %d %x\n", hnd->fd2, hnd->format);
}
- return err;
+ return ret;
}
int gralloc_unregister_buffer(gralloc_module_t const* module,