summaryrefslogtreecommitdiffstats
path: root/exynos4/hal
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2012-03-24 17:38:29 +0100
committercodeworkx <daniel.hillenbrand@codeworkx.de>2012-03-24 17:38:29 +0100
commitf1be2fe3cd7c04704e166f5303c5c41a7be146c1 (patch)
tree30f067137f5bc498e126a3885679a9738af0c188 /exynos4/hal
downloadhardware_samsung-f1be2fe3cd7c04704e166f5303c5c41a7be146c1.zip
hardware_samsung-f1be2fe3cd7c04704e166f5303c5c41a7be146c1.tar.gz
hardware_samsung-f1be2fe3cd7c04704e166f5303c5c41a7be146c1.tar.bz2
initial commit, taken and modified from linaro/insignal
Diffstat (limited to 'exynos4/hal')
-rw-r--r--exynos4/hal/Android.mk4
-rw-r--r--exynos4/hal/include/Exif.h231
-rw-r--r--exynos4/hal/include/SecBuffer.h158
-rw-r--r--exynos4/hal/include/SecFimc.h190
-rw-r--r--exynos4/hal/include/SecHdmi.h220
-rw-r--r--exynos4/hal/include/SecRect.h172
-rw-r--r--exynos4/hal/include/audio.h363
-rw-r--r--exynos4/hal/include/exynos_mem.h28
-rw-r--r--exynos4/hal/include/gralloc_priv.h172
-rw-r--r--exynos4/hal/include/i2c-dev.h74
-rw-r--r--exynos4/hal/include/ion.h144
-rw-r--r--exynos4/hal/include/jpeg_api.h121
-rw-r--r--exynos4/hal/include/jpeg_hal.h137
-rw-r--r--exynos4/hal/include/s3c_lcd.h86
-rw-r--r--exynos4/hal/include/s3c_mem.h48
-rw-r--r--exynos4/hal/include/s5p_fimc.h162
-rw-r--r--exynos4/hal/include/s5p_fimc_v4l2.h164
-rw-r--r--exynos4/hal/include/s5p_tvout.h198
-rw-r--r--exynos4/hal/include/s5p_tvout_v4l2.h190
-rw-r--r--exynos4/hal/include/sec_format.h46
-rw-r--r--exynos4/hal/include/sec_g2d.h251
-rw-r--r--exynos4/hal/include/sec_utils.h298
-rw-r--r--exynos4/hal/include/sec_utils_v4l2.h327
-rw-r--r--exynos4/hal/include/swconverter.h462
-rw-r--r--exynos4/hal/include/video.h363
-rw-r--r--exynos4/hal/include/videodev2.h2227
-rw-r--r--exynos4/hal/include/videodev2_samsung.h1115
-rw-r--r--exynos4/hal/libfimg/Android.mk18
-rw-r--r--exynos4/hal/libfimg/FimgApi.cpp245
-rw-r--r--exynos4/hal/libfimg/FimgApi.h186
-rw-r--r--exynos4/hal/libfimg/FimgC210.cpp478
-rw-r--r--exynos4/hal/libfimg/FimgC210.h197
-rw-r--r--exynos4/hal/libhwconverter/Android.mk30
-rw-r--r--exynos4/hal/libhwconverter/HardwareConverter.cpp143
-rw-r--r--exynos4/hal/libhwconverter/HardwareConverter.h42
-rw-r--r--exynos4/hal/liblights/Android.mk33
-rw-r--r--exynos4/hal/liblights/NOTICE190
-rw-r--r--exynos4/hal/liblights/lights.c240
-rw-r--r--exynos4/hal/libs5pjpeg/Android.mk34
-rw-r--r--exynos4/hal/libs5pjpeg/jpeg_api.c347
-rw-r--r--exynos4/hal/libsensors/AkmSensor.cpp310
-rw-r--r--exynos4/hal/libsensors/AkmSensor.h62
-rw-r--r--exynos4/hal/libsensors/Android.mk45
-rw-r--r--exynos4/hal/libsensors/GyroSensor.cpp185
-rw-r--r--exynos4/hal/libsensors/GyroSensor.h55
-rw-r--r--exynos4/hal/libsensors/InputEventReader.cpp88
-rw-r--r--exynos4/hal/libsensors/InputEventReader.h47
-rw-r--r--exynos4/hal/libsensors/LightSensor.cpp160
-rw-r--r--exynos4/hal/libsensors/LightSensor.h55
-rw-r--r--exynos4/hal/libsensors/MODULE_LICENSE_APACHE20
-rw-r--r--exynos4/hal/libsensors/ProximitySensor.cpp144
-rw-r--r--exynos4/hal/libsensors/ProximitySensor.h54
-rw-r--r--exynos4/hal/libsensors/SensorBase.cpp128
-rw-r--r--exynos4/hal/libsensors/SensorBase.h65
-rw-r--r--exynos4/hal/libsensors/ak8973b.h51
-rw-r--r--exynos4/hal/libsensors/sensors.cpp326
-rw-r--r--exynos4/hal/libsensors/sensors.h144
-rw-r--r--exynos4/hal/libswconverter/Android.mk44
-rw-r--r--exynos4/hal/libswconverter/csc_interleave_memcpy_neon.s120
-rw-r--r--exynos4/hal/libswconverter/csc_linear_to_tiled_crop_neon.s492
-rw-r--r--exynos4/hal/libswconverter/csc_linear_to_tiled_interleave_crop_neon.s563
-rw-r--r--exynos4/hal/libswconverter/csc_tiled_to_linear_crop_neon.s701
-rw-r--r--exynos4/hal/libswconverter/csc_tiled_to_linear_deinterleave_crop_neon.s786
-rw-r--r--exynos4/hal/libswconverter/swconvertor.c1828
-rw-r--r--exynos4/hal/libump/Android.mk48
-rw-r--r--exynos4/hal/libump/Makefile38
-rw-r--r--exynos4/hal/libump/arch_011_udd/ump_arch.c260
-rw-r--r--exynos4/hal/libump/arch_011_udd/ump_arch.h65
-rw-r--r--exynos4/hal/libump/arch_011_udd/ump_frontend.c213
-rw-r--r--exynos4/hal/libump/arch_011_udd/ump_internal.h62
-rw-r--r--exynos4/hal/libump/arch_011_udd/ump_ref_drv.c124
-rw-r--r--exynos4/hal/libump/include/ump/ump.h268
-rw-r--r--exynos4/hal/libump/include/ump/ump_debug.h287
-rw-r--r--exynos4/hal/libump/include/ump/ump_osu.h430
-rw-r--r--exynos4/hal/libump/include/ump/ump_platform.h68
-rw-r--r--exynos4/hal/libump/include/ump/ump_ref_drv.h66
-rw-r--r--exynos4/hal/libump/include/ump/ump_uk_types.h147
-rw-r--r--exynos4/hal/libump/os/linux/ump_ioctl.h55
-rw-r--r--exynos4/hal/libump/os/linux/ump_osu_locks.c537
-rw-r--r--exynos4/hal/libump/os/linux/ump_osu_memory.c60
-rw-r--r--exynos4/hal/libump/os/linux/ump_uku.c193
-rw-r--r--exynos4/hal/libump/os/ump_uku.h56
-rw-r--r--exynos4/hal/libump/readme.txt31
-rw-r--r--exynos4/hal/libump/ump.mak34
84 files changed, 19629 insertions, 0 deletions
diff --git a/exynos4/hal/Android.mk b/exynos4/hal/Android.mk
new file mode 100644
index 0000000..edb7a4a
--- /dev/null
+++ b/exynos4/hal/Android.mk
@@ -0,0 +1,4 @@
+ifeq ($(TARGET_BOARD_PLATFORM),exynos4)
+exynos4_dirs := libfimg libhwconverter liblights libs5pjpeg libsensors libswconverter libump
+include $(call all-named-subdir-makefiles,$(exynos4_dirs))
+endif
diff --git a/exynos4/hal/include/Exif.h b/exynos4/hal/include/Exif.h
new file mode 100644
index 0000000..71e2241
--- /dev/null
+++ b/exynos4/hal/include/Exif.h
@@ -0,0 +1,231 @@
+/*
+ * Copyright Samsung Electronics Co.,LTD.
+ * Copyright (C) 2010 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 ANDROID_HARDWARE_EXIF_H
+#define ANDROID_HARDWARE_EXIF_H
+
+#include <math.h>
+
+#define EXIF_LOG2(x) (log((double)(x)) / log(2.0))
+#define APEX_FNUM_TO_APERTURE(x) ((int)(EXIF_LOG2((double)(x)) * 2 + 0.5))
+#define APEX_EXPOSURE_TO_SHUTTER(x) ((x) >= 1 ? \
+ (int)(-(EXIF_LOG2((double)(x)) + 0.5)) : \
+ (int)(-(EXIF_LOG2((double)(x)) - 0.5)))
+#define APEX_ISO_TO_FILMSENSITIVITY(x) ((int)(EXIF_LOG2((x) / 3.125) + 0.5))
+
+#define NUM_SIZE 2
+#define IFD_SIZE 12
+#define OFFSET_SIZE 4
+
+#define NUM_0TH_IFD_TIFF 10
+#define NUM_0TH_IFD_EXIF 22
+#define NUM_0TH_IFD_GPS 10
+#define NUM_1TH_IFD_TIFF 9
+
+/* Type */
+#define EXIF_TYPE_BYTE 1
+#define EXIF_TYPE_ASCII 2
+#define EXIF_TYPE_SHORT 3
+#define EXIF_TYPE_LONG 4
+#define EXIF_TYPE_RATIONAL 5
+#define EXIF_TYPE_UNDEFINED 7
+#define EXIF_TYPE_SLONG 9
+#define EXIF_TYPE_SRATIONAL 10
+
+#define EXIF_FILE_SIZE 28800
+
+/* 0th IFD TIFF Tags */
+#define EXIF_TAG_IMAGE_WIDTH 0x0100
+#define EXIF_TAG_IMAGE_HEIGHT 0x0101
+#define EXIF_TAG_MAKE 0x010f
+#define EXIF_TAG_MODEL 0x0110
+#define EXIF_TAG_ORIENTATION 0x0112
+#define EXIF_TAG_SOFTWARE 0x0131
+#define EXIF_TAG_DATE_TIME 0x0132
+#define EXIF_TAG_YCBCR_POSITIONING 0x0213
+#define EXIF_TAG_EXIF_IFD_POINTER 0x8769
+#define EXIF_TAG_GPS_IFD_POINTER 0x8825
+
+/* 0th IFD Exif Private Tags */
+#define EXIF_TAG_EXPOSURE_TIME 0x829A
+#define EXIF_TAG_FNUMBER 0x829D
+#define EXIF_TAG_EXPOSURE_PROGRAM 0x8822
+#define EXIF_TAG_ISO_SPEED_RATING 0x8827
+#define EXIF_TAG_EXIF_VERSION 0x9000
+#define EXIF_TAG_DATE_TIME_ORG 0x9003
+#define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004
+#define EXIF_TAG_SHUTTER_SPEED 0x9201
+#define EXIF_TAG_APERTURE 0x9202
+#define EXIF_TAG_BRIGHTNESS 0x9203
+#define EXIF_TAG_EXPOSURE_BIAS 0x9204
+#define EXIF_TAG_MAX_APERTURE 0x9205
+#define EXIF_TAG_METERING_MODE 0x9207
+#define EXIF_TAG_FLASH 0x9209
+#define EXIF_TAG_FOCAL_LENGTH 0x920A
+#define EXIF_TAG_USER_COMMENT 0x9286
+#define EXIF_TAG_COLOR_SPACE 0xA001
+#define EXIF_TAG_PIXEL_X_DIMENSION 0xA002
+#define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003
+#define EXIF_TAG_EXPOSURE_MODE 0xA402
+#define EXIF_TAG_WHITE_BALANCE 0xA403
+#define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406
+
+/* 0th IFD GPS Info Tags */
+#define EXIF_TAG_GPS_VERSION_ID 0x0000
+#define EXIF_TAG_GPS_LATITUDE_REF 0x0001
+#define EXIF_TAG_GPS_LATITUDE 0x0002
+#define EXIF_TAG_GPS_LONGITUDE_REF 0x0003
+#define EXIF_TAG_GPS_LONGITUDE 0x0004
+#define EXIF_TAG_GPS_ALTITUDE_REF 0x0005
+#define EXIF_TAG_GPS_ALTITUDE 0x0006
+#define EXIF_TAG_GPS_TIMESTAMP 0x0007
+#define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B
+#define EXIF_TAG_GPS_DATESTAMP 0x001D
+
+/* 1th IFD TIFF Tags */
+#define EXIF_TAG_COMPRESSION_SCHEME 0x0103
+#define EXIF_TAG_X_RESOLUTION 0x011A
+#define EXIF_TAG_Y_RESOLUTION 0x011B
+#define EXIF_TAG_RESOLUTION_UNIT 0x0128
+#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201
+#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202
+
+typedef enum {
+ EXIF_ORIENTATION_UP = 1,
+ EXIF_ORIENTATION_90 = 6,
+ EXIF_ORIENTATION_180 = 3,
+ EXIF_ORIENTATION_270 = 8,
+} ExifOrientationType;
+
+typedef enum {
+ EXIF_SCENE_STANDARD,
+ EXIF_SCENE_LANDSCAPE,
+ EXIF_SCENE_PORTRAIT,
+ EXIF_SCENE_NIGHT,
+} CamExifSceneCaptureType;
+
+typedef enum {
+ EXIF_METERING_UNKNOWN,
+ EXIF_METERING_AVERAGE,
+ EXIF_METERING_CENTER,
+ EXIF_METERING_SPOT,
+ EXIF_METERING_MULTISPOT,
+ EXIF_METERING_PATTERN,
+ EXIF_METERING_PARTIAL,
+ EXIF_METERING_OTHER = 255,
+} CamExifMeteringModeType;
+
+typedef enum {
+ EXIF_EXPOSURE_AUTO,
+ EXIF_EXPOSURE_MANUAL,
+ EXIF_EXPOSURE_AUTO_BRACKET,
+} CamExifExposureModeType;
+
+typedef enum {
+ EXIF_WB_AUTO,
+ EXIF_WB_MANUAL,
+} CamExifWhiteBalanceType;
+
+/* Values */
+#define EXIF_DEF_MAKER "SAMSUNG"
+#define EXIF_DEF_MODEL "SAMSUNG"
+#define EXIF_DEF_SOFTWARE "SAMSUNG"
+#define EXIF_DEF_EXIF_VERSION "0220"
+#define EXIF_DEF_USERCOMMENTS "User comments"
+
+#define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */
+#define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */
+#define EXIF_DEF_FNUMBER_DEN 10
+#define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */
+#define EXIF_DEF_FOCAL_LEN_NUM 278 /* 2.78mm */
+#define EXIF_DEF_FOCAL_LEN_DEN 100
+#define EXIF_DEF_FLASH 0 /* O: off, 1: on*/
+#define EXIF_DEF_COLOR_SPACE 1
+#define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO
+#define EXIF_DEF_APEX_DEN 10
+
+#define EXIF_DEF_COMPRESSION 6
+#define EXIF_DEF_RESOLUTION_NUM 72
+#define EXIF_DEF_RESOLUTION_DEN 1
+#define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */
+
+typedef struct {
+ uint32_t num;
+ uint32_t den;
+} rational_t;
+
+typedef struct {
+ int32_t num;
+ int32_t den;
+} srational_t;
+
+typedef struct {
+ bool enableGps;
+ bool enableThumb;
+
+ unsigned char maker[32];
+ unsigned char model[32];
+ unsigned char software[32];
+ unsigned char exif_version[4];
+ unsigned char date_time[20];
+ unsigned char user_comment[150];
+
+ uint32_t width;
+ uint32_t height;
+ uint32_t widthThumb;
+ uint32_t heightThumb;
+
+ uint16_t orientation;
+ uint16_t ycbcr_positioning;
+ uint16_t exposure_program;
+ uint16_t iso_speed_rating;
+ uint16_t metering_mode;
+ uint16_t flash;
+ uint16_t color_space;
+ uint16_t exposure_mode;
+ uint16_t white_balance;
+ uint16_t scene_capture_type;
+
+ rational_t exposure_time;
+ rational_t fnumber;
+ rational_t aperture;
+ rational_t max_aperture;
+ rational_t focal_length;
+
+ srational_t shutter_speed;
+ srational_t brightness;
+ srational_t exposure_bias;
+
+ unsigned char gps_latitude_ref[2];
+ unsigned char gps_longitude_ref[2];
+
+ uint8_t gps_version_id[4];
+ uint8_t gps_altitude_ref;
+
+ rational_t gps_latitude[3];
+ rational_t gps_longitude[3];
+ rational_t gps_altitude;
+ rational_t gps_timestamp[3];
+ unsigned char gps_datestamp[11];
+ unsigned char gps_processing_method[100];
+
+ rational_t x_resolution;
+ rational_t y_resolution;
+ uint16_t resolution_unit;
+ uint16_t compression_scheme;
+} exif_attribute_t;
+
+#endif /* ANDROID_HARDWARE_EXIF_H */
diff --git a/exynos4/hal/include/SecBuffer.h b/exynos4/hal/include/SecBuffer.h
new file mode 100644
index 0000000..b8a41df
--- /dev/null
+++ b/exynos4/hal/include/SecBuffer.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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.
+*/
+
+/*!
+ * \file SecBuffer.h
+ * \brief header file for SecBuffer
+ * \author Sangwoo, Park(sw5771.park@samsung.com)
+ * \date 2011/06/02
+ *
+ * <b>Revision History: </b>
+ * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com) \n
+ * Initial version
+ *
+ */
+
+/**
+ * @page SecBuffer
+ *
+ * @section Introduction
+ * SecBuffer is common struct for buffer
+ *
+ * @section Copyright
+ * Copyright (c) 2008-2011 Samsung Electronics Co., Ltd.All rights reserved. \n
+ * Proprietary and Confidential
+ *
+ * @image html samsung.png
+ */
+
+#ifndef __SEC_BUFFER_H__
+#define __SEC_BUFFER_H__
+
+#include <sys/types.h>
+
+//! Buffer information
+struct SecBuffer
+{
+public:
+ //! Buffer type
+ enum BUFFER_TYPE
+ {
+ BUFFER_TYPE_BASE = 0,
+ BUFFER_TYPE_VIRT = 1, //!< virtual address
+ BUFFER_TYPE_PHYS = 1 << 1, //!< physical address
+ BUFFER_TYPE_RESERVED = 1 << 2, //!< reserved type
+ BUFFER_TYPE_MAX,
+ };
+
+ //! Buffer virtual address
+ union {
+ char *p; //! single address.
+ char *extP[3]; //! Y Cb Cr.
+ } virt;
+
+ //! Buffer physical address
+ union {
+ unsigned int p; //! single address.
+ unsigned int extP[3]; //! Y Cb Cr.
+ } phys;
+
+ //! Buffer reserved id
+ union {
+ unsigned int p; //! \n
+ unsigned int extP[3]; //! \n
+ } reserved;
+
+ //! Buffer size
+ union {
+ unsigned int s;
+ unsigned int extS[3];
+ } size;
+
+ //! Constructor
+ SecBuffer()
+ {
+ for (int i = 0; i < 3; i++) {
+ virt. extP[i] = NULL;
+ phys. extP[i] = 0;
+ reserved.extP[i] = 0;
+ size. extS[i] = 0;
+ }
+ }
+
+ //! Constructor
+ SecBuffer(const SecBuffer *other)
+ {
+ for (int i = 0; i < 3; i++) {
+ virt. extP[i] = other->virt.extP[i];
+ phys. extP[i] = other->phys.extP[i];
+ reserved.extP[i] = other->reserved.extP[i];
+ size. extS[i] = other->size.extS[i];
+ }
+ }
+
+ //! Operator(=) override
+ SecBuffer& operator =(const SecBuffer &other)
+ {
+ for (int i = 0; i < 3; i++) {
+ virt. extP[i] = other.virt.extP[i];
+ phys. extP[i] = other.phys.extP[i];
+ reserved.extP[i] = other.reserved.extP[i];
+ size. extS[i] = other.size.extS[i];
+ }
+ return *this;
+ }
+
+ //! Operator(==) override
+ bool operator ==(const SecBuffer &other) const
+ {
+ return ( virt. extP[0] == other.virt.extP[0]
+ && virt. extP[1] == other.virt.extP[1]
+ && virt. extP[2] == other.virt.extP[2]
+ && phys. extP[0] == other.phys.extP[0]
+ && phys. extP[1] == other.phys.extP[1]
+ && phys. extP[2] == other.phys.extP[2]
+ && reserved.extP[0] == other.reserved.extP[0]
+ && reserved.extP[1] == other.reserved.extP[1]
+ && reserved.extP[2] == other.reserved.extP[2]
+ && size. extS[0] == other.size.extS[0]
+ && size. extS[1] == other.size.extS[1]
+ && size. extS[2] == other.size.extS[2]);
+ }
+
+ //! Operator(!=) override
+ bool operator !=(const SecBuffer &other) const
+ {
+ // use operator(==)
+ return !(*this == other);
+ }
+
+ //! Get Buffer type
+ static int BUFFER_TYPE(SecBuffer *buf)
+ {
+ int type = BUFFER_TYPE_BASE;
+ if (buf->virt.p)
+ type |= BUFFER_TYPE_VIRT;
+ if (buf->phys.p)
+ type |= BUFFER_TYPE_PHYS;
+ if (buf->reserved.p)
+ type |= BUFFER_TYPE_RESERVED;
+
+ return type;
+ }
+};
+
+#endif //__SEC_BUFFER_H__
diff --git a/exynos4/hal/include/SecFimc.h b/exynos4/hal/include/SecFimc.h
new file mode 100644
index 0000000..61585c2
--- /dev/null
+++ b/exynos4/hal/include/SecFimc.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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.
+ */
+
+/*!
+ * \file SecFimc.h
+ * \brief header file for Fimc HAL MODULE
+ * \author Hyunkyung, Kim(hk310.kim@samsung.com)
+ * \date 2010/10/13
+ *
+ * <b>Revision History: </b>
+ * - 2010/10/13 : Hyunkyung, Kim(hk310.kim@samsung.com) \n
+ * Initial version
+ *
+ * - 2011/11/15 : Sunmi, Lee(carrotsm.lee@samsung.com) \n
+ * Adjust V4L2 architecture \n
+ */
+
+#ifndef __SEC_FIMC_H__
+#define __SEC_FIMC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/fb.h>
+
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <asm/sizes.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/poll.h>
+#include <sys/mman.h>
+#include <hardware/hardware.h>
+
+#include "utils/Timers.h"
+
+#ifdef BOARD_USE_V4L2
+#include "s5p_fimc_v4l2.h"
+#include "sec_utils_v4l2.h"
+#else
+#include "s5p_fimc.h"
+#include "sec_utils.h"
+#endif
+#include "sec_format.h"
+
+#include "SecBuffer.h"
+#include "SecRect.h"
+
+#define PFX_NODE_FIMC "/dev/video"
+#define MAX_DST_BUFFERS (3)
+#define MAX_SRC_BUFFERS (1)
+#define MAX_PLANES (3)
+
+#ifdef __cplusplus
+}
+
+class SecFimc
+{
+public:
+ enum DEV {
+ DEV_0 = 0,
+ DEV_1,
+ DEV_2,
+ DEV_3,
+ DEV_MAX,
+ };
+
+ enum MODE {
+ MODE_NONE = 0,
+ MODE_SINGLE_BUF,
+ MODE_MULTI_BUF,
+ MODE_DMA_AUTO,
+ MODE_MAX,
+ };
+
+private:
+ bool mFlagCreate;
+ int mDev;
+ int mFimcMode;
+ int mNumOfBuf;
+
+ int mRealDev;
+ int mFd;
+ int mHwVersion;
+ int mRotVal;
+ bool mFlagGlobalAlpha;
+ int mGlobalAlpha;
+ bool mFlagLocalAlpha;
+ bool mFlagColorKey;
+ int mColorKey;
+ bool mFlagSetSrcParam;
+ bool mFlagSetDstParam;
+ bool mFlagStreamOn;
+
+ s5p_fimc_t mS5pFimc;
+ struct v4l2_capability mFimcCap;
+
+ SecBuffer mSrcBuffer;
+ SecBuffer mDstBuffer[MAX_DST_BUFFERS];
+
+public:
+ SecFimc();
+ virtual ~SecFimc();
+
+ virtual bool create(enum DEV dev, enum MODE mode, int numOfBuf);
+ virtual bool destroy(void);
+ bool flagCreate(void);
+
+ int getFd(void);
+
+ SecBuffer * getMemAddr(int index = 0);
+
+ int getHWVersion(void);
+
+ virtual bool setSrcParams(unsigned int width, unsigned int height,
+ unsigned int cropX, unsigned int cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int colorFormat,
+ bool forceChange = true);
+
+ virtual bool getSrcParams(unsigned int *width, unsigned int *height,
+ unsigned int *cropX, unsigned int *cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int *colorFormat);
+
+ virtual bool setSrcAddr(unsigned int physYAddr,
+ unsigned int physCbAddr = 0,
+ unsigned int physCrAddr = 0,
+ int colorFormat = 0);
+
+ virtual bool setDstParams(unsigned int width, unsigned int height,
+ unsigned int cropX, unsigned int cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int colorFormat,
+ bool forceChange = true);
+
+ virtual bool getDstParams(unsigned int *width, unsigned int *height,
+ unsigned int *cropX, unsigned int *cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int *colorFormat);
+
+ virtual bool setDstAddr(unsigned int physYAddr, unsigned int physCbAddr = 0, unsigned int physCrAddr = 0, int buf_index = 0);
+
+ virtual bool setRotVal(unsigned int rotVal);
+ virtual bool setGlobalAlpha(bool enable = true, int alpha = 0xff);
+ virtual bool setLocalAlpha(bool enable);
+ virtual bool setColorKey(bool enable = true, int colorKey = 0xff);
+
+ virtual bool draw(int src_index, int dst_index);
+
+private:
+ bool m_streamOn(void);
+ bool m_checkSrcSize(unsigned int width, unsigned int height,
+ unsigned int cropX, unsigned int cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int colorFormat,
+ bool forceChange = false);
+
+ bool m_checkDstSize(unsigned int width, unsigned int height,
+ unsigned int cropX, unsigned int cropY,
+ unsigned int *cropWidth, unsigned int *cropHeight,
+ int colorFormat,
+ int rotVal,
+ bool forceChange = false);
+ int m_widthOfFimc(int v4l2ColorFormat, int width);
+ int m_heightOfFimc(int v4l2ColorFormat, int height);
+ int m_getYuvBpp(unsigned int fmt);
+ int m_getYuvPlanes(unsigned int fmt);
+};
+#endif
+
+#endif //__SEC_FIMC_H__
diff --git a/exynos4/hal/include/SecHdmi.h b/exynos4/hal/include/SecHdmi.h
new file mode 100644
index 0000000..67c3378
--- /dev/null
+++ b/exynos4/hal/include/SecHdmi.h
@@ -0,0 +1,220 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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.
+**
+** @author Sangwoo, Park(sw5771.park@samsung.com)
+** @date 2010-09-10
+**
+*/
+
+#ifndef __SEC_HDMI_H__
+#define __SEC_HDMI_H__
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+
+#ifdef BOARD_USE_V4L2
+#include "s5p_tvout_v4l2.h"
+#else
+#include "s5p_tvout.h"
+#endif
+#if defined(BOARD_USES_FIMGAPI)
+#include "sec_g2d.h"
+#endif
+#include "s3c_lcd.h"
+#include "SecBuffer.h"
+#include "SecFimc.h"
+
+#include "../libhdmi/libsForhdmi/libedid/libedid.h"
+#include "../libhdmi/libsForhdmi/libcec/libcec.h"
+
+#include "../libhdmi/SecHdmi/SecHdmiCommon.h"
+#include "../libhdmi/SecHdmi/SecHdmiV4L2Utils.h"
+
+#if defined(BOARD_USES_FIMGAPI)
+#include "FimgApi.h"
+#endif
+
+#include <linux/fb.h>
+
+#include <hardware/hardware.h>
+
+#include <utils/threads.h>
+
+
+namespace android {
+
+class SecHdmi: virtual public RefBase
+{
+public :
+ enum HDMI_LAYER {
+ HDMI_LAYER_BASE = 0,
+ HDMI_LAYER_VIDEO,
+ HDMI_LAYER_GRAPHIC_0,
+ HDMI_LAYER_GRAPHIC_1,
+ HDMI_LAYER_MAX,
+ };
+
+private :
+ class CECThread: public Thread
+ {
+ public:
+ bool mFlagRunning;
+
+ private:
+ sp<SecHdmi> mSecHdmi;
+ Mutex mThreadLoopLock;
+ Mutex mThreadControlLock;
+ virtual bool threadLoop();
+ enum CECDeviceType mDevtype;
+ int mLaddr;
+ int mPaddr;
+
+ public:
+ CECThread(sp<SecHdmi> secHdmi)
+ :Thread(false),
+ mFlagRunning(false),
+ mSecHdmi(secHdmi),
+ mDevtype(CEC_DEVICE_PLAYER),
+ mLaddr(0),
+ mPaddr(0){
+ };
+ virtual ~CECThread();
+
+ bool start();
+ bool stop();
+
+ };
+
+ Mutex mLock;
+
+ sp<CECThread> mCECThread;
+
+ bool mFlagCreate;
+ bool mFlagConnected;
+ bool mFlagLayerEnable[HDMI_LAYER_MAX];
+ bool mFlagHdmiStart[HDMI_LAYER_MAX];
+
+ int mSrcWidth[HDMI_LAYER_MAX];
+ int mSrcHeight[HDMI_LAYER_MAX];
+ int mSrcColorFormat[HDMI_LAYER_MAX];
+ int mHdmiResolutionWidth[HDMI_LAYER_MAX];
+ int mHdmiResolutionHeight[HDMI_LAYER_MAX];
+
+ int mHdmiDstWidth;
+ int mHdmiDstHeight;
+
+ unsigned int mHdmiSrcYAddr;
+ unsigned int mHdmiSrcCbCrAddr;
+
+ int mHdmiOutputMode;
+ unsigned int mHdmiResolutionValue;
+
+ unsigned int mHdmiPresetId;
+ v4l2_std_id mHdmiStdId;
+ unsigned int mCompositeStd;
+
+ bool mHdcpMode;
+ int mAudioMode;
+ unsigned int mUIRotVal;
+ unsigned int mG2DUIRotVal;
+
+ int mCurrentHdmiOutputMode;
+ unsigned int mCurrentHdmiResolutionValue;
+ bool mCurrentHdcpMode;
+ int mCurrentAudioMode;
+ bool mHdmiInfoChange;
+
+ int mFimcDstColorFormat;
+
+ SecBuffer mFimcReservedMem[HDMI_FIMC_OUTPUT_BUF_NUM];
+ unsigned int mFimcCurrentOutBufIndex;
+ SecFimc mSecFimc;
+
+ unsigned int mHdmiResolutionValueList[14];
+ int mHdmiSizeOfResolutionValueList;
+
+ SecBuffer mMixerBuffer[HDMI_LAYER_MAX][MAX_BUFFERS_MIXER];
+
+ void *mFBaddr;
+ unsigned int mFBsize;
+ int mFBionfd;
+ int mHdmiFd[HDMI_LAYER_MAX];
+
+ int mDstWidth[HDMI_LAYER_MAX];
+ int mDstHeight[HDMI_LAYER_MAX];
+ int mPrevDstWidth[HDMI_LAYER_MAX];
+ int mPrevDstHeight[HDMI_LAYER_MAX];
+
+ int mDefaultFBFd;
+ int mDisplayWidth;
+ int mDisplayHeight;
+
+ struct v4l2_rect mDstRect;
+
+public :
+
+ SecHdmi();
+ virtual ~SecHdmi();
+ bool create(int width, int height);
+ bool destroy(void);
+ inline bool flagCreate(void) { return mFlagCreate; }
+
+ bool connect(void);
+ bool disconnect(void);
+
+ bool flagConnected(void);
+
+ bool flush(int srcW, int srcH, int srcColorFormat,
+ unsigned int srcYAddr, unsigned int srcCbAddr, unsigned int srcCrAddr,
+ int dstX, int dstY,
+ int hdmiLayer,
+ int num_of_hwc_layer);
+
+ bool clear(int hdmiLayer);
+
+ bool setHdmiOutputMode(int hdmiOutputMode, bool forceRun = false);
+ bool setHdmiResolution(unsigned int hdmiResolutionValue, bool forceRun = false);
+ bool setHdcpMode(bool hdcpMode, bool forceRun = false);
+ bool setUIRotation(unsigned int rotVal, unsigned int hwcLayer);
+ bool setDisplaySize(int width, int height);
+
+private:
+
+ bool m_reset(int w, int h, int colorFormat, int hdmiLayer, int hwcLayer);
+ bool m_startHdmi(int hdmiLayer, unsigned int num_of_plane);
+ bool m_startHdmi(int hdmiLayer);
+ bool m_stopHdmi(int hdmiLayer);
+ bool m_setHdmiOutputMode(int hdmiOutputMode);
+ bool m_setHdmiResolution(unsigned int hdmiResolutionValue);
+ bool m_setCompositeResolution(unsigned int compositeStdId);
+ bool m_setHdcpMode(bool hdcpMode);
+ bool m_setAudioMode(int audioMode);
+
+ int m_resolutionValueIndex(unsigned int ResolutionValue);
+ bool m_flagHWConnected(void);
+};
+
+}; // namespace android
+
+#endif //__SEC_HDMI_H__
diff --git a/exynos4/hal/include/SecRect.h b/exynos4/hal/include/SecRect.h
new file mode 100644
index 0000000..1160a0b
--- /dev/null
+++ b/exynos4/hal/include/SecRect.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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.
+*/
+
+/*!
+ * \file SecRect.h
+ * \brief header file for SecRect
+ * \author Sangwoo, Park(sw5771.park@samsung.com)
+ * \date 2011/06/02
+ *
+ * <b>Revision History: </b>
+ * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com) \n
+ * Initial version
+ *
+ */
+
+/**
+ * @page SecRect
+ *
+ * @section Introduction
+ * SetRect is common struct for rectangle
+ *
+ * @section Copyright
+ * Copyright (c) 2008-2011 Samsung Electronics Co., Ltd.All rights reserved. \n
+ * Proprietary and Confidential
+ *
+ * @image html samsung.png
+ */
+
+#ifndef __SEC_RECT_H__
+#define __SEC_RECT_H__
+
+//! Rectangle information
+struct SecRect
+{
+ int x; //!< x pos
+ int y; //!< y pos
+ int w; //!< width
+ int h; //!< height
+ int fullW; //!< full width of image
+ int fullH; //!< full height of image
+ int colorFormat; //!< V4L2_PIX_FMT_XXX
+
+ //! Constructor
+ SecRect(int _x_ = 0,
+ int _y_ = 0,
+ int _w_ = 0,
+ int _h_ = 0,
+ int _fullW_ = 0,
+ int _fullH_ = 0,
+ int _colorFormat_ = 0)
+ {
+ x = _x_;
+ y = _y_;
+ w = _w_;
+ h = _h_;
+ fullW = _fullW_;
+ fullH = _fullH_;
+ colorFormat = _colorFormat_;
+ }
+
+ //! Constructor
+ SecRect(const SecRect *other)
+ {
+ x = other->x;
+ y = other->y;
+ w = other->w;
+ h = other->h;
+ fullW = other->fullW;
+ fullH = other->fullH;
+ colorFormat = other->colorFormat;
+ }
+
+ //! Operator(=) override
+ SecRect& operator =(const SecRect &other)
+ {
+ x = other.x;
+ y = other.y;
+ w = other.w;
+ h = other.h;
+ fullW = other.fullW;
+ fullH = other.fullH;
+ colorFormat = other.colorFormat;
+ return *this;
+ }
+
+ //! Operator(==) override
+ bool operator ==(const SecRect &other) const
+ {
+ return ( x == other.x
+ && y == other.y
+ && w == other.w
+ && h == other.h
+ && fullW == other.fullW
+ && fullH == other.fullH
+ && colorFormat == other.colorFormat);
+ }
+
+ //! Operator(!=) override
+ bool operator !=(const SecRect &other) const
+ {
+ // use operator(==)
+ return !(*this == other);
+ }
+};
+
+//! Clip information
+struct SecRect2
+{
+ int x1; //!< Left (The x-coordinate value of upper-left corner)
+ int y1; //!< Top (The y-coordinate value of upper-left corner)
+ int x2; //!< Right (The x-coordinate value of lower-right corner)
+ int y2; //!< Bottom (The y-coordinate value of lower-right corner)
+
+ //! Constructor
+ SecRect2(int _x1_ = 0, int _y1_ = 0, int _x2_ = 0, int _y2_ = 0)
+ {
+ x1 = _x1_;
+ y1 = _y1_;
+ x2 = _x2_;
+ y2 = _y2_;
+ }
+
+ //! Constructor
+ SecRect2(const SecRect2 *other)
+ {
+ x1 = other->x1;
+ y1 = other->y1;
+ x2 = other->x2;
+ y2 = other->y2;
+ }
+
+ //! Operator(=) override
+ SecRect2& operator =(const SecRect2 &other)
+ {
+ x1 = other.x1;
+ y1 = other.y1;
+ x2 = other.x2;
+ y2 = other.y2;
+ return *this;
+ }
+
+ //! Operator(==) override
+ bool operator ==(const SecRect2 &other) const
+ {
+ return ( x1 == other.x1
+ && y1 == other.y1
+ && x2 == other.x2
+ && y2 == other.y2);
+ }
+
+ //! Operator(!=) override
+ bool operator !=(const SecRect2 &other) const
+ {
+ // use operator(==)
+ return !(*this == other);
+ }
+};
+
+#endif //__SEC_RECT_H__
diff --git a/exynos4/hal/include/audio.h b/exynos4/hal/include/audio.h
new file mode 100644
index 0000000..1275db3
--- /dev/null
+++ b/exynos4/hal/include/audio.h
@@ -0,0 +1,363 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 _AUDIO_H_
+#define _AUDIO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __HDMI_AUDIO_HDMIAUDIOPORT__
+#define __HDMI_AUDIO_HDMIAUDIOPORT__
+/**
+ * @enum HDMIAudioPort
+ * Available audio inputs on HDMI HW module.
+ */
+enum HDMIAudioPort {
+ /** I2S input port */
+ I2S_PORT,
+ /** SPDIF input port */
+ SPDIF_PORT,
+ /** DSD input port */
+ DSD_PORT,
+};
+#endif /* __HDMI_AUDIO_HDMIAUDIOPORT__ */
+
+#ifndef __HDMI_AUDIO_AUDIOFORMAT__
+#define __HDMI_AUDIO_AUDIOFORMAT__
+/**
+ * @enum AudioFormat
+ * The encoding format of audio stream
+ */
+enum AudioFormat {
+ /** LPCM encoding format */
+ LPCM_FORMAT = 1,
+ /** AC3 encoding format */
+ AC3_FORMAT,
+ /** MPEG1 encoding format */
+ MPEG1_FORMAT,
+ /** MP3 encoding format */
+ MP3_FORMAT,
+ /** MPEG2 encoding format */
+ MPEG2_FORMAT,
+ /** AAC encoding format */
+ AAC_FORMAT,
+ /** DTS encoding format */
+ DTS_FORMAT,
+ /** ATRAC encoding format */
+ ATRAC_FORMAT,
+ /** DSD encoding format */
+ DSD_FORMAT,
+ /** Dolby Digital+ encoding format */
+ Dolby_Digital_Plus_FORMAT,
+ /** DTS HD encoding format */
+ DTS_HD_FORMAT,
+ /** MAT encoding format */
+ MAT_FORMAT,
+ /** DST encoding format */
+ DST_FORMAT,
+ /** WAM_Pro encoding format */
+ WAM_Pro_FORMAT
+};
+#endif /* __HDMI_AUDIO_AUDIOFORMAT__ */
+
+#ifndef __HDMI_AUDIO_LPCMWORDLENGTH__
+#define __HDMI_AUDIO_LPCMWORDLENGTH__
+/**
+ * @enum LPCM_WordLen
+ * Word length of LPCM audio stream.
+ */
+enum LPCM_WordLen {
+ /** 16bit word length */
+ WORD_16 = 0,
+ /** 17bit word length */
+ WORD_17,
+ /** 18bit word length */
+ WORD_18,
+ /** 19bit word length */
+ WORD_19,
+ /** 20bit word length */
+ WORD_20,
+ /** 21bit word length */
+ WORD_21,
+ /** 22bit word length */
+ WORD_22,
+ /** 23bit word length */
+ WORD_23,
+ /** 24bit word length */
+ WORD_24
+};
+#endif /* __HDMI_AUDIO_LPCMWORDLENGTH__ */
+
+#ifndef __HDMI_AUDIO_SAMPLINGFREQUENCY__
+#define __HDMI_AUDIO_SAMPLINGFREQUENCY__
+/**
+ * @enum SamplingFreq
+ * Sampling frequency of audio stream.
+ */
+enum SamplingFreq {
+ /** 32KHz sampling frequency */
+ SF_32KHZ = 0,
+ /** 44.1KHz sampling frequency */
+ SF_44KHZ,
+ /** 48KHz sampling frequency */
+ SF_48KHZ,
+ /** 88.2KHz sampling frequency */
+ SF_88KHZ,
+ /** 96KHz sampling frequency */
+ SF_96KHZ,
+ /** 176.4KHz sampling frequency */
+ SF_176KHZ,
+ /** 192KHz sampling frequency */
+ SF_192KHZ
+};
+#endif /* __HDMI_AUDIO_SAMPLINGFREQUENCY__ */
+
+#ifndef __HDMI_AUDIO_CHANNELNUMBER__
+#define __HDMI_AUDIO_CHANNELNUMBER__
+/**
+ * @enum ChannelNum
+ * Channel number of audio stream.
+ */
+enum ChannelNum {
+ /** 2 channel audio stream */
+ CH_2 = 2,
+ /** 3 channel audio stream */
+ CH_3,
+ /** 4 channel audio stream */
+ CH_4,
+ /** 5 channel audio stream */
+ CH_5,
+ /** 6 channel audio stream */
+ CH_6,
+ /** 7 channel audio stream */
+ CH_7,
+ /** 8 channel audio stream */
+ CH_8,
+};
+#endif /* __HDMI_AUDIO_CHANNELNUMBER__ */
+
+#ifndef __HDMI_AUDIO_AUDIOSAMPLEPACKETTYPE__
+#define __HDMI_AUDIO_AUDIOSAMPLEPACKETTYPE__
+/**
+ * @enum HDMIASPType
+ * Type of HDMI audio sample packet
+ */
+enum HDMIASPType {
+ /** Audio Sample Packet Type */
+ HDMI_ASP,
+ /** One Bit Audio Packet Type */
+ HDMI_DSD,
+ /** High Bit Rate Packet Type */
+ HDMI_HBR,
+ /** DST Packet Type */
+ HDMI_DST
+};
+#endif /* __HDMI_AUDID_AUDIOSAMPLEPACKETTYPE__ */
+
+#ifndef __HDMI_AUDIO_I2S_CUV_AUDIO_CODING_TYPE__
+#define __HDMI_AUDIO_I2S_CUV_AUDIO_CODING_TYPE__
+/**
+ * @enum CUVAudioCoding
+ * Audio coding type information for CUV fields.
+ */
+enum CUVAudioCoding {
+ /** Linear PCM coding type */
+ CUV_LPCM,
+ /** Non-linear PCM coding type */
+ CUV_NLPCM
+};
+#endif /* __HDMI_AUDIO_I2S_CUV_AUDIO_CODING_TYPE__ */
+
+#ifndef __HDMI_AUDIO_SPDIF_AUDIO_CODING_TYPE__
+#define __HDMI_AUDIO_SPDIF_AUDIO_CODING_TYPE__
+/**
+ * @enum SPDIFAudioCoding
+ * Audio coding type information for SPDIF input port.
+ */
+enum SPDIFAudioCoding {
+ /** Linear PCM coding type */
+ SPDIF_LPCM,
+ /** Non-linear PCM coding type */
+ SPDIF_NLPCM
+};
+#endif /* __HDMI_AUDIO_SPDIF_AUDIO_CODING_TYPE__ */
+
+#ifndef __HDMI_AUDIO_I2S_CUV_CHANNEL_NUMBER__
+#define __HDMI_AUDIO_I2S_CUV_CHANNEL_NUMBER__
+/**
+ * @enum CUVChannelNumber
+ * Channel number information for CUV fields.
+ */
+enum CUVChannelNumber {
+ /** Unknown channel audio stream */
+ CUV_CH_UNDEFINED = 0,
+ /** 1 channel audio stream */
+ CUV_CH_01,
+ /** 2 channel audio stream */
+ CUV_CH_02,
+ /** 3 channel audio stream */
+ CUV_CH_03,
+ /** 4 channel audio stream */
+ CUV_CH_04,
+ /** 5 channel audio stream */
+ CUV_CH_05,
+ /** 6 channel audio stream */
+ CUV_CH_06,
+ /** 7 channel audio stream */
+ CUV_CH_07,
+ /** 8 channel audio stream */
+ CUV_CH_08,
+ /** 9 channel audio stream */
+ CUV_CH_09,
+ /** 10 channel audio stream */
+ CUV_CH_10,
+ /** 11 channel audio stream */
+ CUV_CH_11,
+ /** 12 channel audio stream */
+ CUV_CH_12,
+ /** 13 channel audio stream */
+ CUV_CH_13,
+ /** 14 channel audio stream */
+ CUV_CH_14,
+ /** 15 channel audio stream */
+ CUV_CH_15,
+};
+#endif /* __HDMI_AUDIO_I2S_CUV_CHANNEL_NUMBER__ */
+
+#ifndef __HDMI_AUDIO_I2S_CUV_WORD_LENGTH__
+#define __HDMI_AUDIO_I2S_CUV_WORD_LENGTH__
+/**
+ * @enum CUVWordLength
+ * Word length information of LPCM audio stream for CUV fields.
+ */
+enum CUVWordLength {
+ /** Max word length is 20 bits, number of valid bits is not defined */
+ CUV_WL_20_NOT_DEFINED,
+ /** Max word length is 20 bits, 16 bits are valid */
+ CUV_WL_20_16,
+ /** Max word length is 20 bits, 18 bits are valid */
+ CUV_WL_20_18,
+ /** Max word length is 20 bits, 19 bits are valid */
+ CUV_WL_20_19,
+ /** Max word length is 20 bits, 20 bits are valid */
+ CUV_WL_20_20,
+ /** Max word length is 20 bits, 17 bits are valid */
+ CUV_WL_20_17,
+ /** Max word length is 24 bits, number of valid bits is not defined */
+ CUV_WL_24_NOT_DEFINED,
+ /** Max word length is 24 bits, 20 bits are valid */
+ CUV_WL_24_20,
+ /** Max word length is 24 bits, 22 bits are valid */
+ CUV_WL_24_22,
+ /** Max word length is 24 bits, 23 bits are valid */
+ CUV_WL_24_23,
+ /** Max word length is 24 bits, 24 bits are valid */
+ CUV_WL_24_24,
+ /** Max word length is 24 bits, 21 bits are valid */
+ CUV_WL_24_21,
+};
+#endif /* __HDMI_AUDIO_I2S_CUV_WORD_LENGTH__ */
+
+#ifndef __HDMI_AUDIO_I2S_BITS_PER_CHANNEL__
+#define __HDMI_AUDIO_I2S_BITS_PER_CHANNEL__
+
+/**
+ * @enum I2SBitsPerChannel
+ * Serial data bit per channel in I2S audio stream.
+ */
+enum I2SBitsPerChannel {
+ /** 16 bits per channel */
+ I2S_BPC_16,
+ /** 20 bits per channel */
+ I2S_BPC_20,
+ /** 24 bits per channel */
+ I2S_BPC_24
+};
+
+#endif /* __HDMI_AUDIO_I2S_BITS_PER_CHANNEL__ */
+
+#ifndef __HDMI_AUDIO_I2S_DATA_FORMAT__
+#define __HDMI_AUDIO_I2S_DATA_FORMAT__
+
+/**
+ * @enum I2SDataFormat
+ * Foramt of data in I2S audio stream.
+ */
+enum I2SDataFormat {
+ /** Basic format */
+ I2S_BASIC,
+ /** Left justified format */
+ I2S_LEFT_JUSTIFIED,
+ /** Right justified format */
+ I2S_RIGHT_JUSTIFIED
+};
+
+#endif /* __HDMI_AUDIO_I2S_DATA_FORMAT__ */
+
+#ifndef __HDMI_AUDIO_I2S_CLOCK_PER_FRAME__
+#define __HDMI_AUDIO_I2S_CLOCK_PER_FRAME__
+
+/**
+ * @enum I2SClockPerFrame
+ * Bit clock per Frame in I2S audio stream.
+ */
+enum I2SClockPerFrame {
+ /** 32 clock per Frame */
+ I2S_32FS,
+ /** 48 clock per Frame */
+ I2S_48FS,
+ /** 64 clock per Frame */
+ I2S_64FS
+};
+
+#endif /* __HDMI_AUDIO_I2S_CLOCK_PER_FRAME__ */
+
+#ifndef __HDMI_AUDIO_I2S_PARAMETER__
+#define __HDMI_AUDIO_I2S_PARAMETER__
+
+//! Structure for I2S audio stream
+struct I2SParameter {
+ enum I2SBitsPerChannel bpc;
+ enum I2SDataFormat format;
+ enum I2SClockPerFrame clk;
+};
+#endif /* __HDMI_AUDIO_I2S_PARAMETER__ */
+
+//! Structure for HDMI audio input
+struct HDMIAudioParameter {
+ /** Input audio port to HDMI HW */
+ enum HDMIAudioPort inputPort;
+ /** Output Packet type **/
+ enum HDMIASPType outPacket;
+ /** Encoding format */
+ enum AudioFormat formatCode;
+ /** Channel number */
+ enum ChannelNum channelNum;
+ /** Sampling frequency */
+ enum SamplingFreq sampleFreq;
+ /** Word length. This is avaliable only if LPCM encoding format */
+ enum LPCM_WordLen wordLength;
+ /** structure for I2S audio stream */
+ struct I2SParameter i2sParam;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _AUDIO_H_
diff --git a/exynos4/hal/include/exynos_mem.h b/exynos4/hal/include/exynos_mem.h
new file mode 100644
index 0000000..a65f030
--- /dev/null
+++ b/exynos4/hal/include/exynos_mem.h
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+#ifndef __INCLUDE_EXYNOS_MEM_H
+#define __INCLUDE_EXYNOS_MEM_H __FILE__
+
+/* IOCTL commands */
+#define EXYNOS_MEM_SET_CACHEABLE _IOW('M', 200, bool)
+#define EXYNOS_MEM_PADDR_CACHE_FLUSH _IOW('M', 201, struct exynos_mem_flush_range)
+
+struct exynos_mem_flush_range {
+ dma_addr_t start;
+ size_t length;
+};
+
+#endif /* __INCLUDE_EXYNOS_MEM_H */
diff --git a/exynos4/hal/include/gralloc_priv.h b/exynos4/hal/include/gralloc_priv.h
new file mode 100644
index 0000000..9f3346a
--- /dev/null
+++ b/exynos4/hal/include/gralloc_priv.h
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef GRALLOC_PRIV_H_
+#define GRALLOC_PRIV_H_
+
+#include <stdint.h>
+#include <pthread.h>
+#include <errno.h>
+#include <linux/fb.h>
+
+#include <hardware/gralloc.h>
+#include <cutils/native_handle.h>
+
+#include <ump/ump.h>
+
+#define GRALLOC_ARM_UMP_MODULE 1
+
+struct private_handle_t;
+
+struct private_module_t
+{
+ gralloc_module_t base;
+
+ private_handle_t* framebuffer;
+ uint32_t flags;
+ uint32_t numBuffers;
+ uint32_t bufferMask;
+ pthread_mutex_t lock;
+ buffer_handle_t currentBuffer;
+
+ struct fb_var_screeninfo info;
+ struct fb_fix_screeninfo finfo;
+ float xdpi;
+ float ydpi;
+ float fps;
+
+ enum
+ {
+ // flag to indicate we'll post this buffer
+ PRIV_USAGE_LOCKED_FOR_POST = 0x80000000
+ };
+};
+
+#ifdef __cplusplus
+struct private_handle_t : public native_handle
+{
+#else
+struct private_handle_t
+{
+ struct native_handle nativeHandle;
+#endif
+
+ enum
+ {
+ PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
+ PRIV_FLAGS_USES_UMP = 0x00000002,
+ };
+
+ enum
+ {
+ LOCK_STATE_WRITE = 1<<31,
+ LOCK_STATE_MAPPED = 1<<30,
+ LOCK_STATE_READ_MASK = 0x3FFFFFFF
+ };
+
+ // ints
+ int magic;
+ int flags;
+ int size;
+ int base;
+ int lockState;
+ int writeOwner;
+ int pid;
+
+ // Following members are for UMP memory only
+ int ump_id;
+ int ump_mem_handle;
+
+ // Following members is for framebuffer only
+ int fd;
+ int offset;
+
+
+#ifdef __cplusplus
+ static const int sNumInts = 11;
+ static const int sNumFds = 0;
+ static const int sMagic = 0x3141592;
+
+ private_handle_t(int flags, int size, int base, int lock_state, ump_secure_id secure_id, ump_handle handle):
+ magic(sMagic),
+ flags(flags),
+ size(size),
+ base(base),
+ lockState(lock_state),
+ writeOwner(0),
+ pid(getpid()),
+ ump_id((int)secure_id),
+ ump_mem_handle((int)handle),
+ fd(0),
+ offset(0)
+ {
+ version = sizeof(native_handle);
+ numFds = sNumFds;
+ numInts = sNumInts;
+ }
+
+ private_handle_t(int flags, int size, int base, int lock_state, int fb_file, int fb_offset):
+ magic(sMagic),
+ flags(flags),
+ size(size),
+ base(base),
+ lockState(lock_state),
+ writeOwner(0),
+ pid(getpid()),
+ ump_id((int)UMP_INVALID_SECURE_ID),
+ ump_mem_handle((int)UMP_INVALID_MEMORY_HANDLE),
+ fd(fb_file),
+ offset(fb_offset)
+ {
+ version = sizeof(native_handle);
+ numFds = sNumFds;
+ numInts = sNumInts;
+ }
+
+ ~private_handle_t()
+ {
+ magic = 0;
+ }
+
+ bool usesPhysicallyContiguousMemory()
+ {
+ return (flags & PRIV_FLAGS_FRAMEBUFFER) ? true : false;
+ }
+
+ static int validate(const native_handle* h)
+ {
+ const private_handle_t* hnd = (const private_handle_t*)h;
+ if (!h || h->version != sizeof(native_handle) || h->numInts != sNumInts || h->numFds != sNumFds || hnd->magic != sMagic)
+ {
+ return -EINVAL;
+ }
+ return 0;
+ }
+
+ static private_handle_t* dynamicCast(const native_handle* in)
+ {
+ if (validate(in) == 0)
+ {
+ return (private_handle_t*) in;
+ }
+ return NULL;
+ }
+#endif
+};
+
+#endif /* GRALLOC_PRIV_H_ */
diff --git a/exynos4/hal/include/i2c-dev.h b/exynos4/hal/include/i2c-dev.h
new file mode 100644
index 0000000..a7a35a7
--- /dev/null
+++ b/exynos4/hal/include/i2c-dev.h
@@ -0,0 +1,74 @@
+/*
+ i2c-dev.h - i2c-bus driver, char device interface
+
+ Copyright (C) 1995-97 Simon G. Vogl
+ Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _LINUX_I2C_DEV_H
+#define _LINUX_I2C_DEV_H
+
+#include <linux/types.h>
+#include <linux/compiler.h>
+
+/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an
+ * unsigned long, except for:
+ * - I2C_FUNCS, takes pointer to an unsigned long
+ * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
+ * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
+ */
+#define I2C_RETRIES 0x0701 /* number of times a device address should
+ be polled when not acknowledging */
+#define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */
+
+/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
+ * are NOT supported! (due to code brokenness)
+ */
+#define I2C_SLAVE 0x0703 /* Use this slave address */
+#define I2C_SLAVE_FORCE 0x0706 /* Use this slave address, even if it
+ is already in use by a driver! */
+#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */
+
+#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */
+
+#define I2C_RDWR 0x0707 /* Combined R/W transfer (one STOP only) */
+
+#define I2C_PEC 0x0708 /* != 0 to use PEC with SMBus */
+#define I2C_SMBUS 0x0720 /* SMBus transfer */
+
+
+/* This is the structure as used in the I2C_SMBUS ioctl call */
+struct i2c_smbus_ioctl_data {
+ __u8 read_write;
+ __u8 command;
+ __u32 size;
+ union i2c_smbus_data __user *data;
+};
+
+/* This is the structure as used in the I2C_RDWR ioctl call */
+struct i2c_rdwr_ioctl_data {
+ struct i2c_msg __user *msgs; /* pointers to i2c_msgs */
+ __u32 nmsgs; /* number of i2c_msgs */
+};
+
+#define I2C_RDRW_IOCTL_MAX_MSGS 42
+
+#ifdef __KERNEL__
+#define I2C_MAJOR 89 /* Device major number */
+#endif
+
+#endif /* _LINUX_I2C_DEV_H */
diff --git a/exynos4/hal/include/ion.h b/exynos4/hal/include/ion.h
new file mode 100644
index 0000000..dbb8896
--- /dev/null
+++ b/exynos4/hal/include/ion.h
@@ -0,0 +1,144 @@
+#ifndef _LIB_ION_H_
+#define _LIB_ION_H_
+
+#include <unistd.h> /* size_t */
+
+#define ION_HEAP_SYSTEM_MASK (1 << 0)
+#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << 1)
+#define ION_HEAP_EXYNOS_MASK (1 << 4)
+#define ION_HEAP_EXYNOS_CONTIG_MASK (1 << 5)
+
+/* ION_MSYNC_FLAGS
+ * values of @flags parameter to ion_msync()
+ *
+ * IMSYNC_DEV_TO_READ: Device only reads the buffer
+ * IMSYNC_DEV_TO_WRITE: Device may writes to the buffer
+ * IMSYNC_DEV_TO_RW: Device reads and writes to the buffer
+ *
+ * IMSYNC_SYNC_FOR_DEV: ion_msync() for device to access the buffer
+ * IMSYNC_SYNC_FOR_CPU: ion_msync() for CPU to access the buffer after device
+ * has accessed it.
+ *
+ * The values must be ORed with one of IMSYNC_DEV_* and one of IMSYNC_SYNC_*.
+ * Otherwise, ion_msync() will not effect.
+ */
+enum ION_MSYNC_FLAGS {
+ IMSYNC_DEV_TO_READ = 0,
+ IMSYNC_DEV_TO_WRITE = 1,
+ IMSYNC_DEV_TO_RW = 2,
+ IMSYNC_SYNC_FOR_DEV = 0x10000,
+ IMSYNC_SYNC_FOR_CPU = 0x20000,
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ion_client
+ * An ION client is an object or an entity that needs to use the service of
+ * ION and has unique address space. ion_client is an identifier of an ION
+ * client and it represents the ION client.
+ * All operations on ION needs a valid ion_client value and it can be obtained
+ * by ion_client_create().
+ */
+typedef int ion_client;
+
+/* ion_buffer
+ * An identifier of a buffer allocated from ION. You must obtain to access
+ * a buffer allocated from ION. If you have an effective ion_buffer, you have
+ * three options to work with it.
+ * - To access the buffer, you can request an address (user virtual address)
+ * of the buffer with ion_map().
+ * - To pass the buffer to the kernel, you can pass the ion_buffer to the
+ * kernel driver directly, if the kernel driver can work with ION.
+ * - To pass the buffer to other processes, you can pass the ion_buffer to
+ * other processes through RPC machanism such as socket communication or
+ * Android Binder because ion_buffer is actually an open file descripotor
+ * of the current process.
+ */
+typedef int ion_buffer;
+
+/* ion_client_create()
+ * @RETURN: new ion_client.
+ * netative value if creating new ion_client is failed.
+ *
+ * A call to ion_client_create() must be paired with ion_client_destroy(),
+ * symmetrically. ion_client_destroy() needs a valid ion_client that
+ * is returned by ion_client_create().
+ */
+ion_client ion_client_create(void);
+
+/* ion_client_destroy()
+ * @client: An ion_client value to remove.
+ */
+void ion_client_destroy(ion_client client);
+
+/* ion_alloc() - Allocates new buffer from ION.
+ * @client: A valid ion_client value returned by ion_client_create().
+ * @len: Size of a buffer required in bytes.
+ * @align: Alignment requirements of @len and the start address of the allocated
+ * buffer. If the @len is not aligned by @align, ION allocates a buffer
+ * that is aligned by @align and the size of the buffer will be larger
+ * than @len.
+ * @flags: Additional requirements about buffer. ION_HEAP_SYSTEM_CONTIG_MASK
+ * for allocating physically contiguous buffer and ION_HEAP_SYSTEM_MASK
+ * for virtually contiguous buffer. You can combine those flags or
+ * simply give -1(0xFFFFFFFF) if you do not care about the contiguouty
+ * of the buffer.
+ * @RETURN: An ion_buffer that represents the buffer allocated. It is only
+ * unique in the context of the given client, @client.
+ * -error if the allocation failed.
+ * See the description of ion_buffer above for detailed information.
+ */
+ion_buffer ion_alloc(ion_client client, size_t len, size_t align,
+ unsigned int flags);
+
+/* ion_free() - Frees an existing buffer that is allocated by ION
+ * @buffer: An ion_buffer of the buffer to be released.
+ */
+void ion_free(ion_buffer buffer);
+
+/* ion_map() - Obtains a virtual address of the buffer identied by @buffer
+ * @buffer: The buffer to map. The virtual address returned is allocated by the
+ * kernel.
+ * @len: The size of the buffer to map. This must not exceed the size of the
+ * buffer represented by @fd_buf. Thus you need to know the size of it
+ * before calling this function. If @len is less than the size of the
+ * buffer, this function just map just the size requested (@len) not the
+ * entire buffer.
+ * @offset: How many pages will be ignored while mapping.@offset number of
+ * pages from the start of the buffer will not be mapped.
+ * @RETURN: The start virtual addres mapped.
+ * MAP_FAILED if mapping fails.
+ *
+ * Note that @len + (@offset * PAGE_SIZE) must not exceed the size of the
+ * buffer.
+ */
+void *ion_map(ion_buffer buffer, size_t len, off_t offset);
+
+/* ion_unmap() - Frees the buffer mapped by ion_map()
+ * @addr: The address returned by ion_map().
+ * @len: The size of the buffer mapped by ion_map().
+ * @RETURN: 0 on success, and -1 on failure.
+ * errno is also set on failure.
+ */
+int ion_unmap(void *addr, size_t len);
+
+/* ion_msync() - Makes sure that data in the buffer are visible to H/W peri.
+ * @client: A valid ion_client value returned by ion_client_create().
+ * @buffer: The buffer to perform ion_msync().
+ * @flags: Direction of access of H/W peri and CPU. See the description of
+ * ION_MSYNC_FLAGS.
+ * @size: Size to ion_msync() in bytes.
+ * @offset: Where ion_msync() start in @buffer, size in bytes.
+ * @RETURN: 0 if successful. -error, otherwise.
+ *
+ * Note that @offset + @size must not exceed the size of @buffer.
+ */
+int ion_msync(ion_client client, ion_buffer buffer, long flags,
+ size_t size, off_t offset);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _LIB_ION_H_ */
diff --git a/exynos4/hal/include/jpeg_api.h b/exynos4/hal/include/jpeg_api.h
new file mode 100644
index 0000000..f2685e1
--- /dev/null
+++ b/exynos4/hal/include/jpeg_api.h
@@ -0,0 +1,121 @@
+#ifndef __JPEG_API_H__
+#define __JPEG_API_H__
+
+#define JPEG_DRIVER_NAME "/dev/s5p-jpeg"
+
+#define MAX_JPEG_WIDTH 3264
+#define MAX_JPEG_HEIGHT 2448
+
+#define MAX_JPEG_RES (MAX_JPEG_WIDTH * MAX_JPEG_HEIGHT)
+
+#define JPEG_STREAM_BUF_SIZE MAX_JPEG_RES
+#define JPEG_FRAME_BUF_SIZE (MAX_JPEG_RES * 3)
+
+#define JPEG_TOTAL_BUF_SIZE (JPEG_STREAM_BUF_SIZE + JPEG_FRAME_BUF_SIZE)
+
+#define JPEG_IOCTL_MAGIC 'J'
+
+#define IOCTL_JPEG_DEC_EXE _IO(JPEG_IOCTL_MAGIC, 1)
+#define IOCTL_JPEG_ENC_EXE _IO(JPEG_IOCTL_MAGIC, 2)
+#define IOCTL_GET_DEC_IN_BUF _IO(JPEG_IOCTL_MAGIC, 3)
+#define IOCTL_GET_DEC_OUT_BUF _IO(JPEG_IOCTL_MAGIC, 4)
+#define IOCTL_GET_ENC_IN_BUF _IO(JPEG_IOCTL_MAGIC, 5)
+#define IOCTL_GET_ENC_OUT_BUF _IO(JPEG_IOCTL_MAGIC, 6)
+#define IOCTL_SET_DEC_PARAM _IO(JPEG_IOCTL_MAGIC, 7)
+#define IOCTL_SET_ENC_PARAM _IO(JPEG_IOCTL_MAGIC, 8)
+
+enum jpeg_ret_type{
+ JPEG_FAIL,
+ JPEG_OK,
+ JPEG_ENCODE_FAIL,
+ JPEG_ENCODE_OK,
+ JPEG_DECODE_FAIL,
+ JPEG_DECODE_OK,
+ JPEG_OUT_OF_MEMORY,
+ JPEG_UNKNOWN_ERROR
+};
+
+enum jpeg_img_quality_level {
+ QUALITY_LEVEL_1 = 0, /* high */
+ QUALITY_LEVEL_2,
+ QUALITY_LEVEL_3,
+ QUALITY_LEVEL_4, /* low */
+};
+
+/* raw data image format */
+enum jpeg_frame_format {
+ YUV_422, /* decode output, encode input */
+ YUV_420, /* decode output, encode output */
+ RGB_565, /* encode input */
+};
+
+/* jpeg data format */
+enum jpeg_stream_format {
+ JPEG_422, /* decode input, encode output */
+ JPEG_420, /* decode input, encode output */
+ JPEG_444, /* decode input*/
+ JPEG_GRAY, /* decode input*/
+ JPEG_RESERVED,
+};
+
+enum jpeg_test_mode {
+ encode_mode,
+ decode_mode,
+};
+
+struct jpeg_dec_param {
+ unsigned int width;
+ unsigned int height;
+ unsigned int size;
+ enum jpeg_stream_format in_fmt;
+ enum jpeg_frame_format out_fmt;
+};
+
+struct jpeg_enc_param {
+ unsigned int width;
+ unsigned int height;
+ unsigned int size;
+ enum jpeg_frame_format in_fmt;
+ enum jpeg_stream_format out_fmt;
+ enum jpeg_img_quality_level quality;
+};
+
+struct jpeg_args{
+ char *in_buf;
+ unsigned int in_cookie;
+ unsigned int in_buf_size;
+ char *out_buf;
+ unsigned int out_cookie;
+ unsigned int out_buf_size;
+ char *mmapped_addr;
+ struct jpeg_dec_param *dec_param;
+ struct jpeg_enc_param *enc_param;
+};
+
+struct jpeg_lib {
+ int jpeg_fd;
+ struct jpeg_args args;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int api_jpeg_decode_init();
+int api_jpeg_encode_init();
+int api_jpeg_decode_deinit(int dev_fd);
+int api_jpeg_encode_deinit(int dev_fd);
+void *api_jpeg_get_decode_in_buf(int dev_fd, unsigned int size);
+void *api_jpeg_get_encode_in_buf(int dev_fd, unsigned int size);
+void *api_jpeg_get_decode_out_buf(int dev_fd);
+void *api_jpeg_get_encode_out_buf(int dev_fd);
+void api_jpeg_set_decode_param(struct jpeg_dec_param *param);
+void api_jpeg_set_encode_param(struct jpeg_enc_param *param);
+enum jpeg_ret_type api_jpeg_decode_exe(int dev_fd,
+ struct jpeg_dec_param *dec_param);
+enum jpeg_ret_type api_jpeg_encode_exe(int dev_fd,
+ struct jpeg_enc_param *enc_param);
+#ifdef __cplusplus
+}
+#endif
+
+#endif//__JPEG_API_H__
diff --git a/exynos4/hal/include/jpeg_hal.h b/exynos4/hal/include/jpeg_hal.h
new file mode 100644
index 0000000..5c55592
--- /dev/null
+++ b/exynos4/hal/include/jpeg_hal.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 "videodev2.h"
+
+#define JPEG_DEC_NODE "/dev/video11"
+#define JPEG_ENC_NODE "/dev/video12"
+
+#define JPEG_MAX_PLANE_CNT 3
+#define JPEG_DEC_OUT_BYTE_ALIGN 8
+
+//#define JPEG_PERF_MEAS
+
+#ifdef JPEG_PERF_MEAS
+#define JPEG_PERF_DEFINE(n) \
+ struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0;
+
+#define JPEG_PERF_START(n) \
+ gettimeofday(&time_start_##n, NULL);
+
+#define JPEG_PERF_END(n) \
+ gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time(&time_start_##n, &time_stop_##n);
+
+#define JPEG_PERF(n) \
+ log_time_##n
+#else
+#define JPEG_PERF_DEFINE(n)
+#define JPEG_PERF_START(n)
+#define JPEG_PERF_END(n)
+#define JPEG_PERF(n)
+#endif
+
+enum jpeg_ret_type {
+ JPEG_FAIL,
+ JPEG_OK,
+ JPEG_ENCODE_FAIL,
+ JPEG_ENCODE_OK,
+ JPEG_DECODE_FAIL,
+ JPEG_DECODE_OK,
+ JPEG_OUT_OF_MEMORY,
+ JPEG_UNKNOWN_ERROR
+};
+
+enum jpeg_quality_level {
+ QUALITY_LEVEL_1 = 0, /* high */
+ QUALITY_LEVEL_2,
+ QUALITY_LEVEL_3,
+ QUALITY_LEVEL_4, /* low */
+};
+
+enum jpeg_mode {
+ JPEG_ENCODE,
+ JPEG_DECODE
+};
+
+struct jpeg_buf {
+ int num_planes;
+ void *start[JPEG_MAX_PLANE_CNT];
+ int length[JPEG_MAX_PLANE_CNT];
+ enum v4l2_memory memory;
+ enum v4l2_buf_type buf_type; // Caller need not set this
+};
+
+struct jpeg_buf_info {
+ int num_planes;
+ enum v4l2_memory memory;
+ enum v4l2_buf_type buf_type;
+ int reserved[4];
+};
+
+struct jpeg_pixfmt {
+ int in_fmt;
+ int out_fmt;
+ int reserved[4];
+};
+
+struct jpeg_config {
+ enum jpeg_mode mode;
+ enum jpeg_quality_level enc_qual; // for encoding
+
+ int width;
+ int height;
+
+ int num_planes;
+
+ int scaled_width; // 1/2, 1/4 scaling for decoding
+ int scaled_height; // 1/2, 1/4 scaling for decoding
+
+ int sizeJpeg;
+
+ union {
+ struct jpeg_pixfmt enc_fmt;
+ struct jpeg_pixfmt dec_fmt;
+ } pix;
+
+ int reserved[8];
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int jpeghal_dec_init();
+int jpeghal_enc_init();
+
+int jpeghal_dec_setconfig(int fd, struct jpeg_config *config);
+int jpeghal_enc_setconfig(int fd, struct jpeg_config *config);
+int jpeghal_dec_getconfig(int fd, struct jpeg_config *config);
+int jpeghal_enc_getconfig(int fd, struct jpeg_config *config);
+
+int jpeghal_set_inbuf(int fd, struct jpeg_buf *buf);
+int jpeghal_set_outbuf(int fd, struct jpeg_buf *buf);
+
+int jpeghal_dec_exe(int fd, struct jpeg_buf *in_buf, struct jpeg_buf *out_buf);
+int jpeghal_enc_exe(int fd, struct jpeg_buf *in_buf, struct jpeg_buf *out_buf);
+
+int jpeghal_deinit(int fd, struct jpeg_buf *in_buf, struct jpeg_buf *out_buf);
+
+int jpeghal_s_ctrl(int fd, int cid, int value);
+int jpeghal_g_ctrl(int fd, int id);
+
+unsigned long measure_time(struct timeval *start, struct timeval *stop);
+#ifdef __cplusplus
+}
+#endif
diff --git a/exynos4/hal/include/s3c_lcd.h b/exynos4/hal/include/s3c_lcd.h
new file mode 100644
index 0000000..7f2dec7
--- /dev/null
+++ b/exynos4/hal/include/s3c_lcd.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 _S3CFB_LCD_
+#define _S3CFB_LCD_
+
+/*
+ * S T R U C T U R E S F O R C U S T O M I O C T L S
+ *
+*/
+struct s3cfb_user_window {
+ int x;
+ int y;
+};
+
+struct s3cfb_user_plane_alpha {
+ int channel;
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+};
+
+struct s3cfb_user_chroma {
+ int enabled;
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+};
+
+typedef struct {
+ unsigned int phy_start_addr;
+ unsigned int xres; /* visible resolution*/
+ unsigned int yres;
+ unsigned int xres_virtual; /* virtual resolution*/
+ unsigned int yres_virtual;
+ unsigned int xoffset; /* offset from virtual to visible */
+ unsigned int yoffset; /* resolution */
+ unsigned int lcd_offset_x;
+ unsigned int lcd_offset_y;
+} s3c_fb_next_info_t;
+
+#ifdef BOARD_USE_V4L2_ION
+struct s3c_fb_user_ion_client {
+ int fd;
+ int offset;
+};
+#endif
+
+/*
+ * C U S T O M I O C T L S
+ *
+*/
+
+#define S3CFB_WIN_POSITION _IOW ('F', 203, struct s3cfb_user_window)
+#define S3CFB_WIN_SET_PLANE_ALPHA _IOW ('F', 204, struct s3cfb_user_plane_alpha)
+#define S3CFB_WIN_SET_CHROMA _IOW ('F', 205, struct s3cfb_user_chroma)
+#define S3CFB_SET_VSYNC_INT _IOW ('F', 206, unsigned int)
+#define S3CFB_SET_SUSPEND_FIFO _IOW ('F', 300, unsigned long)
+#define S3CFB_SET_RESUME_FIFO _IOW ('F', 301, unsigned long)
+#define S3CFB_GET_LCD_WIDTH _IOR ('F', 302, int)
+#define S3CFB_GET_LCD_HEIGHT _IOR ('F', 303, int)
+#define S3CFB_GET_FB_PHY_ADDR _IOR ('F', 310, unsigned int)
+#define S3C_FB_GET_CURR_FB_INFO _IOR ('F', 305, s3c_fb_next_info_t)
+#define S3CFB_GET_ION_USER_HANDLE _IOWR('F', 208, struct s3c_fb_user_ion_client)
+
+/***************** LCD frame buffer *****************/
+#define FB0_NAME "/dev/fb0"
+#define FB1_NAME "/dev/fb1"
+#define FB2_NAME "/dev/fb2"
+#define FB3_NAME "/dev/fb3"
+#define FB4_NAME "/dev/fb4"
+
+#endif
diff --git a/exynos4/hal/include/s3c_mem.h b/exynos4/hal/include/s3c_mem.h
new file mode 100644
index 0000000..dd4cbdb
--- /dev/null
+++ b/exynos4/hal/include/s3c_mem.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 _S3C_MEM_COMMON_H_
+#define _S3C_MEM_COMMON_H_
+
+#define MEM_IOCTL_MAGIC 'M'
+
+#define S3C_MEM_ALLOC _IOWR(MEM_IOCTL_MAGIC, 310, struct s3c_mem_alloc)
+#define S3C_MEM_FREE _IOWR(MEM_IOCTL_MAGIC, 311, struct s3c_mem_alloc)
+
+#define S3C_MEM_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 314, struct s3c_mem_alloc)
+#define S3C_MEM_SHARE_FREE _IOWR(MEM_IOCTL_MAGIC, 315, struct s3c_mem_alloc)
+
+#define S3C_MEM_CACHEABLE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 316, struct s3c_mem_alloc)
+#define S3C_MEM_CACHEABLE_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 317, struct s3c_mem_alloc)
+
+#define S3C_MEM_CACHE_FLUSH _IOWR(MEM_IOCTL_MAGIC, 318, struct s3c_mem_alloc)
+#define S3C_MEM_CACHE_INVAL _IOWR(MEM_IOCTL_MAGIC, 319, struct s3c_mem_alloc)
+#define S3C_MEM_CACHE_CLEAN _IOWR(MEM_IOCTL_MAGIC, 320, struct s3c_mem_alloc)
+
+struct s3c_mem_alloc {
+ int size;
+ unsigned int vir_addr;
+ unsigned int phy_addr;
+};
+
+struct s3c_mem_dma_param {
+ int size;
+ unsigned int src_addr;
+ unsigned int dst_addr;
+ int cfg;
+};
+
+#endif // _S3C_MEM_COMMON_H_
diff --git a/exynos4/hal/include/s5p_fimc.h b/exynos4/hal/include/s5p_fimc.h
new file mode 100644
index 0000000..b813e69
--- /dev/null
+++ b/exynos4/hal/include/s5p_fimc.h
@@ -0,0 +1,162 @@
+/* Copyright(c) 2011 Samsung Electronics Co, Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, 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 _S5P_FIMC_H_
+#define _S5P_FIMC_H_
+
+#include <linux/videodev2.h>
+#include "SecBuffer.h"
+/*
+ * G E N E R A L S
+ *
+*/
+#define MIN(x, y) ((x < y) ? x : y)
+
+/*
+ * P I X E L F O R M A T G U I D E
+ *
+ * The 'x' means 'DO NOT CARE'
+ * The '*' means 'FIMC SPECIFIC'
+ * For some fimc formats, we couldn't find equivalent format in the V4L2 FOURCC.
+ *
+ * FIMC TYPE PLANES ORDER V4L2_PIX_FMT
+ * ---------------------------------------------------------
+ * RGB565 x x V4L2_PIX_FMT_RGB565
+ * RGB888 x x V4L2_PIX_FMT_RGB24
+ * YUV420 2 LSB_CBCR V4L2_PIX_FMT_NV12
+ * YUV420 2 LSB_CRCB V4L2_PIX_FMT_NV21
+ * YUV420 2 MSB_CBCR V4L2_PIX_FMT_NV21X*
+ * YUV420 2 MSB_CRCB V4L2_PIX_FMT_NV12X*
+ * YUV420 3 x V4L2_PIX_FMT_YUV420
+ * YUV422 1 YCBYCR V4L2_PIX_FMT_YUYV
+ * YUV422 1 YCRYCB V4L2_PIX_FMT_YVYU
+ * YUV422 1 CBYCRY V4L2_PIX_FMT_UYVY
+ * YUV422 1 CRYCBY V4L2_PIX_FMT_VYUY*
+ * YUV422 2 LSB_CBCR V4L2_PIX_FMT_NV16*
+ * YUV422 2 LSB_CRCB V4L2_PIX_FMT_NV61*
+ * YUV422 2 MSB_CBCR V4L2_PIX_FMT_NV16X*
+ * YUV422 2 MSB_CRCB V4L2_PIX_FMT_NV61X*
+ * YUV422 3 x V4L2_PIX_FMT_YUV422P
+ *
+*/
+
+/*
+ * V 4 L 2 F I M C E X T E N S I O N S
+ *
+*/
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
+
+/* FOURCC for FIMC specific */
+#define V4L2_PIX_FMT_NV12X v4l2_fourcc('N', '1', '2', 'X')
+#define V4L2_PIX_FMT_NV21X v4l2_fourcc('N', '2', '1', 'X')
+#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')
+#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')
+#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')
+#define V4L2_PIX_FMT_NV16X v4l2_fourcc('N', '1', '6', 'X')
+#define V4L2_PIX_FMT_NV61X v4l2_fourcc('N', '6', '1', 'X')
+
+#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
+
+/* CID extensions */
+#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0)
+#define V4L2_CID_OVLY_MODE (V4L2_CID_PRIVATE_BASE + 9)
+#define V4L2_CID_DST_INFO (V4L2_CID_PRIVATE_BASE + 10)
+#define V4L2_CID_GET_PHY_SRC_YADDR (V4L2_CID_PRIVATE_BASE + 12)
+#define V4L2_CID_GET_PHY_SRC_CADDR (V4L2_CID_PRIVATE_BASE + 13)
+#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20)
+#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21)
+
+/*
+ * U S E R D E F I N E D T Y P E S
+ *
+*/
+#define FIMC1_RESERVED_SIZE 32768
+
+enum fimc_overlay_mode {
+ FIMC_OVLY_NOT_FIXED = 0x0, /* Overlay mode isn't fixed. */
+ FIMC_OVLY_FIFO = 0x1, /* Non-destructive Overlay with FIFO */
+ FIMC_OVLY_DMA_AUTO = 0x2, /* Non-destructive Overlay with DMA */
+ FIMC_OVLY_DMA_MANUAL = 0x3, /* Non-destructive Overlay with DMA */
+ FIMC_OVLY_NONE_SINGLE_BUF = 0x4, /* Destructive Overlay with DMA single destination buffer */
+ FIMC_OVLY_NONE_MULTI_BUF = 0x5, /* Destructive Overlay with DMA multiple dstination buffer */
+};
+
+typedef unsigned int dma_addr_t;
+
+struct fimc_buf {
+ dma_addr_t base[3];
+ size_t length[3];
+};
+
+struct fimc_buffer {
+ void *virt_addr;
+ void *phys_addr;
+ size_t length;
+};
+
+struct yuv_fmt_list {
+ const char *name;
+ const char *desc;
+ unsigned int fmt;
+ int bpp;
+ int planes;
+};
+
+struct img_offset {
+ int y_h;
+ int y_v;
+ int cb_h;
+ int cb_v;
+ int cr_h;
+ int cr_v;
+};
+
+//------------ STRUCT ---------------------------------------------------------//
+
+typedef struct
+{
+ unsigned int full_width; // Source Image Full Width (Virtual screen size)
+ unsigned int full_height; // Source Image Full Height (Virtual screen size)
+ unsigned int start_x; // Source Image Start width offset
+ unsigned int start_y; // Source Image Start height offset
+ unsigned int width; // Source Image Width
+ unsigned int height; // Source Image Height
+ unsigned int buf_addr_phy_rgb_y; // Base Address of the Source Image (RGB or Y): Physical Address
+ unsigned int buf_addr_phy_cb; // Base Address of the Source Image (CB Component) : Physical Address
+ unsigned int buf_addr_phy_cr; // Base Address of the Source Image (CR Component) : Physical Address
+ unsigned int color_space; // Color Space of the Source Image
+} s5p_fimc_img_info;
+
+typedef struct
+{
+ s5p_fimc_img_info src;
+ s5p_fimc_img_info dst;
+} s5p_fimc_params_t;
+
+typedef struct _s5p_fimc_t {
+ int dev_fd;
+ struct fimc_buffer out_buf;
+
+ s5p_fimc_params_t params;
+
+ int use_ext_out_mem;
+ unsigned int hw_ver;
+}s5p_fimc_t;
+
+#endif
diff --git a/exynos4/hal/include/s5p_fimc_v4l2.h b/exynos4/hal/include/s5p_fimc_v4l2.h
new file mode 100644
index 0000000..35b84a0
--- /dev/null
+++ b/exynos4/hal/include/s5p_fimc_v4l2.h
@@ -0,0 +1,164 @@
+/* Copyright(c) 2011 Samsung Electronics Co, Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, 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 _S5P_FIMC_H_
+#define _S5P_FIMC_H_
+
+#include "videodev2.h"
+#include "SecBuffer.h"
+
+/*
+ * G E N E R A L S
+ *
+*/
+
+/*
+ * P I X E L F O R M A T G U I D E
+ *
+ * The 'x' means 'DO NOT CARE'
+ * The '*' means 'FIMC SPECIFIC'
+ * For some fimc formats, we couldn't find equivalent format in the V4L2 FOURCC.
+ *
+ * FIMC TYPE PLANES ORDER V4L2_PIX_FMT
+ * ---------------------------------------------------------
+ * RGB565 x x V4L2_PIX_FMT_RGB565
+ * RGB888 x x V4L2_PIX_FMT_RGB24
+ * YUV420 2 LSB_CBCR V4L2_PIX_FMT_NV12
+ * YUV420 2 LSB_CRCB V4L2_PIX_FMT_NV21
+ * YUV420 2 MSB_CBCR V4L2_PIX_FMT_NV21X*
+ * YUV420 2 MSB_CRCB V4L2_PIX_FMT_NV12X*
+ * YUV420 3 x V4L2_PIX_FMT_YUV420
+ * YUV422 1 YCBYCR V4L2_PIX_FMT_YUYV
+ * YUV422 1 YCRYCB V4L2_PIX_FMT_YVYU
+ * YUV422 1 CBYCRY V4L2_PIX_FMT_UYVY
+ * YUV422 1 CRYCBY V4L2_PIX_FMT_VYUY*
+ * YUV422 2 LSB_CBCR V4L2_PIX_FMT_NV16*
+ * YUV422 2 LSB_CRCB V4L2_PIX_FMT_NV61*
+ * YUV422 2 MSB_CBCR V4L2_PIX_FMT_NV16X*
+ * YUV422 2 MSB_CRCB V4L2_PIX_FMT_NV61X*
+ * YUV422 3 x V4L2_PIX_FMT_YUV422P
+ *
+*/
+
+/*
+ * V 4 L 2 F I M C E X T E N S I O N S
+ *
+*/
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
+
+/* FOURCC for FIMC specific */
+#define V4L2_PIX_FMT_NV12X v4l2_fourcc('N', '1', '2', 'X')
+#define V4L2_PIX_FMT_NV21X v4l2_fourcc('N', '2', '1', 'X')
+#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')
+#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')
+#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')
+#define V4L2_PIX_FMT_NV16X v4l2_fourcc('N', '1', '6', 'X')
+#define V4L2_PIX_FMT_NV61X v4l2_fourcc('N', '6', '1', 'X')
+
+#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
+
+/* CID extensions */
+#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0)
+#define V4L2_CID_OVLY_MODE (V4L2_CID_PRIVATE_BASE + 9)
+#define V4L2_CID_DST_INFO (V4L2_CID_PRIVATE_BASE + 10)
+#define V4L2_CID_GET_PHY_SRC_YADDR (V4L2_CID_PRIVATE_BASE + 12)
+#define V4L2_CID_GET_PHY_SRC_CADDR (V4L2_CID_PRIVATE_BASE + 13)
+#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20)
+#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21)
+
+/*
+ * U S E R D E F I N E D T Y P E S
+ *
+*/
+#define FIMC1_RESERVED_SIZE 32768
+
+enum fimc_overlay_mode {
+ FIMC_OVLY_NOT_FIXED = 0x0, /* Overlay mode isn't fixed. */
+ FIMC_OVLY_FIFO = 0x1, /* Non-destructive Overlay with FIFO */
+ FIMC_OVLY_DMA_AUTO = 0x2, /* Non-destructive Overlay with DMA */
+ FIMC_OVLY_DMA_MANUAL = 0x3, /* Non-destructive Overlay with DMA */
+ FIMC_OVLY_NONE_SINGLE_BUF = 0x4, /* Destructive Overlay with DMA single destination buffer */
+ FIMC_OVLY_NONE_MULTI_BUF = 0x5, /* Destructive Overlay with DMA multiple dstination buffer */
+};
+
+typedef unsigned int dma_addr_t;
+
+struct fimc_buf {
+ dma_addr_t base[3];
+ size_t size[3];
+ int planes;
+};
+
+struct fimc_buffer {
+ void *virt_addr;
+ void *phys_addr;
+ size_t length;
+};
+
+struct yuv_fmt_list {
+ const char *name;
+ const char *desc;
+ unsigned int fmt;
+ int bpp;
+ int planes;
+};
+
+struct img_offset {
+ int y_h;
+ int y_v;
+ int cb_h;
+ int cb_v;
+ int cr_h;
+ int cr_v;
+};
+
+//------------ STRUCT ---------------------------------------------------------//
+
+typedef struct
+{
+ unsigned int full_width; // Source Image Full Width (Virtual screen size)
+ unsigned int full_height; // Source Image Full Height (Virtual screen size)
+ unsigned int start_x; // Source Image Start width offset
+ unsigned int start_y; // Source Image Start height offset
+ unsigned int width; // Source Image Width
+ unsigned int height; // Source Image Height
+ unsigned int buf_addr_phy_rgb_y; // Base Address of the Source Image (RGB or Y): Physical Address
+ unsigned int buf_addr_phy_cb; // Base Address of the Source Image (CB Component) : Physical Address
+ unsigned int buf_addr_phy_cr; // Base Address of the Source Image (CR Component) : Physical Address
+ unsigned int color_space; // Color Space of the Source Image
+ unsigned int planes; // number of planes for the Image
+} s5p_fimc_img_info;
+
+typedef struct
+{
+ s5p_fimc_img_info src;
+ s5p_fimc_img_info dst;
+} s5p_fimc_params_t;
+
+typedef struct _s5p_fimc_t {
+ int dev_fd;
+ struct fimc_buffer out_buf;
+
+ s5p_fimc_params_t params;
+
+ int use_ext_out_mem;
+ unsigned int hw_ver;
+} s5p_fimc_t;
+
+#endif
diff --git a/exynos4/hal/include/s5p_tvout.h b/exynos4/hal/include/s5p_tvout.h
new file mode 100644
index 0000000..62295d2
--- /dev/null
+++ b/exynos4/hal/include/s5p_tvout.h
@@ -0,0 +1,198 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 __S5P_TVOUT_H__
+#define __S5P_TVOUT_H__
+
+#include <linux/fb.h>
+#include "videodev2.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************
+ * Define
+ *******************************************/
+/* TVOUT control */
+#ifdef SAMSUNG_EXYNOS4210
+#define TVOUT_DEV "/dev/video14"
+#else
+#define TVOUT_DEV "/dev/video16"
+#endif
+#define HPD_DEV "/dev/HPD"
+
+/* ------------- Output -----------------*/
+/* type */
+#define V4L2_OUTPUT_TYPE_MSDMA 4
+#define V4L2_OUTPUT_TYPE_COMPOSITE 5
+#define V4L2_OUTPUT_TYPE_SVIDEO 6
+#define V4L2_OUTPUT_TYPE_YPBPR_INERLACED 7
+#define V4L2_OUTPUT_TYPE_YPBPR_PROGRESSIVE 8
+#define V4L2_OUTPUT_TYPE_RGB_PROGRESSIVE 9
+#define V4L2_OUTPUT_TYPE_DIGITAL 10
+#define V4L2_OUTPUT_TYPE_HDMI V4L2_OUTPUT_TYPE_DIGITAL
+#define V4L2_OUTPUT_TYPE_HDMI_RGB 11
+#define V4L2_OUTPUT_TYPE_DVI 12
+
+/* ------------- STD -------------------*/
+#define V4L2_STD_PAL_BDGHI\
+ (V4L2_STD_PAL_B|V4L2_STD_PAL_D|V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_PAL_I)
+
+#define V4L2_STD_480P_60_16_9 ((v4l2_std_id)0x04000000)
+#define V4L2_STD_480P_60_4_3 ((v4l2_std_id)0x05000000)
+#define V4L2_STD_576P_50_16_9 ((v4l2_std_id)0x06000000)
+#define V4L2_STD_576P_50_4_3 ((v4l2_std_id)0x07000000)
+#define V4L2_STD_720P_60 ((v4l2_std_id)0x08000000)
+#define V4L2_STD_720P_50 ((v4l2_std_id)0x09000000)
+#define V4L2_STD_1080P_60 ((v4l2_std_id)0x0a000000)
+#define V4L2_STD_1080P_50 ((v4l2_std_id)0x0b000000)
+#define V4L2_STD_1080I_60 ((v4l2_std_id)0x0c000000)
+#define V4L2_STD_1080I_50 ((v4l2_std_id)0x0d000000)
+#define V4L2_STD_480P_59 ((v4l2_std_id)0x0e000000)
+#define V4L2_STD_720P_59 ((v4l2_std_id)0x0f000000)
+#define V4L2_STD_1080I_59 ((v4l2_std_id)0x10000000)
+#define V4L2_STD_1080P_59 ((v4l2_std_id)0x11000000)
+#define V4L2_STD_1080P_30 ((v4l2_std_id)0x12000000)
+#define V4L2_STD_TVOUT_720P_60_SBS_HALF ((v4l2_std_id)0x13000000)
+#define V4L2_STD_TVOUT_720P_59_SBS_HALF ((v4l2_std_id)0x14000000)
+#define V4L2_STD_TVOUT_720P_50_TB ((v4l2_std_id)0x15000000)
+#define V4L2_STD_TVOUT_1080P_24_TB ((v4l2_std_id)0x16000000)
+#define V4L2_STD_TVOUT_1080P_23_TB ((v4l2_std_id)0x17000000)
+
+/* TVOUT video */
+#ifdef SAMSUNG_EXYNOS4210
+#define TVOUT_DEV_V "/dev/video21"
+#else
+#define TVOUT_DEV_V "/dev/video20"
+#endif
+
+/* ------------- Input ------------------*/
+/* type */
+#define V4L2_INPUT_TYPE_MSDMA 3
+#define V4L2_INPUT_TYPE_FIFO 4
+
+/* TVOUT video */
+#define PFX_NODE_FB "/dev/graphics/fb"
+
+/*******************************************
+ * structures
+ *******************************************/
+
+/* TVOUT */
+struct v4l2_vid_overlay_src {
+ void *base_y;
+ void *base_c;
+ struct v4l2_pix_format pix_fmt;
+};
+
+struct v4l2_window_s5p_tvout {
+ __u32 capability;
+ __u32 flags;
+ __u32 priority;
+ struct v4l2_window win;
+};
+
+struct v4l2_pix_format_s5p_tvout {
+ void *base_y;
+ void *base_c;
+ __u32 src_img_endian;
+ struct v4l2_pix_format pix_fmt;
+};
+
+struct vid_overlay_param {
+ struct v4l2_vid_overlay_src src;
+ struct v4l2_rect src_crop;
+ struct v4l2_framebuffer dst;
+ struct v4l2_window dst_win;
+};
+
+struct tvout_param {
+ struct v4l2_pix_format_s5p_tvout tvout_src;
+ struct v4l2_window_s5p_tvout tvout_rect;
+ struct v4l2_rect tvout_dst;
+};
+
+struct overlay_param {
+ struct v4l2_framebuffer overlay_frame;
+ struct v4l2_window_s5p_tvout overlay_rect;
+ struct v4l2_rect overlay_dst;
+};
+
+/* FB */
+struct s5ptvfb_user_window {
+ int x;
+ int y;
+};
+
+struct s5ptvfb_user_plane_alpha {
+ int channel;
+ unsigned char alpha;
+};
+
+struct s5ptvfb_user_chroma {
+ int enabled;
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+};
+
+enum s5ptvfb_ver_scaling_t {
+ VERTICAL_X1,
+ VERTICAL_X2,
+};
+
+enum s5ptvfb_hor_scaling_t {
+ HORIZONTAL_X1,
+ HORIZONTAL_X2,
+};
+
+struct s5ptvfb_user_scaling {
+ enum s5ptvfb_ver_scaling_t ver;
+ enum s5ptvfb_hor_scaling_t hor;
+};
+
+/*******************************************
+ * custom ioctls
+ *******************************************/
+
+#define VIDIOC_S_BASEADDR _IOR('V', 83, int)
+
+#define VIDIOC_HDCP_ENABLE _IOWR('V', 100, unsigned int)
+#define VIDIOC_HDCP_STATUS _IOR('V', 101, unsigned int)
+#define VIDIOC_HDCP_PROT_STATUS _IOR('V', 102, unsigned int)
+
+#define VIDIOC_INIT_AUDIO _IOR('V', 103, unsigned int)
+#define VIDIOC_AV_MUTE _IOR('V', 104, unsigned int)
+#define VIDIOC_G_AVMUTE _IOR('V', 105, unsigned int)
+#define HPD_GET_STATE _IOR('H', 100, unsigned int)
+
+#define S5PTVFB_WIN_POSITION _IOW('F', 213, struct s5ptvfb_user_window)
+#define S5PTVFB_WIN_SET_PLANE_ALPHA _IOW('F', 214, struct s5ptvfb_user_plane_alpha)
+#define S5PTVFB_WIN_SET_CHROMA _IOW('F', 215, struct s5ptvfb_user_chroma)
+
+#define S5PTVFB_SET_VSYNC_INT _IOW('F', 216, unsigned int)
+#define S5PTVFB_WAITFORVSYNC _IO('F', 32)
+#define S5PTVFB_WIN_SET_ADDR _IOW('F', 219, unsigned int)
+#define S5PTVFB_SET_WIN_ON _IOW('F', 220, unsigned int)
+#define S5PTVFB_SET_WIN_OFF _IOW('F', 221, unsigned int)
+#define S5PTVFB_SCALING _IOW('F', 222, struct s5ptvfb_user_scaling)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __S5P_TVOUT_H__ */
diff --git a/exynos4/hal/include/s5p_tvout_v4l2.h b/exynos4/hal/include/s5p_tvout_v4l2.h
new file mode 100644
index 0000000..16f78b1
--- /dev/null
+++ b/exynos4/hal/include/s5p_tvout_v4l2.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 __S5P_TVOUT_H__
+#define __S5P_TVOUT_H__
+
+#include <linux/fb.h>
+
+#include "videodev2.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************
+ * Define
+ *******************************************/
+/* TVOUT control */
+#define PFX_NODE_FB "/dev/graphics/fb"
+
+#define TVOUT_DEV_V "/dev/video20"
+#define TVOUT_DEV_G0 "/dev/video16"
+#define TVOUT_DEV_G1 "/dev/video17"
+
+#define HPD_DEV "/dev/HPD"
+
+/* ------------- Output -----------------*/
+/* type */
+#define V4L2_OUTPUT_TYPE_MSDMA 4
+#define V4L2_OUTPUT_TYPE_COMPOSITE 5
+#define V4L2_OUTPUT_TYPE_SVIDEO 6
+#define V4L2_OUTPUT_TYPE_YPBPR_INERLACED 7
+#define V4L2_OUTPUT_TYPE_YPBPR_PROGRESSIVE 8
+#define V4L2_OUTPUT_TYPE_RGB_PROGRESSIVE 9
+#define V4L2_OUTPUT_TYPE_DIGITAL 10
+#define V4L2_OUTPUT_TYPE_HDMI V4L2_OUTPUT_TYPE_DIGITAL
+#define V4L2_OUTPUT_TYPE_HDMI_RGB 11
+#define V4L2_OUTPUT_TYPE_DVI 12
+
+/* ------------- STD -------------------*/
+#define V4L2_STD_PAL_BDGHI\
+ (V4L2_STD_PAL_B|V4L2_STD_PAL_D|V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_PAL_I)
+
+#define V4L2_STD_480P_60_16_9 ((v4l2_std_id)0x04000000)
+#define V4L2_STD_480P_60_4_3 ((v4l2_std_id)0x05000000)
+#define V4L2_STD_576P_50_16_9 ((v4l2_std_id)0x06000000)
+#define V4L2_STD_576P_50_4_3 ((v4l2_std_id)0x07000000)
+#define V4L2_STD_720P_60 ((v4l2_std_id)0x08000000)
+#define V4L2_STD_720P_50 ((v4l2_std_id)0x09000000)
+#define V4L2_STD_1080P_60 ((v4l2_std_id)0x0a000000)
+#define V4L2_STD_1080P_50 ((v4l2_std_id)0x0b000000)
+#define V4L2_STD_1080I_60 ((v4l2_std_id)0x0c000000)
+#define V4L2_STD_1080I_50 ((v4l2_std_id)0x0d000000)
+#define V4L2_STD_480P_59 ((v4l2_std_id)0x0e000000)
+#define V4L2_STD_720P_59 ((v4l2_std_id)0x0f000000)
+#define V4L2_STD_1080I_59 ((v4l2_std_id)0x10000000)
+#define V4L2_STD_1080P_59 ((v4l2_std_id)0x11000000)
+#define V4L2_STD_1080P_30 ((v4l2_std_id)0x12000000)
+#define V4L2_STD_TVOUT_720P_60_SBS_HALF ((v4l2_std_id)0x13000000)
+#define V4L2_STD_TVOUT_720P_59_SBS_HALF ((v4l2_std_id)0x14000000)
+#define V4L2_STD_TVOUT_720P_50_TB ((v4l2_std_id)0x15000000)
+#define V4L2_STD_TVOUT_1080P_24_TB ((v4l2_std_id)0x16000000)
+#define V4L2_STD_TVOUT_1080P_23_TB ((v4l2_std_id)0x17000000)
+
+/* ------------- Input ------------------*/
+/* type */
+#define V4L2_INPUT_TYPE_MSDMA 3
+#define V4L2_INPUT_TYPE_FIFO 4
+
+/*******************************************
+ * structures
+ *******************************************/
+
+/* TVOUT */
+struct v4l2_vid_overlay_src {
+ void *base_y;
+ void *base_c;
+ struct v4l2_pix_format pix_fmt;
+};
+
+struct v4l2_window_s5p_tvout {
+ __u32 capability;
+ __u32 flags;
+ __u32 priority;
+ struct v4l2_window win;
+};
+
+struct v4l2_pix_format_s5p_tvout {
+ void *base_y;
+ void *base_c;
+ __u32 src_img_endian;
+ struct v4l2_pix_format pix_fmt;
+};
+
+struct vid_overlay_param {
+ struct v4l2_vid_overlay_src src;
+ struct v4l2_rect src_crop;
+ struct v4l2_framebuffer dst;
+ struct v4l2_window dst_win;
+};
+
+struct tvout_param {
+ struct v4l2_pix_format_s5p_tvout tvout_src;
+ struct v4l2_window_s5p_tvout tvout_rect;
+ struct v4l2_rect tvout_dst;
+};
+
+struct overlay_param {
+ struct v4l2_framebuffer overlay_frame;
+ struct v4l2_window_s5p_tvout overlay_rect;
+ struct v4l2_rect overlay_dst;
+};
+
+/* FB */
+struct s5ptvfb_user_window {
+ int x;
+ int y;
+};
+
+struct s5ptvfb_user_plane_alpha {
+ int channel;
+ unsigned char alpha;
+};
+
+struct s5ptvfb_user_chroma {
+ int enabled;
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+};
+
+enum s5ptvfb_ver_scaling_t {
+ VERTICAL_X1,
+ VERTICAL_X2,
+};
+
+enum s5ptvfb_hor_scaling_t {
+ HORIZONTAL_X1,
+ HORIZONTAL_X2,
+};
+
+struct s5ptvfb_user_scaling {
+ enum s5ptvfb_ver_scaling_t ver;
+ enum s5ptvfb_hor_scaling_t hor;
+};
+
+/*******************************************
+ * custom ioctls
+ *******************************************/
+
+#define VIDIOC_S_BASEADDR _IOR('V', 83, int)
+
+#define VIDIOC_HDCP_ENABLE _IOWR('V', 100, unsigned int)
+#define VIDIOC_HDCP_STATUS _IOR('V', 101, unsigned int)
+#define VIDIOC_HDCP_PROT_STATUS _IOR('V', 102, unsigned int)
+
+#define VIDIOC_INIT_AUDIO _IOR('V', 103, unsigned int)
+#define VIDIOC_AV_MUTE _IOR('V', 104, unsigned int)
+#define VIDIOC_G_AVMUTE _IOR('V', 105, unsigned int)
+#define HPD_GET_STATE _IOR('H', 100, unsigned int)
+
+#define S5PTVFB_WIN_POSITION _IOW('F', 213, struct s5ptvfb_user_window)
+#define S5PTVFB_WIN_SET_PLANE_ALPHA _IOW('F', 214, struct s5ptvfb_user_plane_alpha)
+#define S5PTVFB_WIN_SET_CHROMA _IOW('F', 215, struct s5ptvfb_user_chroma)
+
+#define S5PTVFB_SET_VSYNC_INT _IOW('F', 216, unsigned int)
+#define S5PTVFB_WAITFORVSYNC _IO('F', 32)
+#define S5PTVFB_WIN_SET_ADDR _IOW('F', 219, unsigned int)
+#define S5PTVFB_SET_WIN_ON _IOW('F', 220, unsigned int)
+#define S5PTVFB_SET_WIN_OFF _IOW('F', 221, unsigned int)
+#define S5PTVFB_SCALING _IOW('F', 222, struct s5ptvfb_user_scaling)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __S5P_TVOUT_H__ */
diff --git a/exynos4/hal/include/sec_format.h b/exynos4/hal/include/sec_format.h
new file mode 100644
index 0000000..8722b45
--- /dev/null
+++ b/exynos4/hal/include/sec_format.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 _SEC_FORMAT_H_
+#define _SEC_FORMAT_H_
+
+/* enum related to pixel format */
+
+enum {
+ HAL_PIXEL_FORMAT_YCbCr_422_P = 0x100,
+ HAL_PIXEL_FORMAT_YCbCr_420_P = 0x101,
+ HAL_PIXEL_FORMAT_YCbCr_420_I = 0x102,
+ HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x103,
+ HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x104,
+ HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x105,
+ HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x106,
+ HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x107,
+ HAL_PIXEL_FORMAT_ARGB888 = 0x108,
+ // support custom format for zero copy
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x110,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x111,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED = 0x112,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP = 0x113,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP = 0x114,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x115,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I = 0x116,
+ HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117,
+ HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I = 0x118,
+ HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I = 0x11B,
+ HAL_PIXEL_FORMAT_CUSTOM_MAX
+};
+
+#endif
diff --git a/exynos4/hal/include/sec_g2d.h b/exynos4/hal/include/sec_g2d.h
new file mode 100644
index 0000000..772cbf8
--- /dev/null
+++ b/exynos4/hal/include/sec_g2d.h
@@ -0,0 +1,251 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 _SEC_G2D_DRIVER_H_
+#define _SEC_G2D_DRIVER_H_
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned long u32;
+
+#define SEC_G2D_DEV_NAME "/dev/fimg2d"
+
+#define G2D_IOCTL_MAGIC 'G'
+
+#define G2D_BLIT _IO(G2D_IOCTL_MAGIC,0)
+#define G2D_GET_VERSION _IO(G2D_IOCTL_MAGIC,1)
+#define G2D_GET_MEMORY _IOR(G2D_IOCTL_MAGIC,2, unsigned int)
+#define G2D_GET_MEMORY_SIZE _IOR(G2D_IOCTL_MAGIC,3, unsigned int)
+#define G2D_DMA_CACHE_CLEAN _IOWR(G2D_IOCTL_MAGIC,4, struct g2d_dma_info)
+#define G2D_DMA_CACHE_FLUSH _IOWR(G2D_IOCTL_MAGIC,5, struct g2d_dma_info)
+#define G2D_SYNC _IO(G2D_IOCTL_MAGIC,6)
+#define G2D_RESET _IO(G2D_IOCTL_MAGIC,7)
+
+#define G2D_MAX_WIDTH (2048)
+#define G2D_MAX_HEIGHT (2048)
+
+#define G2D_ALPHA_VALUE_MAX (255)
+
+#define G2D_POLLING (1<<0)
+#define G2D_INTERRUPT (0<<0)
+#define G2D_CACHE_OP (1<<1)
+#define G2D_NONE_INVALIDATE (0<<1)
+#define G2D_HYBRID_MODE (1<<2)
+
+typedef enum {
+ G2D_ROT_0 = 0,
+ G2D_ROT_90,
+ G2D_ROT_180,
+ G2D_ROT_270,
+ G2D_ROT_X_FLIP,
+ G2D_ROT_Y_FLIP
+} G2D_ROT_DEG;
+
+typedef enum {
+ G2D_ALPHA_BLENDING_MIN = 0, // wholly transparent
+ G2D_ALPHA_BLENDING_MAX = 255, // 255
+ G2D_ALPHA_BLENDING_OPAQUE = 256, // opaque
+} G2D_ALPHA_BLENDING_MODE;
+
+typedef enum {
+ G2D_COLORKEY_NONE = 0,
+ G2D_COLORKEY_SRC_ON,
+ G2D_COLORKEY_DST_ON,
+ G2D_COLORKEY_SRC_DST_ON,
+} G2D_COLORKEY_MODE;
+
+typedef enum {
+ G2D_BLUE_SCREEN_NONE = 0,
+ G2D_BLUE_SCREEN_TRANSPARENT,
+ G2D_BLUE_SCREEN_WITH_COLOR,
+} G2D_BLUE_SCREEN_MODE;
+
+typedef enum {
+ G2D_ROP_SRC = 0,
+ G2D_ROP_DST,
+ G2D_ROP_SRC_AND_DST,
+ G2D_ROP_SRC_OR_DST,
+ G2D_ROP_3RD_OPRND,
+ G2D_ROP_SRC_AND_3RD_OPRND,
+ G2D_ROP_SRC_OR_3RD_OPRND,
+ G2D_ROP_SRC_XOR_3RD_OPRND,
+ G2D_ROP_DST_OR_3RD,
+} G2D_ROP_TYPE;
+
+typedef enum {
+ G2D_THIRD_OP_NONE = 0,
+ G2D_THIRD_OP_PATTERN,
+ G2D_THIRD_OP_FG,
+ G2D_THIRD_OP_BG
+} G2D_THIRD_OP_MODE;
+
+typedef enum {
+ G2D_BLACK = 0,
+ G2D_RED,
+ G2D_GREEN,
+ G2D_BLUE,
+ G2D_WHITE,
+ G2D_YELLOW,
+ G2D_CYAN,
+ G2D_MAGENTA
+} G2D_COLOR;
+
+typedef enum {
+ G2D_RGB_565 = ((0<<4)|2),
+
+ G2D_ABGR_8888 = ((2<<4)|1),
+ G2D_BGRA_8888 = ((3<<4)|1),
+ G2D_ARGB_8888 = ((0<<4)|1),
+ G2D_RGBA_8888 = ((1<<4)|1),
+
+ G2D_XBGR_8888 = ((2<<4)|0),
+ G2D_BGRX_8888 = ((3<<4)|0),
+ G2D_XRGB_8888 = ((0<<4)|0),
+ G2D_RGBX_8888 = ((1<<4)|0),
+
+ G2D_ABGR_1555 = ((2<<4)|4),
+ G2D_BGRA_5551 = ((3<<4)|4),
+ G2D_ARGB_1555 = ((0<<4)|4),
+ G2D_RGBA_5551 = ((1<<4)|4),
+
+ G2D_XBGR_1555 = ((2<<4)|3),
+ G2D_BGRX_5551 = ((3<<4)|3),
+ G2D_XRGB_1555 = ((0<<4)|3),
+ G2D_RGBX_5551 = ((1<<4)|3),
+
+ G2D_ABGR_4444 = ((2<<4)|6),
+ G2D_BGRA_4444 = ((3<<4)|6),
+ G2D_ARGB_4444 = ((0<<4)|6),
+ G2D_RGBA_4444 = ((1<<4)|6),
+
+ G2D_XBGR_4444 = ((2<<4)|5),
+ G2D_BGRX_4444 = ((3<<4)|5),
+ G2D_XRGB_4444 = ((0<<4)|5),
+ G2D_RGBX_4444 = ((1<<4)|5),
+
+ G2D_PACKED_BGR_888 = ((2<<4)|7),
+ G2D_PACKED_RGB_888 = ((0<<4)|7),
+
+ G2D_MAX_COLOR_SPACE
+} G2D_COLOR_SPACE;
+
+typedef enum {
+ G2D_Clear_Mode, //!< [0, 0]
+ G2D_Src_Mode, //!< [Sa, Sc]
+ G2D_Dst_Mode, //!< [Da, Dc]
+ G2D_SrcOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
+ G2D_DstOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
+ G2D_SrcIn_Mode, //!< [Sa * Da, Sc * Da]
+ G2D_DstIn_Mode, //!< [Sa * Da, Sa * Dc]
+ G2D_SrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)]
+ G2D_DstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)]
+ G2D_SrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc]
+ G2D_DstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)]
+ G2D_Xor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
+
+ // these modes are defined in the SVG Compositing standard
+ // http://www.w3.org/TR/2009/WD-SVGCompositing-20090430/
+ G2D_Plus_Mode,
+ G2D_Multiply_Mode,
+ G2D_Screen_Mode,
+ G2D_Overlay_Mode,
+ G2D_Darken_Mode,
+ G2D_Lighten_Mode,
+ G2D_ColorDodge_Mode,
+ G2D_ColorBurn_Mode,
+ G2D_HardLight_Mode,
+ G2D_SoftLight_Mode,
+ G2D_Difference_Mode,
+ G2D_Exclusion_Mode,
+
+ kLastMode = G2D_Exclusion_Mode
+} G2D_PORTTERDUFF_MODE;
+
+typedef enum {
+ G2D_MEMORY_KERNEL,
+ G2D_MEMORY_USER
+} G2D_MEMORY_TYPE;
+
+typedef struct {
+ int x;
+ int y;
+ unsigned int w;
+ unsigned int h;
+ unsigned int full_w;
+ unsigned int full_h;
+ int color_format;
+ unsigned int bytes_per_pixel;
+ unsigned char * addr;
+} g2d_rect;
+
+typedef struct {
+ unsigned int rotate_val;
+ unsigned int alpha_val;
+
+ unsigned int blue_screen_mode; //true : enable, false : disable
+ unsigned int color_key_val; //screen color value
+ unsigned int color_switch_val; //one color
+
+ unsigned int src_color; // when set one color on SRC
+
+ unsigned int third_op_mode;
+ unsigned int rop_mode;
+ unsigned int mask_mode;
+ unsigned int render_mode;
+ unsigned int potterduff_mode;
+ unsigned int memory_type;
+} g2d_flag;
+
+typedef struct {
+ unsigned int t;
+ unsigned int b;
+ unsigned int l;
+ unsigned int r;
+} g2d_clip;
+
+typedef struct {
+ g2d_rect src_rect;
+ g2d_rect dst_rect;
+ g2d_clip clip;
+ g2d_flag flag;
+} g2d_params;
+
+struct g2d_dma_info {
+ unsigned long addr;
+ unsigned int size;
+};
+
+typedef struct _sec_g2d_t {
+ int dev_fd;
+ g2d_params params;
+}sec_g2d_t;
+
+typedef struct __s5p_rect {
+ uint32_t x;
+ uint32_t y;
+ uint32_t w;
+ uint32_t h;
+} __s5p_rect;
+
+typedef struct __s5p_img {
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
+ uint32_t offset;
+ uint32_t base;
+ int memory_id;
+} __s5p_img;
+
+#endif /*_SEC_G2D_DRIVER_H_*/
diff --git a/exynos4/hal/include/sec_utils.h b/exynos4/hal/include/sec_utils.h
new file mode 100644
index 0000000..55808f4
--- /dev/null
+++ b/exynos4/hal/include/sec_utils.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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 __SAMSUNG_SYSLSI_SEC_COMMON_H__
+#define __SAMSUNG_SYSLSI_SEC_COMMON_H__
+
+//---------------------------------------------------------//
+// Include
+//---------------------------------------------------------//
+
+#include <hardware/hardware.h>
+#include "sec_format.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/videodev2.h>
+#include "videodev2_samsung.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+//---------------------------------------------------------//
+// Common structure //
+//---------------------------------------------------------//
+struct ADDRS {
+ unsigned int addr_y;
+ unsigned int addr_cbcr;
+ unsigned int buf_idx;
+ unsigned int reserved;
+};
+
+//---------------------------------------------------------//
+// Common function //
+//---------------------------------------------------------//
+inline int HAL_PIXEL_FORMAT_2_V4L2_PIX(int HAL_PIXEL_FORMAT)
+{
+ int V4L2_PIX = -1;
+
+ switch (HAL_PIXEL_FORMAT) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB24;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_565:
+ V4L2_PIX = V4L2_PIX_FMT_RGB565;
+ break;
+
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ V4L2_PIX = V4L2_PIX_FMT_RGB555X;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ V4L2_PIX = V4L2_PIX_FMT_RGB444;
+ break;
+
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV420;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV61;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV12;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YUYV;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV422P;
+ break;
+
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_UYVY;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV16;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV21;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ V4L2_PIX = V4L2_PIX_FMT_NV12T;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YVYU;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_VYUY;
+ break;
+
+ default:
+ LOGE("%s::unmatched HAL_PIXEL_FORMAT color_space(0x%x)\n",
+ __func__, HAL_PIXEL_FORMAT);
+ break;
+ }
+
+ return V4L2_PIX;
+}
+
+inline int V4L2_PIX_2_HAL_PIXEL_FORMAT(int V4L2_PIX)
+{
+ int HAL_PIXEL_FORMAT = -1;
+
+ switch (V4L2_PIX) {
+ case V4L2_PIX_FMT_RGB32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB24:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_888;
+ break;
+
+ case V4L2_PIX_FMT_RGB565:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_565;
+ break;
+
+ case V4L2_PIX_FMT_BGR32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_BGRA_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB555X:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_5551;
+ break;
+
+ case V4L2_PIX_FMT_RGB444:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_4444;
+ break;
+
+ case V4L2_PIX_FMT_YUV420:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_420_P;
+ break;
+
+ case V4L2_PIX_FMT_NV16:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_NV12:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP;
+ break;
+
+ case V4L2_PIX_FMT_YUYV:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I;
+ break;
+
+ case V4L2_PIX_FMT_YUV422P:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_422_P;
+ break;
+
+ case V4L2_PIX_FMT_UYVY:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I;
+ break;
+
+ case V4L2_PIX_FMT_NV21:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP;
+ break;
+
+ case V4L2_PIX_FMT_NV12T:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
+ break;
+
+ case V4L2_PIX_FMT_NV61:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_YVYU:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I;
+ break;
+
+ case V4L2_PIX_FMT_VYUY:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I;
+ break;
+
+ default:
+ LOGE("%s::unmatched V4L2_PIX color_space(%d)\n",
+ __func__, V4L2_PIX);
+ break;
+ }
+
+ return HAL_PIXEL_FORMAT;
+}
+
+#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
+#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
+#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
+
+#define GET_32BPP_FRAME_SIZE(w, h) (((w) * (h)) << 2)
+#define GET_24BPP_FRAME_SIZE(w, h) (((w) * (h)) * 3)
+#define GET_16BPP_FRAME_SIZE(w, h) (((w) * (h)) << 1)
+
+inline unsigned int FRAME_SIZE(int HAL_PIXEL_FORMAT, int w, int h)
+{
+ unsigned int frame_size = 0;
+ unsigned int size = 0;
+
+ switch (HAL_PIXEL_FORMAT) {
+ // 16bpp
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 24bpp
+ case HAL_PIXEL_FORMAT_RGB_888:
+ frame_size = GET_24BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 32bpp
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ frame_size = GET_32BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 12bpp
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ size = w * h;
+ frame_size = size + ((size >> 2) << 1);
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ frame_size = ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h))
+ + ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h >> 1));
+ break;
+
+ // 16bpp
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ default:
+ LOGD("%s::no matching source colorformat(0x%x), w(%d), h(%d) fail\n",
+ __func__, HAL_PIXEL_FORMAT, w, h);
+ break;
+ }
+
+ return frame_size;
+}
+
+#endif //__SAMSUNG_SYSLSI_SEC_COMMON_H__ \ No newline at end of file
diff --git a/exynos4/hal/include/sec_utils_v4l2.h b/exynos4/hal/include/sec_utils_v4l2.h
new file mode 100644
index 0000000..3aa7c35
--- /dev/null
+++ b/exynos4/hal/include/sec_utils_v4l2.h
@@ -0,0 +1,327 @@
+/*
+ * Copyright@ Samsung Electronics Co. LTD
+ *
+ * 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.
+*/
+
+/*
+ * file sec_utils_v4l2.h
+ * brief header file for sec_utils_v4l2.h
+ * author Sangwoo, Park(sw5771.park@samsung.com)
+ * date 2011/06/02
+ *
+ * Revision History:
+ * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com)
+ * Initial version
+ *
+ * - 2011/12/07 : Jeonghee, Kim(jhhhh.kim@samsung.com)
+ * use V4L2_PIX_FMT_NV12M as HAL_PIXEL_FORMAT_YCbCr_420_SP, HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP
+ *
+ * - 2011/12/07 : Hyeonmyeong Choi( hyeon.choi@samsung.com)
+ * Add V4L2_PIX_FMT_YVU420M
+ *
+ */
+
+
+#ifndef __SAMSUNG_SYSLSI_SEC_COMMON_H__
+#define __SAMSUNG_SYSLSI_SEC_COMMON_H__
+
+//---------------------------------------------------------//
+// Include
+//---------------------------------------------------------//
+
+#include <hardware/hardware.h>
+#include "sec_format.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "videodev2.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+//---------------------------------------------------------//
+// Common structure //
+//---------------------------------------------------------//
+struct ADDRS {
+ unsigned int addr_y;
+ unsigned int addr_cbcr;
+ unsigned int buf_idx;
+ unsigned int reserved;
+};
+
+//---------------------------------------------------------//
+// Common function //
+//---------------------------------------------------------//
+inline int HAL_PIXEL_FORMAT_2_V4L2_PIX(int HAL_PIXEL_FORMAT)
+{
+ int V4L2_PIX = -1;
+
+ switch (HAL_PIXEL_FORMAT) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB24;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_565:
+ V4L2_PIX = V4L2_PIX_FMT_RGB565;
+ break;
+
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+#if defined(BOARD_USE_V4L2)
+ V4L2_PIX = V4L2_PIX_FMT_BGR32;
+#else
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+#endif
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ V4L2_PIX = V4L2_PIX_FMT_RGB555X;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ V4L2_PIX = V4L2_PIX_FMT_RGB444;
+ break;
+
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV420M;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV61;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV12M;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YUYV;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV422P;
+ break;
+
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_UYVY;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV16;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV21;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ V4L2_PIX = V4L2_PIX_FMT_NV12MT;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YVYU;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_VYUY;
+ break;
+
+ default:
+ LOGE("%s::unmatched HAL_PIXEL_FORMAT color_space(0x%x)\n",
+ __func__, HAL_PIXEL_FORMAT);
+ break;
+ }
+
+ return V4L2_PIX;
+}
+
+inline int V4L2_PIX_2_HAL_PIXEL_FORMAT(int V4L2_PIX)
+{
+ int HAL_PIXEL_FORMAT = -1;
+
+ switch (V4L2_PIX) {
+ case V4L2_PIX_FMT_RGB32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB24:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_888;
+ break;
+
+ case V4L2_PIX_FMT_RGB565:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_565;
+ break;
+
+ case V4L2_PIX_FMT_BGR32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_BGRA_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB555X:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_5551;
+ break;
+
+ case V4L2_PIX_FMT_RGB444:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_4444;
+ break;
+
+ case V4L2_PIX_FMT_YUV420:
+ case V4L2_PIX_FMT_YUV420M:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_420_P;
+ break;
+
+ case V4L2_PIX_FMT_YVU420:
+ case V4L2_PIX_FMT_YVU420M:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YV12;
+ break;
+
+ case V4L2_PIX_FMT_NV16:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_NV12:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP;
+ break;
+
+ case V4L2_PIX_FMT_YUYV:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I;
+ break;
+
+ case V4L2_PIX_FMT_YUV422P:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_422_P;
+ break;
+
+ case V4L2_PIX_FMT_UYVY:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I;
+ break;
+
+ case V4L2_PIX_FMT_NV21:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP;
+ break;
+ case V4L2_PIX_FMT_NV12MT:
+
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
+ break;
+
+ case V4L2_PIX_FMT_NV61:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_YVYU:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I;
+ break;
+
+ case V4L2_PIX_FMT_VYUY:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I;
+ break;
+
+ default:
+ LOGE("%s::unmatched V4L2_PIX color_space(%d)\n",
+ __func__, V4L2_PIX);
+ break;
+ }
+
+ return HAL_PIXEL_FORMAT;
+}
+
+#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
+#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
+#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
+#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+
+#define GET_32BPP_FRAME_SIZE(w, h) (((w) * (h)) << 2)
+#define GET_24BPP_FRAME_SIZE(w, h) (((w) * (h)) * 3)
+#define GET_16BPP_FRAME_SIZE(w, h) (((w) * (h)) << 1)
+
+inline unsigned int FRAME_SIZE(int HAL_PIXEL_FORMAT, int w, int h)
+{
+ unsigned int frame_size = 0;
+ unsigned int size = 0;
+
+ switch (HAL_PIXEL_FORMAT) {
+ // 16bpp
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 24bpp
+ case HAL_PIXEL_FORMAT_RGB_888:
+ frame_size = GET_24BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 32bpp
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ frame_size = GET_32BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 12bpp
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ size = w * h;
+ frame_size = size + ((size >> 2) << 1);
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ frame_size = ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h))
+ + ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h >> 1));
+ break;
+
+ // 16bpp
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ default:
+ LOGD("%s::no matching source colorformat(0x%x), w(%d), h(%d) fail\n",
+ __func__, HAL_PIXEL_FORMAT, w, h);
+ break;
+ }
+
+ return frame_size;
+}
+
+#endif //__SAMSUNG_SYSLSI_SEC_COMMON_H__
diff --git a/exynos4/hal/include/swconverter.h b/exynos4/hal/include/swconverter.h
new file mode 100644
index 0000000..eb2eae3
--- /dev/null
+++ b/exynos4/hal/include/swconverter.h
@@ -0,0 +1,462 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file swconverter.h
+ * @brief SEC_OMX specific define. It support MFC 5.x tiled.
+ * NV12T(tiled) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * uv pixel block is interleaved as u v u v u v ...
+ * y1 y2 y7 y8 y9 y10 y15 y16
+ * y3 y4 y5 y6 y11 y12 y13 y14
+ * y17 y18 y23 y24 y25 y26 y31 y32
+ * y19 y20 y21 y22 y27 y28 y29 y30
+ * uv1 uv2 uv7 uv8 uv9 uv10 uv15 uv16
+ * uv3 uv4 uv5 uv6 uv11 uv12 uv13 uv14
+ * YUV420Planar(linear) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * y1 y2 y3 y4 y5 y6 y7 y8
+ * y9 y10 y11 y12 y13 y14 y15 y16
+ * y17 y18 y19 y20 y21 y22 y23 y24
+ * y25 y26 y27 y28 y29 y30 y31 y32
+ * u1 u2 u3 u4 u5 u6 u7 u8
+ * v1 v2 v3 v4 v5 v6 v7 v8
+ * YUV420Semiplanar(linear) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * uv pixel block is interleaved as u v u v u v ...
+ * y1 y2 y3 y4 y5 y6 y7 y8
+ * y9 y10 y11 y12 y13 y14 y15 y16
+ * y17 y18 y19 y20 y21 y22 y23 y24
+ * y25 y26 y27 y28 y29 y30 y31 y32
+ * uv1 uv2 uv3 uv4 uv5 uv6 uv7 uv8
+ * uv9 uv10 uv11 uv12 uv13 uv14 uv15 uv16
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+#ifndef SW_CONVERTOR_H_
+#define SW_CONVERTOR_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Format Conversion API */
+/*--------------------------------------------------------------------------------*/
+/*
+ * De-interleaves src to dest1, dest2
+ *
+ * @param dest1
+ * Address of de-interleaved data[out]
+ *
+ * @param dest2
+ * Address of de-interleaved data[out]
+ *
+ * @param src
+ * Address of interleaved data[in]
+ *
+ * @param src_size
+ * Size of interleaved data[in]
+ */
+void csc_deinterleave_memcpy(
+ unsigned char *dest1,
+ unsigned char *dest2,
+ unsigned char *src,
+ unsigned int src_size);
+
+/*
+ * Interleaves src1, src2 to dest
+ *
+ * @param dest
+ * Address of interleaved data[out]
+ *
+ * @param src1
+ * Address of de-interleaved data[in]
+ *
+ * @param src2
+ * Address of de-interleaved data[in]
+ *
+ * @param src_size
+ * Size of de-interleaved data[in]
+ */
+void csc_interleave_memcpy(
+ unsigned char *dest,
+ unsigned char *src1,
+ unsigned char *src2,
+ unsigned int src_size);
+
+/* C Code */
+/*
+ * Converts tiled data to linear
+ * 1. y of nv12t to y of yuv420p
+ * 2. y of nv12t to y of yuv420s
+ *
+ * @param dst
+ * y address of yuv420[out]
+ *
+ * @param src
+ * y address of nv12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_tiled_to_linear_y(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts tiled data to linear
+ * 1. uv of nv12t to y of yuv420s
+ *
+ * @param dst
+ * uv address of yuv420s[out]
+ *
+ * @param src
+ * uv address of nv12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420s[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420s[in]
+ *
+ */
+void csc_tiled_to_linear_uv(
+ unsigned char *uv_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts tiled data to linear
+ * 1. uv of nt12t to uv of yuv420p
+ *
+ * @param u_dst
+ * u address of yuv420p[out]
+ *
+ * @param v_dst
+ * v address of yuv420p[out]
+ *
+ * @param uv_src
+ * uv address of nt12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420p[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420p[in]
+ */
+void csc_tiled_to_linear_uv_deinterleave(
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts linear data to tiled
+ * 1. y of yuv420 to y of nv12t
+ *
+ * @param dst
+ * y address of nv12t[out]
+ *
+ * @param src
+ * y address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_linear_to_tiled_y(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts and interleaves linear data to tiled
+ * 1. uv of nv12t to uv of yuv420
+ *
+ * @param dst
+ * uv address of nv12t[out]
+ *
+ * @param src
+ * u address of yuv420[in]
+ *
+ * @param src
+ * v address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ *
+ */
+void csc_linear_to_tiled_uv(
+ unsigned char *uv_dst,
+ unsigned char *u_src,
+ unsigned char *v_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ *
+ * @param dst
+ * Y address of YUV420[out]
+ *
+ * @param src
+ * Y address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: real height of YUV420[in]
+ *
+ */
+void csc_tiled_to_linear_y_neon(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * 1. UV of NV12T to Y of YUV420S
+ *
+ * @param u_dst
+ * UV plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * (real height)/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_uv_neon(
+ unsigned char *uv_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * Deinterleave src to u_dst, v_dst
+ * 1. UV of NV12T to Y of YUV420P
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * (real height)/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_uv_deinterleave_neon(
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts linear data to tiled
+ * 1. y of yuv420 to y of nv12t
+ *
+ * @param dst
+ * y address of nv12t[out]
+ *
+ * @param src
+ * y address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_linear_to_tiled_y_neon(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts and interleaves linear data to tiled
+ * 1. uv of nv12t to uv of yuv420
+ *
+ * @param dst
+ * uv address of nv12t[out]
+ *
+ * @param src
+ * u address of yuv420[in]
+ *
+ * @param src
+ * v address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ *
+ */
+void csc_linear_to_tiled_uv_neon(
+ unsigned char *uv_dst,
+ unsigned char *u_src,
+ unsigned char *v_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts RGB565 to YUV420P
+ *
+ * @param y_dst
+ * Y plane address of YUV420P[out]
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param rgb_src
+ * Address of RGB565[in]
+ *
+ * @param width
+ * Width of RGB565[in]
+ *
+ * @param height
+ * Height of RGB565[in]
+ */
+void csc_RGB565_to_YUV420P(
+ unsigned char *y_dst,
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts RGB565 to YUV420S
+ *
+ * @param y_dst
+ * Y plane address of YUV420S[out]
+ *
+ * @param uv_dst
+ * UV plane address of YUV420S[out]
+ *
+ * @param rgb_src
+ * Address of RGB565[in]
+ *
+ * @param width
+ * Width of RGB565[in]
+ *
+ * @param height
+ * Height of RGB565[in]
+ */
+void csc_RGB565_to_YUV420SP(
+ unsigned char *y_dst,
+ unsigned char *uv_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts ARGB8888 to YUV420P
+ *
+ * @param y_dst
+ * Y plane address of YUV420P[out]
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param rgb_src
+ * Address of ARGB8888[in]
+ *
+ * @param width
+ * Width of ARGB8888[in]
+ *
+ * @param height
+ * Height of ARGB8888[in]
+ */
+void csc_ARGB8888_to_YUV420P(
+ unsigned char *y_dst,
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height);
+
+/*
+ * Converts ARGB888 to YUV420SP
+ *
+ * @param y_dst
+ * Y plane address of YUV420SP[out]
+ *
+ * @param uv_dst
+ * UV plane address of YUV420SP[out]
+ *
+ * @param rgb_src
+ * Address of ARGB8888[in]
+ *
+ * @param width
+ * Width of ARGB8888[in]
+ *
+ * @param height
+ * Height of ARGB8888[in]
+ */
+void csc_ARGB8888_to_YUV420SP(
+ unsigned char *y_dst,
+ unsigned char *uv_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height);
+
+#endif /*COLOR_SPACE_CONVERTOR_H_*/
diff --git a/exynos4/hal/include/video.h b/exynos4/hal/include/video.h
new file mode 100644
index 0000000..0565b85
--- /dev/null
+++ b/exynos4/hal/include/video.h
@@ -0,0 +1,363 @@
+#ifndef _VIDEO_H_
+#define _VIDEO_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __HDMI_VIDEO_VIDEOFORMAT__
+#define __HDMI_VIDEO_VIDEOFORMAT__
+/**
+ * @enum VideoFormat
+ * Video format
+ */
+enum VideoFormat {
+ /** 640x480p\@60Hz */
+ v640x480p_60Hz = 0,
+ /** 720x480p\@60Hz */
+ v720x480p_60Hz,
+ /** 1280x700p\@60Hz */
+ v1280x720p_60Hz,
+ /** 1920x1080i\@60Hz */
+ v1920x1080i_60Hz,
+ /** 720x480i\@60Hz */
+ v720x480i_60Hz,
+ /** 720x240p\@60Hz */
+ v720x240p_60Hz,
+ /** 2880x480i\@60Hz */
+ v2880x480i_60Hz,
+ /** 2880x240p\@60Hz */
+ v2880x240p_60Hz,
+ /** 1440x480p\@60Hz */
+ v1440x480p_60Hz,
+ /** 1920x1080p\@60Hz */
+ v1920x1080p_60Hz,
+ /** 720x576p\@60Hz */
+ v720x576p_50Hz,
+ /** 1280x720p\@50Hz */
+ v1280x720p_50Hz,
+ /** 1920x1080i\@50Hz (V total = 1125) */
+ v1920x1080i_50Hz,
+ /** 720x576i\@50Hz */
+ v720x576i_50Hz,
+ /** 720x288p\@50Hz */
+ v720x288p_50Hz,
+ /** 2880x576i\@50Hz */
+ v2880x576i_50Hz,
+ /** 2880x288p\@50Hz */
+ v2880x288p_50Hz,
+ /** 1440x576p\@50Hz */
+ v1440x576p_50Hz,
+ /** 1920x1080p\@50Hz */
+ v1920x1080p_50Hz,
+ /** 1920x1080p\@24Hz */
+ v1920x1080p_24Hz,
+ /** 1920x1080p\@25Hz */
+ v1920x1080p_25Hz,
+ /** 1920x1080p\@30Hz */
+ v1920x1080p_30Hz,
+ /** 2880x480p\@60Hz */
+ v2880x480p_60Hz,
+ /** 2880x576p\@60Hz */
+ v2880x576p_50Hz,
+ /** 1920x1080i\@50Hz (V total = 1250) */
+ v1920x1080i_50Hz_1250,
+ /** 1920x1080i\@100Hz */
+ v1920x1080i_100Hz,
+ /** 1280x720p\@100Hz */
+ v1280x720p_100Hz,
+ /** 720x576p\@100Hz */
+ v720x576p_100Hz,
+ /** 720x576i\@100Hz */
+ v720x576i_100Hz,
+ /** 1920x1080i\@120Hz */
+ v1920x1080i_120Hz,
+ /** 1280x720p\@120Hz */
+ v1280x720p_120Hz,
+ /** 720x480p\@120Hz */
+ v720x480p_120Hz,
+ /** 720x480i\@120Hz */
+ v720x480i_120Hz,
+ /** 720x576p\@200Hz */
+ v720x576p_200Hz,
+ /** 720x576i\@200Hz */
+ v720x576i_200Hz,
+ /** 720x480p\@240Hz */
+ v720x480p_240Hz,
+ /** 720x480i\@240Hz */
+ v720x480i_240Hz,
+ /** 1280x720p\@24Hz */
+ v1280x720p_24Hz,
+ /** 1280x720p\@25Hz */
+ v1280x720p_25Hz,
+ /** 1280x720p\@30Hz */
+ v1280x720p_30Hz,
+ /** 1920x1080p\@120Hz */
+ v1920x1080p_120Hz,
+ /** 1920x1080p\@100Hz */
+ v1920x1080p_100Hz,
+ /** 4Kx2K\@30Hz */
+ v4Kx2K_30Hz,
+};
+#endif /* __HDMI_VIDEO_VIDEOFORMAT__ */
+#ifndef __HDMI_VIDEO_COLORSPACE__
+#define __HDMI_VIDEO_COLORSPACE__
+/**
+ * @enum ColorSpace
+ * Color space of video stream.
+ */
+enum ColorSpace {
+ /** RGB color space */
+ HDMI_CS_RGB,
+ /** YCbCr 4:4:4 color space */
+ HDMI_CS_YCBCR444,
+ /** YCbCr 4:2:2 color space */
+ HDMI_CS_YCBCR422
+};
+#endif /* __HDMI_VIDEO_COLORSPACE__ */
+
+#ifndef __HDMI_VIDEO_COLORDEPTH__
+#define __HDMI_VIDEO_COLORDEPTH__
+/**
+ * @enum ColorDepth
+ * Color depth per pixel of video stream
+ */
+enum ColorDepth {
+ /** 36 bit color depth per pixel */
+ HDMI_CD_36,
+ /** 30 bit color depth per pixel */
+ HDMI_CD_30,
+ /** 24 bit color depth per pixel */
+ HDMI_CD_24
+};
+#endif /* __HDMI_VIDEO_COLORDEPTH__ */
+
+#ifndef __HDMI_VIDEO_HDMIMODE__
+#define __HDMI_VIDEO_HDMIMODE__
+/**
+ * @enum HDMIMode
+ * System mode
+ */
+enum HDMIMode {
+ /** DVI mode */
+ DVI = 0,
+ /** HDMI mode */
+ HDMI
+};
+#endif /* __HDMI_VIDEO_HDMIMODE__ */
+
+#ifndef __HDMI_VIDEO_PIXELLIMIT__
+#define __HDMI_VIDEO_PIXELLIMIT__
+/**
+ * @enum PixelLimit
+ * Pixel limitation of video stream
+ */
+enum PixelLimit {
+ /** Full range */
+ HDMI_FULL_RANGE,
+ /** Limit range for RGB color space */
+ HDMI_RGB_LIMIT_RANGE,
+ /** Limit range for YCbCr color space */
+ HDMI_YCBCR_LIMIT_RANGE
+};
+#endif /* __HDMI_VIDEO_PIXELLIMIT__ */
+
+#ifndef __HDMI_VIDEO_COLORIMETRY__
+#define __HDMI_VIDEO_COLORIMETRY__
+/**
+ * @enum HDMIColorimetry
+ * Colorimetry of video stream
+ */
+enum HDMIColorimetry {
+ /** Colorimetry is not defined */
+ HDMI_COLORIMETRY_NO_DATA,
+ /** ITU601 colorimetry */
+ HDMI_COLORIMETRY_ITU601,
+ /** ITU709 colorimetry */
+ HDMI_COLORIMETRY_ITU709,
+ /** Extended ITU601 colorimetry */
+ HDMI_COLORIMETRY_EXTENDED_xvYCC601,
+ /** Extended ITU709 colorimetry */
+ HDMI_COLORIMETRY_EXTENDED_xvYCC709
+};
+#endif /* __HDMI_VIDEO_COLORIMETRY__ */
+
+#ifndef __HDMI_VIDEO_PIXELASPECTRATIO__
+#define __HDMI_VIDEO_PIXELASPECTRATIO__
+/**
+ * @enum PixelAspectRatio
+ * Pixel aspect ratio of video stream
+ */
+enum PixelAspectRatio {
+ /** as picutre pixel ratio */
+ HDMI_PIXEL_RATIO_AS_PICTURE,
+ /** 4:3 pixel ratio */
+ HDMI_PIXEL_RATIO_4_3,
+ /** 16:9 pixel ratio */
+ HDMI_PIXEL_RATIO_16_9
+};
+#endif /* __HDMI_VIDEO_PIXELASPECTRATIO__ */
+
+#ifndef __HDMI_VIDEO_PIXELFREQUENCY__
+#define __HDMI_VIDEO_PIXELFREQUENCY__
+/**
+ * @enum PixelFreq
+ * Pixel Frequency
+ */
+enum PixelFreq {
+ /** 25.2 MHz pixel frequency */
+ PIXEL_FREQ_25_200 = 2520,
+ /** 25.175 MHz pixel frequency */
+ PIXEL_FREQ_25_175 = 2517,
+ /** 27 MHz pixel frequency */
+ PIXEL_FREQ_27 = 2700,
+ /** 27.027 MHz pixel frequency */
+ PIXEL_FREQ_27_027 = 2702,
+ /** 54 MHz pixel frequency */
+ PIXEL_FREQ_54 = 5400,
+ /** 54.054 MHz pixel frequency */
+ PIXEL_FREQ_54_054 = 5405,
+ /** 74.25 MHz pixel frequency */
+ PIXEL_FREQ_74_250 = 7425,
+ /** 74.176 MHz pixel frequency */
+ PIXEL_FREQ_74_176 = 7417,
+ /** 148.5 MHz pixel frequency */
+ PIXEL_FREQ_148_500 = 14850,
+ /** 148.352 MHz pixel frequency */
+ PIXEL_FREQ_148_352 = 14835,
+ /** 108.108 MHz pixel frequency */
+ PIXEL_FREQ_108_108 = 10810,
+ /** 72 MHz pixel frequency */
+ PIXEL_FREQ_72 = 7200,
+ /** 25 MHz pixel frequency */
+ PIXEL_FREQ_25 = 2500,
+ /** 65 MHz pixel frequency */
+ PIXEL_FREQ_65 = 6500,
+ /** 108 MHz pixel frequency */
+ PIXEL_FREQ_108 = 10800,
+ /** 162 MHz pixel frequency */
+ PIXEL_FREQ_162 = 16200,
+ /** 59.4 MHz pixel frequency */
+ PIXEL_FREQ_59_400 = 5940,
+};
+#endif /* __HDMI_VIDEO_PIXELFREQUENCY__ */
+
+#ifndef __HDMI_PHY_PIXELFREQUENCY__
+#define __HDMI_PHY_PIXELFREQUENCY__
+
+/**
+ * @enum PHYFreq
+ * PHY Frequency
+ */
+enum PHYFreq {
+ /** Not supported */
+ PHY_FREQ_NOT_SUPPORTED = -1,
+ /** 25.2 MHz pixel frequency */
+ PHY_FREQ_25_200 = 0,
+ /** 25.175 MHz pixel frequency */
+ PHY_FREQ_25_175,
+ /** 27 MHz pixel frequency */
+ PHY_FREQ_27,
+ /** 27.027 MHz pixel frequency */
+ PHY_FREQ_27_027,
+ /** 54 MHz pixel frequency */
+ PHY_FREQ_54,
+ /** 54.054 MHz pixel frequency */
+ PHY_FREQ_54_054,
+ /** 74.25 MHz pixel frequency */
+ PHY_FREQ_74_250,
+ /** 74.176 MHz pixel frequency */
+ PHY_FREQ_74_176,
+ /** 148.5 MHz pixel frequency */
+ PHY_FREQ_148_500,
+ /** 148.352 MHz pixel frequency */
+ PHY_FREQ_148_352,
+ /** 108.108 MHz pixel frequency */
+ PHY_FREQ_108_108,
+ /** 72 MHz pixel frequency */
+ PHY_FREQ_72,
+ /** 25 MHz pixel frequency */
+ PHY_FREQ_25,
+ /** 65 MHz pixel frequency */
+ PHY_FREQ_65,
+ /** 108 MHz pixel frequency */
+ PHY_FREQ_108,
+ /** 162 MHz pixel frequency */
+ PHY_FREQ_162,
+ /** 59.4 MHz pixel frequency */
+ PHY_FREQ_59_400,
+};
+
+#endif /* __HDMI_PHY_PIXELFREQUENCY__ */
+
+#ifndef __HDMI_VIDEO_SOURCE__
+#define __HDMI_VIDEO_SOURCE__
+/**
+ * @enum HDMIVideoSource
+ * Type of video source.
+ */
+enum HDMIVideoSource {
+ /** Internal Video Source */
+ HDMI_SOURCE_INTERNAL,
+ /** External Video Source */
+ HDMI_SOURCE_EXTERNAL,
+};
+#endif /* __HDMI_VIDEO_SOURCE__ */
+
+#ifndef __HDMI_3D_VIDEO_STRUCTURE__
+#define __HDMI_3D_VIDEO_STRUCTURE__
+/**
+ * @enum HDMI3DVideoStructure
+ * Type of 3D Video Structure
+ */
+enum HDMI3DVideoStructure {
+ /** 2D Video Format */
+ HDMI_2D_VIDEO_FORMAT = -1,
+ /** 3D Frame Packing Structure */
+ HDMI_3D_FP_FORMAT = 0,
+ /** 3D Field Alternative Structure */
+ HDMI_3D_FA_FORMAT,
+ /** 3D Line Alternative Structure */
+ HDMI_3D_LA_FORMAT,
+ /** Side-by-Side(Full)Structure */
+ HDMI_3D_SSF_FORMAT,
+ /** 3D L+Depth Structure */
+ HDMI_3D_LD_FORMAT,
+ /** 3D L+Depth+Graphics Structure */
+ HDMI_3D_LDGFX_FORMAT,
+ /** 3D Top-and-Bottom Structure */
+ HDMI_3D_TB_FORMAT,
+ /** HDMI VIC Structure (ex. 4Kx2K) */
+ HDMI_VIC_FORMAT,
+ /** Side-by-Side(Half)Structure */
+ HDMI_3D_SSH_FORMAT,
+};
+#endif /* __HDMI_3D_VIDEO_STRUCTURE__ */
+
+#ifndef __HDMI_VIDEO_PARAMETER__
+#define __HDMI_VIDEO_PARAMETER__
+//! Structure for HDMI video
+struct HDMIVideoParameter {
+ /** Video interface */
+ enum HDMIMode mode;
+ /** Video format */
+ enum VideoFormat resolution;
+ /** Color space */
+ enum ColorSpace colorSpace;
+ /** Color depth */
+ enum ColorDepth colorDepth;
+ /** Colorimetry */
+ enum HDMIColorimetry colorimetry;
+ /** Pixel aspect ratio */
+ enum PixelAspectRatio pixelAspectRatio;
+ /** Video Source */
+ enum HDMIVideoSource videoSrc;
+ /** 3D Video Structure */
+ enum HDMI3DVideoStructure hdmi_3d_format;
+};
+#endif /* __HDMI_VIDEO_PARAMETER__*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _VIDEO_H_ */
diff --git a/exynos4/hal/include/videodev2.h b/exynos4/hal/include/videodev2.h
new file mode 100644
index 0000000..48b3081
--- /dev/null
+++ b/exynos4/hal/include/videodev2.h
@@ -0,0 +1,2227 @@
+/*
+ * Video for Linux Two header file
+ *
+ * Copyright (C) 1999-2007 the contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Alternatively you can redistribute this file under the terms of the
+ * BSD license as stated below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. The names of its contributors may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Header file for v4l or V4L2 drivers and applications
+ * with public API.
+ * All kernel-specific stuff were moved to media/v4l2-dev.h, so
+ * no #if __KERNEL tests are allowed here
+ *
+ * See http://linuxtv.org for more info
+ *
+ * Author: Bill Dirks <bill@thedirks.org>
+ * Justin Schoeman
+ * Hans Verkuil <hverkuil@xs4all.nl>
+ * et al.
+ */
+#ifndef __LINUX_VIDEODEV2_H
+#define __LINUX_VIDEODEV2_H
+
+#ifdef __KERNEL__
+#include <linux/time.h> /* need struct timeval */
+#else
+#include <sys/time.h>
+#endif
+#include <linux/compiler.h>
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/*
+ * Common stuff for both V4L1 and V4L2
+ * Moved from videodev.h
+ */
+#define VIDEO_MAX_FRAME 32
+#define VIDEO_MAX_PLANES 8
+
+#ifndef __KERNEL__
+
+/* These defines are V4L1 specific and should not be used with the V4L2 API!
+ They will be removed from this header in the future. */
+
+#define VID_TYPE_CAPTURE 1 /* Can capture */
+#define VID_TYPE_TUNER 2 /* Can tune */
+#define VID_TYPE_TELETEXT 4 /* Does teletext */
+#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
+#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
+#define VID_TYPE_CLIPPING 32 /* Can clip */
+#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
+#define VID_TYPE_SCALES 128 /* Scalable */
+#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
+#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
+#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
+#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
+#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
+#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
+#endif
+
+/*
+ * M I S C E L L A N E O U S
+ */
+
+/* Four-character-code (FOURCC) */
+#define v4l2_fourcc(a, b, c, d)\
+ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
+
+/*
+ * E N U M S
+ */
+enum v4l2_field {
+ V4L2_FIELD_ANY = 0, /* driver can choose from none,
+ top, bottom, interlaced
+ depending on whatever it thinks
+ is approximate ... */
+ V4L2_FIELD_NONE = 1, /* this device has no fields ... */
+ V4L2_FIELD_TOP = 2, /* top field only */
+ V4L2_FIELD_BOTTOM = 3, /* bottom field only */
+ V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
+ V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
+ buffer, top-bottom order */
+ V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
+ V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
+ separate buffers */
+ V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field
+ first and the top field is
+ transmitted first */
+ V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field
+ first and the bottom field is
+ transmitted first */
+};
+#define V4L2_FIELD_HAS_TOP(field) \
+ ((field) == V4L2_FIELD_TOP ||\
+ (field) == V4L2_FIELD_INTERLACED ||\
+ (field) == V4L2_FIELD_INTERLACED_TB ||\
+ (field) == V4L2_FIELD_INTERLACED_BT ||\
+ (field) == V4L2_FIELD_SEQ_TB ||\
+ (field) == V4L2_FIELD_SEQ_BT)
+#define V4L2_FIELD_HAS_BOTTOM(field) \
+ ((field) == V4L2_FIELD_BOTTOM ||\
+ (field) == V4L2_FIELD_INTERLACED ||\
+ (field) == V4L2_FIELD_INTERLACED_TB ||\
+ (field) == V4L2_FIELD_INTERLACED_BT ||\
+ (field) == V4L2_FIELD_SEQ_TB ||\
+ (field) == V4L2_FIELD_SEQ_BT)
+#define V4L2_FIELD_HAS_BOTH(field) \
+ ((field) == V4L2_FIELD_INTERLACED ||\
+ (field) == V4L2_FIELD_INTERLACED_TB ||\
+ (field) == V4L2_FIELD_INTERLACED_BT ||\
+ (field) == V4L2_FIELD_SEQ_TB ||\
+ (field) == V4L2_FIELD_SEQ_BT)
+
+enum v4l2_buf_type {
+ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
+ V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
+ V4L2_BUF_TYPE_VBI_CAPTURE = 4,
+ V4L2_BUF_TYPE_VBI_OUTPUT = 5,
+ V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
+ V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
+#if 1
+ /* Experimental */
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
+#endif
+ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
+ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
+ V4L2_BUF_TYPE_PRIVATE = 0x80,
+};
+
+#define V4L2_TYPE_IS_MULTIPLANAR(type) \
+ ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
+ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+
+#define V4L2_TYPE_IS_OUTPUT(type) \
+ ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \
+ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \
+ || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \
+ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \
+ || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \
+ || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
+
+enum v4l2_tuner_type {
+ V4L2_TUNER_RADIO = 1,
+ V4L2_TUNER_ANALOG_TV = 2,
+ V4L2_TUNER_DIGITAL_TV = 3,
+};
+
+enum v4l2_memory {
+ V4L2_MEMORY_MMAP = 1,
+ V4L2_MEMORY_USERPTR = 2,
+ V4L2_MEMORY_OVERLAY = 3,
+};
+
+/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
+enum v4l2_colorspace {
+ /* ITU-R 601 -- broadcast NTSC/PAL */
+ V4L2_COLORSPACE_SMPTE170M = 1,
+
+ /* 1125-Line (US) HDTV */
+ V4L2_COLORSPACE_SMPTE240M = 2,
+
+ /* HD and modern captures. */
+ V4L2_COLORSPACE_REC709 = 3,
+
+ /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
+ V4L2_COLORSPACE_BT878 = 4,
+
+ /* These should be useful. Assume 601 extents. */
+ V4L2_COLORSPACE_470_SYSTEM_M = 5,
+ V4L2_COLORSPACE_470_SYSTEM_BG = 6,
+
+ /* I know there will be cameras that send this. So, this is
+ * unspecified chromaticities and full 0-255 on each of the
+ * Y'CbCr components
+ */
+ V4L2_COLORSPACE_JPEG = 7,
+
+ /* For RGB colourspaces, this is probably a good start. */
+ V4L2_COLORSPACE_SRGB = 8,
+};
+
+enum v4l2_priority {
+ V4L2_PRIORITY_UNSET = 0, /* not initialized */
+ V4L2_PRIORITY_BACKGROUND = 1,
+ V4L2_PRIORITY_INTERACTIVE = 2,
+ V4L2_PRIORITY_RECORD = 3,
+ V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE,
+};
+
+struct v4l2_rect {
+ __s32 left;
+ __s32 top;
+ __s32 width;
+ __s32 height;
+};
+
+struct v4l2_fract {
+ __u32 numerator;
+ __u32 denominator;
+};
+
+/*
+ * D R I V E R C A P A B I L I T I E S
+ */
+struct v4l2_capability {
+ __u8 driver[16]; /* i.e. "bttv" */
+ __u8 card[32]; /* i.e. "Hauppauge WinTV" */
+ __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
+ __u32 version; /* should use KERNEL_VERSION() */
+ __u32 capabilities; /* Device capabilities */
+ __u32 reserved[4];
+};
+
+/* Values for 'capabilities' field */
+#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
+#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
+#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
+#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */
+#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */
+#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */
+#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
+#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
+#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
+#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
+#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
+
+/* Is a video capture device that supports multiplanar formats */
+#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
+/* Is a video output device that supports multiplanar formats */
+#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
+
+#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
+#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
+#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
+#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
+
+#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
+#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
+#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
+
+/*
+ * V I D E O I M A G E F O R M A T
+ */
+struct v4l2_pix_format {
+ __u32 width;
+ __u32 height;
+ __u32 pixelformat;
+ enum v4l2_field field;
+ __u32 bytesperline; /* for padding, zero if unused */
+ __u32 sizeimage;
+ enum v4l2_colorspace colorspace;
+ __u32 priv; /* private data, depends on pixelformat */
+};
+
+/* Pixel format FOURCC depth Description */
+
+/* RGB formats */
+#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
+#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
+#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
+#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */
+#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
+#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
+#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H') /* 18 BGR-6-6-6 */
+#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
+#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
+#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
+#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
+
+/* Grey formats */
+#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
+#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */
+#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */
+#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */
+#define V4L2_PIX_FMT_Y12 v4l2_fourcc('Y', '1', '2', ' ') /* 12 Greyscale */
+#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
+
+/* Grey bit-packed formats */
+#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
+
+/* Palette formats */
+#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
+
+/* Luminance+Chrominance formats */
+#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
+#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
+#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
+#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
+#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
+#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
+#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
+#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
+#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
+#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
+#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
+#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
+#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
+#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
+#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
+#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
+#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
+#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
+
+/* two planes -- one Y, one Cr + Cb interleaved */
+#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
+#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
+#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
+#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
+
+/* two non contiguous planes - one Y, one Cr + Cb interleaved */
+#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
+#define V4L2_PIX_FMT_NV21M v4l2_fourcc('N', 'M', '2', '1') /* 21 Y/CrCb 4:2:0 */
+#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
+#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */
+
+/* three non contiguous planes - Y, Cb, Cr */
+#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'U', 'V', 'M') /* 12 YUV420 planar */
+#define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'V', 'U', 'M') /* 12 YVU420 planar */
+
+/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
+#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
+#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
+#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
+#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */
+#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0') /* 10 BGBG.. GRGR.. */
+#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */
+#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */
+#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */
+#define V4L2_PIX_FMT_SBGGR12 v4l2_fourcc('B', 'G', '1', '2') /* 12 BGBG.. GRGR.. */
+#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */
+#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */
+#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */
+ /* 10bit raw bayer DPCM compressed to 8 bits */
+#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
+ /*
+ * 10bit raw bayer, expanded to 16 bits
+ * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
+ */
+#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
+
+/* compressed formats */
+#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
+#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */
+#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */
+#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */
+
+
+#define V4L2_PIX_FMT_H264 v4l2_fourcc('H', '2', '6', '4') /* H264 */
+#define V4L2_PIX_FMT_H263 v4l2_fourcc('H', '2', '6', '3') /* H263 */
+#define V4L2_PIX_FMT_MPEG12 v4l2_fourcc('M', 'P', '1', '2') /* MPEG-1/2 */
+#define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG-4 */
+#define V4L2_PIX_FMT_FIMV v4l2_fourcc('F', 'I', 'M', 'V') /* FIMV */
+#define V4L2_PIX_FMT_FIMV1 v4l2_fourcc('F', 'I', 'M', '1') /* FIMV1 */
+#define V4L2_PIX_FMT_FIMV2 v4l2_fourcc('F', 'I', 'M', '2') /* FIMV2 */
+#define V4L2_PIX_FMT_FIMV3 v4l2_fourcc('F', 'I', 'M', '3') /* FIMV3 */
+#define V4L2_PIX_FMT_FIMV4 v4l2_fourcc('F', 'I', 'M', '4') /* FIMV4 */
+#define V4L2_PIX_FMT_XVID v4l2_fourcc('X', 'V', 'I', 'D') /* Xvid */
+#define V4L2_PIX_FMT_VC1 v4l2_fourcc('V', 'C', '1', 'A') /* VC-1 */
+#define V4L2_PIX_FMT_VC1_RCV v4l2_fourcc('V', 'C', '1', 'R') /* VC-1 RCV */
+#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
+
+
+/* Vendor-specific formats */
+#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
+#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
+#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
+#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0') /* SN9C20x YUV 4:2:0 */
+#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */
+#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */
+#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */
+#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */
+#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */
+#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */
+#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */
+#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */
+#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */
+#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X') /* compressed GBRG bayer */
+#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */
+#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */
+#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */
+#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
+#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */
+#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */
+#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */
+#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */
+#define V4L2_PIX_FMT_JPGL v4l2_fourcc('J', 'P', 'G', 'L') /* JPEG-Lite */
+
+#define V4L2_PIX_FMT_JPEG_444 v4l2_fourcc('J', 'P', 'G', '4') /* yuv444 of JFIF JPEG */
+#define V4L2_PIX_FMT_JPEG_422 v4l2_fourcc('J', 'P', 'G', '2') /* yuv422 of JFIF JPEG */
+#define V4L2_PIX_FMT_JPEG_420 v4l2_fourcc('J', 'P', 'G', '0') /* yuv420 of JFIF JPEG */
+#define V4L2_PIX_FMT_JPEG_GRAY v4l2_fourcc('J', 'P', 'G', 'G') /* grey of JFIF JPEG */
+#define V4L2_PIX_FMT_YUV444_2P v4l2_fourcc('Y', 'U', '2', 'P') /* 16 xxxxyyyy uuuuvvvv */
+#define V4L2_PIX_FMT_YVU444_2P v4l2_fourcc('Y', 'V', '2', 'P') /* 16 xxxxyyyy uuuuvvvv */
+#define V4L2_PIX_FMT_YUV444_3P v4l2_fourcc('Y', 'U', '3', 'P') /* 16 xxxxyyyy uuuuvvvv */
+/*
+ * F O R M A T E N U M E R A T I O N
+ */
+struct v4l2_fmtdesc {
+ __u32 index; /* Format number */
+ enum v4l2_buf_type type; /* buffer type */
+ __u32 flags;
+ __u8 description[32]; /* Description string */
+ __u32 pixelformat; /* Format fourcc */
+ __u32 reserved[4];
+};
+
+#define V4L2_FMT_FLAG_COMPRESSED 0x0001
+#define V4L2_FMT_FLAG_EMULATED 0x0002
+
+#if 1
+ /* Experimental Frame Size and frame rate enumeration */
+/*
+ * F R A M E S I Z E E N U M E R A T I O N
+ */
+enum v4l2_frmsizetypes {
+ V4L2_FRMSIZE_TYPE_DISCRETE = 1,
+ V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
+ V4L2_FRMSIZE_TYPE_STEPWISE = 3,
+};
+
+struct v4l2_frmsize_discrete {
+ __u32 width; /* Frame width [pixel] */
+ __u32 height; /* Frame height [pixel] */
+};
+
+struct v4l2_frmsize_stepwise {
+ __u32 min_width; /* Minimum frame width [pixel] */
+ __u32 max_width; /* Maximum frame width [pixel] */
+ __u32 step_width; /* Frame width step size [pixel] */
+ __u32 min_height; /* Minimum frame height [pixel] */
+ __u32 max_height; /* Maximum frame height [pixel] */
+ __u32 step_height; /* Frame height step size [pixel] */
+};
+
+struct v4l2_frmsizeenum {
+ __u32 index; /* Frame size number */
+ __u32 pixel_format; /* Pixel format */
+ __u32 type; /* Frame size type the device supports. */
+
+ union { /* Frame size */
+ struct v4l2_frmsize_discrete discrete;
+ struct v4l2_frmsize_stepwise stepwise;
+ };
+
+ __u32 reserved[2]; /* Reserved space for future use */
+};
+
+/*
+ * F R A M E R A T E E N U M E R A T I O N
+ */
+enum v4l2_frmivaltypes {
+ V4L2_FRMIVAL_TYPE_DISCRETE = 1,
+ V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
+ V4L2_FRMIVAL_TYPE_STEPWISE = 3,
+};
+
+struct v4l2_frmival_stepwise {
+ struct v4l2_fract min; /* Minimum frame interval [s] */
+ struct v4l2_fract max; /* Maximum frame interval [s] */
+ struct v4l2_fract step; /* Frame interval step size [s] */
+};
+
+struct v4l2_frmivalenum {
+ __u32 index; /* Frame format index */
+ __u32 pixel_format; /* Pixel format */
+ __u32 width; /* Frame width */
+ __u32 height; /* Frame height */
+ __u32 type; /* Frame interval type the device supports. */
+
+ union { /* Frame interval */
+ struct v4l2_fract discrete;
+ struct v4l2_frmival_stepwise stepwise;
+ };
+
+ __u32 reserved[2]; /* Reserved space for future use */
+};
+#endif
+
+/*
+ * T I M E C O D E
+ */
+struct v4l2_timecode {
+ __u32 type;
+ __u32 flags;
+ __u8 frames;
+ __u8 seconds;
+ __u8 minutes;
+ __u8 hours;
+ __u8 userbits[4];
+};
+
+/* Type */
+#define V4L2_TC_TYPE_24FPS 1
+#define V4L2_TC_TYPE_25FPS 2
+#define V4L2_TC_TYPE_30FPS 3
+#define V4L2_TC_TYPE_50FPS 4
+#define V4L2_TC_TYPE_60FPS 5
+
+/* Flags */
+#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
+#define V4L2_TC_FLAG_COLORFRAME 0x0002
+#define V4L2_TC_USERBITS_field 0x000C
+#define V4L2_TC_USERBITS_USERDEFINED 0x0000
+#define V4L2_TC_USERBITS_8BITCHARS 0x0008
+/* The above is based on SMPTE timecodes */
+
+struct v4l2_jpegcompression {
+ int quality;
+
+ int APPn; /* Number of APP segment to be written,
+ * must be 0..15 */
+ int APP_len; /* Length of data in JPEG APPn segment */
+ char APP_data[60]; /* Data in the JPEG APPn segment. */
+
+ int COM_len; /* Length of data in JPEG COM segment */
+ char COM_data[60]; /* Data in JPEG COM segment */
+
+ __u32 jpeg_markers; /* Which markers should go into the JPEG
+ * output. Unless you exactly know what
+ * you do, leave them untouched.
+ * Inluding less markers will make the
+ * resulting code smaller, but there will
+ * be fewer applications which can read it.
+ * The presence of the APP and COM marker
+ * is influenced by APP_len and COM_len
+ * ONLY, not by this property! */
+
+#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
+#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
+#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
+#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
+#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
+ * allways use APP0 */
+};
+
+/*
+ * M E M O R Y - M A P P I N G B U F F E R S
+ */
+struct v4l2_requestbuffers {
+ __u32 count;
+ enum v4l2_buf_type type;
+ enum v4l2_memory memory;
+ __u32 reserved[2];
+};
+
+/**
+ * struct v4l2_plane - plane info for multi-planar buffers
+ * @bytesused: number of bytes occupied by data in the plane (payload)
+ * @length: size of this plane (NOT the payload) in bytes
+ * @mem_offset: when memory in the associated struct v4l2_buffer is
+ * V4L2_MEMORY_MMAP, equals the offset from the start of
+ * the device memory for this plane (or is a "cookie" that
+ * should be passed to mmap() called on the video node)
+ * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
+ * pointing to this plane
+ * @data_offset: offset in the plane to the start of data; usually 0,
+ * unless there is a header in front of the data
+ *
+ * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
+ * with two planes can have one plane for Y, and another for interleaved CbCr
+ * components. Each plane can reside in a separate memory buffer, or even in
+ * a completely separate memory node (e.g. in embedded devices).
+ */
+struct v4l2_plane {
+ __u32 bytesused;
+ __u32 length;
+ union {
+ __u32 mem_offset;
+ unsigned long userptr;
+ } m;
+ __u32 data_offset;
+ void *cookie;
+ void *share;
+ __u32 reserved[9];
+};
+
+/**
+ * struct v4l2_buffer - video buffer info
+ * @index: id number of the buffer
+ * @type: buffer type (type == *_MPLANE for multiplanar buffers)
+ * @bytesused: number of bytes occupied by data in the buffer (payload);
+ * unused (set to 0) for multiplanar buffers
+ * @flags: buffer informational flags
+ * @field: field order of the image in the buffer
+ * @timestamp: frame timestamp
+ * @timecode: frame timecode
+ * @sequence: sequence count of this frame
+ * @memory: the method, in which the actual video data is passed
+ * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
+ * offset from the start of the device memory for this plane,
+ * (or a "cookie" that should be passed to mmap() as offset)
+ * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
+ * a userspace pointer pointing to this buffer
+ * @planes: for multiplanar buffers; userspace pointer to the array of plane
+ * info structs for this buffer
+ * @length: size in bytes of the buffer (NOT its payload) for single-plane
+ * buffers (when type != *_MPLANE); number of elements in the
+ * planes array for multi-plane buffers
+ * @input: input number from which the video data has has been captured
+ *
+ * Contains data exchanged by application and driver using one of the Streaming
+ * I/O methods.
+ */
+struct v4l2_buffer {
+ __u32 index;
+ enum v4l2_buf_type type;
+ __u32 bytesused;
+ __u32 flags;
+ enum v4l2_field field;
+ struct timeval timestamp;
+ struct v4l2_timecode timecode;
+ __u32 sequence;
+
+ /* memory location */
+ enum v4l2_memory memory;
+ union {
+ __u32 offset;
+ unsigned long userptr;
+ struct v4l2_plane *planes;
+ } m;
+ __u32 length;
+ __u32 input;
+ __u32 reserved;
+};
+
+/* Flags for 'flags' field */
+#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
+#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
+#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
+#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
+#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
+#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
+/* Buffer is ready, but the data contained within is corrupted. */
+#define V4L2_BUF_FLAG_ERROR 0x0040
+#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
+#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */
+
+/*
+ * O V E R L A Y P R E V I E W
+ */
+struct v4l2_framebuffer {
+ __u32 capability;
+ __u32 flags;
+/* FIXME: in theory we should pass something like PCI device + memory
+ * region + offset instead of some physical address */
+ void *base;
+ struct v4l2_pix_format fmt;
+};
+/* Flags for the 'capability' field. Read only */
+#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
+#define V4L2_FBUF_CAP_CHROMAKEY 0x0002
+#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
+#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
+#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010
+#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020
+#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040
+#define V4L2_FBUF_CAP_SRC_CHROMAKEY 0x0080
+/* Flags for the 'flags' field. */
+#define V4L2_FBUF_FLAG_PRIMARY 0x0001
+#define V4L2_FBUF_FLAG_OVERLAY 0x0002
+#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
+#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008
+#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
+#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
+#define V4L2_FBUF_FLAG_SRC_CHROMAKEY 0x0040
+
+struct v4l2_clip {
+ struct v4l2_rect c;
+ struct v4l2_clip __user *next;
+};
+
+struct v4l2_window {
+ struct v4l2_rect w;
+ enum v4l2_field field;
+ __u32 chromakey;
+ struct v4l2_clip __user *clips;
+ __u32 clipcount;
+ void __user *bitmap;
+ __u8 global_alpha;
+};
+
+/*
+ * C A P T U R E P A R A M E T E R S
+ */
+struct v4l2_captureparm {
+ __u32 capability; /* Supported modes */
+ __u32 capturemode; /* Current mode */
+ struct v4l2_fract timeperframe; /* Time per frame in .1us units */
+ __u32 extendedmode; /* Driver-specific extensions */
+ __u32 readbuffers; /* # of buffers for read */
+ __u32 reserved[4];
+};
+
+/* Flags for 'capability' and 'capturemode' fields */
+#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
+#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
+
+struct v4l2_outputparm {
+ __u32 capability; /* Supported modes */
+ __u32 outputmode; /* Current mode */
+ struct v4l2_fract timeperframe; /* Time per frame in seconds */
+ __u32 extendedmode; /* Driver-specific extensions */
+ __u32 writebuffers; /* # of buffers for write */
+ __u32 reserved[4];
+};
+
+/*
+ * I N P U T I M A G E C R O P P I N G
+ */
+struct v4l2_cropcap {
+ enum v4l2_buf_type type;
+ struct v4l2_rect bounds;
+ struct v4l2_rect defrect;
+ struct v4l2_fract pixelaspect;
+};
+
+struct v4l2_crop {
+ enum v4l2_buf_type type;
+ struct v4l2_rect c;
+};
+
+/*
+ * A N A L O G V I D E O S T A N D A R D
+ */
+
+typedef __u64 v4l2_std_id;
+
+/* one bit for each */
+#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
+#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
+#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
+#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
+#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
+#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
+#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
+#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
+
+#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
+#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
+#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
+#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
+
+#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
+#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
+#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000)
+#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000)
+
+#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
+#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
+#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
+#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
+#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
+#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
+#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
+#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000)
+
+/* ATSC/HDTV */
+#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
+#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
+
+/* FIXME:
+ Although std_id is 64 bits, there is an issue on PPC32 architecture that
+ makes switch(__u64) to break. So, there's a hack on v4l2-common.c rounding
+ this value to 32 bits.
+ As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide),
+ it should work fine. However, if needed to add more than two standards,
+ v4l2-common.c should be fixed.
+ */
+
+/* some merged standards */
+#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
+#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)
+#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H)
+#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK)
+
+/* some common needed stuff */
+#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
+ V4L2_STD_PAL_B1 |\
+ V4L2_STD_PAL_G)
+#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\
+ V4L2_STD_PAL_D1 |\
+ V4L2_STD_PAL_K)
+#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\
+ V4L2_STD_PAL_DK |\
+ V4L2_STD_PAL_H |\
+ V4L2_STD_PAL_I)
+#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\
+ V4L2_STD_NTSC_M_JP |\
+ V4L2_STD_NTSC_M_KR)
+#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
+ V4L2_STD_SECAM_K |\
+ V4L2_STD_SECAM_K1)
+#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\
+ V4L2_STD_SECAM_G |\
+ V4L2_STD_SECAM_H |\
+ V4L2_STD_SECAM_DK |\
+ V4L2_STD_SECAM_L |\
+ V4L2_STD_SECAM_LC)
+
+#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\
+ V4L2_STD_PAL_60 |\
+ V4L2_STD_NTSC |\
+ V4L2_STD_NTSC_443)
+#define V4L2_STD_625_50 (V4L2_STD_PAL |\
+ V4L2_STD_PAL_N |\
+ V4L2_STD_PAL_Nc |\
+ V4L2_STD_SECAM)
+#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\
+ V4L2_STD_ATSC_16_VSB)
+
+#define V4L2_STD_UNKNOWN 0
+#define V4L2_STD_ALL (V4L2_STD_525_60 |\
+ V4L2_STD_625_50)
+
+struct v4l2_standard {
+ __u32 index;
+ v4l2_std_id id;
+ __u8 name[24];
+ struct v4l2_fract frameperiod; /* Frames, not fields */
+ __u32 framelines;
+ __u32 reserved[4];
+};
+
+/*
+ * V I D E O T I M I N G S D V P R E S E T
+ */
+struct v4l2_dv_preset {
+ __u32 preset;
+ __u32 reserved[4];
+};
+
+/*
+ * D V P R E S E T S E N U M E R A T I O N
+ */
+struct v4l2_dv_enum_preset {
+ __u32 index;
+ __u32 preset;
+ __u8 name[32]; /* Name of the preset timing */
+ __u32 width;
+ __u32 height;
+ __u32 reserved[4];
+};
+
+/*
+ * D V P R E S E T V A L U E S
+ */
+#define V4L2_DV_INVALID 0
+#define V4L2_DV_480P59_94 1 /* BT.1362 */
+#define V4L2_DV_576P50 2 /* BT.1362 */
+#define V4L2_DV_720P24 3 /* SMPTE 296M */
+#define V4L2_DV_720P25 4 /* SMPTE 296M */
+#define V4L2_DV_720P30 5 /* SMPTE 296M */
+#define V4L2_DV_720P50 6 /* SMPTE 296M */
+#define V4L2_DV_720P59_94 7 /* SMPTE 274M */
+#define V4L2_DV_720P60 8 /* SMPTE 274M/296M */
+#define V4L2_DV_1080I29_97 9 /* BT.1120/ SMPTE 274M */
+#define V4L2_DV_1080I30 10 /* BT.1120/ SMPTE 274M */
+#define V4L2_DV_1080I25 11 /* BT.1120 */
+#define V4L2_DV_1080I50 12 /* SMPTE 296M */
+#define V4L2_DV_1080I60 13 /* SMPTE 296M */
+#define V4L2_DV_1080P24 14 /* SMPTE 296M */
+#define V4L2_DV_1080P25 15 /* SMPTE 296M */
+#define V4L2_DV_1080P30 16 /* SMPTE 296M */
+#define V4L2_DV_1080P50 17 /* BT.1120 */
+#define V4L2_DV_1080P60 18 /* BT.1120 */
+
+#define V4L2_DV_480P60 19
+#define V4L2_DV_1080I59_94 20
+#define V4L2_DV_1080P59_94 21
+
+#define V4L2_DV_720P60_FP 22
+#define V4L2_DV_720P60_SB_HALF 23
+#define V4L2_DV_720P60_TB 24
+#define V4L2_DV_720P59_94_FP 25
+#define V4L2_DV_720P59_94_SB_HALF 26
+#define V4L2_DV_720P59_94_TB 27
+#define V4L2_DV_720P50_FP 28
+#define V4L2_DV_720P50_SB_HALF 29
+#define V4L2_DV_720P50_TB 30
+#define V4L2_DV_1080P24_FP 31
+#define V4L2_DV_1080P24_SB_HALF 32
+#define V4L2_DV_1080P24_TB 33
+#define V4L2_DV_1080P23_98_FP 34
+#define V4L2_DV_1080P23_98_SB_HALF 35
+#define V4L2_DV_1080P23_98_TB 36
+#define V4L2_DV_1080I60_SB_HALF 37
+#define V4L2_DV_1080I59_94_SB_HALF 38
+#define V4L2_DV_1080I50_SB_HALF 39
+#define V4L2_DV_1080P60_SB_HALF 40
+#define V4L2_DV_1080P60_TB 41
+#define V4L2_DV_1080P30_FP 42
+#define V4L2_DV_1080P30_SB_HALF 43
+#define V4L2_DV_1080P30_TB 44
+
+/*
+ * D V B T T I M I N G S
+ */
+
+/* BT.656/BT.1120 timing data */
+struct v4l2_bt_timings {
+ __u32 width; /* width in pixels */
+ __u32 height; /* height in lines */
+ __u32 interlaced; /* Interlaced or progressive */
+ __u32 polarities; /* Positive or negative polarity */
+ __u64 pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
+ __u32 hfrontporch; /* Horizpontal front porch in pixels */
+ __u32 hsync; /* Horizontal Sync length in pixels */
+ __u32 hbackporch; /* Horizontal back porch in pixels */
+ __u32 vfrontporch; /* Vertical front porch in pixels */
+ __u32 vsync; /* Vertical Sync length in lines */
+ __u32 vbackporch; /* Vertical back porch in lines */
+ __u32 il_vfrontporch; /* Vertical front porch for bottom field of
+ * interlaced field formats
+ */
+ __u32 il_vsync; /* Vertical sync length for bottom field of
+ * interlaced field formats
+ */
+ __u32 il_vbackporch; /* Vertical back porch for bottom field of
+ * interlaced field formats
+ */
+ __u32 reserved[16];
+} __attribute__ ((packed));
+
+/* Interlaced or progressive format */
+#define V4L2_DV_PROGRESSIVE 0
+#define V4L2_DV_INTERLACED 1
+
+/* Polarities. If bit is not set, it is assumed to be negative polarity */
+#define V4L2_DV_VSYNC_POS_POL 0x00000001
+#define V4L2_DV_HSYNC_POS_POL 0x00000002
+
+
+/* DV timings */
+struct v4l2_dv_timings {
+ __u32 type;
+ union {
+ struct v4l2_bt_timings bt;
+ __u32 reserved[32];
+ };
+} __attribute__ ((packed));
+
+/* Values for the type field */
+#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */
+
+/*
+ * V I D E O I N P U T S
+ */
+struct v4l2_input {
+ __u32 index; /* Which input */
+ __u8 name[32]; /* Label */
+ __u32 type; /* Type of input */
+ __u32 audioset; /* Associated audios (bitfield) */
+ __u32 tuner; /* Associated tuner */
+ v4l2_std_id std;
+ __u32 status;
+ __u32 capabilities;
+ __u32 reserved[3];
+};
+
+/* Values for the 'type' field */
+#define V4L2_INPUT_TYPE_TUNER 1
+#define V4L2_INPUT_TYPE_CAMERA 2
+
+/* field 'status' - general */
+#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */
+#define V4L2_IN_ST_NO_SIGNAL 0x00000002
+#define V4L2_IN_ST_NO_COLOR 0x00000004
+
+/* field 'status' - sensor orientation */
+/* If sensor is mounted upside down set both bits */
+#define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */
+#define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */
+
+/* field 'status' - analog */
+#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */
+#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */
+
+/* field 'status' - digital */
+#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */
+#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */
+#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */
+
+/* field 'status' - VCR and set-top box */
+#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */
+#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
+#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
+
+/* capabilities flags */
+#define V4L2_IN_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_IN_CAP_STD 0x00000004 /* Supports S_STD */
+
+/*
+ * V I D E O O U T P U T S
+ */
+struct v4l2_output {
+ __u32 index; /* Which output */
+ __u8 name[32]; /* Label */
+ __u32 type; /* Type of output */
+ __u32 audioset; /* Associated audios (bitfield) */
+ __u32 modulator; /* Associated modulator */
+ v4l2_std_id std;
+ __u32 capabilities;
+ __u32 reserved[3];
+};
+/* Values for the 'type' field */
+#define V4L2_OUTPUT_TYPE_MODULATOR 1
+#define V4L2_OUTPUT_TYPE_ANALOG 2
+#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
+
+/* capabilities flags */
+#define V4L2_OUT_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_OUT_CAP_STD 0x00000004 /* Supports S_STD */
+
+/*
+ * C O N T R O L S
+ */
+struct v4l2_control {
+ __u32 id;
+ __s32 value;
+};
+
+struct v4l2_ext_control {
+ __u32 id;
+ __u32 size;
+ __u32 reserved2[1];
+ union {
+ __s32 value;
+ __s64 value64;
+ char *string;
+ };
+} __attribute__ ((packed));
+
+struct v4l2_ext_controls {
+ __u32 ctrl_class;
+ __u32 count;
+ __u32 error_idx;
+ __u32 reserved[2];
+ struct v4l2_ext_control *controls;
+};
+
+/* Values for ctrl_class field */
+#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
+#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
+#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */
+#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */
+#define V4L2_CTRL_CLASS_CODEC 0x009c0000 /* Codec control class */
+
+#define V4L2_CTRL_ID_MASK (0x0fffffff)
+#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
+#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
+
+enum v4l2_ctrl_type {
+ V4L2_CTRL_TYPE_INTEGER = 1,
+ V4L2_CTRL_TYPE_BOOLEAN = 2,
+ V4L2_CTRL_TYPE_MENU = 3,
+ V4L2_CTRL_TYPE_BUTTON = 4,
+ V4L2_CTRL_TYPE_INTEGER64 = 5,
+ V4L2_CTRL_TYPE_CTRL_CLASS = 6,
+ V4L2_CTRL_TYPE_STRING = 7,
+};
+
+/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
+struct v4l2_queryctrl {
+ __u32 id;
+ enum v4l2_ctrl_type type;
+ __u8 name[32]; /* Whatever */
+ __s32 minimum; /* Note signedness */
+ __s32 maximum;
+ __s32 step;
+ __s32 default_value;
+ __u32 flags;
+ __u32 reserved[2];
+};
+
+/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
+struct v4l2_querymenu {
+ __u32 id;
+ __u32 index;
+ __u8 name[32]; /* Whatever */
+ __u32 reserved;
+};
+
+/* Control flags */
+#define V4L2_CTRL_FLAG_DISABLED 0x0001
+#define V4L2_CTRL_FLAG_GRABBED 0x0002
+#define V4L2_CTRL_FLAG_READ_ONLY 0x0004
+#define V4L2_CTRL_FLAG_UPDATE 0x0008
+#define V4L2_CTRL_FLAG_INACTIVE 0x0010
+#define V4L2_CTRL_FLAG_SLIDER 0x0020
+#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040
+
+/* Query flag, to be ORed with the control ID */
+#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
+
+/* User-class control IDs defined by V4L2 */
+#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
+#define V4L2_CID_USER_BASE V4L2_CID_BASE
+/* IDs reserved for driver specific controls */
+#define V4L2_CID_PRIVATE_BASE 0x08000000
+
+#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
+#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
+#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
+#define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
+#define V4L2_CID_HUE (V4L2_CID_BASE+3)
+#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
+#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
+#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
+#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
+#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
+#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
+#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */
+#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
+#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
+#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
+#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
+#define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
+#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */
+#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
+#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
+#define V4L2_CID_GAIN (V4L2_CID_BASE+19)
+#define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
+#define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
+
+/* Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */
+#define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
+#define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
+
+#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
+enum v4l2_power_line_frequency {
+ V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
+ V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
+ V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
+};
+#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
+#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
+#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
+#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
+#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29)
+#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30)
+#define V4L2_CID_COLORFX (V4L2_CID_BASE+31)
+enum v4l2_colorfx {
+ V4L2_COLORFX_NONE = 0,
+ V4L2_COLORFX_BW = 1,
+ V4L2_COLORFX_SEPIA = 2,
+ V4L2_COLORFX_NEGATIVE = 3,
+ V4L2_COLORFX_EMBOSS = 4,
+ V4L2_COLORFX_SKETCH = 5,
+ V4L2_COLORFX_SKY_BLUE = 6,
+ V4L2_COLORFX_GRASS_GREEN = 7,
+ V4L2_COLORFX_SKIN_WHITEN = 8,
+ V4L2_COLORFX_VIVID = 9,
+};
+#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
+#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
+
+#define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
+#define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
+
+#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
+
+#define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+37)
+#define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+38)
+
+/*
+ * This is custom CID
+ */
+/* for rgb alpha function */
+#define V4L2_CID_GLOBAL_ALPHA (V4L2_CID_BASE+39)
+
+/* cacheable configuration */
+#define V4L2_CID_CACHEABLE (V4L2_CID_BASE+40)
+
+/* jpeg captured size */
+#define V4L2_CID_CAM_JPEG_MEMSIZE (V4L2_CID_BASE+41)
+#define V4L2_CID_CAM_JPEG_ENCODEDSIZE (V4L2_CID_BASE+42)
+
+#define V4L2_CID_SET_SHAREABLE (V4L2_CID_BASE+43)
+
+/* TV configuration */
+#define V4L2_CID_TV_LAYER_BLEND_ENABLE (V4L2_CID_BASE+44)
+#define V4L2_CID_TV_LAYER_BLEND_ALPHA (V4L2_CID_BASE+45)
+#define V4L2_CID_TV_PIXEL_BLEND_ENABLE (V4L2_CID_BASE+46)
+#define V4L2_CID_TV_CHROMA_ENABLE (V4L2_CID_BASE+47)
+#define V4L2_CID_TV_CHROMA_VALUE (V4L2_CID_BASE+48)
+#define V4L2_CID_TV_HPD_STATUS (V4L2_CID_BASE+49)
+
+/* last CID + 1 */
+#define V4L2_CID_LASTP1 (V4L2_CID_BASE+50)
+
+/* MPEG-class control IDs defined by V4L2 */
+#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
+#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1)
+
+/* MPEG streams */
+#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0)
+enum v4l2_mpeg_stream_type {
+ V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */
+ V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */
+ V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */
+ V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */
+ V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */
+ V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */
+};
+#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1)
+#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2)
+#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3)
+#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4)
+#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5)
+#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6)
+#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7)
+enum v4l2_mpeg_stream_vbi_fmt {
+ V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */
+ V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */
+};
+
+/* MPEG audio */
+#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100)
+enum v4l2_mpeg_audio_sampling_freq {
+ V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0,
+ V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1,
+ V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2,
+};
+#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101)
+enum v4l2_mpeg_audio_encoding {
+ V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,
+ V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1,
+ V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2,
+ V4L2_MPEG_AUDIO_ENCODING_AAC = 3,
+ V4L2_MPEG_AUDIO_ENCODING_AC3 = 4,
+};
+#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102)
+enum v4l2_mpeg_audio_l1_bitrate {
+ V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0,
+ V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1,
+ V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2,
+ V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3,
+ V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4,
+ V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5,
+ V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6,
+ V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7,
+ V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8,
+ V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9,
+ V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10,
+ V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11,
+ V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12,
+ V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13,
+};
+#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103)
+enum v4l2_mpeg_audio_l2_bitrate {
+ V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0,
+ V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1,
+ V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2,
+ V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3,
+ V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4,
+ V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5,
+ V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6,
+ V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7,
+ V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8,
+ V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9,
+ V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10,
+ V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11,
+ V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12,
+ V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13,
+};
+#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104)
+enum v4l2_mpeg_audio_l3_bitrate {
+ V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0,
+ V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1,
+ V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2,
+ V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3,
+ V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4,
+ V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5,
+ V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6,
+ V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7,
+ V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8,
+ V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9,
+ V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10,
+ V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11,
+ V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12,
+ V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13,
+};
+#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105)
+enum v4l2_mpeg_audio_mode {
+ V4L2_MPEG_AUDIO_MODE_STEREO = 0,
+ V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1,
+ V4L2_MPEG_AUDIO_MODE_DUAL = 2,
+ V4L2_MPEG_AUDIO_MODE_MONO = 3,
+};
+#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106)
+enum v4l2_mpeg_audio_mode_extension {
+ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0,
+ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1,
+ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2,
+ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3,
+};
+#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107)
+enum v4l2_mpeg_audio_emphasis {
+ V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0,
+ V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1,
+ V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2,
+};
+#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108)
+enum v4l2_mpeg_audio_crc {
+ V4L2_MPEG_AUDIO_CRC_NONE = 0,
+ V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
+};
+#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109)
+#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110)
+#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111)
+enum v4l2_mpeg_audio_ac3_bitrate {
+ V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17,
+ V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18,
+};
+
+/* MPEG video */
+#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200)
+enum v4l2_mpeg_video_encoding {
+ V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0,
+ V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1,
+ V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,
+};
+#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201)
+enum v4l2_mpeg_video_aspect {
+ V4L2_MPEG_VIDEO_ASPECT_1x1 = 0,
+ V4L2_MPEG_VIDEO_ASPECT_4x3 = 1,
+ V4L2_MPEG_VIDEO_ASPECT_16x9 = 2,
+ V4L2_MPEG_VIDEO_ASPECT_221x100 = 3,
+};
+#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202)
+#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203)
+#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204)
+#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205)
+#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206)
+enum v4l2_mpeg_video_bitrate_mode {
+ V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0,
+ V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1,
+};
+#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207)
+#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208)
+#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209)
+#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
+#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
+
+/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
+#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
+enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
+ V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,
+ V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
+};
+#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2)
+enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
+ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0,
+ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
+ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2,
+ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
+ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,
+};
+#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3)
+enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
+ V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0,
+ V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
+};
+#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4)
+enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {
+ V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,
+ V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1,
+};
+#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6)
+enum v4l2_mpeg_cx2341x_video_median_filter_type {
+ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
+ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1,
+ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2,
+ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,
+ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
+};
+#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9)
+#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)
+#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)
+
+/* For codecs */
+
+#define V4L2_CID_CODEC_BASE (V4L2_CTRL_CLASS_CODEC | 0x900)
+#define V4L2_CID_CODEC_CLASS (V4L2_CTRL_CLASS_CODEC | 1)
+
+/* Codec class control IDs specific to the MFC5X driver */
+#define V4L2_CID_CODEC_MFC5X_BASE (V4L2_CTRL_CLASS_CODEC | 0x1000)
+
+/* For both decoding and encoding */
+
+/* For decoding */
+
+#define V4L2_CID_CODEC_LOOP_FILTER_MPEG4_ENABLE (V4L2_CID_CODEC_BASE + 110)
+#define V4L2_CID_CODEC_DISPLAY_DELAY (V4L2_CID_CODEC_BASE + 137)
+#define V4L2_CID_CODEC_REQ_NUM_BUFS (V4L2_CID_CODEC_BASE + 140)
+#define V4L2_CID_CODEC_SLICE_INTERFACE (V4L2_CID_CODEC_BASE + 141)
+#define V4L2_CID_CODEC_PACKED_PB (V4L2_CID_CODEC_BASE + 142)
+#define V4L2_CID_CODEC_FRAME_TAG (V4L2_CID_CODEC_BASE + 143)
+#define V4L2_CID_CODEC_CRC_ENABLE (V4L2_CID_CODEC_BASE + 144)
+#define V4L2_CID_CODEC_CRC_DATA_LUMA (V4L2_CID_CODEC_BASE + 145)
+#define V4L2_CID_CODEC_CRC_DATA_CHROMA (V4L2_CID_CODEC_BASE + 146)
+#define V4L2_CID_CODEC_CRC_DATA_LUMA_BOT (V4L2_CID_CODEC_BASE + 147)
+#define V4L2_CID_CODEC_CRC_DATA_CHROMA_BOT (V4L2_CID_CODEC_BASE + 148)
+#define V4L2_CID_CODEC_CRC_GENERATED (V4L2_CID_CODEC_BASE + 149)
+#define V4L2_CID_CODEC_FRAME_TYPE (V4L2_CID_CODEC_BASE + 154)
+#define V4L2_CID_CODEC_CHECK_STATE (V4L2_CID_CODEC_BASE + 155)
+#define V4L2_CID_CODEC_DISPLAY_STATUS (V4L2_CID_CODEC_BASE + 156)
+#define V4L2_CID_CODEC_FRAME_PACK_SEI_PARSE (V4L2_CID_CODEC_BASE + 157)
+#define V4L2_CID_CODEC_FRAME_PACK_SEI_AVAIL (V4L2_CID_CODEC_BASE + 158)
+#define V4L2_CID_CODEC_FRAME_PACK_ARRGMENT_ID (V4L2_CID_CODEC_BASE + 159)
+#define V4L2_CID_CODEC_FRAME_PACK_SEI_INFO (V4L2_CID_CODEC_BASE + 160)
+#define V4L2_CID_CODEC_FRAME_PACK_GRID_POS (V4L2_CID_CODEC_BASE + 161)
+
+/* For encoding */
+#define V4L2_CID_CODEC_LOOP_FILTER_H264 (V4L2_CID_CODEC_BASE + 9)
+enum v4l2_cid_codec_loop_filter_h264 {
+ V4L2_CID_CODEC_LOOP_FILTER_H264_ENABLE = 0,
+ V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE = 1,
+ V4L2_CID_CODEC_LOOP_FILTER_H264_DISABLE_AT_BOUNDARY = 2,
+};
+
+#define V4L2_CID_CODEC_FRAME_INSERTION (V4L2_CID_CODEC_BASE + 10)
+enum v4l2_cid_codec_frame_insertion {
+ V4L2_CID_CODEC_FRAME_INSERT_NONE = 0x0,
+ V4L2_CID_CODEC_FRAME_INSERT_I_FRAME = 0x1,
+ V4L2_CID_CODEC_FRAME_INSERT_NOT_CODED = 0x2,
+};
+
+#define V4L2_CID_CODEC_ENCODED_LUMA_ADDR (V4L2_CID_CODEC_BASE + 11)
+#define V4L2_CID_CODEC_ENCODED_CHROMA_ADDR (V4L2_CID_CODEC_BASE + 12)
+
+#define V4L2_CID_CODEC_ENCODED_I_PERIOD_CH V4L2_CID_CODEC_MFC5X_ENC_GOP_SIZE
+#define V4L2_CID_CODEC_ENCODED_FRAME_RATE_CH V4L2_CID_CODEC_MFC5X_ENC_H264_RC_FRAME_RATE
+#define V4L2_CID_CODEC_ENCODED_BIT_RATE_CH V4L2_CID_CODEC_MFC5X_ENC_RC_BIT_RATE
+
+#define V4L2_CID_CODEC_FRAME_PACK_SEI_GEN (V4L2_CID_CODEC_BASE + 13)
+#define V4L2_CID_CODEC_FRAME_PACK_FRM0_FLAG (V4L2_CID_CODEC_BASE + 14)
+enum v4l2_codec_mfc5x_enc_flag {
+ V4L2_CODEC_MFC5X_ENC_FLAG_DISABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_FLAG_ENABLE = 1,
+};
+#define V4L2_CID_CODEC_FRAME_PACK_ARRGMENT_TYPE (V4L2_CID_CODEC_BASE + 15)
+enum v4l2_codec_mfc5x_enc_frame_pack_arrgment_type {
+ V4L2_CODEC_MFC5X_ENC_FRAME_PACK_SIDE_BY_SIDE = 0,
+ V4L2_CODEC_MFC5X_ENC_FRAME_PACK_TOP_AND_BOT = 1,
+ V4L2_CODEC_MFC5X_ENC_FRAME_PACK_TMP_INTER = 2,
+};
+
+/* common */
+enum v4l2_codec_mfc5x_enc_switch {
+ V4L2_CODEC_MFC5X_ENC_SW_DISABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_SW_ENABLE = 1,
+};
+enum v4l2_codec_mfc5x_enc_switch_inv {
+ V4L2_CODEC_MFC5X_ENC_SW_INV_ENABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_SW_INV_DISABLE = 1,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_GOP_SIZE (V4L2_CID_CODEC_MFC5X_BASE+300)
+#define V4L2_CID_CODEC_MFC5X_ENC_MULTI_SLICE_MODE (V4L2_CID_CODEC_MFC5X_BASE+301)
+enum v4l2_codec_mfc5x_enc_multi_slice_mode {
+ V4L2_CODEC_MFC5X_ENC_MULTI_SLICE_MODE_DISABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_MULTI_SLICE_MODE_MACROBLOCK_COUNT = 1,
+ V4L2_CODEC_MFC5X_ENC_MULTI_SLICE_MODE_BIT_COUNT = 3,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_MULTI_SLICE_MB (V4L2_CID_CODEC_MFC5X_BASE+302)
+#define V4L2_CID_CODEC_MFC5X_ENC_MULTI_SLICE_BIT (V4L2_CID_CODEC_MFC5X_BASE+303)
+#define V4L2_CID_CODEC_MFC5X_ENC_INTRA_REFRESH_MB (V4L2_CID_CODEC_MFC5X_BASE+304)
+#define V4L2_CID_CODEC_MFC5X_ENC_PAD_CTRL_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+305)
+#define V4L2_CID_CODEC_MFC5X_ENC_PAD_LUMA_VALUE (V4L2_CID_CODEC_MFC5X_BASE+306)
+#define V4L2_CID_CODEC_MFC5X_ENC_PAD_CB_VALUE (V4L2_CID_CODEC_MFC5X_BASE+307)
+#define V4L2_CID_CODEC_MFC5X_ENC_PAD_CR_VALUE (V4L2_CID_CODEC_MFC5X_BASE+308)
+#define V4L2_CID_CODEC_MFC5X_ENC_RC_FRAME_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+309)
+#define V4L2_CID_CODEC_MFC5X_ENC_RC_BIT_RATE (V4L2_CID_CODEC_MFC5X_BASE+310)
+#define V4L2_CID_CODEC_MFC5X_ENC_RC_REACTION_COEFF (V4L2_CID_CODEC_MFC5X_BASE+311)
+#define V4L2_CID_CODEC_MFC5X_ENC_STREAM_SIZE (V4L2_CID_CODEC_MFC5X_BASE+312)
+#define V4L2_CID_CODEC_MFC5X_ENC_FRAME_COUNT (V4L2_CID_CODEC_MFC5X_BASE+313)
+#define V4L2_CID_CODEC_MFC5X_ENC_FRAME_TYPE (V4L2_CID_CODEC_MFC5X_BASE+314)
+enum v4l2_codec_mfc5x_enc_frame_type {
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_NOT_CODED = 0,
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_I_FRAME = 1,
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_P_FRAME = 2,
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_B_FRAME = 3,
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_SKIPPED = 4,
+ V4L2_CODEC_MFC5X_ENC_FRAME_TYPE_OTHERS = 5,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_FORCE_FRAME_TYPE (V4L2_CID_CODEC_MFC5X_BASE+315)
+enum v4l2_codec_mfc5x_enc_force_frame_type {
+ V4L2_CODEC_MFC5X_ENC_FORCE_FRAME_TYPE_I_FRAME = 1,
+ V4L2_CODEC_MFC5X_ENC_FORCE_FRAME_TYPE_NOT_CODED = 2,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_VBV_BUF_SIZE (V4L2_CID_CODEC_MFC5X_BASE+316)
+#define V4L2_CID_CODEC_MFC5X_ENC_SEQ_HDR_MODE (V4L2_CID_CODEC_MFC5X_BASE+317)
+enum v4l2_codec_mfc5x_enc_seq_hdr_mode {
+ V4L2_CODEC_MFC5X_ENC_SEQ_HDR_MODE_SEQ = 0,
+ V4L2_CODEC_MFC5X_ENC_SEQ_HDR_MODE_SEQ_FRAME = 1,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_FRAME_SKIP_MODE (V4L2_CID_CODEC_MFC5X_BASE+318)
+enum v4l2_codec_mfc5x_enc_frame_skip_mode {
+ V4L2_CODEC_MFC5X_ENC_FRAME_SKIP_MODE_DISABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_FRAME_SKIP_MODE_LEVEL = 1,
+ V4L2_CODEC_MFC5X_ENC_FRAME_SKIP_MODE_VBV_BUF_SIZE = 2,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_RC_FIXED_TARGET_BIT (V4L2_CID_CODEC_MFC5X_BASE+319)
+#define V4L2_CID_CODEC_MFC5X_ENC_FRAME_DELTA (V4L2_CID_CODEC_MFC5X_BASE+320)
+
+/* codec specific */
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_B_FRAMES (V4L2_CID_CODEC_MFC5X_BASE+400)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_PROFILE (V4L2_CID_CODEC_MFC5X_BASE+401)
+enum v4l2_codec_mfc5x_enc_h264_profile {
+ V4L2_CODEC_MFC5X_ENC_H264_PROFILE_MAIN = 0,
+ V4L2_CODEC_MFC5X_ENC_H264_PROFILE_HIGH = 1,
+ V4L2_CODEC_MFC5X_ENC_H264_PROFILE_BASELINE = 2,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LEVEL (V4L2_CID_CODEC_MFC5X_BASE+402)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_INTERLACE (V4L2_CID_CODEC_MFC5X_BASE+403)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LOOP_FILTER_MODE (V4L2_CID_CODEC_MFC5X_BASE+404)
+enum v4l2_codec_mfc5x_enc_h264_loop_filter {
+ V4L2_CODEC_MFC5X_ENC_H264_LOOP_FILTER_ENABLE = 0,
+ V4L2_CODEC_MFC5X_ENC_H264_LOOP_FILTER_DISABLE = 1,
+ V4L2_CODEC_MFC5X_ENC_H264_LOOP_FILTER_DISABLE_AT_BOUNDARY = 2,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LOOP_FILTER_ALPHA (V4L2_CID_CODEC_MFC5X_BASE+405)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LOOP_FILTER_BETA (V4L2_CID_CODEC_MFC5X_BASE+406)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_ENTROPY_MODE (V4L2_CID_CODEC_MFC5X_BASE+407)
+enum v4l2_codec_mfc5x_enc_h264_entropy_mode {
+ V4L2_CODEC_MFC5X_ENC_H264_ENTROPY_MODE_CAVLC = 0,
+ V4L2_CODEC_MFC5X_ENC_H264_ENTROPY_MODE_CABAC = 1,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_MAX_REF_PIC (V4L2_CID_CODEC_MFC5X_BASE+408)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_NUM_REF_PIC_4P (V4L2_CID_CODEC_MFC5X_BASE+409)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_8X8_TRANSFORM (V4L2_CID_CODEC_MFC5X_BASE+410)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MB_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+411)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_FRAME_RATE (V4L2_CID_CODEC_MFC5X_BASE+412)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+413)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+414)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+415)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MB_DARK (V4L2_CID_CODEC_MFC5X_BASE+416)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MB_SMOOTH (V4L2_CID_CODEC_MFC5X_BASE+417)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MB_STATIC (V4L2_CID_CODEC_MFC5X_BASE+418)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_MB_ACTIVITY (V4L2_CID_CODEC_MFC5X_BASE+419)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+420)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_RC_B_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+421)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_AR_VUI_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+422)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_AR_VUI_IDC (V4L2_CID_CODEC_MFC5X_BASE+423)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_EXT_SAR_WIDTH (V4L2_CID_CODEC_MFC5X_BASE+424)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_EXT_SAR_HEIGHT (V4L2_CID_CODEC_MFC5X_BASE+425)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_OPEN_GOP (V4L2_CID_CODEC_MFC5X_BASE+426)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_I_PERIOD (V4L2_CID_CODEC_MFC5X_BASE+427)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_HIER_P_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+428)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LAYER0_QP (V4L2_CID_CODEC_MFC5X_BASE+429)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LAYER1_QP (V4L2_CID_CODEC_MFC5X_BASE+430)
+#define V4L2_CID_CODEC_MFC5X_ENC_H264_LAYER2_QP (V4L2_CID_CODEC_MFC5X_BASE+431)
+
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_B_FRAMES (V4L2_CID_CODEC_MFC5X_BASE+440)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_PROFILE (V4L2_CID_CODEC_MFC5X_BASE+441)
+enum v4l2_codec_mfc5x_enc_mpeg4_profile {
+ V4L2_CODEC_MFC5X_ENC_MPEG4_PROFILE_SIMPLE = 0,
+ V4L2_CODEC_MFC5X_ENC_MPEG4_PROFILE_ADVANCED_SIMPLE = 1,
+};
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_LEVEL (V4L2_CID_CODEC_MFC5X_BASE+442)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+443)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+444)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+445)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_QUARTER_PIXEL (V4L2_CID_CODEC_MFC5X_BASE+446)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+447)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_B_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+448)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_VOP_TIME_RES (V4L2_CID_CODEC_MFC5X_BASE+449)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_VOP_FRM_DELTA (V4L2_CID_CODEC_MFC5X_BASE+450)
+#define V4L2_CID_CODEC_MFC5X_ENC_MPEG4_RC_MB_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+451)
+
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_FRAME_RATE (V4L2_CID_CODEC_MFC5X_BASE+460)
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+461)
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_MIN_QP (V4L2_CID_CODEC_MFC5X_BASE+462)
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_MAX_QP (V4L2_CID_CODEC_MFC5X_BASE+463)
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_P_FRAME_QP (V4L2_CID_CODEC_MFC5X_BASE+464)
+#define V4L2_CID_CODEC_MFC5X_ENC_H263_RC_MB_ENABLE (V4L2_CID_CODEC_MFC5X_BASE+465)
+
+/* Camera class control IDs */
+#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
+#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
+
+#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
+enum v4l2_exposure_auto_type {
+ V4L2_EXPOSURE_AUTO = 0,
+ V4L2_EXPOSURE_MANUAL = 1,
+ V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
+ V4L2_EXPOSURE_APERTURE_PRIORITY = 3
+};
+#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
+#define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
+
+#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
+#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
+#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
+#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
+
+#define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
+#define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
+
+#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
+#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
+#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
+
+#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
+#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14)
+#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15)
+
+#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
+
+#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
+#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18)
+
+/* FM Modulator class control IDs */
+#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
+#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
+
+#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1)
+#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
+#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3)
+#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
+#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
+
+#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
+#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
+#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66)
+
+#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80)
+#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81)
+#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
+#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83)
+#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84)
+
+#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96)
+#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
+#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98)
+
+#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112)
+enum v4l2_preemphasis {
+ V4L2_PREEMPHASIS_DISABLED = 0,
+ V4L2_PREEMPHASIS_50_uS = 1,
+ V4L2_PREEMPHASIS_75_uS = 2,
+};
+#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
+#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114)
+
+/*
+ * T U N I N G
+ */
+struct v4l2_tuner {
+ __u32 index;
+ __u8 name[32];
+ enum v4l2_tuner_type type;
+ __u32 capability;
+ __u32 rangelow;
+ __u32 rangehigh;
+ __u32 rxsubchans;
+ __u32 audmode;
+ __s32 signal;
+ __s32 afc;
+ __u32 reserved[4];
+};
+
+struct v4l2_modulator {
+ __u32 index;
+ __u8 name[32];
+ __u32 capability;
+ __u32 rangelow;
+ __u32 rangehigh;
+ __u32 txsubchans;
+ __u32 reserved[4];
+};
+
+/* Flags for the 'capability' field */
+#define V4L2_TUNER_CAP_LOW 0x0001
+#define V4L2_TUNER_CAP_NORM 0x0002
+#define V4L2_TUNER_CAP_STEREO 0x0010
+#define V4L2_TUNER_CAP_LANG2 0x0020
+#define V4L2_TUNER_CAP_SAP 0x0020
+#define V4L2_TUNER_CAP_LANG1 0x0040
+#define V4L2_TUNER_CAP_RDS 0x0080
+#define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100
+#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
+
+/* Flags for the 'rxsubchans' field */
+#define V4L2_TUNER_SUB_MONO 0x0001
+#define V4L2_TUNER_SUB_STEREO 0x0002
+#define V4L2_TUNER_SUB_LANG2 0x0004
+#define V4L2_TUNER_SUB_SAP 0x0004
+#define V4L2_TUNER_SUB_LANG1 0x0008
+#define V4L2_TUNER_SUB_RDS 0x0010
+
+/* Values for the 'audmode' field */
+#define V4L2_TUNER_MODE_MONO 0x0000
+#define V4L2_TUNER_MODE_STEREO 0x0001
+#define V4L2_TUNER_MODE_LANG2 0x0002
+#define V4L2_TUNER_MODE_SAP 0x0002
+#define V4L2_TUNER_MODE_LANG1 0x0003
+#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
+
+struct v4l2_frequency {
+ __u32 tuner;
+ enum v4l2_tuner_type type;
+ __u32 frequency;
+ __u32 reserved[8];
+};
+
+struct v4l2_hw_freq_seek {
+ __u32 tuner;
+ enum v4l2_tuner_type type;
+ __u32 seek_upward;
+ __u32 wrap_around;
+ __u32 spacing;
+ __u32 reserved[7];
+};
+
+/*
+ * R D S
+ */
+
+struct v4l2_rds_data {
+ __u8 lsb;
+ __u8 msb;
+ __u8 block;
+} __attribute__ ((packed));
+
+#define V4L2_RDS_BLOCK_MSK 0x7
+#define V4L2_RDS_BLOCK_A 0
+#define V4L2_RDS_BLOCK_B 1
+#define V4L2_RDS_BLOCK_C 2
+#define V4L2_RDS_BLOCK_D 3
+#define V4L2_RDS_BLOCK_C_ALT 4
+#define V4L2_RDS_BLOCK_INVALID 7
+
+#define V4L2_RDS_BLOCK_CORRECTED 0x40
+#define V4L2_RDS_BLOCK_ERROR 0x80
+
+/*
+ * A U D I O
+ */
+struct v4l2_audio {
+ __u32 index;
+ __u8 name[32];
+ __u32 capability;
+ __u32 mode;
+ __u32 reserved[2];
+};
+
+/* Flags for the 'capability' field */
+#define V4L2_AUDCAP_STEREO 0x00001
+#define V4L2_AUDCAP_AVL 0x00002
+
+/* Flags for the 'mode' field */
+#define V4L2_AUDMODE_AVL 0x00001
+
+struct v4l2_audioout {
+ __u32 index;
+ __u8 name[32];
+ __u32 capability;
+ __u32 mode;
+ __u32 reserved[2];
+};
+
+/*
+ * M P E G S E R V I C E S
+ *
+ * NOTE: EXPERIMENTAL API
+ */
+#if 1
+#define V4L2_ENC_IDX_FRAME_I (0)
+#define V4L2_ENC_IDX_FRAME_P (1)
+#define V4L2_ENC_IDX_FRAME_B (2)
+#define V4L2_ENC_IDX_FRAME_MASK (0xf)
+
+struct v4l2_enc_idx_entry {
+ __u64 offset;
+ __u64 pts;
+ __u32 length;
+ __u32 flags;
+ __u32 reserved[2];
+};
+
+#define V4L2_ENC_IDX_ENTRIES (64)
+struct v4l2_enc_idx {
+ __u32 entries;
+ __u32 entries_cap;
+ __u32 reserved[4];
+ struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES];
+};
+
+
+#define V4L2_ENC_CMD_START (0)
+#define V4L2_ENC_CMD_STOP (1)
+#define V4L2_ENC_CMD_PAUSE (2)
+#define V4L2_ENC_CMD_RESUME (3)
+
+/* Flags for V4L2_ENC_CMD_STOP */
+#define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0)
+
+struct v4l2_encoder_cmd {
+ __u32 cmd;
+ __u32 flags;
+ union {
+ struct {
+ __u32 data[8];
+ } raw;
+ };
+};
+
+#endif
+
+
+/*
+ * D A T A S E R V I C E S ( V B I )
+ *
+ * Data services API by Michael Schimek
+ */
+
+/* Raw VBI */
+struct v4l2_vbi_format {
+ __u32 sampling_rate; /* in 1 Hz */
+ __u32 offset;
+ __u32 samples_per_line;
+ __u32 sample_format; /* V4L2_PIX_FMT_* */
+ __s32 start[2];
+ __u32 count[2];
+ __u32 flags; /* V4L2_VBI_* */
+ __u32 reserved[2]; /* must be zero */
+};
+
+/* VBI flags */
+#define V4L2_VBI_UNSYNC (1 << 0)
+#define V4L2_VBI_INTERLACED (1 << 1)
+
+/* Sliced VBI
+ *
+ * This implements is a proposal V4L2 API to allow SLICED VBI
+ * required for some hardware encoders. It should change without
+ * notice in the definitive implementation.
+ */
+
+struct v4l2_sliced_vbi_format {
+ __u16 service_set;
+ /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
+ service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
+ (equals frame lines 313-336 for 625 line video
+ standards, 263-286 for 525 line standards) */
+ __u16 service_lines[2][24];
+ __u32 io_size;
+ __u32 reserved[2]; /* must be zero */
+};
+
+/* Teletext World System Teletext
+ (WST), defined on ITU-R BT.653-2 */
+#define V4L2_SLICED_TELETEXT_B (0x0001)
+/* Video Program System, defined on ETS 300 231*/
+#define V4L2_SLICED_VPS (0x0400)
+/* Closed Caption, defined on EIA-608 */
+#define V4L2_SLICED_CAPTION_525 (0x1000)
+/* Wide Screen System, defined on ITU-R BT1119.1 */
+#define V4L2_SLICED_WSS_625 (0x4000)
+
+#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
+#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
+
+struct v4l2_sliced_vbi_cap {
+ __u16 service_set;
+ /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
+ service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
+ (equals frame lines 313-336 for 625 line video
+ standards, 263-286 for 525 line standards) */
+ __u16 service_lines[2][24];
+ enum v4l2_buf_type type;
+ __u32 reserved[3]; /* must be 0 */
+};
+
+struct v4l2_sliced_vbi_data {
+ __u32 id;
+ __u32 field; /* 0: first field, 1: second field */
+ __u32 line; /* 1-23 */
+ __u32 reserved; /* must be 0 */
+ __u8 data[48];
+};
+
+/*
+ * Sliced VBI data inserted into MPEG Streams
+ */
+
+/*
+ * V4L2_MPEG_STREAM_VBI_FMT_IVTV:
+ *
+ * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an
+ * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI
+ * data
+ *
+ * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header
+ * definitions are not included here. See the MPEG-2 specifications for details
+ * on these headers.
+ */
+
+/* Line type IDs */
+#define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1)
+#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4)
+#define V4L2_MPEG_VBI_IVTV_WSS_625 (5)
+#define V4L2_MPEG_VBI_IVTV_VPS (7)
+
+struct v4l2_mpeg_vbi_itv0_line {
+ __u8 id; /* One of V4L2_MPEG_VBI_IVTV_* above */
+ __u8 data[42]; /* Sliced VBI data for the line */
+} __attribute__ ((packed));
+
+struct v4l2_mpeg_vbi_itv0 {
+ __le32 linemask[2]; /* Bitmasks of VBI service lines present */
+ struct v4l2_mpeg_vbi_itv0_line line[35];
+} __attribute__ ((packed));
+
+struct v4l2_mpeg_vbi_ITV0 {
+ struct v4l2_mpeg_vbi_itv0_line line[36];
+} __attribute__ ((packed));
+
+#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0"
+#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0"
+
+struct v4l2_mpeg_vbi_fmt_ivtv {
+ __u8 magic[4];
+ union {
+ struct v4l2_mpeg_vbi_itv0 itv0;
+ struct v4l2_mpeg_vbi_ITV0 ITV0;
+ };
+} __attribute__ ((packed));
+
+/*
+ * A G G R E G A T E S T R U C T U R E S
+ */
+
+/**
+ * struct v4l2_plane_pix_format - additional, per-plane format definition
+ * @sizeimage: maximum size in bytes required for data, for which
+ * this plane will be used
+ * @bytesperline: distance in bytes between the leftmost pixels in two
+ * adjacent lines
+ */
+struct v4l2_plane_pix_format {
+ __u32 sizeimage;
+ __u16 bytesperline;
+ __u16 reserved[7];
+} __attribute__ ((packed));
+
+/**
+ * struct v4l2_pix_format_mplane - multiplanar format definition
+ * @width: image width in pixels
+ * @height: image height in pixels
+ * @pixelformat: little endian four character code (fourcc)
+ * @field: field order (for interlaced video)
+ * @colorspace: supplemental to pixelformat
+ * @plane_fmt: per-plane information
+ * @num_planes: number of planes for this format
+ */
+struct v4l2_pix_format_mplane {
+ __u32 width;
+ __u32 height;
+ __u32 pixelformat;
+ enum v4l2_field field;
+ enum v4l2_colorspace colorspace;
+
+ struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
+ __u8 num_planes;
+ __u8 reserved[11];
+} __attribute__ ((packed));
+
+/**
+ * struct v4l2_format - stream data format
+ * @type: type of the data stream
+ * @pix: definition of an image format
+ * @pix_mp: definition of a multiplanar image format
+ * @win: definition of an overlaid image
+ * @vbi: raw VBI capture or output parameters
+ * @sliced: sliced VBI capture or output parameters
+ * @raw_data: placeholder for future extensions and custom formats
+ */
+struct v4l2_format {
+ enum v4l2_buf_type type;
+ union {
+ struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
+ struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
+ struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
+ struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
+ struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
+ __u8 raw_data[200]; /* user-defined */
+ } fmt;
+};
+
+/* Stream type-dependent parameters
+ */
+struct v4l2_streamparm {
+ enum v4l2_buf_type type;
+ union {
+ struct v4l2_captureparm capture;
+ struct v4l2_outputparm output;
+ __u8 raw_data[200]; /* user-defined */
+ } parm;
+};
+
+/*
+ * E V E N T S
+ */
+
+#define V4L2_EVENT_ALL 0
+#define V4L2_EVENT_VSYNC 1
+#define V4L2_EVENT_EOS 2
+#define V4L2_EVENT_PRIVATE_START 0x08000000
+
+/* Payload for V4L2_EVENT_VSYNC */
+struct v4l2_event_vsync {
+ /* Can be V4L2_FIELD_ANY, _NONE, _TOP or _BOTTOM */
+ __u8 field;
+} __attribute__ ((packed));
+
+struct v4l2_event {
+ __u32 type;
+ union {
+ struct v4l2_event_vsync vsync;
+ __u8 data[64];
+ } u;
+ __u32 pending;
+ __u32 sequence;
+ struct timespec timestamp;
+ __u32 reserved[9];
+};
+
+struct v4l2_event_subscription {
+ __u32 type;
+ __u32 reserved[7];
+};
+
+/*
+ * A D V A N C E D D E B U G G I N G
+ *
+ * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS!
+ * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY!
+ */
+
+/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */
+
+#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
+#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */
+#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
+#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
+
+struct v4l2_dbg_match {
+ __u32 type; /* Match type */
+ union { /* Match this chip, meaning determined by type */
+ __u32 addr;
+ char name[32];
+ };
+} __attribute__ ((packed));
+
+struct v4l2_dbg_register {
+ struct v4l2_dbg_match match;
+ __u32 size; /* register size in bytes */
+ __u64 reg;
+ __u64 val;
+} __attribute__ ((packed));
+
+/* VIDIOC_DBG_G_CHIP_IDENT */
+struct v4l2_dbg_chip_ident {
+ struct v4l2_dbg_match match;
+ __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */
+ __u32 revision; /* chip revision, chip specific */
+} __attribute__ ((packed));
+
+/*
+ * I O C T L C O D E S F O R V I D E O D E V I C E S
+ *
+ */
+#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
+#define VIDIOC_RESERVED _IO('V', 1)
+#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
+#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
+#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
+#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
+#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
+#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
+#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
+#define VIDIOC_OVERLAY _IOW('V', 14, int)
+#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
+#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
+#define VIDIOC_STREAMON _IOW('V', 18, int)
+#define VIDIOC_STREAMOFF _IOW('V', 19, int)
+#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
+#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
+#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
+#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
+#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
+#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
+#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
+#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
+#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
+#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
+#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
+#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
+#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
+#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
+#define VIDIOC_G_INPUT _IOR('V', 38, int)
+#define VIDIOC_S_INPUT _IOWR('V', 39, int)
+#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
+#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
+#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
+#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
+#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
+#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
+#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
+#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
+#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
+#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
+#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
+#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
+#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
+#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
+#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
+#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
+#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
+#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
+#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
+#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
+#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
+#define VIDIOC_LOG_STATUS _IO('V', 70)
+#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
+#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
+#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
+#if 1
+#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
+#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
+#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
+#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
+#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
+#endif
+
+#if 1
+/* Experimental, meant for debugging, testing and internal use.
+ Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined.
+ You must be root to use these ioctls. Never use these in applications! */
+#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
+#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
+
+/* Experimental, meant for debugging, testing and internal use.
+ Never use this ioctl in applications! */
+#define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident)
+#endif
+
+#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
+#define VIDIOC_ENUM_DV_PRESETS _IOWR('V', 83, struct v4l2_dv_enum_preset)
+#define VIDIOC_S_DV_PRESET _IOWR('V', 84, struct v4l2_dv_preset)
+#define VIDIOC_G_DV_PRESET _IOWR('V', 85, struct v4l2_dv_preset)
+#define VIDIOC_QUERY_DV_PRESET _IOR('V', 86, struct v4l2_dv_preset)
+#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
+#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
+#define VIDIOC_DQEVENT _IOR('V', 89, struct v4l2_event)
+#define VIDIOC_SUBSCRIBE_EVENT _IOW('V', 90, struct v4l2_event_subscription)
+#define VIDIOC_UNSUBSCRIBE_EVENT _IOW('V', 91, struct v4l2_event_subscription)
+
+/* Reminder: when adding new ioctls please add support for them to
+ drivers/media/video/v4l2-compat-ioctl32.c as well! */
+
+#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
+
+#endif /* __LINUX_VIDEODEV2_H */
diff --git a/exynos4/hal/include/videodev2_samsung.h b/exynos4/hal/include/videodev2_samsung.h
new file mode 100644
index 0000000..41f8338
--- /dev/null
+++ b/exynos4/hal/include/videodev2_samsung.h
@@ -0,0 +1,1115 @@
+/*
+ * Video for Linux Two header file for samsung
+ *
+ * Copyright (C) 2009, Dongsoo Nathaniel Kim<dongsoo45.kim@samsung.com>
+ *
+ * This header file contains several v4l2 APIs to be proposed to v4l2
+ * community and until bein accepted, will be used restrictly in Samsung's
+ * camera interface driver FIMC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Alternatively, 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 __LINUX_VIDEODEV2_SAMSUNG_H
+#define __LINUX_VIDEODEV2_SAMSUNG_H
+
+/* Values for 'capabilities' field */
+/* Object detection device */
+#define V4L2_CAP_OBJ_RECOGNITION 0x10000000
+/* strobe control */
+#define V4L2_CAP_STROBE 0x20000000
+
+#define V4L2_CID_FOCUS_MODE (V4L2_CID_CAMERA_CLASS_BASE+17)
+/* Focus Methods */
+enum v4l2_focus_mode {
+ V4L2_FOCUS_MODE_AUTO = 0,
+ V4L2_FOCUS_MODE_MACRO = 1,
+ V4L2_FOCUS_MODE_MANUAL = 2,
+ V4L2_FOCUS_MODE_LASTP = 2,
+};
+
+#define V4L2_CID_ZOOM_MODE (V4L2_CID_CAMERA_CLASS_BASE+18)
+/* Zoom Methods */
+enum v4l2_zoom_mode {
+ V4L2_ZOOM_MODE_CONTINUOUS = 0,
+ V4L2_ZOOM_MODE_OPTICAL = 1,
+ V4L2_ZOOM_MODE_DIGITAL = 2,
+ V4L2_ZOOM_MODE_LASTP = 2,
+};
+
+/* Exposure Methods */
+#define V4L2_CID_PHOTOMETRY (V4L2_CID_CAMERA_CLASS_BASE+19)
+enum v4l2_photometry_mode {
+ V4L2_PHOTOMETRY_MULTISEG = 0, /*Multi Segment*/
+ V4L2_PHOTOMETRY_CWA = 1, /*Centre Weighted Average*/
+ V4L2_PHOTOMETRY_SPOT = 2,
+ V4L2_PHOTOMETRY_AFSPOT = 3, /*Spot metering on focused point*/
+ V4L2_PHOTOMETRY_LASTP = V4L2_PHOTOMETRY_AFSPOT,
+};
+
+/* Manual exposure control items menu type: iris, shutter, iso */
+#define V4L2_CID_CAM_APERTURE (V4L2_CID_CAMERA_CLASS_BASE+20)
+#define V4L2_CID_CAM_SHUTTER (V4L2_CID_CAMERA_CLASS_BASE+21)
+#define V4L2_CID_CAM_ISO (V4L2_CID_CAMERA_CLASS_BASE+22)
+
+/* Following CIDs are menu type */
+#define V4L2_CID_SCENEMODE (V4L2_CID_CAMERA_CLASS_BASE+23)
+#define V4L2_CID_CAM_STABILIZE (V4L2_CID_CAMERA_CLASS_BASE+24)
+#define V4L2_CID_CAM_MULTISHOT (V4L2_CID_CAMERA_CLASS_BASE+25)
+
+/* Control dynamic range */
+#define V4L2_CID_CAM_DR (V4L2_CID_CAMERA_CLASS_BASE+26)
+
+/* White balance preset control */
+#define V4L2_CID_WHITE_BALANCE_PRESET (V4L2_CID_CAMERA_CLASS_BASE+27)
+
+/* CID extensions */
+#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0)
+#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1)
+#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2)
+#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3)
+#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4)
+#define V4L2_CID_OVERLAY_AUTO (V4L2_CID_PRIVATE_BASE + 5)
+#define V4L2_CID_OVERLAY_VADDR0 (V4L2_CID_PRIVATE_BASE + 6)
+#define V4L2_CID_OVERLAY_VADDR1 (V4L2_CID_PRIVATE_BASE + 7)
+#define V4L2_CID_OVERLAY_VADDR2 (V4L2_CID_PRIVATE_BASE + 8)
+#define V4L2_CID_OVLY_MODE (V4L2_CID_PRIVATE_BASE + 9)
+#define V4L2_CID_DST_INFO (V4L2_CID_PRIVATE_BASE + 10)
+/* UMP secure id control */
+#define V4L2_CID_GET_UMP_SECURE_ID (V4L2_CID_PRIVATE_BASE + 11)
+#define V4L2_CID_IMAGE_EFFECT_FN (V4L2_CID_PRIVATE_BASE + 16)
+#define V4L2_CID_IMAGE_EFFECT_APPLY (V4L2_CID_PRIVATE_BASE + 17)
+#define V4L2_CID_IMAGE_EFFECT_CB (V4L2_CID_PRIVATE_BASE + 18)
+#define V4L2_CID_IMAGE_EFFECT_CR (V4L2_CID_PRIVATE_BASE + 19)
+#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20)
+#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21)
+
+#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53)
+
+/* CID Extensions for camera sensor operations */
+#define V4L2_CID_CAM_PREVIEW_ONOFF (V4L2_CID_PRIVATE_BASE + 64)
+#define V4L2_CID_CAM_CAPTURE (V4L2_CID_PRIVATE_BASE + 65)
+#define V4L2_CID_CAM_JPEG_MEMSIZE (V4L2_CID_PRIVATE_BASE + 66)
+
+#define V4L2_CID_CAM_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 14)
+#define V4L2_CID_CAM_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 15)
+#define V4L2_CID_CAM_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 22)
+#define V4L2_CID_CAM_SENSOR_VER (V4L2_CID_PRIVATE_BASE + 23)
+#define V4L2_CID_CAM_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 24)
+#define V4L2_CID_CAM_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 25)
+#define V4L2_CID_CAM_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 26)
+#define V4L2_CID_CAM_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 27)
+#define V4L2_CID_CAM_FW_VER (V4L2_CID_PRIVATE_BASE + 28)
+#define V4L2_CID_CAM_SET_FW_ADDR (V4L2_CID_PRIVATE_BASE + 29)
+#define V4L2_CID_CAM_SET_FW_SIZE (V4L2_CID_PRIVATE_BASE + 30)
+#define V4L2_CID_CAM_UPDATE_FW (V4L2_CID_PRIVATE_BASE + 31)
+#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32)
+#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33)
+#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34)
+#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35)
+#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36)
+#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37)
+#define V4L2_CID_CAM_SENSOR_MAKER (V4L2_CID_PRIVATE_BASE + 38)
+#define V4L2_CID_CAM_SENSOR_OPTICAL (V4L2_CID_PRIVATE_BASE + 39)
+#define V4L2_CID_CAM_AF_VER_LOW (V4L2_CID_PRIVATE_BASE + 40)
+#define V4L2_CID_CAM_AF_VER_HIGH (V4L2_CID_PRIVATE_BASE + 41)
+#define V4L2_CID_CAM_GAMMA_RG_LOW (V4L2_CID_PRIVATE_BASE + 42)
+#define V4L2_CID_CAM_GAMMA_RG_HIGH (V4L2_CID_PRIVATE_BASE + 43)
+#define V4L2_CID_CAM_GAMMA_BG_LOW (V4L2_CID_PRIVATE_BASE + 44)
+#define V4L2_CID_CAM_GAMMA_BG_HIGH (V4L2_CID_PRIVATE_BASE + 45)
+#define V4L2_CID_CAM_DUMP_FW (V4L2_CID_PRIVATE_BASE + 46)
+#define V4L2_CID_CAM_GET_DUMP_SIZE (V4L2_CID_PRIVATE_BASE + 47)
+#define V4L2_CID_CAMERA_VT_MODE (V4L2_CID_PRIVATE_BASE + 48)
+#define V4L2_CID_CAMERA_VGA_BLUR (V4L2_CID_PRIVATE_BASE + 49)
+#define V4L2_CID_CAMERA_CAPTURE (V4L2_CID_PRIVATE_BASE + 50)
+
+#define V4L2_CID_MAIN_SW_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 54)
+#define V4L2_CID_MAIN_SW_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 55)
+#define V4L2_CID_MAIN_SW_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 56)
+#define V4L2_CID_MAIN_SW_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 57)
+#define V4L2_CID_MAIN_SW_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 58)
+#define V4L2_CID_MAIN_SW_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 59)
+#define V4L2_CID_MAIN_SW_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 60)
+
+/* SLIM IS control */
+#define V4L2_CID_FIMC_IS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x1000)
+
+#define V4L2_CID_IS_LOAD_FW (V4L2_CID_FIMC_IS_BASE + 10)
+#define V4L2_CID_IS_INIT_PARAM (V4L2_CID_FIMC_IS_BASE + 11)
+#define V4L2_CID_IS_RESETi (V4L2_CID_FIMC_IS_BASE + 12)
+#define V4L2_CID_IS_S_POWER (V4L2_CID_FIMC_IS_BASE + 13)
+enum is_set_power {
+ IS_POWER_OFF,
+ IS_POWER_ON
+};
+
+#define V4L2_CID_IS_S_STREAM (V4L2_CID_FIMC_IS_BASE + 14)
+enum is_set_stream {
+ IS_DISABLE_STREAM,
+ IS_ENABLE_STREAM
+};
+
+#define V4L2_CID_IS_S_SCENARIO_MODE (V4L2_CID_FIMC_IS_BASE + 15)
+#define V4L2_CID_IS_S_FORMAT_SCENARIO (V4L2_CID_FIMC_IS_BASE + 16)
+enum scenario_mode {
+ IS_MODE_PREVIEW_STILL,
+ IS_MODE_PREVIEW_VIDEO,
+ IS_MODE_CAPTURE_STILL,
+ IS_MODE_CAPTURE_VIDEO,
+ IS_MODE_MAX
+};
+
+/* global */
+#define V4L2_CID_IS_CAMERA_SHOT_MODE_NORMAL (V4L2_CID_FIMC_IS_BASE + 101)
+/* value : 1 : single shot , >=2 : continuous shot */
+
+#define V4L2_CID_IS_CAMERA_SENSOR_NUM (V4L2_CID_FIMC_IS_BASE + 201)
+
+#define V4L2_CID_IS_CAMERA_FOCUS_MODE (V4L2_CID_FIMC_IS_BASE + 401)
+enum is_focus_mode {
+ IS_FOCUS_MODE_AUTO,
+ IS_FOCUS_MODE_MACRO,
+ IS_FOCUS_MODE_INFINITY,
+ IS_FOCUS_MODE_CONTINUOUS,
+ IS_FOCUS_MODE_TOUCH,
+ IS_FOCUS_MODE_FACEDETECT,
+ IS_FOCUS_MODE_MAX,
+};
+
+#define V4L2_CID_IS_CAMERA_FLASH_MODE (V4L2_CID_FIMC_IS_BASE + 402)
+enum is_flash_mode {
+ IS_FLASH_MODE_OFF,
+ IS_FLASH_MODE_AUTO,
+ IS_FLASH_MODE_AUTO_REDEYE,
+ IS_FLASH_MODE_ON,
+ IS_FLASH_MODE_TORCH,
+ IS_FLASH_MODE_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_AWB_MODE (V4L2_CID_FIMC_IS_BASE + 403)
+enum is_awb_mode {
+ IS_AWB_AUTO,
+ IS_AWB_DAYLIGHT,
+ IS_AWB_CLOUDY,
+ IS_AWB_TUNGSTEN,
+ IS_AWB_FLUORESCENT,
+ IS_AWB_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_IMAGE_EFFECT (V4L2_CID_FIMC_IS_BASE + 404)
+enum is_image_effect {
+ IS_IMAGE_EFFECT_DISABLE,
+ IS_IMAGE_EFFECT_MONOCHROME,
+ IS_IMAGE_EFFECT_NEGATIVE_MONO,
+ IS_IMAGE_EFFECT_NEGATIVE_COLOR,
+ IS_IMAGE_EFFECT_SEPIA,
+ IS_IMAGE_EFFECT_SEPIA_CB,
+ IS_IMAGE_EFFECT_SEPIA_CR,
+ IS_IMAGE_EFFECT_NEGATIVE,
+ IS_IMAGE_EFFECT_ARTFREEZE,
+ IS_IMAGE_EFFECT_EMBOSSING,
+ IS_IMAGE_EFFECT_SILHOUETTE,
+ IS_IMAGE_EFFECT_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_ISO (V4L2_CID_FIMC_IS_BASE + 405)
+enum is_iso {
+ IS_ISO_AUTO,
+ IS_ISO_50,
+ IS_ISO_100,
+ IS_ISO_200,
+ IS_ISO_400,
+ IS_ISO_800,
+ IS_ISO_1600,
+ IS_ISO_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_CONTRAST (V4L2_CID_FIMC_IS_BASE + 406)
+enum is_contrast {
+ IS_CONTRAST_AUTO,
+ IS_CONTRAST_MINUS_2,
+ IS_CONTRAST_MINUS_1,
+ IS_CONTRAST_DEFAULT,
+ IS_CONTRAST_PLUS_1,
+ IS_CONTRAST_PLUS_2,
+ IS_CONTRAST_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_SATURATION (V4L2_CID_FIMC_IS_BASE + 407)
+enum is_saturation {
+ IS_SATURATION_MINUS_2,
+ IS_SATURATION_MINUS_1,
+ IS_SATURATION_DEFAULT,
+ IS_SATURATION_PLUS_1,
+ IS_SATURATION_PLUS_2,
+ IS_SATURATION_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_SHARPNESS (V4L2_CID_FIMC_IS_BASE + 408)
+enum is_sharpness {
+ IS_SHARPNESS_MINUS_2,
+ IS_SHARPNESS_MINUS_1,
+ IS_SHARPNESS_DEFAULT,
+ IS_SHARPNESS_PLUS_1,
+ IS_SHARPNESS_PLUS_2,
+ IS_SHARPNESS_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_EXPOSURE (V4L2_CID_FIMC_IS_BASE + 409)
+enum is_exposure {
+ IS_EXPOSURE_MINUS_4,
+ IS_EXPOSURE_MINUS_3,
+ IS_EXPOSURE_MINUS_2,
+ IS_EXPOSURE_MINUS_1,
+ IS_EXPOSURE_DEFAULT,
+ IS_EXPOSURE_PLUS_1,
+ IS_EXPOSURE_PLUS_2,
+ IS_EXPOSURE_PLUS_3,
+ IS_EXPOSURE_PLUS_4,
+ IS_EXPOSURE_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_BRIGHTNESS (V4L2_CID_FIMC_IS_BASE + 410)
+enum is_brightness {
+ IS_BRIGHTNESS_MINUS_2,
+ IS_BRIGHTNESS_MINUS_1,
+ IS_BRIGHTNESS_DEFAULT,
+ IS_BRIGHTNESS_PLUS_1,
+ IS_BRIGHTNESS_PLUS_2,
+ IS_BRIGHTNESS_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_HUE (V4L2_CID_FIMC_IS_BASE + 411)
+enum is_hue {
+ IS_HUE_MINUS_2,
+ IS_HUE_MINUS_1,
+ IS_HUE_DEFAULT,
+ IS_HUE_PLUS_1,
+ IS_HUE_PLUS_2,
+ IS_HUE_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_METERING (V4L2_CID_FIMC_IS_BASE + 412)
+enum is_metering {
+ IS_METERING_CENTER,
+ IS_METERING_SPOT,
+ IS_METERING_MATRIX,
+ IS_METERING_MAX
+};
+#define V4L2_CID_IS_CAMERA_METERING_POSITION_X (V4L2_CID_FIMC_IS_BASE + 500)
+#define V4L2_CID_IS_CAMERA_METERING_POSITION_Y (V4L2_CID_FIMC_IS_BASE + 501)
+#define V4L2_CID_IS_CAMERA_METERING_WINDOW_X (V4L2_CID_FIMC_IS_BASE + 502)
+#define V4L2_CID_IS_CAMERA_METERING_WINDOW_Y (V4L2_CID_FIMC_IS_BASE + 503)
+
+#define V4L2_CID_IS_CAMERA_AFC_MODE (V4L2_CID_FIMC_IS_BASE + 413)
+enum is_afc_mode {
+ IS_AFC_DISABLE,
+ IS_AFC_AUTO,
+ IS_AFC_MANUAL_50HZ,
+ IS_AFC_MANUAL_60HZ,
+ IS_AFC_MAX
+};
+
+#define V4L2_CID_IS_FD_GET_FACE_COUNT (V4L2_CID_FIMC_IS_BASE + 600)
+#define V4L2_CID_IS_FD_GET_FACE_FRAME_NUMBER (V4L2_CID_FIMC_IS_BASE + 601)
+#define V4L2_CID_IS_FD_GET_FACE_CONFIDENCE (V4L2_CID_FIMC_IS_BASE + 602)
+#define V4L2_CID_IS_FD_GET_FACE_SMILE_LEVEL (V4L2_CID_FIMC_IS_BASE + 603)
+#define V4L2_CID_IS_FD_GET_FACE_BLINK_LEVEL (V4L2_CID_FIMC_IS_BASE + 604)
+#define V4L2_CID_IS_FD_GET_FACE_TOPLEFT_X (V4L2_CID_FIMC_IS_BASE + 605)
+#define V4L2_CID_IS_FD_GET_FACE_TOPLEFT_Y (V4L2_CID_FIMC_IS_BASE + 606)
+#define V4L2_CID_IS_FD_GET_FACE_BOTTOMRIGHT_X (V4L2_CID_FIMC_IS_BASE + 607)
+#define V4L2_CID_IS_FD_GET_FACE_BOTTOMRIGHT_Y (V4L2_CID_FIMC_IS_BASE + 608)
+#define V4L2_CID_IS_FD_GET_LEFT_EYE_TOPLEFT_X (V4L2_CID_FIMC_IS_BASE + 609)
+#define V4L2_CID_IS_FD_GET_LEFT_EYE_TOPLEFT_Y (V4L2_CID_FIMC_IS_BASE + 610)
+#define V4L2_CID_IS_FD_GET_LEFT_EYE_BOTTOMRIGHT_X (V4L2_CID_FIMC_IS_BASE + 611)
+#define V4L2_CID_IS_FD_GET_LEFT_EYE_BOTTOMRIGHT_Y (V4L2_CID_FIMC_IS_BASE + 612)
+#define V4L2_CID_IS_FD_GET_RIGHT_EYE_TOPLEFT_X (V4L2_CID_FIMC_IS_BASE + 613)
+#define V4L2_CID_IS_FD_GET_RIGHT_EYE_TOPLEFT_Y (V4L2_CID_FIMC_IS_BASE + 614)
+#define V4L2_CID_IS_FD_GET_RIGHT_EYE_BOTTOMRIGHT_X (V4L2_CID_FIMC_IS_BASE + 615)
+#define V4L2_CID_IS_FD_GET_RIGHT_EYE_BOTTOMRIGHT_Y (V4L2_CID_FIMC_IS_BASE + 616)
+#define V4L2_CID_IS_FD_GET_MOUTH_TOPLEFT_X (V4L2_CID_FIMC_IS_BASE + 617)
+#define V4L2_CID_IS_FD_GET_MOUTH_TOPLEFT_Y (V4L2_CID_FIMC_IS_BASE + 618)
+#define V4L2_CID_IS_FD_GET_MOUTH_BOTTOMRIGHT_X (V4L2_CID_FIMC_IS_BASE + 619)
+#define V4L2_CID_IS_FD_GET_MOUTH_BOTTOMRIGHT_Y (V4L2_CID_FIMC_IS_BASE + 620)
+#define V4L2_CID_IS_FD_GET_ANGLE (V4L2_CID_FIMC_IS_BASE + 621)
+#define V4L2_CID_IS_FD_GET_NEXT (V4L2_CID_FIMC_IS_BASE + 622)
+#define V4L2_CID_IS_FD_GET_DATA (V4L2_CID_FIMC_IS_BASE + 623)
+
+#define V4L2_CID_IS_FD_SET_MAX_FACE_NUMBER (V4L2_CID_FIMC_IS_BASE + 650)
+#define V4L2_CID_IS_FD_SET_ROLL_ANGLE (V4L2_CID_FIMC_IS_BASE + 651)
+enum is_fd_roll_angle {
+ /* 0, 45, 0, -45 */
+ IS_FD_ROLL_ANGLE_BASIC = 0,
+ /* 0, 30, 0, -30, 0, 45, 0, -45 */
+ IS_FD_ROLL_ANGLE_PRECISE_BASIC = 1,
+ /* 0, 90, 0, -90 */
+ IS_FD_ROLL_ANGLE_SIDES = 2,
+ /* 0, 90, 0, -90 0, 45, 0, -45 */
+ IS_FD_ROLL_ANGLE_PRECISE_SIDES = 3,
+ /* 0, 90, 0, -90, 0, 180 */
+ IS_FD_ROLL_ANGLE_FULL = 4,
+ /* 0, 90, 0, -90, 0, 180, 0, 135, 0, -135 */
+ IS_FD_ROLL_ANGLE_PRECISE_FULL = 5,
+};
+
+#define V4L2_CID_IS_FD_SET_YAW_ANGLE (V4L2_CID_FIMC_IS_BASE + 652)
+enum is_fd_yaw_angle {
+ IS_FD_YAW_ANGLE_0 = 0,
+ IS_FD_YAW_ANGLE_45 = 1,
+ IS_FD_YAW_ANGLE_90 = 2,
+ IS_FD_YAW_ANGLE_45_90 = 3,
+};
+
+#define V4L2_CID_IS_FD_SET_SMILE_MODE (V4L2_CID_FIMC_IS_BASE + 653)
+enum is_fd_smile_mode {
+ IS_FD_SMILE_MODE_DISABLE = 0,
+ IS_FD_SMILE_MODE_ENABLE = 1,
+};
+
+#define V4L2_CID_IS_FD_SET_BLINK_MODE (V4L2_CID_FIMC_IS_BASE + 654)
+enum is_fd_blink_mode {
+ IS_FD_BLINK_MODE_DISABLE = 0,
+ IS_FD_BLINK_MODE_ENABLE = 1,
+};
+
+#define V4L2_CID_IS_FD_SET_EYE_DETECT_MODE (V4L2_CID_FIMC_IS_BASE + 655)
+enum is_fd_eye_detect_mode {
+ IS_FD_EYE_DETECT_DISABLE = 0,
+ IS_FD_EYE_DETECT_ENABLE = 1,
+};
+
+#define V4L2_CID_IS_FD_SET_MOUTH_DETECT_MODE (V4L2_CID_FIMC_IS_BASE + 656)
+enum is_fd_mouth_detect_mode {
+ IS_FD_MOUTH_DETECT_DISABLE = 0,
+ IS_FD_MOUTH_DETECT_ENABLE = 1,
+};
+
+#define V4L2_CID_IS_FD_SET_ORIENTATION_MODE (V4L2_CID_FIMC_IS_BASE + 657)
+enum is_fd_orientation_mode {
+ IS_FD_ORIENTATION_DISABLE = 0,
+ IS_FD_ORIENTATION_ENABLE = 1,
+};
+
+#define V4L2_CID_IS_FD_SET_ORIENTATION (V4L2_CID_FIMC_IS_BASE + 658)
+#define V4L2_CID_IS_FD_SET_DATA_ADDRESS (V4L2_CID_FIMC_IS_BASE + 659)
+
+#define V4L2_CID_IS_SET_ISP (V4L2_CID_FIMC_IS_BASE + 440)
+enum is_isp_bypass_mode {
+ IS_ISP_BYPASS_DISABLE,
+ IS_ISP_BYPASS_ENABLE,
+ IS_ISP_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_DRC (V4L2_CID_FIMC_IS_BASE + 441)
+enum is_drc_bypass_mode {
+ IS_DRC_BYPASS_DISABLE,
+ IS_DRC_BYPASS_ENABLE,
+ IS_DRC_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_FD (V4L2_CID_FIMC_IS_BASE + 442)
+enum is_fd_bypass_mode {
+ IS_FD_BYPASS_DISABLE,
+ IS_FD_BYPASS_ENABLE,
+ IS_FD_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_ODC (V4L2_CID_FIMC_IS_BASE + 443)
+enum is_odc_bypass_mode {
+ IS_ODC_BYPASS_DISABLE,
+ IS_ODC_BYPASS_ENABLE,
+ IS_ODC_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_DIS (V4L2_CID_FIMC_IS_BASE + 444)
+enum is_dis_bypass_mode {
+ IS_DIS_BYPASS_DISABLE,
+ IS_DIS_BYPASS_ENABLE,
+ IS_DIS_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_3DNR (V4L2_CID_FIMC_IS_BASE + 445)
+enum is_tdnr_bypass_mode {
+ IS_TDNR_BYPASS_DISABLE,
+ IS_TDNR_BYPASS_ENABLE,
+ IS_TDNR_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_SCALERC (V4L2_CID_FIMC_IS_BASE + 446)
+enum is_scalerc_bypass_mode {
+ IS_SCALERC_BYPASS_DISABLE,
+ IS_SCALERC_BYPASS_ENABLE,
+ IS_SCALERC_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_SET_SCALERP (V4L2_CID_FIMC_IS_BASE + 446)
+enum is_scalerp_bypass_mode {
+ IS_SCALERP_BYPASS_DISABLE,
+ IS_SCALERP_BYPASS_ENABLE,
+ IS_SCALERP_BYPASS_MAX
+};
+
+#define V4L2_CID_IS_ROTATION_MODE (V4L2_CID_FIMC_IS_BASE + 450)
+enum is_rotation_mode {
+ IS_ROTATION_0,
+ IS_ROTATION_90,
+ IS_ROTATION_180,
+ IS_ROTATION_270,
+ IS_ROTATION_MAX
+};
+
+#define V4L2_CID_IS_3DNR_1ST_FRAME_MODE (V4L2_CID_FIMC_IS_BASE + 451)
+enum is_tdnr_1st_frame_mode {
+ IS_TDNR_1ST_FRAME_NOPROCESSING,
+ IS_TDNR_1ST_FRAME_2DNR,
+ IS_TDNR_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_OBJECT_POSITION_X (V4L2_CID_FIMC_IS_BASE + 452)
+#define V4L2_CID_IS_CAMERA_OBJECT_POSITION_Y (V4L2_CID_FIMC_IS_BASE + 453)
+#define V4L2_CID_IS_CAMERA_WINDOW_SIZE_X (V4L2_CID_FIMC_IS_BASE + 454)
+#define V4L2_CID_IS_CAMERA_WINDOW_SIZE_Y (V4L2_CID_FIMC_IS_BASE + 455)
+
+#define V4L2_CID_IS_CAMERA_EXIF_EXPTIME (V4L2_CID_FIMC_IS_BASE + 456)
+#define V4L2_CID_IS_CAMERA_EXIF_FLASH (V4L2_CID_FIMC_IS_BASE + 457)
+#define V4L2_CID_IS_CAMERA_EXIF_ISO (V4L2_CID_FIMC_IS_BASE + 458)
+#define V4L2_CID_IS_CAMERA_EXIF_SHUTTERSPEED (V4L2_CID_FIMC_IS_BASE + 459)
+#define V4L2_CID_IS_CAMERA_EXIF_BRIGHTNESS (V4L2_CID_FIMC_IS_BASE + 460)
+
+#define V4L2_CID_IS_CAMERA_ISP_SEL_INPUT (V4L2_CID_FIMC_IS_BASE + 461)
+enum is_isp_sel_input {
+ IS_ISP_INPUT_OTF,
+ IS_ISP_INPUT_DMA1,
+ IS_ISP_INPUT_DMA2,
+ IS_ISP_INPUT_DMA12,
+ IS_ISP_INPUT_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_ISP_SEL_OUTPUT (V4L2_CID_FIMC_IS_BASE + 462)
+enum is_isp_sel_output {
+ IS_ISP_OUTPUT_OTF,
+ IS_ISP_OUTPUT_DMA1,
+ IS_ISP_OUTPUT_DMA2,
+ IS_ISP_OUTPUT_DMA12,
+ IS_ISP_OUTPUT_OTF_DMA1,
+ IS_ISP_OUTPUT_OTF_DMA2,
+ IS_ISP_OUTPUT_OTF_DMA12,
+ IS_ISP_OUTPUT_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_DRC_SEL_INPUT (V4L2_CID_FIMC_IS_BASE + 463)
+enum is_drc_sel_input {
+ IS_DRC_INPUT_OTF,
+ IS_DRC_INPUT_DMA,
+ IS_DRC_INPUT_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_FD_SEL_INPUT (V4L2_CID_FIMC_IS_BASE + 464)
+enum is_fd_sel_input {
+ IS_FD_INPUT_OTF,
+ IS_FD_INPUT_DMA,
+ IS_FD_INPUT_MAX
+};
+
+#define V4L2_CID_IS_CAMERA_INIT_WIDTH (V4L2_CID_FIMC_IS_BASE + 465)
+#define V4L2_CID_IS_CAMERA_INIT_HEIGHT (V4L2_CID_FIMC_IS_BASE + 466)
+
+#define V4L2_CID_IS_CMD_ISP (V4L2_CID_FIMC_IS_BASE + 467)
+enum is_isp_cmd_mode {
+ IS_ISP_COMMAND_STOP,
+ IS_ISP_COMMAND_START,
+ IS_ISP_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_DRC (V4L2_CID_FIMC_IS_BASE + 468)
+enum is_drc_cmd_mode {
+ IS_DRC_COMMAND_STOP,
+ IS_DRC_COMMAND_START,
+ IS_DRC_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_FD (V4L2_CID_FIMC_IS_BASE + 469)
+enum is_fd_cmd_mode {
+ IS_FD_COMMAND_STOP,
+ IS_FD_COMMAND_START,
+ IS_FD_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_ODC (V4L2_CID_FIMC_IS_BASE + 470)
+enum is_odc_cmd_mode {
+ IS_ODC_COMMAND_STOP,
+ IS_ODC_COMMAND_START,
+ IS_ODC_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_DIS (V4L2_CID_FIMC_IS_BASE + 471)
+enum is_dis_cmd_mode {
+ IS_DIS_COMMAND_STOP,
+ IS_DIS_COMMAND_START,
+ IS_DIS_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_TDNR (V4L2_CID_FIMC_IS_BASE + 472)
+enum is_tdnr_cmd_mode {
+ IS_TDNR_COMMAND_STOP,
+ IS_TDNR_COMMAND_START,
+ IS_TDNR_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_SCALERC (V4L2_CID_FIMC_IS_BASE + 473)
+enum is_scalerc_cmd_mode {
+ IS_SCALERC_COMMAND_STOP,
+ IS_SCALERC_COMMAND_START,
+ IS_SCALERC_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_CMD_SCALERP (V4L2_CID_FIMC_IS_BASE + 474)
+enum is_scalerp_cmd_mode {
+ IS_SCALERP_COMMAND_STOP,
+ IS_SCALERP_COMMAND_START,
+ IS_SCALERP_COMMAND_MAX
+};
+
+#define V4L2_CID_IS_GET_SENSOR_OFFSET_X (V4L2_CID_FIMC_IS_BASE + 480)
+#define V4L2_CID_IS_GET_SENSOR_OFFSET_Y (V4L2_CID_FIMC_IS_BASE + 481)
+#define V4L2_CID_IS_GET_SENSOR_WIDTH (V4L2_CID_FIMC_IS_BASE + 482)
+#define V4L2_CID_IS_GET_SENSOR_HEIGHT (V4L2_CID_FIMC_IS_BASE + 483)
+
+#define V4L2_CID_IS_GET_FRAME_VALID (V4L2_CID_FIMC_IS_BASE + 484)
+#define V4L2_CID_IS_SET_FRAME_VALID (V4L2_CID_FIMC_IS_BASE + 485)
+#define V4L2_CID_IS_GET_FRAME_BADMARK (V4L2_CID_FIMC_IS_BASE + 486)
+#define V4L2_CID_IS_SET_FRAME_BADMARK (V4L2_CID_FIMC_IS_BASE + 487)
+#define V4L2_CID_IS_GET_FRAME_CAPTURED (V4L2_CID_FIMC_IS_BASE + 488)
+#define V4L2_CID_IS_SET_FRAME_CAPTURED (V4L2_CID_FIMC_IS_BASE + 489)
+#define V4L2_CID_IS_SET_FRAME_NUMBER (V4L2_CID_FIMC_IS_BASE + 490)
+#define V4L2_CID_IS_GET_FRAME_NUMBER (V4L2_CID_FIMC_IS_BASE + 491)
+#define V4L2_CID_IS_CLEAR_FRAME_NUMBER (V4L2_CID_FIMC_IS_BASE + 492)
+#define V4L2_CID_IS_GET_LOSTED_FRAME_NUMBER (V4L2_CID_FIMC_IS_BASE + 493)
+#define V4L2_CID_IS_ISP_DMA_BUFFER_NUM (V4L2_CID_FIMC_IS_BASE + 494)
+#define V4L2_CID_IS_ISP_DMA_BUFFER_ADDRESS (V4L2_CID_FIMC_IS_BASE + 495)
+
+#define V4L2_CID_IS_ZOOM_STATE (V4L2_CID_FIMC_IS_BASE + 660)
+#define V4L2_CID_IS_ZOOM_MAX_LEVEL (V4L2_CID_FIMC_IS_BASE + 661)
+#define V4L2_CID_IS_ZOOM (V4L2_CID_FIMC_IS_BASE + 662)
+#define V4L2_CID_IS_FW_DEBUG_REGION_ADDR (V4L2_CID_FIMC_IS_BASE + 663)
+
+enum v4l2_blur {
+ BLUR_LEVEL_0 = 0,
+ BLUR_LEVEL_1,
+ BLUR_LEVEL_2,
+ BLUR_LEVEL_3,
+ BLUR_LEVEL_MAX,
+};
+
+#if 1
+#define V4L2_CID_CAMERA_SCENE_MODE (V4L2_CID_PRIVATE_BASE+70)
+enum v4l2_scene_mode {
+ SCENE_MODE_BASE,
+ SCENE_MODE_NONE,
+ SCENE_MODE_PORTRAIT,
+ SCENE_MODE_NIGHTSHOT,
+ SCENE_MODE_BACK_LIGHT,
+ SCENE_MODE_LANDSCAPE,
+ SCENE_MODE_SPORTS,
+ SCENE_MODE_PARTY_INDOOR,
+ SCENE_MODE_BEACH_SNOW,
+ SCENE_MODE_SUNSET,
+ SCENE_MODE_DUST_DAWN,
+ SCENE_MODE_FALL_COLOR,
+ SCENE_MODE_FIREWORKS,
+ SCENE_MODE_TEXT,
+ SCENE_MODE_CANDLE_LIGHT,
+ SCENE_MODE_MAX,
+};
+
+#define V4L2_CID_CAMERA_FLASH_MODE (V4L2_CID_PRIVATE_BASE+71)
+enum v4l2_flash_mode {
+ FLASH_MODE_BASE,
+ FLASH_MODE_OFF,
+ FLASH_MODE_AUTO,
+ FLASH_MODE_ON,
+ FLASH_MODE_TORCH,
+ FLASH_MODE_MAX,
+};
+
+#define V4L2_CID_CAMERA_BRIGHTNESS (V4L2_CID_PRIVATE_BASE+72)
+enum v4l2_ev_mode {
+ EV_MINUS_4 = -4,
+ EV_MINUS_3 = -3,
+ EV_MINUS_2 = -2,
+ EV_MINUS_1 = -1,
+ EV_DEFAULT = 0,
+ EV_PLUS_1 = 1,
+ EV_PLUS_2 = 2,
+ EV_PLUS_3 = 3,
+ EV_PLUS_4 = 4,
+ EV_MAX,
+};
+
+#define V4L2_CID_CAMERA_WHITE_BALANCE (V4L2_CID_PRIVATE_BASE+73)
+enum v4l2_wb_mode {
+ WHITE_BALANCE_BASE = 0,
+ WHITE_BALANCE_AUTO,
+ WHITE_BALANCE_SUNNY,
+ WHITE_BALANCE_CLOUDY,
+ WHITE_BALANCE_TUNGSTEN,
+ WHITE_BALANCE_FLUORESCENT,
+ WHITE_BALANCE_MAX,
+};
+
+#define V4L2_CID_CAMERA_EFFECT (V4L2_CID_PRIVATE_BASE+74)
+enum v4l2_effect_mode {
+ IMAGE_EFFECT_BASE = 0,
+ IMAGE_EFFECT_NONE,
+ IMAGE_EFFECT_BNW,
+ IMAGE_EFFECT_SEPIA,
+ IMAGE_EFFECT_AQUA,
+ IMAGE_EFFECT_ANTIQUE,
+ IMAGE_EFFECT_NEGATIVE,
+ IMAGE_EFFECT_SHARPEN,
+ IMAGE_EFFECT_MAX,
+};
+
+#define V4L2_CID_CAMERA_ISO (V4L2_CID_PRIVATE_BASE+75)
+enum v4l2_iso_mode {
+ ISO_AUTO = 0,
+ ISO_50,
+ ISO_100,
+ ISO_200,
+ ISO_400,
+ ISO_800,
+ ISO_1600,
+ ISO_SPORTS,
+ ISO_NIGHT,
+ ISO_MOVIE,
+ ISO_MAX,
+};
+
+#define V4L2_CID_CAMERA_METERING (V4L2_CID_PRIVATE_BASE+76)
+enum v4l2_metering_mode {
+ METERING_BASE = 0,
+ METERING_MATRIX,
+ METERING_CENTER,
+ METERING_SPOT,
+ METERING_MAX,
+};
+
+#define V4L2_CID_CAMERA_CONTRAST (V4L2_CID_PRIVATE_BASE+77)
+enum v4l2_contrast_mode {
+ CONTRAST_MINUS_2 = 0,
+ CONTRAST_MINUS_1,
+ CONTRAST_DEFAULT,
+ CONTRAST_PLUS_1,
+ CONTRAST_PLUS_2,
+ CONTRAST_MAX,
+};
+
+#define V4L2_CID_CAMERA_SATURATION (V4L2_CID_PRIVATE_BASE+78)
+enum v4l2_saturation_mode {
+ SATURATION_MINUS_2 = 0,
+ SATURATION_MINUS_1,
+ SATURATION_DEFAULT,
+ SATURATION_PLUS_1,
+ SATURATION_PLUS_2,
+ SATURATION_MAX,
+};
+
+#define V4L2_CID_CAMERA_SHARPNESS (V4L2_CID_PRIVATE_BASE+79)
+enum v4l2_sharpness_mode {
+ SHARPNESS_MINUS_2 = 0,
+ SHARPNESS_MINUS_1,
+ SHARPNESS_DEFAULT,
+ SHARPNESS_PLUS_1,
+ SHARPNESS_PLUS_2,
+ SHARPNESS_MAX,
+};
+
+#define V4L2_CID_CAMERA_WDR (V4L2_CID_PRIVATE_BASE+80)
+enum v4l2_wdr_mode {
+ WDR_OFF,
+ WDR_ON,
+ WDR_MAX,
+};
+
+#define V4L2_CID_CAMERA_ANTI_SHAKE (V4L2_CID_PRIVATE_BASE+81)
+enum v4l2_anti_shake_mode {
+ ANTI_SHAKE_OFF,
+ ANTI_SHAKE_STILL_ON,
+ ANTI_SHAKE_MOVIE_ON,
+ ANTI_SHAKE_MAX,
+};
+
+#define V4L2_CID_CAMERA_TOUCH_AF_START_STOP (V4L2_CID_PRIVATE_BASE+82)
+enum v4l2_touch_af {
+ TOUCH_AF_STOP = 0,
+ TOUCH_AF_START,
+ TOUCH_AF_MAX,
+};
+
+#define V4L2_CID_CAMERA_SMART_AUTO (V4L2_CID_PRIVATE_BASE+83)
+enum v4l2_smart_auto {
+ SMART_AUTO_OFF = 0,
+ SMART_AUTO_ON,
+ SMART_AUTO_MAX,
+};
+
+#define V4L2_CID_CAMERA_VINTAGE_MODE (V4L2_CID_PRIVATE_BASE+84)
+enum v4l2_vintage_mode {
+ VINTAGE_MODE_BASE,
+ VINTAGE_MODE_OFF,
+ VINTAGE_MODE_NORMAL,
+ VINTAGE_MODE_WARM,
+ VINTAGE_MODE_COOL,
+ VINTAGE_MODE_BNW,
+ VINTAGE_MODE_MAX,
+};
+
+#define V4L2_CID_CAMERA_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE+85)
+#define V4L2_CID_CAMERA_GPS_LATITUDE (V4L2_CID_CAMERA_CLASS_BASE + 30)//(V4L2_CID_PRIVATE_BASE+86)
+#define V4L2_CID_CAMERA_GPS_LONGITUDE (V4L2_CID_CAMERA_CLASS_BASE + 31)//(V4L2_CID_PRIVATE_BASE+87)
+#define V4L2_CID_CAMERA_GPS_TIMESTAMP (V4L2_CID_CAMERA_CLASS_BASE + 32)//(V4L2_CID_PRIVATE_BASE+88)
+#define V4L2_CID_CAMERA_GPS_ALTITUDE (V4L2_CID_CAMERA_CLASS_BASE + 33)//(V4L2_CID_PRIVATE_BASE+89)
+#define V4L2_CID_CAMERA_EXIF_TIME_INFO (V4L2_CID_CAMERA_CLASS_BASE + 34)
+#define V4L2_CID_CAMERA_GPS_PROCESSINGMETHOD (V4L2_CID_CAMERA_CLASS_BASE+35)
+#define V4L2_CID_CAMERA_ZOOM (V4L2_CID_PRIVATE_BASE+90)
+enum v4l2_zoom_level {
+ ZOOM_LEVEL_0 = 0,
+ ZOOM_LEVEL_1,
+ ZOOM_LEVEL_2,
+ ZOOM_LEVEL_3,
+ ZOOM_LEVEL_4,
+ ZOOM_LEVEL_5,
+ ZOOM_LEVEL_6,
+ ZOOM_LEVEL_7,
+ ZOOM_LEVEL_8,
+ ZOOM_LEVEL_9,
+ ZOOM_LEVEL_10,
+ ZOOM_LEVEL_11,
+ ZOOM_LEVEL_12,
+ ZOOM_LEVEL_MAX = 31,
+};
+
+#define V4L2_CID_CAMERA_FACE_DETECTION (V4L2_CID_PRIVATE_BASE+91)
+enum v4l2_face_detection {
+ FACE_DETECTION_OFF = 0,
+ FACE_DETECTION_ON,
+ FACE_DETECTION_NOLINE,
+ FACE_DETECTION_ON_BEAUTY,
+ FACE_DETECTION_MAX,
+};
+
+#define V4L2_CID_CAMERA_SMART_AUTO_STATUS (V4L2_CID_PRIVATE_BASE+92)
+enum v4l2_smart_auto_status {
+ SMART_AUTO_STATUS_AUTO = 0,
+ SMART_AUTO_STATUS_LANDSCAPE,
+ SMART_AUTO_STATUS_PORTRAIT,
+ SMART_AUTO_STATUS_MACRO,
+ SMART_AUTO_STATUS_NIGHT,
+ SMART_AUTO_STATUS_PORTRAIT_NIGHT,
+ SMART_AUTO_STATUS_BACKLIT,
+ SMART_AUTO_STATUS_PORTRAIT_BACKLIT,
+ SMART_AUTO_STATUS_ANTISHAKE,
+ SMART_AUTO_STATUS_PORTRAIT_ANTISHAKE,
+ SMART_AUTO_STATUS_MAX,
+};
+
+#define V4L2_CID_CAMERA_SET_AUTO_FOCUS (V4L2_CID_PRIVATE_BASE+93)
+enum v4l2_auto_focus {
+ AUTO_FOCUS_OFF = 0,
+ AUTO_FOCUS_ON,
+ AUTO_FOCUS_MAX,
+};
+
+#define V4L2_CID_CAMERA_BEAUTY_SHOT (V4L2_CID_PRIVATE_BASE+94)
+enum v4l2_beauty_shot {
+ BEAUTY_SHOT_OFF = 0,
+ BEAUTY_SHOT_ON,
+ BEAUTY_SHOT_MAX,
+};
+
+#define V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK (V4L2_CID_PRIVATE_BASE+95)
+enum v4l2_ae_awb_lockunlock {
+ AE_UNLOCK_AWB_UNLOCK = 0,
+ AE_LOCK_AWB_UNLOCK,
+ AE_UNLOCK_AWB_LOCK,
+ AE_LOCK_AWB_LOCK,
+ AE_AWB_MAX
+};
+
+#define V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK (V4L2_CID_PRIVATE_BASE+96)
+enum v4l2_face_lock {
+ FACE_LOCK_OFF = 0,
+ FACE_LOCK_ON,
+ FIRST_FACE_TRACKING,
+ FACE_LOCK_MAX,
+};
+
+#define V4L2_CID_CAMERA_OBJECT_POSITION_X (V4L2_CID_PRIVATE_BASE+97)
+#define V4L2_CID_CAMERA_OBJECT_POSITION_Y (V4L2_CID_PRIVATE_BASE+98)
+#define V4L2_CID_CAMERA_FOCUS_MODE (V4L2_CID_PRIVATE_BASE+99)
+enum v4l2_focusmode {
+ FOCUS_MODE_AUTO = 0,
+ FOCUS_MODE_MACRO,
+ FOCUS_MODE_FACEDETECT,
+ FOCUS_MODE_INFINITY,
+ FOCUS_MODE_CONTINOUS,
+ FOCUS_MODE_TOUCH,
+ FOCUS_MODE_MAX,
+ FOCUS_MODE_DEFAULT = (1 << 8),
+};
+
+#define V4L2_CID_CAMERA_OBJ_TRACKING_STATUS (V4L2_CID_PRIVATE_BASE+100)
+enum v4l2_obj_tracking_status {
+ OBJECT_TRACKING_STATUS_BASE,
+ OBJECT_TRACKING_STATUS_PROGRESSING,
+ OBJECT_TRACKING_STATUS_SUCCESS,
+ OBJECT_TRACKING_STATUS_FAIL,
+ OBJECT_TRACKING_STATUS_MISSING,
+ OBJECT_TRACKING_STATUS_MAX,
+};
+
+#define V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP (V4L2_CID_PRIVATE_BASE+101)
+enum v4l2_ot_start_stop {
+ OT_STOP = 0,
+ OT_START,
+ OT_MAX,
+};
+
+#define V4L2_CID_CAMERA_CAF_START_STOP (V4L2_CID_PRIVATE_BASE+102)
+enum v4l2_caf_start_stop {
+ CAF_STOP = 0,
+ CAF_START,
+ CAF_MAX,
+};
+
+#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT (V4L2_CID_PRIVATE_BASE+103)
+#define V4L2_CID_CAMERA_FRAME_RATE (V4L2_CID_PRIVATE_BASE+104)
+enum v4l2_frame_rate {
+ FRAME_RATE_AUTO = 0,
+ FRAME_RATE_7 = 7,
+ FRAME_RATE_15 = 15,
+ FRAME_RATE_30 = 30,
+ FRAME_RATE_60 = 60,
+ FRAME_RATE_120 = 120,
+ FRAME_RATE_MAX
+};
+
+#define V4L2_CID_CAMERA_ANTI_BANDING (V4L2_CID_PRIVATE_BASE+105)
+enum v4l2_anti_banding {
+ ANTI_BANDING_AUTO = 0,
+ ANTI_BANDING_50HZ = 1,
+ ANTI_BANDING_60HZ = 2,
+ ANTI_BANDING_OFF = 3,
+};
+
+#define V4L2_CID_CAMERA_SET_GAMMA (V4L2_CID_PRIVATE_BASE+106)
+enum v4l2_gamma_mode {
+ GAMMA_OFF = 0,
+ GAMMA_ON = 1,
+ GAMMA_MAX,
+};
+
+#define V4L2_CID_CAMERA_SET_SLOW_AE (V4L2_CID_PRIVATE_BASE+107)
+enum v4l2_slow_ae_mode {
+ SLOW_AE_OFF,
+ SLOW_AE_ON,
+ SLOW_AE_MAX,
+};
+
+#define V4L2_CID_CAMERA_BATCH_REFLECTION (V4L2_CID_PRIVATE_BASE+108)
+#define V4L2_CID_CAMERA_EXIF_ORIENTATION (V4L2_CID_PRIVATE_BASE+109)
+
+#define V4L2_CID_CAMERA_RESET (V4L2_CID_PRIVATE_BASE+111) //s1_camera [ Defense process by ESD input ]
+#define V4L2_CID_CAMERA_CHECK_DATALINE (V4L2_CID_PRIVATE_BASE+112)
+#define V4L2_CID_CAMERA_CHECK_DATALINE_STOP (V4L2_CID_PRIVATE_BASE+113)
+
+#endif
+
+#if defined(CONFIG_ARIES_NTT) // Modify NTTS1
+#define V4L2_CID_CAMERA_AE_AWB_DISABLE_LOCK (V4L2_CID_PRIVATE_BASE+114)
+#endif
+#define V4L2_CID_CAMERA_THUMBNAIL_NULL (V4L2_CID_PRIVATE_BASE+115)
+#define V4L2_CID_CAMERA_SENSOR_MODE (V4L2_CID_PRIVATE_BASE+116)
+
+#define V4L2_CID_CAMERA_EXIF_EXPTIME (V4L2_CID_PRIVATE_BASE+117)
+#define V4L2_CID_CAMERA_EXIF_FLASH (V4L2_CID_PRIVATE_BASE+118)
+#define V4L2_CID_CAMERA_EXIF_ISO (V4L2_CID_PRIVATE_BASE+119)
+#define V4L2_CID_CAMERA_EXIF_TV (V4L2_CID_PRIVATE_BASE+120)
+#define V4L2_CID_CAMERA_EXIF_BV (V4L2_CID_PRIVATE_BASE+121)
+#define V4L2_CID_CAMERA_EXIF_EBV (V4L2_CID_PRIVATE_BASE+122)
+
+#define V4L2_CID_CAMERA_BUSFREQ_LOCK (V4L2_CID_PRIVATE_BASE+125)
+#define V4L2_CID_CAMERA_BUSFREQ_UNLOCK (V4L2_CID_PRIVATE_BASE+126)
+
+/* Pixel format FOURCC depth Description */
+/* 12 Y/CbCr 4:2:0 64x32 macroblocks */
+#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2')
+
+/*
+ * * V4L2 extention for digital camera
+ * */
+/* Strobe flash light */
+enum v4l2_strobe_control {
+ /* turn off the flash light */
+ V4L2_STROBE_CONTROL_OFF = 0,
+ /* turn on the flash light */
+ V4L2_STROBE_CONTROL_ON = 1,
+ /* act guide light before splash */
+ V4L2_STROBE_CONTROL_AFGUIDE = 2,
+ /* charge the flash light */
+ V4L2_STROBE_CONTROL_CHARGE = 3,
+};
+
+enum v4l2_strobe_conf {
+ V4L2_STROBE_OFF = 0, /* Always off */
+ V4L2_STROBE_ON = 1, /* Always splashes */
+ /* Auto control presets */
+ V4L2_STROBE_AUTO = 2,
+ V4L2_STROBE_REDEYE_REDUCTION = 3,
+ V4L2_STROBE_SLOW_SYNC = 4,
+ V4L2_STROBE_FRONT_CURTAIN = 5,
+ V4L2_STROBE_REAR_CURTAIN = 6,
+ /* Extra manual control presets */
+ /* keep turned on until turning off */
+ V4L2_STROBE_PERMANENT = 7,
+ V4L2_STROBE_EXTERNAL = 8,
+};
+
+enum v4l2_strobe_status {
+ V4L2_STROBE_STATUS_OFF = 0,
+ /* while processing configurations */
+ V4L2_STROBE_STATUS_BUSY = 1,
+ V4L2_STROBE_STATUS_ERR = 2,
+ V4L2_STROBE_STATUS_CHARGING = 3,
+ V4L2_STROBE_STATUS_CHARGED = 4,
+};
+
+/* capabilities field */
+/* No strobe supported */
+#define V4L2_STROBE_CAP_NONE 0x0000
+/* Always flash off mode */
+#define V4L2_STROBE_CAP_OFF 0x0001
+/* Always use flash light mode */
+#define V4L2_STROBE_CAP_ON 0x0002
+/* Flashlight works automatic */
+#define V4L2_STROBE_CAP_AUTO 0x0004
+/* Red-eye reduction */
+#define V4L2_STROBE_CAP_REDEYE 0x0008
+/* Slow sync */
+#define V4L2_STROBE_CAP_SLOWSYNC 0x0010
+/* Front curtain */
+#define V4L2_STROBE_CAP_FRONT_CURTAIN 0x0020
+/* Rear curtain */
+#define V4L2_STROBE_CAP_REAR_CURTAIN 0x0040
+/* keep turned on until turning off */
+#define V4L2_STROBE_CAP_PERMANENT 0x0080
+/* use external strobe */
+#define V4L2_STROBE_CAP_EXTERNAL 0x0100
+
+/* Set mode and Get status */
+struct v4l2_strobe {
+ /* off/on/charge:0/1/2 */
+ enum v4l2_strobe_control control;
+ /* supported strobe capabilities */
+ __u32 capabilities;
+ enum v4l2_strobe_conf mode;
+ enum v4l2_strobe_status status; /* read only */
+ /* default is 0 and range of value varies from each models */
+ __u32 flash_ev;
+ __u32 reserved[4];
+};
+
+#define VIDIOC_S_STROBE _IOWR('V', 83, struct v4l2_strobe)
+#define VIDIOC_G_STROBE _IOR('V', 84, struct v4l2_strobe)
+
+/* Object recognition and collateral actions */
+enum v4l2_recog_mode {
+ V4L2_RECOGNITION_MODE_OFF = 0,
+ V4L2_RECOGNITION_MODE_ON = 1,
+ V4L2_RECOGNITION_MODE_LOCK = 2,
+};
+
+enum v4l2_recog_action {
+ V4L2_RECOGNITION_ACTION_NONE = 0, /* only recognition */
+ V4L2_RECOGNITION_ACTION_BLINK = 1, /* Capture on blinking */
+ V4L2_RECOGNITION_ACTION_SMILE = 2, /* Capture on smiling */
+};
+
+enum v4l2_recog_pattern {
+ V4L2_RECOG_PATTERN_FACE = 0, /* Face */
+ V4L2_RECOG_PATTERN_HUMAN = 1, /* Human */
+ V4L2_RECOG_PATTERN_CHAR = 2, /* Character */
+};
+
+struct v4l2_recog_rect {
+ enum v4l2_recog_pattern p; /* detected pattern */
+ struct v4l2_rect o; /* detected area */
+ __u32 reserved[4];
+};
+
+struct v4l2_recog_data {
+ __u8 detect_cnt; /* detected object counter */
+ struct v4l2_rect o; /* detected area */
+ __u32 reserved[4];
+};
+
+struct v4l2_recognition {
+ enum v4l2_recog_mode mode;
+
+ /* Which pattern to detect */
+ enum v4l2_recog_pattern pattern;
+
+ /* How many object to detect */
+ __u8 obj_num;
+
+ /* select detected object */
+ __u32 detect_idx;
+
+ /* read only :Get object coordination */
+ struct v4l2_recog_data data;
+
+ enum v4l2_recog_action action;
+ __u32 reserved[4];
+};
+
+#define VIDIOC_S_RECOGNITION _IOWR('V', 85, struct v4l2_recognition)
+#define VIDIOC_G_RECOGNITION _IOR('V', 86, struct v4l2_recognition)
+
+/* We use this struct as the v4l2_streamparm raw_data for
+ * VIDIOC_G_PARM and VIDIOC_S_PARM
+ */
+struct sec_cam_parm {
+ struct v4l2_captureparm capture;
+ int contrast;
+ int effects;
+ int brightness;
+ int exposure;
+ int flash_mode;
+ int focus_mode;
+ int aeawb_mode;
+ int iso;
+ int metering;
+ int saturation;
+ int scene_mode;
+ int sharpness;
+ int hue;
+ int white_balance;
+ int anti_banding;
+};
+
+#endif /* __LINUX_VIDEODEV2_SAMSUNG_H */
diff --git a/exynos4/hal/libfimg/Android.mk b/exynos4/hal/libfimg/Android.mk
new file mode 100644
index 0000000..0d607e2
--- /dev/null
+++ b/exynos4/hal/libfimg/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES += \
+ $(BOARD_HAL_PATH)/include \
+
+LOCAL_SRC_FILES := \
+ FimgApi.cpp \
+ FimgC210.cpp
+
+LOCAL_SHARED_LIBRARIES:= liblog libutils libbinder
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := libfimg
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos4/hal/libfimg/FimgApi.cpp b/exynos4/hal/libfimg/FimgApi.cpp
new file mode 100644
index 0000000..b4c5890
--- /dev/null
+++ b/exynos4/hal/libfimg/FimgApi.cpp
@@ -0,0 +1,245 @@
+/*
+**
+** Copyright 2009 Samsung Electronics Co, Ltd.
+**
+** 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
+///////////////////////////////////////////////////
+#define LOG_NDEBUG 0
+#define LOG_TAG "FimgApi"
+#include <utils/Log.h>
+
+#include "FimgApi.h"
+
+//---------------------------------------------------------------------------//
+// Global Function
+//---------------------------------------------------------------------------//
+#ifndef REAL_DEBUG
+ void VOID_FUNC(const char* format, ...)
+ {}
+#endif
+
+//---------------------------------------------------------------------------//
+// FimgApi
+//---------------------------------------------------------------------------//
+
+//---------------------------------------------------------------------------//
+// Method Function Implementation
+//---------------------------------------------------------------------------//
+
+FimgApi::FimgApi()
+{
+ m_flagCreate = false;
+}
+
+FimgApi::~FimgApi()
+{
+ if(m_flagCreate == true)
+ PRINT("%s::this is not Destroyed fail \n", __func__);
+}
+
+bool FimgApi::Create(void)
+{
+ bool ret = false;
+
+ if(t_Lock() == false) {
+ PRINT("%s::t_Lock() fail \n", __func__);
+ goto CREATE_DONE;
+ }
+
+ if(m_flagCreate == true) {
+ PRINT("%s::Already Created fail \n", __func__);
+ goto CREATE_DONE;
+ }
+
+ if(t_Create() == false) {
+ PRINT("%s::t_Create() fail \n", __func__);
+ goto CREATE_DONE;
+ }
+
+ m_flagCreate = true;
+
+ ret = true;
+
+CREATE_DONE :
+
+ t_UnLock();
+
+ return ret;
+}
+
+bool FimgApi::Destroy(void)
+{
+ bool ret = false;
+
+ if(t_Lock() == false) {
+ PRINT("%s::t_Lock() fail \n", __func__);
+ goto DESTROY_DONE;
+ }
+
+ if(m_flagCreate == false) {
+ PRINT("%s::Already Destroyed fail \n", __func__);
+ goto DESTROY_DONE;
+ }
+
+ if(t_Destroy() == false) {
+ PRINT("%s::t_Destroy() fail \n", __func__);
+ goto DESTROY_DONE;
+ }
+
+ m_flagCreate = false;
+
+ ret = true;
+
+DESTROY_DONE :
+
+ t_UnLock();
+
+ return ret;
+}
+
+bool FimgApi::Stretch(FimgRect * src, FimgRect * dst, FimgClip *clip, FimgFlag * flag)
+{
+ bool ret = false;
+
+ if(t_Lock() == false) {
+ PRINT("%s::t_Lock() fail \n", __func__);
+ goto STRETCH_DONE;
+ }
+
+ if(m_flagCreate == false) {
+ PRINT("%s::This is not Created fail \n", __func__);
+ goto STRETCH_DONE;
+ }
+
+ if(t_Stretch(src, dst, clip, flag) == false) {
+ goto STRETCH_DONE;
+ }
+
+ ret = true;
+
+STRETCH_DONE :
+
+ t_UnLock();
+
+ return ret;
+}
+
+bool FimgApi::Sync(void)
+{
+ bool ret = false;
+
+ if(m_flagCreate == false) {
+ PRINT("%s::This is not Created fail \n", __func__);
+ goto SYNC_DONE;
+ }
+
+ if(t_Sync() == false) {
+ goto SYNC_DONE;
+ }
+
+ ret = true;
+
+SYNC_DONE :
+
+ return ret;
+}
+
+bool FimgApi::t_Create(void)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+bool FimgApi::t_Destroy(void)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+bool FimgApi::t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+bool FimgApi::t_Sync(void)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+bool FimgApi::t_Lock(void)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+bool FimgApi::t_UnLock(void)
+{
+ PRINT("%s::This is empty virtual function fail\n", __func__);
+ return false;
+}
+
+
+//---------------------------------------------------------------------------//
+// extern function
+//---------------------------------------------------------------------------//
+extern "C" int stretchFimgApi(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
+{
+ FimgApi * fimgApi = createFimgApi();
+
+ if(fimgApi == NULL) {
+ PRINT("%s::createFimgApi() fail \n", __func__);
+ return -1;
+ }
+
+ if(fimgApi->Stretch(src, dst, clip, flag) == false) {
+ if(fimgApi != NULL)
+ destroyFimgApi(fimgApi);
+
+ return -1;
+ }
+
+ if(fimgApi != NULL)
+ destroyFimgApi(fimgApi);
+
+ return 0;
+}
+
+extern "C" int SyncFimgApi(void)
+{
+ FimgApi * fimgApi = createFimgApi();
+ if(fimgApi == NULL) {
+ PRINT("%s::createFimgApi() fail \n", __func__);
+ return -1;
+ }
+
+ if(fimgApi->Sync() == false) {
+ if(fimgApi != NULL)
+ destroyFimgApi(fimgApi);
+
+ return -1;
+ }
+
+ if(fimgApi != NULL)
+ destroyFimgApi(fimgApi);
+
+ return 0;
+}
+
diff --git a/exynos4/hal/libfimg/FimgApi.h b/exynos4/hal/libfimg/FimgApi.h
new file mode 100644
index 0000000..3daac3d
--- /dev/null
+++ b/exynos4/hal/libfimg/FimgApi.h
@@ -0,0 +1,186 @@
+/*
+**
+** Copyright 2009 Samsung Electronics Co, Ltd.
+** Copyright 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.
+**
+**
+*/
+
+#ifndef FIMG_API_H
+#define FIMG_API_H
+
+#include <utils/Log.h>
+
+#include "../include/sec_g2d.h"
+//#include <sec_g2d.h>
+#define REAL_DEBUG
+#define ANDROID_LOG
+
+#if defined(REAL_DEBUG)
+#ifdef ANDROID_LOG
+ #define PRINT LOGE
+ #define PRINTD LOGD
+#else
+ #define PRINT printf
+ #define PRINTD printf
+#endif
+#else
+ void VOID_FUNC(const char* format, ...);
+
+ #define PRINT VOID_FUNC
+ #define PRINTD VOID_FUNC
+#endif
+
+typedef g2d_rect FimgRect;
+typedef g2d_flag FimgFlag;
+typedef g2d_clip FimgClip;
+
+#ifdef __cplusplus
+class FimgApi
+{
+public:
+#endif
+ enum COLOR_FORMAT {
+ COLOR_FORMAT_BASE = 0,
+
+ COLOR_FORMAT_RGB_565 = G2D_RGB_565,
+
+ COLOR_FORMAT_RGBA_8888 = G2D_RGBA_8888,
+ COLOR_FORMAT_ARGB_8888 = G2D_ARGB_8888,
+ COLOR_FORMAT_BGRA_8888 = G2D_BGRA_8888,
+ COLOR_FORMAT_ABGR_8888 = G2D_ABGR_8888,
+
+ COLOR_FORMAT_RGBX_8888 = G2D_RGBX_8888,
+ COLOR_FORMAT_XRGB_8888 = G2D_XRGB_8888,
+ COLOR_FORMAT_BGRX_8888 = G2D_BGRX_8888,
+ COLOR_FORMAT_XBGR_8888 = G2D_XBGR_8888,
+
+ COLOR_FORMAT_RGBA_5551 = G2D_RGBA_5551,
+ COLOR_FORMAT_ARGB_1555 = G2D_ARGB_1555,
+ COLOR_FORMAT_BGRA_5551 = G2D_BGRA_5551,
+ COLOR_FORMAT_ABGR_1555 = G2D_ABGR_1555,
+
+ COLOR_FORMAT_RGBX_5551 = G2D_RGBX_5551,
+ COLOR_FORMAT_XRGB_1555 = G2D_XRGB_1555,
+ COLOR_FORMAT_BGRX_5551 = G2D_BGRX_5551,
+ COLOR_FORMAT_XBGR_1555 = G2D_XBGR_1555,
+
+ COLOR_FORMAT_RGBA_4444 = G2D_RGBA_4444,
+ COLOR_FORMAT_ARGB_4444 = G2D_ARGB_4444,
+ COLOR_FORMAT_BGRA_4444 = G2D_BGRA_4444,
+ COLOR_FORMAT_ABGR_4444 = G2D_ABGR_4444,
+
+ COLOR_FORMAT_RGBX_4444 = G2D_RGBX_4444,
+ COLOR_FORMAT_XRGB_4444 = G2D_XRGB_4444,
+ COLOR_FORMAT_BGRX_4444 = G2D_BGRX_4444,
+ COLOR_FORMAT_XBGR_4444 = G2D_XBGR_4444,
+
+ COLOR_FORMAT_PACKED_RGB_888 = G2D_PACKED_RGB_888,
+ COLOR_FORMAT_PACKED_BGR_888 = G2D_PACKED_BGR_888,
+ COLOR_FORMAT_YUV_420SP,
+ COLOR_FORMAT_YUV_420P,
+ COLOR_FORMAT_YUV_420I,
+ COLOR_FORMAT_YUV_422SP,
+ COLOR_FORMAT_YUV_422P,
+ COLOR_FORMAT_YUV_422I,
+ COLOR_FORMAT_YUYV,
+
+ COLOR_FORMAT_MAX,
+ };
+
+ enum ROTATE {
+ ROTATE_BASE = 0,
+ ROTATE_0 = G2D_ROT_0,
+ ROTATE_90 = G2D_ROT_90,
+ ROTATE_180 = G2D_ROT_180,
+ ROTATE_270 = G2D_ROT_270,
+ ROTATE_X_FLIP = G2D_ROT_X_FLIP,
+ ROTATE_Y_FLIP = G2D_ROT_Y_FLIP,
+ ROTATE_MAX,
+ };
+
+ enum ALPHA_VALUE {
+ ALPHA_MIN = G2D_ALPHA_BLENDING_MIN, // wholly transparent
+ ALPHA_MAX = G2D_ALPHA_BLENDING_MAX, // 255
+ ALPHA_OPAQUE = G2D_ALPHA_BLENDING_OPAQUE, // opaque
+ };
+
+ enum DITHER {
+ DITHER_BASE = 0,
+ DITHER_OFF = 0,
+ DITHER_ON = 1,
+ DITHER_MAX,
+ };
+#ifdef __cplusplus
+private :
+ bool m_flagCreate;
+
+protected :
+ FimgApi();
+ FimgApi(const FimgApi& rhs) {}
+ virtual ~FimgApi();
+
+public:
+ bool Create(void);
+ bool Destroy(void);
+ inline bool FlagCreate(void) { return m_flagCreate; }
+ bool Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag);
+ bool Sync(void);
+
+protected:
+ virtual bool t_Create(void);
+ virtual bool t_Destroy(void);
+ virtual bool t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag);
+ virtual bool t_Sync(void);
+ virtual bool t_Lock(void);
+ virtual bool t_UnLock(void);
+
+};
+#endif
+
+/*---------------------------------------------------------------------------
+ * user api extern function
+ *---------------------------------------------------------------------------
+ * usage 1
+ * FimgApi * p = createFimgApi();
+ * p->Stretch()
+ * destroyFimgApi(p);
+ *
+ * usage 2
+ * stretchFimgApi(src, dst, clip, flag);
+ *-------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+#endif
+struct FimgApi * createFimgApi();
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void destroyFimgApi(FimgApi * ptrFimgApi);
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int stretchFimgApi(FimgRect * src,
+ FimgRect * dst,
+ FimgClip * clip,
+ FimgFlag * flag);
+#ifdef __cplusplus
+extern "C"
+#endif
+int SyncFimgApi(void);
+
+#endif //FIMG_API_H
diff --git a/exynos4/hal/libfimg/FimgC210.cpp b/exynos4/hal/libfimg/FimgC210.cpp
new file mode 100644
index 0000000..129acae
--- /dev/null
+++ b/exynos4/hal/libfimg/FimgC210.cpp
@@ -0,0 +1,478 @@
+/*
+**
+** Copyright 2009 Samsung Electronics Co, Ltd.
+**
+** 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
+///////////////////////////////////////////////////
+#define LOG_NDEBUG 0
+#define LOG_TAG "FimgC210"
+#include <utils/Log.h>
+
+#include "FimgC210.h"
+
+namespace android
+{
+
+//---------------------------------------------------------------------------//
+// FimgC210
+//---------------------------------------------------------------------------//
+
+Mutex FimgC210::m_instanceLock;
+int FimgC210::m_curFimgC210Index = 0;
+int FimgC210::m_numOfInstance = 0;
+FimgApi * FimgC210::m_ptrFimgApiList[NUMBER_FIMG_LIST] = {NULL, };
+
+//---------------------------------------------------------------------------//
+
+FimgC210::FimgC210()
+ : m_g2dFd(0),
+ m_g2dVirtAddr(NULL),
+ m_g2dSize(0),
+ m_g2dSrcVirtAddr(NULL),
+ m_g2dSrcSize(0),
+ m_g2dDstVirtAddr(NULL),
+ m_g2dDstSize(0)
+{
+ m_lock = new Mutex(Mutex::SHARED, "FimgC210");
+}
+
+FimgC210::~FimgC210()
+{
+ delete m_lock;
+}
+
+FimgApi * FimgC210::CreateInstance()
+{
+ Mutex::Autolock autolock(m_instanceLock);
+
+ FimgApi * ptrFimg = NULL;
+
+ // Using List like RingBuffer...
+ for(int i = m_curFimgC210Index; i < NUMBER_FIMG_LIST; i++) {
+ if(m_ptrFimgApiList[i] == NULL)
+ m_ptrFimgApiList[i] = new FimgC210;
+
+ if(m_ptrFimgApiList[i]->FlagCreate() == false) {
+ if(m_ptrFimgApiList[i]->Create() == false) {
+ PRINT("%s::Create(%d) fail\n", __func__, i);
+ goto CreateInstance_End;
+ }
+ else
+ m_numOfInstance++;
+ }
+
+ if(i < NUMBER_FIMG_LIST - 1)
+ m_curFimgC210Index = i + 1;
+ else
+ m_curFimgC210Index = 0;
+
+ ptrFimg = m_ptrFimgApiList[i];
+ goto CreateInstance_End;
+ }
+
+CreateInstance_End :
+
+ return ptrFimg;
+}
+
+void FimgC210::DestroyInstance(FimgApi * ptrFimgApi)
+{
+ Mutex::Autolock autolock(m_instanceLock);
+
+ for(int i = 0; i < NUMBER_FIMG_LIST; i++) {
+ if(m_ptrFimgApiList[i] != NULL
+ && m_ptrFimgApiList[i] == ptrFimgApi) {
+ if(m_ptrFimgApiList[i]->FlagCreate() == true
+ && m_ptrFimgApiList[i]->Destroy() == false) {
+ PRINT("%s::Destroy() fail\n", __func__);
+ } else {
+ FimgC210 * tempFimgC210 = (FimgC210 *)m_ptrFimgApiList[i];
+ delete tempFimgC210;
+ m_ptrFimgApiList[i] = NULL;
+
+ m_numOfInstance--;
+ }
+
+ break;
+ }
+ }
+}
+
+void FimgC210::DestroyAllInstance(void)
+{
+ Mutex::Autolock autolock(m_instanceLock);
+
+ for(int i = 0; i < NUMBER_FIMG_LIST; i++) {
+ if(m_ptrFimgApiList[i] != NULL) {
+ if(m_ptrFimgApiList[i]->FlagCreate() == true
+ && m_ptrFimgApiList[i]->Destroy() == false) {
+ PRINT("%s::Destroy() fail\n", __func__);
+ } else {
+ FimgC210 * tempFimgC210 = (FimgC210 *)m_ptrFimgApiList[i];
+ delete tempFimgC210;
+ m_ptrFimgApiList[i] = NULL;
+ }
+ }
+ }
+}
+
+
+bool FimgC210::t_Create(void)
+{
+ bool ret = true;
+
+ if(m_CreateG2D() == false) {
+ PRINT("%s::m_CreateG2D() fail \n", __func__);
+
+ if(m_DestroyG2D() == false)
+ PRINT("%s::m_DestroyG2D() fail \n", __func__);
+
+ ret = false;
+ }
+
+ return ret;
+}
+
+bool FimgC210::t_Destroy(void)
+{
+ bool ret = true;
+
+ if(m_DestroyG2D() == false) {
+ PRINT("%s::m_DestroyG2D() fail \n", __func__);
+ ret = false;
+ }
+
+ return ret;
+}
+
+bool FimgC210::t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
+{
+ #ifdef CHECK_FIMGC210_PERFORMANCE
+ #define NUM_OF_STEP (10)
+ StopWatch stopWatch("CHECK_FIMGC210_PERFORMANCE");
+ const char * stopWatchName[NUM_OF_STEP];
+ nsecs_t stopWatchTime[NUM_OF_STEP];
+ int stopWatchIndex = 0;
+ #endif // CHECK_FIMGC210_PERFORMANCE
+
+ if(m_DoG2D(src, dst, clip, flag) == false) {
+ goto STRETCH_FAIL;
+ }
+
+#ifdef G2D_NONE_BLOCKING_MODE
+ if(m_PollG2D(&m_g2dPoll) == false)
+ {
+ PRINT("%s::m_PollG2D() fail\n", __func__);
+ goto STRETCH_FAIL;
+ }
+#endif
+
+ #ifdef CHECK_FIMGC210_PERFORMANCE
+ m_PrintFimgC210Performance(src, dst, stopWatchIndex, stopWatchName, stopWatchTime);
+ #endif // CHECK_FIMGC210_PERFORMANCE
+
+ return true;
+
+STRETCH_FAIL:
+ return false;
+
+}
+
+bool FimgC210::t_Sync(void)
+{
+#if 0
+ if(ioctl(m_g2dFd, G2D_SYNC) < 0) {
+ PRINT("%s::G2D_Sync fail\n", __func__);
+ goto SYNC_FAIL;
+ }
+#else
+ if(m_PollG2D(&m_g2dPoll) == false)
+ {
+ PRINT("%s::m_PollG2D() fail\n", __func__);
+ goto SYNC_FAIL;
+ }
+#endif
+ return true;
+
+SYNC_FAIL:
+ return false;
+
+}
+
+bool FimgC210::t_Lock(void)
+{
+ m_lock->lock();
+ return true;
+}
+
+bool FimgC210::t_UnLock(void)
+{
+ m_lock->unlock();
+ return true;
+}
+
+bool FimgC210::m_CreateG2D(void)
+{
+ void * mmap_base;
+
+ if(m_g2dFd != 0) {
+ PRINT("%s::m_g2dFd(%d) is not 0 fail\n", __func__, m_g2dFd);
+ return false;
+ }
+
+#ifdef G2D_NONE_BLOCKING_MODE
+ m_g2dFd = open(SEC_G2D_DEV_NAME, O_RDWR | O_NONBLOCK);
+#else
+ m_g2dFd = open(SEC_G2D_DEV_NAME, O_RDWR);
+#endif
+ if(m_g2dFd < 0) {
+ PRINT("%s::open(%s) fail(%s)\n", __func__, SEC_G2D_DEV_NAME, strerror(errno));
+ m_g2dFd = 0;
+ return false;
+ }
+
+ memset(&m_g2dPoll, 0, sizeof(m_g2dPoll));
+ m_g2dPoll.fd = m_g2dFd;
+ m_g2dPoll.events = POLLOUT | POLLERR;
+
+ return true;
+}
+
+bool FimgC210::m_DestroyG2D(void)
+{
+ if(m_g2dVirtAddr != NULL) {
+ munmap(m_g2dVirtAddr, m_g2dSize);
+ m_g2dVirtAddr = NULL;
+ m_g2dSize = 0;
+ }
+
+ if(0 < m_g2dFd) {
+ close(m_g2dFd);
+ }
+ m_g2dFd = 0;
+
+ return true;
+}
+
+//bool FimgC210::m_DoG2D(FimgRect * src, FimgRect * dst, int rotateValue, int alphaValue, int colorKey)
+bool FimgC210::m_DoG2D(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag)
+{
+ g2d_params params;
+
+ memcpy(&params.src_rect, src, sizeof(FimgRect));
+ memcpy(&params.dst_rect, dst, sizeof(FimgRect));
+ memcpy(&params.clip, clip, sizeof(FimgClip));
+ memcpy(&params.flag, flag, sizeof(FimgFlag));
+
+ if(ioctl(m_g2dFd, G2D_BLIT, &params) < 0) {
+ #if 0
+ {
+ PRINT("---------------------------------------\n");
+ PRINT("src.color_format : %d \n", src->color_format);
+ PRINT("src.full_w : %d \n", src->full_w);
+ PRINT("src.full_h : %d \n", src->full_h);
+ PRINT("src.x : %d \n", src->x);
+ PRINT("src.y : %d \n", src->y);
+ PRINT("src.w : %d \n", src->w);
+ PRINT("src.h : %d \n", src->h);
+
+ PRINT("dst.color_format : %d \n", dst->color_format);
+ PRINT("dst.full_w : %d \n", dst->full_w);
+ PRINT("dst.full_h : %d \n", dst->full_h);
+ PRINT("dst.x : %d \n", dst->x);
+ PRINT("dst.y : %d \n", dst->y);
+ PRINT("dst.w : %d \n", dst->w);
+ PRINT("dst.h : %d \n", dst->h);
+
+ PRINT("flag.rotate_val : %d \n", flag->rotate_val);
+ PRINT("flag.alpha_val : %d(%d) \n", flag->alpha_val);
+ PRINT("flag.color_key_mode : %d(%d) \n", flag->color_key_mode, flag->color_key_val);
+ PRINT("---------------------------------------\n");
+ }
+ #endif
+
+ return false;
+ }
+
+ return true;
+}
+
+inline bool FimgC210::m_PollG2D(struct pollfd * events)
+{
+ #define G2D_POLL_TIME (1000)
+
+ int ret;
+
+ ret = poll(events, 1, G2D_POLL_TIME);
+
+ if (ret < 0) {
+ if(ioctl(m_g2dFd, G2D_RESET) < 0) {
+ PRINT("%s::G2D_RESET fail\n", __func__);
+ }
+ PRINT("%s::poll fail \n", __func__);
+ return false;
+ }
+ else if (ret == 0) {
+ if(ioctl(m_g2dFd, G2D_RESET) < 0) {
+ PRINT("%s::G2D_RESET fail\n", __func__);
+ }
+ PRINT("%s::No data in %d milli secs..\n", __func__, G2D_POLL_TIME);
+ return false;
+ }
+
+ return true;
+}
+
+inline bool FimgC210::m_CleanG2D(unsigned int virtAddr, unsigned int size)
+{
+ g2d_dma_info dma_info = { virtAddr, size };
+
+ if(ioctl(m_g2dFd, G2D_DMA_CACHE_CLEAN, &dma_info) < 0) {
+ PRINT("%s::G2D_DMA_CACHE_CLEAN(%d, %d) fail\n", __func__, virtAddr, size);
+ return false;
+ }
+ return true;
+}
+
+inline bool FimgC210::m_FlushG2D (unsigned int virtAddr, unsigned int size)
+{
+ g2d_dma_info dma_info = { virtAddr, size };
+
+ if(ioctl(m_g2dFd, G2D_DMA_CACHE_FLUSH, &dma_info) < 0) {
+ PRINT("%s::G2D_DMA_CACHE_FLUSH(%d, %d) fail\n", __func__, virtAddr, size);
+ return false;
+ }
+ return true;
+}
+
+inline int FimgC210::m_RotateValueFimgApi2FimgHw(int rotateValue)
+{
+ switch (rotateValue) {
+ case ROTATE_0: return G2D_ROT_0;
+ case ROTATE_90: return G2D_ROT_90;
+ case ROTATE_180: return G2D_ROT_180;
+ case ROTATE_270: return G2D_ROT_270;
+ case ROTATE_X_FLIP: return G2D_ROT_X_FLIP;
+ case ROTATE_Y_FLIP: return G2D_ROT_Y_FLIP;
+ }
+
+ return -1;
+}
+
+
+#ifdef CHECK_FIMGC210_PERFORMANCE
+void FimgC210::m_PrintFimgC210Performance(FimgRect * src,
+ FimgRect * dst,
+ int stopWatchIndex,
+ const char * stopWatchName[],
+ nsecs_t stopWatchTime[])
+{
+ char * srcColorFormat = "UNKNOW_COLOR_FORMAT";
+ char * dstColorFormat = "UNKNOW_COLOR_FORMAT";
+
+ switch(src->color_format)
+ {
+ case COLOR_FORMAT_RGB_565 :
+ srcColorFormat = "RGB_565";
+ break;
+ case COLOR_FORMAT_RGBA_8888 :
+ srcColorFormat = "RGBA_8888";
+ break;
+ case COLOR_FORMAT_RGBX_8888 :
+ srcColorFormat = "RGBX_8888";
+ break;
+ default :
+ srcColorFormat = "UNKNOW_COLOR_FORMAT";
+ break;
+ }
+
+ switch(dst->color_format)
+ {
+ case COLOR_FORMAT_RGB_565 :
+ dstColorFormat = "RGB_565";
+ break;
+ case COLOR_FORMAT_RGBA_8888 :
+ dstColorFormat = "RGBA_8888";
+ break;
+ case COLOR_FORMAT_RGBX_8888 :
+ dstColorFormat = "RGBX_8888";
+ break;
+ default :
+ dstColorFormat = "UNKNOW_COLOR_FORMAT";
+ break;
+ }
+
+
+#ifdef CHECK_FIMGC210_CRITICAL_PERFORMANCE
+#else
+ PRINT("===============================================\n");
+ PRINT("src[%3d, %3d | %10s] -> dst[%3d, %3d | %10s]\n",
+ src->w, src->h, srcColorFormat,
+ dst->w, dst->h, dstColorFormat);
+#endif
+
+ nsecs_t totalTime = stopWatchTime[stopWatchIndex - 1];
+
+ for(int i = 0 ; i < stopWatchIndex; i++) {
+ nsecs_t sectionTime;
+
+ if(i != 0)
+ sectionTime = stopWatchTime[i] - stopWatchTime[i-1];
+ else
+ sectionTime = stopWatchTime[i];
+
+#ifdef CHECK_FIMGC210_CRITICAL_PERFORMANCE
+ if(1500 < (sectionTime / 1000)) // check 1.5 mille second..
+#endif
+ {
+ PRINT("===============================================\n");
+ PRINT("src[%3d, %3d | %10s] -> dst[%3d, %3d | %10s]\n",
+ src->w, src->h, srcColorFormat,
+ dst->w, dst->h, dstColorFormat);
+
+ PRINT("%20s : %5lld msec(%5.2f %%)\n",
+ stopWatchName[i],
+ sectionTime / 1000,
+ ((float)sectionTime / (float)totalTime) * 100.0f);
+ }
+ }
+
+}
+#endif // CHECK_FIMGC210_PERFORMANCE
+
+//---------------------------------------------------------------------------//
+// extern function
+//---------------------------------------------------------------------------//
+extern "C" struct FimgApi * createFimgApi()
+{
+ if (fimgApiAutoFreeThread == 0)
+ fimgApiAutoFreeThread = new FimgApiAutoFreeThread();
+ else
+ fimgApiAutoFreeThread->SetOneMoreSleep();
+
+ return FimgC210::CreateInstance();
+}
+
+extern "C" void destroyFimgApi(FimgApi * ptrFimgApi)
+{
+ // Dont' call DestrotInstance..
+ // return FimgC210::DestroyInstance(ptrFimgApi);
+}
+
+}; // namespace android
diff --git a/exynos4/hal/libfimg/FimgC210.h b/exynos4/hal/libfimg/FimgC210.h
new file mode 100644
index 0000000..7aa9a9a
--- /dev/null
+++ b/exynos4/hal/libfimg/FimgC210.h
@@ -0,0 +1,197 @@
+/*
+**
+** Copyright 2008, The Android Open Source Project
+** Copyright 2009 Samsung Electronics Co, Ltd. All Rights Reserved.
+**
+** 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 FIMG_C210_H
+#define FIMG_C210_H
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <sys/stat.h>
+
+#include <linux/android_pmem.h>
+#include <utils/threads.h>
+#include <utils/StopWatch.h>
+
+#include "FimgApi.h"
+//#include "FimgMem.h"
+
+#include "sec_g2d.h"
+
+//-----------------------------------------------------------------//
+
+namespace android
+{
+
+//#define CHECK_FIMGC210_PERFORMANCE
+//#define CHECK_FIMGC210_CRITICAL_PERFORMANCE
+#define NUMBER_FIMG_LIST (1) // kcoolsw : because of pmem
+//#define G2D_NONE_BLOCKING_MODE // Not supported yet. because of sysMMU Page fault
+#define GET_RECT_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel))
+#define GET_REAL_SIZE(rect) ((rect->full_w) * (rect->h) * (rect->bytes_per_pixel))
+#define GET_START_ADDR(rect) (rect->virt_addr + ((rect->y * rect->full_w) * rect->bytes_per_pixel))
+
+
+//---------------------------------------------------------------------------//
+// class FimgC210 : public FimgBase
+//---------------------------------------------------------------------------//
+class FimgC210 : public FimgApi
+{
+private :
+ int m_g2dFd;
+
+ unsigned char * m_g2dVirtAddr;
+ unsigned int m_g2dSize;
+ unsigned char * m_g2dSrcVirtAddr;
+ unsigned int m_g2dSrcSize;
+ unsigned char * m_g2dDstVirtAddr;
+ unsigned int m_g2dDstSize;
+ struct pollfd m_g2dPoll;
+
+ Mutex * m_lock;
+
+ static Mutex m_instanceLock;
+ static int m_curFimgC210Index;
+ static int m_numOfInstance;
+
+ static FimgApi * m_ptrFimgApiList[NUMBER_FIMG_LIST];
+
+
+protected :
+ FimgC210();
+ virtual ~FimgC210();
+
+public:
+ static FimgApi * CreateInstance();
+ static void DestroyInstance(FimgApi * ptrFimgApi);
+ static void DestroyAllInstance(void);
+
+protected:
+ virtual bool t_Create(void);
+ virtual bool t_Destroy(void);
+ virtual bool t_Stretch(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag);
+ virtual bool t_Sync(void);
+ virtual bool t_Lock(void);
+ virtual bool t_UnLock(void);
+
+private:
+ bool m_CreateG2D(void);
+ bool m_DestroyG2D(void);
+ bool SetClipRectl(FimgRect * dst, FimgClip * clip, FimgClip * clipTempMidRect);
+
+ bool m_DoG2D(FimgRect * src, FimgRect * dst, FimgClip * clip, FimgFlag * flag);
+
+ inline bool m_PollG2D(struct pollfd * events);
+
+ inline bool m_CleanG2D (unsigned int addr, unsigned int size);
+ inline bool m_FlushG2D (unsigned int addr, unsigned int size);
+
+ inline int m_ColorFormatFimgApi2FimgHw(int colorFormat);
+ inline int m_RotateValueFimgApi2FimgHw(int rotateValue);
+
+ #ifdef CHECK_FIMGC210_PERFORMANCE
+ void m_PrintFimgC210Performance(FimgRect * src,
+ FimgRect * dst,
+ int stopWatchIndex,
+ const char * stopWatchName[],
+ nsecs_t stopWatchTime[]);
+ #endif // CHECK_FIMGC210_PERFORMANCE
+};
+
+//---------------------------------------------------------------------------//
+// class FimgApiAutoFreeThread : public Thread
+//---------------------------------------------------------------------------//
+class FimgApiAutoFreeThread;
+
+static sp<FimgApiAutoFreeThread> fimgApiAutoFreeThread = 0;
+
+class FimgApiAutoFreeThread : public Thread
+{
+ private:
+ bool mOneMoreSleep;
+ bool mDestroyed;
+
+ public:
+ FimgApiAutoFreeThread(void):
+ //Thread(true),
+ Thread(false),
+ mOneMoreSleep(true),
+ mDestroyed(false)
+ { }
+ ~FimgApiAutoFreeThread(void)
+ {
+ if(mDestroyed == false)
+ {
+ FimgC210::DestroyAllInstance();
+ mDestroyed = true;
+ }
+ }
+
+ virtual void onFirstRef()
+ {
+ run("FimgApiAutoFreeThread", PRIORITY_BACKGROUND);
+ }
+
+ virtual bool threadLoop()
+ {
+ //#define SLEEP_TIME (10000000) // 10 sec
+ #define SLEEP_TIME (3000000) // 3 sec
+ //#define SLEEP_TIME (1000000) // 1 sec
+
+ if(mOneMoreSleep == true)
+ {
+ mOneMoreSleep = false;
+ usleep(SLEEP_TIME);
+
+ return true;
+ }
+ else
+ {
+ if(mDestroyed == false)
+ {
+ FimgC210::DestroyAllInstance();
+ mDestroyed = true;
+ }
+
+ fimgApiAutoFreeThread = 0;
+
+ return false;
+ }
+ }
+
+ void SetOneMoreSleep(void)
+ {
+ mOneMoreSleep = true;
+ }
+};
+
+}; // namespace android
+
+#endif // FIMG_C210_H
diff --git a/exynos4/hal/libhwconverter/Android.mk b/exynos4/hal/libhwconverter/Android.mk
new file mode 100644
index 0000000..ecda03b
--- /dev/null
+++ b/exynos4/hal/libhwconverter/Android.mk
@@ -0,0 +1,30 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_SHARED_LIBRARIES := liblog libutils libcutils libfimc
+
+LOCAL_SRC_FILES := HardwareConverter.cpp
+
+LOCAL_C_INCLUDES := \
+ $(TOP)/$(BOARD_HAL_PATH)/include \
+ $(TOP)/$(BOARD_HMM_PATH)/openmax/sec_omx/include/khronos \
+ $(TOP)/$(BOARD_HMM_PATH)/openmax/sec_omx/include/sec
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := libhwconverter
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos4/hal/libhwconverter/HardwareConverter.cpp b/exynos4/hal/libhwconverter/HardwareConverter.cpp
new file mode 100644
index 0000000..3a66767
--- /dev/null
+++ b/exynos4/hal/libhwconverter/HardwareConverter.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2009 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 <utils/Log.h>
+
+#include "SEC_OMX_Def.h"
+#include "SecFimc.h"
+#include "HardwareConverter.h"
+
+HardwareConverter::HardwareConverter()
+{
+ SecFimc* handle_fimc = new SecFimc();
+ mSecFimc = (void *)handle_fimc;
+
+ if (handle_fimc->create(SecFimc::DEV_2, SecFimc::MODE_MULTI_BUF, 1) == false)
+ bHWconvert_flag = 0;
+ else
+ bHWconvert_flag = 1;
+}
+
+HardwareConverter::~HardwareConverter()
+{
+ SecFimc* handle_fimc = (SecFimc*)mSecFimc;
+ handle_fimc->destroy();
+ delete mSecFimc;
+}
+
+bool HardwareConverter::convert(
+ void * src_addr,
+ void *dst_addr,
+ OMX_COLOR_FORMATTYPE src_format,
+ int32_t width,
+ int32_t height,
+ OMX_COLOR_FORMATTYPE dst_format)
+{
+ SecFimc* handle_fimc = (SecFimc*)mSecFimc;
+
+ int rotate_value = 0;
+ unsigned int src_crop_x = 0;
+ unsigned int src_crop_y = 0;
+ unsigned int src_crop_width = width;
+ unsigned int src_crop_height = height;
+
+ unsigned int dst_crop_x = 0;
+ unsigned int dst_crop_y = 0;
+ unsigned int dst_crop_width = width;
+ unsigned int dst_crop_height = height;
+
+ void **src_addr_array = (void **)src_addr;
+ void **dst_addr_array = (void **)dst_addr;
+
+ unsigned int src_har_format = OMXtoHarPixelFomrat(src_format);
+ unsigned int dst_har_format = OMXtoHarPixelFomrat(dst_format);
+
+ // set post processor configuration
+ if (!handle_fimc->setSrcParams(width, height, src_crop_x, src_crop_y,
+ &src_crop_width, &src_crop_height,
+ src_har_format)) {
+ LOGE("%s:: setSrcParms() failed", __func__);
+ return false;
+ }
+
+ if (!handle_fimc->setSrcAddr((unsigned int)src_addr_array[0],
+ (unsigned int)src_addr_array[1],
+ (unsigned int)src_addr_array[1],
+ src_har_format)) {
+ LOGE("%s:: setSrcPhyAddr() failed", __func__);
+ return false;
+ }
+
+ if (!handle_fimc->setRotVal(rotate_value)) {
+ LOGE("%s:: setRotVal() failed", __func__);
+ return false;
+ }
+
+ if (!handle_fimc->setDstParams(width, height, dst_crop_x, dst_crop_y,
+ &dst_crop_width, &dst_crop_height,
+ dst_har_format)) {
+ LOGE("%s:: setDstParams() failed", __func__);
+ return false;
+ }
+
+ switch (dst_format) {
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ if (!handle_fimc->setDstAddr((unsigned int)(dst_addr_array[0]),
+ (unsigned int)(dst_addr_array[1]),
+ (unsigned int)(dst_addr_array[1]))) {
+ LOGE("%s:: setDstPhyAddr() failed", __func__);
+ return false;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ if (!handle_fimc->setDstAddr((unsigned int)(dst_addr_array[0]),
+ (unsigned int)(dst_addr_array[1]),
+ (unsigned int)(dst_addr_array[2]))) {
+ LOGE("%s:: setDstPhyAddr() failed", __func__);
+ return false;
+ }
+ break;
+ }
+
+ if (!handle_fimc->draw(0, 0)) {
+ LOGE("%s:: handleOneShot() failed", __func__);
+ return false;
+ }
+
+ return true;
+}
+
+unsigned int HardwareConverter::OMXtoHarPixelFomrat(OMX_COLOR_FORMATTYPE omx_format)
+{
+ unsigned int hal_format = 0;
+
+ switch (omx_format) {
+ case OMX_COLOR_FormatYUV420Planar:
+ hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ hal_format = HAL_PIXEL_FORMAT_YCbCr_420_SP;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ hal_format = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
+ break;
+ default:
+ hal_format = HAL_PIXEL_FORMAT_YCbCr_420_P;
+ break;
+ }
+ return hal_format;
+}
diff --git a/exynos4/hal/libhwconverter/HardwareConverter.h b/exynos4/hal/libhwconverter/HardwareConverter.h
new file mode 100644
index 0000000..5520fb6
--- /dev/null
+++ b/exynos4/hal/libhwconverter/HardwareConverter.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 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 HARDWARE_CONVERTER_H_
+
+#define HARDWARE_CONVERTER_H_
+
+#include <OMX_Video.h>
+
+class HardwareConverter {
+public:
+ HardwareConverter();
+ ~HardwareConverter();
+ bool convert(
+ void * src_addr,
+ void * dst_addr,
+ OMX_COLOR_FORMATTYPE src_format,
+ int32_t width,
+ int32_t height,
+ OMX_COLOR_FORMATTYPE dst_format);
+ bool bHWconvert_flag;
+private:
+ void *mSecFimc;
+ unsigned int OMXtoHarPixelFomrat(OMX_COLOR_FORMATTYPE omx_format);
+};
+
+void test_function();
+
+#endif // HARDWARE_CONVERTER_H_
diff --git a/exynos4/hal/liblights/Android.mk b/exynos4/hal/liblights/Android.mk
new file mode 100644
index 0000000..995bd02
--- /dev/null
+++ b/exynos4/hal/liblights/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2011 The Android Open Source Project
+# Copyright (C) 2011 The CyanogenMod 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.
+
+LOCAL_PATH:= $(call my-dir)
+# HAL module implemenation, not prelinked and stored in
+# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := lights.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+
+LOCAL_SHARED_LIBRARIES := liblog
+
+LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM)
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/exynos4/hal/liblights/NOTICE b/exynos4/hal/liblights/NOTICE
new file mode 100644
index 0000000..f921593
--- /dev/null
+++ b/exynos4/hal/liblights/NOTICE
@@ -0,0 +1,190 @@
+
+ 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.
+
+ 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.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/exynos4/hal/liblights/lights.c b/exynos4/hal/liblights/lights.c
new file mode 100644
index 0000000..06bb5f8
--- /dev/null
+++ b/exynos4/hal/liblights/lights.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2011 The CyanogenMod 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.
+ */
+
+
+#define LOG_TAG "lights"
+#define LOG_NDEBUG 0
+
+#include <cutils/log.h>
+
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <hardware/lights.h>
+
+/******************************************************************************/
+
+static pthread_once_t g_init = PTHREAD_ONCE_INIT;
+static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
+static int g_enable_touchlight = -1;
+
+char const*const PANEL_FILE
+ = "/sys/class/backlight/panel/brightness";
+
+char const*const BUTTON_POWER
+ = "/sys/class/sec/sec_touchkey/enable_disable";
+
+char const*const BUTTON_FILE
+ = "/sys/class/sec/sec_touchkey/brightness";
+
+void init_globals(void)
+{
+ // init the mutex
+ pthread_mutex_init(&g_lock, NULL);
+}
+
+void
+load_settings()
+{
+ FILE* fp = fopen("/data/.disable_touchlight", "r");
+ if (!fp) {
+ g_enable_touchlight = 1;
+ } else {
+ g_enable_touchlight = (int)(fgetc(fp));
+ if (g_enable_touchlight == '1')
+ g_enable_touchlight = 1;
+ else
+ g_enable_touchlight = 0;
+
+ fclose(fp);
+ }
+}
+
+static int
+write_int(char const* path, int value)
+{
+ int fd;
+ static int already_warned = 0;
+
+ fd = open(path, O_RDWR);
+ if (fd >= 0) {
+ char buffer[20];
+ int bytes = sprintf(buffer, "%d\n", value);
+ int amt = write(fd, buffer, bytes);
+ close(fd);
+ return amt == -1 ? -errno : 0;
+ } else {
+ if (already_warned == 0) {
+ LOGE("write_int failed to open %s\n", path);
+ already_warned = 1;
+ }
+ return -errno;
+ }
+}
+
+static int
+is_lit(struct light_state_t const* state)
+{
+ return state->color & 0x00ffffff;
+}
+
+static int
+rgb_to_brightness(struct light_state_t const* state)
+{
+ int color = state->color & 0x00ffffff;
+ return ((77*((color>>16)&0x00ff))
+ + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
+}
+
+static int
+set_light_backlight(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ load_settings();
+
+ int err = 0;
+ int brightness = rgb_to_brightness(state);
+
+ pthread_mutex_lock(&g_lock);
+ err = write_int(PANEL_FILE, brightness);
+
+ if (g_enable_touchlight == -1 || g_enable_touchlight > 0)
+ err = write_int(BUTTON_FILE, brightness > 0 ? 1 : 0);
+
+ pthread_mutex_unlock(&g_lock);
+
+ return err;
+}
+
+static int
+set_light_keyboard(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ return 0;
+}
+
+static int
+set_light_buttons(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ int err = 0;
+ int on = is_lit(state);
+
+ pthread_mutex_lock(&g_lock);
+ LOGD("set_light_button on=%d\n", on ? 1 : 0);
+ err = write_int(BUTTON_FILE, on ? 1:0);
+ pthread_mutex_unlock(&g_lock);
+
+ return err;
+}
+
+static int
+set_light_battery(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ return 0;
+}
+
+static int
+set_light_notification(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ return 0;
+}
+
+static int
+set_light_attention(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ return 0;
+}
+
+static int
+close_lights(struct light_device_t *dev)
+{
+ if (dev) {
+ free(dev);
+ }
+ return 0;
+}
+
+
+/******************************************************************************/
+static int open_lights(const struct hw_module_t* module, char const* name,
+ struct hw_device_t** device)
+{
+ int (*set_light)(struct light_device_t* dev,
+ struct light_state_t const* state);
+
+ if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) {
+ set_light = set_light_backlight;
+ }
+ else if (0 == strcmp(LIGHT_ID_KEYBOARD, name)) {
+ set_light = set_light_keyboard;
+ }
+ else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) {
+ set_light = set_light_buttons;
+ }
+ else if (0 == strcmp(LIGHT_ID_BATTERY, name)) {
+ set_light = set_light_battery;
+ }
+ else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) {
+ set_light = set_light_notification;
+ }
+ else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) {
+ set_light = set_light_attention;
+ }
+ else {
+ return -EINVAL;
+ }
+
+ pthread_once(&g_init, init_globals);
+
+ struct light_device_t *dev = malloc(sizeof(struct light_device_t));
+ memset(dev, 0, sizeof(*dev));
+
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = 0;
+ dev->common.module = (struct hw_module_t*)module;
+ dev->common.close = (int (*)(struct hw_device_t*))close_lights;
+ dev->set_light = set_light;
+
+ *device = (struct hw_device_t*)dev;
+ return 0;
+}
+
+
+static struct hw_module_methods_t lights_module_methods = {
+ .open = open_lights,
+};
+
+const struct hw_module_t HAL_MODULE_INFO_SYM = {
+ .tag = HARDWARE_MODULE_TAG,
+ .version_major = 1,
+ .version_minor = 0,
+ .id = LIGHTS_HARDWARE_MODULE_ID,
+ .name = "Samsung Exynos4210 Lights Module",
+ .author = "The CyanogenMod Project",
+ .methods = &lights_module_methods,
+};
diff --git a/exynos4/hal/libs5pjpeg/Android.mk b/exynos4/hal/libs5pjpeg/Android.mk
new file mode 100644
index 0000000..e1ac187
--- /dev/null
+++ b/exynos4/hal/libs5pjpeg/Android.mk
@@ -0,0 +1,34 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH) \
+ $(BOARD_HAL_PATH)/include \
+
+LOCAL_SRC_FILES:= \
+ jpeg_api.c \
+
+LOCAL_SHARED_LIBRARIES:= liblog
+LOCAL_SHARED_LIBRARIES+= libdl
+
+LOCAL_MODULE_TAGS := eng
+
+LOCAL_MODULE:= libs5pjpeg
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos4/hal/libs5pjpeg/jpeg_api.c b/exynos4/hal/libs5pjpeg/jpeg_api.c
new file mode 100644
index 0000000..eb80e07
--- /dev/null
+++ b/exynos4/hal/libs5pjpeg/jpeg_api.c
@@ -0,0 +1,347 @@
+/*
+**
+** Copyright 2008, The Android Open Source Project
+** Copyright 2010, Samsung Electronics Co. LTD
+**
+** 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.
+*/
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "Jpeg-api"
+
+#include <utils/Log.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <math.h>
+#include <sys/poll.h>
+
+#ifdef S5P_VMEM
+#include "s5p_vmem_api.h"
+#endif
+#include "jpeg_api.h"
+
+static struct jpeg_lib *jpeg_ctx = NULL;
+#ifdef S5P_VMEM
+static int mem_fp;
+unsigned int cookie;
+#endif /* S5P_VMEM */
+
+static unsigned int get_yuv_size(enum jpeg_frame_format out_format,
+ unsigned int width, unsigned int height)
+{
+ switch (out_format) {
+ case YUV_422 :
+ if (width % 16 != 0)
+ width += 16 - (width % 16);
+ if (height % 8 != 0)
+ height += 8 - (height % 8);
+ break;
+
+ case YUV_420 :
+ if (width % 16 != 0)
+ width += 16 - (width % 16);
+ if (height % 16 != 0)
+ height += 16 - (height % 16);
+ break;
+
+ default:
+ LOGV("get_yuv_size return fmt(%d)\n", out_format);
+ return(0);
+ }
+
+ LOGV("get_yuv_size width(%d) height(%d)\n", width, height);
+
+ switch (out_format) {
+ case YUV_422 :
+ return(width*height*2);
+ case YUV_420 :
+ return((width*height) + (width*height >> 1));
+ default :
+ return(0);
+ }
+}
+
+static int check_input_size(unsigned int width, unsigned int height)
+{
+ if ((width % 16) != 0 || (height % 8) != 0)
+ return -1;
+
+ return 0;
+}
+
+static void init_decode_param(void)
+{
+ jpeg_ctx = (struct jpeg_lib *)malloc(sizeof(struct jpeg_lib));
+ memset(jpeg_ctx, 0x00, sizeof(struct jpeg_lib));
+
+ jpeg_ctx->args.dec_param = (struct jpeg_dec_param *)malloc(sizeof(struct jpeg_dec_param));
+ memset(jpeg_ctx->args.dec_param, 0x00, sizeof(struct jpeg_dec_param));
+}
+
+static void init_encode_param(void)
+{
+ jpeg_ctx = (struct jpeg_lib *)malloc(sizeof(struct jpeg_lib));
+ memset(jpeg_ctx, 0x00, sizeof(struct jpeg_lib));
+
+ jpeg_ctx->args.enc_param = (struct jpeg_enc_param *)malloc(sizeof(struct jpeg_enc_param));
+ memset(jpeg_ctx->args.enc_param, 0x00, sizeof(struct jpeg_enc_param));
+}
+
+int api_jpeg_decode_init()
+{
+ init_decode_param();
+ jpeg_ctx->jpeg_fd = open(JPEG_DRIVER_NAME, O_RDWR);
+
+ if (jpeg_ctx->jpeg_fd < 0) {
+ LOGE("JPEG driver open failed\n");
+ return -1;
+ }
+
+#ifdef S5P_VMEM
+ mem_fp = s5p_vmem_open();
+ LOGV("s5p_vmem_open\n");
+#else
+ jpeg_ctx->args.mmapped_addr = (char *) mmap(0,
+ JPEG_TOTAL_BUF_SIZE,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ jpeg_ctx->jpeg_fd, 0);
+
+ if (jpeg_ctx->args.mmapped_addr == NULL) {
+ LOGE("JPEG mmap failed\n");
+ return -1;
+ }
+ LOGV("api_jpeg_decode_init jpeg_ctx->args.mmapped_addr 0x%08x\n",
+ jpeg_ctx->args.mmapped_addr);
+#endif /* S5P_VMEM */
+
+ return jpeg_ctx->jpeg_fd;
+}
+
+int api_jpeg_encode_init()
+{
+ init_encode_param();
+ jpeg_ctx->jpeg_fd = open(JPEG_DRIVER_NAME, O_RDWR);
+
+ if (jpeg_ctx->jpeg_fd < 0) {
+ LOGE("JPEG driver open failed %d\n", jpeg_ctx->jpeg_fd);
+ return -1;
+ }
+
+#ifdef S5P_VMEM
+ mem_fp = s5p_vmem_open();
+ LOGI("s5p_vmem_open\n");
+#else
+
+ jpeg_ctx->args.mmapped_addr = (char *) mmap(0,
+ JPEG_TOTAL_BUF_SIZE,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ jpeg_ctx->jpeg_fd, 0);
+
+ if (jpeg_ctx->args.mmapped_addr == NULL) {
+ LOGE("JPEG mmap failed\n");
+ return -1;
+ }
+ LOGV("api_jpeg_encode_init jpeg_ctx->args.mmapped_addr 0x%08x\n",
+ jpeg_ctx->args.mmapped_addr);
+#endif /* S5P_VMEM */
+ return jpeg_ctx->jpeg_fd;
+}
+
+int api_jpeg_decode_deinit(int dev_fd)
+{
+ if (jpeg_ctx->args.mmapped_addr != NULL)
+ munmap(jpeg_ctx->args.mmapped_addr, JPEG_TOTAL_BUF_SIZE);
+
+#ifdef S5P_VMEM
+ s5p_free_share(mem_fp, jpeg_ctx->args.in_cookie, jpeg_ctx->args.in_buf);
+ s5p_free_share(mem_fp, jpeg_ctx->args.out_cookie, jpeg_ctx->args.out_buf);
+ s5p_vmem_close(mem_fp);
+#endif
+
+ close(jpeg_ctx->jpeg_fd);
+
+ if (jpeg_ctx->args.dec_param != NULL)
+ free(jpeg_ctx->args.dec_param);
+
+ free(jpeg_ctx);
+
+ return JPEG_OK;
+}
+
+int api_jpeg_encode_deinit(int dev_fd)
+{
+ if (jpeg_ctx->args.mmapped_addr != NULL)
+ munmap(jpeg_ctx->args.mmapped_addr, JPEG_TOTAL_BUF_SIZE);
+
+#ifdef S5P_VMEM
+ s5p_free_share(mem_fp, jpeg_ctx->args.in_cookie, jpeg_ctx->args.in_buf);
+ s5p_free_share(mem_fp, jpeg_ctx->args.out_cookie, jpeg_ctx->args.out_buf);
+ s5p_vmem_close(mem_fp);
+#endif
+ close(jpeg_ctx->jpeg_fd);
+
+ if (jpeg_ctx->args.enc_param != NULL)
+ free(jpeg_ctx->args.enc_param);
+
+ free(jpeg_ctx);
+
+ return JPEG_OK;
+}
+
+void *api_jpeg_get_decode_in_buf(int dev_fd, unsigned int size)
+{
+ if (size < 0 || size > MAX_JPEG_RES) {
+ LOGE("Invalid decode input buffer size\r\n");
+ return NULL;
+ }
+#ifdef S5P_VMEM
+ jpeg_ctx->args.in_cookie = (unsigned int)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_DEC_IN_BUF, size);
+ jpeg_ctx->args.in_buf = s5p_malloc_share(mem_fp,
+ jpeg_ctx->args.in_cookie,
+ &jpeg_ctx->args.in_buf_size);
+#else
+ jpeg_ctx->args.in_buf = (char *)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_DEC_IN_BUF,
+ jpeg_ctx->args.mmapped_addr);
+#endif /* S5P_VMEM */
+ return (void *)(jpeg_ctx->args.in_buf);
+}
+
+void *api_jpeg_get_encode_in_buf(int dev_fd, unsigned int size)
+{
+#ifdef S5P_VMEM
+ jpeg_ctx->args.in_cookie = (unsigned int)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_ENC_IN_BUF, (size*3));
+ jpeg_ctx->args.in_buf = s5p_malloc_share(mem_fp,
+ jpeg_ctx->args.in_cookie,
+ &jpeg_ctx->args.in_buf_size);
+#else
+ jpeg_ctx->args.enc_param->size = size;
+ jpeg_ctx->args.in_buf = (char *)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_ENC_IN_BUF,
+ jpeg_ctx->args.mmapped_addr);
+#endif
+
+ LOGV("api_jpeg_get_encode_in_buf: 0x%x\n",
+ jpeg_ctx->args.in_buf);
+
+ return (void *)(jpeg_ctx->args.in_buf);
+}
+
+void *api_jpeg_get_decode_out_buf(int dev_fd)
+{
+#ifdef S5P_VMEM
+ jpeg_ctx->args.out_cookie = (unsigned int)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_DEC_OUT_BUF, JPEG_FRAME_BUF_SIZE);
+ jpeg_ctx->args.out_buf = s5p_malloc_share(mem_fp,
+ jpeg_ctx->args.out_cookie,
+ &jpeg_ctx->args.out_buf_size);
+#else
+ jpeg_ctx->args.out_buf = (char *)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_DEC_OUT_BUF,
+ jpeg_ctx->args.mmapped_addr);
+#endif /* S5P_VMEM */
+ /*
+ LOGV("api_jpeg_get_decode_out_buf: 0x%x\n",
+ jpeg_ctx->args.out_buf);
+ */
+ return (void *)(jpeg_ctx->args.out_buf);
+}
+
+void *api_jpeg_get_encode_out_buf(int dev_fd)
+{
+#ifdef S5P_VMEM
+ jpeg_ctx->args.out_cookie = (unsigned int)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_ENC_OUT_BUF, JPEG_STREAM_BUF_SIZE);
+ jpeg_ctx->args.out_buf = s5p_malloc_share(mem_fp,
+ jpeg_ctx->args.out_cookie,
+ &jpeg_ctx->args.out_buf_size);
+#else
+ jpeg_ctx->args.out_buf = (char *)ioctl(jpeg_ctx->jpeg_fd,
+ IOCTL_GET_ENC_OUT_BUF,
+ jpeg_ctx->args.mmapped_addr);
+#endif /* S5P_VMEM */
+
+ LOGV("api_jpeg_get_encode_out_buf: 0x%x\n",
+ jpeg_ctx->args.out_buf);
+
+ return (void *)(jpeg_ctx->args.out_buf);
+}
+
+void api_jpeg_set_decode_param(struct jpeg_dec_param *param)
+{
+ memcpy(jpeg_ctx->args.dec_param, param, sizeof(struct jpeg_dec_param));
+ ioctl(jpeg_ctx->jpeg_fd, IOCTL_SET_DEC_PARAM, jpeg_ctx->args.dec_param);
+}
+
+void api_jpeg_set_encode_param(struct jpeg_enc_param *param)
+{
+ memcpy(jpeg_ctx->args.enc_param, param, sizeof(struct jpeg_enc_param));
+ ioctl(jpeg_ctx->jpeg_fd, IOCTL_SET_ENC_PARAM, jpeg_ctx->args.enc_param);
+}
+
+enum jpeg_ret_type api_jpeg_decode_exe(int dev_fd,
+ struct jpeg_dec_param *dec_param)
+{
+ struct jpeg_args *arg;
+
+ arg = &(jpeg_ctx->args);
+
+ ioctl(jpeg_ctx->jpeg_fd, IOCTL_JPEG_DEC_EXE, arg->dec_param);
+ LOGV("api_jpeg_decode_exe dec_param->out_fmt :%d \
+ dec_param->width : %d dec_param->height : %d\n",
+ arg->dec_param->out_fmt,
+ arg->dec_param->width,
+ arg->dec_param->height);
+ dec_param->width = arg->dec_param->width;
+ dec_param->height = arg->dec_param->height;
+ dec_param->size = get_yuv_size(arg->dec_param->out_fmt,
+ arg->dec_param->width,
+ arg->dec_param->height);
+
+ return JPEG_DECODE_OK;
+}
+
+enum jpeg_ret_type api_jpeg_encode_exe(int dev_fd,
+ struct jpeg_enc_param *enc_param)
+{
+ struct jpeg_args *arg;
+ arg = &(jpeg_ctx->args);
+
+ // check MCU validation width & height & sampling mode
+ if (check_input_size(jpeg_ctx->args.enc_param->width,
+ jpeg_ctx->args.enc_param->height) < 0) {
+ LOGV("width/height doesn't match with MCU\r\n");
+ return JPEG_FAIL;
+ }
+
+ ioctl(jpeg_ctx->jpeg_fd, IOCTL_JPEG_ENC_EXE, arg->enc_param);
+
+ enc_param->size = arg->enc_param->size;
+
+ return JPEG_ENCODE_OK;
+}
diff --git a/exynos4/hal/libsensors/AkmSensor.cpp b/exynos4/hal/libsensors/AkmSensor.cpp
new file mode 100644
index 0000000..c147bd6
--- /dev/null
+++ b/exynos4/hal/libsensors/AkmSensor.cpp
@@ -0,0 +1,310 @@
+/*
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <math.h>
+#include <poll.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+#include <dlfcn.h>
+
+#include "ak8973b.h"
+
+#include <cutils/log.h>
+#include "AkmSensor.h"
+
+//#define LOG_NDEBUG 0
+
+/*****************************************************************************/
+
+int (*akm_is_sensor_enabled)(uint32_t sensor_type);
+int (*akm_enable_sensor)(uint32_t sensor_type);
+int (*akm_disable_sensor)(uint32_t sensor_type);
+int (*akm_set_delay)(uint32_t sensor_type, uint64_t delay);
+
+int stub_is_sensor_enabled(uint32_t sensor_type) {
+ return 0;
+}
+
+int stub_enable_disable_sensor(uint32_t sensor_type) {
+ return -ENODEV;
+}
+
+int stub_set_delay(uint32_t sensor_type, uint64_t delay) {
+ return -ENODEV;
+}
+
+AkmSensor::AkmSensor()
+: SensorBase(NULL, NULL),
+ mEnabled(0),
+ mPendingMask(0),
+ mInputReader(32)
+{
+ /* Open the library before opening the input device. The library
+ * creates a uinput device.
+ */
+ if (loadAKMLibrary() == 0) {
+ data_name = "compass_sensor";
+ data_fd = openInput("compass_sensor");
+ }
+
+ memset(mPendingEvents, 0, sizeof(mPendingEvents));
+
+ mPendingEvents[Accelerometer].version = sizeof(sensors_event_t);
+ mPendingEvents[Accelerometer].sensor = ID_A;
+ mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER;
+ mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ mPendingEvents[MagneticField].version = sizeof(sensors_event_t);
+ mPendingEvents[MagneticField].sensor = ID_M;
+ mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD;
+ mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ mPendingEvents[Orientation ].version = sizeof(sensors_event_t);
+ mPendingEvents[Orientation ].sensor = ID_O;
+ mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION;
+ mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ // read the actual value of all sensors if they're enabled already
+ struct input_absinfo absinfo;
+ short flags = 0;
+
+ if (akm_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) {
+ mEnabled |= 1<<Accelerometer;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z;
+ }
+ }
+ if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) {
+ mEnabled |= 1<<MagneticField;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Y), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.y = absinfo.value * CONVERT_M_Y;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Z), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z;
+ }
+ }
+ if (akm_is_sensor_enabled(SENSOR_TYPE_ORIENTATION)) {
+ mEnabled |= 1<<Orientation;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_YAW), &absinfo)) {
+ mPendingEvents[Orientation].orientation.azimuth = absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PITCH), &absinfo)) {
+ mPendingEvents[Orientation].orientation.pitch = absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ROLL), &absinfo)) {
+ mPendingEvents[Orientation].orientation.roll = -absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ORIENT_STATUS), &absinfo)) {
+ mPendingEvents[Orientation].orientation.status = uint8_t(absinfo.value & SENSOR_STATE_MASK);
+ }
+ }
+
+ // disable temperature sensor, since it is not supported
+ akm_disable_sensor(SENSOR_TYPE_TEMPERATURE);
+}
+
+AkmSensor::~AkmSensor()
+{
+ if (mLibAKM) {
+ unsigned ref = ::dlclose(mLibAKM);
+ }
+}
+
+int AkmSensor::enable(int32_t handle, int en)
+{
+ int what = -1;
+
+ switch (handle) {
+ case ID_A: what = Accelerometer; break;
+ case ID_M: what = MagneticField; break;
+ case ID_O: what = Orientation; break;
+ }
+
+ if (uint32_t(what) >= numSensors)
+ return -EINVAL;
+
+ int newState = en ? 1 : 0;
+ int err = 0;
+
+ if ((uint32_t(newState)<<what) != (mEnabled & (1<<what))) {
+ uint32_t sensor_type;
+ switch (what) {
+ case Accelerometer: sensor_type = SENSOR_TYPE_ACCELEROMETER; break;
+ case MagneticField: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break;
+ case Orientation: sensor_type = SENSOR_TYPE_ORIENTATION; break;
+ }
+ short flags = newState;
+ if (en)
+ err = akm_enable_sensor(sensor_type);
+ else
+ err = akm_disable_sensor(sensor_type);
+
+ LOGE_IF(err, "Could not change sensor state (%s)", strerror(-err));
+ if (!err) {
+ mEnabled &= ~(1<<what);
+ mEnabled |= (uint32_t(flags)<<what);
+ }
+ }
+ return err;
+}
+
+int AkmSensor::setDelay(int32_t handle, int64_t ns)
+{
+ uint32_t sensor_type = 0;
+
+ if (ns < 0)
+ return -EINVAL;
+
+ switch (handle) {
+ case ID_A: sensor_type = SENSOR_TYPE_ACCELEROMETER; break;
+ case ID_M: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break;
+ case ID_O: sensor_type = SENSOR_TYPE_ORIENTATION; break;
+ }
+
+ if (sensor_type == 0)
+ return -EINVAL;
+
+ return akm_set_delay(sensor_type, ns);
+}
+
+int AkmSensor::loadAKMLibrary()
+{
+ mLibAKM = dlopen("libakm.so", RTLD_NOW);
+
+ if (!mLibAKM) {
+ akm_is_sensor_enabled = stub_is_sensor_enabled;
+ akm_enable_sensor = stub_enable_disable_sensor;
+ akm_disable_sensor = stub_enable_disable_sensor;
+ akm_set_delay = stub_set_delay;
+ LOGE("AkmSensor: unable to load AKM Library, %s", dlerror());
+ return -ENOENT;
+ }
+
+ *(void **)&akm_is_sensor_enabled = dlsym(mLibAKM, "akm_is_sensor_enabled");
+ *(void **)&akm_enable_sensor = dlsym(mLibAKM, "akm_enable_sensor");
+ *(void **)&akm_disable_sensor = dlsym(mLibAKM, "akm_disable_sensor");
+ *(void **)&akm_set_delay = dlsym(mLibAKM, "akm_set_delay");
+
+ return 0;
+}
+
+int AkmSensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ ssize_t n = mInputReader.fill(data_fd);
+ if (n < 0)
+ return n;
+
+ int numEventReceived = 0;
+ input_event const* event;
+
+ while (count && mInputReader.readEvent(&event)) {
+ int type = event->type;
+ if (type == EV_REL) {
+ processEvent(event->code, event->value);
+ mInputReader.next();
+ } else if (type == EV_SYN) {
+ int64_t time = timevalToNano(event->time);
+ for (int j=0 ; count && mPendingMask && j<numSensors ; j++) {
+ if (mPendingMask & (1<<j)) {
+ mPendingMask &= ~(1<<j);
+ mPendingEvents[j].timestamp = time;
+ if (mEnabled & (1<<j)) {
+ *data++ = mPendingEvents[j];
+ count--;
+ numEventReceived++;
+ }
+ }
+ }
+ if (!mPendingMask) {
+ mInputReader.next();
+ }
+ } else {
+ LOGE("AkmSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ mInputReader.next();
+ }
+ }
+ return numEventReceived;
+}
+
+void AkmSensor::processEvent(int code, int value)
+{
+ switch (code) {
+ case EVENT_TYPE_ACCEL_X:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X;
+ break;
+ case EVENT_TYPE_ACCEL_Y:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y;
+ break;
+ case EVENT_TYPE_ACCEL_Z:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.z = value * CONVERT_A_Z;
+ break;
+
+ case EVENT_TYPE_MAGV_X:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_X value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.x = value * CONVERT_M_X;
+ break;
+ case EVENT_TYPE_MAGV_Y:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_Y value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.y = value * CONVERT_M_Y;
+ break;
+ case EVENT_TYPE_MAGV_Z:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_Z value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.z = value * CONVERT_M_Z;
+ break;
+
+ case EVENT_TYPE_YAW:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.azimuth = value * CONVERT_O_A;
+ break;
+ case EVENT_TYPE_PITCH:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.pitch = value * CONVERT_O_P;
+ break;
+ case EVENT_TYPE_ROLL:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.roll = value * CONVERT_O_R;
+ break;
+ case EVENT_TYPE_ORIENT_STATUS:
+ uint8_t status = uint8_t(value & SENSOR_STATE_MASK);
+ if (status == 4)
+ status = 0;
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.status = status;
+ break;
+ }
+}
diff --git a/exynos4/hal/libsensors/AkmSensor.h b/exynos4/hal/libsensors/AkmSensor.h
new file mode 100644
index 0000000..44214e0
--- /dev/null
+++ b/exynos4/hal/libsensors/AkmSensor.h
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_AKM_SENSOR_H
+#define ANDROID_AKM_SENSOR_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+
+#include "sensors.h"
+#include "SensorBase.h"
+#include "InputEventReader.h"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class AkmSensor : public SensorBase {
+public:
+ AkmSensor();
+ virtual ~AkmSensor();
+
+ enum {
+ Accelerometer = 0,
+ MagneticField = 1,
+ Orientation = 2,
+ numSensors
+ };
+
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+ virtual int readEvents(sensors_event_t* data, int count);
+ void processEvent(int code, int value);
+
+private:
+ int loadAKMLibrary();
+ void *mLibAKM;
+ uint32_t mEnabled;
+ uint32_t mPendingMask;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvents[numSensors];
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_AKM_SENSOR_H
diff --git a/exynos4/hal/libsensors/Android.mk b/exynos4/hal/libsensors/Android.mk
new file mode 100644
index 0000000..15c29a2
--- /dev/null
+++ b/exynos4/hal/libsensors/Android.mk
@@ -0,0 +1,45 @@
+# 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.
+
+
+LOCAL_PATH := $(call my-dir)
+
+ifneq ($(TARGET_SIMULATOR),true)
+
+# HAL module implemenation, not prelinked, and stored in
+# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\"
+LOCAL_SRC_FILES := \
+ sensors.cpp \
+ SensorBase.cpp \
+ LightSensor.cpp \
+ ProximitySensor.cpp \
+ AkmSensor.cpp \
+ GyroSensor.cpp \
+ InputEventReader.cpp
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # !TARGET_SIMULATOR
diff --git a/exynos4/hal/libsensors/GyroSensor.cpp b/exynos4/hal/libsensors/GyroSensor.cpp
new file mode 100644
index 0000000..ef0c01c
--- /dev/null
+++ b/exynos4/hal/libsensors/GyroSensor.cpp
@@ -0,0 +1,185 @@
+/*
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <math.h>
+#include <poll.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+#include <cutils/log.h>
+
+#include "GyroSensor.h"
+
+#define FETCH_FULL_EVENT_BEFORE_RETURN 1
+#define IGNORE_EVENT_TIME 350000000
+/*****************************************************************************/
+
+GyroSensor::GyroSensor()
+ : SensorBase(NULL, "gyro_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false),
+ mEnabledTime(0)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_GY;
+ mPendingEvent.type = SENSOR_TYPE_GYROSCOPE;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+GyroSensor::~GyroSensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int GyroSensor::setInitialState() {
+ struct input_absinfo absinfo_x;
+ struct input_absinfo absinfo_y;
+ struct input_absinfo absinfo_z;
+ float value;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_x) &&
+ !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_y) &&
+ !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_z)) {
+ value = absinfo_x.value;
+ mPendingEvent.data[0] = value * CONVERT_GYRO_X;
+ value = absinfo_x.value;
+ mPendingEvent.data[1] = value * CONVERT_GYRO_Y;
+ value = absinfo_x.value;
+ mPendingEvent.data[2] = value * CONVERT_GYRO_Z;
+ mHasPendingEvent = true;
+ }
+ return 0;
+}
+
+int GyroSensor::enable(int32_t, int en) {
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ int err;
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ mEnabledTime = getTimestamp() + IGNORE_EVENT_TIME;
+ } else {
+ buf[0] = '0';
+ }
+ err = write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ setInitialState();
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool GyroSensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int GyroSensor::setDelay(int32_t handle, int64_t delay_ns)
+{
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[80];
+ sprintf(buf, "%lld", delay_ns);
+ write(fd, buf, strlen(buf)+1);
+ close(fd);
+ return 0;
+ }
+ return -1;
+}
+
+int GyroSensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ ssize_t n = mInputReader.fill(data_fd);
+ if (n < 0)
+ return n;
+
+ int numEventReceived = 0;
+ input_event const* event;
+
+#if FETCH_FULL_EVENT_BEFORE_RETURN
+again:
+#endif
+ while (count && mInputReader.readEvent(&event)) {
+ int type = event->type;
+ if (type == EV_REL) {
+ float value = event->value;
+ if (event->code == EVENT_TYPE_GYRO_X) {
+ mPendingEvent.data[0] = value * CONVERT_GYRO_X;
+ } else if (event->code == EVENT_TYPE_GYRO_Y) {
+ mPendingEvent.data[1] = value * CONVERT_GYRO_Y;
+ } else if (event->code == EVENT_TYPE_GYRO_Z) {
+ mPendingEvent.data[2] = value * CONVERT_GYRO_Z;
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ if (mPendingEvent.timestamp >= mEnabledTime) {
+ *data++ = mPendingEvent;
+ numEventReceived++;
+ }
+ count--;
+ }
+ } else {
+ LOGE("GyroSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+#if FETCH_FULL_EVENT_BEFORE_RETURN
+ /* if we didn't read a complete event, see if we can fill and
+ try again instead of returning with nothing and redoing poll. */
+ if (numEventReceived == 0 && mEnabled == 1) {
+ n = mInputReader.fill(data_fd);
+ if (n)
+ goto again;
+ }
+#endif
+
+ return numEventReceived;
+}
+
diff --git a/exynos4/hal/libsensors/GyroSensor.h b/exynos4/hal/libsensors/GyroSensor.h
new file mode 100644
index 0000000..e8997de
--- /dev/null
+++ b/exynos4/hal/libsensors/GyroSensor.h
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_GYRO_SENSOR_H
+#define ANDROID_GYRO_SENSOR_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include "sensors.h"
+#include "SensorBase.h"
+#include "InputEventReader.h"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class GyroSensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+ int64_t mEnabledTime;
+
+ int setInitialState();
+
+public:
+ GyroSensor();
+ virtual ~GyroSensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_GYRO_SENSOR_H
diff --git a/exynos4/hal/libsensors/InputEventReader.cpp b/exynos4/hal/libsensors/InputEventReader.cpp
new file mode 100644
index 0000000..1014f29
--- /dev/null
+++ b/exynos4/hal/libsensors/InputEventReader.cpp
@@ -0,0 +1,88 @@
+/*
+ * 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 <stdint.h>
+#include <errno.h>
+#include <unistd.h>
+#include <poll.h>
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <linux/input.h>
+
+#include <cutils/log.h>
+
+#include "InputEventReader.h"
+
+/*****************************************************************************/
+
+struct input_event;
+
+InputEventCircularReader::InputEventCircularReader(size_t numEvents)
+ : mBuffer(new input_event[numEvents * 2]),
+ mBufferEnd(mBuffer + numEvents),
+ mHead(mBuffer),
+ mCurr(mBuffer),
+ mFreeSpace(numEvents)
+{
+}
+
+InputEventCircularReader::~InputEventCircularReader()
+{
+ delete [] mBuffer;
+}
+
+ssize_t InputEventCircularReader::fill(int fd)
+{
+ size_t numEventsRead = 0;
+ if (mFreeSpace) {
+ const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));
+ if (nread<0 || nread % sizeof(input_event)) {
+ // we got a partial event!!
+ return nread<0 ? -errno : -EINVAL;
+ }
+
+ numEventsRead = nread / sizeof(input_event);
+ if (numEventsRead) {
+ mHead += numEventsRead;
+ mFreeSpace -= numEventsRead;
+ if (mHead > mBufferEnd) {
+ size_t s = mHead - mBufferEnd;
+ memcpy(mBuffer, mBufferEnd, s * sizeof(input_event));
+ mHead = mBuffer + s;
+ }
+ }
+ }
+
+ return numEventsRead;
+}
+
+ssize_t InputEventCircularReader::readEvent(input_event const** events)
+{
+ *events = mCurr;
+ ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;
+ return available ? 1 : 0;
+}
+
+void InputEventCircularReader::next()
+{
+ mCurr++;
+ mFreeSpace++;
+ if (mCurr >= mBufferEnd) {
+ mCurr = mBuffer;
+ }
+}
diff --git a/exynos4/hal/libsensors/InputEventReader.h b/exynos4/hal/libsensors/InputEventReader.h
new file mode 100644
index 0000000..180aade
--- /dev/null
+++ b/exynos4/hal/libsensors/InputEventReader.h
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_INPUT_EVENT_READER_H
+#define ANDROID_INPUT_EVENT_READER_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/*****************************************************************************/
+
+struct input_event;
+
+class InputEventCircularReader
+{
+ struct input_event* const mBuffer;
+ struct input_event* const mBufferEnd;
+ struct input_event* mHead;
+ struct input_event* mCurr;
+ ssize_t mFreeSpace;
+
+public:
+ InputEventCircularReader(size_t numEvents);
+ ~InputEventCircularReader();
+ ssize_t fill(int fd);
+ ssize_t readEvent(input_event const** events);
+ void next();
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_INPUT_EVENT_READER_H
diff --git a/exynos4/hal/libsensors/LightSensor.cpp b/exynos4/hal/libsensors/LightSensor.cpp
new file mode 100644
index 0000000..1d4f0e4
--- /dev/null
+++ b/exynos4/hal/libsensors/LightSensor.cpp
@@ -0,0 +1,160 @@
+/*
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <math.h>
+#include <poll.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+
+#include <linux/lightsensor.h>
+
+#include <cutils/log.h>
+
+#include "LightSensor.h"
+
+// #define LOG_NDEBUG 0
+
+/*****************************************************************************/
+
+LightSensor::LightSensor()
+ : SensorBase(NULL, "light_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_L;
+ mPendingEvent.type = SENSOR_TYPE_LIGHT;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+LightSensor::~LightSensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int LightSensor::setInitialState() {
+ struct input_absinfo absinfo;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_LIGHT), &absinfo)) {
+ // make sure to report an event immediately
+ mHasPendingEvent = true;
+ mPendingEvent.light = absinfo.value;
+ }
+ return 0;
+}
+
+int LightSensor::setDelay(int32_t handle, int64_t ns)
+{
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[80];
+ sprintf(buf, "%lld", ns);
+ write(fd, buf, strlen(buf)+1);
+ close(fd);
+ return 0;
+ }
+ return -1;
+}
+
+int LightSensor::enable(int32_t handle, int en)
+{
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ int err;
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ } else {
+ buf[0] = '0';
+ }
+ err = write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool LightSensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int LightSensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ ssize_t n = mInputReader.fill(data_fd);
+ if (n < 0)
+ return n;
+
+ int numEventReceived = 0;
+ input_event const* event;
+
+ while (count && mInputReader.readEvent(&event)) {
+ int type = event->type;
+ if (type == EV_ABS) {
+ if (event->code == EVENT_TYPE_LIGHT) {
+ if (event->value != -1) {
+ LOGV("LightSensor: event (value=%d)", event->value);
+ // FIXME: not sure why we're getting -1 sometimes
+ mPendingEvent.light = event->value;
+ }
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ *data++ = mPendingEvent;
+ count--;
+ numEventReceived++;
+ }
+ } else {
+ LOGE("LightSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+ return numEventReceived;
+}
diff --git a/exynos4/hal/libsensors/LightSensor.h b/exynos4/hal/libsensors/LightSensor.h
new file mode 100644
index 0000000..85e65d9
--- /dev/null
+++ b/exynos4/hal/libsensors/LightSensor.h
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_LIGHT_SENSOR_H
+#define ANDROID_LIGHT_SENSOR_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include "sensors.h"
+#include "SensorBase.h"
+#include "InputEventReader.h"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class LightSensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+
+ float indexToValue(size_t index) const;
+ int setInitialState();
+
+public:
+ LightSensor();
+ virtual ~LightSensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_LIGHT_SENSOR_H
diff --git a/exynos4/hal/libsensors/MODULE_LICENSE_APACHE2 b/exynos4/hal/libsensors/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/exynos4/hal/libsensors/MODULE_LICENSE_APACHE2
diff --git a/exynos4/hal/libsensors/ProximitySensor.cpp b/exynos4/hal/libsensors/ProximitySensor.cpp
new file mode 100644
index 0000000..46424a5
--- /dev/null
+++ b/exynos4/hal/libsensors/ProximitySensor.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <math.h>
+#include <poll.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+
+#include <linux/capella_cm3602.h>
+
+#include <cutils/log.h>
+
+#include "ProximitySensor.h"
+
+/*****************************************************************************/
+
+ProximitySensor::ProximitySensor()
+ : SensorBase(NULL, "proximity_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_P;
+ mPendingEvent.type = SENSOR_TYPE_PROXIMITY;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+ProximitySensor::~ProximitySensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int ProximitySensor::setInitialState() {
+ struct input_absinfo absinfo;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) {
+ // make sure to report an event immediately
+ mHasPendingEvent = true;
+ mPendingEvent.distance = indexToValue(absinfo.value);
+ }
+ return 0;
+}
+
+int ProximitySensor::enable(int32_t, int en) {
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ } else {
+ buf[0] = '0';
+ }
+ write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ setInitialState();
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool ProximitySensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int ProximitySensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ ssize_t n = mInputReader.fill(data_fd);
+ if (n < 0)
+ return n;
+
+ int numEventReceived = 0;
+ input_event const* event;
+
+ while (count && mInputReader.readEvent(&event)) {
+ int type = event->type;
+ if (type == EV_ABS) {
+ if (event->code == EVENT_TYPE_PROXIMITY) {
+ mPendingEvent.distance = indexToValue(event->value);
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ *data++ = mPendingEvent;
+ count--;
+ numEventReceived++;
+ }
+ } else {
+ LOGE("ProximitySensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+ return numEventReceived;
+}
+
+float ProximitySensor::indexToValue(size_t index) const
+{
+ LOGV("ProximitySensor: Index = %zu", index);
+ return index * PROXIMITY_THRESHOLD_CM;
+}
diff --git a/exynos4/hal/libsensors/ProximitySensor.h b/exynos4/hal/libsensors/ProximitySensor.h
new file mode 100644
index 0000000..08ea49c
--- /dev/null
+++ b/exynos4/hal/libsensors/ProximitySensor.h
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_PROXIMITY_SENSOR_H
+#define ANDROID_PROXIMITY_SENSOR_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include "sensors.h"
+#include "SensorBase.h"
+#include "InputEventReader.h"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class ProximitySensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+
+ int setInitialState();
+ float indexToValue(size_t index) const;
+
+public:
+ ProximitySensor();
+ virtual ~ProximitySensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_PROXIMITY_SENSOR_H
diff --git a/exynos4/hal/libsensors/SensorBase.cpp b/exynos4/hal/libsensors/SensorBase.cpp
new file mode 100644
index 0000000..d448eb2
--- /dev/null
+++ b/exynos4/hal/libsensors/SensorBase.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <math.h>
+#include <poll.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+
+#include <cutils/log.h>
+
+#include <linux/input.h>
+
+#include "SensorBase.h"
+
+/*****************************************************************************/
+
+SensorBase::SensorBase(
+ const char* dev_name,
+ const char* data_name)
+ : dev_name(dev_name), data_name(data_name),
+ dev_fd(-1), data_fd(-1)
+{
+ if (data_name) {
+ data_fd = openInput(data_name);
+ }
+}
+
+SensorBase::~SensorBase() {
+ if (data_fd >= 0) {
+ close(data_fd);
+ }
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ }
+}
+
+int SensorBase::open_device() {
+ if (dev_fd<0 && dev_name) {
+ dev_fd = open(dev_name, O_RDONLY);
+ LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno));
+ }
+ return 0;
+}
+
+int SensorBase::close_device() {
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ dev_fd = -1;
+ }
+ return 0;
+}
+
+int SensorBase::getFd() const {
+ if (!data_name) {
+ return dev_fd;
+ }
+ return data_fd;
+}
+
+int SensorBase::setDelay(int32_t handle, int64_t ns) {
+ return 0;
+}
+
+bool SensorBase::hasPendingEvents() const {
+ return false;
+}
+
+int64_t SensorBase::getTimestamp() {
+ struct timespec t;
+ t.tv_sec = t.tv_nsec = 0;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
+}
+
+int SensorBase::openInput(const char* inputName) {
+ int fd = -1;
+ const char *dirname = "/dev/input";
+ char devname[PATH_MAX];
+ char *filename;
+ DIR *dir;
+ struct dirent *de;
+ dir = opendir(dirname);
+ if(dir == NULL)
+ return -1;
+ strcpy(devname, dirname);
+ filename = devname + strlen(devname);
+ *filename++ = '/';
+ while((de = readdir(dir))) {
+ if(de->d_name[0] == '.' &&
+ (de->d_name[1] == '\0' ||
+ (de->d_name[1] == '.' && de->d_name[2] == '\0')))
+ continue;
+ strcpy(filename, de->d_name);
+ fd = open(devname, O_RDONLY);
+ if (fd>=0) {
+ char name[80];
+ if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
+ name[0] = '\0';
+ }
+ if (!strcmp(name, inputName)) {
+ strcpy(input_name, filename);
+ break;
+ } else {
+ close(fd);
+ fd = -1;
+ }
+ }
+ }
+ closedir(dir);
+ LOGE_IF(fd<0, "couldn't find '%s' input device", inputName);
+ return fd;
+}
diff --git a/exynos4/hal/libsensors/SensorBase.h b/exynos4/hal/libsensors/SensorBase.h
new file mode 100644
index 0000000..bb4d055
--- /dev/null
+++ b/exynos4/hal/libsensors/SensorBase.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_SENSOR_BASE_H
+#define ANDROID_SENSOR_BASE_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+
+/*****************************************************************************/
+
+struct sensors_event_t;
+
+class SensorBase {
+protected:
+ const char* dev_name;
+ const char* data_name;
+ char input_name[PATH_MAX];
+ int dev_fd;
+ int data_fd;
+
+ int openInput(const char* inputName);
+ static int64_t getTimestamp();
+
+
+ static int64_t timevalToNano(timeval const& t) {
+ return t.tv_sec*1000000000LL + t.tv_usec*1000;
+ }
+
+ int open_device();
+ int close_device();
+
+public:
+ SensorBase(
+ const char* dev_name,
+ const char* data_name);
+
+ virtual ~SensorBase();
+
+ virtual int readEvents(sensors_event_t* data, int count) = 0;
+ virtual bool hasPendingEvents() const;
+ virtual int getFd() const;
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled) = 0;
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_SENSOR_BASE_H
diff --git a/exynos4/hal/libsensors/ak8973b.h b/exynos4/hal/libsensors/ak8973b.h
new file mode 100644
index 0000000..9b7ab60
--- /dev/null
+++ b/exynos4/hal/libsensors/ak8973b.h
@@ -0,0 +1,51 @@
+/*
+ * Definitions for akm8973 compass chip.
+ */
+#ifndef AKM8973_H
+#define AKM8973_H
+
+#include <linux/ioctl.h>
+
+#define AKM8973_I2C_NAME "ak8973b"
+
+#define AKMIO 0xA1
+
+/* IOCTLs for AKM library */
+#define ECS_IOCTL_WRITE _IOW(AKMIO, 0x01, char*)
+#define ECS_IOCTL_READ _IOWR(AKMIO, 0x02, char*)
+#define ECS_IOCTL_RESET _IO(AKMIO, 0x03)
+#define ECS_IOCTL_SET_MODE _IOW(AKMIO, 0x04, short)
+#define ECS_IOCTL_GETDATA _IOR(AKMIO, 0x05, char[SENSOR_DATA_SIZE])
+#define ECS_IOCTL_SET_YPR _IOW(AKMIO, 0x06, short[12])
+#define ECS_IOCTL_GET_OPEN_STATUS _IOR(AKMIO, 0x07, int)
+#define ECS_IOCTL_GET_CLOSE_STATUS _IOR(AKMIO, 0x08, int)
+#define ECS_IOCTL_GET_DELAY _IOR(AKMIO, 0x30, int64_t)
+#define ECS_IOCTL_GET_PROJECT_NAME _IOR(AKMIO, 0x0D, char[64])
+#define ECS_IOCTL_GET_MATRIX _IOR(AKMIO, 0x0E, short [4][3][3])
+
+/* IOCTLs for APPs */
+#define ECS_IOCTL_APP_SET_MODE _IOW(AKMIO, 0x10, short)
+#define ECS_IOCTL_APP_SET_MFLAG _IOW(AKMIO, 0x11, short)
+#define ECS_IOCTL_APP_GET_MFLAG _IOW(AKMIO, 0x12, short)
+#define ECS_IOCTL_APP_SET_AFLAG _IOW(AKMIO, 0x13, short)
+#define ECS_IOCTL_APP_GET_AFLAG _IOR(AKMIO, 0x14, short)
+#define ECS_IOCTL_APP_SET_TFLAG _IOR(AKMIO, 0x15, short)
+#define ECS_IOCTL_APP_GET_TFLAG _IOR(AKMIO, 0x16, short)
+#define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17)
+#define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, int64_t)
+#define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
+
+/* Set raw magnetic vector flag */
+#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
+
+/* Get raw magnetic vector flag */
+#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
+
+struct akm8973_platform_data {
+ short layouts[4][3][3];
+ char project_name[64];
+ int gpio_RST;
+ int gpio_INT;
+};
+
+#endif
diff --git a/exynos4/hal/libsensors/sensors.cpp b/exynos4/hal/libsensors/sensors.cpp
new file mode 100644
index 0000000..6f0bdad
--- /dev/null
+++ b/exynos4/hal/libsensors/sensors.cpp
@@ -0,0 +1,326 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "Sensors"
+
+#include <hardware/sensors.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <math.h>
+#include <poll.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include <linux/input.h>
+
+#include <utils/Atomic.h>
+#include <utils/Log.h>
+
+#include "sensors.h"
+
+#include "LightSensor.h"
+#include "ProximitySensor.h"
+#include "AkmSensor.h"
+#include "GyroSensor.h"
+
+/*****************************************************************************/
+
+#define DELAY_OUT_TIME 0x7FFFFFFF
+
+#define LIGHT_SENSOR_POLLTIME 2000000000
+
+
+#define SENSORS_ACCELERATION (1<<ID_A)
+#define SENSORS_MAGNETIC_FIELD (1<<ID_M)
+#define SENSORS_ORIENTATION (1<<ID_O)
+#define SENSORS_LIGHT (1<<ID_L)
+#define SENSORS_PROXIMITY (1<<ID_P)
+#define SENSORS_GYROSCOPE (1<<ID_GY)
+
+#define SENSORS_ACCELERATION_HANDLE 0
+#define SENSORS_MAGNETIC_FIELD_HANDLE 1
+#define SENSORS_ORIENTATION_HANDLE 2
+#define SENSORS_LIGHT_HANDLE 3
+#define SENSORS_PROXIMITY_HANDLE 4
+#define SENSORS_GYROSCOPE_HANDLE 5
+
+#define AKM_FTRACE 0
+#define AKM_DEBUG 0
+#define AKM_DATA 0
+
+/*****************************************************************************/
+
+/* The SENSORS Module */
+static const struct sensor_t sSensorList[] = {
+ { "KR3DM 3-axis Accelerometer",
+ "STMicroelectronics",
+ 1, SENSORS_ACCELERATION_HANDLE,
+ SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_A, 0.23f, 20000, { } },
+ { "AK8975 3-axis Magnetic field sensor",
+ "Asahi Kasei Microdevices",
+ 1, SENSORS_MAGNETIC_FIELD_HANDLE,
+ SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, { } },
+ { "AK8973 Orientation sensor",
+ "Asahi Kasei Microdevices",
+ 1, SENSORS_ORIENTATION_HANDLE,
+ SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, { } },
+ { "CM3663 Light sensor",
+ "Capella Microsystems",
+ 1, SENSORS_LIGHT_HANDLE,
+ SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.75f, 0, { } },
+ { "CM3663 Proximity sensor",
+ "Capella Microsystems",
+ 1, SENSORS_PROXIMITY_HANDLE,
+ SENSOR_TYPE_PROXIMITY, 5.0f, 5.0f, 0.75f, 0, { } },
+ { "K3G Gyroscope sensor",
+ "STMicroelectronics",
+ 1, SENSORS_GYROSCOPE_HANDLE,
+ SENSOR_TYPE_GYROSCOPE, RANGE_GYRO, CONVERT_GYRO, 6.1f, 1190, { } },
+};
+
+
+static int open_sensors(const struct hw_module_t* module, const char* id,
+ struct hw_device_t** device);
+
+
+static int sensors__get_sensors_list(struct sensors_module_t* module,
+ struct sensor_t const** list)
+{
+ *list = sSensorList;
+ return ARRAY_SIZE(sSensorList);
+}
+
+static struct hw_module_methods_t sensors_module_methods = {
+ open: open_sensors
+};
+
+struct sensors_module_t HAL_MODULE_INFO_SYM = {
+ common: {
+ tag: HARDWARE_MODULE_TAG,
+ version_major: 1,
+ version_minor: 0,
+ id: SENSORS_HARDWARE_MODULE_ID,
+ name: "Samsung Sensor module",
+ author: "Samsung Electronic Company",
+ methods: &sensors_module_methods,
+ },
+ get_sensors_list: sensors__get_sensors_list,
+};
+
+struct sensors_poll_context_t {
+ struct sensors_poll_device_t device; // must be first
+
+ sensors_poll_context_t();
+ ~sensors_poll_context_t();
+ int activate(int handle, int enabled);
+ int setDelay(int handle, int64_t ns);
+ int pollEvents(sensors_event_t* data, int count);
+
+private:
+ enum {
+ light = 0,
+ proximity = 1,
+ akm = 2,
+ gyro = 3,
+ numSensorDrivers,
+ numFds,
+ };
+
+ static const size_t wake = numFds - 1;
+ static const char WAKE_MESSAGE = 'W';
+ struct pollfd mPollFds[numFds];
+ int mWritePipeFd;
+ SensorBase* mSensors[numSensorDrivers];
+
+ int handleToDriver(int handle) const {
+ switch (handle) {
+ case ID_A:
+ case ID_M:
+ case ID_O:
+ return akm;
+ case ID_P:
+ return proximity;
+ case ID_L:
+ return light;
+ case ID_GY:
+ return gyro;
+ }
+ return -EINVAL;
+ }
+};
+
+/*****************************************************************************/
+
+sensors_poll_context_t::sensors_poll_context_t()
+{
+ mSensors[light] = new LightSensor();
+ mPollFds[light].fd = mSensors[light]->getFd();
+ mPollFds[light].events = POLLIN;
+ mPollFds[light].revents = 0;
+
+ mSensors[proximity] = new ProximitySensor();
+ mPollFds[proximity].fd = mSensors[proximity]->getFd();
+ mPollFds[proximity].events = POLLIN;
+ mPollFds[proximity].revents = 0;
+
+ mSensors[akm] = new AkmSensor();
+ mPollFds[akm].fd = mSensors[akm]->getFd();
+ mPollFds[akm].events = POLLIN;
+ mPollFds[akm].revents = 0;
+
+ mSensors[gyro] = new GyroSensor();
+ mPollFds[gyro].fd = mSensors[gyro]->getFd();
+ mPollFds[gyro].events = POLLIN;
+ mPollFds[gyro].revents = 0;
+
+ int wakeFds[2];
+ int result = pipe(wakeFds);
+ LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno));
+ fcntl(wakeFds[0], F_SETFL, O_NONBLOCK);
+ fcntl(wakeFds[1], F_SETFL, O_NONBLOCK);
+ mWritePipeFd = wakeFds[1];
+
+ mPollFds[wake].fd = wakeFds[0];
+ mPollFds[wake].events = POLLIN;
+ mPollFds[wake].revents = 0;
+}
+
+sensors_poll_context_t::~sensors_poll_context_t() {
+ for (int i=0 ; i<numSensorDrivers ; i++) {
+ delete mSensors[i];
+ }
+ close(mPollFds[wake].fd);
+ close(mWritePipeFd);
+}
+
+int sensors_poll_context_t::activate(int handle, int enabled) {
+ int index = handleToDriver(handle);
+ if (index < 0) return index;
+ int err = mSensors[index]->enable(handle, enabled);
+ if (enabled && !err) {
+ const char wakeMessage(WAKE_MESSAGE);
+ int result = write(mWritePipeFd, &wakeMessage, 1);
+ LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno));
+ }
+ return err;
+}
+
+int sensors_poll_context_t::setDelay(int handle, int64_t ns) {
+
+ int index = handleToDriver(handle);
+ if (index < 0) return index;
+ return mSensors[index]->setDelay(handle, ns);
+}
+
+int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
+{
+ int nbEvents = 0;
+ int n = 0;
+
+ do {
+ // see if we have some leftover from the last poll()
+ for (int i=0 ; count && i<numSensorDrivers ; i++) {
+ SensorBase* const sensor(mSensors[i]);
+ if ((mPollFds[i].revents & POLLIN) || (sensor->hasPendingEvents())) {
+ int nb = sensor->readEvents(data, count);
+ if (nb < count) {
+ // no more data for this sensor
+ mPollFds[i].revents = 0;
+ }
+ count -= nb;
+ nbEvents += nb;
+ data += nb;
+ }
+ }
+
+ if (count) {
+ // we still have some room, so try to see if we can get
+ // some events immediately or just wait if we don't have
+ // anything to return
+ n = poll(mPollFds, numFds, nbEvents ? 0 : -1);
+ if (n<0) {
+ LOGE("poll() failed (%s)", strerror(errno));
+ return -errno;
+ }
+ if (mPollFds[wake].revents & POLLIN) {
+ char msg;
+ int result = read(mPollFds[wake].fd, &msg, 1);
+ LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno));
+ LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg));
+ mPollFds[wake].revents = 0;
+ }
+ }
+ // if we have events and space, go read them
+ } while (n && count);
+
+ return nbEvents;
+}
+
+/*****************************************************************************/
+
+static int poll__close(struct hw_device_t *dev)
+{
+ sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+ if (ctx) {
+ delete ctx;
+ }
+ return 0;
+}
+
+static int poll__activate(struct sensors_poll_device_t *dev,
+ int handle, int enabled) {
+ sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+ return ctx->activate(handle, enabled);
+}
+
+static int poll__setDelay(struct sensors_poll_device_t *dev,
+ int handle, int64_t ns) {
+ sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+ return ctx->setDelay(handle, ns);
+}
+
+static int poll__poll(struct sensors_poll_device_t *dev,
+ sensors_event_t* data, int count) {
+ sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+ return ctx->pollEvents(data, count);
+}
+
+/*****************************************************************************/
+
+/** Open a new instance of a sensor device using name */
+static int open_sensors(const struct hw_module_t* module, const char* id,
+ struct hw_device_t** device)
+{
+ int status = -EINVAL;
+ sensors_poll_context_t *dev = new sensors_poll_context_t();
+
+ memset(&dev->device, 0, sizeof(sensors_poll_device_t));
+
+ dev->device.common.tag = HARDWARE_DEVICE_TAG;
+ dev->device.common.version = 0;
+ dev->device.common.module = const_cast<hw_module_t*>(module);
+ dev->device.common.close = poll__close;
+ dev->device.activate = poll__activate;
+ dev->device.setDelay = poll__setDelay;
+ dev->device.poll = poll__poll;
+
+ *device = &dev->device.common;
+ status = 0;
+
+ return status;
+}
+
diff --git a/exynos4/hal/libsensors/sensors.h b/exynos4/hal/libsensors/sensors.h
new file mode 100644
index 0000000..ecc6fed
--- /dev/null
+++ b/exynos4/hal/libsensors/sensors.h
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_SENSORS_H
+#define ANDROID_SENSORS_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <linux/input.h>
+
+#include <hardware/hardware.h>
+#include <hardware/sensors.h>
+
+__BEGIN_DECLS
+
+/*****************************************************************************/
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define ID_A (0)
+#define ID_M (1)
+#define ID_O (2)
+#define ID_L (3)
+#define ID_P (4)
+#define ID_GY (5)
+
+/*****************************************************************************/
+
+/*
+ * The SENSORS Module
+ */
+
+/* the CM3663 is a binary proximity sensor that triggers around 6 cm on
+ * this hardware */
+#define PROXIMITY_THRESHOLD_CM 6.0f
+
+/*****************************************************************************/
+
+#define AKM_DEVICE_NAME "/dev/akm8975"
+#define CM_DEVICE_NAME "/dev/i2c11" // FIXME Proximity
+#define LS_DEVICE_NAME "/dev/i2c11" // FIXME Lig
+
+/*
+ E/Sensors ( 2656): AkmSensor: processing event (type=0, code=0)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=8)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=3)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=4)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=5)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=0)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=1)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=2)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=6)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=7)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=9)
+ E/Sensors ( 2656): AkmSensor: processing event (type=0, code=0)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=8)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=3)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=4)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=5)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=0)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=1)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=2)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=6)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=7)
+ E/Sensors ( 2656): AkmSensor: processing event (type=2, code=9)
+*/
+
+// for akm8975
+#define EVENT_TYPE_ACCEL_X ABS_Y //1
+#define EVENT_TYPE_ACCEL_Y ABS_X //0
+#define EVENT_TYPE_ACCEL_Z ABS_Z //2
+//#define EVENT_TYPE_ACCEL_STATUS ABS_WHEEL //8
+
+#define EVENT_TYPE_YAW ABS_RX //3
+#define EVENT_TYPE_PITCH ABS_RY //4
+#define EVENT_TYPE_ROLL ABS_RZ //5
+#define EVENT_TYPE_ORIENT_STATUS ABS_WHEEL //8
+
+#define EVENT_TYPE_MAGV_X ABS_RUDDER // 6
+#define EVENT_TYPE_MAGV_Y ABS_THROTTLE // 7
+#define EVENT_TYPE_MAGV_Z ABS_GAS // 9
+
+#define EVENT_TYPE_TEMPERATURE ABS_THROTTLE
+#define EVENT_TYPE_STEP_COUNT ABS_GAS
+#define EVENT_TYPE_PROXIMITY ABS_DISTANCE
+#define EVENT_TYPE_LIGHT ABS_MISC
+
+#define EVENT_TYPE_GYRO_X REL_RY
+#define EVENT_TYPE_GYRO_Y REL_RX
+#define EVENT_TYPE_GYRO_Z REL_RZ
+
+// 90 LSB = 1G for KR3DM
+#define LSB (90.0f)
+#define NUMOFACCDATA (8.0f)
+
+// conversion of acceleration data to SI units (m/s^2)
+#define RANGE_A (2*GRAVITY_EARTH)
+#define CONVERT_A (GRAVITY_EARTH / LSB / NUMOFACCDATA)
+#define CONVERT_A_X (CONVERT_A)
+#define CONVERT_A_Y (-CONVERT_A)
+#define CONVERT_A_Z (-CONVERT_A)
+
+// conversion of magnetic data to uT units
+#define CONVERT_M (1.0f/16.0f)
+#define CONVERT_M_X (CONVERT_M)
+#define CONVERT_M_Y (-CONVERT_M)
+#define CONVERT_M_Z (CONVERT_M)
+
+/* conversion of orientation data to degree units */
+#define CONVERT_O (1.0f/64.0f)
+#define CONVERT_O_A (CONVERT_O)
+#define CONVERT_O_P (CONVERT_O)
+#define CONVERT_O_R (-CONVERT_O)
+
+// conversion of gyro data to SI units (radian/sec)
+#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f)
+#define CONVERT_GYRO ((70.0f / 1000.0f) * ((float)M_PI / 180.0f))
+#define CONVERT_GYRO_X (CONVERT_GYRO)
+#define CONVERT_GYRO_Y (-CONVERT_GYRO)
+#define CONVERT_GYRO_Z (CONVERT_GYRO)
+
+#define SENSOR_STATE_MASK (0x7FFF)
+
+/*****************************************************************************/
+
+__END_DECLS
+
+#endif // ANDROID_SENSORS_H
diff --git a/exynos4/hal/libswconverter/Android.mk b/exynos4/hal/libswconverter/Android.mk
new file mode 100644
index 0000000..ce6daf4
--- /dev/null
+++ b/exynos4/hal/libswconverter/Android.mk
@@ -0,0 +1,44 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ swconvertor.c \
+ csc_linear_to_tiled_crop_neon.s \
+ csc_linear_to_tiled_interleave_crop_neon.s \
+ csc_tiled_to_linear_crop_neon.s \
+ csc_tiled_to_linear_deinterleave_crop_neon.s \
+ csc_interleave_memcpy_neon.s
+
+LOCAL_C_INCLUDES := \
+ $(TOP)/$(BOARD_HMM_PATH)/openmax/include/khronos \
+ $(TOP)/$(BOARD_HMM_PATH)/openmax/include/sec \
+ $(TOP)/$(BOARD_HAL_PATH)/include \
+ $(TOP)/$(BOARD_HAL_PATH)/libhwconverter
+
+ifeq ($(BOARD_USE_SAMSUNG_COLORFORMAT), true)
+LOCAL_CFLAGS += -DUSE_SAMSUNG_COLORFORMAT
+endif
+
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := libswconverter
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_ARM_MODE := arm
+
+LOCAL_SHARED_LIBRARIES := liblog libfimc libhwconverter
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos4/hal/libswconverter/csc_interleave_memcpy_neon.s b/exynos4/hal/libswconverter/csc_interleave_memcpy_neon.s
new file mode 100644
index 0000000..1ab25b6
--- /dev/null
+++ b/exynos4/hal/libswconverter/csc_interleave_memcpy_neon.s
@@ -0,0 +1,120 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file csc_linear_to_tiled_crop_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+/*
+ * Interleave src1, src2 to dst
+ *
+ * @param dest
+ * dst address[out]
+ *
+ * @param src1
+ * src1 address[in]
+ *
+ * @param src2
+ * src2 address[in]
+ *
+ * @param src_size
+ * src_size or src1
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_interleave_memcpy_neon
+ .type csc_interleave_memcpy_neon, %function
+csc_interleave_memcpy_neon:
+ .fnstart
+
+ @r0 dest
+ @r1 src1
+ @r2 src2
+ @r3 src_size
+ @r4
+ @r5
+ @r6
+ @r7
+ @r8 temp1
+ @r9 temp2
+ @r10 dest_addr
+ @r11 src1_addr
+ @r12 src2_addr
+ @r14 i
+
+ stmfd sp!, {r8-r12,r14} @ backup registers
+
+ mov r10, r0
+ mov r11, r1
+ mov r12, r2
+ mov r14, r3
+
+ cmp r14, #128
+ blt LESS_THAN_128
+
+LOOP_128:
+ vld1.8 {q0}, [r11]!
+ vld1.8 {q2}, [r11]!
+ vld1.8 {q4}, [r11]!
+ vld1.8 {q6}, [r11]!
+ vld1.8 {q8}, [r11]!
+ vld1.8 {q10}, [r11]!
+ vld1.8 {q12}, [r11]!
+ vld1.8 {q14}, [r11]!
+ vld1.8 {q1}, [r12]!
+ vld1.8 {q3}, [r12]!
+ vld1.8 {q5}, [r12]!
+ vld1.8 {q7}, [r12]!
+ vld1.8 {q9}, [r12]!
+ vld1.8 {q11}, [r12]!
+ vld1.8 {q13}, [r12]!
+ vld1.8 {q15}, [r12]!
+
+ vst2.8 {q0, q1}, [r10]!
+ vst2.8 {q2, q3}, [r10]!
+ vst2.8 {q4, q5}, [r10]!
+ vst2.8 {q6, q7}, [r10]!
+ vst2.8 {q8, q9}, [r10]!
+ vst2.8 {q10, q11}, [r10]!
+ vst2.8 {q12, q13}, [r10]!
+ vst2.8 {q14, q15}, [r10]!
+
+ sub r14, #128
+ cmp r14, #128
+ bgt LOOP_128
+
+LESS_THAN_128:
+ cmp r14, #0
+ beq RESTORE_REG
+
+LOOP_1:
+ ldrb r8, [r11], #1
+ ldrb r9, [r12], #1
+ strb r8, [r10], #1
+ strb r9, [r10], #1
+ subs r14, #1
+ bne LOOP_1
+
+RESTORE_REG:
+ ldmfd sp!, {r8-r12,r15} @ restore registers
+ .fnend
diff --git a/exynos4/hal/libswconverter/csc_linear_to_tiled_crop_neon.s b/exynos4/hal/libswconverter/csc_linear_to_tiled_crop_neon.s
new file mode 100644
index 0000000..8f59826
--- /dev/null
+++ b/exynos4/hal/libswconverter/csc_linear_to_tiled_crop_neon.s
@@ -0,0 +1,492 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file csc_linear_to_tiled_crop_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+/*
+ * Converts linear data to tiled
+ * Crops left, top, right, buttom
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left. It should be even.
+ *
+ * @param top
+ * Crop size of top. It should be even.
+ *
+ * @param right
+ * Crop size of right. It should be even.
+ *
+ * @param buttom
+ * Crop size of buttom. It should be even.
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_linear_to_tiled_crop_neon
+ .type csc_linear_to_tiled_crop_neon, %function
+csc_linear_to_tiled_crop_neon:
+ .fnstart
+
+ @r0 tiled_dest
+ @r1 linear_src
+ @r2 yuv420_width
+ @r3 yuv420_height
+ @r4 j
+ @r5 i
+ @r6 nn(tiled_addr)
+ @r7 mm(linear_addr)
+ @r8 aligned_x_size
+ @r9 aligned_y_size
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r11, [sp, #44] @ top
+ ldr r14, [sp, #52] @ buttom
+ ldr r10, [sp, #40] @ left
+ ldr r12, [sp, #48] @ right
+
+ sub r9, r3, r11 @ aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5
+ sub r9, r9, r14
+ bic r9, r9, #0x1F
+
+ sub r8, r2, r10 @ aligned_x_size = ((yuv420_width-left-right)>>6)<<6
+ sub r8, r8, r12
+ bic r8, r8, #0x3F
+
+ mov r5, #0 @ i = 0
+LOOP_ALIGNED_Y_SIZE:
+
+ mov r4, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE:
+
+ bl GET_TILED_OFFSET
+
+ ldr r10, [sp, #44] @ r10 = top
+ ldr r14, [sp, #40] @ r14 = left
+ add r10, r5, r10 @ temp1 = linear_x_size*(i+top)
+ mul r10, r2, r10
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ add r7, r7, r14 @ linear_addr = linear_addr+left
+ sub r10, r2, #32
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*1, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*2, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*3, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*1}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*2}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*3}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*4, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*5, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*6, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*7, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*4}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*5}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*6}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*7}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*8, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*9, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*10, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*11, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*8}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*9}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*10}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*11}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*12, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*13, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*14, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*15, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*12}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*13}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*14}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*15}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*16, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*17, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*18, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*19, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*16}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*17}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*18}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*19}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*20, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*21, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*22, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*23, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*20}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*21}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*22}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*23}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*24, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*25, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*26, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*27, 64}
+ pld [r7, r2]
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*24}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*25}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*26}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*27}
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src+linear_x_size*28, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*29, 64}
+ pld [r7, r2]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2]
+ vld1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*30, 64}
+ pld [r7, r2]
+ vld1.8 {q10, q11}, [r7], r10
+ vld1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*31, 64}
+ vld1.8 {q14, q15}, [r7], r10
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr+64*28}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*29}
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*30}
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*31}
+ vst1.8 {q14, q15}, [r6]!
+
+ add r4, r4, #64 @ j = j+64
+ cmp r4, r8 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE
+
+ add r5, r5, #32 @ i = i+32
+ cmp r5, r9 @ i<aligned_y_size
+ blt LOOP_ALIGNED_Y_SIZE
+
+ ldr r10, [sp, #44] @ r10 = top
+ ldr r11, [sp, #52] @ r11 = buttom
+ sub r10, r3, r10
+ sub r10, r10, r11
+ cmp r5, r10 @ i == (yuv420_height-top-buttom)
+ beq LOOP_LINEAR_Y_SIZE_2_START
+
+LOOP_LINEAR_Y_SIZE_1:
+
+ mov r4, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE_1:
+
+ bl GET_TILED_OFFSET
+
+ ldr r10, [sp, #44] @ r10 = top
+ ldr r14, [sp, #40] @ r14 = left
+ add r10, r5, r10 @ temp1 = yuv420_width*(i+top)
+ mul r10, r2, r10
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ add r7, r7, r14 @ linear_addr = linear_addr+left
+ sub r10, r2, #32 @ temp1 = yuv420_width-32
+
+ pld [r7, r2]
+ vld1.8 {q0, q1}, [r7]! @ load {linear_src, 64}
+ pld [r7, r2]
+ vld1.8 {q2, q3}, [r7], r10
+ vld1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*1, 64}
+ vld1.8 {q6, q7}, [r7]
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+ and r10, r5, #0x1F @ temp1 = i&0x1F
+ mov r10, r10, lsl #6 @ temp1 = 64*temp1
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp1
+ vst1.8 {q0, q1}, [r6]! @ store {tiled_addr}
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*1}
+ vst1.8 {q6, q7}, [r6]!
+
+ add r4, r4, #64 @ j = j+64
+ cmp r4, r8 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE_1
+
+ add r5, r5, #2 @ i = i+2
+ ldr r10, [sp, #44] @ r10 = top
+ ldr r14, [sp, #52] @ r14 = buttom
+ sub r10, r3, r10
+ sub r10, r10, r14
+ cmp r5, r10 @ i<yuv420_height-top-buttom
+ blt LOOP_LINEAR_Y_SIZE_1
+
+LOOP_LINEAR_Y_SIZE_2_START:
+ ldr r10, [sp, #40] @ r10 = left
+ ldr r11, [sp, #48] @ r11 = right
+ sub r10, r2, r10
+ sub r10, r10, r11
+ cmp r8, r10 @ aligned_x_size == (yuv420_width-left-right)
+ beq RESTORE_REG
+
+ mov r5, #0 @ i = 0
+LOOP_LINEAR_Y_SIZE_2:
+
+ mov r4, r8 @ j = aligned_x_size
+LOOP_LINEAR_X_SIZE_2:
+
+ bl GET_TILED_OFFSET
+
+ ldr r10, [sp, #44] @ r14 = top
+ ldr r14, [sp, #40] @ r10 = left
+ add r10, r5, r10
+ mul r10, r2, r10 @ temp1 = linear_x_size*(i+top)
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ add r7, r7, r14 @ linear_addr = linear_addr+left
+
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+ and r11, r5, #0x1F @ temp2 = i&0x1F
+ mov r11, r11, lsl #6 @ temp2 = 64*temp2
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+ and r11, r4, #0x3F @ temp2 = j&0x3F
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+
+ ldrh r10, [r7], r2
+ ldrh r11, [r7]
+ strh r10, [r6], #64
+ strh r11, [r6]
+
+ ldr r12, [sp, #40] @ r12 = left
+ ldr r14, [sp, #48] @ r14 = right
+ add r4, r4, #2 @ j = j+2
+ sub r12, r2, r12
+ sub r12, r12, r14
+ cmp r4, r12 @ j<(yuv420_width-left-right)
+ blt LOOP_LINEAR_X_SIZE_2
+
+ ldr r12, [sp, #44] @ r12 = top
+ ldr r14, [sp, #52] @ r14 = buttom
+ add r5, r5, #2 @ i = i+2
+ sub r12, r3, r12
+ sub r12, r12, r14
+ cmp r5, r12 @ i<(yuv420_height-top-buttom)
+ blt LOOP_LINEAR_Y_SIZE_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+
+ mov r11, r5, asr #5 @ temp2 = i>>5
+ mov r10, r4, asr #6 @ temp1 = j>>6
+
+ and r12, r11, #0x1 @ if (temp2 & 0x1)
+ cmp r12, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+ sub r6, r11, #1 @ tiled_addr = temp2-1
+
+ ldr r7, [sp, #40] @ left
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ sub r12, r12, r7
+ ldr r7, [sp, #48] @ right
+ sub r12, r12, r7
+ bic r12, r12, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r6, r12 @ tiled_addr = tiled_addr*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp1
+ add r6, r6, #2 @ tiled_addr = tiled_addr+2
+ bic r12, r10, #0x3 @ temp3 = (temp1>>2)<<2
+ add r6, r6, r12 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ ldr r7, [sp, #44] @ top
+ add r12, r3, #31 @ temp3 = linear_y_size+31
+ sub r12, r12, r7
+ ldr r7, [sp, #52] @ buttom
+ sub r12, r12, r7
+ bic r12, r12, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r12, r12, #32 @ temp3 = temp3 - 32
+ cmp r5, r12 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r12, r10, #2 @ temp3 = temp1+2
+ bic r12, r12, #3 @ temp3 = (temp3>>2)<<2
+ add r6, r10, r12 @ tiled_addr = temp1+temp3
+ ldr r7, [sp, #40] @ left
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ sub r12, r12, r7
+ ldr r7, [sp, #48] @ right
+ sub r12, r12, r7
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r11, r11, r12 @ tiled_y_index = tiled_y_index*temp3
+ add r6, r6, r11 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r6, r6, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ ldr r7, [sp, #40] @ left
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ sub r12, r12, r7
+ ldr r7, [sp, #48] @ right
+ sub r12, r12, r7
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r11, r12 @ tiled_addr = temp2*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ mov pc, lr
+
+ .fnend
diff --git a/exynos4/hal/libswconverter/csc_linear_to_tiled_interleave_crop_neon.s b/exynos4/hal/libswconverter/csc_linear_to_tiled_interleave_crop_neon.s
new file mode 100644
index 0000000..33a31da
--- /dev/null
+++ b/exynos4/hal/libswconverter/csc_linear_to_tiled_interleave_crop_neon.s
@@ -0,0 +1,563 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file csc_linear_to_tiled_interleave_crop_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+/*
+ * Converts tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left. It should be even.
+ *
+ * @param top
+ * Crop size of top. It should be even.
+ *
+ * @param right
+ * Crop size of right. It should be even.
+ *
+ * @param buttom
+ * Crop size of buttom. It should be even.
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_linear_to_tiled_interleave_crop_neon
+ .type csc_linear_to_tiled_interleave_crop_neon, %function
+csc_linear_to_tiled_interleave_crop_neon:
+ .fnstart
+
+ @r0 tiled_dest
+ @r1 linear_src_u
+ @r2 linear_src_v
+ @r3 yuv420_width
+ @r4 yuv420_height
+ @r5 j
+ @r6 i
+ @r7 tiled_addr
+ @r8 linear_addr
+ @r9 aligned_x_size
+ @r10 aligned_y_size
+ @r11 temp1
+ @r12 temp2
+ @r14 temp3
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r4, [sp, #40] @ load linear_y_size to r4
+
+ ldr r10, [sp, #48] @ r10 = top
+ ldr r14, [sp, #56] @ r14 = buttom
+ ldr r11, [sp, #44] @ r11 = left
+ ldr r12, [sp, #52] @ r12 = right
+
+ sub r10, r4, r10 @ aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5
+ sub r10, r10, r14
+ bic r10, r10, #0x1F
+ sub r11, r3, r11 @ aligned_x_size = ((yuv420_width-left-right)>>6)<<6
+ sub r11, r11, r12
+ bic r9, r11, #0x3F
+
+ mov r6, #0 @ i = 0
+LOOP_ALIGNED_Y_SIZE:
+
+ mov r5, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE:
+
+ bl GET_TILED_OFFSET
+
+ ldr r12, [sp, #48] @ r12 = top
+ ldr r8, [sp, #44] @ r8 = left
+
+ mov r11, r3, asr #1 @ temp1 = (yuv420_width/2)*(i+top)
+ add r12, r6, r12
+ mul r11, r11, r12
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ add r11, r11, r8, asr #1 @ temp1 = temp1+left/2
+
+ mov r12, r3, asr #1 @ temp2 = yuv420_width/2
+ sub r12, r12, #16 @ temp2 = yuv420_width-16
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*1, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*2, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*3, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*1, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*2, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*3, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*1}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*2}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*3}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*4, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*5, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*6, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*7, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*4, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*5, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*6, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*7, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*4}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*5}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*6}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*7}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*8, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*9, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*10, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*11, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*8, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*9, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*10, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*11, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*8}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*9}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*10}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*11}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*12, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*13, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*14, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*15, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*12, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*13, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*14, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*15, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*12}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*13}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*14}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*15}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*16, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*17, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*18, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*19, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*16, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*17, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*18, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*19, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*16}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*17}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*18}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*19}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*20, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*21, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*22, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*23, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*20, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*21, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*22, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*23, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*20}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*21}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*22}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*23}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*24, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*25, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*26, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*27, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*24, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*25, 32}
+ vld1.8 {q7}, [r11], r12
+ pld [r8]
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*26, 32}
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3, asr #1]
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*27, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*24}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*25}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*26}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*27}
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]! @ load {linear_src_u+(linear_x_size/2)*28, 32}
+ vld1.8 {q2}, [r8], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]! @ load {linear_src_u+(linear_x_size/2)*29, 32}
+ vld1.8 {q6}, [r8], r12
+ pld [r11]
+ vld1.8 {q8}, [r8]! @ load {linear_src_u+(linear_x_size/2)*30, 32}
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3, asr #1]
+ vld1.8 {q12}, [r8]! @ load {linear_src_u+(linear_x_size/2)*31, 32}
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v+(linear_x_size/2)*28, 32}
+ vld1.8 {q3}, [r11], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]! @ load {linear_src_v+(linear_x_size/2)*29, 32}
+ vld1.8 {q7}, [r11], r12
+ vld1.8 {q9}, [r11]! @ load {linear_src_v+(linear_x_size/2)*30, 32}
+ vld1.8 {q11}, [r11], r12
+ vld1.8 {q13}, [r11]! @ load {linear_src_v+(linear_x_size/2)*31, 32}
+ vld1.8 {q15}, [r11], r12
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr+64*28}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*29}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*30}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*31}
+ vst2.8 {q14, q15}, [r7]!
+
+ add r5, r5, #64 @ j = j+64
+ cmp r5, r9 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE
+
+ add r6, r6, #32 @ i = i+32
+ cmp r6, r10 @ i<aligned_y_size
+ blt LOOP_ALIGNED_Y_SIZE
+
+ cmp r6, r4
+ beq LOOP_LINEAR_Y_SIZE_2_START
+
+LOOP_LINEAR_Y_SIZE_1:
+
+ mov r5, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE_1:
+
+ bl GET_TILED_OFFSET
+
+ ldr r12, [sp, #48] @ r12 = top
+ ldr r8, [sp, #44] @ r8 = left
+
+ mov r11, r3, asr #1 @ temp1 = (yuv420_width/2)*(i+top)
+ add r12, r6, r12
+ mul r11, r11, r12
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ add r11, r11, r8, asr #1 @ temp1 = temp1+left/2
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+ and r14, r6, #0x1F @ temp3 = i&0x1F@
+ mov r14, r14, lsl #6 @ temp3 = temp3*64
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+
+ vld1.8 {q0}, [r8]! @ load {linear_src_u, 32}
+ vld1.8 {q2}, [r8]
+ vld1.8 {q1}, [r11]! @ load {linear_src_v, 32}
+ vld1.8 {q3}, [r11]
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr}
+ vst2.8 {q2, q3}, [r7]!
+
+ add r5, r5, #64 @ j = j+64
+ cmp r5, r9 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE_1
+
+ ldr r12, [sp, #48] @ r12 = top
+ ldr r8, [sp, #56] @ r8 = buttom
+ add r6, r6, #1 @ i = i+1
+ sub r12, r4, r12
+ sub r12, r12, r8
+ cmp r6, r12 @ i<(yuv420_height-top-buttom)
+ blt LOOP_LINEAR_Y_SIZE_1
+
+LOOP_LINEAR_Y_SIZE_2_START:
+ cmp r5, r3
+ beq RESTORE_REG
+
+ mov r6, #0 @ i = 0
+LOOP_LINEAR_Y_SIZE_2:
+
+ mov r5, r9 @ j = aligned_x_size
+LOOP_LINEAR_X_SIZE_2:
+
+ bl GET_TILED_OFFSET
+
+ ldr r12, [sp, #48] @ r12 = top
+ ldr r8, [sp, #44] @ r8 = left
+
+ mov r11, r3, asr #1 @ temp1 = (yuv420_width/2)*(i+top)
+ add r12, r6, r12
+ mul r11, r11, r12
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ add r11, r11, r8, asr #1 @ temp1 = temp1+left/2
+
+ mov r12, r3, asr #1 @ temp2 = linear_x_size/2
+ sub r12, r12, #1 @ temp2 = linear_x_size-1
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+ and r14, r6, #0x1F @ temp3 = i&0x1F@
+ mov r14, r14, lsl #6 @ temp3 = temp3*64
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ and r14, r5, #0x3F @ temp3 = j&0x3F
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+
+ ldrb r10, [r8], #1
+ ldrb r14, [r11], #1
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #2
+
+ ldr r12, [sp, #44] @ r12 = left
+ ldr r8, [sp, #52] @ r8 = right
+ add r5, r5, #2 @ j = j+2
+ sub r12, r3, r12
+ sub r12, r12, r8
+ cmp r5, r12 @ j<(yuv420_width-left-right)
+ blt LOOP_LINEAR_X_SIZE_2
+
+ ldr r12, [sp, #48] @ r12 = top
+ ldr r8, [sp, #56] @ r8 = buttom
+ add r6, r6, #1 @ i = i+1
+ sub r12, r4, r12
+ sub r12, r12, r8
+ cmp r6, r12 @ i<(yuv420_height-top-buttom)
+ blt LOOP_LINEAR_Y_SIZE_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+ stmfd sp!, {r14}
+
+ mov r12, r6, asr #5 @ temp2 = i>>5
+ mov r11, r5, asr #6 @ temp1 = j>>6
+
+ and r14, r12, #0x1 @ if (temp2 & 0x1)
+ cmp r14, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+
+ ldr r7, [sp, #48] @ r7 = left , (r14 was pushed to stack)
+ ldr r8, [sp, #56] @ r8 = right , (r14 was pushed to stack)
+ sub r14, r3, r7
+ sub r14, r14, r8
+ add r14, r14, #127 @ temp3 = (((yuv420_width-left-right)+127)>>7)<<7
+ bic r14, r14, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ sub r7, r12, #1 @ tiled_addr = temp2-1
+ mul r7, r7, r14 @ tiled_addr = tiled_addr*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp1
+ add r7, r7, #2 @ tiled_addr = tiled_addr+2
+ bic r14, r11, #0x3 @ temp3 = (temp1>>2)<<2
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ ldr r7, [sp, #52] @ r7 = top, (r14 was pushed to stack)
+ ldr r8, [sp, #60] @ r8 = buttom, (r14 was pushed to stack)
+ sub r14, r4, r7
+ sub r14, r14, r8
+ add r14, r14, #31 @ temp3 = (((yuv420_height-top-buttom)+31)>>5)<<5
+ bic r14, r14, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r14, r14, #32 @ temp3 = temp3 - 32
+ cmp r6, r14 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r14, r11, #2 @ temp3 = temp1+2
+ bic r14, r14, #3 @ temp3 = (temp3>>2)<<2
+ add r7, r11, r14 @ tiled_addr = temp1+temp3
+ ldr r8, [sp, #48] @ r8 = left, (r14 was pushed to stack)
+ sub r14, r3, r8
+ ldr r8, [sp, #56] @ r8 = right, (r14 was pushed to stack)
+ sub r14, r14, r8
+ add r14, r14, #127 @ temp3 = (((yuv420_width-left-right)+127)>>7)<<7
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r12, r12, r14 @ tiled_y_index = tiled_y_index*temp3
+ add r7, r7, r12 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r7, r7, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ ldr r8, [sp, #48] @ r8 = left, (r14 was pushed to stack)
+ sub r14, r3, r8
+ ldr r8, [sp, #56] @ r8 = right, (r14 was pushed to stack)
+ sub r14, r14, r8
+ add r14, r14, #127 @ temp3 = (((yuv420_width-left-right)+127)>>7)<<7
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r7, r12, r14 @ tiled_addr = temp2*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ ldmfd sp!, {r15} @ restore registers
+
+ .fnend
+
diff --git a/exynos4/hal/libswconverter/csc_tiled_to_linear_crop_neon.s b/exynos4/hal/libswconverter/csc_tiled_to_linear_crop_neon.s
new file mode 100644
index 0000000..9cb81b5
--- /dev/null
+++ b/exynos4/hal/libswconverter/csc_tiled_to_linear_crop_neon.s
@@ -0,0 +1,701 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file csc_tiled_to_linear_crop_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+/*
+ * Converts tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left. It should be even.
+ *
+ * @param top
+ * Crop size of top. It should be even.
+ *
+ * @param right
+ * Crop size of right. It should be even.
+ *
+ * @param buttom
+ * Crop size of buttom. It should be even.
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_tiled_to_linear_crop_neon
+ .type csc_tiled_to_linear_crop_neon, %function
+csc_tiled_to_linear_crop_neon:
+ .fnstart
+
+ @r0 yuv420_dest
+ @r1 nv12t_src
+ @r2 yuv420_width
+ @r3 yuv420_height
+ @r4
+ @r5 i
+ @r6 j
+ @r7 tiled_offset
+ @r8 tiled_offset1
+ @r9 linear_offset
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r12, [sp, #48] @ r12 = right
+ ldr r10, [sp, #40] @ r10 = left
+ sub r12, r2, r12 @ temp3 = yuv420_width-right@
+ sub r10, r12, r10 @ temp1 = temp3-left@
+ cmp r10, #256 @ if (temp1 >= 256)
+ blt LOOP_HEIGHT_64_START
+
+ ldr r5, [sp, #44] @ i = top
+LOOP_HEIGHT_256:
+ ldr r6, [sp, #40] @ j = left
+ mov r14, r5, asr #5 @ temp4 = i>>5
+ bic r12, r6, #0xFF @ temp3 = (j>>8)<<8
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ and r11, r14, #0x1 @ if (temp4 & 0x1)
+ cmp r11, #0x1
+ bne LOOP_HEIGHT_256_GET_TILED_EVEN
+LOOP_HEIGHT_256_GET_TILED_ODD:
+ sub r7, r14, #1 @ tiled_offset = temp4-1
+ add r10, r2, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)
+ mul r7, r7, r10
+ add r7, r7, r12 @ tiled_offset = tiled_offset+temp3
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2
+ bic r10, r12, #0x3 @ temp1 = (temp3>>2)<<2
+ add r7, r7, r10 @ tiled_offset = tiled_offset+temp1
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #4096 @ tiled_offset1 = tiled_offset+2048*2
+ mov r14, #8
+ b LOOP_HEIGHT_256_GET_TILED_END
+
+LOOP_HEIGHT_256_GET_TILED_EVEN:
+ add r11, r3, #31 @ temp2 = ((yuv420_height+31)>>5)<<5
+ bic r11, r11, #0x1F
+ add r10, r5, #32 @ if ((i+32)<temp2)
+ cmp r10, r11
+ bge LOOP_HEIGHT_256_GET_TILED_EVEN1
+ add r10, r12, #2 @ temp1 = temp3+2
+ bic r10, r10, #0x3 @ temp1 = (temp1>>2)<<2
+ add r7, r12, r10 @ tiled_offset = temp3+temp1@
+ add r10, r2, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset+temp4*(temp1>>6)
+ mla r7, r14, r10, r7
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #12288 @ tiled_offset1 = tiled_offset+2048*6
+ mov r14, #8
+ b LOOP_HEIGHT_256_GET_TILED_END
+
+LOOP_HEIGHT_256_GET_TILED_EVEN1:
+ add r10, r2, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = temp4*(temp1>>6)
+ mul r7, r14, r10
+ add r7, r7, r12 @ tiled_offset = tiled_offset+temp3
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #4096 @ tiled_offset1 = tiled_offset+2048*2
+ mov r14, #4
+
+LOOP_HEIGHT_256_GET_TILED_END:
+
+ ldr r12, [sp, #48] @ right
+ ldr r9, [sp, #44] @ top
+ and r10, r5, #0x1F @ temp1 = i&0x1F
+ add r7, r7, r10, lsl #6 @ tiled_offset = tiled_offset+64*(temp1)
+ add r8, r8, r10, lsl #6 @ tiled_offset1 = tiled_offset1+64*(temp1)
+ sub r11, r2, r6 @ temp2 = yuv420_width-left(==j)-right
+ sub r11, r11, r12
+ sub r9, r5, r9 @ linear_offset = temp2*(i-top)@
+ mul r9, r11, r9
+ add r12, r6, #256 @ temp3 = ((j+256)>>8)<<8@
+ bic r12, r12, #0xFF
+ sub r12, r12, r6 @ temp3 = temp3-j@
+ and r10, r6, #0x3F @ temp1 = left(==j)&0x3F
+
+ cmp r12, #192 @ if (temp3 > 192)
+ ble LOOP_HEIGHT_256_LEFT_192
+ add r11, r1, r7 @ r11 = nv12t_src+tiled_offset+temp1
+ add r11, r11, r10
+ pld [r11]
+ add r12, r1, r7 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r11, #32]
+ add r12, r12, #2048
+ pld [r12]
+ cmp r10, #0
+ pld [r12, #32]
+ stmnefd sp!, {r9-r12, r14} @ backup registers
+ rsbne r10, r10, #64
+ blne MEMCOPY_UNDER_64
+ ldmnefd sp!, {r9-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_256_64
+ vld1.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ vld1.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r11]! @ store {yuv420_dest+linear_offset, 64}
+ vst1.8 {q2, q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_256_64:
+ add r11, r1, r8 @ r11 = nv12t_src+tiled_offset1
+ pld [r11]
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r11, #32]
+ vld1.8 {q6, q7}, [r12]
+ add r12, r11, #2048 @ r12 = nv12t_src+tiled_offset1+2048
+ pld [r12]
+ vld1.8 {q8, q9}, [r11]! @ load {nv12t_src+tiled_offset1, 64}
+ pld [r12, #32]
+ vld1.8 {q10, q11}, [r11]
+ vld1.8 {q12, q13}, [r12]! @ load {nv12t_src+tiled_offset1+2048, 64}
+ vld1.8 {q14, q15}, [r12]
+
+ sub r11, r0, r10 @ r11 = yuv420_dest+linear_offset+64-temp1
+ add r12, r9, #64
+ add r11, r11, r12
+
+ vst1.8 {q4, q5}, [r11]! @ store {yuv420_dest+linear_offset+64-temp1, 64}
+ vst1.8 {q6, q7}, [r11]!
+ vst1.8 {q8, q9}, [r11]! @ store {yuv420_dest+linear_offset+128-temp1, 64}
+ vst1.8 {q10, q11}, [r11]!
+ vst1.8 {q12, q13}, [r11]! @ store {yuv420_dest+linear_offset+192-temp1, 64}
+ vst1.8 {q14, q15}, [r11]!
+
+ add r9, r9, #256
+ sub r9, r9, r10
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_192:
+ cmp r12, #128 @ if (temp3 > 128)
+ ble LOOP_HEIGHT_256_LEFT_128
+ add r11, r1, r7 @ r11 = nv12t_src+tiled_offset+2048+temp1
+ add r11, r11, r10
+ add r11, r11, #2048
+ pld [r11]
+ add r12, r1, r8 @ r12 = nv12t_src+tiled_offset1
+ pld [r11, #32]
+ cmp r10, #0
+ pld [r12]
+ stmnefd sp!, {r9-r12, r14} @ backup registers
+ pld [r12, #32]
+ rsbne r10, r10, #64
+ blne MEMCOPY_UNDER_64
+ ldmnefd sp!, {r9-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_192_64
+ vld1.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+2048+temp1, 64}
+ vld1.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r11]! @ store {yuv420_dest+linear_offset, 64}
+ vst1.8 {q2, q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_192_64:
+ add r11, r1, r8 @ r11 = nv12t_src+tiled_offset1+2048
+ add r11, r11, #2048
+ pld [r11]
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset1, 64}
+ pld [r11, #32]
+ vld1.8 {q6, q7}, [r12]
+ vld1.8 {q8, q9}, [r11]! @ load {nv12t_src+tiled_offset1+2048, 64}
+ vld1.8 {q10, q11}, [r11]
+
+ sub r11, r0, r10 @ r11 = yuv420_dest+linear_offset+64-temp1
+ add r12, r9, #64
+ add r11, r11, r12
+
+ vst1.8 {q4, q5}, [r11]! @ store {yuv420_dest+linear_offset+64-temp1, 64}
+ vst1.8 {q6, q7}, [r11]!
+ vst1.8 {q8, q9}, [r11]! @ store {yuv420_dest+linear_offset+128-temp1, 64}
+ vst1.8 {q10, q11}, [r11]!
+
+ add r9, r9, #192
+ sub r9, r9, r10
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_128:
+ cmp r12, #64 @ if (temp3 > 64)
+ ble LOOP_HEIGHT_256_LEFT_64
+ add r11, r1, r8 @ r11 = nv12t_src+tiled_offset1+temp1
+ add r11, r11, r10
+ pld [r11]
+ add r12, r1, r8 @ r12 = nv12t_src+tiled_offset1
+ add r12, r12, #2048
+ pld [r11, #32]
+ cmp r10, #0
+ pld [r12]
+ stmnefd sp!, {r9-r12, r14} @ backup registers
+ pld [r12, #32]
+ rsbne r10, r10, #64
+ blne MEMCOPY_UNDER_64
+ ldmnefd sp!, {r9-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_128_64
+ vld1.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset1+temp1, 64}
+ vld1.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r11]! @ store {yuv420_dest+linear_offset, 64}
+ vst1.8 {q2, q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_128_64:
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset1, 64}
+ vld1.8 {q6, q7}, [r12]
+
+ sub r11, r0, r10 @ r11 = yuv420_dest+linear_offset+64-temp1
+ add r12, r9, #64
+ add r11, r11, r12
+
+ vst1.8 {q4, q5}, [r11]! @ store {yuv420_dest+linear_offset+64-temp1, 64}
+ vst1.8 {q6, q7}, [r11]!
+
+ add r9, r9, #128
+ sub r9, r9, r10
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_64:
+ add r11, r1, r8 @ r11 = nv12t_src+tiled_offset1+2048+temp1
+ add r11, r11, #2048
+ add r11, r11, r10
+ cmp r10, #0
+ pld [r11]
+ stmnefd sp!, {r9-r12, r14} @ backup registers
+ pld [r11, #32]
+ rsbne r10, r10, #64
+ blne MEMCOPY_UNDER_64
+ ldmnefd sp!, {r9-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_64_64
+ vld1.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset1+temp1, 64}
+ vld1.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r11]! @ store {yuv420_dest+linear_offset, 64}
+ vst1.8 {q2, q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_64_64:
+ add r9, r9, #64
+ sub r9, r9, r10
+
+LOOP_HEIGHT_256_LEFT_END:
+
+ ldr r12, [sp, #48] @ right
+ add r7, r7, r14, lsl #11 @ tiled_offset = tiled_offset+temp4*2048
+ add r10, r1, r7 @ r10 = nv12t_src+tiled_offset
+ pld [r10]
+ bic r6, r6, #0xFF @ j = (left>>8)<<8
+ pld [r10, #32]
+ add r6, r6, #256 @ j = j + 256
+ sub r11, r2, r12 @ temp2 = yuv420_width-right-256
+ sub r11, r11, #256
+ cmp r6, r11
+ bgt LOOP_HEIGHT_256_WIDTH_END
+
+LOOP_HEIGHT_256_WIDTH:
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r12]
+ vld1.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset, 64}
+ pld [r12, #32]
+ vld1.8 {q2, q3}, [r10]
+
+ add r8, r8, r14, lsl #11 @ tiled_offset1 = tiled_offset1+temp4*2048
+ add r10, r1, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r10]
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r10, #32]
+ vld1.8 {q6, q7}, [r12]
+
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r12]
+ vld1.8 {q8, q9}, [r10]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r12, #32]
+ vld1.8 {q10, q11}, [r10]
+
+ add r7, r7, r14, lsl #11 @ tiled_offset = tiled_offset+temp4*2048
+ add r10, r1, r7
+ pld [r10]
+ vld1.8 {q12, q13}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r10, #32]
+ vld1.8 {q14, q15}, [r12]
+
+ add r12, r0, r9 @ r12 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r12]!
+ vst1.8 {q2, q3}, [r12]!
+ vst1.8 {q4, q5}, [r12]!
+ vst1.8 {q6, q7}, [r12]!
+ vst1.8 {q8, q9}, [r12]!
+ vst1.8 {q10, q11}, [r12]!
+ vst1.8 {q12, q13}, [r12]!
+ vst1.8 {q14, q15}, [r12]!
+ add r9, r9, #256 @ linear_offset = linear_offset+256
+
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+
+ add r6, r6, #256 @ j=j+256
+ cmp r6, r11 @ j<=temp2
+ ble LOOP_HEIGHT_256_WIDTH
+
+LOOP_HEIGHT_256_WIDTH_END:
+
+ add r8, r8, r14, lsl #11 @ tiled_offset1 = tiled_offset1+temp4*2048
+ ldr r14, [sp, #48] @ right
+ sub r11, r2, r6 @ temp2 = yuv420_width-right-j
+ sub r11, r11, r14
+ cmp r11, #0
+ beq LOOP_HEIGHT_256_RIGHT_END
+ cmp r11, #192
+ ble LOOP_HEIGHT_256_RIGHT_192
+ add r12, r10, #2048
+ pld [r12]
+ vld1.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r12, #32]
+ vld1.8 {q2, q3}, [r10]
+
+ add r10, r1, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r10]
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048}
+ pld [r10, #32]
+ vld1.8 {q6, q7}, [r12]
+
+ add r14, r10, #2048 @ r10 = nv12t_src+tiled_offset1+2048
+ pld [r14]
+ vld1.8 {q8, q9}, [r10]! @ load {nv12t_src+tiled_offset1}
+ pld [r14, #32]
+ vld1.8 {q10, q11}, [r10]
+
+ add r12, r0, r9 @ r12 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r12]!
+ vst1.8 {q2, q3}, [r12]!
+ vst1.8 {q4, q5}, [r12]!
+ vst1.8 {q6, q7}, [r12]!
+ vst1.8 {q8, q9}, [r12]!
+ vst1.8 {q10, q11}, [r12]!
+ add r9, r9, #192 @ linear_offset = linear_offset+192
+
+ stmfd sp!, {r9-r12, r14} @ backup registers
+ sub r10, r11, #192
+ mov r11, r14
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_192:
+ cmp r11, #128
+ ble LOOP_HEIGHT_256_RIGHT_128
+ add r12, r10, #2048
+ pld [r12]
+ vld1.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r12, #32]
+ vld1.8 {q2, q3}, [r10]
+
+ add r14, r1, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r14]
+ vld1.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048}
+ pld [r14, #32]
+ vld1.8 {q6, q7}, [r12]
+
+ add r12, r0, r9 @ r12 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r12]!
+ vst1.8 {q2, q3}, [r12]!
+ vst1.8 {q4, q5}, [r12]!
+ vst1.8 {q6, q7}, [r12]!
+ add r9, r9, #128 @ linear_offset = linear_offset+128
+
+ stmfd sp!, {r9-r12, r14} @ backup registers
+ sub r10, r11, #128
+ mov r11, r14
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_128:
+ cmp r11, #64
+ ble LOOP_HEIGHT_256_RIGHT_64
+ add r14, r10, #2048
+ pld [r14]
+ vld1.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r14, #32]
+ vld1.8 {q2, q3}, [r10]
+
+ add r12, r0, r9 @ r12 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r12]!
+ vst1.8 {q2, q3}, [r12]!
+ add r9, r9, #64 @ linear_offset = linear_offset+64
+
+ stmfd sp!, {r9-r12, r14} @ backup registers
+ sub r10, r11, #64
+ mov r11, r14
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_64:
+ stmfd sp!, {r9-r12, r14} @ backup registers
+ mov r14, r11
+ mov r11, r10
+ mov r10, r14
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12, r14} @ restore registers
+
+LOOP_HEIGHT_256_RIGHT_END:
+
+ ldr r14, [sp, #52] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r3, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_256
+ b RESTORE_REG
+
+LOOP_HEIGHT_64_START:
+ cmp r10, #64 @ if (temp1 >= 64)
+ blt LOOP_HEIGHT_2_START
+
+ ldr r5, [sp, #44] @ i = top
+LOOP_HEIGHT_64:
+ ldr r6, [sp, #40] @ j = left
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ ldr r9, [sp, #44] @ linear_offset = top
+ add r11, r6, #64 @ temp2 = ((j+64)>>6)<<6
+ bic r11, r11, #0x3F
+ sub r11, r11, r6 @ temp2 = temp2-j
+ sub r9, r5, r9 @ linear_offset = temp1*(i-top)
+ mul r9, r9, r10
+ and r14, r6, #0x3 @ temp4 = j&0x3
+ add r7, r7, r14 @ tiled_offset = tiled_offset+temp4
+ stmfd sp!, {r9-r12} @ backup parameters
+ mov r10, r11
+ add r11, r1, r7
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12} @ restore parameters
+ add r9, r9, r11 @ linear_offset = linear_offset+temp2
+ add r6, r6, r11 @ j = j+temp2@
+
+ add r14, r6, #64
+ cmp r14, r12
+ bgt LOOP_HEIGHT_64_1
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ add r7, r1, r7
+ vld1.8 {q0, q1}, [r7]!
+ vld1.8 {q2, q3}, [r7]
+ add r7, r0, r9
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]
+ add r9, r9, #64
+ add r6, r6, #64
+
+LOOP_HEIGHT_64_1:
+ add r14, r6, #64
+ cmp r14, r12
+ bgt LOOP_HEIGHT_64_2
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ add r7, r1, r7
+ vld1.8 {q0, q1}, [r7]!
+ vld1.8 {q2, q3}, [r7]
+ add r7, r0, r9
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]
+ add r9, r9, #64
+ add r6, r6, #64
+
+LOOP_HEIGHT_64_2:
+ cmp r6, r12
+ bge LOOP_HEIGHT_64_3
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ sub r11, r12, r6
+ stmfd sp!, {r9-r12} @ backup parameters
+ mov r10, r11
+ add r11, r1, r7
+ bl MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12} @ restore parameters
+
+LOOP_HEIGHT_64_3:
+
+ ldr r14, [sp, #52] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r3, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_64
+ b RESTORE_REG
+
+LOOP_HEIGHT_2_START:
+
+ ldr r5, [sp, #44] @ i = top
+LOOP_HEIGHT_2:
+
+ ldr r6, [sp, #40] @ j = left
+ ldr r9, [sp, #44] @ linear_offset = top
+ add r11, r6, #64 @ temp2 = ((j+64)>>6)<<6
+ bic r11, r11, #0x3F
+ sub r11, r11, r6 @ temp2 = temp2-j
+ sub r9, r5, r9 @ linear_offset = temp1*(i-top)
+ mul r9, r10, r9
+ add r9, r0, r9 @ linear_offset = linear_dst+linear_offset
+LOOP_HEIGHT_2_WIDTH:
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+
+ and r14, r6, #0x3 @ temp4 = j&0x3@
+ add r7, r7, r14 @ tiled_offset = tiled_offset+temp4@
+ add r7, r1, r7
+
+ ldrh r14, [r7]
+ strh r14, [r9], #2
+
+ ldr r14, [sp, #48] @ right
+ add r6, r6, #2 @ j=j+2
+ sub r14, r2, r14 @ j<yuv420_width-right
+ cmp r6, r14
+ blt LOOP_HEIGHT_2_WIDTH
+
+ ldr r14, [sp, #52] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r3, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+MEMCOPY_UNDER_64: @ count=r10, src=r11
+ cmp r10, #32
+ add r9, r0, r9 @ r9 = yuv420_dest+linear_offset
+ blt MEMCOPY_UNDER_32
+ vld1.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ sub r10, r10, #32
+ cmp r10, #0
+ vst1.8 {q0, q1}, [r9]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ beq MEMCOPY_UNDER_END
+MEMCOPY_UNDER_32:
+ cmp r10, #16
+ blt MEMCOPY_UNDER_16
+ vld1.8 {q0}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ sub r10, r10, #16
+ cmp r10, #0
+ vst1.8 {q0}, [r9]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ beq MEMCOPY_UNDER_END
+MEMCOPY_UNDER_16:
+ ldrb r12, [r11], #1
+ strb r12, [r9], #1
+ subs r10, r10, #1
+ bne MEMCOPY_UNDER_16
+
+MEMCOPY_UNDER_END:
+ and r10, r6, #0x3F @ temp1 = left(==j)&0x3F
+ cmp r10, #0
+ mov pc, lr
+
+tile_4x2_read_asm:
+LFB0:
+ add ip, r3, #32
+ sub r0, r0, #1
+ cmp r1, ip
+ cmple r3, r1
+ mov ip, r2, asr #2
+ mov r0, r0, asr #7
+ stmfd sp!, {r4, r5, lr}
+LCFI0:
+ add r0, r0, #1
+ bge L2
+ sub r1, r1, #1
+ tst r1, #32
+ bne L2
+ tst r3, #32
+ bne L2
+ mov r4, r2, asr #7
+ and r1, r3, #31
+ eor r4, r4, r3, asr #5
+ ubfx r3, r3, #6, #8
+ tst r4, #1
+ ubfx r4, r2, #8, #6
+ and ip, ip, #15
+ mov r2, r2, asr #6
+ mla r3, r0, r3, r4
+ orr r1, ip, r1, asl #4
+ b L9
+L2:
+ mov r2, ip, asr #5
+ and r4, r3, #31
+ eor r1, r2, r3, asr #5
+ and r5, r2, #127
+ ubfx r3, r3, #6, #8
+ tst r1, #1
+ and r1, ip, #15
+ mov r2, ip, asr #4
+ mla r3, r0, r3, r5
+ orr r1, r1, r4, asl #4
+L9:
+ andne r2, r2, #1
+ andeq r2, r2, #1
+ orrne r2, r2, #2
+ mov r1, r1, asl #2
+ orr r3, r1, r3, asl #13
+ orr r0, r3, r2, asl #11
+ ldmfd sp!, {r4, r5, pc}
+LFE0:
+ .fnend
+
diff --git a/exynos4/hal/libswconverter/csc_tiled_to_linear_deinterleave_crop_neon.s b/exynos4/hal/libswconverter/csc_tiled_to_linear_deinterleave_crop_neon.s
new file mode 100644
index 0000000..cdd101e
--- /dev/null
+++ b/exynos4/hal/libswconverter/csc_tiled_to_linear_deinterleave_crop_neon.s
@@ -0,0 +1,786 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file csc_tiled_to_linear_deinterleave_crop_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2012.02.01 : Create
+ */
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left. It should be even.
+ *
+ * @param top
+ * Crop size of top. It should be even.
+ *
+ * @param right
+ * Crop size of right. It should be even.
+ *
+ * @param buttom
+ * Crop size of buttom. It should be even.
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_tiled_to_linear_deinterleave_crop_neon
+ .type csc_tiled_to_linear_deinterleave_crop_neon, %function
+csc_tiled_to_linear_deinterleave_crop_neon:
+ .fnstart
+
+ @r0 yuv420_u_dest
+ @r1 yuv420_v_dest
+ @r2 nv12t_src
+ @r3 yuv420_width
+ @r4 yuv420_height
+ @r5 i
+ @r6 j
+ @r7 tiled_offset
+ @r8 tiled_offset1
+ @r9 linear_offset
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r4, [sp, #40] @ r4 = yuv420_height
+
+ ldr r12, [sp, #52] @ r12 = right
+ ldr r10, [sp, #44] @ r10 = left
+ sub r12, r3, r12 @ temp3 = yuv420_width-right@
+ sub r10, r12, r10 @ temp1 = temp3-left@
+ cmp r10, #256 @ if (temp1 >= 256)
+ blt LOOP_HEIGHT_64_START
+
+ ldr r5, [sp, #48] @ top
+LOOP_HEIGHT_256:
+ ldr r6, [sp, #44] @ j = left
+ mov r14, r5, asr #5 @ temp4 = i>>5
+ bic r12, r6, #0xFF @ temp3 = (j>>8)<<8
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ and r11, r14, #0x1 @ if (temp4 & 0x1)
+ cmp r11, #0x1
+ bne LOOP_HEIGHT_256_GET_TILED_EVEN
+LOOP_HEIGHT_256_GET_TILED_ODD:
+ sub r7, r14, #1 @ tiled_offset = temp4-1
+ add r10, r3, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)
+ mul r7, r7, r10
+ add r7, r7, r12 @ tiled_offset = tiled_offset+temp3
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2
+ bic r10, r12, #0x3 @ temp1 = (temp3>>2)<<2
+ add r7, r7, r10 @ tiled_offset = tiled_offset+temp1
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #4096 @ tiled_offset1 = tiled_offset+2048*2
+ mov r14, #8
+ b LOOP_HEIGHT_256_GET_TILED_END
+
+LOOP_HEIGHT_256_GET_TILED_EVEN:
+ add r11, r4, #31 @ temp2 = ((yuv420_height+31)>>5)<<5
+ bic r11, r11, #0x1F
+ add r10, r5, #32 @ if ((i+32)<temp2)
+ cmp r10, r11
+ bge LOOP_HEIGHT_256_GET_TILED_EVEN1
+ add r10, r12, #2 @ temp1 = temp3+2
+ bic r10, r10, #0x3 @ temp1 = (temp1>>2)<<2
+ add r7, r12, r10 @ tiled_offset = temp3+temp1@
+ add r10, r3, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset+temp4*(temp1>>6)
+ mla r7, r14, r10, r7
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #12288 @ tiled_offset1 = tiled_offset+2048*6
+ mov r14, #8
+ b LOOP_HEIGHT_256_GET_TILED_END
+
+LOOP_HEIGHT_256_GET_TILED_EVEN1:
+ add r10, r3, #127 @ temp1 = ((yuv420_width+127)>>7)<<7
+ bic r10, r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = temp4*(temp1>>6)
+ mul r7, r14, r10
+ add r7, r7, r12 @ tiled_offset = tiled_offset+temp3
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11
+ add r8, r7, #4096 @ tiled_offset1 = tiled_offset+2048*2
+ mov r14, #4
+
+LOOP_HEIGHT_256_GET_TILED_END:
+
+ ldr r12, [sp, #52] @ right
+ ldr r9, [sp, #48] @ top
+ and r10, r5, #0x1F @ temp1 = i&0x1F
+ add r7, r7, r10, lsl #6 @ tiled_offset = tiled_offset+64*(temp1)
+ add r8, r8, r10, lsl #6 @ tiled_offset1 = tiled_offset1+64*(temp1)
+ sub r11, r3, r6 @ temp2 = yuv420_width-left(==j)-right
+ sub r11, r11, r12
+ sub r9, r5, r9 @ linear_offset = temp2*(i-top)/2@
+ mul r9, r11, r9
+ mov r9, r9, asr #1
+ add r12, r6, #256 @ temp3 = ((j+256)>>8)<<8@
+ bic r12, r12, #0xFF
+ sub r12, r12, r6 @ temp3 = temp3-j@
+ and r10, r6, #0x3F @ temp1 = left(==j)&0x3F
+
+ cmp r12, #192 @ if (temp3 > 192)
+ ble LOOP_HEIGHT_256_LEFT_192
+ add r11, r2, r7 @ r11 = nv12t_src+tiled_offset+temp1
+ add r11, r11, r10
+ pld [r11]
+ add r12, r2, r7 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r11, #32]
+ add r12, r12, #2048
+ pld [r12]
+ cmp r10, #0
+ pld [r12, #32]
+ stmnefd sp!, {r8-r12, r14} @ backup registers
+ rsbne r10, r10, #64
+ blne INTERLEAVED_MEMCOPY_UNDER_64
+ ldmnefd sp!, {r8-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_256_64
+ vld2.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ vld2.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r11]!
+ vst1.8 {q2}, [r11]!
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r11]!
+ vst1.8 {q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_256_64:
+ add r11, r2, r8 @ r11 = nv12t_src+tiled_offset1
+ pld [r11]
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r11, #32]
+ vld2.8 {q6, q7}, [r12]
+ add r12, r11, #2048 @ r12 = nv12t_src+tiled_offset1+2048
+ pld [r12]
+ vld2.8 {q8, q9}, [r11]! @ load {nv12t_src+tiled_offset1, 64}
+ pld [r12, #32]
+ vld2.8 {q10, q11}, [r11]
+ vld2.8 {q12, q13}, [r12]! @ load {nv12t_src+tiled_offset1+2048, 64}
+ vld2.8 {q14, q15}, [r12]
+
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q4}, [r11]!
+ vst1.8 {q6}, [r11]!
+ vst1.8 {q8}, [r11]!
+ vst1.8 {q10}, [r11]!
+ vst1.8 {q12}, [r11]!
+ vst1.8 {q14}, [r11]!
+
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q5}, [r11]!
+ vst1.8 {q7}, [r11]!
+ vst1.8 {q9}, [r11]!
+ vst1.8 {q11}, [r11]!
+ vst1.8 {q13}, [r11]!
+ vst1.8 {q15}, [r11]!
+
+ add r9, r9, #128
+ sub r9, r9, r10, asr #1
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_192:
+ cmp r12, #128 @ if (temp3 > 128)
+ ble LOOP_HEIGHT_256_LEFT_128
+ add r11, r2, r7 @ r11 = nv12t_src+tiled_offset+2048+temp1
+ add r11, r11, r10
+ add r11, r11, #2048
+ pld [r11]
+ add r12, r2, r8 @ r12 = nv12t_src+tiled_offset1
+ pld [r11, #32]
+ cmp r10, #0
+ pld [r12]
+ stmnefd sp!, {r8-r12, r14} @ backup registers
+ pld [r12, #32]
+ rsbne r10, r10, #64
+ blne INTERLEAVED_MEMCOPY_UNDER_64
+ ldmnefd sp!, {r8-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_192_64
+ vld2.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+2048+temp1, 64}
+ vld2.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r11]!
+ vst1.8 {q2}, [r11]!
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r11]!
+ vst1.8 {q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_192_64:
+ add r11, r2, r8 @ r11 = nv12t_src+tiled_offset1+2048
+ add r11, r11, #2048
+ pld [r11]
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset1, 64}
+ pld [r11, #32]
+ vld2.8 {q6, q7}, [r12]
+ vld2.8 {q8, q9}, [r11]! @ load {nv12t_src+tiled_offset1+2048, 64}
+ vld2.8 {q10, q11}, [r11]
+
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q4}, [r11]!
+ vst1.8 {q6}, [r11]!
+ vst1.8 {q8}, [r11]!
+ vst1.8 {q10}, [r11]!
+
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q5}, [r11]!
+ vst1.8 {q7}, [r11]!
+ vst1.8 {q9}, [r11]!
+ vst1.8 {q11}, [r11]!
+
+ add r9, r9, #96
+ sub r9, r9, r10, asr #1
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_128:
+ cmp r12, #64 @ if (temp3 > 64)
+ ble LOOP_HEIGHT_256_LEFT_64
+ add r11, r2, r8 @ r11 = nv12t_src+tiled_offset1+temp1
+ add r11, r11, r10
+ pld [r11]
+ add r12, r2, r8 @ r12 = nv12t_src+tiled_offset1
+ add r12, r12, #2048
+ pld [r11, #32]
+ cmp r10, #0
+ pld [r12]
+ stmnefd sp!, {r8-r12, r14} @ backup registers
+ pld [r12, #32]
+ rsbne r10, r10, #64
+ blne INTERLEAVED_MEMCOPY_UNDER_64
+ ldmnefd sp!, {r8-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_128_64
+ vld2.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset1+temp1, 64}
+ vld2.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r11]!
+ vst1.8 {q2}, [r11]!
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r11]!
+ vst1.8 {q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_128_64:
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset1, 64}
+ vld2.8 {q6, q7}, [r12]
+
+ add r11, r0, r9 @ r11 = yuv420_u_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q4}, [r11]!
+ vst1.8 {q6}, [r11]!
+
+ add r11, r1, r9 @ r11 = yuv420_v_dest+linear_offset+32-temp1/2
+ add r11, r11, #32
+ sub r11, r11, r10, asr #1
+ vst1.8 {q5}, [r11]!
+ vst1.8 {q7}, [r11]!
+
+ add r9, r9, #64
+ sub r9, r9, r10, asr #1
+ b LOOP_HEIGHT_256_LEFT_END
+
+LOOP_HEIGHT_256_LEFT_64:
+ add r11, r2, r8 @ r11 = nv12t_src+tiled_offset1+2048+temp1
+ add r11, r11, #2048
+ add r11, r11, r10
+ cmp r10, #0
+ pld [r11]
+ stmnefd sp!, {r8-r12, r14} @ backup registers
+ pld [r11, #32]
+ rsbne r10, r10, #64
+ blne INTERLEAVED_MEMCOPY_UNDER_64
+ ldmnefd sp!, {r8-r12, r14} @ restore registers
+ bne LOOP_HEIGHT_256_LEFT_64_64
+ vld2.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset1+temp1, 64}
+ vld2.8 {q2, q3}, [r11]
+ add r11, r0, r9 @ r11 = yuv420_dest+linear_offset
+ vst1.8 {q0, q1}, [r11]! @ store {yuv420_dest+linear_offset, 64}
+ vst1.8 {q2, q3}, [r11]!
+LOOP_HEIGHT_256_LEFT_64_64:
+ add r9, r9, #32
+ sub r9, r9, r10, asr #1
+
+LOOP_HEIGHT_256_LEFT_END:
+
+ ldr r12, [sp, #52] @ right
+ add r7, r7, r14, lsl #11 @ tiled_offset = tiled_offset+temp4*2048
+ add r10, r2, r7 @ r10 = nv12t_src+tiled_offset
+ pld [r10]
+ bic r6, r6, #0xFF @ j = (left>>8)<<8
+ pld [r10, #32]
+ add r6, r6, #256 @ j = j + 256
+ sub r11, r3, r12 @ temp2 = yuv420_width-right-256
+ sub r11, r11, #256
+ cmp r6, r11
+ bgt LOOP_HEIGHT_256_WIDTH_END
+
+LOOP_HEIGHT_256_WIDTH:
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r12]
+ vld2.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset, 64}
+ pld [r12, #32]
+ vld2.8 {q2, q3}, [r10]
+
+ add r8, r8, r14, lsl #11 @ tiled_offset1 = tiled_offset1+temp4*2048
+ add r10, r2, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r10]
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r10, #32]
+ vld2.8 {q6, q7}, [r12]
+
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+ pld [r12]
+ vld2.8 {q8, q9}, [r10]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r12, #32]
+ vld2.8 {q10, q11}, [r10]
+
+ add r7, r7, r14, lsl #11 @ tiled_offset = tiled_offset+temp4*2048
+ add r10, r2, r7
+ pld [r10]
+ vld2.8 {q12, q13}, [r12]! @ load {nv12t_src+tiled_offset+2048, 64}
+ pld [r10, #32]
+ vld2.8 {q14, q15}, [r12]
+
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r12]!
+ vst1.8 {q2}, [r12]!
+ vst1.8 {q4}, [r12]!
+ vst1.8 {q6}, [r12]!
+ vst1.8 {q8}, [r12]!
+ vst1.8 {q10}, [r12]!
+ vst1.8 {q12}, [r12]!
+ vst1.8 {q14}, [r12]!
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r12]!
+ vst1.8 {q3}, [r12]!
+ vst1.8 {q5}, [r12]!
+ vst1.8 {q7}, [r12]!
+ vst1.8 {q9}, [r12]!
+ vst1.8 {q11}, [r12]!
+ vst1.8 {q13}, [r12]!
+ vst1.8 {q15}, [r12]!
+ add r9, r9, #128 @ linear_offset = linear_offset+128
+
+ add r12, r10, #2048 @ r12 = nv12t_src+tiled_offset+2048
+
+ add r6, r6, #256 @ j=j+256
+ cmp r6, r11 @ j<=temp2
+ ble LOOP_HEIGHT_256_WIDTH
+
+LOOP_HEIGHT_256_WIDTH_END:
+
+ add r8, r8, r14, lsl #11 @ tiled_offset1 = tiled_offset1+temp4*2048
+ ldr r14, [sp, #52] @ right
+ sub r11, r3, r6 @ temp2 = yuv420_width-right-j
+ sub r11, r11, r14
+ cmp r11, #0
+ beq LOOP_HEIGHT_256_RIGHT_END
+ cmp r11, #192
+ ble LOOP_HEIGHT_256_RIGHT_192
+ add r12, r10, #2048
+ pld [r12]
+ vld2.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r12, #32]
+ vld2.8 {q2, q3}, [r10]
+
+ add r10, r2, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r10]
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048}
+ pld [r10, #32]
+ vld2.8 {q6, q7}, [r12]
+
+ add r14, r10, #2048 @ r10 = nv12t_src+tiled_offset1+2048
+ pld [r14]
+ vld2.8 {q8, q9}, [r10]! @ load {nv12t_src+tiled_offset1}
+ pld [r14, #32]
+ vld2.8 {q10, q11}, [r10]
+
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r12]!
+ vst1.8 {q2}, [r12]!
+ vst1.8 {q4}, [r12]!
+ vst1.8 {q6}, [r12]!
+ vst1.8 {q8}, [r12]!
+ vst1.8 {q10}, [r12]!
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r12]!
+ vst1.8 {q3}, [r12]!
+ vst1.8 {q5}, [r12]!
+ vst1.8 {q7}, [r12]!
+ vst1.8 {q9}, [r12]!
+ vst1.8 {q11}, [r12]!
+ add r9, r9, #96 @ linear_offset = linear_offset+96
+
+ stmfd sp!, {r8-r12, r14} @ backup registers
+ sub r10, r11, #192
+ mov r11, r14
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r8-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_192:
+ cmp r11, #128
+ ble LOOP_HEIGHT_256_RIGHT_128
+ add r12, r10, #2048
+ pld [r12]
+ vld2.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r12, #32]
+ vld2.8 {q2, q3}, [r10]
+
+ add r14, r2, r8 @ r10 = nv12t_src+tiled_offset1
+ pld [r14]
+ vld2.8 {q4, q5}, [r12]! @ load {nv12t_src+tiled_offset+2048}
+ pld [r14, #32]
+ vld2.8 {q6, q7}, [r12]
+
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r12]!
+ vst1.8 {q2}, [r12]!
+ vst1.8 {q4}, [r12]!
+ vst1.8 {q6}, [r12]!
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r12]!
+ vst1.8 {q3}, [r12]!
+ vst1.8 {q5}, [r12]!
+ vst1.8 {q7}, [r12]!
+ add r9, r9, #64 @ linear_offset = linear_offset+64
+
+ stmfd sp!, {r8-r12, r14} @ backup registers
+ sub r10, r11, #128
+ mov r11, r14
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r8-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_128:
+ cmp r11, #64
+ ble LOOP_HEIGHT_256_RIGHT_64
+ add r14, r10, #2048
+ pld [r14]
+ vld2.8 {q0, q1}, [r10]! @ load {nv12t_src+tiled_offset}
+ pld [r14, #32]
+ vld2.8 {q2, q3}, [r10]
+
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r12]!
+ vst1.8 {q2}, [r12]!
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r12]!
+ vst1.8 {q3}, [r12]!
+ add r9, r9, #32 @ linear_offset = linear_offset+32
+
+ stmfd sp!, {r8-r12, r14} @ backup registers
+ sub r10, r11, #64
+ mov r11, r14
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r8-r12, r14} @ restore registers
+ b LOOP_HEIGHT_256_RIGHT_END
+
+LOOP_HEIGHT_256_RIGHT_64:
+ stmfd sp!, {r8-r12, r14} @ backup registers
+ mov r14, r11
+ mov r11, r10
+ mov r10, r14
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r8-r12, r14} @ restore registers
+
+LOOP_HEIGHT_256_RIGHT_END:
+
+ ldr r14, [sp, #56] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r4, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_256
+ b RESTORE_REG
+
+LOOP_HEIGHT_64_START:
+ cmp r10, #64 @ if (temp1 >= 64)
+ blt LOOP_HEIGHT_2_START
+
+ ldr r5, [sp, #48] @ i = top
+LOOP_HEIGHT_64:
+ ldr r6, [sp, #44] @ j = left
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r3
+ mov r1, r4
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ ldr r9, [sp, #48] @ linear_offset = top
+ ldr r12, [sp, #52] @ r12 = right
+ add r11, r6, #64 @ temp2 = ((j+64)>>6)<<6
+ bic r11, r11, #0x3F
+ sub r11, r11, r6 @ temp2 = temp2-j
+ sub r12, r3, r12 @ temp3 = yuv420_width-right
+ sub r14, r12, r6 @ temp4 = temp3-left
+ sub r9, r5, r9 @ linear_offset = temp4*(i-top)/2
+ mul r9, r9, r14
+ mov r9, r9, asr #1
+ and r14, r6, #0x3 @ temp4 = j&0x3
+ add r7, r7, r14 @ tiled_offset = tiled_offset+temp4
+ stmfd sp!, {r9-r12} @ backup parameters
+ mov r10, r11
+ add r11, r2, r7
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12} @ restore parameters
+ add r9, r9, r11, asr #1 @ linear_offset = linear_offset+temp2/2
+ add r6, r6, r11 @ j = j+temp2@
+
+ add r14, r6, #64
+ cmp r14, r12
+ bgt LOOP_HEIGHT_64_1
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r3
+ mov r1, r4
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ add r7, r2, r7
+ vld2.8 {q0, q1}, [r7]!
+ vld2.8 {q2, q3}, [r7]
+ add r7, r0, r9
+ vst1.8 {q0}, [r7]!
+ vst1.8 {q2}, [r7]
+ add r7, r1, r9
+ vst1.8 {q1}, [r7]!
+ vst1.8 {q3}, [r7]
+ add r9, r9, #32
+ add r6, r6, #64
+
+LOOP_HEIGHT_64_1:
+ add r14, r6, #64
+ cmp r14, r12
+ bgt LOOP_HEIGHT_64_2
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r3
+ mov r1, r4
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ add r7, r2, r7
+ vld2.8 {q0, q1}, [r7]!
+ vld2.8 {q2, q3}, [r7]
+ add r7, r0, r9
+ vst1.8 {q0}, [r7]!
+ vst1.8 {q2}, [r7]
+ add r7, r1, r9
+ vst1.8 {q1}, [r7]!
+ vst1.8 {q3}, [r7]
+ add r9, r9, #32
+ add r6, r6, #64
+
+LOOP_HEIGHT_64_2:
+ cmp r6, r12
+ bge LOOP_HEIGHT_64_3
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r3
+ mov r1, r4
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+ sub r11, r12, r6
+ stmfd sp!, {r9-r12} @ backup parameters
+ mov r10, r11
+ add r11, r2, r7
+ bl INTERLEAVED_MEMCOPY_UNDER_64
+ ldmfd sp!, {r9-r12} @ restore parameters
+
+LOOP_HEIGHT_64_3:
+
+ ldr r14, [sp, #56] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r4, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_64
+ b RESTORE_REG
+
+LOOP_HEIGHT_2_START:
+
+ ldr r5, [sp, #48] @ i = top
+LOOP_HEIGHT_2:
+
+ ldr r12, [sp, #52] @ linear_offset = right
+ ldr r6, [sp, #44] @ j = left
+ ldr r9, [sp, #48] @ linear_offset = top
+
+ sub r12, r3, r12 @ temp3 = yuv420_width-right
+ sub r14, r12, r6 @ temp4 = temp3-left@
+ sub r9, r5, r9 @ r9 = i-top
+ mul r9, r14, r9 @ temp4*(i-top)
+ mov r9, r9, lsr #1 @ linear_offset = temp4*(i-top)/2
+ add r11, r0, r9
+ add r12, r1, r9
+LOOP_HEIGHT_2_WIDTH:
+ stmfd sp!, {r0-r3, r12} @ backup parameters
+ mov r0, r2
+ mov r1, r3
+ mov r2, r6
+ mov r3, r5
+ bl tile_4x2_read_asm
+ mov r7, r0
+ ldmfd sp!, {r0-r3, r12} @ restore parameters
+
+ and r14, r6, #0x3 @ temp4 = j&0x3@
+ add r7, r7, r14 @ tiled_offset = tiled_offset+temp4@
+ add r7, r2, r7
+
+ ldrh r14, [r7]
+ strb r14, [r11], #1
+ mov r14, r14, lsr #8
+ strb r14, [r12], #1
+
+ ldr r14, [sp, #52] @ right
+ add r6, r6, #2 @ j=j+2
+ sub r14, r3, r14 @ j<yuv420_width-right
+ cmp r6, r14
+ blt LOOP_HEIGHT_2_WIDTH
+
+ ldr r14, [sp, #56] @ buttom
+ add r5, r5, #1 @ i=i+1
+ sub r14, r4, r14 @ i<yuv420_height-buttom
+ cmp r5, r14
+ blt LOOP_HEIGHT_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+INTERLEAVED_MEMCOPY_UNDER_64: @ count=r10, src=r11
+ cmp r10, #32
+ blt INTERLEAVED_MEMCOPY_UNDER_32
+ vld2.8 {q0, q1}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ sub r10, r10, #32
+ cmp r10, #0
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {q0}, [r12] @ load {nv12t_src+tiled_offset+temp1, 64}
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {q1}, [r12] @ load {nv12t_src+tiled_offset+temp1, 64}
+ add r9, r9, #16
+ beq INTERLEAVED_MEMCOPY_UNDER_END
+INTERLEAVED_MEMCOPY_UNDER_32:
+ cmp r10, #16
+ blt INTERLEAVED_MEMCOPY_UNDER_16
+ vld2.8 {q0}, [r11]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ sub r10, r10, #16
+ cmp r10, #0
+ add r12, r0, r9 @ r12 = yuv420_u_dest+linear_offset
+ vst1.8 {d0}, [r12]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ add r12, r1, r9 @ r12 = yuv420_v_dest+linear_offset
+ vst1.8 {d1}, [r12]! @ load {nv12t_src+tiled_offset+temp1, 64}
+ add r9, r9, #8
+ beq INTERLEAVED_MEMCOPY_UNDER_END
+INTERLEAVED_MEMCOPY_UNDER_16:
+ ldrh r12, [r11], #2
+ add r8, r0, r9 @ r8 = yuv420_u_dest+linear_offset
+ strb r12, [r8]
+ add r8, r1, r9 @ r8 = yuv420_v_dest+linear_offset
+ mov r12, r12, lsr #8
+ strb r12, [r8]
+ subs r10, r10, #2
+ add r9, r9, #1
+ bne INTERLEAVED_MEMCOPY_UNDER_16
+
+INTERLEAVED_MEMCOPY_UNDER_END:
+ and r10, r6, #0x3F @ temp1 = left(==j)&0x3F
+ cmp r10, #0
+ mov pc, lr
+
+tile_4x2_read_asm:
+LFB0:
+ add ip, r3, #32
+ sub r0, r0, #1
+ cmp r1, ip
+ cmple r3, r1
+ mov ip, r2, asr #2
+ mov r0, r0, asr #7
+ stmfd sp!, {r4, r5, lr}
+LCFI0:
+ add r0, r0, #1
+ bge L2
+ sub r1, r1, #1
+ tst r1, #32
+ bne L2
+ tst r3, #32
+ bne L2
+ mov r4, r2, asr #7
+ and r1, r3, #31
+ eor r4, r4, r3, asr #5
+ ubfx r3, r3, #6, #8
+ tst r4, #1
+ ubfx r4, r2, #8, #6
+ and ip, ip, #15
+ mov r2, r2, asr #6
+ mla r3, r0, r3, r4
+ orr r1, ip, r1, asl #4
+ b L9
+L2:
+ mov r2, ip, asr #5
+ and r4, r3, #31
+ eor r1, r2, r3, asr #5
+ and r5, r2, #127
+ ubfx r3, r3, #6, #8
+ tst r1, #1
+ and r1, ip, #15
+ mov r2, ip, asr #4
+ mla r3, r0, r3, r5
+ orr r1, r1, r4, asl #4
+L9:
+ andne r2, r2, #1
+ andeq r2, r2, #1
+ orrne r2, r2, #2
+ mov r1, r1, asl #2
+ orr r3, r1, r3, asl #13
+ orr r0, r3, r2, asl #11
+ ldmfd sp!, {r4, r5, pc}
+LFE0:
+ .fnend
+
diff --git a/exynos4/hal/libswconverter/swconvertor.c b/exynos4/hal/libswconverter/swconvertor.c
new file mode 100644
index 0000000..043add2
--- /dev/null
+++ b/exynos4/hal/libswconverter/swconvertor.c
@@ -0,0 +1,1828 @@
+/*
+ *
+ * Copyright 2012 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file swconvertor.c
+ *
+ * @brief SEC_OMX specific define
+ *
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ *
+ * @version 1.0
+ *
+ * @history
+ * 2012.02.01 : Create
+ */
+
+#include "stdio.h"
+#include "stdlib.h"
+#include "swconverter.h"
+
+/*
+ * Get tiled address of position(x,y)
+ *
+ * @param x_size
+ * width of tiled[in]
+ *
+ * @param y_size
+ * height of tiled[in]
+ *
+ * @param x_pos
+ * x position of tield[in]
+ *
+ * @param src_size
+ * y position of tield[in]
+ *
+ * @return
+ * address of tiled data
+ */
+static int tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos)
+{
+ int pixel_x_m1, pixel_y_m1;
+ int roundup_x, roundup_y;
+ int linear_addr0, linear_addr1, bank_addr ;
+ int x_addr;
+ int trans_addr;
+
+ pixel_x_m1 = x_size -1;
+ pixel_y_m1 = y_size -1;
+
+ roundup_x = ((pixel_x_m1 >> 7) + 1);
+ roundup_y = ((pixel_x_m1 >> 6) + 1);
+
+ x_addr = x_pos >> 2;
+
+ if ((y_size <= y_pos+32) && ( y_pos < y_size) &&
+ (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) {
+ linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf));
+ linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f));
+
+ if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
+ bank_addr = ((x_addr >> 4) & 0x1);
+ else
+ bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
+ } else {
+ linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf));
+ linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f));
+
+ if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1))
+ bank_addr = ((x_addr >> 4) & 0x1);
+ else
+ bank_addr = 0x2 | ((x_addr >> 4) & 0x1);
+ }
+
+ linear_addr0 = linear_addr0 << 2;
+ trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0;
+
+ return trans_addr;
+}
+
+/*
+ * De-interleaves src to dest1, dest2
+ *
+ * @param dest1
+ * Address of de-interleaved data[out]
+ *
+ * @param dest2
+ * Address of de-interleaved data[out]
+ *
+ * @param src
+ * Address of interleaved data[in]
+ *
+ * @param src_size
+ * Size of interleaved data[in]
+ */
+void csc_deinterleave_memcpy(
+ unsigned char *dest1,
+ unsigned char *dest2,
+ unsigned char *src,
+ unsigned int src_size)
+{
+ unsigned int i = 0;
+ for(i=0; i<src_size/2; i++) {
+ dest1[i] = src[i*2];
+ dest2[i] = src[i*2+1];
+ }
+}
+
+/*
+ * Interleaves src1, src2 to dest
+ *
+ * @param dest
+ * Address of interleaved data[out]
+ *
+ * @param src1
+ * Address of de-interleaved data[in]
+ *
+ * @param src2
+ * Address of de-interleaved data[in]
+ *
+ * @param src_size
+ * Size of de-interleaved data[in]
+ */
+void csc_interleave_memcpy(
+ unsigned char *dest,
+ unsigned char *src1,
+ unsigned char *src2,
+ unsigned int src_size)
+{
+ unsigned int i = 0;
+ for(i=0; i<src_size; i++) {
+ dest[i * 2] = src1[i];
+ dest[i * 2 + 1] = src2[i];
+ }
+}
+
+/*
+ * Converts tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+static void csc_tiled_to_linear_crop(
+ unsigned char *yuv420_dest,
+ unsigned char *nv12t_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom)
+{
+ unsigned int i, j;
+ unsigned int tiled_offset = 0, tiled_offset1 = 0;
+ unsigned int linear_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
+
+ temp3 = yuv420_width-right;
+ temp1 = temp3-left;
+ /* real width is greater than or equal 256 */
+ if (temp1 >= 256) {
+ for (i=top; i<yuv420_height-buttom; i=i+1) {
+ j = left;
+ temp3 = (j>>8)<<8;
+ temp3 = temp3>>6;
+ temp4 = i>>5;
+ if (temp4 & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = temp4-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+temp3;
+ tiled_offset = tiled_offset+2;
+ temp1 = (temp3>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*2;
+ temp4 = 8;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = temp3+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = temp3+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+temp4*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*6;
+ temp4 = 8;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = temp4*(temp1>>6);
+ tiled_offset = tiled_offset+temp3;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*2;
+ temp4 = 4;
+ }
+ }
+
+ temp1 = i&0x1F;
+ tiled_offset = tiled_offset+64*(temp1);
+ tiled_offset1 = tiled_offset1+64*(temp1);
+ temp2 = yuv420_width-left-right;
+ linear_offset = temp2*(i-top);
+ temp3 = ((j+256)>>8)<<8;
+ temp3 = temp3-j;
+ temp1 = left&0x3F;
+ if (temp3 > 192) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+temp1, 64-temp1);
+ temp2 = ((left+63)>>6)<<6;
+ temp3 = ((yuv420_width-right)>>6)<<6;
+ if (temp2 == temp3) {
+ temp2 = yuv420_width-right-(64-temp1);
+ }
+ memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset+2048, 64);
+ memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1, 64);
+ memcpy(yuv420_dest+linear_offset+192-temp1, nv12t_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+256-temp1;
+ } else if (temp3 > 128) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset+2048+temp1, 64-temp1);
+ memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1, 64);
+ memcpy(yuv420_dest+linear_offset+128-temp1, nv12t_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+192-temp1;
+ } else if (temp3 > 64) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+temp1, 64-temp1);
+ memcpy(yuv420_dest+linear_offset+64-temp1, nv12t_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+128-temp1;
+ } else if (temp3 > 0) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset1+2048+temp1, 64-temp1);
+ linear_offset = linear_offset+64-temp1;
+ }
+
+ tiled_offset = tiled_offset+temp4*2048;
+ j = (left>>8)<<8;
+ j = j + 256;
+ temp2 = yuv420_width-right-256;
+ for (; j<=temp2; j=j+256) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ tiled_offset1 = tiled_offset1+temp4*2048;
+ memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+ memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
+ tiled_offset = tiled_offset+temp4*2048;
+ memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+256;
+ }
+
+ tiled_offset1 = tiled_offset1+temp4*2048;
+ temp2 = yuv420_width-right-j;
+ if (temp2 > 192) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+ memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, 64);
+ memcpy(yuv420_dest+linear_offset+192, nv12t_src+tiled_offset1+2048, temp2-192);
+ } else if (temp2 > 128) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, 64);
+ memcpy(yuv420_dest+linear_offset+128, nv12t_src+tiled_offset1, temp2-128);
+ } else if (temp2 > 64) {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ memcpy(yuv420_dest+linear_offset+64, nv12t_src+tiled_offset+2048, temp2-64);
+ } else {
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+ }
+ }
+ } else if (temp1 >= 64) {
+ for (i=top; i<(yuv420_height-buttom); i=i+1) {
+ j = left;
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
+ temp2 = ((j+64)>>6)<<6;
+ temp2 = temp2-j;
+ linear_offset = temp1*(i-top);
+ temp4 = j&0x3;
+ tiled_offset = tiled_offset+temp4;
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+ linear_offset = linear_offset+temp2;
+ j = j+temp2;
+ if ((j+64) <= temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ linear_offset = linear_offset+64;
+ j = j+64;
+ }
+ if ((j+64) <= temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 64);
+ linear_offset = linear_offset+64;
+ j = j+64;
+ }
+ if (j < temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
+ temp2 = temp3-j;
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, temp2);
+ }
+ }
+ } else {
+ for (i=top; i<(yuv420_height-buttom); i=i+1) {
+ linear_offset = temp1*(i-top);
+ for (j=left; j<(yuv420_width-right); j=j+2) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_height, j, i);
+ temp4 = j&0x3;
+ tiled_offset = tiled_offset+temp4;
+ memcpy(yuv420_dest+linear_offset, nv12t_src+tiled_offset, 2);
+ linear_offset = linear_offset+2;
+ }
+ }
+ }
+}
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+static void csc_tiled_to_linear_deinterleave_crop(
+ unsigned char *yuv420_u_dest,
+ unsigned char *yuv420_v_dest,
+ unsigned char *nv12t_uv_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_uv_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom)
+{
+ unsigned int i, j;
+ unsigned int tiled_offset = 0, tiled_offset1 = 0;
+ unsigned int linear_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0;
+
+ temp3 = yuv420_width-right;
+ temp1 = temp3-left;
+ /* real width is greater than or equal 256 */
+ if (temp1 >= 256) {
+ for (i=top; i<yuv420_uv_height-buttom; i=i+1) {
+ j = left;
+ temp3 = (j>>8)<<8;
+ temp3 = temp3>>6;
+ temp4 = i>>5;
+ if (temp4 & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = temp4-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+temp3;
+ tiled_offset = tiled_offset+2;
+ temp1 = (temp3>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*2;
+ temp4 = 8;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = temp3+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = temp3+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+temp4*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*6;
+ temp4 = 8;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = temp4*(temp1>>6);
+ tiled_offset = tiled_offset+temp3;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*2;
+ temp4 = 4;
+ }
+ }
+
+ temp1 = i&0x1F;
+ tiled_offset = tiled_offset+64*(temp1);
+ tiled_offset1 = tiled_offset1+64*(temp1);
+ temp2 = yuv420_width-left-right;
+ linear_offset = temp2*(i-top)/2;
+ temp3 = ((j+256)>>8)<<8;
+ temp3 = temp3-j;
+ temp1 = left&0x3F;
+ if (temp3 > 192) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset, yuv420_v_dest+linear_offset, nv12t_uv_src+tiled_offset+temp1, 64-temp1);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
+ yuv420_v_dest+linear_offset+(32-temp1/2),
+ nv12t_uv_src+tiled_offset+2048, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(64-temp1/2),
+ yuv420_v_dest+linear_offset+(64-temp1/2),
+ nv12t_uv_src+tiled_offset1, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(96-temp1/2),
+ yuv420_v_dest+linear_offset+(96-temp1/2),
+ nv12t_uv_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+128-temp1/2;
+ } else if (temp3 > 128) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset+2048+temp1, 64-temp1);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
+ yuv420_v_dest+linear_offset+(32-temp1/2),
+ nv12t_uv_src+tiled_offset1, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(64-temp1/2),
+ yuv420_v_dest+linear_offset+(64-temp1/2),
+ nv12t_uv_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+96-temp1/2;
+ } else if (temp3 > 64) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset1+temp1, 64-temp1);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+(32-temp1/2),
+ yuv420_v_dest+linear_offset+(32-temp1/2),
+ nv12t_uv_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+64-temp1/2;
+ } else if (temp3 > 0) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset1+2048+temp1, 64-temp1);
+ linear_offset = linear_offset+32-temp1/2;
+ }
+
+ tiled_offset = tiled_offset+temp4*2048;
+ j = (left>>8)<<8;
+ j = j + 256;
+ temp2 = yuv420_width-right-256;
+ for (; j<=temp2; j=j+256) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ tiled_offset1 = tiled_offset1+temp4*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
+ yuv420_v_dest+linear_offset+32,
+ nv12t_uv_src+tiled_offset+2048, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
+ yuv420_v_dest+linear_offset+64,
+ nv12t_uv_src+tiled_offset1, 64);
+ tiled_offset = tiled_offset+temp4*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+96,
+ yuv420_v_dest+linear_offset+96,
+ nv12t_uv_src+tiled_offset1+2048, 64);
+ linear_offset = linear_offset+128;
+ }
+
+ tiled_offset1 = tiled_offset1+temp4*2048;
+ temp2 = yuv420_width-right-j;
+ if (temp2 > 192) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
+ yuv420_v_dest+linear_offset+32,
+ nv12t_uv_src+tiled_offset+2048, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
+ yuv420_v_dest+linear_offset+64,
+ nv12t_uv_src+tiled_offset1, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+96,
+ yuv420_v_dest+linear_offset+96,
+ nv12t_uv_src+tiled_offset1+2048, temp2-192);
+ } else if (temp2 > 128) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
+ yuv420_v_dest+linear_offset+32,
+ nv12t_uv_src+tiled_offset+2048, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+64,
+ yuv420_v_dest+linear_offset+64,
+ nv12t_uv_src+tiled_offset1, temp2-128);
+ } else if (temp2 > 64) {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset+32,
+ yuv420_v_dest+linear_offset+32,
+ nv12t_uv_src+tiled_offset+2048, temp2-64);
+ } else {
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, temp2);
+ }
+ }
+ } else if (temp1 >= 64) {
+ for (i=top; i<(yuv420_uv_height-buttom); i=i+1) {
+ j = left;
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
+ temp2 = ((j+64)>>6)<<6;
+ temp2 = temp2-j;
+ temp3 = yuv420_width-right;
+ temp4 = temp3-left;
+ linear_offset = temp4*(i-top)/2;
+ temp4 = j&0x3;
+ tiled_offset = tiled_offset+temp4;
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, temp2);
+ linear_offset = linear_offset+temp2/2;
+ j = j+temp2;
+ if ((j+64) <= temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ linear_offset = linear_offset+32;
+ j = j+64;
+ }
+ if ((j+64) <= temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 64);
+ linear_offset = linear_offset+32;
+ j = j+64;
+ }
+ if (j < temp3) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
+ temp1 = temp3-j;
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, temp1);
+ }
+ }
+ } else {
+ for (i=top; i<(yuv420_uv_height-buttom); i=i+1) {
+ temp3 = yuv420_width-right;
+ temp4 = temp3-left;
+ linear_offset = temp4*(i-top)/2;
+ for (j=left; j<(yuv420_width-right); j=j+2) {
+ tiled_offset = tile_4x2_read(yuv420_width, yuv420_uv_height, j, i);
+ temp3 = j&0x3;
+ tiled_offset = tiled_offset+temp3;
+ csc_deinterleave_memcpy(yuv420_u_dest+linear_offset,
+ yuv420_v_dest+linear_offset,
+ nv12t_uv_src+tiled_offset, 2);
+ linear_offset = linear_offset+1;
+ }
+ }
+ }
+}
+
+/*
+ * Converts linear data to tiled
+ * Crops left, top, right, buttom
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+static void csc_linear_to_tiled_crop(
+ unsigned char *nv12t_dest,
+ unsigned char *yuv420_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0, aligned_y_size = 0;
+ unsigned int tiled_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5;
+ aligned_x_size = ((yuv420_width-left-right)>>6)<<6;
+
+ for (i=0; i<aligned_y_size; i=i+32) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ memcpy(nv12t_dest+tiled_offset, yuv420_src+left+j+yuv420_width*(i+top), 64);
+ memcpy(nv12t_dest+tiled_offset+64*1, yuv420_src+left+j+yuv420_width*(i+top+1), 64);
+ memcpy(nv12t_dest+tiled_offset+64*2, yuv420_src+left+j+yuv420_width*(i+top+2), 64);
+ memcpy(nv12t_dest+tiled_offset+64*3, yuv420_src+left+j+yuv420_width*(i+top+3), 64);
+ memcpy(nv12t_dest+tiled_offset+64*4, yuv420_src+left+j+yuv420_width*(i+top+4), 64);
+ memcpy(nv12t_dest+tiled_offset+64*5, yuv420_src+left+j+yuv420_width*(i+top+5), 64);
+ memcpy(nv12t_dest+tiled_offset+64*6, yuv420_src+left+j+yuv420_width*(i+top+6), 64);
+ memcpy(nv12t_dest+tiled_offset+64*7, yuv420_src+left+j+yuv420_width*(i+top+7), 64);
+ memcpy(nv12t_dest+tiled_offset+64*8, yuv420_src+left+j+yuv420_width*(i+top+8), 64);
+ memcpy(nv12t_dest+tiled_offset+64*9, yuv420_src+left+j+yuv420_width*(i+top+9), 64);
+ memcpy(nv12t_dest+tiled_offset+64*10, yuv420_src+left+j+yuv420_width*(i+top+10), 64);
+ memcpy(nv12t_dest+tiled_offset+64*11, yuv420_src+left+j+yuv420_width*(i+top+11), 64);
+ memcpy(nv12t_dest+tiled_offset+64*12, yuv420_src+left+j+yuv420_width*(i+top+12), 64);
+ memcpy(nv12t_dest+tiled_offset+64*13, yuv420_src+left+j+yuv420_width*(i+top+13), 64);
+ memcpy(nv12t_dest+tiled_offset+64*14, yuv420_src+left+j+yuv420_width*(i+top+14), 64);
+ memcpy(nv12t_dest+tiled_offset+64*15, yuv420_src+left+j+yuv420_width*(i+top+15), 64);
+ memcpy(nv12t_dest+tiled_offset+64*16, yuv420_src+left+j+yuv420_width*(i+top+16), 64);
+ memcpy(nv12t_dest+tiled_offset+64*17, yuv420_src+left+j+yuv420_width*(i+top+17), 64);
+ memcpy(nv12t_dest+tiled_offset+64*18, yuv420_src+left+j+yuv420_width*(i+top+18), 64);
+ memcpy(nv12t_dest+tiled_offset+64*19, yuv420_src+left+j+yuv420_width*(i+top+19), 64);
+ memcpy(nv12t_dest+tiled_offset+64*20, yuv420_src+left+j+yuv420_width*(i+top+20), 64);
+ memcpy(nv12t_dest+tiled_offset+64*21, yuv420_src+left+j+yuv420_width*(i+top+21), 64);
+ memcpy(nv12t_dest+tiled_offset+64*22, yuv420_src+left+j+yuv420_width*(i+top+22), 64);
+ memcpy(nv12t_dest+tiled_offset+64*23, yuv420_src+left+j+yuv420_width*(i+top+23), 64);
+ memcpy(nv12t_dest+tiled_offset+64*24, yuv420_src+left+j+yuv420_width*(i+top+24), 64);
+ memcpy(nv12t_dest+tiled_offset+64*25, yuv420_src+left+j+yuv420_width*(i+top+25), 64);
+ memcpy(nv12t_dest+tiled_offset+64*26, yuv420_src+left+j+yuv420_width*(i+top+26), 64);
+ memcpy(nv12t_dest+tiled_offset+64*27, yuv420_src+left+j+yuv420_width*(i+top+27), 64);
+ memcpy(nv12t_dest+tiled_offset+64*28, yuv420_src+left+j+yuv420_width*(i+top+28), 64);
+ memcpy(nv12t_dest+tiled_offset+64*29, yuv420_src+left+j+yuv420_width*(i+top+29), 64);
+ memcpy(nv12t_dest+tiled_offset+64*30, yuv420_src+left+j+yuv420_width*(i+top+30), 64);
+ memcpy(nv12t_dest+tiled_offset+64*31, yuv420_src+left+j+yuv420_width*(i+top+31), 64);
+ }
+ }
+
+ for (i=aligned_y_size; i<(yuv420_height-top-buttom); i=i+2) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ memcpy(nv12t_dest+tiled_offset+64*(temp1), yuv420_src+left+j+yuv420_width*(i+top), 64);
+ memcpy(nv12t_dest+tiled_offset+64*(temp1+1), yuv420_src+left+j+yuv420_width*(i+top+1), 64);
+ }
+ }
+
+ for (i=0; i<(yuv420_height-top-buttom); i=i+2) {
+ for (j=aligned_x_size; j<(yuv420_width-left-right); j=j+2) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1), yuv420_src+left+j+yuv420_width*(i+top), 2);
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1+1), yuv420_src+left+j+yuv420_width*(i+top+1), 2);
+ }
+ }
+
+}
+
+/*
+ * Converts and Interleaves linear to tiled
+ * Crops left, top, right, buttom
+ * 1. UV of YUV420P to UV of NV12T
+ *
+ * @param nv12t_uv_dest
+ * UV plane address of NV12T[out]
+ *
+ * @param yuv420p_u_src
+ * U plane address of YUV420P[in]
+ *
+ * @param yuv420p_v_src
+ * V plane address of YUV420P[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+static void csc_linear_to_tiled_interleave_crop(
+ unsigned char *nv12t_uv_dest,
+ unsigned char *yuv420_u_src,
+ unsigned char *yuv420_v_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0, aligned_y_size = 0;
+ unsigned int tiled_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ aligned_y_size = ((yuv420_height-top-buttom)>>5)<<5;
+ aligned_x_size = ((yuv420_width-left-right)>>6)<<6;
+
+ for (i=0; i<aligned_y_size; i=i+32) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*1,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+1),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+1), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*2,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+2),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+2), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*3,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+3),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+3), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*4,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+4),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+4), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*5,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+5),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+5), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*6,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+6),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+6), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*7,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+7),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+7), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*8,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+8),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+8), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*9,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+9),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+9), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*10,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+10),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+10), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*11,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+11),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+11), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*12,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+12),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+12), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*13,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+13),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+13), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*14,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+14),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+14), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*15,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+15),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+15), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*16,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+16),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+16), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*17,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+17),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+17), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*18,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+18),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+18), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*19,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+19),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+19), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*20,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+20),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+20), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*21,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+21),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+21), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*22,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+22),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+22), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*23,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+23),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+23), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*24,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+24),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+24), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*25,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+25),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+25), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*26,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+26),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+26), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*27,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+27),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+27), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*28,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+28),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+28), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*29,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+29),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+29), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*30,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+30),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+30), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*31,
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top+31),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top+31), 32);
+
+ }
+ }
+
+ for (i=aligned_y_size; i<(yuv420_height-top-buttom); i=i+1) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1),
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 32);
+ }
+ }
+
+ for (i=0; i<(yuv420_height-top-buttom); i=i+1) {
+ for (j=aligned_x_size; j<(yuv420_width-left-right); j=j+2) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = (((yuv420_height-top-buttom)+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = (((yuv420_width-left-right)+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1),
+ yuv420_u_src+left/2+j/2+yuv420_width/2*(i+top),
+ yuv420_v_src+left/2+j/2+yuv420_width/2*(i+top), 1);
+ }
+ }
+
+}
+
+
+/*
+ * Converts tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+void csc_tiled_to_linear_crop_neon(
+ unsigned char *yuv420_dest,
+ unsigned char *nv12t_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom);
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * Crops left, top, right, buttom
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+void csc_tiled_to_linear_deinterleave_crop_neon(
+ unsigned char *yuv420_u_dest,
+ unsigned char *yuv420_v_dest,
+ unsigned char *nv12t_uv_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_uv_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom);
+
+/*
+ * Converts linear data to tiled
+ * Crops left, top, right, buttom
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+void csc_linear_to_tiled_crop_neon(
+ unsigned char *nv12t_dest,
+ unsigned char *yuv420_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom);
+
+/*
+ * Converts and Interleaves linear to tiled
+ * Crops left, top, right, buttom
+ * 1. UV of YUV420P to UV of NV12T
+ *
+ * @param nv12t_uv_dest
+ * UV plane address of NV12T[out]
+ *
+ * @param yuv420p_u_src
+ * U plane address of YUV420P[in]
+ *
+ * @param yuv420p_v_src
+ * V plane address of YUV420P[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ *
+ * @param left
+ * Crop size of left
+ *
+ * @param top
+ * Crop size of top
+ *
+ * @param right
+ * Crop size of right
+ *
+ * @param buttom
+ * Crop size of buttom
+ */
+void csc_linear_to_tiled_interleave_crop_neon(
+ unsigned char *nv12t_uv_dest,
+ unsigned char *yuv420_u_src,
+ unsigned char *yuv420_v_src,
+ unsigned int yuv420_width,
+ unsigned int yuv420_height,
+ unsigned int left,
+ unsigned int top,
+ unsigned int right,
+ unsigned int buttom);
+
+/*
+ * Converts tiled data to linear.
+ * 1. y of nv12t to y of yuv420p
+ * 2. y of nv12t to y of yuv420s
+ *
+ * @param dst
+ * y address of yuv420[out]
+ *
+ * @param src
+ * y address of nv12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_tiled_to_linear_y(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_crop(y_dst, y_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts tiled data to linear
+ * 1. uv of nv12t to y of yuv420s
+ *
+ * @param dst
+ * uv address of yuv420s[out]
+ *
+ * @param src
+ * uv address of nv12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420s[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420s[in]
+ *
+ */
+void csc_tiled_to_linear_uv(
+ unsigned char *uv_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_crop(uv_dst, uv_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts tiled data to linear
+ * 1. uv of nt12t to uv of yuv420p
+ *
+ * @param u_dst
+ * u address of yuv420p[out]
+ *
+ * @param v_dst
+ * v address of yuv420p[out]
+ *
+ * @param uv_src
+ * uv address of nt12t[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420p[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420p[in]
+ */
+void csc_tiled_to_linear_uv_deinterleave(
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_deinterleave_crop(u_dst, v_dst, uv_src, width, height,
+ 0, 0, 0, 0);
+}
+
+/*
+ * Converts linear data to tiled
+ * 1. y of yuv420 to y of nv12t
+ *
+ * @param dst
+ * y address of nv12t[out]
+ *
+ * @param src
+ * y address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_linear_to_tiled_y(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_linear_to_tiled_crop(y_dst, y_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts and interleaves linear data to tiled
+ * 1. uv of nv12t to uv of yuv420
+ *
+ * @param dst
+ * uv address of nv12t[out]
+ *
+ * @param src
+ * u address of yuv420[in]
+ *
+ * @param src
+ * v address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ *
+ */
+void csc_linear_to_tiled_uv(
+ unsigned char *uv_dst,
+ unsigned char *u_src,
+ unsigned char *v_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_linear_to_tiled_interleave_crop(uv_dst, u_src, v_src, width, height,
+ 0, 0, 0, 0);
+}
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ *
+ * @param dst
+ * Y address of YUV420[out]
+ *
+ * @param src
+ * Y address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: real height of YUV420[in]
+ *
+ */
+void csc_tiled_to_linear_y_neon(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_crop_neon(y_dst, y_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * 1. UV of NV12T to Y of YUV420S
+ *
+ * @param u_dst
+ * UV plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * (real height)/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_uv_neon(
+ unsigned char *uv_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_crop_neon(uv_dst, uv_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts tiled data to linear for mfc 6.x
+ * Deinterleave src to u_dst, v_dst
+ * 1. UV of NV12T to Y of YUV420P
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * real width of YUV420[in]
+ *
+ * @param yuv420_height
+ * (real height)/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_uv_deinterleave_neon(
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *uv_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_tiled_to_linear_deinterleave_crop_neon(u_dst, v_dst, uv_src, width, height,
+ 0, 0, 0, 0);
+}
+
+/*
+ * Converts linear data to tiled
+ * 1. y of yuv420 to y of nv12t
+ *
+ * @param dst
+ * y address of nv12t[out]
+ *
+ * @param src
+ * y address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ * it should be even
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ * it should be even.
+ *
+ */
+void csc_linear_to_tiled_y_neon(
+ unsigned char *y_dst,
+ unsigned char *y_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_linear_to_tiled_crop_neon(y_dst, y_src, width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts and interleaves linear data to tiled
+ * 1. uv of nv12t to uv of yuv420
+ *
+ * @param dst
+ * uv address of nv12t[out]
+ *
+ * @param src
+ * u address of yuv420[in]
+ *
+ * @param src
+ * v address of yuv420[in]
+ *
+ * @param yuv420_width
+ * real width of yuv420[in]
+ *
+ * @param yuv420_height
+ * real height of yuv420[in]
+ *
+ */
+void csc_linear_to_tiled_uv_neon(
+ unsigned char *uv_dst,
+ unsigned char *u_src,
+ unsigned char *v_src,
+ unsigned int width,
+ unsigned int height)
+{
+ csc_linear_to_tiled_interleave_crop_neon(uv_dst, u_src, v_src,
+ width, height, 0, 0, 0, 0);
+}
+
+/*
+ * Converts RGB565 to YUV420P
+ *
+ * @param y_dst
+ * Y plane address of YUV420P[out]
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param rgb_src
+ * Address of RGB565[in]
+ *
+ * @param width
+ * Width of RGB565[in]
+ *
+ * @param height
+ * Height of RGB565[in]
+ */
+void csc_RGB565_to_YUV420P(
+ unsigned char *y_dst,
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height)
+{
+ unsigned int i, j;
+ unsigned int tmp;
+
+ unsigned int R, G, B;
+ unsigned int Y, U, V;
+
+ unsigned int offset1 = width * height;
+ unsigned int offset2 = width/2 * height/2;
+
+ unsigned short int *pSrc = (unsigned short int *)rgb_src;
+
+ unsigned char *pDstY = (unsigned char *)y_dst;
+ unsigned char *pDstU = (unsigned char *)u_dst;
+ unsigned char *pDstV = (unsigned char *)v_dst;
+
+ unsigned int yIndex = 0;
+ unsigned int uIndex = 0;
+ unsigned int vIndex = 0;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ tmp = pSrc[j * width + i];
+
+ R = (tmp & 0x0000F800) >> 8;
+ G = (tmp & 0x000007E0) >> 3;
+ B = (tmp & 0x0000001F);
+ B = B << 3;
+
+ Y = ((66 * R) + (129 * G) + (25 * B) + 128);
+ Y = Y >> 8;
+ Y += 16;
+
+ pDstY[yIndex++] = (unsigned char)Y;
+
+ if ((j % 2) == 0 && (i % 2) == 0) {
+ U = ((-38 * R) - (74 * G) + (112 * B) + 128);
+ U = U >> 8;
+ U += 128;
+ V = ((112 * R) - (94 * G) - (18 * B) + 128);
+ V = V >> 8;
+ V += 128;
+
+ pDstU[uIndex++] = (unsigned char)U;
+ pDstV[vIndex++] = (unsigned char)V;
+ }
+ }
+ }
+}
+
+/*
+ * Converts RGB565 to YUV420SP
+ *
+ * @param y_dst
+ * Y plane address of YUV420SP[out]
+ *
+ * @param uv_dst
+ * UV plane address of YUV420SP[out]
+ *
+ * @param rgb_src
+ * Address of RGB565[in]
+ *
+ * @param width
+ * Width of RGB565[in]
+ *
+ * @param height
+ * Height of RGB565[in]
+ */
+void csc_RGB565_to_YUV420SP(
+ unsigned char *y_dst,
+ unsigned char *uv_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height)
+{
+ unsigned int i, j;
+ unsigned int tmp;
+
+ unsigned int R, G, B;
+ unsigned int Y, U, V;
+
+ unsigned int offset = width * height;
+
+ unsigned short int *pSrc = (unsigned short int *)rgb_src;
+
+ unsigned char *pDstY = (unsigned char *)y_dst;
+ unsigned char *pDstUV = (unsigned char *)uv_dst;
+
+ unsigned int yIndex = 0;
+ unsigned int uvIndex = 0;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ tmp = pSrc[j * width + i];
+
+ R = (tmp & 0x0000F800) >> 11;
+ R = R * 8;
+ G = (tmp & 0x000007E0) >> 5;
+ G = G * 4;
+ B = (tmp & 0x0000001F);
+ B = B * 8;
+
+ Y = ((66 * R) + (129 * G) + (25 * B) + 128);
+ Y = Y >> 8;
+ Y += 16;
+
+ pDstY[yIndex++] = (unsigned char)Y;
+
+ if ((j % 2) == 0 && (i % 2) == 0) {
+ U = ((-38 * R) - (74 * G) + (112 * B) + 128);
+ U = U >> 8;
+ U += 128;
+ V = ((112 * R) - (94 * G) - (18 * B) + 128);
+ V = V >> 8;
+ V += 128;
+
+ pDstUV[uvIndex++] = (unsigned char)U;
+ pDstUV[uvIndex++] = (unsigned char)V;
+ }
+ }
+ }
+}
+
+/*
+ * Converts ARGB8888 to YUV420P
+ *
+ * @param y_dst
+ * Y plane address of YUV420P[out]
+ *
+ * @param u_dst
+ * U plane address of YUV420P[out]
+ *
+ * @param v_dst
+ * V plane address of YUV420P[out]
+ *
+ * @param rgb_src
+ * Address of ARGB8888[in]
+ *
+ * @param width
+ * Width of ARGB8888[in]
+ *
+ * @param height
+ * Height of ARGB8888[in]
+ */
+void csc_ARGB8888_to_YUV420P(
+ unsigned char *y_dst,
+ unsigned char *u_dst,
+ unsigned char *v_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height)
+{
+ unsigned int i, j;
+ unsigned int tmp;
+
+ unsigned int R, G, B;
+ unsigned int Y, U, V;
+
+ unsigned int offset1 = width * height;
+ unsigned int offset2 = width/2 * height/2;
+
+ unsigned int *pSrc = (unsigned int *)rgb_src;
+
+ unsigned char *pDstY = (unsigned char *)y_dst;
+ unsigned char *pDstU = (unsigned char *)u_dst;
+ unsigned char *pDstV = (unsigned char *)v_dst;
+
+ unsigned int yIndex = 0;
+ unsigned int uIndex = 0;
+ unsigned int vIndex = 0;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ tmp = pSrc[j * width + i];
+
+ R = (tmp & 0x00FF0000) >> 16;
+ G = (tmp & 0x0000FF00) >> 8;
+ B = (tmp & 0x000000FF);
+
+ Y = ((66 * R) + (129 * G) + (25 * B) + 128);
+ Y = Y >> 8;
+ Y += 16;
+
+ pDstY[yIndex++] = (unsigned char)Y;
+
+ if ((j % 2) == 0 && (i % 2) == 0) {
+ U = ((-38 * R) - (74 * G) + (112 * B) + 128);
+ U = U >> 8;
+ U += 128;
+ V = ((112 * R) - (94 * G) - (18 * B) + 128);
+ V = V >> 8;
+ V += 128;
+
+ pDstU[uIndex++] = (unsigned char)U;
+ pDstV[vIndex++] = (unsigned char)V;
+ }
+ }
+ }
+}
+
+
+/*
+ * Converts ARGB8888 to YUV420SP
+ *
+ * @param y_dst
+ * Y plane address of YUV420SP[out]
+ *
+ * @param uv_dst
+ * UV plane address of YUV420SP[out]
+ *
+ * @param rgb_src
+ * Address of ARGB8888[in]
+ *
+ * @param width
+ * Width of ARGB8888[in]
+ *
+ * @param height
+ * Height of ARGB8888[in]
+ */
+void csc_ARGB8888_to_YUV420SP(
+ unsigned char *y_dst,
+ unsigned char *uv_dst,
+ unsigned char *rgb_src,
+ unsigned int width,
+ unsigned int height)
+{
+ unsigned int i, j;
+ unsigned int tmp;
+
+ unsigned int R, G, B;
+ unsigned int Y, U, V;
+
+ unsigned int offset = width * height;
+
+ unsigned int *pSrc = (unsigned int *)rgb_src;
+
+ unsigned char *pDstY = (unsigned char *)y_dst;
+ unsigned char *pDstUV = (unsigned char *)uv_dst;
+
+ unsigned int yIndex = 0;
+ unsigned int uvIndex = 0;
+
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ tmp = pSrc[j * width + i];
+
+ R = (tmp & 0x00FF0000) >> 16;
+ G = (tmp & 0x0000FF00) >> 8;
+ B = (tmp & 0x000000FF);
+
+ Y = ((66 * R) + (129 * G) + (25 * B) + 128);
+ Y = Y >> 8;
+ Y += 16;
+
+ pDstY[yIndex++] = (unsigned char)Y;
+
+ if ((j % 2) == 0 && (i % 2) == 0) {
+ U = ((-38 * R) - (74 * G) + (112 * B) + 128);
+ U = U >> 8;
+ U += 128;
+ V = ((112 * R) - (94 * G) - (18 * B) + 128);
+ V = V >> 8;
+ V += 128;
+
+ pDstUV[uvIndex++] = (unsigned char)U;
+ pDstUV[uvIndex++] = (unsigned char)V;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/exynos4/hal/libump/Android.mk b/exynos4/hal/libump/Android.mk
new file mode 100644
index 0000000..687370c
--- /dev/null
+++ b/exynos4/hal/libump/Android.mk
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2010 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.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+UMP_SRCS := \
+ arch_011_udd/ump_frontend.c \
+ arch_011_udd/ump_ref_drv.c \
+ arch_011_udd/ump_arch.c \
+ os/linux/ump_uku.c \
+ os/linux/ump_osu_memory.c \
+ os/linux/ump_osu_locks.c
+
+# Shared and static library for target
+# ========================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := libUMP
+LOCAL_SRC_FILES := $(UMP_SRCS)
+
+LOCAL_C_INCLUDES:= \
+ $(BOARD_HAL_PATH)/libump/ \
+ $(BOARD_HAL_PATH)/libump/include/ump \
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT_STATIC_LIBRARIES)/
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libUMP
+LOCAL_MODULE_TAGS := optional
+LOCAL_WHOLE_STATIC_LIBRARIES := libUMP
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos4/hal/libump/Makefile b/exynos4/hal/libump/Makefile
new file mode 100644
index 0000000..b936fe9
--- /dev/null
+++ b/exynos4/hal/libump/Makefile
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+#
+# 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.
+#
+
+UMP_DIR ?= .
+UMP_LIB ?= libUMP
+UDD_OS ?= android
+#CROSS_COMPILE ?= arm-none-linux-gnueabi-
+TARGET_CC ?= $(CROSS_COMPILE)gcc
+TARGET_AR ?= $(CROSS_COMPILE)ar
+CFLAGS += -I$(UMP_DIR)/include -I$(UMP_DIR)/include/ump -Wall -march=armv6 -mthumb-interwork -fno-strict-aliasing -Wno-strict-aliasing -Wno-long-long -O3
+
+include ump.mak
+
+%.o: %.c
+ $(TARGET_CC) -c -o $@ $< $(CFLAGS)
+
+UMP_OBJS := $(UMP_SRCS:.c=.o)
+
+libUMP.so: $(UMP_OBJS)
+ arm-none-linux-gnueabi-gcc -shared -o $@ $(UMP_OBJS) $(CFLAGS)
+libUMP.a: $(UMP_OBJS)
+ $(TARGET_AR) rcs $@ $(UMP_OBJS)
+
+clean:
+ -rm -f $(UMP_OBJS) libUMP.so libUMP.a
diff --git a/exynos4/hal/libump/arch_011_udd/ump_arch.c b/exynos4/hal/libump/arch_011_udd/ump_arch.c
new file mode 100644
index 0000000..79c3c18
--- /dev/null
+++ b/exynos4/hal/libump/arch_011_udd/ump_arch.c
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_arch.c
+ *
+ * UMP arch layer for UMP-UDD
+ */
+
+#include <ump/ump.h>
+#include "ump_arch.h"
+#include <ump/ump_debug.h>
+
+#include <ump/ump_uk_types.h>
+#include "../os/ump_uku.h"
+
+/** Pointer to an OS-Specific context that we should pass in _uku_ calls */
+void *ump_uk_ctx = NULL;
+
+/** Reference counting of ump_arch_open() and ump_arch_close(). */
+volatile static int ump_ref_count = 0;
+
+/** Lock for critical section in open/close */
+_ump_osu_lock_t * ump_lock = NULL;
+
+ump_result ump_arch_open(void)
+{
+ ump_result retval = UMP_OK;
+
+ _ump_osu_lock_auto_init( &ump_lock, 0, 0, 0 );
+
+ /* Check that the lock was initialized */
+ if (NULL == ump_lock)
+ {
+ UMP_DEBUG_PRINT(1, ("UMP: ump_arch_open() failed to init lock\n"));
+ return UMP_ERROR;
+ }
+
+ /* Attempt to obtain a lock */
+ if( _UMP_OSU_ERR_OK != _ump_osu_lock_wait( ump_lock, _UMP_OSU_LOCKMODE_RW ) )
+ {
+ UMP_DEBUG_PRINT(1, ("UMP: ump_arch_open() failed to acquire lock\n"));
+ return UMP_ERROR;
+ }
+
+ /* ASSERT NEEDED */
+ UMP_DEBUG_ASSERT(0 <= ump_ref_count, ("UMP: Reference count invalid at _ump_base_arch_open()"));
+ ump_ref_count++;
+
+ if (1 == ump_ref_count)
+ {
+ /* We are the first, open the UMP device driver */
+
+ if (_UMP_OSU_ERR_OK != _ump_uku_open( &ump_uk_ctx ))
+ {
+ UMP_DEBUG_PRINT(1, ("UMP: ump_arch_open() failed to open UMP device driver\n"));
+ retval = UMP_ERROR;
+ ump_ref_count--;
+ }
+ }
+
+ /* Signal the lock so someone else can use it */
+ _ump_osu_lock_signal( ump_lock, _UMP_OSU_LOCKMODE_RW );
+
+ return retval;
+}
+
+
+
+void ump_arch_close(void)
+{
+ _ump_osu_lock_auto_init( &ump_lock, 0, 0, 0 );
+
+ /* Check that the lock was initialized */
+ if(NULL == ump_lock)
+ {
+ UMP_DEBUG_PRINT(1, ("UMP: ump_arch_close() failed to init lock\n"));
+ return;
+ }
+
+ /* Attempt to obtain a lock */
+ if( _UMP_OSU_ERR_OK != _ump_osu_lock_wait( ump_lock, _UMP_OSU_LOCKMODE_RW ) )
+ {
+ UMP_DEBUG_PRINT(1, ("UMP: ump_arch_close() failed to acquire lock\n"));
+ return;
+ }
+
+ UMP_DEBUG_ASSERT(0 < ump_ref_count, ("UMP: ump_arch_close() called while no references exist"));
+ if (ump_ref_count > 0)
+ {
+ ump_ref_count--;
+ if (0 == ump_ref_count)
+ {
+ _ump_osu_errcode_t retval = _ump_uku_close(&ump_uk_ctx);
+ UMP_DEBUG_ASSERT(retval == _UMP_OSU_ERR_OK, ("UMP: Failed to close UMP interface"));
+ UMP_IGNORE(retval);
+ ump_uk_ctx = NULL;
+ _ump_osu_lock_signal( ump_lock, _UMP_OSU_LOCKMODE_RW );
+ _ump_osu_lock_term( ump_lock ); /* Not 100% thread safe, since another thread can already be waiting for this lock in ump_arch_open() */
+ ump_lock = NULL;
+ return;
+ }
+ }
+
+ /* Signal the lock so someone else can use it */
+ _ump_osu_lock_signal( ump_lock, _UMP_OSU_LOCKMODE_RW );
+}
+
+
+
+ump_secure_id ump_arch_allocate(unsigned long * size, ump_alloc_constraints constraints)
+{
+ _ump_uk_allocate_s call_arg;
+
+ if ( NULL == size )
+ {
+ return UMP_INVALID_SECURE_ID;
+ }
+
+ call_arg.ctx = ump_uk_ctx;
+ call_arg.secure_id = UMP_INVALID_SECURE_ID;
+ call_arg.size = *size;
+#ifdef UMP_DEBUG_SKIP_CODE
+ /** Run-time ASSERTing that _ump_uk_api_version_s and ump_alloc_constraints are
+ * interchangable */
+ switch (constraints)
+ {
+ case UMP_REF_DRV_CONSTRAINT_NONE:
+ UMP_DEBUG_ASSERT( UMP_REF_DRV_UK_CONSTRAINT_NONE == constraints, ("ump_uk_alloc_constraints out of sync with ump_alloc_constraints") );
+ break;
+ case UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR:
+ UMP_DEBUG_ASSERT( UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR == constraints, ("ump_uk_alloc_constraints out of sync with ump_alloc_constraints") );
+ break;
+ default:
+ UMP_DEBUG_ASSERT( 1, ("ump_uk_alloc_constraints out of sync with ump_alloc_constraints: %d unrecognized", constraints) );
+ break;
+ }
+#endif
+ call_arg.constraints = (ump_uk_alloc_constraints)constraints;
+
+ if ( _UMP_OSU_ERR_OK != _ump_uku_allocate(&call_arg) )
+ {
+ return UMP_INVALID_SECURE_ID;
+ }
+
+ *size = call_arg.size;
+
+ UMP_DEBUG_PRINT(4, ("UMP: Allocated ID %u, size %ul", call_arg.secure_id, call_arg.size));
+
+ return call_arg.secure_id;
+}
+
+
+
+unsigned long ump_arch_size_get(ump_secure_id secure_id)
+{
+ _ump_uk_size_get_s dd_size_call_arg;
+
+ dd_size_call_arg.ctx = ump_uk_ctx;
+ dd_size_call_arg.secure_id = secure_id;
+ dd_size_call_arg.size = 0;
+
+ if (_UMP_OSU_ERR_OK == _ump_uku_size_get( &dd_size_call_arg ) )
+ {
+ return dd_size_call_arg.size;
+ }
+
+ return 0;
+}
+
+
+void ump_arch_reference_release(ump_secure_id secure_id)
+{
+ _ump_uk_release_s dd_release_call_arg;
+ _ump_osu_errcode_t retval;
+
+ dd_release_call_arg.ctx = ump_uk_ctx;
+ dd_release_call_arg.secure_id = secure_id;
+
+ UMP_DEBUG_PRINT(4, ("UMP: Releasing ID %u", secure_id));
+
+ retval = _ump_uku_release( &dd_release_call_arg );
+ UMP_DEBUG_ASSERT(retval == _UMP_OSU_ERR_OK, ("UMP: Failed to release reference to UMP memory"));
+ UMP_IGNORE(retval);
+}
+
+
+void* ump_arch_map(ump_secure_id secure_id, unsigned long size, ump_cache_enabled cache, unsigned long *cookie_out)
+{
+ _ump_uk_map_mem_s dd_map_call_arg;
+
+ UMP_DEBUG_ASSERT_POINTER( cookie_out );
+
+ dd_map_call_arg.ctx = ump_uk_ctx;
+ dd_map_call_arg.secure_id = secure_id;
+ dd_map_call_arg.size = size;
+ dd_map_call_arg.is_cached = (u32) (UMP_CACHE_ENABLE==cache);
+
+ if ( -1 == _ump_uku_map_mem( &dd_map_call_arg ) )
+ {
+ UMP_DEBUG_PRINT(4, ("UMP: Mapping failed for ID %u", secure_id));
+ return NULL;
+ }
+
+ UMP_DEBUG_PRINT(4, ("Mapped %u at 0x%08lx", secure_id, (unsigned long)dd_map_call_arg.mapping));
+
+ *cookie_out = dd_map_call_arg.cookie;
+ return dd_map_call_arg.mapping;
+}
+
+
+
+void ump_arch_unmap(void* mapping, unsigned long size, unsigned long cookie)
+{
+ _ump_uk_unmap_mem_s dd_unmap_call_arg;
+
+ dd_unmap_call_arg.ctx = ump_uk_ctx;
+ dd_unmap_call_arg.mapping = mapping;
+ dd_unmap_call_arg.size = size;
+ dd_unmap_call_arg.cookie = cookie;
+
+ UMP_DEBUG_PRINT(4, ("Unmapping 0x%08lx", (unsigned long)mapping));
+ _ump_uku_unmap_mem( &dd_unmap_call_arg );
+}
+
+/** Memory synchronization - cache flushing of mapped memory */
+int ump_arch_msync(ump_secure_id secure_id, void* mapping, unsigned long cookie, void * address, unsigned long size, ump_cpu_msync_op op)
+{
+ _ump_uk_msync_s dd_msync_call_arg;
+
+ dd_msync_call_arg.ctx = ump_uk_ctx;
+ dd_msync_call_arg.mapping = mapping;
+ dd_msync_call_arg.address = address;
+ dd_msync_call_arg.size = size;
+ dd_msync_call_arg.op = (ump_uk_msync_op)op;
+ dd_msync_call_arg.cookie = cookie;
+ dd_msync_call_arg.secure_id = secure_id;
+ dd_msync_call_arg.is_cached = 0;
+
+ UMP_DEBUG_PRINT(4, ("Msync 0x%08lx", (unsigned long)mapping));
+ _ump_uku_msynch( &dd_msync_call_arg );
+ if ( 0==dd_msync_call_arg.is_cached )
+ {
+ UMP_DEBUG_PRINT(4, ("Trying to flush uncached UMP mem ID: %d", secure_id));
+ }
+ return dd_msync_call_arg.is_cached;
+}
diff --git a/exynos4/hal/libump/arch_011_udd/ump_arch.h b/exynos4/hal/libump/arch_011_udd/ump_arch.h
new file mode 100644
index 0000000..064d7c5
--- /dev/null
+++ b/exynos4/hal/libump/arch_011_udd/ump_arch.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_arch.h
+ *
+ * Header file for the arch dependent backend, which will do the communication with the UMP device driver.
+ */
+
+#ifndef _UNIFIED_MEMORY_PROVIDER_ARCH_H_
+#define _UNIFIED_MEMORY_PROVIDER_ARCH_H_
+
+#include <ump/ump.h>
+#include <ump/ump_ref_drv.h>
+#include "ump_internal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/** Open UMP interface. */
+ump_result ump_arch_open(void);
+
+/** Close UMP interface. */
+void ump_arch_close(void);
+
+/** Allocate UMP memory. */
+ump_secure_id ump_arch_allocate(unsigned long * size, ump_alloc_constraints constraints);
+
+/** Query size of specified UMP memory, in bytes. */
+unsigned long ump_arch_size_get(ump_secure_id secure_id);
+
+/** Release a reference from specified UMP memory. */
+void ump_arch_reference_release(ump_secure_id secure_id);
+
+/** Map specified UMP memory into CPU address space */
+void* ump_arch_map(ump_secure_id secure_id, unsigned long size, ump_cache_enabled cache, unsigned long *cookie_out);
+
+/** Unmap specified UMP memory from CPU adderss space */
+void ump_arch_unmap(void* mapping, unsigned long size, unsigned long cookie);
+
+/** Memory synchronization - cache flushing of mapped memory
+ * @return Is_cached: 1==True 0==NonCached */
+int ump_arch_msync(ump_secure_id secure_id, void* mapping, unsigned long cookie, void * address, unsigned long size, ump_cpu_msync_op op);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UNIFIED_MEMORY_PROVIDER_ARCH_H_ */
diff --git a/exynos4/hal/libump/arch_011_udd/ump_frontend.c b/exynos4/hal/libump/arch_011_udd/ump_frontend.c
new file mode 100644
index 0000000..8c93332
--- /dev/null
+++ b/exynos4/hal/libump/arch_011_udd/ump_frontend.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_frontend.c
+ *
+ * This file implements the user space API of the UMP API.
+ * It relies heavily on a arch backend to do the communication with the UMP device driver.
+ */
+
+#include <ump/ump.h>
+#include "ump_internal.h"
+#include "ump_arch.h"
+#include <ump/ump_debug.h>
+#include <ump/ump_osu.h>
+
+UMP_API_EXPORT ump_result ump_open(void)
+{
+ return ump_arch_open();
+}
+
+UMP_API_EXPORT void ump_close(void)
+{
+ ump_arch_close();
+}
+
+UMP_API_EXPORT ump_secure_id ump_secure_id_get(ump_handle memh)
+{
+ ump_mem * mem = (ump_mem*)memh;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != mem->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < mem->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < mem->size, ("Memory size of passed handle too low"));
+
+ return mem->secure_id;
+}
+
+UMP_API_EXPORT ump_handle ump_handle_create_from_secure_id(ump_secure_id secure_id)
+{
+ unsigned long size;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != secure_id, ("Secure ID is invalid"));
+
+ size = ump_arch_size_get(secure_id);
+ if (0 != size)
+ {
+ unsigned long cookie;
+ /*
+ * The UMP memory which the secure_id referes to could now be deleted and re-created
+ * since we don't have any references to it yet. The mapping below will however fail if
+ * we have supplied incorrect size, so we are safe.
+ */
+ void * mapping = ump_arch_map(secure_id, size, UMP_CACHE_DISABLE, &cookie);
+ if (NULL != mapping)
+ {
+ ump_mem * mem = _ump_osu_calloc(1, sizeof(*mem));
+ if (NULL != mem)
+ {
+ mem->secure_id = secure_id;
+ mem->mapped_mem = mapping;
+ mem->size = size;
+ mem->cookie = cookie;
+ mem->is_cached = 1; /* Is set to actually check in the ump_cpu_msync_now() function */
+
+ _ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0);
+ UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n"));
+ mem->ref_count = 1;
+
+ /* This is called only to set the cache settings in this handle */
+ ump_cpu_msync_now((ump_handle)mem, UMP_MSYNC_READOUT_CACHE_ENABLED, NULL, 0);
+
+ UMP_DEBUG_PRINT(4, ("UMP handle created for ID %u of size %lu, mapped into address 0x%08lx", mem->secure_id, mem->size, (unsigned long)mem->mapped_mem));
+
+ return (ump_handle)mem;
+ }
+
+ ump_arch_unmap(mapping, size, cookie);
+ }
+ }
+
+ UMP_DEBUG_PRINT(2, ("UMP handle creation failed for ID %u", secure_id));
+
+ return UMP_INVALID_MEMORY_HANDLE;
+}
+
+UMP_API_EXPORT unsigned long ump_size_get(ump_handle memh)
+{
+ ump_mem * mem = (ump_mem*)memh;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != mem->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < mem->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < mem->size, ("Memory size of passed handle too low"));
+
+ return mem->size;
+}
+
+UMP_API_EXPORT void ump_read(void *dst, ump_handle srch, unsigned long offset, unsigned long length)
+{
+ ump_mem * src = (ump_mem*)srch;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != srch, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != src->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < src->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < src->size, ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != src->mapped_mem, ("UMP Memory is not mapped"));
+ UMP_DEBUG_ASSERT((src->size) >= (offset + length), ("Requested read beyond end of UMP memory"));
+
+ _ump_osu_memcpy(dst,(char*)(src->mapped_mem) + offset, length);
+}
+
+UMP_API_EXPORT void ump_write(ump_handle dsth, unsigned long offset, const void *src, unsigned long length)
+{
+ ump_mem * dst = (ump_mem*)dsth;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != dsth, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != dst->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < dst->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < dst->size, ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != dst->mapped_mem, ("UMP Memory is not mapped"));
+ UMP_DEBUG_ASSERT((dst->size) >= (offset + length), ("Requested write beyond end of UMP memory"));
+
+ _ump_osu_memcpy((char*)(dst->mapped_mem) + offset, src, length);
+}
+
+
+
+UMP_API_EXPORT void* ump_mapped_pointer_get(ump_handle memh)
+{
+ ump_mem * mem = (ump_mem*)memh;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != mem->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < mem->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < mem->size, ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != mem->mapped_mem, ("Error in mapping pointer (not mapped)"));
+
+ return mem->mapped_mem;
+}
+
+
+
+UMP_API_EXPORT void ump_mapped_pointer_release(ump_handle memh)
+{
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != ((ump_mem*)memh)->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < ((ump_mem*)memh)->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < ((ump_mem*)memh)->size, ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != ((ump_mem*)memh)->mapped_mem, ("Error in mapping pointer (not mapped)"));
+
+ /* noop, cos we map in the pointer when handle is created, and unmap it when handle is destroyed */
+}
+
+
+
+UMP_API_EXPORT void ump_reference_add(ump_handle memh)
+{
+ ump_mem * mem = (ump_mem*)memh;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != mem->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < mem->ref_count, ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < mem->size, ("Memory size of passed handle too low"));
+
+ _ump_osu_lock_wait(mem->ref_lock, _UMP_OSU_LOCKMODE_RW);
+ mem->ref_count += 1;
+ _ump_osu_lock_signal(mem->ref_lock, _UMP_OSU_LOCKMODE_RW);
+}
+
+
+
+UMP_API_EXPORT void ump_reference_release(ump_handle memh)
+{
+ ump_mem * mem = (ump_mem*)memh;
+
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+ UMP_DEBUG_ASSERT(UMP_INVALID_SECURE_ID != ((ump_mem*)mem)->secure_id, ("Secure ID is inavlid"));
+ UMP_DEBUG_ASSERT(0 < (((ump_mem*)mem)->ref_count), ("Reference count too low"));
+ UMP_DEBUG_ASSERT(0 < ((ump_mem*)mem)->size, ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != ((ump_mem*)mem)->mapped_mem, ("Error in mapping pointer (not mapped)"));
+
+ _ump_osu_lock_wait(mem->ref_lock, _UMP_OSU_LOCKMODE_RW);
+ mem->ref_count -= 1;
+ if (0 == mem->ref_count)
+ {
+ /* Remove memory mapping, which holds our only reference towards the UMP kernel space driver */
+ ump_arch_unmap(mem->mapped_mem, mem->size, mem->cookie);
+
+ _ump_osu_lock_signal(mem->ref_lock, _UMP_OSU_LOCKMODE_RW);
+
+ /* Free the lock protecting the reference count */
+ _ump_osu_lock_term(mem->ref_lock);
+
+ /* Free the memory for this handle */
+ _ump_osu_free(mem);
+ } else {
+ _ump_osu_lock_signal(mem->ref_lock, _UMP_OSU_LOCKMODE_RW);
+ }
+}
diff --git a/exynos4/hal/libump/arch_011_udd/ump_internal.h b/exynos4/hal/libump/arch_011_udd/ump_internal.h
new file mode 100644
index 0000000..bc1f2a9
--- /dev/null
+++ b/exynos4/hal/libump/arch_011_udd/ump_internal.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_internal.c
+ *
+ * Internal definitions and debugging macros for the UMP implementation.
+ */
+
+#ifndef _UNIFIED_MEMORY_PROVIDER_INTERNAL_H_
+#define _UNIFIED_MEMORY_PROVIDER_INTERNAL_H_
+
+#include <ump/ump.h>
+#include <ump/ump_osu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum ump_cache_enabled
+{
+ UMP_CACHE_DISABLE = 0,
+ UMP_CACHE_ENABLE = 1
+} ump_cache_enabled;
+
+/**
+ * The actual (hidden) definition of ump_handles.
+ */
+typedef struct ump_mem
+{
+ ump_secure_id secure_id; /**< UMP device driver cookie */
+ void * mapped_mem; /**< Mapped memory; all read and write use this */
+ unsigned long size; /**< Size of allocated memory */
+ _ump_osu_lock_t* ref_lock; /**< Lock protection ref_count */
+ int ref_count; /**< The reference count of the ump_handle in userspace. It is used for finding out
+ when to free the memory used by this userspace handle. It is NOT the same as the
+ real ump_mem reference count in the devicedriver which do reference counting
+ for the memory that this handle reveals. */
+ unsigned long cookie; /**< cookie for use in arch_unmap calls */
+ ump_cache_enabled is_cached;
+} ump_mem;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* _UNIFIED_MEMORY_PROVIDER_INTERNAL_H_ */
diff --git a/exynos4/hal/libump/arch_011_udd/ump_ref_drv.c b/exynos4/hal/libump/arch_011_udd/ump_ref_drv.c
new file mode 100644
index 0000000..cf3b9eb
--- /dev/null
+++ b/exynos4/hal/libump/arch_011_udd/ump_ref_drv.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_ref_drv.c
+ *
+ * Implementation of the user space API extensions provided by the reference implementation.
+ */
+
+#include <ump/ump_ref_drv.h>
+#include <ump/ump.h>
+#include "ump_internal.h"
+#include "ump_arch.h"
+#include <ump/ump_debug.h>
+#include <ump/ump_osu.h>
+
+/* Allocate a buffer which can be used directly by hardware, 4kb aligned */
+static ump_handle ump_ref_drv_allocate_internal(unsigned long size, ump_alloc_constraints constraints, ump_cache_enabled cache);
+
+
+
+/* Allocate a buffer which can be used directly by hardware, 4kb aligned */
+ump_handle ump_ref_drv_allocate(unsigned long size, ump_alloc_constraints constraints)
+{
+ ump_cache_enabled cache= UMP_CACHE_DISABLE;
+ if ( 0!=(constraints&UMP_REF_DRV_CONSTRAINT_USE_CACHE) )
+ {
+ cache = UMP_CACHE_ENABLE;
+ }
+ return ump_ref_drv_allocate_internal(size, constraints, cache);
+}
+
+UMP_API_EXPORT int ump_cpu_msync_now(ump_handle memh, ump_cpu_msync_op op, void* address, int size)
+{
+ ump_mem * mem = (ump_mem*)memh;
+ UMP_DEBUG_ASSERT(UMP_INVALID_MEMORY_HANDLE != memh, ("Handle is invalid"));
+
+ /* If the op is readout, we do the readout from DD.
+ Else we skip flushing if the userspace handle says that it is uncached */
+ if ((UMP_MSYNC_READOUT_CACHE_ENABLED!=op) && (0 == mem->is_cached) ) return 0;
+
+ UMP_DEBUG_ASSERT(0 < (((ump_mem*)mem)->ref_count), ("Reference count too low"));
+ UMP_DEBUG_ASSERT((size>=0) && (size <= ((ump_mem*)mem)->size), ("Memory size of passed handle too low"));
+ UMP_DEBUG_ASSERT(NULL != ((ump_mem*)mem)->mapped_mem, ("Error in mapping pointer (not mapped)"));
+
+ if (size > mem->size) size = mem->size;
+
+ mem->is_cached = ump_arch_msync(mem->secure_id, mem->mapped_mem, mem->cookie, address, size, op);
+ return mem->is_cached ;
+}
+
+/* Allocate a buffer which can be used directly by hardware, 4kb aligned */
+static ump_handle ump_ref_drv_allocate_internal(unsigned long size, ump_alloc_constraints constraints, ump_cache_enabled cache)
+{
+ ump_secure_id secure_id;
+ unsigned long allocated_size = size;
+
+ UMP_DEBUG_PRINT(4, ("Allocating UMP memory of size %lu", size));
+
+ secure_id = ump_arch_allocate(&allocated_size, constraints);
+ if (secure_id != UMP_INVALID_SECURE_ID)
+ {
+ unsigned long cookie;
+ void * mapping;
+
+ mapping = ump_arch_map(secure_id, allocated_size, cache, &cookie);
+ if (NULL != mapping)
+ {
+ /*
+ * PS: By now we have actually increased the ref count in the device driver by 2,
+ * one for the allocation iteself, and one for the mapping.
+ */
+ ump_mem * mem;
+ mem = _ump_osu_calloc(1, sizeof(*mem));
+ if (NULL != mem)
+ {
+ mem->secure_id = secure_id;
+ mem->mapped_mem = mapping;
+ mem->size = allocated_size;
+ mem->cookie = cookie;
+ mem->is_cached = 1; /* Default to ON, is disabled later if not */
+
+ _ump_osu_lock_auto_init(&mem->ref_lock, 0, 0, 0);
+ UMP_DEBUG_ASSERT(NULL != mem->ref_lock, ("Failed to initialize lock\n"));
+ mem->ref_count = 1;
+
+ /*
+ * ump_arch_allocate() gave us a kernel space reference, and the same did ump_arch_map()
+ * We release the one from ump_arch_allocate(), and rely solely on the one from the ump_arch_map()
+ * That is, ump_arch_unmap() should now do the final release towards the UMP kernel space driver.
+ */
+ ump_arch_reference_release(secure_id);
+
+ /* This is called only to set the cache settings in this handle */
+ ump_cpu_msync_now((ump_handle)mem, UMP_MSYNC_READOUT_CACHE_ENABLED, NULL, 0);
+
+ UMP_DEBUG_PRINT(4, ("UMP handle created for ID %u of size %lu, mapped into address 0x%08lx", mem->secure_id, mem->size, (unsigned long)mem->mapped_mem));
+
+ return (ump_handle)mem;
+ }
+
+ ump_arch_unmap(mapping, allocated_size, cookie); /* Unmap the memory */
+ ump_arch_reference_release(secure_id); /* Release reference added when we allocated the UMP memory */
+ }
+
+ ump_arch_reference_release(secure_id); /* Release reference added when we allocated the UMP memory */
+ }
+
+ UMP_DEBUG_PRINT(4, ("Allocation of UMP memory failed"));
+ return UMP_INVALID_MEMORY_HANDLE;
+}
diff --git a/exynos4/hal/libump/include/ump/ump.h b/exynos4/hal/libump/include/ump/ump.h
new file mode 100644
index 0000000..2829113
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump.h
@@ -0,0 +1,268 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump.h
+ *
+ * This file contains the user space part of the UMP API.
+ */
+
+#ifndef _UNIFIED_MEMORY_PROVIDER_H_
+#define _UNIFIED_MEMORY_PROVIDER_H_
+
+
+/** @defgroup ump_user_space_api UMP User Space API
+ * @{ */
+
+
+#include "ump_platform.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * External representation of a UMP handle in user space.
+ */
+typedef void * ump_handle;
+
+/**
+ * Typedef for a secure ID, a system wide identificator for UMP memory buffers.
+ */
+typedef unsigned int ump_secure_id;
+
+/**
+ * Value to indicate an invalid UMP memory handle.
+ */
+#define UMP_INVALID_MEMORY_HANDLE ((ump_handle)0)
+
+/**
+ * Value to indicate an invalid secure Id.
+ */
+#define UMP_INVALID_SECURE_ID ((ump_secure_id)-1)
+
+/**
+ * UMP error codes for user space.
+ */
+typedef enum
+{
+ UMP_OK = 0, /**< indicates success */
+ UMP_ERROR, /**< indicates failure */
+} ump_result;
+
+
+/**
+ * Opens and initializes the UMP library.
+ *
+ * This function must be called at least once before calling any other UMP API functions.
+ * Each open is reference counted and must be matched with a call to @ref ump_close "ump_close".
+ *
+ * @see ump_close
+ *
+ * @return UMP_OK indicates success, UMP_ERROR indicates failure.
+ */
+UMP_API_EXPORT ump_result ump_open(void);
+
+
+/**
+ * Terminate the UMP library.
+ *
+ * This must be called once for every successful @ref ump_open "ump_open". The UMP library is
+ * terminated when, and only when, the last open reference to the UMP interface is closed.
+ *
+ * @see ump_open
+ */
+UMP_API_EXPORT void ump_close(void);
+
+
+/**
+ * Retrieves the secure ID for the specified UMP memory.
+ *
+ * This identificator is unique across the entire system, and uniquely identifies
+ * the specified UMP memory. This identificator can later be used through the
+ * @ref ump_handle_create_from_secure_id "ump_handle_create_from_secure_id" or
+ * @ref ump_dd_handle_create_from_secure_id "ump_dd_handle_create_from_secure_id"
+ * functions in order to access this UMP memory, for instance from another process.
+ *
+ * @note There is a kernel space equivalent function called @ref ump_dd_secure_id_get "ump_dd_secure_id_get"
+ *
+ * @see ump_handle_create_from_secure_id
+ * @see ump_dd_handle_create_from_secure_id
+ * @see ump_dd_secure_id_get
+ *
+ * @param mem Handle to UMP memory.
+ *
+ * @return Returns the secure ID for the specified UMP memory.
+ */
+UMP_API_EXPORT ump_secure_id ump_secure_id_get(ump_handle mem);
+
+
+/**
+ * Retrieves a handle to allocated UMP memory.
+ *
+ * The usage of UMP memory is reference counted, so this will increment the reference
+ * count by one for the specified UMP memory.
+ * Use @ref ump_reference_release "ump_reference_release" when there is no longer any
+ * use for the retrieved handle.
+ *
+ * @note There is a kernel space equivalent function called @ref ump_dd_handle_create_from_secure_id "ump_dd_handle_create_from_secure_id"
+ *
+ * @see ump_reference_release
+ * @see ump_dd_handle_create_from_secure_id
+ *
+ * @param secure_id The secure ID of the UMP memory to open, that can be retrieved using the @ref ump_secure_id_get "ump_secure_id_get " function.
+ *
+ * @return UMP_INVALID_MEMORY_HANDLE indicates failure, otherwise a valid handle is returned.
+ */
+UMP_API_EXPORT ump_handle ump_handle_create_from_secure_id(ump_secure_id secure_id);
+
+
+/**
+ * Retrieves the actual size of the specified UMP memory.
+ *
+ * The size is reported in bytes, and is typically page aligned.
+ *
+ * @note There is a kernel space equivalent function called @ref ump_dd_size_get "ump_dd_size_get"
+ *
+ * @see ump_dd_size_get
+ *
+ * @param mem Handle to UMP memory.
+ *
+ * @return Returns the allocated size of the specified UMP memory, in bytes.
+ */
+UMP_API_EXPORT unsigned long ump_size_get(ump_handle mem);
+
+
+/**
+ * Read from specified UMP memory.
+ *
+ * Another way of reading from (and writing to) UMP memory is to use the
+ * @ref ump_mapped_pointer_get "ump_mapped_pointer_get" to retrieve
+ * a CPU mapped pointer to the memory.
+ *
+ * @see ump_mapped_pointer_get
+ *
+ * @param dst Destination buffer.
+ * @param src Handle to UMP memory to read from.
+ * @param offset Where to start reading, given in bytes.
+ * @param length How much to read, given in bytes.
+ */
+UMP_API_EXPORT void ump_read(void * dst, ump_handle src, unsigned long offset, unsigned long length);
+
+
+/**
+ * Write to specified UMP memory.
+ *
+ * Another way of writing to (and reading from) UMP memory is to use the
+ * @ref ump_mapped_pointer_get "ump_mapped_pointer_get" to retrieve
+ * a CPU mapped pointer to the memory.
+ *
+ * @see ump_mapped_pointer_get
+ *
+ * @param dst Handle to UMP memory to write to.
+ * @param offset Where to start writing, given in bytes.
+ * @param src Buffer to read from.
+ * @param length How much to write, given in bytes.
+ */
+UMP_API_EXPORT void ump_write(ump_handle dst, unsigned long offset, const void * src, unsigned long length);
+
+
+/**
+ * Retrieves a memory mapped pointer to the specified UMP memory.
+ *
+ * This function retrieves a memory mapped pointer to the specified UMP memory,
+ * that can be used by the CPU. Every successful call to
+ * @ref ump_mapped_pointer_get "ump_mapped_pointer_get" is reference counted,
+ * and must therefor be followed by a call to
+ * @ref ump_mapped_pointer_release "ump_mapped_pointer_release " when the
+ * memory mapping is no longer needed.
+ *
+ * @note Systems without a MMU for the CPU only return the physical address, because no mapping is required.
+ *
+ * @see ump_mapped_pointer_release
+ *
+ * @param mem Handle to UMP memory.
+ *
+ * @return NULL indicates failure, otherwise a CPU mapped pointer is returned.
+ */
+UMP_API_EXPORT void * ump_mapped_pointer_get(ump_handle mem);
+
+
+/**
+ * Releases a previously mapped pointer to the specified UMP memory.
+ *
+ * The CPU mapping of the specified UMP memory memory is reference counted,
+ * so every call to @ref ump_mapped_pointer_get "ump_mapped_pointer_get" must
+ * be matched with a call to this function when the mapping is no longer needed.
+ *
+ * The CPU mapping is not removed before all references to the mapping is released.
+ *
+ * @note Systems without a MMU must still implement this function, even though no unmapping should be needed.
+ *
+ * @param mem Handle to UMP memory.
+ */
+UMP_API_EXPORT void ump_mapped_pointer_release(ump_handle mem);
+
+
+/**
+ * Adds an extra reference to the specified UMP memory.
+ *
+ * This function adds an extra reference to the specified UMP memory. This function should
+ * be used every time a UMP memory handle is duplicated, that is, assigned to another ump_handle
+ * variable. The function @ref ump_reference_release "ump_reference_release" must then be used
+ * to release each copy of the UMP memory handle.
+ *
+ * @note You are not required to call @ref ump_reference_add "ump_reference_add"
+ * for UMP handles returned from
+ * @ref ump_handle_create_from_secure_id "ump_handle_create_from_secure_id",
+ * because these handles are already reference counted by this function.
+ *
+ * @note There is a kernel space equivalent function called @ref ump_dd_reference_add "ump_dd_reference_add"
+ *
+ * @see ump_dd_reference_add
+ *
+ * @param mem Handle to UMP memory.
+ */
+UMP_API_EXPORT void ump_reference_add(ump_handle mem);
+
+
+/**
+ * Releases a reference from the specified UMP memory.
+ *
+ * This function should be called once for every reference to the UMP memory handle.
+ * When the last reference is released, all resources associated with this UMP memory
+ * handle are freed.
+ *
+ * @note There is a kernel space equivalent function called @ref ump_dd_reference_release "ump_dd_reference_release"
+ *
+ * @see ump_dd_reference_release
+ *
+ * @param mem Handle to UMP memory.
+ */
+UMP_API_EXPORT void ump_reference_release(ump_handle mem);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/** @} */ /* end group ump_user_space_api */
+
+
+#endif /*_UNIFIED_MEMORY_PROVIDER_H_ */
diff --git a/exynos4/hal/libump/include/ump/ump_debug.h b/exynos4/hal/libump/include/ump/ump_debug.h
new file mode 100644
index 0000000..5ede8a3
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump_debug.h
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_debug.h
+ *
+ * The file include several useful macros for debugging and printing.
+ * - UMP_PRINTF(...) Do not use this function: Will be included in Release builds.
+ * - UMP_DEBUG_TRACE() Prints current location in code.
+ * - UMP_DEBUG_PRINT(nr, (X) ) Prints the second argument if nr<=UMP_DEBUG_LEVEL.
+ * - UMP_DEBUG_TPRINT(nr, X ) Prints the source trace and second argument if nr<=UMP_DEBUG_LEVEL.
+ * - UMP_DEBUG_ERROR( (X) ) Prints an errortext, a source trace, and the given error message.
+ * - UMP_DEBUG_ASSERT(exp,(X)) If the asserted expr is false, the program will exit.
+ * - UMP_DEBUG_ASSERT_RANGE(x, min, max) Triggers if variable x is not between or equal to max and min.
+ * - UMP_DEBUG_ASSERT_LEQ(x, max) Triggers if variable x is not less than equal to max.
+ * - UMP_DEBUG_ASSERT_POINTER(pointer) Triggers if the pointer is a zero pointer.
+ * - UMP_DEBUG_CODE( X ) The code inside the macro is only copiled in Debug builds.
+ *
+ * The (X) means that you must add an extra parantese around the argumentlist.
+ *
+ * The printf function: UMP_PRINTF(...) is routed to _ump_sys_printf
+ *
+ * Suggested range for the DEBUG-LEVEL is [1:6] where
+ * [1:2] Is messages with highest priority, indicate possible errors.
+ * [3:4] Is messages with medium priority, output important variables.
+ * [5:6] Is messages with low priority, used during extensive debugging.
+ *
+ */
+#ifndef _UMP_DEBUG_H_
+#define _UMP_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* START: Configuration */
+#ifndef UMP_PRINTF
+ #define UMP_PRINTF printf
+#endif /* UMP_PRINTF */
+
+#ifndef UMP_PRINT_FLUSH
+ #define UMP_PRINT_FLUSH do {} while (0)
+#endif /* UMP_PRINT_FLUSH */
+
+#ifndef UMP_DEBUG_LEVEL
+ #define UMP_DEBUG_LEVEL 1
+#endif /* UMP_DEBUG_LEVEL */
+
+#ifndef UMP_DEBUG_ERROR_START_MSG
+ #define UMP_DEBUG_ERROR_START_MSG do {\
+ UMP_PRINTF("*********************************************************************\n");\
+ UMP_PRINT_FLUSH; } while (0)
+#endif /* UMP_DEBUG_ERROR_START_MSG */
+
+#ifndef UMP_DEBUG_ERROR_STOP_MSG
+ #define UMP_DEBUG_ERROR_STOP_MSG do { UMP_PRINTF("\n"); UMP_PRINT_FLUSH; } while (0)
+#endif /* UMP_DEBUG_ERROR_STOP_MSG */
+
+#ifndef UMP_ASSERT_QUIT_CMD
+ #define UMP_ASSERT_QUIT_CMD abort()
+#endif /* UMP_ASSERT_QUIT_CMD */
+/* STOP: Configuration */
+
+/**
+ * The macro UMP_FUNCTION evaluates to the name of the function enclosing
+ * this macro's usage, or "<unknown>" if not supported.
+ */
+#if (defined(__SYMBIAN32__) && defined(__ARMCC__)) || defined(_MSC_VER)
+# define UMP_FUNCTION __FUNCTION__
+#elif __STDC__ && __STDC_VERSION__ >= 199901L
+# define UMP_FUNCTION __FUNCTION__
+#elif defined(__GNUC__) && __GNUC__ >= 2
+# define UMP_FUNCTION __FUNCTION__
+#elif defined(__func__)
+# define UMP_FUNCTION __func__
+#else
+# define UMP_FUNCTION "<unknown>"
+#endif
+
+/**
+ * Explicitly ignore a parameter passed into a function, to suppress compiler warnings.
+ * Should only be used with parameter names.
+ */
+#define UMP_IGNORE(x) (void)x
+
+/**
+ * @def UMP_DEBUG_TRACE()
+ * @brief Prints current location in code.
+ * Can be turned off by defining UMP_DEBUG_SKIP_TRACE
+ */
+
+#ifndef UMP_DEBUG_SKIP_TRACE
+ #ifndef UMP_DEBUG_SKIP_PRINT_FUNCTION_NAME
+ #define UMP_DEBUG_TRACE() do { UMP_PRINTF( "In file: "__FILE__ \
+ " function: %s() line:%4d\n" , UMP_FUNCTION, __LINE__); UMP_PRINT_FLUSH; } while (0)
+ #else
+ #define UMP_DEBUG_TRACE() do { UMP_PRINTF( "In file: "__FILE__ " line:%4d\n" , __LINE__); UMP_PRINT_FLUSH; } while (0)
+ #endif /* UMP_DEBUG_SKIP_PRINT_FUNCTION_NAME */
+#else
+ #define UMP_DEBUG_TRACE()
+#endif /* UMP_DEBUG_SKIP_TRACE */
+
+/**
+ * @def UMP_DEBUG_PRINT(nr, (X) )
+ * @brief Prints the second argument if nr<=UMP_DEBUG_LEVEL.
+ * Can be turned off by defining UMP_DEBUG_SKIP_PRINT
+ * @param nr If nr <= UMP_DEBUG_LEVEL, we print the text.
+ * @param X A parantese with the contents to be sent to UMP_PRINTF
+ */
+#ifndef UMP_DEBUG_SKIP_PRINT
+ #define UMP_DEBUG_PRINT(nr, X ) do { if ( nr<=UMP_DEBUG_LEVEL ) { UMP_PRINTF X ; UMP_PRINT_FLUSH; } } while (0)
+#else
+ #define UMP_DEBUG_PRINT(nr, X )
+#endif /* UMP_DEBUG_SKIP_PRINT */
+
+/**
+ * @def UMP_DEBUG_TPRINT(nr, (X) )
+ * @brief Prints the second argument if nr<=UMP_DEBUG_LEVEL.
+ * Can be turned off by defining UMP_DEBUG_SKIP_TPRINT.
+ * Can be shortened by defining UMP_DEBUG_TPRINT_SKIP_FUNCTION.
+ * @param nr If nr <= UMP_DEBUG_LEVEL, we print the text.
+ * @param X A parantese with the contents to be sent to UMP_PRINTF
+ */
+
+/* helper to handle if the function name should be included or not */
+#ifndef UMP_DEBUG_TPRINT_SKIP_FUNCTION
+ #define UMP_DEBUG_TPRINT_INTERN do {UMP_PRINTF( ""__FILE__" %s()%4d " , UMP_FUNCTION, __LINE__); UMP_PRINT_FLUSH; } while (0)
+#else
+ #define UMP_DEBUG_TPRINT_INTERN do {UMP_PRINTF( ""__FILE__ "%4d " , __LINE__); UMP_PRINT_FLUSH; } while (0)
+#endif /* UMP_DEBUG_TPRINT_SKIP_FUNCTION */
+
+#ifndef UMP_DEBUG_SKIP_TPRINT
+ #define UMP_DEBUG_TPRINT(nr, X ) \
+ do{\
+ if ( nr<=UMP_DEBUG_LEVEL )\
+ {\
+ UMP_DEBUG_TPRINT_INTERN;\
+ UMP_PRINTF X ;\
+ UMP_PRINT_FLUSH;\
+ }\
+ } while (0)
+#else
+ #define UMP_DEBUG_TPRINT(nr, X )
+#endif /* UMP_DEBUG_SKIP_TPRINT */
+
+/**
+ * @def UMP_DEBUG_ERROR( (X) )
+ * @brief Prints an errortext, a source Trace, and the given error message.
+ * Prints filename, function, linenr, and the given error message.
+ * The error message must be inside a second parantese.
+ * The error message is written on a separate line, and a NL char is added.
+ * Can be turned of by defining UMP_DEBUG_SKIP_ERROR;
+ * You do not need to type the words ERROR in the message, since it will
+ * be added anyway.
+ *
+ * @note You should not end the text with a newline, since it is added by the macro.
+ * @note You should not write "ERROR" in the text, since it is added by the macro.
+ * @param X A parantese with the contents to be sent to UMP_PRINTF
+ */
+
+#ifndef UMP_DEBUG_SKIP_ERROR
+ #define UMP_DEBUG_ERROR( X ) \
+ do{ \
+ UMP_DEBUG_ERROR_START_MSG;\
+ UMP_PRINTF("ERROR: ");\
+ UMP_PRINT_FLUSH;\
+ UMP_DEBUG_TRACE(); \
+ UMP_PRINTF X ; \
+ UMP_PRINT_FLUSH;\
+ UMP_DEBUG_ERROR_STOP_MSG;\
+ } while (0)
+#else
+ #define UMP_DEBUG_ERROR( X ) do{ ; } while ( 0 )
+#endif /* UMP_DEBUG_SKIP_ERROR */
+
+/**
+ * @def UMP_DEBUG_ASSERT(expr, (X) )
+ * @brief If the asserted expr is false, the program will exit.
+ * Prints filename, function, linenr, and the given error message.
+ * The error message must be inside a second parantese.
+ * The error message is written on a separate line, and a NL char is added.
+ * Can be turned of by defining UMP_DEBUG_SKIP_ERROR;
+ * You do not need to type the words ASSERT in the message, since it will
+ * be added anyway.
+ *
+ * @param X A parantese with the contents to be sent to UMP_PRINTF
+ * Prints filename, function, linenr, and the error message
+ * on a separte line. A newline char is added at the end.
+ * Can be turned of by defining UMP_DEBUG_SKIP_ASSERT
+ * @param expr Will exit program if \a expr is false;
+ * @param (X) Text that will be written if the assertion toggles.
+ */
+
+#ifndef UMP_DEBUG_SKIP_ASSERT
+ #define UMP_DEBUG_ASSERT(expr, X ) \
+ do{\
+ if ( !(expr) ) \
+ { \
+ UMP_DEBUG_ERROR_START_MSG;\
+ UMP_PRINTF("ASSERT EXIT: ");\
+ UMP_PRINT_FLUSH;\
+ UMP_DEBUG_TRACE(); \
+ UMP_PRINTF X ; \
+ UMP_PRINT_FLUSH;\
+ UMP_DEBUG_ERROR_STOP_MSG;\
+ UMP_ASSERT_QUIT_CMD;\
+ }\
+ } while (0)
+#else
+ #define UMP_DEBUG_ASSERT(expr, X)
+#endif /* UMP_DEBUG_SKIP_ASSERT */
+
+
+/**
+ * @def UMP_DEBUG_ASSERT_POINTER(pointer)
+ * @brief If the asserted pointer is NULL, the program terminates and TRACE info is printed
+ * The checking is disabled if "UMP_DEBUG_SKIP_ASSERT" is defined.
+ */
+#define UMP_DEBUG_ASSERT_POINTER(pointer) UMP_DEBUG_ASSERT(pointer, ("Null pointer " #pointer) )
+
+/**
+ * @def UMP_DEBUG_ASSERT_HANDLE(handle)
+ * @brief If the asserted handle is not a valid handle, the program terminates and TRACE info is printed
+ * The checking is disabled if "UMP_DEBUG_SKIP_ASSERT" is defined.
+ */
+#define UMP_DEBUG_ASSERT_HANDLE(handle) UMP_DEBUG_ASSERT(UMP_NO_HANDLE != (handle), ("Invalid handle" #handle) )
+
+/**
+ * @def UMP_DEBUG_ASSERT_ALIGNMENT(ptr, align)
+ * @brief If the asserted pointer is not aligned to align, the program terminates with trace info printed.
+ * The checking is disabled if "UMP_DEBUG_SKIP_ASSERT" is defined.
+ */
+#ifndef UMP_DEBUG_SKIP_ASSERT
+ #define UMP_DEBUG_ASSERT_ALIGNMENT(ptr, align) do { \
+ UMP_DEBUG_ASSERT(0 == (align & (align - 1)), ("align %d is not a power-of-two", align)); \
+ UMP_DEBUG_ASSERT(0 == (((u32)(ptr)) & (align - 1)), ("ptr %p not aligned to %d bytes", (void*)ptr, align)); \
+ } while (0)
+#else
+ #define UMP_DEBUG_ASSERT_ALIGNMENT(ptr, align)
+#endif /* UMP_DEBUG_SKIP_ASSERT */
+
+/**
+ * @def UMP_DEBUG_ASSERT_RANGE(x,min,max)
+ * @brief If variable x is not between or equal to max and min, the assertion triggers.
+ * The checking is disabled if "UMP_DEBUG_SKIP_ASSERT" is defined.
+ */
+#define UMP_DEBUG_ASSERT_RANGE(x, min, max) \
+ UMP_DEBUG_ASSERT( (x) >= (min) && (x) <= (max), \
+ (#x " out of range (%2.2f)", (double)x ) \
+ )
+
+/**
+ * @def UMP_DEBUG_ASSERT_LEQ(x,max)
+ * @brief If variable x is less than or equal to max, the assertion triggers.
+ * The checking is disabled if "UMP_DEBUG_SKIP_ASSERT" is defined.
+ */
+#define UMP_DEBUG_ASSERT_LEQ(x, max) \
+ UMP_DEBUG_ASSERT( (x) <= (max), \
+ (#x " out of range (%2.2f)", (double)x ) \
+ )
+
+/**
+ * @def UMP_DEBUG_CODE( X )
+ * @brief Run the code X on debug builds.
+ * The code will not be used if UMP_DEBUG_SKIP_CODE is defined .
+ *
+ */
+#ifdef UMP_DEBUG_SKIP_CODE
+ #define UMP_DEBUG_CODE( X )
+#else
+ #define UMP_DEBUG_CODE( X ) X
+#endif /* UMP_DEBUG_SKIP_CODE */
+
+#endif /* _UMP_DEBUG_H_ */
+
diff --git a/exynos4/hal/libump/include/ump/ump_osu.h b/exynos4/hal/libump/include/ump/ump_osu.h
new file mode 100644
index 0000000..5c9a650
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump_osu.h
@@ -0,0 +1,430 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_osu.h
+ * Defines the OS abstraction layer for the base driver
+ */
+
+#ifndef __UMP_OSU_H__
+#define __UMP_OSU_H__
+
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+typedef unsigned int u32;
+#ifdef _MSC_VER
+ typedef unsigned __int64 u64;
+ typedef signed __int64 s64;
+#else
+ typedef unsigned long long u64;
+ typedef signed long long s64;
+#endif
+
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
+typedef unsigned long ump_bool;
+
+#ifndef UMP_TRUE
+#define UMP_TRUE ((ump_bool)1)
+#endif
+
+#ifndef UMP_FALSE
+#define UMP_FALSE ((ump_bool)0)
+#endif
+
+#define UMP_STATIC static
+
+/**
+ * @addtogroup ump_user_space_api Unified Device Driver (UDD) APIs used by UMP
+ *
+ * @{
+ */
+
+/**
+ * @defgroup ump_osuapi UDD OS Abstraction for User-side (OSU) APIs for UMP
+ *
+ * @{
+ */
+
+/* The following is necessary to prevent the _ump_osk_errcode_t doxygen from
+ * becoming unreadable: */
+/** @cond OSU_COPY_OF__UMP_OSU_ERRCODE_T */
+
+/**
+ * @brief OSU/OSK Error codes.
+ *
+ * Each OS may use its own set of error codes, and may require that the
+ * User/Kernel interface take certain error code. This means that the common
+ * error codes need to be sufficiently rich to pass the correct error code
+ * through from the OSK/OSU to U/K layer, across all OSs.
+ *
+ * The result is that some error codes will appear redundant on some OSs.
+ * Under all OSs, the OSK/OSU layer must translate native OS error codes to
+ * _ump_osk/u_errcode_t codes. Similarly, the U/K layer must translate from
+ * _ump_osk/u_errcode_t codes to native OS error codes.
+ *
+ */
+typedef enum
+{
+ _UMP_OSK_ERR_OK = 0, /**< Success. */
+ _UMP_OSK_ERR_FAULT = -1, /**< General non-success */
+ _UMP_OSK_ERR_INVALID_FUNC = -2, /**< Invalid function requested through User/Kernel interface (e.g. bad IOCTL number) */
+ _UMP_OSK_ERR_INVALID_ARGS = -3, /**< Invalid arguments passed through User/Kernel interface */
+ _UMP_OSK_ERR_NOMEM = -4, /**< Insufficient memory */
+ _UMP_OSK_ERR_TIMEOUT = -5, /**< Timeout occured */
+ _UMP_OSK_ERR_RESTARTSYSCALL = -6, /**< Special: On certain OSs, must report when an interruptable mutex is interrupted. Ignore otherwise. */
+ _UMP_OSK_ERR_ITEM_NOT_FOUND = -7, /**< Table Lookup failed */
+ _UMP_OSK_ERR_BUSY = -8, /**< Device/operation is busy. Try again later */
+ _UMP_OSK_ERR_UNSUPPORTED = -9, /**< Optional part of the interface used, and is unsupported */
+} _ump_osk_errcode_t;
+
+/** @endcond */ /* end cond OSU_COPY_OF__UMP_OSU_ERRCODE_T */
+
+/**
+ * @brief OSU Error codes.
+ *
+ * OSU error codes - enum values intentionally same as OSK
+ */
+typedef enum
+{
+ _UMP_OSU_ERR_OK = 0, /**< Success. */
+ _UMP_OSU_ERR_FAULT = -1, /**< General non-success */
+ _UMP_OSU_ERR_TIMEOUT = -2, /**< Timeout occured */
+} _ump_osu_errcode_t;
+
+/** @brief Translate OSU error code to base driver error code.
+ *
+ * The _UMP_OSU_TRANSLATE_ERROR macro translates an OSU error code to the
+ * error codes in use by the base driver.
+ */
+#define _UMP_OSU_TRANSLATE_ERROR(_ump_osu_errcode) ( ( _UMP_OSU_ERR_OK == (_ump_osu_errcode) ) ? UMP_ERR_NO_ERROR : UMP_ERR_FUNCTION_FAILED)
+
+/** @defgroup _ump_osu_lock OSU Mutual Exclusion Locks
+ * @{ */
+
+/** @brief OSU Mutual Exclusion Lock flags type.
+ *
+ * This is made to look like and function identically to the OSK locks (refer
+ * to \ref _ump_osk_lock). However, please note the following \b important
+ * differences:
+ * - the OSU default lock is a Sleeping, non-interruptible mutex.
+ * - the OSU adds the ANYUNLOCK type of lock which allows a thread which doesn't
+ * own the lock to release the lock.
+ * - the order parameter when creating a lock is currently unused
+ *
+ * @note Pay careful attention to the difference in default locks for OSU and
+ * OSK locks; OSU locks are always non-interruptible, but OSK locks are by
+ * default, interruptible. This has implications for systems that do not
+ * distinguish between user and kernel mode.
+ */
+typedef enum
+{
+ _UMP_OSU_LOCKFLAG_DEFAULT = 0, /**< Default lock type. */
+ /** @enum _ump_osu_lock_flags_t
+ *
+ * Flags from 0x8000--0x1 are RESERVED for Kernel-mode
+ */
+ _UMP_OSU_LOCKFLAG_ANYUNLOCK = 0x10000, /**< Mutex that guarantees that any thread can unlock it when locked. Otherwise, this will not be possible. */
+ /** @enum _ump_osu_lock_flags_t
+ *
+ * Flags from 0x80000000 are RESERVED for User-mode
+ */
+ _UMP_OSU_LOCKFLAG_STATIC = 0x80000000, /* Flag in OSU reserved range to identify lock as a statically initialized lock */
+
+ } _ump_osu_lock_flags_t;
+
+typedef enum
+{
+ _UMP_OSU_LOCKMODE_UNDEF = -1, /**< Undefined lock mode. For internal use only */
+ _UMP_OSU_LOCKMODE_RW = 0x0, /**< Default. Lock is used to protect data that is read from and written to */
+ /** @enum _ump_osu_lock_mode_t
+ *
+ * Lock modes 0x1--0x3F are RESERVED for Kernel-mode */
+} _ump_osu_lock_mode_t;
+
+/** @brief Private type for Mutual Exclusion lock objects. */
+typedef struct _ump_osu_lock_t_struct _ump_osu_lock_t;
+
+/** @brief The number of static locks supported in _ump_osu_lock_static(). */
+#define UMP_OSU_STATIC_LOCK_COUNT (sizeof(_ump_osu_static_locks) / sizeof(_ump_osu_lock_t))
+
+/** @} */ /* end group _ump_osu_lock */
+
+/** @defgroup _ump_osu_memory OSU Memory Allocation
+ * @{ */
+
+/** @brief Allocate zero-initialized memory.
+ *
+ * Returns a buffer capable of containing at least \a n elements of \a size
+ * bytes each. The buffer is initialized to zero.
+ *
+ * The buffer is suitably aligned for storage and subsequent access of every
+ * type that the compiler supports. Therefore, the pointer to the start of the
+ * buffer may be cast into any pointer type, and be subsequently accessed from
+ * such a pointer, without loss of information.
+ *
+ * When the buffer is no longer in use, it must be freed with _ump_osu_free().
+ * Failure to do so will cause a memory leak.
+ *
+ * @note Most toolchains supply memory allocation functions that meet the
+ * compiler's alignment requirements.
+ *
+ * @param n Number of elements to allocate
+ * @param size Size of each element
+ * @return On success, the zero-initialized buffer allocated. NULL on failure
+ */
+void *_ump_osu_calloc( u32 n, u32 size );
+
+/** @brief Allocate memory.
+ *
+ * Returns a buffer capable of containing at least \a size bytes. The
+ * contents of the buffer are undefined.
+ *
+ * The buffer is suitably aligned for storage and subsequent access of every
+ * type that the compiler supports. Therefore, the pointer to the start of the
+ * buffer may be cast into any pointer type, and be subsequently accessed from
+ * such a pointer, without loss of information.
+ *
+ * When the buffer is no longer in use, it must be freed with _ump_osu_free().
+ * Failure to do so will cause a memory leak.
+ *
+ * @note Most toolchains supply memory allocation functions that meet the
+ * compiler's alignment requirements.
+ *
+ * Remember to free memory using _ump_osu_free().
+ * @param size Number of bytes to allocate
+ * @return On success, the buffer allocated. NULL on failure.
+ */
+void *_ump_osu_malloc( u32 size );
+
+/** @brief Free memory.
+ *
+ * Reclaims the buffer pointed to by the parameter \a ptr for the system.
+ * All memory returned from _ump_osu_malloc(), _ump_osu_calloc() and
+ * _ump_osu_realloc() must be freed before the application exits. Otherwise,
+ * a memory leak will occur.
+ *
+ * Memory must be freed once. It is an error to free the same non-NULL pointer
+ * more than once.
+ *
+ * It is legal to free the NULL pointer.
+ *
+ * @param ptr Pointer to buffer to free
+ */
+void _ump_osu_free( void *ptr );
+
+/** @brief Copies memory.
+ *
+ * Copies the \a len bytes from the buffer pointed by the parameter \a src
+ * directly to the buffer pointed by \a dst.
+ *
+ * It is an error for \a src to overlap \a dst anywhere in \a len bytes.
+ *
+ * @param dst Pointer to the destination array where the content is to be
+ * copied.
+ * @param src Pointer to the source of data to be copied.
+ * @param len Number of bytes to copy.
+ * @return \a dst is always passed through unmodified.
+ */
+void *_ump_osu_memcpy( void *dst, const void *src, u32 len );
+
+/** @brief Fills memory.
+ *
+ * Sets the first \a size bytes of the block of memory pointed to by \a ptr to
+ * the specified value
+ * @param ptr Pointer to the block of memory to fill.
+ * @param chr Value to be set, passed as u32. Only the 8 Least Significant Bits (LSB)
+ * are used.
+ * @param size Number of bytes to be set to the value.
+ * @return \a ptr is always passed through unmodified
+ */
+void *_ump_osu_memset( void *ptr, u32 chr, u32 size );
+
+/** @} */ /* end group _ump_osu_memory */
+
+
+/** @addtogroup _ump_osu_lock
+ * @{ */
+
+/** @brief Initialize a Mutual Exclusion Lock.
+ *
+ * Locks are created in the signalled (unlocked) state.
+ *
+ * The parameter \a initial must be zero.
+ *
+ * At present, the parameter \a order must be zero. It remains for future
+ * expansion for mutex order checking.
+ *
+ * @param flags flags combined with bitwise OR ('|'), or zero. There are
+ * restrictions on which flags can be combined, see \ref _ump_osu_lock_flags_t.
+ * @param initial For future expansion into semaphores. SBZ.
+ * @param order The locking order of the mutex. SBZ.
+ * @return On success, a pointer to a \ref _ump_osu_lock_t object. NULL on failure.
+ */
+_ump_osu_lock_t *_ump_osu_lock_init( _ump_osu_lock_flags_t flags, u32 initial, u32 order );
+
+/** @brief Obtain a statically initialized Mutual Exclusion Lock.
+ *
+ * Retrieves a reference to a statically initialized lock. Up to
+ * _UMP_OSU_STATIC_LOCK_COUNT statically initialized locks are
+ * available. Only _ump_osu_lock_wait(), _ump_osu_lock_trywait(),
+ * _ump_osu_lock_signal() can be used with statically initialized locks.
+ * _UMP_OSU_LOCKMODE_RW mode should be used when waiting and signalling
+ * statically initialized locks.
+ *
+ * For the same \a nr a pointer to the same statically initialized lock is
+ * returned. That is, given the following code:
+ * @code
+ * extern u32 n;
+ *
+ * _ump_osu_lock_t *locka = _ump_osu_lock_static(n);
+ * _ump_osu_lock_t *lockb = _ump_osu_lock_static(n);
+ * @endcode
+ * Then (locka == lockb), for all 0 <= n < UMP_OSU_STATIC_LOCK_COUNT.
+ *
+ * @param nr index of a statically initialized lock [0..UMP_OSU_STATIC_LOCK_COUNT-1]
+ * @return On success, a pointer to a _ump_osu_lock_t object. NULL on failure.
+ */
+_ump_osu_lock_t *_ump_osu_lock_static( u32 nr );
+
+/** @brief Initialize a Mutual Exclusion Lock safely across multiple threads.
+ *
+ * The _ump_osu_lock_auto_init() function guarantees that the given lock will
+ * be initialized once and precisely once, even in a situation involving
+ * multiple threads.
+ *
+ * This is necessary because the first call to certain Public API functions must
+ * initialize the API. However, there can be a race involved to call the first
+ * library function in multi-threaded applications. To resolve this race, a
+ * mutex can be used. This mutex must be initialized, but initialized only once
+ * by any thread that might compete for its initialization. This function
+ * guarantees the initialization to happen correctly, even when there is an
+ * initialization race between multiple threads.
+ *
+ * Otherwise, the operation is identical to the _ump_osu_lock_init() function.
+ * For more details, refer to _ump_osu_lock_init().
+ *
+ * @param pplock pointer to storage for a _ump_osu_lock_t pointer. This
+ * _ump_osu_lock_t pointer may point to a _ump_osu_lock_t that has been
+ * initialized already
+ * @param flags flags combined with bitwise OR ('|'), or zero. There are
+ * restrictions on which flags can be combined. Refer to
+ * \ref _ump_osu_lock_flags_t for more information.
+ * The absence of any flags (the value 0) results in a sleeping-mutex,
+ * which is non-interruptible.
+ * @param initial For future expansion into semaphores. SBZ.
+ * @param order The locking order of the mutex. SBZ.
+ * @return On success, _UMP_OSU_ERR_OK is returned and a pointer to an
+ * initialized \ref _ump_osu_lock_t object is written into \a *pplock.
+ * _UMP_OSU_ERR_FAULT is returned on failure.
+ */
+_ump_osu_errcode_t _ump_osu_lock_auto_init( _ump_osu_lock_t **pplock, _ump_osu_lock_flags_t flags, u32 initial, u32 order );
+
+/** @brief Wait for a lock to be signalled (obtained).
+ *
+ * After a thread has successfully waited on the lock, the lock is obtained by
+ * the thread, and is marked as unsignalled. The thread releases the lock by
+ * signalling it.
+ *
+ * To prevent deadlock, locks must always be obtained in the same order.
+ *
+ * @param lock the lock to wait upon (obtain).
+ * @param mode the mode in which the lock should be obtained. Currently this
+ * must be _UMP_OSU_LOCKMODE_RW.
+ * @return On success, _UMP_OSU_ERR_OK, _UMP_OSU_ERR_FAULT on error.
+ */
+_ump_osu_errcode_t _ump_osu_lock_wait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode);
+
+/** @brief Wait for a lock to be signalled (obtained) with timeout
+ *
+ * After a thread has successfully waited on the lock, the lock is obtained by
+ * the thread, and is marked as unsignalled. The thread releases the lock by
+ * signalling it.
+ *
+ * To prevent deadlock, locks must always be obtained in the same order.
+ *
+ * This version can return early if it cannot obtain the lock within the given timeout.
+ *
+ * @param lock the lock to wait upon (obtain).
+ * @param mode the mode in which the lock should be obtained. Currently this
+ * must be _UMP_OSU_LOCKMODE_RW.
+ * @param timeout Relative time in microseconds for the timeout
+ * @return _UMP_OSU_ERR_OK if the lock was obtained, _UMP_OSU_ERR_TIMEOUT if the timeout expired or _UMP_OSU_ERR_FAULT on error.
+ */
+_ump_osu_errcode_t _ump_osu_lock_timed_wait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode, u64 timeout);
+
+/** @brief Test for a lock to be signalled and obtains the lock when so.
+ *
+ * Obtains the lock only when it is in signalled state. The lock is then
+ * marked as unsignalled. The lock is released again by signalling
+ * it by _ump_osu_lock_signal().
+ *
+ * If the lock could not be obtained immediately (that is, another thread
+ * currently holds the lock), then this function \b does \b not wait for the
+ * lock to be in a signalled state. Instead, an error code is immediately
+ * returned to indicate that the thread could not obtain the lock.
+ *
+ * To prevent deadlock, locks must always be obtained in the same order.
+ *
+ * @param lock the lock to wait upon (obtain).
+ * @param mode the mode in which the lock should be obtained. Currently this
+ * must be _UMP_OSU_LOCKMODE_RW.
+ * @return When the lock was obtained, _UMP_OSU_ERR_OK. If the lock could not
+ * be obtained, _UMP_OSU_ERR_FAULT.
+ */
+_ump_osu_errcode_t _ump_osu_lock_trywait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode);
+
+/** @brief Signal (release) a lock.
+ *
+ * Locks may only be signalled by the thread that originally waited upon the
+ * lock, unless the lock was created using the _UMP_OSU_LOCKFLAG_ANYUNLOCK flag.
+ *
+ * @param lock the lock to signal (release).
+ * @param mode the mode in which the lock should be obtained. This must match
+ * the mode in which the lock was waited upon.
+ */
+void _ump_osu_lock_signal( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode );
+
+/** @brief Terminate a lock.
+ *
+ * This terminates a lock and frees all associated resources.
+ *
+ * It is a programming error to terminate the lock when it is held (unsignalled)
+ * by a thread.
+ *
+ * @param lock the lock to terminate.
+ */
+void _ump_osu_lock_term( _ump_osu_lock_t *lock );
+/** @} */ /* end group _ump_osu_lock */
+
+/** @} */ /* end group osuapi */
+
+/** @} */ /* end group uddapi */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UMP_OSU_H__ */
diff --git a/exynos4/hal/libump/include/ump/ump_platform.h b/exynos4/hal/libump/include/ump/ump_platform.h
new file mode 100644
index 0000000..68e01be
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump_platform.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_platform.h
+ *
+ * This file should define UMP_API_EXPORT,
+ * which dictates how the UMP user space API should be exported/imported.
+ * Modify this file, if needed, to match your platform setup.
+ */
+
+#ifndef __UMP_PLATFORM_H__
+#define __UMP_PLATFORM_H__
+
+/** @addtogroup ump_user_space_api
+ * @{ */
+
+/**
+ * A define which controls how UMP user space API functions are imported and exported.
+ * This define should be set by the implementor of the UMP API.
+ */
+#if defined(_WIN32)
+
+#define UMP_API_EXPORT
+
+#elif defined(__SYMBIAN32__)
+
+#define UMP_API_EXPORT IMPORT_C
+
+#else
+
+#if defined(__GNUC__)
+#if __GNUC__ >= 4
+# define MALI_VISIBLE __attribute__ ((visibility ("default"))) /**< Function should be visible from outside the dll */
+#else
+# define MALI_VISIBLE
+#endif
+
+#elif defined(__ARMCC_VERSION)
+/* ARMCC specific */
+# define MALI_VISIBLE __declspec(dllexport)
+
+#else
+# define MALI_VISIBLE
+
+#endif
+
+#define UMP_API_EXPORT MALI_VISIBLE
+
+#endif
+
+/** @} */ /* end group ump_user_space_api */
+
+
+#endif /* __UMP_PLATFORM_H__ */
diff --git a/exynos4/hal/libump/include/ump/ump_ref_drv.h b/exynos4/hal/libump/include/ump/ump_ref_drv.h
new file mode 100644
index 0000000..19fb28d
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump_ref_drv.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_ref_drv.h
+ *
+ * Reference driver extensions to the UMP user space API for allocating UMP memory
+ */
+
+#ifndef _UNIFIED_MEMORY_PROVIDER_REF_DRV_H_
+#define _UNIFIED_MEMORY_PROVIDER_REF_DRV_H_
+
+#include "ump.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+ /* This enum must match with the IOCTL enum in ump_ioctl.h */
+ UMP_REF_DRV_CONSTRAINT_NONE = 0,
+ UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR = 1,
+ UMP_REF_DRV_CONSTRAINT_USE_CACHE = 4,
+} ump_alloc_constraints;
+
+/** Allocate an UMP handle containing a memory buffer.
+ * Input: Size: The minimum size for the allocation.
+ * Usage: If this is UMP_REF_DRV_CONSTRAINT_USE_CACHE, the allocation is mapped as cached by the cpu.
+ * If it is UMP_REF_DRV_CONSTRAINT_NONE it is mapped as noncached.
+ * The flag UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR is not supported.*/
+UMP_API_EXPORT ump_handle ump_ref_drv_allocate(unsigned long size, ump_alloc_constraints usage);
+
+typedef enum
+{
+ UMP_MSYNC_CLEAN = 0 ,
+ UMP_MSYNC_CLEAN_AND_INVALIDATE = 1,
+ UMP_MSYNC_READOUT_CACHE_ENABLED = 128,
+} ump_cpu_msync_op;
+
+/** Flushing cache for an ump_handle.
+ * The function will always CLEAN_AND_INVALIDATE as long as the \a op is not UMP_MSYNC_READOUT_CACHE_ENABLED.
+ * If so it will only report back if the given ump_handle is cacheable.
+ * At the momement the implementation does not use \a address or \a size.
+ * Return value is 1 if cache is enabled, and 0 if it is disabled for the given allocation.*/
+UMP_API_EXPORT int ump_cpu_msync_now(ump_handle mem, ump_cpu_msync_op op, void* address, int size);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_UNIFIED_MEMORY_PROVIDER_REF_DRV_H_ */
diff --git a/exynos4/hal/libump/include/ump/ump_uk_types.h b/exynos4/hal/libump/include/ump/ump_uk_types.h
new file mode 100644
index 0000000..1a4c1c8
--- /dev/null
+++ b/exynos4/hal/libump/include/ump/ump_uk_types.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_uk_types.h
+ * Defines the types and constants used in the user-kernel interface
+ */
+
+#ifndef __UMP_UK_TYPES_H__
+#define __UMP_UK_TYPES_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Helpers for API version handling */
+#define MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
+#define IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
+#define GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
+#define IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
+
+/**
+ * API version define.
+ * Indicates the version of the kernel API
+ * The version is a 16bit integer incremented on each API change.
+ * The 16bit integer is stored twice in a 32bit integer
+ * So for version 1 the value would be 0x00010001
+ */
+#define UMP_IOCTL_API_VERSION MAKE_VERSION_ID(2)
+
+typedef enum
+{
+ _UMP_IOC_QUERY_API_VERSION = 1,
+ _UMP_IOC_ALLOCATE,
+ _UMP_IOC_RELEASE,
+ _UMP_IOC_SIZE_GET,
+ _UMP_IOC_MAP_MEM, /* not used in Linux */
+ _UMP_IOC_UNMAP_MEM, /* not used in Linux */
+ _UMP_IOC_MSYNC,
+}_ump_uk_functions;
+
+typedef enum
+{
+ UMP_REF_DRV_UK_CONSTRAINT_NONE = 0,
+ UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR = 1,
+ UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE = 4,
+} ump_uk_alloc_constraints;
+
+typedef enum
+{
+ _UMP_UK_MSYNC_CLEAN = 0,
+ _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE = 1,
+ _UMP_UK_MSYNC_READOUT_CACHE_ENABLED = 128,
+} ump_uk_msync_op;
+
+/**
+ * Get API version ([in,out] u32 api_version, [out] u32 compatible)
+ */
+typedef struct _ump_uk_api_version_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ u32 version; /**< Set to the user space version on entry, stores the device driver version on exit */
+ u32 compatible; /**< Non-null if the device is compatible with the client */
+} _ump_uk_api_version_s;
+
+/**
+ * ALLOCATE ([out] u32 secure_id, [in,out] u32 size, [in] contraints)
+ */
+typedef struct _ump_uk_allocate_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ u32 secure_id; /**< Return value from DD to Userdriver */
+ u32 size; /**< Input and output. Requested size; input. Returned size; output */
+ ump_uk_alloc_constraints constraints; /**< Only input to Devicedriver */
+} _ump_uk_allocate_s;
+
+/**
+ * SIZE_GET ([in] u32 secure_id, [out]size )
+ */
+typedef struct _ump_uk_size_get_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ u32 secure_id; /**< Input to DD */
+ u32 size; /**< Returned size; output */
+} _ump_uk_size_get_s;
+
+/**
+ * Release ([in] u32 secure_id)
+ */
+typedef struct _ump_uk_release_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ u32 secure_id; /**< Input to DD */
+} _ump_uk_release_s;
+
+typedef struct _ump_uk_map_mem_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ void *mapping; /**< [out] Returns user-space virtual address for the mapping */
+ void *phys_addr; /**< [in] physical address */
+ unsigned long size; /**< [in] size */
+ u32 secure_id; /**< [in] secure_id to assign to mapping */
+ void * _ukk_private; /**< Only used inside linux port between kernel frontend and common part to store vma */
+ u32 cookie;
+ u32 is_cached; /**< [in,out] caching of CPU mappings */
+} _ump_uk_map_mem_s;
+
+typedef struct _ump_uk_unmap_mem_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ void *mapping;
+ u32 size;
+ void * _ukk_private;
+ u32 cookie;
+} _ump_uk_unmap_mem_s;
+
+typedef struct _ump_uk_msync_s
+{
+ void *ctx; /**< [in,out] user-kernel context (trashed on output) */
+ void *mapping; /**< [in] mapping addr */
+ void *address; /**< [in] flush start addr */
+ u32 size; /**< [in] size to flush */
+ ump_uk_msync_op op; /**< [in] flush operation */
+ u32 cookie; /**< [in] cookie stored with reference to the kernel mapping internals */
+ u32 secure_id; /**< [in] cookie stored with reference to the kernel mapping internals */
+ u32 is_cached; /**< [out] caching of CPU mappings */
+} _ump_uk_msync_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UMP_UK_TYPES_H__ */
diff --git a/exynos4/hal/libump/os/linux/ump_ioctl.h b/exynos4/hal/libump/os/linux/ump_ioctl.h
new file mode 100644
index 0000000..e978858
--- /dev/null
+++ b/exynos4/hal/libump/os/linux/ump_ioctl.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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 __UMP_IOCTL_H__
+#define __UMP_IOCTL_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#include <ump_uk_types.h>
+
+#ifndef __user
+#define __user
+#endif
+
+
+/**
+ * @file UMP_ioctl.h
+ * This file describes the interface needed to use the Linux device driver.
+ * The interface is used by the userpace UMP driver.
+ */
+
+#define UMP_IOCTL_NR 0x90
+
+
+#define UMP_IOC_QUERY_API_VERSION _IOR(UMP_IOCTL_NR, _UMP_IOC_QUERY_API_VERSION, _ump_uk_api_version_s)
+#define UMP_IOC_ALLOCATE _IOWR(UMP_IOCTL_NR, _UMP_IOC_ALLOCATE, _ump_uk_allocate_s)
+#define UMP_IOC_RELEASE _IOR(UMP_IOCTL_NR, _UMP_IOC_RELEASE, _ump_uk_release_s)
+#define UMP_IOC_SIZE_GET _IOWR(UMP_IOCTL_NR, _UMP_IOC_SIZE_GET, _ump_uk_size_get_s)
+#define UMP_IOC_MSYNC _IOW(UMP_IOCTL_NR, _UMP_IOC_MSYNC, _ump_uk_size_get_s)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UMP_IOCTL_H__ */
diff --git a/exynos4/hal/libump/os/linux/ump_osu_locks.c b/exynos4/hal/libump/os/linux/ump_osu_locks.c
new file mode 100644
index 0000000..97ba858
--- /dev/null
+++ b/exynos4/hal/libump/os/linux/ump_osu_locks.c
@@ -0,0 +1,537 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+#if ((!defined _XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 600))
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 600
+#endif
+
+
+#define _POSIX_C_SOURCE 200112L
+
+#include <ump/ump_osu.h>
+#include <ump/ump_debug.h>
+
+#include <pthread.h>
+#include <time.h>
+#include <sys/time.h>
+#include <errno.h>
+
+/**
+ * @file ump_osu_locks.c
+ * File implements the user side of the OS interface
+ */
+
+/** @opt Most of the time, we use the plain mutex type of osu_lock, and so
+ * only require the flags and mutex members. This costs 2 extra DWORDS, but
+ * most of the time we don't use those DWORDS.
+ * Therefore, ANY_UNLOCK type osu_locks can be implemented as a second
+ * structure containing the member _ump_osu_lock_t lock_t, plus the extra
+ * state required. Then, we use &container->lock_t when passing out of the
+ * OSU api, and CONTAINER_OF() when passing back in to recover the original
+ * structure. */
+
+/** Private declaration of the OSU lock type */
+struct _ump_osu_lock_t_struct
+{
+ /** At present, only two types of mutex, so we store this information as
+ * the flags supplied at init time */
+ _ump_osu_lock_flags_t flags;
+
+ pthread_mutex_t mutex; /**< Used in both plain and ANY_UNLOCK osu_locks */
+
+ /* Extra State for ANY_UNLOCK osu_locks. These are UNINITIALIZED when
+ * flags does not contain _UMP_OSU_LOCKFLAG_ANYUNLOCK: */
+ pthread_cond_t condition; /**< The condition object to use while blocking */
+ ump_bool state; /**< The boolean which indicates the event's state */
+
+ UMP_DEBUG_CODE(
+ /** debug checking of locks */
+ _ump_osu_lock_mode_t locked_as;
+ ) /* UMP_DEBUG_CODE */
+
+};
+
+/* Provide two statically initialized locks */
+UMP_STATIC _ump_osu_lock_t _ump_osu_static_locks[] =
+{
+ {
+ _UMP_OSU_LOCKFLAG_STATIC,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_COND_INITIALIZER,
+ UMP_FALSE,
+ UMP_DEBUG_CODE( _UMP_OSU_LOCKMODE_UNDEF )
+ },
+ {
+ _UMP_OSU_LOCKFLAG_STATIC,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_COND_INITIALIZER,
+ UMP_FALSE,
+ UMP_DEBUG_CODE( _UMP_OSU_LOCKMODE_UNDEF )
+ },
+ {
+ _UMP_OSU_LOCKFLAG_STATIC,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_COND_INITIALIZER,
+ UMP_FALSE,
+ UMP_DEBUG_CODE( _UMP_OSU_LOCKMODE_UNDEF )
+ },
+ {
+ _UMP_OSU_LOCKFLAG_STATIC,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_COND_INITIALIZER,
+ UMP_FALSE,
+ UMP_DEBUG_CODE( _UMP_OSU_LOCKMODE_UNDEF )
+ },
+};
+
+/* Critical section for auto_init */
+UMP_STATIC pthread_mutex_t static_auto_init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+
+_ump_osu_errcode_t _ump_osu_lock_auto_init( _ump_osu_lock_t **pplock, _ump_osu_lock_flags_t flags, u32 initial, u32 order )
+{
+ int call_result;
+ /* Validate parameters: */
+ UMP_DEBUG_ASSERT_POINTER( pplock );
+
+ /** @opt We don't lock the Critical Section or do anything if this is already non-null */
+ if ( NULL != *pplock)
+ {
+ return _UMP_OSU_ERR_OK;
+ }
+
+ /* We MIGHT need to initialize it, lock the Critical Section and check again */
+ call_result = pthread_mutex_lock(&static_auto_init_mutex);
+ /* It would be a programming error for this to fail: */
+ UMP_DEBUG_ASSERT( 0 == call_result,
+ ("failed to lock critical section\n") );
+
+ if ( NULL != *pplock )
+ {
+ /*
+ We caught a race condition to initialize this osu_lock.
+ The other thread won the race, so the osu_lock is now initialized.
+ */
+ call_result = pthread_mutex_unlock(&static_auto_init_mutex);
+
+ UMP_DEBUG_ASSERT(0 == call_result,
+ ("failed to unlock critical section\n"));
+
+ return _UMP_OSU_ERR_OK;
+ }
+
+ /* We're the first thread in: initialize the osu_lock */
+ *pplock = _ump_osu_lock_init( flags, initial, order );
+
+ if ( NULL == *pplock )
+ {
+ /* osu_lock creation failed */
+ call_result = pthread_mutex_unlock(&static_auto_init_mutex);
+ UMP_DEBUG_ASSERT(0 == call_result,
+ ("failed to unlock critical section\n"));
+
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+
+ /* osu_lock created OK */
+ call_result = pthread_mutex_unlock(&static_auto_init_mutex);
+
+ UMP_DEBUG_ASSERT(0 == call_result,
+ ("failed to unlock critical section\n"));
+
+ UMP_IGNORE( call_result );
+
+ return _UMP_OSU_ERR_OK;
+}
+
+
+_ump_osu_lock_t *_ump_osu_lock_init( _ump_osu_lock_flags_t flags, u32 initial, u32 order )
+{
+ _ump_osu_lock_t * lock;
+ pthread_mutexattr_t mutex_attributes;
+
+ /* Validate parameters: */
+ /* Flags acceptable */
+ UMP_DEBUG_ASSERT( 0 == ( flags & ~( _UMP_OSU_LOCKFLAG_ANYUNLOCK)),
+ ("incorrect flags or trying to initialise a statically initialized lock, %.8X\n", flags) );
+
+ /* Parameter initial SBZ - for future expansion */
+ UMP_DEBUG_ASSERT( 0 == initial,
+ ("initial must be zero\n") );
+
+ if (0 != pthread_mutexattr_init(&mutex_attributes))
+ {
+ return NULL;
+ }
+
+#if UMP_DEBUG_EXTENDED_MUTEX_LOCK_CHECKING
+#define UMP_PTHREADS_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK
+#else
+#define UMP_PTHREADS_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT
+#endif
+
+ if (0 != pthread_mutexattr_settype(&mutex_attributes, UMP_PTHREADS_MUTEX_TYPE))
+ {
+ /** Return NULL on failure */
+ pthread_mutexattr_destroy(&mutex_attributes);
+ return NULL;
+
+ }
+
+#undef UMP_PTHREADS_MUTEX_TYPE
+
+ /** @opt use containing structures for the ANY_UNLOCK type, to
+ * save 2 DWORDS when not in use */
+ lock = _ump_osu_malloc( sizeof(_ump_osu_lock_t) );
+
+ if( NULL == lock )
+ {
+ /** Return NULL on failure */
+ pthread_mutexattr_destroy(&mutex_attributes);
+ return NULL;
+ }
+
+ if (0 != pthread_mutex_init( &lock->mutex, &mutex_attributes ))
+ {
+ pthread_mutexattr_destroy(&mutex_attributes);
+ _ump_osu_free( lock );
+ return NULL;
+ }
+
+ /* done with the mutexattr object */
+ pthread_mutexattr_destroy(&mutex_attributes);
+
+ /* ANY_UNLOCK type */
+ if ( flags & _UMP_OSU_LOCKFLAG_ANYUNLOCK )
+ {
+ if (0 != pthread_cond_init( &lock->condition, NULL ))
+ {
+ /* cleanup */
+ pthread_mutex_destroy( &lock->mutex );
+ _ump_osu_free( lock );
+ return NULL;
+ }
+ lock->state = UMP_FALSE; /* mark as unlocked by default */
+ }
+
+ lock->flags = flags;
+
+ /** Debug lock checking */
+ UMP_DEBUG_CODE( lock->locked_as = _UMP_OSU_LOCKMODE_UNDEF );
+
+ return lock;
+}
+
+_ump_osu_errcode_t _ump_osu_lock_timed_wait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode, u64 timeout)
+{
+ /* absolute time specifier */
+ struct timespec ts;
+ struct timeval tv;
+
+ /* Parameter validation */
+ UMP_DEBUG_ASSERT_POINTER( lock );
+
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_RW == mode,
+ ("unrecognised mode, %.8X\n", mode) );
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKFLAG_ANYUNLOCK == lock->flags, ("Timed operations only implemented for ANYUNLOCK type locks"));
+
+ /* calculate the realtime timeout value */
+
+ if (0 != gettimeofday(&tv, NULL))
+ {
+ UMP_DEBUG_PRINT(1,("Could not get the current realtime value to calculate the absolute value for a timed mutex lock with a timeout"));
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ tv.tv_usec += timeout;
+
+#define UMP_USECS_PER_SECOND 1000000ULL
+#define UMP_NANOSECS_PER_USEC 1000ULL
+
+ /* did we overflow a second in the usec part? */
+ while (tv.tv_usec >= UMP_USECS_PER_SECOND)
+ {
+ tv.tv_usec -= UMP_USECS_PER_SECOND;
+ tv.tv_sec++;
+ }
+
+ /* copy to the correct struct */
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = (tv.tv_usec * UMP_NANOSECS_PER_USEC);
+
+#undef UMP_USECS_PER_SECOND
+#undef UMP_NANOSECS_PER_USEC
+
+ /* lock the mutex protecting access to the state field */
+ pthread_mutex_lock( &lock->mutex );
+ /* loop while locked (state is UMP_TRUE) */
+ /* pthread_cond_timedwait unlocks the mutex, wait, and locks the mutex once unblocked (either due to the event or the timeout) */
+ while ( UMP_TRUE == lock->state )
+ {
+ int res;
+ res = pthread_cond_timedwait( &lock->condition, &lock->mutex, &ts );
+ if (0 == res) continue; /* test the state variable again (loop condition) */
+ else if (ETIMEDOUT == res)
+ {
+ /* timeout, need to clean up and return the correct error code */
+ pthread_mutex_unlock(&lock->mutex);
+ return _UMP_OSU_ERR_TIMEOUT;
+ }
+ else
+ {
+ UMP_DEBUG_PRINT(1, ("Unexpected return from pthread_cond_timedwait 0x%08X\n", res));
+
+ pthread_mutex_unlock(&lock->mutex);
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ }
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as,
+ ("This lock was already locked\n") );
+ UMP_DEBUG_CODE( lock->locked_as = mode );
+
+ /* the state is UMP_FALSE (unlocked), so we set it to UMP_TRUE to indicate that it's locked and can return knowing that we own the lock */
+ lock->state = UMP_TRUE;
+ /* final unlock of the mutex */
+ pthread_mutex_unlock(&lock->mutex);
+
+ return _UMP_OSU_ERR_OK;
+
+}
+
+_ump_osu_errcode_t _ump_osu_lock_wait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode)
+{
+ /* Parameter validation */
+ UMP_DEBUG_ASSERT_POINTER( lock );
+
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_RW == mode,
+ ("unrecognised mode, %.8X\n", mode) );
+
+ /** @note since only one flag can be set, we use a switch statement here.
+ * Otherwise, MUST add an enum into the _ump_osu_lock_t to store the
+ * implemented lock type */
+ switch ( lock->flags )
+ {
+ case _UMP_OSU_LOCKFLAG_STATIC:
+ case 0:
+ /* Usual Mutex type */
+ {
+ int call_result;
+ call_result = pthread_mutex_lock( &lock->mutex );
+ UMP_DEBUG_ASSERT( 0 == call_result,
+ ("pthread_mutex_lock call failed with error code %d\n", call_result));
+ UMP_IGNORE( call_result );
+ }
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as,
+ ("This lock was already locked\n") );
+ UMP_DEBUG_CODE( lock->locked_as = mode );
+ break;
+
+ case _UMP_OSU_LOCKFLAG_ANYUNLOCK:
+ /** @note Use of bitflags in a case statement ONLY works because this
+ * is the ONLY flag that is supported */
+
+ /* lock the mutex protecting access to the state field */
+ pthread_mutex_lock( &lock->mutex );
+ /* loop while locked (state is UMP_TRUE) */
+ /* pthread_cond_wait unlocks the mutex, wait, and locks the mutex once unblocked */
+ while ( UMP_TRUE == lock->state ) pthread_cond_wait( &lock->condition, &lock->mutex );
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as,
+ ("This lock was already locked\n") );
+ UMP_DEBUG_CODE( lock->locked_as = mode );
+
+ /* the state is UMP_FALSE (unlocked), so we set it to UMP_TRUE to indicate that it's locked and can return knowing that we own the lock */
+ lock->state = UMP_TRUE;
+ /* final unlock of the mutex */
+ pthread_mutex_unlock(&lock->mutex);
+ break;
+
+ default:
+ UMP_DEBUG_ERROR( ("lock has incorrect flags==%.8X\n", lock->flags) );
+ break;
+ }
+
+ return _UMP_OSU_ERR_OK;
+}
+
+_ump_osu_errcode_t _ump_osu_lock_trywait( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode)
+{
+ _ump_osu_errcode_t err = _UMP_OSU_ERR_FAULT;
+ /* Parameter validation */
+ UMP_DEBUG_ASSERT_POINTER( lock );
+
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_RW == mode,
+ ("unrecognised mode, %.8X\n", mode) );
+
+ /** @note since only one flag can be set, we use a switch statement here.
+ * Otherwise, MUST add an enum into the _ump_osu_lock_t to store the
+ * implemented lock type */
+ switch ( lock->flags )
+ {
+ case _UMP_OSU_LOCKFLAG_STATIC:
+ case 0:
+ /* Usual Mutex type */
+ {
+ /* This is not subject to UMP_CHECK - overriding the result would cause a programming error */
+ if ( 0 == pthread_mutex_trylock( &lock->mutex ) )
+ {
+ err = _UMP_OSU_ERR_OK;
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as
+ || mode == lock->locked_as,
+ ("tried as mode==%.8X, but was locked as %.8X\n", mode, lock->locked_as) );
+ UMP_DEBUG_CODE( lock->locked_as = mode );
+ }
+ }
+ break;
+
+ case _UMP_OSU_LOCKFLAG_ANYUNLOCK:
+ /** @note Use of bitflags in a case statement ONLY works because this
+ * is the ONLY flag that is supported */
+
+ /* lock the mutex protecting access to the state field */
+ pthread_mutex_lock(&lock->mutex);
+
+ if ( UMP_FALSE == lock->state)
+ {
+ /* unlocked, take the lock */
+ lock->state = UMP_TRUE;
+ err = _UMP_OSU_ERR_OK;
+ }
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ /* Can do this regardless of whether we obtained ANYUNLOCK: */
+
+
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as
+ || mode == lock->locked_as,
+ ("tried as mode==%.8X, but was locked as %.8X\n", mode, lock->locked_as) );
+ /* If we were already locked, this does no harm, because of the above assert: */
+ UMP_DEBUG_CODE( lock->locked_as = mode );
+
+ pthread_mutex_unlock(&lock->mutex);
+ break;
+
+ default:
+ UMP_DEBUG_ERROR( ("lock has incorrect flags==%.8X\n", lock->flags) );
+ break;
+ }
+
+ return err;
+}
+
+
+void _ump_osu_lock_signal( _ump_osu_lock_t *lock, _ump_osu_lock_mode_t mode )
+{
+ /* Parameter validation */
+ UMP_DEBUG_ASSERT_POINTER( lock );
+
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_RW == mode,
+ ("unrecognised mode, %.8X\n", mode) );
+
+ /** @note since only one flag can be set, we use a switch statement here.
+ * Otherwise, MUST add an enum into the _ump_osu_lock_t to store the
+ * implemented lock type */
+ switch ( lock->flags )
+ {
+ case _UMP_OSU_LOCKFLAG_STATIC:
+ case 0:
+ /* Usual Mutex type */
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( mode == lock->locked_as,
+ ("This lock was locked as==%.8X, but tried to unlock as mode==%.8X\n", lock->locked_as, mode));
+ UMP_DEBUG_CODE( lock->locked_as = _UMP_OSU_LOCKMODE_UNDEF );
+
+ {
+ int call_result;
+ call_result = pthread_mutex_unlock( &lock->mutex );
+ UMP_DEBUG_ASSERT( 0 == call_result,
+ ("pthread_mutex_lock call failed with error code %d\n", call_result));
+ UMP_IGNORE( call_result );
+ }
+ break;
+
+ case _UMP_OSU_LOCKFLAG_ANYUNLOCK:
+ /** @note Use of bitflags in a case statement ONLY works because this
+ * is the ONLY flag that is supported */
+
+ pthread_mutex_lock(&lock->mutex);
+ UMP_DEBUG_ASSERT( UMP_TRUE == lock->state, ("Unlocking a _ump_osu_lock_t %p which is not locked\n", lock));
+
+ /* DEBUG tracking of previously locked state - occurs while lock is obtained */
+ UMP_DEBUG_ASSERT( mode == lock->locked_as,
+ ("This lock was locked as==%.8X, but tried to unlock as %.8X\n", lock->locked_as, mode ));
+ UMP_DEBUG_CODE( lock->locked_as = _UMP_OSU_LOCKMODE_UNDEF );
+
+ /* mark as unlocked */
+ lock->state = UMP_FALSE;
+
+ /* signal the condition, only wake a single thread */
+ pthread_cond_signal(&lock->condition);
+
+ pthread_mutex_unlock(&lock->mutex);
+ break;
+
+ default:
+ UMP_DEBUG_ERROR( ("lock has incorrect flags==%.8X\n", lock->flags) );
+ break;
+ }
+}
+
+void _ump_osu_lock_term( _ump_osu_lock_t *lock )
+{
+ int call_result;
+ UMP_DEBUG_ASSERT_POINTER( lock );
+
+ /** Debug lock checking: */
+ /* Lock is signalled on terminate - not a guarantee, since we could be locked immediately beforehand */
+ UMP_DEBUG_ASSERT( _UMP_OSU_LOCKMODE_UNDEF == lock->locked_as,
+ ("cannot terminate held lock\n") );
+
+ call_result = pthread_mutex_destroy( &lock->mutex );
+ UMP_DEBUG_ASSERT( 0 == call_result,
+ ("Incorrect mutex use detected: pthread_mutex_destroy call failed with error code %d\n", call_result) );
+
+ /* Destroy extra state for ANY_UNLOCK type osu_locks */
+ if ( lock->flags & _UMP_OSU_LOCKFLAG_ANYUNLOCK )
+ {
+ UMP_DEBUG_ASSERT( UMP_FALSE == lock->state, ("terminate called on locked object %p\n", lock));
+ call_result = pthread_cond_destroy(&lock->condition);
+ UMP_DEBUG_ASSERT( 0 == call_result,
+ ("Incorrect condition-variable use detected: pthread_cond_destroy call failed with error code %d\n", call_result) );
+ }
+
+ UMP_IGNORE(call_result);
+
+ _ump_osu_free( lock );
+}
+
+_ump_osu_lock_t *_ump_osu_lock_static( u32 nr )
+{
+ UMP_DEBUG_ASSERT( nr < UMP_OSU_STATIC_LOCK_COUNT,
+ ("provided static lock index (%d) out of bounds (0 < nr < %d)\n", nr, UMP_OSU_STATIC_LOCK_COUNT) );
+ return &_ump_osu_static_locks[nr];
+}
diff --git a/exynos4/hal/libump/os/linux/ump_osu_memory.c b/exynos4/hal/libump/os/linux/ump_osu_memory.c
new file mode 100644
index 0000000..5807594
--- /dev/null
+++ b/exynos4/hal/libump/os/linux/ump_osu_memory.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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 <ump/ump_osu.h>
+
+#include <stdlib.h>
+#include <string.h> /* memcmp, memchr, memset */
+
+/**
+ * @file ump_osu_memory.c
+ * File implements the user side of the OS interface
+ */
+
+void *_ump_osu_calloc( u32 n, u32 size )
+{
+ return calloc( n, size );
+}
+
+void *_ump_osu_malloc( u32 size )
+{
+ return malloc( size );
+}
+
+void *_ump_osu_realloc( void *ptr, u32 size )
+{
+ return realloc( ptr, size );
+}
+
+void _ump_osu_free( void *ptr )
+{
+ free( ptr );
+}
+
+void *_ump_osu_memcpy( void *dst, const void *src, u32 len )
+{
+ return memcpy( dst, src, len );
+}
+
+void *_ump_osu_memset( void *ptr, u32 chr, u32 size )
+{
+ return memset( ptr, chr, size );
+}
+
+int _ump_osu_memcmp( const void *ptr1, const void *ptr2, u32 size )
+{
+ return memcmp( ptr1, ptr2, size );
+}
diff --git a/exynos4/hal/libump/os/linux/ump_uku.c b/exynos4/hal/libump/os/linux/ump_uku.c
new file mode 100644
index 0000000..f46a2c7
--- /dev/null
+++ b/exynos4/hal/libump/os/linux/ump_uku.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_uku.c
+ * File implements the user side of the user-kernel interface
+ */
+
+#include "../ump_uku.h"
+#include <stdio.h>
+#include "ump_ioctl.h"
+
+#include <sys/mman.h>
+
+/* Needed for file operations on the device file*/
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+static _ump_osu_errcode_t ump_driver_ioctl(void *context, u32 command, void *args);
+
+static int ump_ioctl_api_version_used = UMP_IOCTL_API_VERSION;
+
+/**
+ * The device file to access the UMP device driver
+ * This is a character special file giving access to the device driver.
+ * Usually created using the mknod command line utility.
+ */
+static const char ump_device_file_name[] = "/dev/ump";
+
+_ump_osu_errcode_t _ump_uku_open( void **context )
+{
+ int ump_device_file;
+ if(NULL == context)
+ {
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ ump_device_file = open(ump_device_file_name, O_RDWR);
+
+ if (-1 == ump_device_file)
+ {
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ {
+ struct _ump_uk_api_version_s args;
+ args.ctx = (void*)ump_device_file;
+ args.version = UMP_IOCTL_API_VERSION;
+ args.compatible = 3;
+ ump_driver_ioctl(args.ctx, UMP_IOC_QUERY_API_VERSION, &args);
+ if ( 1 != args.compatible )
+ {
+ if (IS_API_MATCH(MAKE_VERSION_ID(1), args.version))
+ {
+ ump_ioctl_api_version_used = MAKE_VERSION_ID(1);
+ UMP_PRINTF("The UMP devicedriver does not support cached UMP. Update it if this is needed.\n");
+ }
+ else
+ {
+ UMP_PRINTF("The UMP devicedriver is version: %d, UMP libraries is version: %d.\n", GET_VERSION(args.version), GET_VERSION(UMP_IOCTL_API_VERSION) );
+ close(ump_device_file);
+ return _UMP_OSU_ERR_FAULT;
+ }
+ }
+ }
+
+ *context = (void *) ump_device_file;
+ return _UMP_OSU_ERR_OK;
+}
+
+_ump_osu_errcode_t _ump_uku_close( void **context )
+{
+ if(NULL == context)
+ {
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ if(-1 == (int)*context)
+ {
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ close((int)*context);
+ *context = (void *)-1;
+
+ return _UMP_OSU_ERR_OK;
+}
+
+int _ump_uku_allocate(_ump_uk_allocate_s *args)
+{
+ return ump_driver_ioctl(args->ctx, UMP_IOC_ALLOCATE, args);
+}
+
+_ump_osu_errcode_t _ump_uku_release(_ump_uk_release_s *args)
+{
+ return ump_driver_ioctl(args->ctx, UMP_IOC_RELEASE, args);
+}
+
+_ump_osu_errcode_t _ump_uku_size_get(_ump_uk_size_get_s *args)
+{
+ return ump_driver_ioctl(args->ctx, UMP_IOC_SIZE_GET, args);
+}
+
+
+void _ump_uku_msynch(_ump_uk_msync_s *args)
+{
+ /* This is for backwards compatibillity */
+ if ( MAKE_VERSION_ID(1) == ump_ioctl_api_version_used)
+ {
+ args->is_cached = 0;
+ if ( _UMP_UK_MSYNC_READOUT_CACHE_ENABLED != args->op )
+ {
+ UMP_DEBUG_PRINT(3, ("Warning: Doing UMP cache flush operations on a Device Driver that does not support cached UMP mem.\n"));
+ }
+ return;
+ }
+ ump_driver_ioctl(args->ctx, UMP_IOC_MSYNC, args);
+}
+
+int _ump_uku_map_mem(_ump_uk_map_mem_s *args)
+{
+ int flags;
+ if( -1 == (int)args->ctx )
+ {
+ return -1;
+ }
+
+ flags = MAP_SHARED;
+
+ /* This is for backwards compatibillity */
+ if ( MAKE_VERSION_ID(1) == ump_ioctl_api_version_used)
+ {
+ args->is_cached = 0;
+ }
+
+ /* If we want the Caching to be enabled we set the flags to be PRIVATE. The UMP DD reads this and do proper handling
+ Note: this enforces the user to use proper invalidation*/
+ if ( args->is_cached ) flags = MAP_PRIVATE;
+
+ args->mapping = mmap(NULL, args->size, PROT_READ | PROT_WRITE ,flags , (int)args->ctx, (off_t)args->secure_id * sysconf(_SC_PAGE_SIZE));
+ if (MAP_FAILED == args->mapping)
+ {
+ return -1;
+ }
+
+ args->cookie = 0; /* Cookie is not used in linux _ump_uku_unmap_mem */
+
+ return 0;
+}
+
+void _ump_uku_unmap_mem( _ump_uk_unmap_mem_s *args )
+{
+ /*
+ * If a smaller size is used Linux will just remove the requested range but don't tell
+ * the ump driver before all of it is unmapped, either via another unmap request or upon process shutdown.
+ * Unmapping too much will just ignore the overhead or hit undefined behavior,
+ * only affecting the calling process which could mess itself up in other ways anyway.
+ * So we don't need any security checks here.
+ */
+ munmap(args->mapping, args->size);
+}
+
+static _ump_osu_errcode_t ump_driver_ioctl(void *context, u32 command, void *args)
+{
+ /*UMP_CHECK_NON_NULL(args, _UMP_OSK_ERR_INVALID_ARGS);*/
+
+ /* check for a valid file descriptor */
+ /** @note manual type safety check-point */
+ if( -1 == (int)context )
+ {
+ return _UMP_OSU_ERR_FAULT;
+ }
+
+ /* call ioctl handler of driver */
+ if (0 != ioctl((int)context, command, args)) return -1;
+ return _UMP_OSU_ERR_OK;
+}
diff --git a/exynos4/hal/libump/os/ump_uku.h b/exynos4/hal/libump/os/ump_uku.h
new file mode 100644
index 0000000..7da7185
--- /dev/null
+++ b/exynos4/hal/libump/os/ump_uku.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+/**
+ * @file ump_uku.h
+ * Defines the user-side interface of the user-kernel interface
+ */
+
+#ifndef __UMP_UKU_H__
+#define __UMP_UKU_H__
+
+#include <ump/ump_osu.h>
+#include <ump/ump_debug.h>
+#include <ump/ump_uk_types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+_ump_osu_errcode_t _ump_uku_open( void **context );
+
+_ump_osu_errcode_t _ump_uku_close( void **context );
+
+_ump_osu_errcode_t _ump_uku_allocate( _ump_uk_allocate_s *args );
+
+_ump_osu_errcode_t _ump_uku_release( _ump_uk_release_s *args );
+
+_ump_osu_errcode_t _ump_uku_size_get( _ump_uk_size_get_s *args );
+
+_ump_osu_errcode_t _ump_uku_get_api_version( _ump_uk_api_version_s *args );
+
+int _ump_uku_map_mem( _ump_uk_map_mem_s *args );
+
+void _ump_uku_unmap_mem( _ump_uk_unmap_mem_s *args );
+
+void _ump_uku_msynch(_ump_uk_msync_s *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UMP_UKU_H__ */
diff --git a/exynos4/hal/libump/readme.txt b/exynos4/hal/libump/readme.txt
new file mode 100644
index 0000000..297df38
--- /dev/null
+++ b/exynos4/hal/libump/readme.txt
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2010-2011 ARM Limited. All rights reserved.
+#
+# 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.
+#
+Building the UMP user space library for Linux
+---------------------------------------------
+
+A simple Makefile is provided, and the UMP user space library can be built
+simply by issuing make. This Makefile is setup to use the ARM GCC compiler
+from CodeSourcery, and it builds for ARMv6. Modification to this Makefile
+is needed in order to build for other configurations.
+
+In order to use this library from the Mali GPU driver, invoke the Mali GPU
+driver build system with the following two make variables set;
+- UMP_INCLUDE_DIR should point to the include folder inside this package
+- UMP_LIB should point to the built library (libUMP.so)
+
+This does not apply to Android builds, where the Android.mk file for the
+Mali GPU driver needs to be manually edited in order to add the correct
+include path and link against the correct library.
diff --git a/exynos4/hal/libump/ump.mak b/exynos4/hal/libump/ump.mak
new file mode 100644
index 0000000..e417313
--- /dev/null
+++ b/exynos4/hal/libump/ump.mak
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2011 ARM Limited. All rights reserved.
+#
+# 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.
+#
+
+ifeq ($(UMP_NO_UMP),1)
+
+UMP_SRCS = \
+ $(UMP_DIR)/arch_999_no_ump/ump_frontend.c \
+ $(UMP_DIR)/arch_999_no_ump/ump_ref_drv.c
+
+else
+
+UMP_SRCS = \
+ $(UMP_DIR)/arch_011_udd/ump_frontend.c \
+ $(UMP_DIR)/arch_011_udd/ump_ref_drv.c \
+ $(UMP_DIR)/arch_011_udd/ump_arch.c \
+ $(UMP_DIR)/os/$(UDD_OS)/ump_uku.c \
+ $(UMP_DIR)/os/$(UDD_OS)/ump_osu_memory.c \
+ $(UMP_DIR)/os/$(UDD_OS)/ump_osu_locks.c
+
+endif
+