Merge "Put back old ion library"
diff --git a/camera/Android.mk b/camera/Android.mk
index 1d7e048..2d8da11 100644
--- a/camera/Android.mk
+++ b/camera/Android.mk
@@ -59,6 +59,7 @@
$(LOCAL_PATH)/inc/OMXCameraAdapter \
$(LOCAL_PATH)/../libtiutils \
hardware/ti/omap4xxx/tiler \
+ hardware/ti/omap4xxx/ion \
hardware/ti/omap4xxx/domx/omx_core/inc \
hardware/ti/omap4xxx/domx/mm_osal/inc \
frameworks/base/include/media/stagefright \
@@ -78,7 +79,7 @@
libcamera_client \
libgui \
libdomx \
- libion \
+ libion_ti \
libjpeg \
libexif
diff --git a/camera/MemoryManager.cpp b/camera/MemoryManager.cpp
index b1dbbcf..8631bbd 100644
--- a/camera/MemoryManager.cpp
+++ b/camera/MemoryManager.cpp
@@ -24,7 +24,7 @@
extern "C" {
-#include <ion/ion.h>
+#include <ion.h>
//#include <timm_osal_interfaces.h>
//#include <timm_osal_trace.h>
diff --git a/domx/domx/omx_proxy_common/src/omx_proxy_common.c b/domx/domx/omx_proxy_common/src/omx_proxy_common.c
index 60507c6..3014bf1 100644
--- a/domx/domx/omx_proxy_common/src/omx_proxy_common.c
+++ b/domx/domx/omx_proxy_common/src/omx_proxy_common.c
@@ -75,7 +75,7 @@
#ifdef USE_ION
#include <unistd.h>
-#include <ion/ion.h>
+#include <ion.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/eventfd.h>
diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk
index 58eb424..7931962 100644
--- a/domx/omx_proxy_component/Android.mk
+++ b/domx/omx_proxy_component/Android.mk
@@ -70,6 +70,7 @@
$(LOCAL_PATH)/../omx_core/inc \
$(LOCAL_PATH)/../mm_osal/inc \
$(LOCAL_PATH)/../domx \
+ $(HARDWARE_TI_OMAP4_BASE)/ion/ \
$(LOCAL_PATH)/../domx/omx_rpc/inc
LOCAL_SHARED_LIBRARIES := \
@@ -77,7 +78,7 @@
libc \
libOMX_Core \
liblog \
- libion \
+ libion_ti \
libdomx
LOCAL_CFLAGS += -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER
diff --git a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c
index 50ac002..729c190 100755
--- a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c
+++ b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c
@@ -74,7 +74,7 @@
#ifdef USE_ION
#include <unistd.h>
-#include <ion/ion.h>
+#include <ion.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/eventfd.h>
diff --git a/ion/Android.mk b/ion/Android.mk
new file mode 100644
index 0000000..58fc9f9
--- /dev/null
+++ b/ion/Android.mk
@@ -0,0 +1,13 @@
+# only include if running on an omap4 platform
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := ion.c
+LOCAL_MODULE := libion_ti
+LOCAL_MODULE_TAGS := optional
+LOCAL_SHARED_LIBRARIES := liblog
+include $(BUILD_HEAPTRACKED_SHARED_LIBRARY)
+
+endif
diff --git a/ion/ion.c b/ion/ion.c
new file mode 100644
index 0000000..7170915
--- /dev/null
+++ b/ion/ion.c
@@ -0,0 +1,156 @@
+/*
+ * ion.c
+ *
+ * Memory Allocator functions for ion
+ *
+ * Copyright 2011 Google, Inc
+ *
+ * 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 <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+
+#define LOG_TAG "ion"
+#include <cutils/log.h>
+
+#include <linux/ion.h>
+#include <linux/omap_ion.h>
+#include "ion.h"
+
+int ion_open()
+{
+ int fd = open("/dev/ion", O_RDWR);
+ if (fd < 0)
+ ALOGE("open /dev/ion failed!\n");
+ return fd;
+}
+
+int ion_close(int fd)
+{
+ return close(fd);
+}
+
+static int ion_ioctl(int fd, int req, void *arg)
+{
+ int ret = ioctl(fd, req, arg);
+ if (ret < 0) {
+ ALOGE("ioctl %d failed with code %d: %s\n", req,
+ ret, strerror(errno));
+ return -errno;
+ }
+ return ret;
+}
+
+int ion_alloc(int fd, size_t len, size_t align, unsigned int flags,
+ struct ion_handle **handle)
+{
+ int ret;
+ struct ion_allocation_data data = {
+ .len = len,
+ .align = align,
+ .flags = flags,
+ };
+
+ ret = ion_ioctl(fd, ION_IOC_ALLOC, &data);
+ if (ret < 0)
+ return ret;
+ *handle = data.handle;
+ return ret;
+}
+
+int ion_alloc_tiler(int fd, size_t w, size_t h, int fmt, unsigned int flags,
+ struct ion_handle **handle, size_t *stride)
+{
+ int ret;
+ struct omap_ion_tiler_alloc_data alloc_data = {
+ .w = w,
+ .h = h,
+ .fmt = fmt,
+ .flags = flags,
+ };
+
+ struct ion_custom_data custom_data = {
+ .cmd = OMAP_ION_TILER_ALLOC,
+ .arg = (unsigned long)(&alloc_data),
+ };
+
+ ret = ion_ioctl(fd, ION_IOC_CUSTOM, &custom_data);
+ if (ret < 0)
+ return ret;
+ *stride = alloc_data.stride;
+ *handle = alloc_data.handle;
+ return ret;
+}
+
+int ion_free(int fd, struct ion_handle *handle)
+{
+ struct ion_handle_data data = {
+ .handle = handle,
+ };
+ return ion_ioctl(fd, ION_IOC_FREE, &data);
+}
+
+int ion_map(int fd, struct ion_handle *handle, size_t length, int prot,
+ int flags, off_t offset, unsigned char **ptr, int *map_fd)
+{
+ struct ion_fd_data data = {
+ .handle = handle,
+ };
+ int ret = ion_ioctl(fd, ION_IOC_MAP, &data);
+ if (ret < 0)
+ return ret;
+ *map_fd = data.fd;
+ if (*map_fd < 0) {
+ ALOGE("map ioctl returned negative fd\n");
+ return -EINVAL;
+ }
+ *ptr = mmap(NULL, length, prot, flags, *map_fd, offset);
+ if (*ptr == MAP_FAILED) {
+ ALOGE("mmap failed: %s\n", strerror(errno));
+ return -errno;
+ }
+ return ret;
+}
+
+int ion_share(int fd, struct ion_handle *handle, int *share_fd)
+{
+ int map_fd;
+ struct ion_fd_data data = {
+ .handle = handle,
+ };
+ int ret = ion_ioctl(fd, ION_IOC_SHARE, &data);
+ if (ret < 0)
+ return ret;
+ *share_fd = data.fd;
+ if (*share_fd < 0) {
+ ALOGE("map ioctl returned negative fd\n");
+ return -EINVAL;
+ }
+ return ret;
+}
+
+int ion_import(int fd, int share_fd, struct ion_handle **handle)
+{
+ struct ion_fd_data data = {
+ .fd = share_fd,
+ };
+ int ret = ion_ioctl(fd, ION_IOC_IMPORT, &data);
+ if (ret < 0)
+ return ret;
+ *handle = data.handle;
+ return ret;
+}
diff --git a/ion/ion.h b/ion/ion.h
new file mode 100644
index 0000000..871b9bc
--- /dev/null
+++ b/ion/ion.h
@@ -0,0 +1,35 @@
+/*
+ * ion.c
+ *
+ * Memory Allocator functions for ion
+ *
+ * Copyright 2011 Google, Inc
+ *
+ * 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 <linux/ion.h>
+#include <linux/omap_ion.h>
+
+int ion_open();
+int ion_close(int fd);
+int ion_alloc(int fd, size_t len, size_t align, unsigned int flags,
+ struct ion_handle **handle);
+int ion_alloc_tiler(int fd, size_t w, size_t h, int fmt, unsigned int flags,
+ struct ion_handle **handle, size_t *stride);
+int ion_free(int fd, struct ion_handle *handle);
+int ion_map(int fd, struct ion_handle *handle, size_t length, int prot,
+ int flags, off_t offset, unsigned char **ptr, int *map_fd);
+int ion_share(int fd, struct ion_handle *handle, int *share_fd);
+int ion_import(int fd, int share_fd, struct ion_handle **handle);
+
diff --git a/omap4.mk b/omap4.mk
index b5ef9db..8fc233b 100644
--- a/omap4.mk
+++ b/omap4.mk
@@ -29,7 +29,7 @@
libI420colorconvert \
libtiutils \
libcamera \
- libion \
+ libion_ti \
camera.omap4 \
libomxcameraadapter \
hwcomposer.omap4 \