├── Android.mk ├── AndroidBoard.mk ├── AndroidProducts.mk ├── BoardConfig.mk ├── CleanSpec.mk ├── KernelModules.mk ├── click.mk ├── copy-files.sh ├── custom ├── calibrate_screen ├── egl.cfg ├── kernel ├── keychars │ ├── bahamas-keypad.kcm.bin │ ├── qwerty.kcm.bin │ └── qwerty2.kcm.bin ├── keylayout │ ├── bahamas-keypad.kl │ ├── h2w_headset.kl │ └── qwerty.kl ├── klogtail └── modules │ └── wlan.ko ├── extract-files.sh ├── init.bahamas.rc ├── libcamera ├── Android.mk ├── QualcommCameraHardware.cpp ├── QualcommCameraHardware.h ├── exifwriter.c ├── exifwriter.h ├── jdatadst.cpp ├── jdatadst.h ├── jpegConvert.cpp ├── jpegConvert.h ├── msm_camera.h └── raw2jpeg.h ├── libcopybit ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── copybit.cpp ├── libgralloc ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── allocator.cpp ├── allocator.h ├── framebuffer.cpp ├── gr.h ├── gralloc.cpp ├── gralloc_priv.h └── mapper.cpp ├── liblights ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── lights.c ├── libsensors ├── AkmSensor.cpp ├── AkmSensor.h ├── Android.mk ├── InputEventReader.cpp ├── InputEventReader.h ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── SensorBase.cpp ├── SensorBase.h ├── nusensors.cpp ├── nusensors.h └── sensors.c ├── media_profiles.xml ├── overlay ├── frameworks │ └── base │ │ └── core │ │ └── res │ │ └── res │ │ └── values │ │ └── config.xml └── packages │ ├── apps │ ├── CMParts │ │ └── res │ │ │ └── values │ │ │ ├── arrays.xml │ │ │ └── config.xml │ ├── Camera │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ ├── FM │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ ├── Mms │ │ └── res │ │ │ └── xml │ │ │ └── mms_config.xml │ └── Phone │ │ └── res │ │ └── values │ │ └── config.xml │ └── inputmethods │ └── LatinIME │ └── java │ └── res │ ├── layout │ └── input_gingerbread.xml │ ├── values-land │ └── dimens.xml │ └── values │ └── dimens.xml ├── recovery.fstab ├── setup-makefiles.sh ├── system.prop ├── ueventd.bahamas.rc ├── vendorsetup.sh └── vold.fstab /Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(my-dir) 16 | 17 | ifeq ($(TARGET_DEVICE),click) 18 | subdir_makefiles := \ 19 | $(LOCAL_PATH)/libcopybit/Android.mk \ 20 | $(LOCAL_PATH)/libgralloc/Android.mk \ 21 | $(LOCAL_PATH)/liblights/Android.mk \ 22 | $(LOCAL_PATH)/libcamera/Android.mk \ 23 | $(LOCAL_PATH)/libsensors/Android.mk 24 | 25 | include $(subdir_makefiles) 26 | endif 27 | -------------------------------------------------------------------------------- /AndroidBoard.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | -------------------------------------------------------------------------------- /AndroidProducts.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # 18 | # This file should set PRODUCT_MAKEFILES to a list of product makefiles 19 | # to expose to the build system. LOCAL_DIR will already be set to 20 | # the directory containing this file. 21 | # 22 | # This file may not rely on the value of any variable other than 23 | # LOCAL_DIR; do not use any conditionals, and do not look up the 24 | # value of any variable that isn't set in this file or in a file that 25 | # it includes. 26 | # 27 | 28 | PRODUCT_MAKEFILES := \ 29 | $(LOCAL_DIR)/click.mk 30 | -------------------------------------------------------------------------------- /BoardConfig.mk: -------------------------------------------------------------------------------- 1 | # config.mk 2 | # 3 | # Product-specific compile-time definitions. 4 | # 5 | 6 | # WARNING: This line must come *before* including the proprietary 7 | # variant, so that it gets overwritten by the parent (which goes 8 | # against the traditional rules of inheritance). 9 | USE_CAMERA_STUB := true 10 | 11 | # Fake building with froyo cam, as old libcam is not here yet 12 | BOARD_USE_FROYO_LIBCAMERA := true 13 | 14 | # inherit from the proprietary version 15 | -include vendor/htc/click/BoardConfigVendor.mk 16 | 17 | # ARMv6-compatible processor rev 5 (v6l) 18 | TARGET_BOARD_PLATFORM := msm7k 19 | TARGET_ARCH_VARIANT := armv6j 20 | TARGET_CPU_ABI := armeabi-v6j 21 | TARGET_CPU_ABI2 := armeabi 22 | 23 | TARGET_BOOTLOADER_BOARD_NAME := bahamas 24 | TARGET_OTA_ASSERT_DEVICE := click,tattoo 25 | 26 | TARGET_NO_BOOTLOADER := true 27 | TARGET_NO_RADIOIMAGE := true 28 | 29 | BOARD_LDPI_RECOVERY := true 30 | BOARD_HAS_JANKY_BACKBUFFER := true 31 | 32 | TARGET_PREBUILT_KERNEL := device/htc/click/custom/kernel 33 | 34 | # Wifi related defines 35 | BOARD_WPA_SUPPLICANT_DRIVER := CUSTOM 36 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB := libWifiApi 37 | BOARD_WLAN_DEVICE := wl1251 38 | BOARD_WLAN_TI_STA_DK_ROOT := system/wlan/ti/sta_dk_4_0_4_32 39 | WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/wlan.ko" 40 | WIFI_DRIVER_MODULE_ARG := "" 41 | WIFI_DRIVER_MODULE_NAME := "wlan" 42 | WIFI_FIRMWARE_LOADER := "wlan_loader" 43 | 44 | TARGET_PROVIDES_INIT_RC := false 45 | 46 | BOARD_KERNEL_CMDLINE := no_console_suspend=1 console=null 47 | BOARD_KERNEL_BASE := 0x02E00000 48 | BOARD_KERNEL_PAGESIZE := 2048 49 | 50 | BOARD_USES_GENERIC_AUDIO := false 51 | 52 | BOARD_HAVE_BLUETOOTH := true 53 | 54 | BOARD_AVOID_DRAW_TEXTURE_EXTENSION := true 55 | 56 | BOARD_VENDOR_USE_AKMD := akm8973 57 | 58 | BOARD_VENDOR_QCOM_AMSS_VERSION := 1355 59 | 60 | # Change for Gallery 3D or not 61 | BOARD_HAS_LIMITED_EGL := true 62 | 63 | TARGET_HARDWARE_3D := false 64 | 65 | # OpenGL drivers config file path 66 | BOARD_EGL_CFG := device/htc/click/custom/egl.cfg 67 | 68 | # No authoring clock for OpenCore 69 | # BOARD_NO_PV_AUTHORING_CLOCK := true 70 | 71 | BOARD_HAVE_FM_RADIO := true 72 | BOARD_GLOBAL_CFLAGS += -DHAVE_FM_RADIO 73 | 74 | BOARD_USES_QCOM_HARDWARE := true 75 | BOARD_USES_QCOM_GPS := true 76 | BOARD_USES_QCOM_LIBS := true 77 | BOARD_USES_GPSSHIM := true 78 | BOARD_GPS_LIBRARIES := libgps librpc 79 | 80 | BOARD_USE_NEW_LIBRIL_HTC := true 81 | 82 | TARGET_LIBAGL_USE_GRALLOC_COPYBITS := true 83 | 84 | TARGET_ELECTRONBEAM_FRAMES := 10 85 | 86 | # WITH_DEXPREOPT := true 87 | JS_ENGINE := v8 88 | 89 | TARGET_RELEASETOOLS_EXTENSIONS := device/htc/common 90 | 91 | # # cat /proc/mtd 92 | # dev: size erasesize name 93 | # mtd0: 000a0000 00020000 "misc" 94 | # mtd1: 00500000 00020000 "recovery" 95 | # mtd2: 00280000 00020000 "boot" 96 | # mtd3: 09600000 00020000 "system" 97 | # mtd4: 09600000 00020000 "cache" 98 | # mtd5: 0a520000 00020000 "userdata" 99 | # Changed for click 100 | BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00280000 101 | BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000 102 | BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x09600000 103 | BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x0a520000 104 | BOARD_FLASH_BLOCK_SIZE := 131072 105 | 106 | # Add LUNFILE configuration to the system 107 | # BOARD_UMS_LUNFILE := "/sys/devices/platform/usb_mass_storage/lun0/file" 108 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | # ************************************************ 48 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 49 | # ************************************************ 50 | -------------------------------------------------------------------------------- /KernelModules.mk: -------------------------------------------------------------------------------- 1 | # Kernel Modules TO BE COPIED 2 | PRODUCT_COPY_FILES += \ 3 | device/htc/click/custom/modules/wlan.ko:system/lib/modules/wlan.ko 4 | -------------------------------------------------------------------------------- /click.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | DEVICE_PACKAGE_OVERLAYS += device/htc/click/overlay 18 | 19 | # Defines for Vold to config fstab defs 20 | PRODUCT_COPY_FILES += \ 21 | device/htc/click/vold.fstab:system/etc/vold.fstab 22 | 23 | # Libs to be added to this ROM 24 | PRODUCT_PACKAGES += \ 25 | sensors.bahamas \ 26 | lights.bahamas \ 27 | copybit.bahamas \ 28 | gralloc.bahamas \ 29 | gps.bahamas \ 30 | libOmxCore \ 31 | libmm-omxcore \ 32 | libOmxVidEnc \ 33 | tiwlan.ini \ 34 | dhcpcd.conf \ 35 | wlan_loader \ 36 | dexpreopt 37 | 38 | DISABLE_DEXPREOPT := false 39 | 40 | # Add Gallery 3D / Normal 41 | PRODUCT_PACKAGES += Gallery 42 | 43 | # Boot kernel files 44 | PRODUCT_COPY_FILES += \ 45 | device/htc/click/init.bahamas.rc:root/init.bahamas.rc \ 46 | device/htc/click/ueventd.bahamas.rc:root/ueventd.bahamas.rc 47 | 48 | PRODUCT_COPY_FILES += \ 49 | frameworks/base/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \ 50 | frameworks/base/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \ 51 | frameworks/base/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml \ 52 | frameworks/base/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \ 53 | frameworks/base/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \ 54 | frameworks/base/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml 55 | 56 | # keychars and keylayout files 57 | PRODUCT_COPY_FILES += \ 58 | device/htc/click/custom/keychars/bahamas-keypad.kcm.bin:system/usr/keychars/bahamas-keypad.kcm.bin \ 59 | device/htc/click/custom/keychars/qwerty.kcm.bin:system/usr/keychars/qwerty.kcm.bin \ 60 | device/htc/click/custom/keychars/qwerty2.kcm.bin:system/usr/keychars/qwerty2.kcm.bin \ 61 | device/htc/click/custom/keylayout/bahamas-keypad.kl:system/usr/keylayout/bahamas-keypad.kl \ 62 | device/htc/click/custom/keylayout/h2w_headset.kl:system/usr/keylayout/h2w_headset.kl \ 63 | device/htc/click/custom/keylayout/qwerty.kl:system/usr/keylayout/qwerty.kl 64 | 65 | # precompiled files for /system/bin 66 | PRODUCT_COPY_FILES += \ 67 | device/htc/click/custom/calibrate_screen:system/bin/calibrate_screen \ 68 | device/htc/click/custom/klogtail:system/xbin/klogtail 69 | 70 | # media configuration xml file 71 | PRODUCT_COPY_FILES += \ 72 | device/htc/click/media_profiles.xml:/system/etc/media_profiles.xml 73 | 74 | # Kernel Targets 75 | ifeq ($(TARGET_PREBUILT_KERNEL),) 76 | LOCAL_KERNEL := device/htc/click/custom/kernel 77 | else 78 | LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL) 79 | endif 80 | 81 | PRODUCT_COPY_FILES += \ 82 | $(LOCAL_KERNEL):kernel 83 | 84 | $(call inherit-product, device/common/gps/gps_eu_supl.mk) 85 | $(call inherit-product, device/htc/common/common.mk) 86 | $(call inherit-product, build/target/product/full_base.mk) 87 | 88 | PRODUCT_NAME := htc_click 89 | PRODUCT_DEVICE := click 90 | 91 | # See comment at the top of this file. This is where the other 92 | # half of the device-specific product definition file takes care 93 | # of the aspects that require proprietary drivers that aren't 94 | # commonly available 95 | $(call inherit-product-if-exists, vendor/htc/click/click-vendor.mk) 96 | 97 | # Added all the kernel modules to be copyed 98 | $(call inherit-product-if-exists, device/htc/click/KernelModules.mk) 99 | -------------------------------------------------------------------------------- /copy-files.sh: -------------------------------------------------------------------------------- 1 | mkdir proprietary 2 | mkdir proprietary/firmware 3 | adb pull /system/app/HTCCalibrate.apk proprietary/ 4 | adb pull /system/etc/AudioPara4.csv proprietary/ 5 | adb pull /system/etc/AudioFilter.csv proprietary/ 6 | adb pull /system/etc/AudioPreProcess.csv proprietary/ 7 | adb pull /system/lib/liboemcamera.so proprietary/ 8 | adb pull /system/lib/libmmcamera.so proprietary/ 9 | adb pull /system/lib/libmm-qcamera-tgt.so proprietary/ 10 | adb pull /system/lib/libmmjpeg.so proprietary/ 11 | adb pull /system/lib/libaudioeq.so proprietary/ 12 | adb pull /system/lib/libqcamera.so proprietary/ 13 | adb pull /system/lib/libmm-adspsvc.so proprietary/ 14 | adb pull /system/lib/egl/libGLES_qcom.so proprietary/ 15 | adb pull /system/lib/libgps.so proprietary/ 16 | adb pull /system/lib/libOmxH264Dec.so proprietary/ 17 | adb pull /system/lib/libOmxMpeg4Dec.so proprietary/ 18 | adb pull /system/lib/libOmxVidEnc.so proprietary/ 19 | adb pull /system/lib/libmm-adspsvc.so proprietary/ 20 | adb pull /system/lib/libhtc_acoustic.so proprietary/ 21 | adb pull /system/lib/libhtc_ril.so proprietary/ 22 | adb pull /system/bin/akm8973 proprietary/ 23 | adb pull /system/etc/wifi/Fw1251r1c.bin proprietary/firmware/ 24 | adb pull /system/etc/firmware/brf6300.bin proprietary/firmware/ 25 | adb pull /system/etc/firmware/brf6350.bin proprietary/firmware/ -------------------------------------------------------------------------------- /custom/calibrate_screen: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | SETTINGSDB=/data/data/com.android.providers.settings/databases/settings.db 4 | if [ ! -f $SETTINGSDB ] ; 5 | then 6 | exit 7 | fi 8 | 9 | CALIBRATION=`sqlite3 $SETTINGSDB "select value from system where name='calibration_points';"` 10 | if [ ! -z $CALIBRATION ] ; 11 | then 12 | echo $CALIBRATION > /sys/class/input/input1/calibration_points 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /custom/egl.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open-Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # 17 | # One line per configuration, of the form: 18 | # 19 | # D I TAG 20 | # 21 | # D: display (0: default) 22 | # I: implementation (0: software, 1: hardware) 23 | # TAG: a unique tag 24 | # 25 | # The library name loaded by EGL is constructed as (in that order): 26 | # 27 | # /system/lib/egl/libGLES_$TAG.so 28 | # /system/lib/egl/lib{EGL|GLESv1_CM|GLESv2}_$TAG.so 29 | # 30 | 31 | 32 | 0 0 android 33 | 0 0 qcom 34 | -------------------------------------------------------------------------------- /custom/kernel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/kernel -------------------------------------------------------------------------------- /custom/keychars/bahamas-keypad.kcm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/keychars/bahamas-keypad.kcm.bin -------------------------------------------------------------------------------- /custom/keychars/qwerty.kcm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/keychars/qwerty.kcm.bin -------------------------------------------------------------------------------- /custom/keychars/qwerty2.kcm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/keychars/qwerty2.kcm.bin -------------------------------------------------------------------------------- /custom/keylayout/bahamas-keypad.kl: -------------------------------------------------------------------------------- 1 | key 107 ENDCALL WAKE_DROPPED 2 | key 158 BACK 3 | key 139 MENU WAKE_DROPPED 4 | key 231 CALL 5 | key 102 HOME 6 | key 217 SEARCH 7 | 8 | key 105 DPAD_LEFT 9 | key 106 DPAD_RIGHT 10 | key 108 DPAD_DOWN 11 | key 103 DPAD_UP 12 | key 232 DPAD_CENTER 13 | 14 | key 115 VOLUME_UP WAKE 15 | key 114 VOLUME_DOWN WAKE 16 | 17 | ##### useless ##### 18 | # key 399 GRAVE 19 | # key 2 1 20 | # key 3 2 21 | # key 4 3 22 | # key 5 4 23 | # key 6 5 24 | # key 7 6 25 | # key 8 7 26 | # key 9 8 27 | # key 10 9 28 | # key 11 0 29 | # key 230 SOFT_RIGHT WAKE 30 | # key 60 SOFT_RIGHT WAKE 31 | # key 62 ENDCALL WAKE_DROPPED 32 | # key 229 MENU WAKE_DROPPED 33 | # key 59 MENU WAKE_DROPPED 34 | # key 228 POUND 35 | # key 227 STAR 36 | # key 61 CALL WAKE_DROPPED 37 | # key 116 POWER WAKE 38 | # key 211 FOCUS 39 | # key 212 CAMERA 40 | # 41 | # key 16 Q 42 | # key 17 W 43 | # key 18 E 44 | # key 19 R 45 | # key 20 T 46 | # key 21 Y 47 | # key 22 U 48 | # key 23 I 49 | # key 24 O 50 | # key 25 P 51 | # key 26 LEFT_BRACKET 52 | # key 27 RIGHT_BRACKET 53 | # key 43 BACKSLASH 54 | # 55 | # key 30 A 56 | # key 31 S 57 | # key 32 D 58 | # key 33 F 59 | # key 34 G 60 | # key 35 H 61 | # key 36 J 62 | # key 37 K 63 | # key 38 L 64 | # key 39 SEMICOLON 65 | # key 40 APOSTROPHE 66 | # key 14 DEL 67 | # 68 | # key 44 Z 69 | # key 45 X 70 | # key 46 C 71 | # key 47 V 72 | # key 48 B 73 | # key 49 N 74 | # key 50 M 75 | # key 51 COMMA 76 | # key 52 PERIOD 77 | # key 53 SLASH 78 | # key 28 ENTER 79 | # 80 | # key 56 ALT_LEFT 81 | # key 42 SHIFT_LEFT 82 | # key 15 TAB 83 | # key 57 SPACE 84 | # key 150 EXPLORER 85 | # key 155 ENVELOPE 86 | # 87 | # key 12 MINUS 88 | # key 13 EQUALS 89 | # key 215 AT 90 | -------------------------------------------------------------------------------- /custom/keylayout/h2w_headset.kl: -------------------------------------------------------------------------------- 1 | key 107 ENDCALL WAKE_DROPPED 2 | key 113 MUTE WAKE 3 | key 114 VOLUME_DOWN WAKE 4 | key 115 VOLUME_UP WAKE 5 | key 163 MEDIA_NEXT WAKE 6 | key 164 MEDIA_PLAY_PAUSE WAKE 7 | key 165 MEDIA_PREVIOUS WAKE 8 | key 226 HEADSETHOOK WAKE 9 | key 231 CALL WAKE_DROPPED 10 | -------------------------------------------------------------------------------- /custom/keylayout/qwerty.kl: -------------------------------------------------------------------------------- 1 | key 399 GRAVE 2 | key 2 1 3 | key 3 2 4 | key 4 3 5 | key 5 4 6 | key 6 5 7 | key 7 6 8 | key 8 7 9 | key 9 8 10 | key 10 9 11 | key 11 0 12 | key 158 BACK WAKE_DROPPED 13 | key 230 SOFT_RIGHT WAKE 14 | key 60 SOFT_RIGHT WAKE 15 | key 107 ENDCALL WAKE_DROPPED 16 | key 62 ENDCALL WAKE_DROPPED 17 | key 229 MENU WAKE_DROPPED 18 | key 139 MENU WAKE_DROPPED 19 | key 59 MENU WAKE_DROPPED 20 | key 127 SEARCH WAKE_DROPPED 21 | key 217 SEARCH WAKE_DROPPED 22 | key 228 POUND 23 | key 227 STAR 24 | key 231 CALL WAKE_DROPPED 25 | key 61 CALL WAKE_DROPPED 26 | key 232 DPAD_CENTER WAKE_DROPPED 27 | key 108 DPAD_DOWN WAKE_DROPPED 28 | key 103 DPAD_UP WAKE_DROPPED 29 | key 102 HOME WAKE 30 | key 105 DPAD_LEFT WAKE_DROPPED 31 | key 106 DPAD_RIGHT WAKE_DROPPED 32 | key 115 VOLUME_UP 33 | key 114 VOLUME_DOWN 34 | key 116 POWER WAKE 35 | key 212 CAMERA 36 | 37 | key 16 Q 38 | key 17 W 39 | key 18 E 40 | key 19 R 41 | key 20 T 42 | key 21 Y 43 | key 22 U 44 | key 23 I 45 | key 24 O 46 | key 25 P 47 | key 26 LEFT_BRACKET 48 | key 27 RIGHT_BRACKET 49 | key 43 BACKSLASH 50 | 51 | key 30 A 52 | key 31 S 53 | key 32 D 54 | key 33 F 55 | key 34 G 56 | key 35 H 57 | key 36 J 58 | key 37 K 59 | key 38 L 60 | key 39 SEMICOLON 61 | key 40 APOSTROPHE 62 | key 14 DEL 63 | 64 | key 44 Z 65 | key 45 X 66 | key 46 C 67 | key 47 V 68 | key 48 B 69 | key 49 N 70 | key 50 M 71 | key 51 COMMA 72 | key 52 PERIOD 73 | key 53 SLASH 74 | key 28 ENTER 75 | 76 | key 56 ALT_LEFT 77 | key 100 ALT_RIGHT 78 | key 42 SHIFT_LEFT 79 | key 54 SHIFT_RIGHT 80 | key 15 TAB 81 | key 57 SPACE 82 | key 150 EXPLORER 83 | key 155 ENVELOPE 84 | 85 | key 12 MINUS 86 | key 13 EQUALS 87 | key 215 AT 88 | 89 | 90 | -------------------------------------------------------------------------------- /custom/klogtail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/klogtail -------------------------------------------------------------------------------- /custom/modules/wlan.ko: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/custom/modules/wlan.ko -------------------------------------------------------------------------------- /extract-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (C) 2010 The Android Open Source Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT 18 | 19 | DEVICE=click 20 | MANUFACTURER=htc 21 | 22 | mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary 23 | mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/firmware 24 | adb pull /system/app/HTCCalibrate.apk ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/HTCCalibrate.apk 25 | adb pull /system/etc/AudioPara4.csv ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/AudioPara4.csv 26 | adb pull /system/etc/AudioFilter.csv ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/AudioFilter.csv 27 | adb pull /system/etc/AudioPreProcess.csv ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/AudioPreProcess.csv 28 | adb pull /system/lib/libmm-qcamera-tgt.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libmm-qcamera-tgt.so 29 | adb pull /system/lib/libaudioeq.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libaudioeq.so 30 | adb pull /system/lib/libmm-adspsvc.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libmm-adspsvc.so 31 | adb pull /system/lib/libgps.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libgps.so 32 | adb pull /system/lib/libOmxH264Dec.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libOmxH264Dec.so 33 | adb pull /system/lib/libOmxMpeg4Dec.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libOmxMpeg4Dec.so 34 | adb pull /system/lib/libOmxVidEnc.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libOmxVidEnc.so 35 | adb pull /system/lib/libmm-adspsvc.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libmm-adspsvc.so 36 | adb pull /system/lib/libhtc_acoustic.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libhtc_acoustic.so 37 | adb pull /system/lib/libhtc_ril.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libhtc_ril.so 38 | adb pull /system/etc/wifi/Fw1251r1c.bin ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/firmware/Fw1251r1c.bin 39 | adb pull /system/etc/firmware/brf6300.bin ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/firmware/brf6300.bin 40 | adb pull /system/etc/firmware/brf6350.bin ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/firmware/brf6350.bin 41 | adb pull /system/bin/akm8973 ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/akm8973 42 | 43 | (cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/device-vendor-blobs.mk 44 | # Copyright (C) 2010 The Android Open Source Project 45 | # 46 | # Licensed under the Apache License, Version 2.0 (the "License"); 47 | # you may not use this file except in compliance with the License. 48 | # You may obtain a copy of the License at 49 | # 50 | # http://www.apache.org/licenses/LICENSE-2.0 51 | # 52 | # Unless required by applicable law or agreed to in writing, software 53 | # distributed under the License is distributed on an "AS IS" BASIS, 54 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 55 | # See the License for the specific language governing permissions and 56 | # limitations under the License. 57 | 58 | # This file is generated by device/__MANUFACTURER__/__DEVICE__/extract-files.sh - DO NOT EDIT 59 | 60 | # Prebuilt libraries that are needed to build open-source libraries 61 | PRODUCT_COPY_FILES += \\ 62 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libgps.so:obj/lib/libgps.so 63 | 64 | # proprietary firmware files 65 | PRODUCT_COPY_FILES += \\ 66 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/firmware/Fw1251r1c.bin:system/etc/wifi/Fw1251r1c.bin \\ 67 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/firmware/brf6300.bin:system/etc/firmware/brf6300.bin \\ 68 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/firmware/brf6350.bin:system/etc/firmware/brf6350.bin 69 | 70 | # All the blobs necessary for click 71 | PRODUCT_COPY_FILES += \\ 72 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/HTCCalibrate.apk:system/app/HTCCalibrate.apk \\ 73 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/AudioPara4.csv:system/etc/AudioPara4.csv \\ 74 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/AudioFilter.csv:system/etc/AudioFilter.csv \\ 75 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/AudioPreProcess.csv:system/etc/AudioPreProcess.csv \\ 76 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libmm-qcamera-tgt.so:system/lib/libmm-qcamera-tgt.so \\ 77 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libaudioeq.so:system/lib/libaudioeq.so \\ 78 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libmm-adspsvc.so:system/lib/libmm-adspsvc.so \\ 79 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libgps.so:system/lib/libgps.so \\ 80 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libOmxH264Dec.so:system/lib/libOmxH264Dec.so \\ 81 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libOmxMpeg4Dec.so:system/lib/libOmxMpeg4Dec.so \\ 82 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libOmxVidEnc.so:system/lib/libOmxVidEnc.so \\ 83 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libmm-adspsvc.so:system/lib/libmm-adspsvc.so \\ 84 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libhtc_acoustic.so:system/lib/libhtc_acoustic.so \\ 85 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/libhtc_ril.so:system/lib/libhtc_ril.so \\ 86 | vendor/__MANUFACTURER__/__DEVICE__/proprietary/akm8973:system/bin/akm8973 87 | EOF 88 | 89 | ./setup-makefiles.sh 90 | -------------------------------------------------------------------------------- /init.bahamas.rc: -------------------------------------------------------------------------------- 1 | on boot 2 | # unmap left alt to avoid console switch 3 | setkey 0x0 0x38 0x0 4 | # device reset SEND+MENU+END 5 | setkey 0x0 0xe7 0x706 6 | setkey 0x0 0x8b 0x707 7 | 8 | setkey 0x40 0xe7 0x706 9 | setkey 0x40 0x8b 0x707 10 | 11 | setkey 0x80 0xe7 0x706 12 | setkey 0x80 0x8b 0x707 13 | 14 | setkey 0xc0 0xe7 0x706 15 | setkey 0xc0 0x8b 0x707 16 | setkey 0xc0 0x6b 0x20c 17 | 18 | mkdir /data/misc/wifi 0770 wifi wifi 19 | mkdir /data/misc/wifi/sockets 0770 wifi wifi 20 | mkdir /data/misc/dhcp 0770 dhcp dhcp 21 | chown dhcp dhcp /data/misc/dhcp 22 | 23 | # framebuffer permission for copybit 24 | chmod 0666 /dev/graphics/fb0 25 | 26 | chown radio system /sys/module/gpio_event/parameters/phone_call_status 27 | chmod 0664 /sys/module/gpio_event/parameters/phone_call_status 28 | 29 | # write screen calibration 30 | write /sys/class/input/input1/calibration_points 837,864,166,859,507,503,844,142,167,142 31 | 32 | # bluetooth power up/down interface 33 | chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type 34 | chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state 35 | chmod 0660 /sys/class/rfkill/rfkill0/state 36 | 37 | chown radio radio /sys/class/htc_ecompass/ecompass/PhoneOnOffFlag 38 | 39 | # Permissions for Liblights. 40 | chown system system /sys/class/leds/green/brightness 41 | chown system system /sys/class/leds/green/blink 42 | chown system system /sys/class/leds/amber/brightness 43 | chown system system /sys/class/leds/amber/blink 44 | chown system system /sys/class/leds/button-backlight/brightness 45 | chown system system /sys/class/leds/lcd-backlight/brightness 46 | 47 | # CPU_Scaling Governor make permissions 48 | chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 49 | 50 | # Set idle_sleep_mode permissions to radio 51 | chown radio radio /sys/module/pm/parameters/idle_sleep_mode 52 | 53 | # mount tmp cache system to speed up photo taking 54 | mkdir /cache/tmp 0666 system system 55 | mount tmpfs tmpfs /cache/tmp 56 | 57 | # revise fb0 permission for copybit 58 | chmod 0666 /dev/graphics/fb0 59 | 60 | # cpufreq configurations 61 | write /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate 50000 62 | write /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold 90 63 | 64 | # performance tweaks for flash 65 | write /sys/block/mtdblock3/bdi/read_ahead_kb 4 66 | write /sys/block/mtdblock4/bdi/read_ahead_kb 4 67 | write /sys/block/mtdblock5/bdi/read_ahead_kb 4 68 | 69 | # increase read throughput from sd card 70 | write /sys/block/mmcblk0/bdi/read_ahead_kb 1024 71 | 72 | # enable low memory killer to check file pages 73 | write /sys/module/lowmemorykiller/parameters/minfree 3584,4096,8192,10240,11264,12288 74 | write /sys/module/lowmemorykiller/parameters/minfile 0,0,0,5120,5632,6144 75 | write /sys/module/lowmemorykiller/parameters/check_filepages 1 76 | 77 | write /proc/sys/kernel/sched_latency_ns 5000000 78 | write /proc/sys/kernel/sched_wakeup_granularity_ns 100000 79 | write /proc/sys/kernel/sched_min_granularity_ns 100000 80 | 81 | # Assign TCP buffer thresholds to be ceiling value of technology maximums 82 | # Increased technology maximums should be reflected here. 83 | write /proc/sys/net/core/rmem_max 262144 84 | write /proc/sys/net/core/wmem_max 262144 85 | 86 | setrlimit 8 268435456 268435456 87 | 88 | # compass/accelerometer daemon 89 | service akmd /system/bin/akmd 90 | user compass 91 | group compass misc input 92 | 93 | service calibrate_screen /system/bin/calibrate_screen 94 | user root 95 | group root 96 | oneshot 97 | 98 | service wlan_loader /system/bin/wlan_loader \ 99 | -f /system/etc/wifi/Fw1251r1c.bin -e /proc/calibration \ 100 | -i /system/etc/wifi/tiwlan.ini 101 | disabled 102 | oneshot 103 | 104 | service wpa_supplicant /system/bin/wpa_supplicant \ 105 | -Dtiwlan0 -itiwlan0 -c/data/misc/wifi/wpa_supplicant.conf -q 106 | # we will start as root and wpa_supplicant will switch to user wifi 107 | # after setting up the capabilities required for WEXT 108 | # user wifi 109 | # group wifi inet keystore 110 | socket wpa_tiwlan0 dgram 660 wifi wifi 111 | disabled 112 | oneshot 113 | 114 | service dhcpcd_tiwlan0 /system/bin/dhcpcd -ABKL 115 | disabled 116 | oneshot 117 | 118 | service iprenew_tiwlan0 /system/bin/dhcpcd -n 119 | disabled 120 | oneshot 121 | 122 | service hciattach /system/bin/hciattach \ 123 | -n -s 115200 /dev/ttyHS0 texasalt 4000000 flow 124 | user bluetooth 125 | group bluetooth net_bt_admin 126 | disabled 127 | 128 | # bugreport is triggered by the KEY_BACK and KEY_MENU keycodes 129 | service bugreport /system/bin/dumpstate -d -v -o /sdcard/bugreports/bugreport 130 | disabled 131 | oneshot 132 | keycodes 158 139 133 | -------------------------------------------------------------------------------- /libcamera/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),bahamas) 2 | BUILD_LIBCAMERA:= true 3 | ifeq ($(BUILD_LIBCAMERA),true) 4 | 5 | # When zero we link against libmmcamera; when 1, we dlopen libmmcamera. 6 | DLOPEN_LIBMMCAMERA:=1 7 | 8 | ifneq ($(BUILD_TINY_ANDROID),true) 9 | 10 | LOCAL_PATH:= $(call my-dir) 11 | 12 | include $(CLEAR_VARS) 13 | 14 | LOCAL_MODULE_TAGS:=optional 15 | 16 | LOCAL_SRC_FILES:= QualcommCameraHardware.cpp exifwriter.c jdatadst.cpp jpegConvert.cpp 17 | 18 | LOCAL_CFLAGS:= -DDLOPEN_LIBMMCAMERA=$(DLOPEN_LIBMMCAMERA) 19 | 20 | LOCAL_C_INCLUDES+= \ 21 | vendor/qcom/proprietary/mm-camera/common \ 22 | vendor/qcom/proprietary/mm-camera/apps/appslib \ 23 | external/jhead \ 24 | external/jpeg \ 25 | vendor/qcom/proprietary/mm-camera/jpeg/inc 26 | 27 | LOCAL_SHARED_LIBRARIES:= libbinder libutils libcamera_client liblog libjpeg 28 | 29 | ifneq ($(DLOPEN_LIBMMCAMERA),1) 30 | LOCAL_SHARED_LIBRARIES+= libmmcamera libmm-qcamera-tgt 31 | else 32 | LOCAL_SHARED_LIBRARIES+= libdl libexif 33 | endif 34 | 35 | LOCAL_MODULE:= libcamera 36 | include $(BUILD_SHARED_LIBRARY) 37 | 38 | endif # BUILD_TINY_ANDROID 39 | endif # BUILD_LIBCAMERA 40 | endif # BOARD_USES_OLD_CAMERA_HACK 41 | -------------------------------------------------------------------------------- /libcamera/exifwriter.c: -------------------------------------------------------------------------------- 1 | #include "exifwriter.h" 2 | 3 | #include "jhead.h" 4 | #define LOG_TAG "ExifWriterCamera" 5 | // #define LOG_NDEBUG 0 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define TAG_ORIENTATION 0x0112 18 | #define TAG_MAKE 0x010F 19 | #define TAG_MODEL 0x0110 20 | #define TAG_IMAGE_WIDTH 0x0100 21 | #define TAG_IMAGE_LENGTH 0x0101 22 | #define TAG_EXIF_VERSION 0x9000 23 | #define EXIF_TOTAL_DATA 2 24 | 25 | 26 | float *float2degminsec( float deg ) 27 | { 28 | float *res = malloc( sizeof(float)*3 ); 29 | res[0] = floorf( deg ); 30 | float min = ( deg - res[0] ) * 60.; 31 | res[1] = floorf( min ); 32 | res[2] = ( min - res[1] ) * 60.; 33 | return res; 34 | } 35 | 36 | 37 | // 38 | // original source from 39 | // http://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions 40 | // 41 | char * float2rationnal( float src ) 42 | { 43 | long m[2][2]; 44 | float x, startx; 45 | long maxden = 1000; 46 | long ai; 47 | 48 | startx = x = src; 49 | 50 | LOGV("float2rationnal: Convertir %f", src); 51 | 52 | /* initialize matrix */ 53 | m[0][0] = m[1][1] = 1; 54 | m[0][1] = m[1][0] = 0; 55 | 56 | /* loop finding terms until denom gets too big */ 57 | while (m[1][0] * ( ai = (long)x ) + m[1][1] <= maxden) { 58 | long t; 59 | t = m[0][0] * ai + m[0][1]; 60 | m[0][1] = m[0][0]; 61 | m[0][0] = t; 62 | t = m[1][0] * ai + m[1][1]; 63 | m[1][1] = m[1][0]; 64 | m[1][0] = t; 65 | if(x==(float)ai) break; // AF: division by zero 66 | x = 1/(x - (float) ai); 67 | if(x>(float)0x7FFFFFFF) break; // AF: representation failure 68 | } 69 | 70 | 71 | /* now remaining x is between 0 and 1/ai */ 72 | /* approx as either 0 or 1/m where m is max that will fit in maxden */ 73 | /* first try zero */ 74 | 75 | /* now try other possibility */ 76 | ai = (maxden - m[1][1]) / m[1][0]; 77 | m[0][0] = m[0][0] * ai + m[0][1]; 78 | m[1][0] = m[1][0] * ai + m[1][1]; 79 | 80 | char *res = (char *)malloc( 256 * sizeof(char) ); 81 | 82 | snprintf( res, 256, "%ld/%ld", m[0][0], m[1][0] ); 83 | return res; 84 | } 85 | 86 | char * coord2degminsec( float src ) 87 | { 88 | char *res = (char *)malloc( 256 * sizeof(char) ); 89 | LOGV("coord2degminsec: Convertir %f", src); 90 | float *dms = float2degminsec( fabs(src) ); 91 | LOGV("coord2degminsec: paso1 (float) %f %f %f", dms[0], dms[1], dms[2]); 92 | strcpy( res, float2rationnal(dms[0]) ); 93 | strcat( res , "," ); 94 | strcat( res , float2rationnal(dms[1]) ); 95 | strcat( res , "," ); 96 | strcat( res , float2rationnal(dms[2]) ); 97 | LOGV("coord2degminsec: Convertido en %s", res); 98 | free( dms ); 99 | return res; 100 | } 101 | 102 | static void dump_to_file(const char *fname, 103 | uint8_t *buf, uint32_t size) 104 | { 105 | int nw, cnt = 0; 106 | uint32_t written = 0; 107 | 108 | LOGV("opening file [%s]\n", fname); 109 | int fd = open(fname, O_RDWR | O_CREAT); 110 | if (fd < 0) { 111 | LOGE("failed to create file [%s]: %s", fname, strerror(errno)); 112 | return; 113 | } 114 | 115 | LOGV("writing %d bytes to file [%s]\n", size, fname); 116 | while (written < size) { 117 | nw = write(fd, 118 | buf + written, 119 | size - written); 120 | if (nw < 0) { 121 | LOGE("failed to write to file [%s]: %s", 122 | fname, strerror(errno)); 123 | break; 124 | } 125 | written += nw; 126 | cnt++; 127 | } 128 | LOGV("done writing %d bytes to file [%s] in %d passes\n", 129 | size, fname, cnt); 130 | close(fd); 131 | } 132 | 133 | void writeExif( void *origData, void *destData , int origSize , uint32_t *resultSize, int orientation,camera_position_type *pt ) { 134 | const char *filename = "/cache/tmp/temp.jpg"; 135 | 136 | dump_to_file( filename, (uint8_t *)origData, origSize ); 137 | LOGV("WRITE EXIF Filename %s", filename); 138 | chmod( filename, S_IRWXU ); 139 | ResetJpgfile(); 140 | 141 | 142 | memset(&ImageInfo, 0, sizeof(ImageInfo)); 143 | ImageInfo.FlashUsed = -1; 144 | ImageInfo.MeteringMode = -1; 145 | ImageInfo.Whitebalance = -1; 146 | 147 | int gpsTag = 0; 148 | if( pt != NULL ) { 149 | LOGV("EXIF ADD GPS DATA ........"); 150 | gpsTag = 6; 151 | } else{ 152 | LOGV("EXIF NO GPS ........"); 153 | } 154 | 155 | 156 | ExifElement_t *t = (ExifElement_t *)malloc( sizeof(ExifElement_t)*(EXIF_TOTAL_DATA+gpsTag) ); 157 | 158 | ExifElement_t *it = t; 159 | // Store file date/time. 160 | (*it).Tag = TAG_ORIENTATION; 161 | (*it).Format = FMT_USHORT; 162 | (*it).DataLength = 1; 163 | unsigned short v; 164 | LOGV("EXIF Orientation %d º", orientation); 165 | if( orientation == 90 ) { 166 | (*it).Value = "6\0"; 167 | } else if( orientation == 180 ) { 168 | (*it).Value = "3\0"; 169 | } else { 170 | (*it).Value = "1\0"; 171 | } 172 | (*it).GpsTag = FALSE; 173 | 174 | it++; 175 | (*it).Tag = TAG_MODEL; 176 | (*it).Format = FMT_STRING; 177 | (*it).Value = "Tattoo with CyanogenMOD\0"; 178 | (*it).DataLength = 24; 179 | (*it).GpsTag = FALSE; 180 | 181 | if( pt != NULL ) { 182 | LOGV("pt->latitude == %f", pt->latitude ); 183 | LOGV("pt->longitude == %f", pt->longitude ); 184 | LOGV("pt->altitude == %d", pt->altitude ); 185 | 186 | it++; 187 | (*it).Tag = 0x01; 188 | (*it).Format = FMT_STRING; 189 | if( pt->latitude > 0 ) { 190 | (*it).Value = "N\0"; 191 | } else { 192 | (*it).Value = "S\0"; 193 | } 194 | (*it).DataLength = 2; 195 | (*it).GpsTag = TRUE; 196 | 197 | it++; 198 | (*it).Value = coord2degminsec( pt->latitude ); 199 | LOGV("writeExif: La latitud queda en: %s", (*it).Value); 200 | 201 | (*it).Tag = 0x02; 202 | (*it).Format = FMT_URATIONAL; 203 | (*it).DataLength = 3; 204 | (*it).GpsTag = TRUE; 205 | 206 | it++; 207 | (*it).Tag = 0x03; 208 | (*it).Format = FMT_STRING; 209 | if( (*pt).longitude > 0 ) { 210 | (*it).Value = "E\0"; 211 | } else { 212 | (*it).Value = "W\0"; 213 | } 214 | (*it).DataLength = 2; 215 | (*it).GpsTag = TRUE; 216 | 217 | it++; 218 | (*it).Value = coord2degminsec( pt->longitude ); 219 | LOGV("writeExif: La longitud queda en: %s", (*it).Value); 220 | 221 | (*it).Tag = 0x04; 222 | (*it).Format = FMT_URATIONAL; 223 | (*it).DataLength = 3; 224 | (*it).GpsTag = TRUE; 225 | 226 | it++; 227 | (*it).Tag = 0x05; 228 | (*it).Format = FMT_USHORT; 229 | if( (*pt).altitude > 0 ) { 230 | (*it).Value = "0\0"; 231 | } else { 232 | (*it).Value = "1\0"; 233 | } 234 | (*it).DataLength = 1; 235 | (*it).GpsTag = TRUE; 236 | 237 | it++; 238 | (*it).Value = float2rationnal( fabs( pt->altitude ) ); 239 | LOGV("writeExif: La altitud queda en: %s", (*it).Value); 240 | 241 | (*it).Tag = 0x06; 242 | (*it).Format = FMT_SRATIONAL; 243 | (*it).DataLength = 1; 244 | (*it).GpsTag = TRUE; 245 | } 246 | 247 | { 248 | struct stat st; 249 | if (stat(filename, &st) >= 0) { 250 | ImageInfo.FileDateTime = st.st_mtime; 251 | ImageInfo.FileSize = st.st_size; 252 | } 253 | } 254 | strncpy(ImageInfo.FileName, filename, PATH_MAX); 255 | LOGV("Image EXIF Filename %s", filename); 256 | 257 | ReadMode_t ReadMode; 258 | ReadMode = READ_METADATA; 259 | ReadMode |= READ_IMAGE; 260 | int res = ReadJpegFile(filename, (ReadMode_t)ReadMode ); 261 | LOGV("READ EXIF Filename %s", filename); 262 | 263 | create_EXIF( t, EXIF_TOTAL_DATA, gpsTag); 264 | 265 | WriteJpegFile(filename); 266 | chmod( filename, S_IRWXU ); 267 | DiscardData(); 268 | 269 | FILE *src; 270 | src = fopen( filename, "r"); 271 | 272 | fseek( src, 0L, SEEK_END ); 273 | (*resultSize) = ftell(src); 274 | fseek( src, 0L, SEEK_SET ); 275 | 276 | int read = fread( destData, 1, (*resultSize), src ); 277 | 278 | free( t ); 279 | 280 | unlink( filename ); 281 | } 282 | -------------------------------------------------------------------------------- /libcamera/exifwriter.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDROID_HARDWARE_EXIFWRITER_H 2 | #define ANDROID_HARDWARE_EXIFWRITER_H 3 | 4 | #include 5 | 6 | typedef struct 7 | { 8 | uint32_t timestamp; /* seconds since 1/6/1980 */ 9 | double latitude; /* degrees, WGS ellipsoid */ 10 | double longitude; /* degrees */ 11 | int16_t altitude; /* meters */ 12 | } camera_position_type; 13 | 14 | 15 | void writeExif( void *origData, void *destData , int origSize , uint32_t *resultSize, int orientation, camera_position_type *pt) ; 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /libcamera/jdatadst.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * jdatadst.c 3 | * 4 | * Copyright (C) 1994-1996, Thomas G. Lane. 5 | * Modified 2009 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains compression data destination routines for the case of 10 | * emitting JPEG data to memory. 11 | * While these routines are sufficient for most applications, 12 | * some will want to use a different destination manager. 13 | * IMPORTANT: we assume that fwrite() will correctly transcribe an array of 14 | * unsigned chars into 8-bit-wide elements on external storage. If char is wider 15 | * than 8 bits on your machine, you may need to do some tweaking. 16 | */ 17 | 18 | /* this is not a core library module, so it doesn't define JPEG_INTERNALS */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | //#include 25 | #include 26 | #include "jdatadst.h" 27 | 28 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 29 | extern void * malloc JPP((size_t size)); 30 | extern void free JPP((void *ptr)); 31 | #endif 32 | 33 | 34 | /* Expanded data destination object for stdio output */ 35 | 36 | #define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ 37 | 38 | 39 | /* Expanded data destination object for memory output */ 40 | 41 | typedef struct { 42 | struct jpeg_destination_mgr pub; /* public fields */ 43 | 44 | unsigned char ** outbuffer; /* target buffer */ 45 | unsigned long * outsize; 46 | unsigned char * newbuffer; /* newly allocated buffer */ 47 | unsigned char * buffer; /* start of buffer */ 48 | size_t bufsize; 49 | } my_mem_destination_mgr; 50 | 51 | typedef my_mem_destination_mgr * my_mem_dest_ptr; 52 | 53 | 54 | /* 55 | * Initialize destination --- called by jpeg_start_compress 56 | * before any data is actually written. 57 | */ 58 | 59 | METHODDEF(void) 60 | init_mem_destination (j_compress_ptr cinfo) 61 | { 62 | /* no work necessary here */ 63 | } 64 | 65 | 66 | /* 67 | * Empty the output buffer --- called whenever buffer fills up. 68 | * 69 | * In typical applications, this should write the entire output buffer 70 | * (ignoring the current state of next_output_byte & free_in_buffer), 71 | * reset the pointer & count to the start of the buffer, and return TRUE 72 | * indicating that the buffer has been dumped. 73 | * 74 | * In applications that need to be able to suspend compression due to output 75 | * overrun, a FALSE return indicates that the buffer cannot be emptied now. 76 | * In this situation, the compressor will return to its caller (possibly with 77 | * an indication that it has not accepted all the supplied scanlines). The 78 | * application should resume compression after it has made more room in the 79 | * output buffer. Note that there are substantial restrictions on the use of 80 | * suspension --- see the documentation. 81 | * 82 | * When suspending, the compressor will back up to a convenient restart point 83 | * (typically the start of the current MCU). next_output_byte & free_in_buffer 84 | * indicate where the restart point will be if the current call returns FALSE. 85 | * Data beyond this point will be regenerated after resumption, so do not 86 | * write it out when emptying the buffer externally. 87 | */ 88 | 89 | METHODDEF(boolean) 90 | empty_mem_output_buffer (j_compress_ptr cinfo) 91 | { 92 | size_t nextsize; 93 | unsigned char * nextbuffer; 94 | my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; 95 | 96 | /* Try to allocate new buffer with double size */ 97 | nextsize = dest->bufsize * 2; 98 | nextbuffer = (unsigned char *)malloc(nextsize); 99 | 100 | if (nextbuffer == NULL) 101 | ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); 102 | 103 | MEMCOPY(nextbuffer, dest->buffer, dest->bufsize); 104 | 105 | if (dest->newbuffer != NULL) 106 | free(dest->newbuffer); 107 | 108 | dest->newbuffer = nextbuffer; 109 | 110 | dest->pub.next_output_byte = nextbuffer + dest->bufsize; 111 | dest->pub.free_in_buffer = dest->bufsize; 112 | 113 | dest->buffer = nextbuffer; 114 | dest->bufsize = nextsize; 115 | 116 | return TRUE; 117 | } 118 | 119 | 120 | /* 121 | * Terminate destination --- called by jpeg_finish_compress 122 | * after all data has been written. Usually needs to flush buffer. 123 | * 124 | * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding 125 | * application must deal with any cleanup that should happen even 126 | * for error exit. 127 | */ 128 | 129 | METHODDEF(void) 130 | term_mem_destination (j_compress_ptr cinfo) 131 | { 132 | my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; 133 | 134 | *dest->outbuffer = dest->buffer; 135 | *dest->outsize = dest->bufsize - dest->pub.free_in_buffer; 136 | } 137 | 138 | 139 | /* 140 | * Prepare for output to a memory buffer. 141 | * The caller may supply an own initial buffer with appropriate size. 142 | * Otherwise, or when the actual data output exceeds the given size, 143 | * the library adapts the buffer size as necessary. 144 | * The standard library functions malloc/free are used for allocating 145 | * larger memory, so the buffer is available to the application after 146 | * finishing compression, and then the application is responsible for 147 | * freeing the requested memory. 148 | */ 149 | 150 | GLOBAL(void) 151 | jpeg_mem_dest (j_compress_ptr cinfo, 152 | unsigned char ** outbuffer, unsigned long * outsize) 153 | { 154 | my_mem_dest_ptr dest; 155 | 156 | if (outbuffer == NULL || outsize == NULL) /* sanity check */ 157 | ERREXIT(cinfo, JERR_BUFFER_SIZE); 158 | 159 | /* The destination object is made permanent so that multiple JPEG images 160 | * can be written to the same buffer without re-executing jpeg_mem_dest. 161 | */ 162 | if (cinfo->dest == NULL) { /* first time for this JPEG object? */ 163 | cinfo->dest = (struct jpeg_destination_mgr *) 164 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 165 | SIZEOF(my_mem_destination_mgr)); 166 | } 167 | 168 | dest = (my_mem_dest_ptr) cinfo->dest; 169 | dest->pub.init_destination = init_mem_destination; 170 | dest->pub.empty_output_buffer = empty_mem_output_buffer; 171 | dest->pub.term_destination = term_mem_destination; 172 | dest->outbuffer = outbuffer; 173 | dest->outsize = outsize; 174 | dest->newbuffer = NULL; 175 | 176 | if (*outbuffer == NULL || *outsize == 0) { 177 | /* Allocate initial buffer */ 178 | dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE); 179 | if (dest->newbuffer == NULL) 180 | ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); 181 | *outsize = OUTPUT_BUF_SIZE; 182 | } 183 | 184 | dest->pub.next_output_byte = dest->buffer = *outbuffer; 185 | dest->pub.free_in_buffer = dest->bufsize = *outsize; 186 | } 187 | -------------------------------------------------------------------------------- /libcamera/jdatadst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jdatadst.h 3 | * 4 | * Copyright (C) 1991-1998, Thomas G. Lane. 5 | * Modified 2002-2010 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains routines backported from jpeglib 8 for writing 10 | * jpeg data directly to memory. 11 | */ 12 | 13 | #ifndef JDATADST_H 14 | #define JDATADST_H 15 | 16 | /* 17 | * First we include the configuration files that record how this 18 | * installation of the JPEG library is set up. jconfig.h can be 19 | * generated automatically for many systems. jmorecfg.h contains 20 | * manual configuration options that most people need not worry about. 21 | */ 22 | 23 | #ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ 24 | #include /* widely used configuration options */ 25 | #endif 26 | //#include /* seldom changed options */ 27 | #include 28 | 29 | 30 | extern "C" { 31 | 32 | /* Declarations for routines called by application. 33 | * The JPP macro hides prototype parameters from compilers that can't cope. 34 | * Note JPP requires double parentheses. 35 | */ 36 | 37 | #ifdef HAVE_PROTOTYPES 38 | #define JPP(arglist) arglist 39 | #else 40 | #define JPP(arglist) () 41 | #endif 42 | 43 | 44 | /* Data source and destination managers: memory buffers. */ 45 | EXTERN(void) jpeg_mem_dest (j_compress_ptr cinfo, 46 | unsigned char ** outbuffer, 47 | unsigned long * outsize); 48 | } // extern "C" 49 | 50 | #define SIZEOF(object) ((size_t) sizeof(object)) 51 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 52 | 53 | #endif /* JPEGLIB_H */ 54 | -------------------------------------------------------------------------------- /libcamera/jpegConvert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008, Google Inc. 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | /* 17 | ** Version: 1.0 18 | ** Coded by: Josebagar 02/2011 (linux version) 19 | ** Revised and Recoded: KalimochoAz 02/2011 (android conversions) Done for CyanogenMOD 20 | */ 21 | #include 22 | #include 23 | #include 24 | extern "C" { 25 | #include 26 | } 27 | #if JPEG_LIB_VERSION < 80 28 | // The routines defined in this file have been backported from jpeglib 8.0 29 | #include "jdatadst.h" 30 | #endif 31 | #include "jpegConvert.h" 32 | #include "raw2jpeg.h" 33 | 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | YuvToJpegEncoder* YuvToJpegEncoder::create(int* strides) { 37 | // Only ImageFormat.NV21 and ImageFormat.YUY2 are supported 38 | // for now. 39 | return new Yuv420SpToJpegEncoder(strides); 40 | } 41 | 42 | YuvToJpegEncoder::YuvToJpegEncoder(int* strides) : fStrides(strides) { 43 | } 44 | 45 | bool YuvToJpegEncoder::encode(unsigned char* dest, void* inYuv, int width, 46 | int height, int* offsets, int jpegQuality, uint32_t* mSize) { 47 | struct jpeg_compress_struct cinfo; 48 | struct jpeg_error_mgr jerr; 49 | long unsigned int image_size; 50 | 51 | // Warning, this is ONLY valid for YUV420SP (ImageFormat.NV21 in android) 52 | image_size = (width*height*1.5); 53 | 54 | // Create JPEG compression object 55 | cinfo.err = jpeg_std_error(&jerr); 56 | jpeg_create_compress(&cinfo); 57 | 58 | // Point it to the output file 59 | jpeg_mem_dest(&cinfo, &dest, &image_size); 60 | 61 | setJpegCompressStruct(&cinfo, width, height, jpegQuality); 62 | 63 | jpeg_start_compress(&cinfo, TRUE); 64 | 65 | compress(&cinfo, (uint8_t*) inYuv, offsets); 66 | 67 | jpeg_finish_compress(&cinfo); 68 | 69 | *mSize = (uint32_t) image_size; 70 | mJpegTam = (uint32_t) image_size; 71 | return true; 72 | } 73 | 74 | void YuvToJpegEncoder::setJpegCompressStruct(jpeg_compress_struct* cinfo, 75 | int width, int height, int quality) { 76 | cinfo->image_width = width; 77 | cinfo->image_height = height; 78 | cinfo->input_components = 3; 79 | cinfo->in_color_space = JCS_YCbCr; 80 | jpeg_set_defaults(cinfo); 81 | 82 | jpeg_set_quality(cinfo, quality, TRUE); 83 | jpeg_set_colorspace(cinfo, JCS_YCbCr); 84 | cinfo->raw_data_in = TRUE; 85 | cinfo->dct_method = JDCT_IFAST; 86 | configSamplingFactors(cinfo); 87 | } 88 | 89 | /////////////////////////////////////////////////////////////////// 90 | Yuv420SpToJpegEncoder::Yuv420SpToJpegEncoder(int* strides) : 91 | YuvToJpegEncoder(strides) { 92 | fNumPlanes = 2; 93 | } 94 | 95 | void Yuv420SpToJpegEncoder::compress(jpeg_compress_struct* cinfo, 96 | uint8_t* yuv, int* offsets) { 97 | JSAMPROW y[16]; 98 | JSAMPROW cb[8]; 99 | JSAMPROW cr[8]; 100 | JSAMPARRAY planes[3]; 101 | planes[0] = y; 102 | planes[1] = cb; 103 | planes[2] = cr; 104 | 105 | int width = cinfo->image_width; 106 | int height = cinfo->image_height; 107 | uint8_t* yPlanar = yuv + offsets[0]; 108 | uint8_t* vuPlanar = yuv + offsets[1]; //width * height; 109 | uint8_t* uRows = new uint8_t [8 * (width >> 1)]; 110 | uint8_t* vRows = new uint8_t [8 * (width >> 1)]; 111 | 112 | 113 | // process 16 lines of Y and 8 lines of U/V each time. 114 | while (cinfo->next_scanline < cinfo->image_height) { 115 | //deitnerleave u and v 116 | deinterleave(vuPlanar, uRows, vRows, cinfo->next_scanline, width); 117 | 118 | for (int i = 0; i < 16; i++) { 119 | // y row 120 | y[i] = yPlanar + (cinfo->next_scanline + i) * fStrides[0]; 121 | 122 | // construct u row and v row 123 | if ((i & 1) == 0) { 124 | // height and width are both halved because of downsampling 125 | int offset = (i >> 1) * (width >> 1); 126 | cb[i/2] = uRows + offset; 127 | cr[i/2] = vRows + offset; 128 | } 129 | } 130 | jpeg_write_raw_data(cinfo, planes, 16); 131 | } 132 | delete [] uRows; 133 | delete [] vRows; 134 | 135 | } 136 | 137 | void Yuv420SpToJpegEncoder::deinterleave(uint8_t* vuPlanar, uint8_t* uRows, 138 | uint8_t* vRows, int rowIndex, int width) { 139 | for (int row = 0; row < 8; ++row) { 140 | int offset = ((rowIndex >> 1) + row) * fStrides[1]; 141 | uint8_t* vu = vuPlanar + offset; 142 | for (int i = 0; i < (width >> 1); ++i) { 143 | int index = row * (width >> 1) + i; 144 | uRows[index] = vu[1]; 145 | vRows[index] = vu[0]; 146 | vu += 2; 147 | } 148 | } 149 | } 150 | 151 | void Yuv420SpToJpegEncoder::configSamplingFactors(jpeg_compress_struct* cinfo) { 152 | // cb and cr are horizontally downsampled and vertically downsampled as well. 153 | cinfo->comp_info[0].h_samp_factor = 2; 154 | cinfo->comp_info[0].v_samp_factor = 2; 155 | cinfo->comp_info[1].h_samp_factor = 1; 156 | cinfo->comp_info[1].v_samp_factor = 1; 157 | cinfo->comp_info[2].h_samp_factor = 1; 158 | cinfo->comp_info[2].v_samp_factor = 1; 159 | } 160 | 161 | /////////////////////////////////////////////////////////////////////////////// 162 | 163 | int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality, uint32_t *mSize) { 164 | int imgStrides[2], imgOffsets[2]; 165 | 166 | // Convert the RAW data to JPEG 167 | imgStrides[0] = imgStrides[1] = width; 168 | YuvToJpegEncoder* encoder = YuvToJpegEncoder::create(imgStrides); 169 | if (encoder == NULL) { 170 | return false; 171 | } 172 | 173 | // Guessed from frameworks/base/graphics/java/android/graphics/YuvImage.java 174 | // in android 175 | imgOffsets[0] = 0; 176 | imgOffsets[1] = width*height; 177 | encoder->encode(dest, src, width, height, imgOffsets, quality, mSize); 178 | 179 | delete encoder; 180 | 181 | return true; 182 | } 183 | -------------------------------------------------------------------------------- /libcamera/jpegConvert.h: -------------------------------------------------------------------------------- 1 | #ifndef YuvToJpegEncoder_DEFINED 2 | #define YuvToJpegEncoder_DEFINED 3 | 4 | extern "C" { 5 | #include "jpeglib.h" 6 | #include "jerror.h" 7 | } 8 | 9 | class YuvToJpegEncoder { 10 | public: 11 | /** Create an encoder based on the YUV format. 12 | * 13 | * @param pixelFormat The yuv pixel format as defined in ui/PixelFormat.h. 14 | * @param strides The number of row bytes in each image plane. 15 | * @return an encoder based on the pixelFormat. 16 | */ 17 | static YuvToJpegEncoder* create(int* strides); 18 | 19 | YuvToJpegEncoder(int* strides); 20 | 21 | /** Encode YUV data to jpeg, which is output to a stream. 22 | * 23 | * @param dest The jpeg output stream. 24 | * @param inYuv The input yuv data. 25 | * @param width Width of the the Yuv data in terms of pixels. 26 | * @param height Height of the Yuv data in terms of pixels. 27 | * @param offsets The offsets in each image plane with respect to inYuv. 28 | * @param jpegQuality Picture quality in [0, 100]. 29 | * @return true if successfully compressed the stream. 30 | */ 31 | bool encode(unsigned char* dest, void* inYuv, int width, 32 | int height, int* offsets, int jpegQuality, uint32_t* mSize); 33 | uint32_t mJpegTam; 34 | virtual ~YuvToJpegEncoder() {} 35 | 36 | protected: 37 | int fNumPlanes; 38 | int* fStrides; 39 | void setJpegCompressStruct(jpeg_compress_struct* cinfo, int width, 40 | int height, int quality); 41 | virtual void configSamplingFactors(jpeg_compress_struct* cinfo) = 0; 42 | virtual void compress(jpeg_compress_struct* cinfo, 43 | uint8_t* yuv, int* offsets) = 0; 44 | }; 45 | 46 | class Yuv420SpToJpegEncoder : public YuvToJpegEncoder { 47 | public: 48 | Yuv420SpToJpegEncoder(int* strides); 49 | virtual ~Yuv420SpToJpegEncoder() {} 50 | 51 | private: 52 | void configSamplingFactors(jpeg_compress_struct* cinfo); 53 | void deinterleaveYuv(uint8_t* yuv, int width, int height, 54 | uint8_t*& yPlanar, uint8_t*& uPlanar, uint8_t*& vPlanar); 55 | void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, 56 | int rowIndex, int width); 57 | void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets); 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /libcamera/raw2jpeg.h: -------------------------------------------------------------------------------- 1 | int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int quality, uint32_t *mSize); 2 | -------------------------------------------------------------------------------- /libcopybit/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH:= $(call my-dir) 17 | # HAL module implemenation, not prelinked and stored in 18 | # hw/..so 19 | 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE_TAGS := optional 22 | LOCAL_PRELINK_MODULE := false 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 24 | LOCAL_SHARED_LIBRARIES := liblog 25 | LOCAL_SRC_FILES := copybit.cpp 26 | LOCAL_MODULE := copybit.$(TARGET_BOOTLOADER_BOARD_NAME) 27 | LOCAL_C_INCLUDES += hardware/msm7k/libgralloc 28 | LOCAL_CFLAGS += -DCOPYBIT_MSM7K=1 29 | include $(BUILD_SHARED_LIBRARY) 30 | -------------------------------------------------------------------------------- /libcopybit/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/libcopybit/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libcopybit/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2008, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /libgralloc/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | # HAL module implemenation, not prelinked and stored in 19 | # hw/..so 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE_TAGS := optional 22 | LOCAL_PRELINK_MODULE := false 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 24 | LOCAL_SHARED_LIBRARIES := liblog libcutils 25 | 26 | LOCAL_SRC_FILES := \ 27 | allocator.cpp \ 28 | gralloc.cpp \ 29 | framebuffer.cpp \ 30 | mapper.cpp 31 | 32 | LOCAL_MODULE := gralloc.$(TARGET_BOOTLOADER_BOARD_NAME) 33 | LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" 34 | include $(BUILD_SHARED_LIBRARY) 35 | -------------------------------------------------------------------------------- /libgralloc/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/libgralloc/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libgralloc/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2008-2009, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /libgralloc/allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "allocator.h" 20 | 21 | 22 | // align all the memory blocks on a cache-line boundary 23 | const int SimpleBestFitAllocator::kMemoryAlign = 32; 24 | 25 | SimpleBestFitAllocator::SimpleBestFitAllocator() 26 | : mHeapSize(0) 27 | { 28 | } 29 | 30 | SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size) 31 | : mHeapSize(0) 32 | { 33 | setSize(size); 34 | } 35 | 36 | SimpleBestFitAllocator::~SimpleBestFitAllocator() 37 | { 38 | while(!mList.isEmpty()) { 39 | delete mList.remove(mList.head()); 40 | } 41 | } 42 | 43 | ssize_t SimpleBestFitAllocator::setSize(size_t size) 44 | { 45 | Locker::Autolock _l(mLock); 46 | if (mHeapSize != 0) return -EINVAL; 47 | size_t pagesize = getpagesize(); 48 | mHeapSize = ((size + pagesize-1) & ~(pagesize-1)); 49 | chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign); 50 | mList.insertHead(node); 51 | return size; 52 | } 53 | 54 | 55 | size_t SimpleBestFitAllocator::size() const 56 | { 57 | return mHeapSize; 58 | } 59 | 60 | ssize_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags) 61 | { 62 | Locker::Autolock _l(mLock); 63 | if (mHeapSize == 0) return -EINVAL; 64 | ssize_t offset = alloc(size, flags); 65 | return offset; 66 | } 67 | 68 | ssize_t SimpleBestFitAllocator::deallocate(size_t offset) 69 | { 70 | Locker::Autolock _l(mLock); 71 | if (mHeapSize == 0) return -EINVAL; 72 | chunk_t const * const freed = dealloc(offset); 73 | if (freed) { 74 | return 0; 75 | } 76 | return -ENOENT; 77 | } 78 | 79 | ssize_t SimpleBestFitAllocator::alloc(size_t size, uint32_t flags) 80 | { 81 | if (size == 0) { 82 | return 0; 83 | } 84 | size = (size + kMemoryAlign-1) / kMemoryAlign; 85 | chunk_t* free_chunk = 0; 86 | chunk_t* cur = mList.head(); 87 | 88 | size_t pagesize = getpagesize(); 89 | while (cur) { 90 | int extra = ( -cur->start & ((pagesize/kMemoryAlign)-1) ) ; 91 | 92 | // best fit 93 | if (cur->free && (cur->size >= (size+extra))) { 94 | if ((!free_chunk) || (cur->size < free_chunk->size)) { 95 | free_chunk = cur; 96 | } 97 | if (cur->size == size) { 98 | break; 99 | } 100 | } 101 | cur = cur->next; 102 | } 103 | 104 | if (free_chunk) { 105 | const size_t free_size = free_chunk->size; 106 | free_chunk->free = 0; 107 | free_chunk->size = size; 108 | if (free_size > size) { 109 | int extra = ( -free_chunk->start & ((pagesize/kMemoryAlign)-1) ) ; 110 | if (extra) { 111 | chunk_t* split = new chunk_t(free_chunk->start, extra); 112 | free_chunk->start += extra; 113 | mList.insertBefore(free_chunk, split); 114 | } 115 | 116 | LOGE_IF(((free_chunk->start*kMemoryAlign)&(pagesize-1)), 117 | "page is not aligned!!!"); 118 | 119 | const ssize_t tail_free = free_size - (size+extra); 120 | if (tail_free > 0) { 121 | chunk_t* split = new chunk_t( 122 | free_chunk->start + free_chunk->size, tail_free); 123 | mList.insertAfter(free_chunk, split); 124 | } 125 | } 126 | return (free_chunk->start)*kMemoryAlign; 127 | } 128 | return -ENOMEM; 129 | } 130 | 131 | SimpleBestFitAllocator::chunk_t* SimpleBestFitAllocator::dealloc(size_t start) 132 | { 133 | start = start / kMemoryAlign; 134 | chunk_t* cur = mList.head(); 135 | while (cur) { 136 | if (cur->start == start) { 137 | LOG_FATAL_IF(cur->free, 138 | "block at offset 0x%08lX of size 0x%08lX already freed", 139 | cur->start*kMemoryAlign, cur->size*kMemoryAlign); 140 | 141 | // merge freed blocks together 142 | chunk_t* freed = cur; 143 | cur->free = 1; 144 | do { 145 | chunk_t* const p = cur->prev; 146 | chunk_t* const n = cur->next; 147 | if (p && (p->free || !cur->size)) { 148 | freed = p; 149 | p->size += cur->size; 150 | mList.remove(cur); 151 | delete cur; 152 | } 153 | cur = n; 154 | } while (cur && cur->free); 155 | 156 | LOG_FATAL_IF(!freed->free, 157 | "freed block at offset 0x%08lX of size 0x%08lX is not free!", 158 | freed->start * kMemoryAlign, freed->size * kMemoryAlign); 159 | 160 | return freed; 161 | } 162 | cur = cur->next; 163 | } 164 | return 0; 165 | } 166 | -------------------------------------------------------------------------------- /libgralloc/allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef GRALLOC_ALLOCATOR_H_ 19 | #define GRALLOC_ALLOCATOR_H_ 20 | 21 | #include 22 | #include 23 | 24 | #include "gr.h" 25 | 26 | // ---------------------------------------------------------------------------- 27 | 28 | /* 29 | * A simple templatized doubly linked-list implementation 30 | */ 31 | 32 | template 33 | class LinkedList 34 | { 35 | NODE* mFirst; 36 | NODE* mLast; 37 | 38 | public: 39 | LinkedList() : mFirst(0), mLast(0) { } 40 | bool isEmpty() const { return mFirst == 0; } 41 | NODE const* head() const { return mFirst; } 42 | NODE* head() { return mFirst; } 43 | NODE const* tail() const { return mLast; } 44 | NODE* tail() { return mLast; } 45 | 46 | void insertAfter(NODE* node, NODE* newNode) { 47 | newNode->prev = node; 48 | newNode->next = node->next; 49 | if (node->next == 0) mLast = newNode; 50 | else node->next->prev = newNode; 51 | node->next = newNode; 52 | } 53 | 54 | void insertBefore(NODE* node, NODE* newNode) { 55 | newNode->prev = node->prev; 56 | newNode->next = node; 57 | if (node->prev == 0) mFirst = newNode; 58 | else node->prev->next = newNode; 59 | node->prev = newNode; 60 | } 61 | 62 | void insertHead(NODE* newNode) { 63 | if (mFirst == 0) { 64 | mFirst = mLast = newNode; 65 | newNode->prev = newNode->next = 0; 66 | } else { 67 | newNode->prev = 0; 68 | newNode->next = mFirst; 69 | mFirst->prev = newNode; 70 | mFirst = newNode; 71 | } 72 | } 73 | 74 | void insertTail(NODE* newNode) { 75 | if (mLast == 0) { 76 | insertHead(newNode); 77 | } else { 78 | newNode->prev = mLast; 79 | newNode->next = 0; 80 | mLast->next = newNode; 81 | mLast = newNode; 82 | } 83 | } 84 | 85 | NODE* remove(NODE* node) { 86 | if (node->prev == 0) mFirst = node->next; 87 | else node->prev->next = node->next; 88 | if (node->next == 0) mLast = node->prev; 89 | else node->next->prev = node->prev; 90 | return node; 91 | } 92 | }; 93 | 94 | class SimpleBestFitAllocator 95 | { 96 | public: 97 | 98 | SimpleBestFitAllocator(); 99 | SimpleBestFitAllocator(size_t size); 100 | ~SimpleBestFitAllocator(); 101 | 102 | ssize_t setSize(size_t size); 103 | 104 | ssize_t allocate(size_t size, uint32_t flags = 0); 105 | ssize_t deallocate(size_t offset); 106 | size_t size() const; 107 | 108 | private: 109 | struct chunk_t { 110 | chunk_t(size_t start, size_t size) 111 | : start(start), size(size), free(1), prev(0), next(0) { 112 | } 113 | size_t start; 114 | size_t size : 28; 115 | int free : 4; 116 | mutable chunk_t* prev; 117 | mutable chunk_t* next; 118 | }; 119 | 120 | ssize_t alloc(size_t size, uint32_t flags); 121 | chunk_t* dealloc(size_t start); 122 | 123 | static const int kMemoryAlign; 124 | mutable Locker mLock; 125 | LinkedList mList; 126 | size_t mHeapSize; 127 | }; 128 | 129 | #endif /* GRALLOC_ALLOCATOR_H_ */ 130 | -------------------------------------------------------------------------------- /libgralloc/gr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GR_H_ 18 | #define GR_H_ 19 | 20 | #include 21 | #ifdef HAVE_ANDROID_OS // just want PAGE_SIZE define 22 | # include 23 | #else 24 | # include 25 | #endif 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | /*****************************************************************************/ 35 | 36 | struct private_module_t; 37 | struct private_handle_t; 38 | 39 | inline size_t roundUpToPageSize(size_t x) { 40 | return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); 41 | } 42 | 43 | int mapFrameBufferLocked(struct private_module_t* module); 44 | int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd); 45 | int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd); 46 | 47 | /*****************************************************************************/ 48 | 49 | class Locker { 50 | pthread_mutex_t mutex; 51 | public: 52 | class Autolock { 53 | Locker& locker; 54 | public: 55 | inline Autolock(Locker& locker) : locker(locker) { locker.lock(); } 56 | inline ~Autolock() { locker.unlock(); } 57 | }; 58 | inline Locker() { pthread_mutex_init(&mutex, 0); } 59 | inline ~Locker() { pthread_mutex_destroy(&mutex); } 60 | inline void lock() { pthread_mutex_lock(&mutex); } 61 | inline void unlock() { pthread_mutex_unlock(&mutex); } 62 | }; 63 | 64 | #endif /* GR_H_ */ 65 | -------------------------------------------------------------------------------- /libgralloc/gralloc_priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GRALLOC_PRIV_H_ 18 | #define GRALLOC_PRIV_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | /*****************************************************************************/ 33 | 34 | struct private_module_t; 35 | struct private_handle_t; 36 | 37 | struct private_module_t { 38 | gralloc_module_t base; 39 | 40 | struct private_handle_t* framebuffer; 41 | uint32_t flags; 42 | uint32_t numBuffers; 43 | uint32_t bufferMask; 44 | pthread_mutex_t lock; 45 | buffer_handle_t currentBuffer; 46 | int pmem_master; 47 | void* pmem_master_base; 48 | unsigned long master_phys; 49 | int gpu; 50 | void* gpu_base; 51 | int fb_map_offset; 52 | 53 | struct fb_var_screeninfo info; 54 | struct fb_fix_screeninfo finfo; 55 | float xdpi; 56 | float ydpi; 57 | float fps; 58 | }; 59 | 60 | /*****************************************************************************/ 61 | 62 | #ifdef __cplusplus 63 | struct private_handle_t : public native_handle { 64 | #else 65 | struct private_handle_t { 66 | native_handle_t nativeHandle; 67 | #endif 68 | 69 | enum { 70 | PRIV_FLAGS_FRAMEBUFFER = 0x00000001, 71 | PRIV_FLAGS_USES_PMEM = 0x00000002, 72 | PRIV_FLAGS_USES_GPU = 0x00000004, 73 | }; 74 | 75 | // file-descriptors 76 | int fd; 77 | // ints 78 | int magic; 79 | int flags; 80 | int size; 81 | int offset; 82 | int gpu_fd; // stored as an int, b/c we don't want it marshalled 83 | 84 | // FIXME: the attributes below should be out-of-line 85 | int base; 86 | int map_offset; 87 | int pid; 88 | 89 | #ifdef __cplusplus 90 | static const int sNumInts = 8; 91 | static const int sNumFds = 1; 92 | static const int sMagic = 'gmsm'; 93 | 94 | private_handle_t(int fd, int size, int flags) : 95 | fd(fd), magic(sMagic), flags(flags), size(size), offset(0), 96 | base(0), pid(getpid()) 97 | { 98 | version = sizeof(native_handle); 99 | numInts = sNumInts; 100 | numFds = sNumFds; 101 | } 102 | ~private_handle_t() { 103 | magic = 0; 104 | } 105 | 106 | static int validate(const native_handle* h) { 107 | const private_handle_t* hnd = (const private_handle_t*)h; 108 | if (!h || h->version != sizeof(native_handle) || 109 | h->numInts != sNumInts || h->numFds != sNumFds || 110 | hnd->magic != sMagic) 111 | { 112 | LOGE("invalid gralloc handle (at %p)", h); 113 | return -EINVAL; 114 | } 115 | return 0; 116 | } 117 | #endif 118 | }; 119 | 120 | #endif /* GRALLOC_PRIV_H_ */ 121 | -------------------------------------------------------------------------------- /libgralloc/mapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #include "gralloc_priv.h" 38 | 39 | 40 | // we need this for now because pmem cannot mmap at an offset 41 | #define PMEM_HACK 1 42 | 43 | /* desktop Linux needs a little help with gettid() */ 44 | #if defined(ARCH_X86) && !defined(HAVE_ANDROID_OS) 45 | #define __KERNEL__ 46 | # include 47 | pid_t gettid() { return syscall(__NR_gettid);} 48 | #undef __KERNEL__ 49 | #endif 50 | 51 | /*****************************************************************************/ 52 | 53 | static int gralloc_map(gralloc_module_t const* module, 54 | buffer_handle_t handle, 55 | void** vaddr) 56 | { 57 | private_handle_t* hnd = (private_handle_t*)handle; 58 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { 59 | size_t size = hnd->size; 60 | #if PMEM_HACK 61 | size += hnd->offset; 62 | #endif 63 | void* mappedAddress = mmap(0, size, 64 | PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0); 65 | if (mappedAddress == MAP_FAILED) { 66 | LOGE("Could not mmap handle %p, fd=%d (%s)", 67 | handle, hnd->fd, strerror(errno)); 68 | hnd->base = 0; 69 | return -errno; 70 | } 71 | hnd->base = intptr_t(mappedAddress) + hnd->offset; 72 | //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", 73 | // hnd->fd, hnd->offset, hnd->size, mappedAddress); 74 | } 75 | *vaddr = (void*)hnd->base; 76 | return 0; 77 | } 78 | 79 | static int gralloc_unmap(gralloc_module_t const* module, 80 | buffer_handle_t handle) 81 | { 82 | private_handle_t* hnd = (private_handle_t*)handle; 83 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { 84 | void* base = (void*)hnd->base; 85 | size_t size = hnd->size; 86 | #if PMEM_HACK 87 | base = (void*)(intptr_t(base) - hnd->offset); 88 | size += hnd->offset; 89 | #endif 90 | //LOGD("unmapping from %p, size=%d, flags=%08x", base, size, hnd->flags); 91 | if (munmap(base, size) < 0) { 92 | LOGE("Could not unmap %s", strerror(errno)); 93 | } 94 | } 95 | hnd->base = 0; 96 | return 0; 97 | } 98 | 99 | /*****************************************************************************/ 100 | 101 | static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; 102 | 103 | /*****************************************************************************/ 104 | 105 | int gralloc_register_buffer(gralloc_module_t const* module, 106 | buffer_handle_t handle) 107 | { 108 | if (private_handle_t::validate(handle) < 0) 109 | return -EINVAL; 110 | 111 | // if this handle was created in this process, then we keep it as is. 112 | int err = 0; 113 | private_handle_t* hnd = (private_handle_t*)handle; 114 | if (hnd->pid != getpid()) { 115 | hnd->base = NULL; 116 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_GPU)) { 117 | void *vaddr; 118 | err = gralloc_map(module, handle, &vaddr); 119 | } 120 | } 121 | return err; 122 | } 123 | 124 | int gralloc_unregister_buffer(gralloc_module_t const* module, 125 | buffer_handle_t handle) 126 | { 127 | if (private_handle_t::validate(handle) < 0) 128 | return -EINVAL; 129 | 130 | // never unmap buffers that were created in this process 131 | private_handle_t* hnd = (private_handle_t*)handle; 132 | if (hnd->pid != getpid()) { 133 | if (hnd->base) { 134 | gralloc_unmap(module, handle); 135 | } 136 | } 137 | return 0; 138 | } 139 | 140 | int mapBuffer(gralloc_module_t const* module, 141 | private_handle_t* hnd) 142 | { 143 | void* vaddr; 144 | return gralloc_map(module, hnd, &vaddr); 145 | } 146 | 147 | int terminateBuffer(gralloc_module_t const* module, 148 | private_handle_t* hnd) 149 | { 150 | if (hnd->base) { 151 | // this buffer was mapped, unmap it now 152 | if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) { 153 | if (hnd->pid != getpid()) { 154 | // ... unless it's a "master" pmem buffer, that is a buffer 155 | // mapped in the process it's been allocated. 156 | // (see gralloc_alloc_buffer()) 157 | gralloc_unmap(module, hnd); 158 | } 159 | } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_GPU) { 160 | // XXX: for now do nothing here 161 | } else { 162 | gralloc_unmap(module, hnd); 163 | } 164 | } 165 | 166 | return 0; 167 | } 168 | 169 | int gralloc_lock(gralloc_module_t const* module, 170 | buffer_handle_t handle, int usage, 171 | int l, int t, int w, int h, 172 | void** vaddr) 173 | { 174 | // this is called when a buffer is being locked for software 175 | // access. in thin implementation we have nothing to do since 176 | // not synchronization with the h/w is needed. 177 | // typically this is used to wait for the h/w to finish with 178 | // this buffer if relevant. the data cache may need to be 179 | // flushed or invalidated depending on the usage bits and the 180 | // hardware. 181 | 182 | if (private_handle_t::validate(handle) < 0) 183 | return -EINVAL; 184 | 185 | private_handle_t* hnd = (private_handle_t*)handle; 186 | *vaddr = (void*)hnd->base; 187 | return 0; 188 | } 189 | 190 | int gralloc_unlock(gralloc_module_t const* module, 191 | buffer_handle_t handle) 192 | { 193 | // we're done with a software buffer. nothing to do in this 194 | // implementation. typically this is used to flush the data cache. 195 | 196 | if (private_handle_t::validate(handle) < 0) 197 | return -EINVAL; 198 | return 0; 199 | } 200 | 201 | 202 | /*****************************************************************************/ 203 | 204 | int gralloc_perform(struct gralloc_module_t const* module, 205 | int operation, ... ) 206 | { 207 | int res = -EINVAL; 208 | va_list args; 209 | va_start(args, operation); 210 | 211 | switch (operation) { 212 | case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: { 213 | int fd = va_arg(args, int); 214 | size_t size = va_arg(args, size_t); 215 | size_t offset = va_arg(args, size_t); 216 | void* base = va_arg(args, void*); 217 | 218 | // validate that it's indeed a pmem buffer 219 | pmem_region region; 220 | if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0) { 221 | break; 222 | } 223 | 224 | native_handle_t** handle = va_arg(args, native_handle_t**); 225 | private_handle_t* hnd = (private_handle_t*)native_handle_create( 226 | private_handle_t::sNumFds, private_handle_t::sNumInts); 227 | hnd->magic = private_handle_t::sMagic; 228 | hnd->fd = fd; 229 | hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM; 230 | hnd->size = size; 231 | hnd->offset = offset; 232 | hnd->base = intptr_t(base) + offset; 233 | *handle = (native_handle_t *)hnd; 234 | res = 0; 235 | break; 236 | } 237 | } 238 | 239 | va_end(args); 240 | return res; 241 | } 242 | -------------------------------------------------------------------------------- /liblights/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | ifneq ($(TARGET_SIMULATOR),true) 18 | 19 | include $(CLEAR_VARS) 20 | 21 | LOCAL_MODULE := lights.$(TARGET_BOOTLOADER_BOARD_NAME) 22 | 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 24 | 25 | LOCAL_MODULE_TAGS := optional 26 | 27 | LOCAL_SRC_FILES := lights.c 28 | LOCAL_SHARED_LIBRARIES := liblog 29 | LOCAL_PRELINK_MODULE := false 30 | 31 | include $(BUILD_SHARED_LIBRARY) 32 | 33 | endif # !TARGET_SIMULATOR 34 | -------------------------------------------------------------------------------- /liblights/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/liblights/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /liblights/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2008-2009, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /liblights/lights.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Diogo Ferreira 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "lights" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | static pthread_once_t g_init = PTHREAD_ONCE_INIT; 34 | static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; 35 | static struct light_state_t g_notification; 36 | static struct light_state_t g_battery; 37 | static int g_backlight = 255; 38 | 39 | char const*const AMBER_LED_FILE = "/sys/class/leds/amber/brightness"; 40 | char const*const GREEN_LED_FILE = "/sys/class/leds/green/brightness"; 41 | 42 | char const*const BUTTON_FILE = "/sys/class/leds/button-backlight/brightness"; 43 | 44 | char const*const AMBER_BLINK_FILE = "/sys/class/leds/amber/blink"; 45 | char const*const GREEN_BLINK_FILE = "/sys/class/leds/green/blink"; 46 | 47 | char const*const LCD_BACKLIGHT_FILE = "/sys/class/leds/lcd-backlight/brightness"; 48 | 49 | enum { 50 | LED_BLANK, 51 | LED_AMBER, 52 | LED_GREEN, 53 | LED_BOTH, 54 | }; 55 | 56 | /** 57 | * Aux method, write int to file 58 | */ 59 | static int write_int (const char* path, int value) { 60 | int fd; 61 | static int already_warned = 0; 62 | 63 | fd = open(path, O_RDWR); 64 | if (fd < 0) { 65 | if (already_warned == 0) { 66 | LOGE("write_int failed to open %s\n", path); 67 | already_warned = 1; 68 | } 69 | return -errno; 70 | } 71 | 72 | char buffer[20]; 73 | int bytes = snprintf(buffer, sizeof(buffer), "%d\n",value); 74 | int written = write (fd, buffer, bytes); 75 | close (fd); 76 | 77 | return written == -1 ? -errno : 0; 78 | } 79 | 80 | void init_globals (void) { 81 | pthread_mutex_init (&g_lock, NULL); 82 | } 83 | 84 | static int is_lit (struct light_state_t const* state) { 85 | return state->color & 0x00ffffff; 86 | } 87 | 88 | static unsigned int rgb_to_led(struct light_state_t *state) { 89 | unsigned int colorRGB = state->color & 0xFFFFFF; 90 | unsigned int colorLED = LED_BLANK; 91 | 92 | if (colorRGB & 0xFF) 93 | colorLED |= LED_GREEN; 94 | else { 95 | if ((colorRGB >> 8) & 0xFF) 96 | colorLED |= LED_GREEN; 97 | if ((colorRGB >> 16) & 0xFF) 98 | colorLED |= LED_AMBER; 99 | } 100 | 101 | return colorLED; 102 | } 103 | 104 | static void set_speaker_light_locked (struct light_device_t *dev, 105 | struct light_state_t *state) { 106 | unsigned int colorRGB = state->color & 0xFFFFFF; 107 | unsigned int colorLED = rgb_to_led(state); 108 | 109 | switch (state->flashMode) { 110 | case LIGHT_FLASH_HARDWARE: 111 | case LIGHT_FLASH_TIMED: 112 | switch (colorLED) { 113 | case LED_BOTH: 114 | write_int (AMBER_BLINK_FILE, 1); 115 | write_int (GREEN_BLINK_FILE, 1); 116 | break; 117 | case LED_AMBER: 118 | if (state == &g_battery) 119 | write_int (AMBER_BLINK_FILE, 4); 120 | else 121 | write_int (AMBER_BLINK_FILE, 1); 122 | write_int (GREEN_LED_FILE, 0); 123 | break; 124 | case LED_GREEN: 125 | write_int (GREEN_BLINK_FILE, 1); 126 | write_int (AMBER_LED_FILE, 0); 127 | break; 128 | case LED_BLANK: 129 | write_int (AMBER_BLINK_FILE, 0); 130 | write_int (GREEN_BLINK_FILE, 0); 131 | break; 132 | default: 133 | LOGE("set_led_state: unknown color, colorRGB=0x%08X colorLED=%d\n", 134 | colorRGB, colorLED); 135 | break; 136 | } 137 | break; 138 | case LIGHT_FLASH_NONE: 139 | switch (colorLED) { 140 | case LED_BOTH: 141 | write_int (AMBER_LED_FILE, 1); 142 | write_int (GREEN_LED_FILE, 1); 143 | break; 144 | case LED_AMBER: 145 | write_int (AMBER_LED_FILE, 1); 146 | write_int (GREEN_LED_FILE, 0); 147 | break; 148 | case LED_GREEN: 149 | write_int (AMBER_LED_FILE, 0); 150 | write_int (GREEN_LED_FILE, 1); 151 | break; 152 | case LED_BLANK: 153 | write_int (AMBER_LED_FILE, 0); 154 | write_int (GREEN_LED_FILE, 0); 155 | break; 156 | default: 157 | LOGE("set_led_state: unknown color, colorRGB=0x%08X colorLED=%d\n", 158 | colorRGB, colorLED); 159 | break; 160 | } 161 | break; 162 | default: 163 | LOGE("set_led_state: unknown mode, colorRGB=0x%08X flashMode=%d\n", 164 | colorRGB, state->flashMode); 165 | } 166 | } 167 | 168 | static void set_speaker_light_locked_dual(struct light_device_t *dev, 169 | struct light_state_t *bstate, struct light_state_t *nstate) { 170 | unsigned int bcolorRGB = bstate->color & 0xFFFFFF; 171 | unsigned int bcolorLED = rgb_to_led(bstate); 172 | 173 | switch (bcolorLED) { 174 | case LED_BOTH: 175 | case LED_AMBER: 176 | write_int (AMBER_BLINK_FILE, 4); 177 | write_int (GREEN_LED_FILE, 1); 178 | break; 179 | case LED_GREEN: 180 | write_int (AMBER_BLINK_FILE, 1); 181 | write_int (GREEN_LED_FILE, 1); 182 | break; 183 | case LED_BLANK: 184 | default: 185 | LOGE("set_led_state_dual: unexpected color, bcolorRGB=0x%08X bcolorLED=%d\n", 186 | bcolorRGB, bcolorLED); 187 | break; 188 | } 189 | } 190 | 191 | static void handle_speaker_battery_locked (struct light_device_t *dev) { 192 | if (is_lit (&g_battery) && is_lit (&g_notification)) { 193 | set_speaker_light_locked_dual(dev, &g_battery, &g_notification); 194 | } else if (is_lit (&g_battery)) { 195 | set_speaker_light_locked (dev, &g_battery); 196 | } else { 197 | set_speaker_light_locked (dev, &g_notification); 198 | } 199 | } 200 | 201 | static int set_light_buttons (struct light_device_t* dev, 202 | struct light_state_t const* state) { 203 | int err = 0; 204 | int on = is_lit (state); 205 | pthread_mutex_lock (&g_lock); 206 | err = write_int (BUTTON_FILE, on?255:0); 207 | pthread_mutex_unlock (&g_lock); 208 | 209 | return 0; 210 | } 211 | 212 | static int rgb_to_brightness(struct light_state_t const* state) 213 | { 214 | int color = state->color & 0x00ffffff; 215 | return ((77*((color>>16)&0x00ff)) 216 | + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; 217 | } 218 | 219 | static int set_light_backlight(struct light_device_t* dev, 220 | struct light_state_t const* state) { 221 | int err = 0; 222 | int brightness = rgb_to_brightness(state); 223 | LOGV("%s brightness=%d color=0x%08x", 224 | __func__,brightness, state->color); 225 | pthread_mutex_lock(&g_lock); 226 | g_backlight = brightness; 227 | err = write_int(LCD_BACKLIGHT_FILE, brightness); 228 | pthread_mutex_unlock(&g_lock); 229 | return err; 230 | } 231 | 232 | static int set_light_battery (struct light_device_t* dev, 233 | struct light_state_t const* state) { 234 | pthread_mutex_lock (&g_lock); 235 | g_battery = *state; 236 | handle_speaker_battery_locked(dev); 237 | pthread_mutex_unlock (&g_lock); 238 | 239 | return 0; 240 | } 241 | 242 | static int set_light_attention (struct light_device_t* dev, 243 | struct light_state_t const* state) { 244 | /* tattoo has no attention */ 245 | 246 | return 0; 247 | } 248 | 249 | static int set_light_notifications (struct light_device_t* dev, 250 | struct light_state_t const* state) { 251 | pthread_mutex_lock (&g_lock); 252 | g_notification = *state; 253 | handle_speaker_battery_locked (dev); 254 | pthread_mutex_unlock (&g_lock); 255 | return 0; 256 | } 257 | 258 | static int close_lights (struct light_device_t *dev) { 259 | if (dev) 260 | free (dev); 261 | 262 | return 0; 263 | } 264 | 265 | static int open_lights (const struct hw_module_t* module, char const* name, 266 | struct hw_device_t** device) { 267 | int (*set_light)(struct light_device_t* dev, 268 | struct light_state_t const* state); 269 | 270 | if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) { 271 | set_light = set_light_backlight; 272 | } 273 | else if (0 == strcmp(LIGHT_ID_BUTTONS, name)) { 274 | set_light = set_light_buttons; 275 | } 276 | else if (0 == strcmp(LIGHT_ID_BATTERY, name)) { 277 | set_light = set_light_battery; 278 | } 279 | else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) { 280 | set_light = set_light_attention; 281 | } 282 | else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) { 283 | set_light = set_light_notifications; 284 | } 285 | else { 286 | return -EINVAL; 287 | } 288 | 289 | pthread_once (&g_init, init_globals); 290 | struct light_device_t *dev = malloc (sizeof (struct light_device_t)); 291 | memset (dev,0,sizeof(*dev)); 292 | 293 | dev->common.tag = HARDWARE_DEVICE_TAG; 294 | dev->common.version = 0; 295 | dev->common.module = (struct hw_module_t*)module; 296 | dev->common.close = (int (*)(struct hw_device_t*))close_lights; 297 | dev->set_light = set_light; 298 | 299 | *device = (struct hw_device_t*) dev; 300 | return 0; 301 | } 302 | 303 | static struct hw_module_methods_t lights_module_methods = { 304 | .open = open_lights, 305 | }; 306 | 307 | const struct hw_module_t HAL_MODULE_INFO_SYM = { 308 | .tag = HARDWARE_MODULE_TAG, 309 | .version_major = 2, 310 | .version_minor = 0, 311 | .id = LIGHTS_HARDWARE_MODULE_ID, 312 | .name = "Tattoo lights module", 313 | .author = "Diogo Ferreira ", 314 | .methods = &lights_module_methods, 315 | }; 316 | -------------------------------------------------------------------------------- /libsensors/AkmSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include "AkmSensor.h" 30 | 31 | /*****************************************************************************/ 32 | 33 | AkmSensor::AkmSensor() 34 | : SensorBase(AKM_DEVICE_NAME, "compass"), 35 | mEnabled(0), 36 | mPendingMask(0), 37 | mInputReader(32) 38 | { 39 | memset(mPendingEvents, 0, sizeof(mPendingEvents)); 40 | 41 | mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); 42 | mPendingEvents[Accelerometer].sensor = ID_A; 43 | mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; 44 | mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; 45 | 46 | mPendingEvents[MagneticField].version = sizeof(sensors_event_t); 47 | mPendingEvents[MagneticField].sensor = ID_M; 48 | mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; 49 | mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; 50 | 51 | mPendingEvents[Orientation ].version = sizeof(sensors_event_t); 52 | mPendingEvents[Orientation ].sensor = ID_O; 53 | mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION; 54 | mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH; 55 | 56 | for (int i=0 ; i= numSensors) 133 | return -EINVAL; 134 | 135 | int newState = en ? 1 : 0; 136 | int err = 0; 137 | 138 | if ((uint32_t(newState)<= numSensors) 175 | return -EINVAL; 176 | 177 | if (ns < 0) 178 | return -EINVAL; 179 | 180 | mDelays[what] = ns; 181 | return update_delay(); 182 | #else 183 | return -1; 184 | #endif 185 | } 186 | 187 | int AkmSensor::update_delay() 188 | { 189 | if (mEnabled) { 190 | uint64_t wanted = -1LLU; 191 | for (int i=0 ; itype; 219 | if (type == EV_ABS) { 220 | processEvent(event->code, event->value); 221 | mInputReader.next(); 222 | } else if (type == EV_SYN) { 223 | int64_t time = timevalToNano(event->time); 224 | for (int j=0 ; count && mPendingMask && jcode); 241 | mInputReader.next(); 242 | } 243 | } 244 | 245 | return numEventReceived; 246 | } 247 | 248 | void AkmSensor::processEvent(int code, int value) 249 | { 250 | switch (code) { 251 | case EVENT_TYPE_ACCEL_X: 252 | mPendingMask |= 1< 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | #include "nusensors.h" 27 | #include "SensorBase.h" 28 | #include "InputEventReader.h" 29 | 30 | /*****************************************************************************/ 31 | 32 | struct input_event; 33 | 34 | class AkmSensor : public SensorBase { 35 | public: 36 | AkmSensor(); 37 | virtual ~AkmSensor(); 38 | 39 | enum { 40 | Accelerometer = 0, 41 | MagneticField = 1, 42 | Orientation = 2, 43 | numSensors 44 | }; 45 | 46 | virtual int setDelay(int32_t handle, int64_t ns); 47 | virtual int enable(int32_t handle, int enabled); 48 | virtual int readEvents(sensors_event_t* data, int count); 49 | void processEvent(int code, int value); 50 | 51 | private: 52 | int update_delay(); 53 | uint32_t mEnabled; 54 | uint32_t mPendingMask; 55 | InputEventCircularReader mInputReader; 56 | sensors_event_t mPendingEvents[numSensors]; 57 | uint64_t mDelays[numSensors]; 58 | }; 59 | 60 | /*****************************************************************************/ 61 | 62 | #endif // ANDROID_AKM_SENSOR_H 63 | -------------------------------------------------------------------------------- /libsensors/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | ifneq ($(TARGET_SIMULATOR),true) 19 | 20 | # HAL module implemenation, not prelinked, and stored in 21 | # hw/..so 22 | include $(CLEAR_VARS) 23 | 24 | LOCAL_MODULE := sensors.$(TARGET_BOOTLOADER_BOARD_NAME) 25 | 26 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 27 | 28 | LOCAL_MODULE_TAGS := optional 29 | 30 | LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" 31 | LOCAL_SRC_FILES := \ 32 | sensors.c \ 33 | nusensors.cpp \ 34 | InputEventReader.cpp \ 35 | SensorBase.cpp \ 36 | AkmSensor.cpp 37 | 38 | LOCAL_SHARED_LIBRARIES := liblog libcutils 39 | LOCAL_PRELINK_MODULE := false 40 | 41 | include $(BUILD_SHARED_LIBRARY) 42 | 43 | endif # !TARGET_SIMULATOR 44 | -------------------------------------------------------------------------------- /libsensors/InputEventReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include "InputEventReader.h" 30 | 31 | /*****************************************************************************/ 32 | 33 | struct input_event; 34 | 35 | InputEventCircularReader::InputEventCircularReader(size_t numEvents) 36 | : mBuffer(new input_event[numEvents * 2]), 37 | mBufferEnd(mBuffer + numEvents), 38 | mHead(mBuffer), 39 | mCurr(mBuffer), 40 | mFreeSpace(numEvents) 41 | { 42 | } 43 | 44 | InputEventCircularReader::~InputEventCircularReader() 45 | { 46 | delete [] mBuffer; 47 | } 48 | 49 | ssize_t InputEventCircularReader::fill(int fd) 50 | { 51 | size_t numEventsRead = 0; 52 | if (mFreeSpace) { 53 | const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event)); 54 | if (nread<0 || nread % sizeof(input_event)) { 55 | // we got a partial event!! 56 | return nread<0 ? -errno : -EINVAL; 57 | } 58 | 59 | numEventsRead = nread / sizeof(input_event); 60 | if (numEventsRead) { 61 | mHead += numEventsRead; 62 | mFreeSpace -= numEventsRead; 63 | if (mHead > mBufferEnd) { 64 | size_t s = mHead - mBufferEnd; 65 | memcpy(mBuffer, mBufferEnd, s * sizeof(input_event)); 66 | mHead = mBuffer + s; 67 | } 68 | } 69 | } 70 | 71 | return numEventsRead; 72 | } 73 | 74 | ssize_t InputEventCircularReader::readEvent(input_event const** events) 75 | { 76 | *events = mCurr; 77 | ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace; 78 | return available ? 1 : 0; 79 | } 80 | 81 | void InputEventCircularReader::next() 82 | { 83 | mCurr++; 84 | mFreeSpace++; 85 | if (mCurr >= mBufferEnd) { 86 | mCurr = mBuffer; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /libsensors/InputEventReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_INPUT_EVENT_READER_H 18 | #define ANDROID_INPUT_EVENT_READER_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /*****************************************************************************/ 26 | 27 | struct input_event; 28 | 29 | class InputEventCircularReader 30 | { 31 | struct input_event* const mBuffer; 32 | struct input_event* const mBufferEnd; 33 | struct input_event* mHead; 34 | struct input_event* mCurr; 35 | ssize_t mFreeSpace; 36 | 37 | public: 38 | InputEventCircularReader(size_t numEvents); 39 | ~InputEventCircularReader(); 40 | ssize_t fill(int fd); 41 | ssize_t readEvent(input_event const** events); 42 | void next(); 43 | }; 44 | 45 | /*****************************************************************************/ 46 | 47 | #endif // ANDROID_INPUT_EVENT_READER_H 48 | -------------------------------------------------------------------------------- /libsensors/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_device_htc_click/cd2ba44217fe9e579fd0208fb90b5581d2a9cbd3/libsensors/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libsensors/NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2008, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /libsensors/SensorBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include "SensorBase.h" 30 | 31 | /*****************************************************************************/ 32 | 33 | SensorBase::SensorBase( 34 | const char* dev_name, 35 | const char* data_name) 36 | : dev_name(dev_name), data_name(data_name), 37 | dev_fd(-1), data_fd(-1) 38 | { 39 | data_fd = openInput(data_name); 40 | } 41 | 42 | SensorBase::~SensorBase() { 43 | if (data_fd >= 0) { 44 | close(data_fd); 45 | } 46 | if (dev_fd >= 0) { 47 | close(dev_fd); 48 | } 49 | } 50 | 51 | int SensorBase::open_device() { 52 | if (dev_fd<0 && dev_name) { 53 | dev_fd = open(dev_name, O_RDONLY); 54 | LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno)); 55 | } 56 | return 0; 57 | } 58 | 59 | int SensorBase::close_device() { 60 | if (dev_fd >= 0) { 61 | close(dev_fd); 62 | dev_fd = -1; 63 | } 64 | return 0; 65 | } 66 | 67 | int SensorBase::getFd() const { 68 | return data_fd; 69 | } 70 | 71 | int SensorBase::setDelay(int32_t handle, int64_t ns) { 72 | return 0; 73 | } 74 | 75 | bool SensorBase::hasPendingEvents() const { 76 | return false; 77 | } 78 | 79 | int64_t SensorBase::getTimestamp() { 80 | struct timespec t; 81 | t.tv_sec = t.tv_nsec = 0; 82 | clock_gettime(CLOCK_MONOTONIC, &t); 83 | return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; 84 | } 85 | 86 | int SensorBase::openInput(const char* inputName) { 87 | int fd = -1; 88 | const char *dirname = "/dev/input"; 89 | char devname[PATH_MAX]; 90 | char *filename; 91 | DIR *dir; 92 | struct dirent *de; 93 | dir = opendir(dirname); 94 | if(dir == NULL) 95 | return -1; 96 | strcpy(devname, dirname); 97 | filename = devname + strlen(devname); 98 | *filename++ = '/'; 99 | while((de = readdir(dir))) { 100 | if(de->d_name[0] == '.' && 101 | (de->d_name[1] == '\0' || 102 | (de->d_name[1] == '.' && de->d_name[2] == '\0'))) 103 | continue; 104 | strcpy(filename, de->d_name); 105 | fd = open(devname, O_RDONLY); 106 | if (fd>=0) { 107 | char name[80]; 108 | if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) { 109 | name[0] = '\0'; 110 | } 111 | if (!strcmp(name, inputName)) { 112 | break; 113 | } else { 114 | close(fd); 115 | fd = -1; 116 | } 117 | } 118 | } 119 | closedir(dir); 120 | LOGE_IF(fd<0, "couldn't find '%s' input device", inputName); 121 | return fd; 122 | } 123 | -------------------------------------------------------------------------------- /libsensors/SensorBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSOR_BASE_H 18 | #define ANDROID_SENSOR_BASE_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | /*****************************************************************************/ 27 | 28 | struct sensors_event_t; 29 | 30 | class SensorBase { 31 | protected: 32 | const char* dev_name; 33 | const char* data_name; 34 | int dev_fd; 35 | int data_fd; 36 | 37 | static int openInput(const char* inputName); 38 | static int64_t getTimestamp(); 39 | 40 | 41 | static int64_t timevalToNano(timeval const& t) { 42 | return t.tv_sec*1000000000LL + t.tv_usec*1000; 43 | } 44 | 45 | int open_device(); 46 | int close_device(); 47 | 48 | public: 49 | SensorBase( 50 | const char* dev_name, 51 | const char* data_name); 52 | 53 | virtual ~SensorBase(); 54 | 55 | virtual int readEvents(sensors_event_t* data, int count) = 0; 56 | virtual bool hasPendingEvents() const; 57 | virtual int getFd() const; 58 | virtual int setDelay(int32_t handle, int64_t ns); 59 | virtual int enable(int32_t handle, int enabled) = 0; 60 | }; 61 | 62 | /*****************************************************************************/ 63 | 64 | #endif // ANDROID_SENSOR_BASE_H 65 | -------------------------------------------------------------------------------- /libsensors/nusensors.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "nusensors.h" 32 | #include "AkmSensor.h" 33 | 34 | /*****************************************************************************/ 35 | 36 | struct sensors_poll_context_t { 37 | struct sensors_poll_device_t device; // must be first 38 | 39 | sensors_poll_context_t(); 40 | ~sensors_poll_context_t(); 41 | int activate(int handle, int enabled); 42 | int setDelay(int handle, int64_t ns); 43 | int pollEvents(sensors_event_t* data, int count); 44 | 45 | private: 46 | enum { 47 | akm = 0, 48 | numSensorDrivers, 49 | numFds, 50 | }; 51 | 52 | static const size_t wake = numFds - 1; 53 | static const char WAKE_MESSAGE = 'W'; 54 | struct pollfd mPollFds[numFds]; 55 | int mWritePipeFd; 56 | SensorBase* mSensors[numSensorDrivers]; 57 | 58 | int handleToDriver(int handle) const { 59 | switch (handle) { 60 | case ID_A: 61 | case ID_M: 62 | case ID_O: 63 | return akm; 64 | } 65 | return -EINVAL; 66 | } 67 | }; 68 | 69 | /*****************************************************************************/ 70 | 71 | sensors_poll_context_t::sensors_poll_context_t() 72 | { 73 | mSensors[akm] = new AkmSensor(); 74 | mPollFds[akm].fd = mSensors[akm]->getFd(); 75 | mPollFds[akm].events = POLLIN; 76 | mPollFds[akm].revents = 0; 77 | 78 | int wakeFds[2]; 79 | int result = pipe(wakeFds); 80 | LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno)); 81 | fcntl(wakeFds[0], F_SETFL, O_NONBLOCK); 82 | fcntl(wakeFds[1], F_SETFL, O_NONBLOCK); 83 | mWritePipeFd = wakeFds[1]; 84 | 85 | mPollFds[wake].fd = wakeFds[0]; 86 | mPollFds[wake].events = POLLIN; 87 | mPollFds[wake].revents = 0; 88 | } 89 | 90 | sensors_poll_context_t::~sensors_poll_context_t() { 91 | for (int i=0 ; ienable(handle, enabled); 102 | if (enabled && !err) { 103 | const char wakeMessage(WAKE_MESSAGE); 104 | int result = write(mWritePipeFd, &wakeMessage, 1); 105 | LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); 106 | } 107 | return err; 108 | } 109 | 110 | int sensors_poll_context_t::setDelay(int handle, int64_t ns) { 111 | 112 | int index = handleToDriver(handle); 113 | if (index < 0) return index; 114 | return mSensors[index]->setDelay(handle, ns); 115 | } 116 | 117 | int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count) 118 | { 119 | int nbEvents = 0; 120 | int n = 0; 121 | 122 | do { 123 | // see if we have some leftover from the last poll() 124 | for (int i=0 ; count && ihasPendingEvents())) { 127 | int nb = sensor->readEvents(data, count); 128 | if (nb < count) { 129 | // no more data for this sensor 130 | mPollFds[i].revents = 0; 131 | } 132 | count -= nb; 133 | nbEvents += nb; 134 | data += nb; 135 | } 136 | } 137 | 138 | if (count) { 139 | // we still have some room, so try to see if we can get 140 | // some events immediately or just wait if we don't have 141 | // anything to return 142 | n = poll(mPollFds, numFds, nbEvents ? 0 : -1); 143 | if (n<0) { 144 | LOGE("poll() failed (%s)", strerror(errno)); 145 | return -errno; 146 | } 147 | if (mPollFds[wake].revents & POLLIN) { 148 | char msg; 149 | int result = read(mPollFds[wake].fd, &msg, 1); 150 | LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno)); 151 | LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg)); 152 | mPollFds[wake].revents = 0; 153 | } 154 | } 155 | // if we have events and space, go read them 156 | } while (n && count); 157 | 158 | return nbEvents; 159 | } 160 | 161 | /*****************************************************************************/ 162 | 163 | static int poll__close(struct hw_device_t *dev) 164 | { 165 | sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; 166 | if (ctx) { 167 | delete ctx; 168 | } 169 | return 0; 170 | } 171 | 172 | static int poll__activate(struct sensors_poll_device_t *dev, 173 | int handle, int enabled) { 174 | sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; 175 | return ctx->activate(handle, enabled); 176 | } 177 | 178 | static int poll__setDelay(struct sensors_poll_device_t *dev, 179 | int handle, int64_t ns) { 180 | sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; 181 | return ctx->setDelay(handle, ns); 182 | } 183 | 184 | static int poll__poll(struct sensors_poll_device_t *dev, 185 | sensors_event_t* data, int count) { 186 | sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; 187 | return ctx->pollEvents(data, count); 188 | } 189 | 190 | /*****************************************************************************/ 191 | 192 | int init_nusensors(hw_module_t const* module, hw_device_t** device) 193 | { 194 | int status = -EINVAL; 195 | 196 | sensors_poll_context_t *dev = new sensors_poll_context_t(); 197 | memset(&dev->device, 0, sizeof(sensors_poll_device_t)); 198 | 199 | dev->device.common.tag = HARDWARE_DEVICE_TAG; 200 | dev->device.common.version = 0; 201 | dev->device.common.module = const_cast(module); 202 | dev->device.common.close = poll__close; 203 | dev->device.activate = poll__activate; 204 | dev->device.setDelay = poll__setDelay; 205 | dev->device.poll = poll__poll; 206 | 207 | *device = &dev->device.common; 208 | status = 0; 209 | return status; 210 | } 211 | -------------------------------------------------------------------------------- /libsensors/nusensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORS_H 18 | #define ANDROID_SENSORS_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | __BEGIN_DECLS 31 | 32 | /*****************************************************************************/ 33 | 34 | int init_nusensors(hw_module_t const* module, hw_device_t** device); 35 | 36 | /*****************************************************************************/ 37 | 38 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 39 | 40 | #define ID_A (0) 41 | #define ID_M (1) 42 | #define ID_O (2) 43 | 44 | /*****************************************************************************/ 45 | 46 | /* 47 | * The SENSORS Module 48 | */ 49 | 50 | /*****************************************************************************/ 51 | 52 | #define AKM_DEVICE_NAME "/dev/akm8973_aot" 53 | 54 | #define EVENT_TYPE_ACCEL_X ABS_X 55 | #define EVENT_TYPE_ACCEL_Y ABS_Z 56 | #define EVENT_TYPE_ACCEL_Z ABS_Y 57 | #define EVENT_TYPE_ACCEL_STATUS ABS_WHEEL 58 | 59 | #define EVENT_TYPE_YAW ABS_RX 60 | #define EVENT_TYPE_PITCH ABS_RY 61 | #define EVENT_TYPE_ROLL ABS_RZ 62 | #define EVENT_TYPE_ORIENT_STATUS ABS_RUDDER 63 | 64 | #define EVENT_TYPE_MAGV_X ABS_HAT0X 65 | #define EVENT_TYPE_MAGV_Y ABS_HAT0Y 66 | #define EVENT_TYPE_MAGV_Z ABS_BRAKE 67 | 68 | #define EVENT_TYPE_TEMPERATURE ABS_THROTTLE 69 | #define EVENT_TYPE_STEP_COUNT ABS_GAS 70 | 71 | // 720 LSG = 1G 72 | #define LSG (720.0f) 73 | 74 | 75 | // conversion of acceleration data to SI units (m/s^2) 76 | #define CONVERT_A (GRAVITY_EARTH / LSG) 77 | #define CONVERT_A_X (-CONVERT_A) 78 | #define CONVERT_A_Y (CONVERT_A) 79 | #define CONVERT_A_Z (-CONVERT_A) 80 | 81 | // conversion of magnetic data to uT units 82 | #define CONVERT_M (1.0f/16.0f) 83 | #define CONVERT_M_X (-CONVERT_M) 84 | #define CONVERT_M_Y (-CONVERT_M) 85 | #define CONVERT_M_Z (CONVERT_M) 86 | 87 | #define CONVERT_O (1.0f) 88 | #define CONVERT_O_Y (CONVERT_O) 89 | #define CONVERT_O_P (CONVERT_O) 90 | #define CONVERT_O_R (-CONVERT_O) 91 | 92 | #define SENSOR_STATE_MASK (0x7FFF) 93 | 94 | /*****************************************************************************/ 95 | 96 | __END_DECLS 97 | 98 | #endif // ANDROID_SENSORS_H 99 | -------------------------------------------------------------------------------- /libsensors/sensors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "nusensors.h" 20 | 21 | /*****************************************************************************/ 22 | 23 | /* 24 | * The SENSORS Module 25 | */ 26 | 27 | /* 28 | * the AK8973 has a 8-bit ADC but the firmware seems to average 16 samples, 29 | * or at least makes its calibration on 12-bits values. This increases the 30 | * resolution by 4 bits. 31 | */ 32 | 33 | static const struct sensor_t sSensorList[] = { 34 | { "BMA150 3-axis Accelerometer", 35 | "Bosch", 36 | 1, SENSORS_HANDLE_BASE+ID_A, 37 | SENSOR_TYPE_ACCELEROMETER, 2.8f, 1.0f/4032.0f, 3.0f, 0, { } }, 38 | { "AK8973 3-axis Magnetic field sensor", 39 | "Asahi Kasei", 40 | 1, SENSORS_HANDLE_BASE+ID_M, 41 | SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, 1.0f, 6.7f, 0, { } }, 42 | { "AK8973 Orientation sensor", 43 | "Asahi Kasei", 44 | 1, SENSORS_HANDLE_BASE+ID_O, 45 | SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 9.7f, 0, { } }, 46 | }; 47 | 48 | static int open_sensors(const struct hw_module_t* module, const char* name, 49 | struct hw_device_t** device); 50 | 51 | static int sensors__get_sensors_list(struct sensors_module_t* module, 52 | struct sensor_t const** list) 53 | { 54 | *list = sSensorList; 55 | return ARRAY_SIZE(sSensorList); 56 | } 57 | 58 | static struct hw_module_methods_t sensors_module_methods = { 59 | .open = open_sensors 60 | }; 61 | 62 | const struct sensors_module_t HAL_MODULE_INFO_SYM = { 63 | .common = { 64 | .tag = HARDWARE_MODULE_TAG, 65 | .version_major = 1, 66 | .version_minor = 0, 67 | .id = SENSORS_HARDWARE_MODULE_ID, 68 | .name = "AK8973A Sensors Module", 69 | .author = "The Android Open Source Project", 70 | .methods = &sensors_module_methods, 71 | }, 72 | .get_sensors_list = sensors__get_sensors_list 73 | }; 74 | 75 | /*****************************************************************************/ 76 | 77 | static int open_sensors(const struct hw_module_t* module, const char* name, 78 | struct hw_device_t** device) 79 | { 80 | return init_nusensors(module, device); 81 | } 82 | -------------------------------------------------------------------------------- /media_profiles.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ]> 74 | 78 | 79 | 80 | 81 | 82 | 83 | 94 | 95 | 96 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 124 | 129 | 130 | 135 | 136 | 141 | 142 | 146 | 147 | 151 | 152 | 156 | 157 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 27 | false 28 | 29 | 32 | true 33 | 34 | 37 | 39 | 40 | "wifi,1,1,1" 41 | "mobile,0,0,0" 42 | "mobile_mms,2,0,2" 43 | "mobile_supl,3,0,2" 44 | "mobile_dun,4,0,4" 45 | "mobile_hipri,5,0,3" 46 | 47 | 48 | 51 | 52 | "usb0" 53 | 54 | 55 | 58 | 59 | 60 | 61 | 63 | 64 | "rmnet\\d" 65 | "tiwlan\\d" 66 | 67 | 68 | 69 | false 70 | 71 | 72 | true 73 | 74 | 75 | true 76 | 77 | 78 | com.google.android.location.NetworkLocationProvider 79 | 80 | 81 | com.google.android.location.GeocodeProvider 82 | 83 | 84 | 0 85 | 86 | 87 | 40 88 | 89 | 90 | 110 91 | 92 | 93 | 18 94 | 95 | -------------------------------------------------------------------------------- /overlay/packages/apps/CMParts/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | @string/trackball_color_entry_use_app 21 | @string/trackball_color_entry_green 22 | @string/trackball_color_entry_red 23 | @string/trackball_color_entry_amber 24 | 25 | 26 | 27 | default 28 | green 29 | red 30 | yellow 31 | 32 | 33 | -------------------------------------------------------------------------------- /overlay/packages/apps/CMParts/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | true 20 | 21 | -------------------------------------------------------------------------------- /overlay/packages/apps/Camera/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 25 | true 26 | 27 | 28 | false 29 | false 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /overlay/packages/apps/FM/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | true 8 | 9 | 10 | true 11 | 12 | -------------------------------------------------------------------------------- /overlay/packages/apps/Mms/res/xml/mms_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 23 | 24 | 25 | 26 | 307200 27 | 28 | 29 | 768 30 | 31 | 32 | 1024 33 | 34 | 35 | http://www.htcmms.com.tw/Android/Common/tattoo/ua-profile.xml 36 | 37 | 38 | -------------------------------------------------------------------------------- /overlay/packages/apps/Phone/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | true 22 | true 23 | 24 | 26 | true 27 | 28 | 29 | true 30 | 31 | 34 | true 35 | 36 | 37 | -------------------------------------------------------------------------------- /overlay/packages/inputmethods/LatinIME/java/res/layout/input_gingerbread.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 36 | -------------------------------------------------------------------------------- /overlay/packages/inputmethods/LatinIME/java/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 0.240in 24 | 0.004in 25 | 0.270in 26 | 0in 27 | 38dip 28 | 63dip 29 | 2dip 30 | 31 | 32 | 0.459in 33 | 34 | -0.270in 35 | 36 | -------------------------------------------------------------------------------- /overlay/packages/inputmethods/LatinIME/java/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 0.260in 24 | 0in 25 | 0.300in 26 | 0in 27 | 22dip 28 | 42dip 29 | 63dip 30 | 4dip 31 | 33 | 2.5in 34 | 0.12in 35 | 0.083in 36 | 38sp 37 | 0.000in 38 | 39 | 80sp 40 | 41 | 42 | 0.553in 43 | 44 | -0.325in 45 | 0.05in 46 | 48 | -0.05in 49 | 0.3in 50 | 51 | -------------------------------------------------------------------------------- /recovery.fstab: -------------------------------------------------------------------------------- 1 | # mount point fstype device [device2] 2 | 3 | /boot mtd boot 4 | /cache yaffs2 cache 5 | /data yaffs2 userdata 6 | /misc mtd misc 7 | /recovery mtd recovery 8 | /sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0 9 | /system yaffs2 system 10 | /sd-ext ext3 /dev/block/mmcblk0p2 -------------------------------------------------------------------------------- /setup-makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (C) 2010 The Android Open Source Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | DEVICE=click 18 | MANUFACTURER=htc 19 | 20 | mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE 21 | 22 | (cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/$DEVICE-vendor.mk 23 | # Copyright (C) 2010 The Android Open Source Project 24 | # 25 | # Licensed under the Apache License, Version 2.0 (the "License"); 26 | # you may not use this file except in compliance with the License. 27 | # You may obtain a copy of the License at 28 | # 29 | # http://www.apache.org/licenses/LICENSE-2.0 30 | # 31 | # Unless required by applicable law or agreed to in writing, software 32 | # distributed under the License is distributed on an "AS IS" BASIS, 33 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 34 | # See the License for the specific language governing permissions and 35 | # limitations under the License. 36 | 37 | # This file is generated by device/__MANUFACTURER__/__DEVICE__/setup-makefiles.sh 38 | 39 | # Live wallpaper packages 40 | PRODUCT_PACKAGES := \\ 41 | LiveWallpapersPicker \\ 42 | librs_jni 43 | 44 | \$(call inherit-product, vendor/__MANUFACTURER__/__DEVICE__/device-vendor-blobs.mk) 45 | EOF 46 | 47 | (cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/BoardConfigVendor.mk 48 | # Copyright (C) 2010 The Android Open Source Project 49 | # 50 | # Licensed under the Apache License, Version 2.0 (the "License"); 51 | # you may not use this file except in compliance with the License. 52 | # You may obtain a copy of the License at 53 | # 54 | # http://www.apache.org/licenses/LICENSE-2.0 55 | # 56 | # Unless required by applicable law or agreed to in writing, software 57 | # distributed under the License is distributed on an "AS IS" BASIS, 58 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 | # See the License for the specific language governing permissions and 60 | # limitations under the License. 61 | 62 | # This file is generated by device/__MANUFACTURER__/__DEVICE__/setup-makefiles.sh 63 | 64 | USE_CAMERA_STUB := false 65 | EOF 66 | 67 | mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/overlay/packages/apps/Launcher2/res/layout 68 | (cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/overlay/packages/apps/Launcher2/res/layout/all_apps.xml 69 | 70 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | EOF 92 | -------------------------------------------------------------------------------- /system.prop: -------------------------------------------------------------------------------- 1 | # 2 | # system.prop for tattoo 3 | # 4 | 5 | # Increase SKIA decode memory capability for progressive jpg file 6 | ro.media.dec.jpeg.memcap=20000000 7 | 8 | # RIL specific configuration 9 | rild.libpath=/system/lib/libhtc_ril.so 10 | dalvik.vm.dexopt-flags=m=y 11 | ro.ril.ecc.HTC-ELL=92,93,94 12 | ro.ril.ecc.HTC-WWE=999 13 | ro.ril.enable.a52.HTC-ITA=1 14 | ro.ril.enable.a53.HTC-ITA=1 15 | ro.ril.enable.a52=0 16 | ro.ril.enable.a53=1 17 | ro.ril.enable.dtm = 1 18 | ro.ril.gprsclass = 12 19 | ro.ril.hsdpa.category=10 20 | ro.ril.hsupa.category=5 21 | ro.ril.hsxpa=2 22 | ro.ril.def.agps.mode = 2 23 | 24 | # Modify MMS APN retry timer from 5s to 2s. 25 | ro.gsm.2nd_data_retry_config = max_retries=3, 2000, 2000, 2000 26 | 27 | # Time between scans in seconds. Keep it high to minimize battery drain. 28 | # This only affects the case in which there are remembered access points, 29 | # but none are in range. 30 | wifi.interface = tiwlan0 31 | wifi.supplicant_scan_interval=120 32 | 33 | # density in DPI of the LCD of this board. This is used to scale the UI 34 | # appropriately. If this property is not defined, the default value is 120 dpi. 35 | ro.sf.lcd_density=120 36 | 37 | # View configuration for QVGA 38 | view.fading_edge_length=8 39 | view.touch_slop=15 40 | view.minimum_fling_velocity=25 41 | view.scroll_friction=0.008 42 | 43 | # No Autofocus device 44 | ro.workaround.noautofocus=1 45 | 46 | # Default network type 47 | # 0 => WCDMA Preferred. 48 | ro.telephony.default_network=0 49 | ro.com.google.locationfeatures=1 50 | 51 | ro.opengles.version=65536 52 | 53 | # Disable fs check on boot by default 54 | sys.checkfs.fat=false 55 | 56 | ro.config.notification_sound=tweeters.ogg 57 | ro.config.alarm_alert=Alarm_Classic.ogg 58 | 59 | # Enable JIT by default 60 | dalvik.vm.execution-mode=int:jit 61 | 62 | # Persist default parameters 63 | persist.sys.use_dithering=1 64 | persist.sys.purgeable_assets=0 65 | persist.sys.rotationanimation=false 66 | persist.sys.scrollingcache=2 67 | 68 | # VM heap size 69 | dalvik.vm.heapsize=24m 70 | 71 | # Enable compcache 72 | ro.compcache.default=18 73 | 74 | # Lock dirty_ratio to 20 when USB is mounted for improved transfer speed 75 | ro.vold.umsdirtyratio=20 76 | 77 | # Makes HOME ADW / OTHERS to be always in memoory 78 | pref_lock_home=1 79 | 80 | # Default Tether Enabled 81 | ro.tether.denied=false 82 | 83 | # Enable Google-specific location features, 84 | # like NetworkLocationProvider and LocationCollector. 85 | ro.com.google.locationfeatures=1 86 | -------------------------------------------------------------------------------- /ueventd.bahamas.rc: -------------------------------------------------------------------------------- 1 | mtd@misc 0460 radio diag 2 | /dev/system_bus_freq 0660 system system 3 | /dev/cpu_dma_latency 0660 system system 4 | /dev/radio_feedback 0660 radio radio 5 | /dev/smd9 0600 system system 6 | /dev/ttyHS0 0660 bluetooth bluetooth -------------------------------------------------------------------------------- /vendorsetup.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # This file is executed by build/envsetup.sh, and can use anything 18 | # defined in envsetup.sh. 19 | # 20 | # In particular, you can add lunch options with the add_lunch_combo 21 | # function: add_lunch_combo generic-eng 22 | 23 | add_lunch_combo cyanogen_click-eng 24 | -------------------------------------------------------------------------------- /vold.fstab: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | ## Vold 2.0 fstab for HTC Tattoo 17 | # 18 | ## - San Mehat (san@android.com) 19 | ## 20 | 21 | ####################### 22 | ## Regular device mount 23 | ## 24 | ## Format: dev_mount