├── Android.mk ├── AndroidProducts.mk ├── BoardConfig.mk ├── audio ├── Android.mk ├── audio_hw.c ├── audio_hw.h ├── ril_interface.c └── ril_interface.h ├── bluetooth └── bdroid_buildcfg.h ├── configs ├── gps.xml ├── nfcee_access.xml ├── nfcee_access_debug.xml ├── tiny_hw.xml └── ums_init.sh ├── extract-files.sh ├── gps_daemon.sh ├── idc └── sec_e-pen.idc ├── keylayout ├── sec_e-pen.kl └── sec_touchkey.kl ├── libsensors ├── Android.mk ├── akm8963.c ├── bmp180.c ├── cm36651_light.c ├── cm36651_proximity.c ├── input.c ├── lsm330dlc_acceleration.c ├── lsm330dlc_gyroscope.c ├── noteII_sensors.c ├── noteII_sensors.h ├── ssp.c └── ssp.h ├── lineage.dependencies ├── lineage_n7100.mk ├── n7100.mk ├── overlay ├── frameworks │ └── base │ │ ├── Keyguard │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ ├── core │ │ └── res │ │ │ └── res │ │ │ ├── drawable-xhdpi │ │ │ ├── pointer_arrow.png │ │ │ ├── pointer_spot_anchor.png │ │ │ ├── pointer_spot_hover.png │ │ │ └── pointer_spot_touch.png │ │ │ ├── values │ │ │ ├── config.xml │ │ │ └── pa_config.xml │ │ │ └── xml │ │ │ ├── config_webview_packages.xml │ │ │ └── power_profile.xml │ │ └── packages │ │ └── SystemUI │ │ └── res │ │ └── values │ │ └── config.xml ├── packages │ └── apps │ │ ├── CMFileManager │ │ └── res │ │ │ └── xml │ │ │ └── command_list.xml │ │ ├── Camera2 │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ ├── CarrierConfig │ │ └── res │ │ │ └── xml │ │ │ └── vendor.xml │ │ ├── Dialer │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ ├── Lightbulb │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ └── Settings │ │ └── res │ │ └── values │ │ ├── bools.xml │ │ └── config.xml └── vendor │ └── lineagesdk │ └── lineage │ └── res │ └── res │ └── values │ └── config.xml ├── proprietary-files.txt ├── recovery.fstab ├── ril └── telephony │ └── java │ └── com │ └── android │ └── internal │ └── telephony │ └── SamsungExynos4RIL.java ├── rootdir ├── fstab.smdk4x12 ├── init.target.rc └── init.target.usb.rc ├── shims ├── Android.mk └── libgps-shim │ ├── Android.mk │ ├── gps.c │ └── gps.h ├── system.prop ├── vendor_prop.mk └── vendorsetup.sh /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 | LOCAL_PATH := $(call my-dir) 18 | 19 | ifeq ($(TARGET_DEVICE),n7100) 20 | 21 | include $(call all-makefiles-under,$(LOCAL_PATH)) 22 | 23 | endif 24 | -------------------------------------------------------------------------------- /AndroidProducts.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 | PRODUCT_MAKEFILES := \ 18 | $(LOCAL_DIR)/lineage_n7100.mk -------------------------------------------------------------------------------- /BoardConfig.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 variable is set first, so it can be overridden 18 | # by BoardConfigVendor.mk 19 | 20 | include device/samsung/smdk4412-common/BoardCommonConfig.mk 21 | 22 | # Wifi 23 | WIFI_DRIVER_MODULE_PATH := 24 | 25 | # Bionic 26 | MALLOC_SVELTE := true 27 | TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS := true 28 | LIBART_IMG_BASE := 0x30000000 29 | 30 | # Graphics 31 | TARGET_REQUIRES_SYNCHRONOUS_SETSURFACE := true 32 | 33 | # EGL blobs crash on screen off 34 | TARGET_SKIP_EGL_CONTEXT_DETACH := true 35 | 36 | # Bluetooth 37 | BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/samsung/n7100/bluetooth 38 | 39 | # Kernel 40 | TARGET_KERNEL_SOURCE := kernel/samsung/smdk4412 41 | TARGET_KERNEL_CONFIG := lineageos_n7100_defconfig 42 | 43 | TARGET_SPECIFIC_HEADER_PATH += device/samsung/n7100/include 44 | 45 | # Cache 46 | BOARD_CACHEIMAGE_PARTITION_SIZE := 104857600 47 | BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 48 | 49 | # Recovery 50 | TARGET_RECOVERY_FSTAB := device/samsung/n7100/rootdir/fstab.smdk4x12 51 | TARGET_RECOVERY_DENSITY := mdpi 52 | TARGET_USERIMAGES_USE_F2FS := true 53 | RECOVERY_FSTAB_VERSION := 2 54 | 55 | # assert 56 | TARGET_OTA_ASSERT_DEVICE := t03g,n7100,GT-N7100 57 | -------------------------------------------------------------------------------- /audio/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 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 | include $(CLEAR_VARS) 18 | 19 | LOCAL_MODULE := audio.primary.$(TARGET_BOOTLOADER_BOARD_NAME) 20 | LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 21 | LOCAL_MODULE_TAGS := optional 22 | 23 | LOCAL_SRC_FILES := audio_hw.c ril_interface.c 24 | 25 | LOCAL_C_INCLUDES += \ 26 | external/tinyalsa/include \ 27 | external/expat/lib \ 28 | $(call include-path-for, audio-utils) \ 29 | $(call include-path-for, audio-effects) 30 | 31 | LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl libexpat 32 | 33 | include $(BUILD_SHARED_LIBRARY) 34 | -------------------------------------------------------------------------------- /audio/audio_hw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * Copyright (C) 2012 Wolfson Microelectronics plc 4 | * Copyright (C) 2012 The CyanogenMod Project 5 | * Daniel Hillenbrand 6 | * Guillaume "XpLoDWilD" Lesniak 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /* ALSA cards for WM1811 */ 22 | #define CARD_DEFAULT 0 23 | 24 | #define PORT_PLAYBACK 0 25 | #define PORT_MODEM 1 26 | #define PORT_BT 2 27 | #define PORT_CAPTURE 3 28 | 29 | #define PCM_WRITE pcm_write 30 | 31 | #define PLAYBACK_PERIOD_SIZE 880 32 | #define PLAYBACK_PERIOD_COUNT 8 33 | #define PLAYBACK_SHORT_PERIOD_COUNT 2 34 | 35 | #define CAPTURE_PERIOD_SIZE 1024 36 | #define CAPTURE_PERIOD_COUNT 4 37 | 38 | #define SHORT_PERIOD_SIZE 192 39 | 40 | // 41 | // deep buffer 42 | // 43 | /* screen on */ 44 | #define DEEP_BUFFER_SHORT_PERIOD_SIZE 1056 45 | #define PLAYBACK_DEEP_BUFFER_SHORT_PERIOD_COUNT 4 46 | /* screen off */ 47 | #define DEEP_BUFFER_LONG_PERIOD_SIZE 880 48 | #define PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT 8 49 | 50 | 51 | /* minimum sleep time in out_write() when write threshold is not reached */ 52 | #define MIN_WRITE_SLEEP_US 5000 53 | 54 | #define RESAMPLER_BUFFER_FRAMES (PLAYBACK_PERIOD_SIZE * 2) 55 | #define RESAMPLER_BUFFER_SIZE (4 * RESAMPLER_BUFFER_FRAMES) 56 | 57 | #define DEFAULT_OUT_SAMPLING_RATE 44100 58 | #define MM_LOW_POWER_SAMPLING_RATE 44100 59 | #define MM_FULL_POWER_SAMPLING_RATE 44100 60 | #define DEFAULT_IN_SAMPLING_RATE 44100 61 | 62 | /* sampling rate when using VX port for narrow band */ 63 | #define VX_NB_SAMPLING_RATE 8000 64 | /* sampling rate when using VX port for wide band */ 65 | #define VX_WB_SAMPLING_RATE 16000 66 | 67 | /* product-specific defines */ 68 | #define PRODUCT_DEVICE_PROPERTY "ro.product.device" 69 | #define PRODUCT_NAME_PROPERTY "ro.product.name" 70 | 71 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 72 | 73 | #define STRING_TO_ENUM(string) { #string, string } 74 | 75 | struct string_to_enum { 76 | const char *name; 77 | uint32_t value; 78 | }; 79 | 80 | const struct string_to_enum out_channels_name_to_enum_table[] = { 81 | STRING_TO_ENUM(AUDIO_CHANNEL_OUT_STEREO), 82 | STRING_TO_ENUM(AUDIO_CHANNEL_OUT_5POINT1), 83 | STRING_TO_ENUM(AUDIO_CHANNEL_OUT_7POINT1), 84 | }; 85 | 86 | enum pcm_type { 87 | PCM_NORMAL = 0, 88 | PCM_SPDIF, 89 | PCM_HDMI, 90 | PCM_TOTAL, 91 | }; 92 | 93 | enum output_type { 94 | OUTPUT_DEEP_BUF, // deep PCM buffers output stream 95 | OUTPUT_LOW_LATENCY, // low latency output stream 96 | OUTPUT_HDMI, 97 | OUTPUT_TOTAL 98 | }; 99 | 100 | struct route_setting 101 | { 102 | char *ctl_name; 103 | int intval; 104 | char *strval; 105 | }; 106 | 107 | struct route_setting voicecall_default[] = { 108 | { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, }, 109 | { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, }, 110 | { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, }, 111 | { .ctl_name = "AIF2DACL Source", .intval = 0, }, 112 | { .ctl_name = "AIF2DACR Source", .intval = 0, }, 113 | { .ctl_name = "AIF2 Mode", .intval = 0, }, 114 | { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, }, 115 | { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, }, 116 | { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, }, 117 | { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, }, 118 | { .ctl_name = "AIF2DAC Mux", .strval = "AIF2DACDAT", }, 119 | { .ctl_name = NULL, }, 120 | }; 121 | 122 | struct route_setting voicecall_default_disable[] = { 123 | { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 0, }, 124 | { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 0, }, 125 | { .ctl_name = "AIF2DAC Mux", .strval = "AIF3DACDAT", }, 126 | { .ctl_name = "AIF2 Mode", .intval = 1, }, 127 | { .ctl_name = NULL, }, 128 | }; 129 | 130 | struct route_setting default_input[] = { 131 | { .ctl_name = "Main Mic Switch", .intval = 1, }, 132 | { .ctl_name = "MainMicBias Mode", .intval = 1, }, 133 | { .ctl_name = "AIF1ADCL Source", .intval = 0, }, 134 | { .ctl_name = "AIF2ADCL Source", .intval = 0, }, 135 | { .ctl_name = "MIXINL IN2L Switch", .intval = 1, }, 136 | { .ctl_name = "IN2L Volume", .intval = 25, }, 137 | { .ctl_name = "MIXINL IN2L Volume", .intval = 0, }, 138 | { .ctl_name = "AIF2ADC Volume", .intval = 96, }, 139 | { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, }, 140 | { .ctl_name = NULL, }, 141 | }; 142 | 143 | struct route_setting default_input_disable[] = { 144 | { .ctl_name = "Main Mic Switch", .intval = 0, }, 145 | { .ctl_name = "MainMicBias Mode", .intval = 0, }, 146 | { .ctl_name = "MIXINL IN2L Switch", .intval = 0, }, 147 | { .ctl_name = "AIF2DACL Source", .intval = 0, }, 148 | { .ctl_name = "AIF2DACR Source", .intval = 1, }, 149 | { .ctl_name = NULL, }, 150 | }; 151 | 152 | struct route_setting noise_suppression[] = { 153 | { .ctl_name = "Sub Mic Switch", .intval = 1, }, 154 | { .ctl_name = "SubMicBias Mode", .intval = 1, }, 155 | { .ctl_name = "IN1R Volume", .intval = 25, }, 156 | { .ctl_name = "MIXINR IN1R Switch", .intval = 1, }, 157 | { .ctl_name = "MIXINR IN1R Volume", .intval = 0, }, 158 | { .ctl_name = "AIF1ADCR Source", .intval = 1, }, 159 | { .ctl_name = NULL, }, 160 | }; 161 | struct route_setting noise_suppression_disable[] = { 162 | { .ctl_name = "Sub Mic Switch", .intval = 0, }, 163 | { .ctl_name = "SubMicBias Mode", .intval = 0, }, 164 | { .ctl_name = "MIXINR IN1R Switch", .intval = 0, }, 165 | { .ctl_name = "MIXINR IN1R Volume", .intval = 0, }, 166 | { .ctl_name = NULL, }, 167 | }; 168 | 169 | struct route_setting headset_input[] = { 170 | { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 0, }, 171 | { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 0, }, 172 | { .ctl_name = "Headphone ZC Switch", .intval = 0, }, 173 | { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, 174 | { .ctl_name = "AIF2DAC Volume", .intval = 96, }, 175 | { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, 176 | { .ctl_name = "AIF2 Boost Volume", .intval = 0, }, 177 | { .ctl_name = "DAC1 Volume", .intval = 96, }, 178 | { .ctl_name = "Headphone Volume", .intval = 49, }, 179 | { .ctl_name = "MIXINL IN2L Switch", .intval = 0, }, 180 | { .ctl_name = "MIXINR IN1R Switch", .intval = 0, }, 181 | { .ctl_name = "Headset Mic Switch", .intval = 1, }, 182 | { .ctl_name = "AIF1ADCL Source", .intval = 0, }, 183 | { .ctl_name = "AIF1ADCR Source", .intval = 0, }, 184 | { .ctl_name = "AIF2ADCL Source", .intval = 0, }, 185 | { .ctl_name = "MIXINL IN1L Switch", .intval = 1, }, 186 | { .ctl_name = "IN1L Volume", .intval = 28, }, 187 | { .ctl_name = "MIXINL IN1L Volume", .intval = 0, }, 188 | { .ctl_name = "DAC2 Left Sidetone Volume", .intval = 12, }, 189 | { .ctl_name = "AIF2ADC Volume", .intval = 96, }, 190 | { .ctl_name = "AIF2ADCL DRC Switch", .intval = 0, }, 191 | { .ctl_name = NULL, }, 192 | }; 193 | 194 | struct route_setting headset_input_disable[] = { 195 | { .ctl_name = "Headset Mic Switch", .intval = 0, }, 196 | { .ctl_name = "MIXINL IN1L Switch", .intval = 0, }, 197 | { .ctl_name = "AIF2DACL Source", .intval = 0, }, 198 | { .ctl_name = "AIF2DACR Source", .intval = 1, }, 199 | { .ctl_name = NULL, }, 200 | }; 201 | 202 | struct route_setting bt_output[] = { 203 | { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, 204 | { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, 205 | { .ctl_name = "DAC2 Volume", .intval = 96, }, 206 | { .ctl_name = "AIF2ADC Volume", .intval = 96, }, 207 | { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, }, 208 | { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, }, 209 | { .ctl_name = "AIF3ADC Mux", .intval = 1, }, 210 | { .ctl_name = "AIF2DAC2L Mixer AIF1.1 Switch", .intval = 1, }, 211 | { .ctl_name = "AIF2DAC2R Mixer AIF1.1 Switch", .intval = 1, }, 212 | { .ctl_name = "AIF2DAC Volume", .intval = 96, }, 213 | { .ctl_name = "MIXINL IN1L Volume", .intval = 1, }, 214 | { .ctl_name = "IN2L Volume", .intval = 28, }, 215 | { .ctl_name = "IN1R Volume", .intval = 28, }, 216 | { .ctl_name = "LINEOUT1N Switch", .intval = 0, }, 217 | { .ctl_name = "LINEOUT1P Switch", .intval = 0, }, 218 | { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, }, 219 | { .ctl_name = "AIF2ADC HPF Mode", .intval = 3, }, 220 | { .ctl_name = "AIF2ADC HPF Switch", .intval = 1, }, 221 | { .ctl_name = "AIF2DAC Mux", .strval = "AIF2DACDAT", }, 222 | { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 1, }, 223 | { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 1, }, 224 | { .ctl_name = NULL, }, 225 | }; 226 | 227 | struct route_setting bt_input[] = { 228 | { .ctl_name = "AIF2ADC Mux", .intval = 1, }, 229 | { .ctl_name = "AIF1ADCL Source", .intval = 0, }, 230 | { .ctl_name = "AIF1ADCR Source", .intval = 1, }, 231 | { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, }, 232 | { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, }, 233 | { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 1, }, 234 | { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 1, }, 235 | { .ctl_name = "AIF1ADC1 Volume", .intval = 96, }, 236 | { .ctl_name = "AIF2DAC Volume", .intval = 96, }, 237 | { .ctl_name = NULL, }, 238 | }; 239 | 240 | struct route_setting bt_disable[] = { 241 | { .ctl_name = "AIF1DAC1 Volume", .intval = 96, }, 242 | { .ctl_name = "AIF1 Boost Volume", .intval = 0, }, 243 | { .ctl_name = "DAC2 Volume", .intval = 96, }, 244 | { .ctl_name = "AIF2ADC Volume", .intval = 96, }, 245 | { .ctl_name = "AIF2ADC Mux", .intval = 0, }, 246 | { .ctl_name = "MIXINL IN1L Volume", .intval = 0, }, 247 | { .ctl_name = "LINEOUT1N Switch", .intval = 1, }, 248 | { .ctl_name = "LINEOUT1P Switch", .intval = 1, }, 249 | { .ctl_name = "AIF2ADC HPF Mode", .intval = 0, }, 250 | { .ctl_name = "AIF2ADC HPF Switch", .intval = 0, }, 251 | { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 0, }, 252 | { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 0, }, 253 | { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 0, }, 254 | { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 0, }, 255 | { .ctl_name = NULL, }, 256 | }; 257 | -------------------------------------------------------------------------------- /audio/ril_interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 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 | #define ALOG_TAG "audio_hw_primary" 18 | /*#define ALOG_NDEBUG 0*/ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include "ril_interface.h" 27 | 28 | #define VOLUME_STEPS_DEFAULT "5" 29 | #define VOLUME_STEPS_PROPERTY "ro.config.vc_call_vol_steps" 30 | 31 | /* Function pointers */ 32 | void *(*_ril_open_client)(void); 33 | int (*_ril_close_client)(void *); 34 | int (*_ril_connect)(void *); 35 | int (*_ril_is_connected)(void *); 36 | int (*_ril_disconnect)(void *); 37 | int (*_ril_set_call_volume)(void *, enum ril_sound_type, int); 38 | int (*_ril_set_call_audio_path)(void *, enum ril_audio_path); 39 | int (*_ril_set_call_clock_sync)(void *, enum ril_clock_state); 40 | int (*_ril_set_two_mic_control)(void *, enum ril_two_mic_device, enum ril_two_mic_state); 41 | int (*_ril_set_mic_mute)(void *, enum ril_mic_mute); 42 | int (*_ril_register_unsolicited_handler)(void *, int, void *); 43 | int (*_ril_get_wb_amr)(void *, void *); 44 | 45 | /* Audio WB AMR callback */ 46 | void (*_audio_set_wb_amr_callback)(void *, int); 47 | void *callback_data = NULL; 48 | 49 | void ril_register_set_wb_amr_callback(void *function, void *data) 50 | { 51 | _audio_set_wb_amr_callback = function; 52 | callback_data = data; 53 | } 54 | 55 | /* This is the callback function that the RIL uses to 56 | set the wideband AMR state */ 57 | static int ril_set_wb_amr_callback(void *ril_client, 58 | const void *data, 59 | size_t datalen) 60 | { 61 | int enable = ((int *)data)[0]; 62 | 63 | if (!callback_data || !_audio_set_wb_amr_callback) 64 | return -1; 65 | 66 | _audio_set_wb_amr_callback(callback_data, enable); 67 | 68 | return 0; 69 | } 70 | 71 | static int ril_connect_if_required(struct ril_handle *ril) 72 | { 73 | if (_ril_is_connected(ril->client)) 74 | return 0; 75 | 76 | if (_ril_connect(ril->client) != RIL_CLIENT_ERR_SUCCESS) { 77 | ALOGE("ril_connect() failed"); 78 | return -1; 79 | } 80 | 81 | /* get wb amr status to set pcm samplerate depending on 82 | wb amr status when ril is connected. */ 83 | if(_ril_get_wb_amr) 84 | _ril_get_wb_amr(ril->client, ril_set_wb_amr_callback); 85 | 86 | return 0; 87 | } 88 | 89 | int ril_open(struct ril_handle *ril) 90 | { 91 | char property[PROPERTY_VALUE_MAX]; 92 | 93 | if (!ril) 94 | return -1; 95 | 96 | ril->handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW); 97 | 98 | if (!ril->handle) { 99 | ALOGE("Cannot open '%s'", RIL_CLIENT_LIBPATH); 100 | return -1; 101 | } 102 | 103 | _ril_open_client = dlsym(ril->handle, "OpenClient_RILD"); 104 | _ril_close_client = dlsym(ril->handle, "CloseClient_RILD"); 105 | _ril_connect = dlsym(ril->handle, "Connect_RILD"); 106 | _ril_is_connected = dlsym(ril->handle, "isConnected_RILD"); 107 | _ril_disconnect = dlsym(ril->handle, "Disconnect_RILD"); 108 | _ril_set_call_volume = dlsym(ril->handle, "SetCallVolume"); 109 | _ril_set_call_audio_path = dlsym(ril->handle, "SetCallAudioPath"); 110 | _ril_set_call_clock_sync = dlsym(ril->handle, "SetCallClockSync"); 111 | _ril_set_two_mic_control = dlsym(ril->handle, "SetTwoMicControl"); 112 | _ril_set_mic_mute = dlsym(ril->handle, "SetMute"); 113 | _ril_register_unsolicited_handler = dlsym(ril->handle, 114 | "RegisterUnsolicitedHandler"); 115 | /* since this function is not supported in all RILs, don't require it */ 116 | _ril_get_wb_amr = dlsym(ril->handle, "GetWB_AMR"); 117 | 118 | if (!_ril_open_client || !_ril_close_client || !_ril_connect || 119 | !_ril_is_connected || !_ril_disconnect || !_ril_set_call_volume || 120 | !_ril_set_call_audio_path || !_ril_set_two_mic_control || !_ril_set_mic_mute || 121 | !_ril_set_call_clock_sync || !_ril_register_unsolicited_handler) { 122 | ALOGE("Cannot get symbols from '%s'", RIL_CLIENT_LIBPATH); 123 | dlclose(ril->handle); 124 | return -1; 125 | } 126 | 127 | ril->client = _ril_open_client(); 128 | if (!ril->client) { 129 | ALOGE("ril_open_client() failed"); 130 | dlclose(ril->handle); 131 | return -1; 132 | } 133 | 134 | /* register the wideband AMR callback */ 135 | _ril_register_unsolicited_handler(ril->client, RIL_UNSOL_WB_AMR_STATE, 136 | ril_set_wb_amr_callback); 137 | 138 | property_get(VOLUME_STEPS_PROPERTY, property, VOLUME_STEPS_DEFAULT); 139 | ril->volume_steps_max = atoi(property); 140 | /* this catches the case where VOLUME_STEPS_PROPERTY does not contain 141 | an integer */ 142 | if (ril->volume_steps_max == 0) 143 | ril->volume_steps_max = atoi(VOLUME_STEPS_DEFAULT); 144 | 145 | return 0; 146 | } 147 | 148 | int ril_close(struct ril_handle *ril) 149 | { 150 | if (!ril || !ril->handle || !ril->client) 151 | return -1; 152 | 153 | if ((_ril_disconnect(ril->client) != RIL_CLIENT_ERR_SUCCESS) || 154 | (_ril_close_client(ril->client) != RIL_CLIENT_ERR_SUCCESS)) { 155 | ALOGE("ril_disconnect() or ril_close_client() failed"); 156 | return -1; 157 | } 158 | 159 | dlclose(ril->handle); 160 | return 0; 161 | } 162 | 163 | int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type, 164 | float volume) 165 | { 166 | if (ril_connect_if_required(ril)) 167 | return 0; 168 | 169 | return _ril_set_call_volume(ril->client, sound_type, 170 | (int)(volume * ril->volume_steps_max)); 171 | } 172 | 173 | int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path) 174 | { 175 | if (ril_connect_if_required(ril)) 176 | return 0; 177 | 178 | return _ril_set_call_audio_path(ril->client, path); 179 | } 180 | 181 | int ril_set_call_clock_sync(struct ril_handle *ril, enum ril_clock_state state) 182 | { 183 | if (ril_connect_if_required(ril)) 184 | return 0; 185 | 186 | return _ril_set_call_clock_sync(ril->client, state); 187 | } 188 | 189 | int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device device, enum ril_two_mic_state state) 190 | { 191 | if (ril_connect_if_required(ril)) 192 | return 0; 193 | 194 | return _ril_set_two_mic_control(ril->client, device, state); 195 | } 196 | 197 | int ril_set_mic_mute(struct ril_handle *ril, enum ril_mic_mute state) 198 | { 199 | if (ril_connect_if_required(ril)) 200 | return 0; 201 | 202 | return _ril_set_mic_mute(ril->client, state); 203 | } 204 | -------------------------------------------------------------------------------- /audio/ril_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 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 RIL_INTERFACE_H 18 | #define RIL_INTERFACE_H 19 | 20 | #define RIL_CLIENT_LIBPATH "libsecril-client.so" 21 | 22 | #define RIL_CLIENT_ERR_SUCCESS 0 23 | #define RIL_CLIENT_ERR_AGAIN 1 24 | #define RIL_CLIENT_ERR_INIT 2 // Client is not initialized 25 | #define RIL_CLIENT_ERR_INVAL 3 // Invalid value 26 | #define RIL_CLIENT_ERR_CONNECT 4 // Connection error 27 | #define RIL_CLIENT_ERR_IO 5 // IO error 28 | #define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available 29 | #define RIL_CLIENT_ERR_UNKNOWN 7 30 | 31 | #define RIL_OEM_UNSOL_RESPONSE_BASE 11000 // RIL response base index 32 | #define RIL_UNSOL_WB_AMR_STATE \ 33 | (RIL_OEM_UNSOL_RESPONSE_BASE + 17) // RIL AMR state index 34 | 35 | struct ril_handle 36 | { 37 | void *handle; 38 | void *client; 39 | int volume_steps_max; 40 | }; 41 | 42 | enum ril_sound_type { 43 | SOUND_TYPE_VOICE, 44 | SOUND_TYPE_SPEAKER, 45 | SOUND_TYPE_HEADSET, 46 | SOUND_TYPE_BTVOICE 47 | }; 48 | 49 | enum ril_audio_path { 50 | SOUND_AUDIO_PATH_HANDSET, 51 | SOUND_AUDIO_PATH_HEADSET, 52 | SOUND_AUDIO_PATH_SPEAKER, 53 | SOUND_AUDIO_PATH_BLUETOOTH, 54 | SOUND_AUDIO_PATH_BLUETOOTH_NO_NR, 55 | SOUND_AUDIO_PATH_HEADPHONE 56 | }; 57 | 58 | enum ril_clock_state { 59 | SOUND_CLOCK_STOP, 60 | SOUND_CLOCK_START 61 | }; 62 | 63 | enum ril_two_mic_device { 64 | AUDIENCE, 65 | FORTEMEDIA 66 | }; 67 | 68 | enum ril_two_mic_state { 69 | TWO_MIC_SOLUTION_OFF, 70 | TWO_MIC_SOLUTION_ON 71 | }; 72 | 73 | enum ril_mic_mute { 74 | MIC_UNMUTE, 75 | MIC_MUTE 76 | }; 77 | 78 | /* Function prototypes */ 79 | int ril_open(struct ril_handle *ril); 80 | int ril_close(struct ril_handle *ril); 81 | int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type, 82 | float volume); 83 | int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path); 84 | int ril_set_call_clock_sync(struct ril_handle *ril, enum ril_clock_state state); 85 | void ril_register_set_wb_amr_callback(void *function, void *data); 86 | int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device device, enum ril_two_mic_state state); 87 | int ril_set_mic_mute(struct ril_handle *ril, enum ril_mic_mute state); 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /bluetooth/bdroid_buildcfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * Copyright (C) 2012 The CyanogenMod 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 | 18 | #ifndef _BDROID_BUILDCFG_H 19 | #define _BDROID_BUILDCFG_H 20 | 21 | #define BTM_DEF_LOCAL_NAME "GT-N7100" 22 | 23 | /* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */ 24 | #define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /configs/gps.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 39 | 40 | 48 | 49 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /configs/nfcee_access.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /configs/nfcee_access_debug.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /configs/tiny_hw.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | -------------------------------------------------------------------------------- /configs/ums_init.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | BB=/system/xbin/busybox 3 | LUN_NUM=2 4 | LUN_PATH="/sys/class/android_usb/f_mass_storage/lun%d/file" 5 | VOLD_MANAGED=$( $BB mount | $BB grep "vold" | $BB cut -d " " -f1 |\ 6 | $BB sort -u | $BB head -n $LUN_NUM | $BB tr "\n" " " ) 7 | i=0 8 | for VOLUME in $VOLD_MANAGED 9 | do 10 | LUN=$($BB printf $LUN_PATH $i) 11 | $BB echo $VOLUME > $LUN 12 | i=$(($i + 1)) 13 | done 14 | -------------------------------------------------------------------------------- /extract-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2017 The LineageOS 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 | set -e 18 | 19 | export VENDOR=samsung 20 | export DEVICE=n7100 21 | 22 | ./../smdk4412-common/extract-files.sh $@ 23 | -------------------------------------------------------------------------------- /gps_daemon.sh: -------------------------------------------------------------------------------- 1 | #shellscript as this is the only way selinux will allow this to proceed 2 | /vendor/bin/glgps -------------------------------------------------------------------------------- /idc/sec_e-pen.idc: -------------------------------------------------------------------------------- 1 | touch.deviceType = pointer 2 | touch.orientationAware = 1 3 | -------------------------------------------------------------------------------- /keylayout/sec_e-pen.kl: -------------------------------------------------------------------------------- 1 | key 560 PDCT 2 | 3 | -------------------------------------------------------------------------------- /keylayout/sec_touchkey.kl: -------------------------------------------------------------------------------- 1 | key 158 BACK VIRTUAL 2 | key 139 MENU VIRTUAL 3 | -------------------------------------------------------------------------------- /libsensors/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Răileanu Cosmin 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | # 17 | 18 | LOCAL_PATH := $(call my-dir) 19 | 20 | include $(CLEAR_VARS) 21 | 22 | LOCAL_SRC_FILES := \ 23 | noteII_sensors.c \ 24 | input.c \ 25 | ssp.c \ 26 | akm8963.c \ 27 | cm36651_proximity.c \ 28 | cm36651_light.c \ 29 | lsm330dlc_acceleration.c \ 30 | lsm330dlc_gyroscope.c \ 31 | bmp180.c 32 | 33 | LOCAL_C_INCLUDES := \ 34 | $(LOCAL_PATH) 35 | 36 | LOCAL_SHARED_LIBRARIES := libutils libcutils liblog libhardware 37 | LOCAL_PRELINK_MODULE := false 38 | 39 | LOCAL_MODULE := sensors.$(TARGET_BOOTLOADER_BOARD_NAME) 40 | LOCAL_MODULE_RELATIVE_PATH := hw 41 | LOCAL_VENDOR_MODULE := true 42 | LOCAL_MODULE_TAGS := optional 43 | 44 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /libsensors/akm8963.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #define LOG_TAG "Akm_NoteII" 29 | #include 30 | 31 | #include "noteII_sensors.h" 32 | #include "ssp.h" 33 | 34 | #define AKM8963_CONFIG_PATH "/data/misc/akmd_set.txt" 35 | 36 | extern int mFlushed; 37 | 38 | struct akm8963_data { 39 | sensors_vec_t magnetic; 40 | short magnetic_data[4][3]; 41 | int magnetic_data_count; 42 | int magnetic_data_index; 43 | 44 | short magnetic_extrema[2][3]; 45 | unsigned char asa[3]; 46 | int ho[3]; 47 | 48 | int64_t delay; 49 | int device_fd; 50 | int uinput_fd; 51 | 52 | pthread_t thread; 53 | pthread_mutex_t mutex; 54 | int thread_continue; 55 | }; 56 | 57 | // This AKM8963 implementation is based on 58 | // REPLICANT sensor code for N7100 and AKM8963 documentation 59 | 60 | int akm8963_magnetic_extrema(struct akm8963_data *data, int index) 61 | { 62 | if (data == NULL || index < 0 || index >= 3) 63 | return -EINVAL; 64 | 65 | // Calculate the extrema from HO (software offset) 66 | data->magnetic_extrema[0][index] = (short) ((-45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); 67 | data->magnetic_extrema[1][index] = (short) ((45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); 68 | 69 | return 0; 70 | } 71 | 72 | int akm8963_config_read(struct akm8963_data *data) 73 | { 74 | char buffer[256] = { 0 }; 75 | int config_fd = -1; 76 | int offset = 0; 77 | int length; 78 | int count; 79 | int value; 80 | char *p; 81 | int rc; 82 | 83 | if (data == NULL) 84 | return -EINVAL; 85 | 86 | config_fd = open(AKM8963_CONFIG_PATH, O_RDONLY); 87 | if (config_fd < 0) { 88 | //ALOGD("%s: Unable to open akm8963 config %d %s", __func__, errno, strerror(errno)); 89 | goto error; 90 | } 91 | 92 | rc = 0; 93 | 94 | do { 95 | lseek(config_fd, offset, SEEK_SET); 96 | 97 | length = read(config_fd, buffer, sizeof(buffer)); 98 | if (length <= 0) 99 | break; 100 | 101 | p = strchr((const char *) &buffer, '\n'); 102 | if (p != NULL) { 103 | offset += (int) p - (int) buffer + 1; 104 | *p = '\0'; 105 | } else if ((size_t) length < sizeof(buffer)) { 106 | buffer[length] = '\0'; 107 | } 108 | 109 | count = sscanf((char const *) &buffer, "HSUC_HO_FORM0.x = %d", &value); 110 | if (count == 1) { 111 | data->ho[0] = value; 112 | rc |= akm8963_magnetic_extrema(data, 0); 113 | } 114 | 115 | count = sscanf((char const *) &buffer, "HSUC_HO_FORM0.y = %d", &value); 116 | if (count == 1) { 117 | data->ho[1] = value; 118 | rc |= akm8963_magnetic_extrema(data, 1); 119 | } 120 | 121 | count = sscanf((char const *) &buffer, "HSUC_HO_FORM0.z = %d", &value); 122 | if (count == 1) { 123 | data->ho[2] = value; 124 | rc |= akm8963_magnetic_extrema(data, 2); 125 | } 126 | } while (p != NULL && length > 0); 127 | 128 | goto complete; 129 | 130 | error: 131 | rc = -1; 132 | 133 | complete: 134 | if (config_fd >= 0) 135 | close(config_fd); 136 | 137 | return rc; 138 | } 139 | 140 | int akm8963_config_write(struct akm8963_data *data) 141 | { 142 | char buffer[256] = { 0 }; 143 | int config_fd = -1; 144 | int length; 145 | int value; 146 | int rc; 147 | 148 | if (data == NULL) 149 | return -EINVAL; 150 | 151 | config_fd = open(AKM8963_CONFIG_PATH, O_WRONLY | O_TRUNC | O_CREAT, 0664); 152 | if (config_fd < 0) { 153 | //ALOGD("%s: Unable to open akm8963 config", __func__); 154 | goto error; 155 | } 156 | 157 | value = (int) data->ho[0]; 158 | length = snprintf((char *) &buffer, sizeof(buffer), "HSUC_HO_FORM0.x = %d\n", value); 159 | 160 | rc = write(config_fd, buffer, length); 161 | if (rc < length) { 162 | //ALOGD("%s: Unable to write akm8963 config", __func__); 163 | goto error; 164 | } 165 | 166 | value = (int) data->ho[1]; 167 | length = snprintf((char *) &buffer, sizeof(buffer), "HSUC_HO_FORM0.y = %d\n", value); 168 | 169 | rc = write(config_fd, buffer, length); 170 | if (rc < length) { 171 | //ALOGD("%s: Unable to write akm8963 config", __func__); 172 | goto error; 173 | } 174 | 175 | value = (int) data->ho[2]; 176 | length = snprintf((char *) &buffer, sizeof(buffer), "HSUC_HO_FORM0.z = %d\n", value); 177 | 178 | rc = write(config_fd, buffer, length); 179 | if (rc < length) { 180 | //ALOGD("%s: Unable to write akm8963 config", __func__); 181 | goto error; 182 | } 183 | 184 | rc = 0; 185 | goto complete; 186 | 187 | error: 188 | rc = -1; 189 | 190 | complete: 191 | if (config_fd >= 0) 192 | close(config_fd); 193 | 194 | return rc; 195 | } 196 | 197 | int akm8963_ho_calibration(struct akm8963_data *data, 198 | short *magnetic_data, size_t magnetic_data_size) 199 | { 200 | float ho[2]; 201 | int gain_index; 202 | int i; 203 | 204 | if (data == NULL || magnetic_data == NULL || magnetic_data_size < 3) 205 | return -EINVAL; 206 | 207 | // Update the extrema from the current raw magnetic data 208 | for (i = 0; i < 3; i++) { 209 | if (magnetic_data[i] < data->magnetic_extrema[0][i] || data->magnetic_extrema[0][i] == 0) 210 | data->magnetic_extrema[0][i] = magnetic_data[i]; 211 | if (magnetic_data[i] > data->magnetic_extrema[1][i] || data->magnetic_extrema[1][i] == 0) 212 | data->magnetic_extrema[1][i] = magnetic_data[i]; 213 | } 214 | 215 | // Calculate HO (software offset) 216 | if (data->magnetic_data_count % 10 == 0) { 217 | for (i = 0; i < 3; i++) { 218 | // Calculate offset for minimum to be at -45uT 219 | ho[0] = (0.15f * (((data->asa[i] - 128) * 0.5f) / 128 + 1) * data->magnetic_extrema[0][i] + 45.0f) / 0.06f; 220 | // Calculate offset for maximum to be at +45uT 221 | ho[1] = (0.15f * (((data->asa[i] - 128) * 0.5f) / 128 + 1) * data->magnetic_extrema[1][i] - 45.0f) / 0.06f; 222 | // Average offset to make everyone (mostly) happy 223 | data->ho[i] = (int) (ho[0] + ho[1]) / 2.0f; 224 | } 225 | } 226 | 227 | return 0; 228 | } 229 | 230 | int akm8963_magnetic_axis(struct akm8963_data *data, int index, float *axis) 231 | { 232 | float value; 233 | int count; 234 | int i; 235 | 236 | if (data == NULL || axis == NULL || index < 0 || index >= 3) 237 | return -EINVAL; 238 | 239 | count = data->magnetic_data_count >= 4 ? 4 : data->magnetic_data_count; 240 | value = 0; 241 | 242 | // Average the last 4 (or less) raw magnetic values 243 | for (i = 0; i < count; i++) 244 | value += (float) data->magnetic_data[i][index]; 245 | value /= count; 246 | 247 | // Adjust sensitivity using ASA value 248 | value *= (((data->asa[index] - 128) * 0.5f) / 128 + 1); 249 | 250 | // Magnetic field value in uT from corrected value and HO offset 251 | *axis = 0.15f * value - 0.06f * data->ho[index]; 252 | 253 | return 0; 254 | } 255 | 256 | int akm8963_magnetic(struct akm8963_data *data) 257 | { 258 | int rc; 259 | 260 | if (data == NULL) 261 | return -EINVAL; 262 | 263 | rc = 0; 264 | rc |= akm8963_magnetic_axis(data, 0, &data->magnetic.x); 265 | rc |= akm8963_magnetic_axis(data, 1, &data->magnetic.y); 266 | rc |= akm8963_magnetic_axis(data, 2, &data->magnetic.z); 267 | 268 | return rc; 269 | } 270 | 271 | void *akm8963_thread(void *thread_data) 272 | { 273 | struct noteII_sensors_handlers *handlers = NULL; 274 | struct akm8963_data *data = NULL; 275 | struct input_event event; 276 | struct timeval time; 277 | unsigned char i2c_data[8] = { 0 }; 278 | short magnetic_data[3] = { 0 }; 279 | int index; 280 | long int before, after; 281 | int diff; 282 | int device_fd; 283 | int uinput_fd; 284 | int rc; 285 | 286 | if (thread_data == NULL) 287 | return NULL; 288 | 289 | handlers = (struct noteII_sensors_handlers *) thread_data; 290 | if (handlers->data == NULL) 291 | return NULL; 292 | 293 | data = (struct akm8963_data *) handlers->data; 294 | 295 | device_fd = data->device_fd; 296 | if (device_fd < 0) 297 | return NULL; 298 | 299 | uinput_fd = data->uinput_fd; 300 | if (uinput_fd < 0) 301 | return NULL; 302 | 303 | while (data->thread_continue) { 304 | pthread_mutex_lock(&data->mutex); 305 | if (!data->thread_continue) 306 | break; 307 | 308 | while (handlers->activated) { 309 | gettimeofday(&time, NULL); 310 | before = timestamp(&time); 311 | 312 | memset(&i2c_data, 0, sizeof(i2c_data)); 313 | rc = ioctl(device_fd, ECS_IOCTL_GET_MAGDATA, &i2c_data); 314 | if (rc < 0) { 315 | //ALOGD("%s: Unable to get akm8963 data", __func__); 316 | goto next; 317 | } 318 | 319 | if (!(i2c_data[0] & 0x01)) { 320 | //ALOGD("%s: akm8963 data is not ready", __func__); 321 | goto next; 322 | } 323 | 324 | magnetic_data[0] = (short) ((i2c_data[2] << 8) | (i2c_data[1] & 0xff)); 325 | magnetic_data[1] = (short) ((i2c_data[4] << 8) | (i2c_data[3] & 0xff)); 326 | magnetic_data[2] = (short) ((i2c_data[6] << 8) | (i2c_data[5] & 0xff)); 327 | 328 | index = data->magnetic_data_index; 329 | 330 | data->magnetic_data[index][0] = magnetic_data[0]; 331 | data->magnetic_data[index][1] = magnetic_data[1]; 332 | data->magnetic_data[index][2] = magnetic_data[2]; 333 | 334 | data->magnetic_data_index = (index + 1) % 4; 335 | data->magnetic_data_count++; 336 | 337 | rc = akm8963_ho_calibration(data, (short *) &magnetic_data, sizeof(magnetic_data)); 338 | if (rc < 0) { 339 | //ALOGD("%s: Unable to calibrate akm8963 HO", __func__); 340 | goto next; 341 | } 342 | 343 | rc = akm8963_magnetic(data); 344 | if (rc < 0) { 345 | //ALOGD("%s: Unable to get akm8963 magnetic", __func__); 346 | goto next; 347 | } 348 | 349 | input_event_set(&event, EV_REL, REL_X, (int) (data->magnetic.x * 1000)); 350 | write(uinput_fd, &event, sizeof(event)); 351 | input_event_set(&event, EV_REL, REL_Y, (int) (data->magnetic.y * 1000)); 352 | write(uinput_fd, &event, sizeof(event)); 353 | input_event_set(&event, EV_REL, REL_Z, (int) (data->magnetic.z * 1000)); 354 | write(uinput_fd, &event, sizeof(event)); 355 | input_event_set(&event, EV_REL, REL_MISC, (int) data->magnetic.status); 356 | write(uinput_fd, &event, sizeof(event)); 357 | input_event_set(&event, EV_SYN, 0, 0); 358 | write(uinput_fd, &event, sizeof(event)); 359 | 360 | next: 361 | gettimeofday(&time, NULL); 362 | after = timestamp(&time); 363 | 364 | diff = (int) (data->delay - (after - before)) / 1000; 365 | if (diff <= 0) 366 | continue; 367 | 368 | usleep(diff); 369 | } 370 | } 371 | return NULL; 372 | } 373 | 374 | int akm8963_init(struct noteII_sensors_handlers *handlers, 375 | struct smdk4x12_sensors_device *device) 376 | { 377 | struct akm8963_data *data = NULL; 378 | pthread_attr_t thread_attr; 379 | int device_fd = -1; 380 | int uinput_fd = -1; 381 | int input_fd = -1; 382 | int rc; 383 | int i; 384 | 385 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 386 | 387 | if (handlers == NULL || device == NULL) 388 | return -EINVAL; 389 | 390 | data = (struct akm8963_data *) calloc(1, sizeof(struct akm8963_data)); 391 | 392 | device_fd = open("/dev/akm8963", O_RDONLY); 393 | if (device_fd < 0) { 394 | //ALOGD("%s: Unable to open device", __func__); 395 | goto error; 396 | } 397 | 398 | rc = ioctl(device_fd, ECS_IOCTL_GET_FUSEROMDATA, &data->asa); 399 | if (rc < 0) { 400 | //ALOGD("%s: Unable to get akm8963 FUSE ROM data", __func__); 401 | goto error; 402 | } 403 | 404 | //ALOGD("AKM8963 ASA (Sensitivity Adjustment) values are: (%d, %d, %d)", 405 | //data->asa[0], data->asa[1], data->asa[2]); 406 | 407 | uinput_fd = uinput_rel_create("magnetic_sensor"); 408 | if (uinput_fd < 0) { 409 | //ALOGD("%s: Unable to create uinput", __func__); 410 | goto error; 411 | } 412 | 413 | input_fd = input_open("magnetic_sensor"); 414 | if (input_fd < 0) { 415 | //ALOGD("%s: Unable to open magnetic input", __func__); 416 | goto error; 417 | } 418 | 419 | data->thread_continue = 1; 420 | 421 | pthread_mutex_init(&data->mutex, NULL); 422 | pthread_mutex_lock(&data->mutex); 423 | 424 | pthread_attr_init(&thread_attr); 425 | pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); 426 | 427 | rc = pthread_create(&data->thread, &thread_attr, akm8963_thread, (void *) handlers); 428 | if (rc < 0) { 429 | //ALOGD("%s: Unable to create akm8963 thread", __func__); 430 | pthread_mutex_destroy(&data->mutex); 431 | goto error; 432 | } 433 | 434 | data->device_fd = device_fd; 435 | data->uinput_fd = uinput_fd; 436 | handlers->poll_fd = input_fd; 437 | handlers->data = (void *) data; 438 | 439 | return 0; 440 | 441 | error: 442 | if (data != NULL) 443 | free(data); 444 | 445 | if (uinput_fd >= 0) 446 | close(uinput_fd); 447 | 448 | if (input_fd >= 0) 449 | close(input_fd); 450 | 451 | if (device_fd >= 0) 452 | close(device_fd); 453 | 454 | handlers->poll_fd = -1; 455 | handlers->data = NULL; 456 | 457 | return -1; 458 | } 459 | 460 | int akm8963_deinit(struct noteII_sensors_handlers *handlers) 461 | { 462 | struct akm8963_data *data = NULL; 463 | int rc; 464 | 465 | //ALOGD("%s(%p)", __func__, handlers); 466 | 467 | if (handlers == NULL || handlers->data == NULL) 468 | return -EINVAL; 469 | 470 | data = (struct akm8963_data *) handlers->data; 471 | 472 | handlers->activated = 0; 473 | data->thread_continue = 0; 474 | pthread_mutex_unlock(&data->mutex); 475 | 476 | pthread_mutex_destroy(&data->mutex); 477 | 478 | if (data->uinput_fd >= 0) { 479 | uinput_destroy(data->uinput_fd); 480 | close(data->uinput_fd); 481 | } 482 | data->uinput_fd = -1; 483 | 484 | if (handlers->poll_fd >= 0) 485 | close(handlers->poll_fd); 486 | handlers->poll_fd = -1; 487 | 488 | if (data->device_fd >= 0) 489 | close(data->device_fd); 490 | data->device_fd = -1; 491 | 492 | free(handlers->data); 493 | handlers->data = NULL; 494 | 495 | return 0; 496 | } 497 | 498 | int akm8963_activate(struct noteII_sensors_handlers *handlers) 499 | { 500 | struct akm8963_data *data; 501 | int rc; 502 | 503 | //ALOGD("%s(%p)", __func__, handlers); 504 | 505 | if (handlers == NULL || handlers->data == NULL) 506 | return -EINVAL; 507 | 508 | data = (struct akm8963_data *) handlers->data; 509 | 510 | rc = akm8963_config_read(data); 511 | if (rc < 0) { 512 | //ALOGD("%s: Unable to read akm8963 config", __func__); 513 | } 514 | 515 | rc = ssp_sensor_enable(GEOMAGNETIC_SENSOR); 516 | if (rc < 0) { 517 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 518 | return -1; 519 | } 520 | 521 | handlers->activated = 1; 522 | pthread_mutex_unlock(&data->mutex); 523 | 524 | return 0; 525 | } 526 | 527 | int akm8963_deactivate(struct noteII_sensors_handlers *handlers) 528 | { 529 | struct akm8963_data *data; 530 | int empty; 531 | int rc; 532 | int i; 533 | 534 | //ALOGD("%s(%p)", __func__, handlers); 535 | 536 | if (handlers == NULL || handlers->data == NULL) 537 | return -EINVAL; 538 | 539 | data = (struct akm8963_data *) handlers->data; 540 | 541 | empty = 1; 542 | 543 | for (i = 0; i < (ssize_t) (sizeof(data->magnetic_extrema) / (sizeof(short) * 2)); i++) { 544 | if (data->magnetic_extrema[0][i] != 0 || data->magnetic_extrema[1][i] != 0) { 545 | empty = 0; 546 | break; 547 | } 548 | } 549 | 550 | if (!empty) { 551 | rc = akm8963_config_write(data); 552 | // if (rc < 0) 553 | //ALOGD("%s: Unable to write akm8963 config", __func__); 554 | } 555 | 556 | rc = ssp_sensor_disable(GEOMAGNETIC_SENSOR); 557 | if (rc < 0) { 558 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 559 | return -1; 560 | } 561 | 562 | handlers->activated = 0; 563 | 564 | return 0; 565 | } 566 | 567 | int akm8963_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 568 | { 569 | struct akm8963_data *data; 570 | char mag_path_delay[PATH_MAX] = "/sys/class/sensors/ssp_sensor/mag_poll_delay"; 571 | char ori_path_delay[PATH_MAX] = "/sys/class/sensors/ssp_sensor/ori_poll_delay"; 572 | int rc; 573 | int orirc; 574 | 575 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 576 | 577 | if (handlers == NULL || handlers->data == NULL) 578 | return -EINVAL; 579 | 580 | data = (struct akm8963_data *) handlers->data; 581 | 582 | rc = sysfs_value_write(mag_path_delay, (int) delay); 583 | orirc = sysfs_value_write(ori_path_delay, (int) delay); 584 | if (rc < 0 || orirc < 0) { 585 | //ALOGD("%s: Unable to write sysfs value", __func__); 586 | return -1; 587 | } 588 | 589 | data->delay = delay; 590 | 591 | return 0; 592 | } 593 | 594 | float akm8963_convert(int value) 595 | { 596 | return (float) value / 1000.0f; 597 | } 598 | 599 | int akm8963_get_data(struct noteII_sensors_handlers *handlers, 600 | struct sensors_event_t *event) 601 | { 602 | struct akm8963_data *data; 603 | struct input_event input_event; 604 | int input_fd; 605 | int rc; 606 | 607 | int sensorId = SENSOR_TYPE_MAGNETIC_FIELD; 608 | 609 | if (handlers == NULL || handlers->data == NULL || event == NULL) 610 | return -EINVAL; 611 | 612 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 613 | sensors_event_t sensor_event; 614 | memset(&sensor_event, 0, sizeof(sensor_event)); 615 | sensor_event.version = META_DATA_VERSION; 616 | sensor_event.type = SENSOR_TYPE_META_DATA; 617 | sensor_event.meta_data.sensor = sensorId; 618 | sensor_event.meta_data.what = 0; 619 | *event++ = sensor_event; 620 | mFlushed &= ~(0x01 << sensorId); 621 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 622 | } 623 | 624 | data = (struct akm8963_data *) handlers->data; 625 | 626 | input_fd = handlers->poll_fd; 627 | if (input_fd < 0) 628 | return -1; 629 | 630 | memset(event, 0, sizeof(struct sensors_event_t)); 631 | event->version = sizeof(struct sensors_event_t); 632 | event->sensor = handlers->handle; 633 | event->type = handlers->handle; 634 | 635 | do { 636 | rc = read(input_fd, &input_event, sizeof(input_event)); 637 | if (rc < (int) sizeof(input_event)) 638 | break; 639 | 640 | if (input_event.type == EV_REL) { 641 | switch (input_event.code) { 642 | case REL_X: 643 | event->magnetic.x = akm8963_convert(input_event.value); 644 | break; 645 | case REL_Y: 646 | event->magnetic.y = akm8963_convert(input_event.value); 647 | break; 648 | case REL_Z: 649 | event->magnetic.z = akm8963_convert(input_event.value); 650 | break; 651 | case REL_MISC: 652 | event->magnetic.status = input_event.value; 653 | break; 654 | default: 655 | continue; 656 | } 657 | } else if (input_event.type == EV_SYN) { 658 | if (input_event.code == SYN_REPORT) 659 | event->timestamp = getTimestamp(); 660 | } 661 | } while (input_event.type != EV_SYN); 662 | 663 | return 0; 664 | } 665 | 666 | struct noteII_sensors_handlers akm8963 = { 667 | .name = "AKM8963", 668 | .handle = SENSOR_TYPE_MAGNETIC_FIELD, 669 | .init = akm8963_init, 670 | .deinit = akm8963_deinit, 671 | .activate = akm8963_activate, 672 | .deactivate = akm8963_deactivate, 673 | .set_delay = akm8963_set_delay, 674 | .get_data = akm8963_get_data, 675 | .activated = 0, 676 | .needed = 0, 677 | .poll_fd = -1, 678 | .data = NULL, 679 | }; 680 | -------------------------------------------------------------------------------- /libsensors/bmp180.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #define LOG_TAG "Pressure_NoteII" 33 | #include 34 | 35 | #include "noteII_sensors.h" 36 | #include "ssp.h" 37 | 38 | extern int mFlushed; 39 | 40 | struct bmp180_data { 41 | char path_delay[PATH_MAX]; 42 | }; 43 | 44 | int bmp180_init(struct noteII_sensors_handlers *handlers, 45 | struct smdk4x12_sensors_device *device) 46 | { 47 | struct bmp180_data *data = NULL; 48 | char path[PATH_MAX] = { 0 }; 49 | int input_fd = -1; 50 | int rc; 51 | 52 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 53 | 54 | if (handlers == NULL) 55 | return -EINVAL; 56 | 57 | data = (struct bmp180_data *) calloc(1, sizeof(struct bmp180_data)); 58 | 59 | input_fd = input_open("pressure_sensor"); 60 | if (input_fd < 0) { 61 | //ALOGD("%s: Unable to open input", __func__); 62 | goto error; 63 | } 64 | 65 | rc = sysfs_path_prefix("pressure_sensor", (char *) &path); 66 | if (rc < 0 || path[0] == '\0') { 67 | //ALOGD("%s: Unable to open sysfs", __func__); 68 | goto error; 69 | } 70 | 71 | int sf = snprintf(data->path_delay, PATH_MAX, "%s/poll_delay", path); 72 | if(sf <= 0) 73 | { 74 | //ALOGD("Pressure HAS FAILED !POLL_DELAY!"); 75 | goto error; 76 | } 77 | 78 | handlers->poll_fd = input_fd; 79 | handlers->data = (void *) data; 80 | 81 | return 0; 82 | 83 | error: 84 | if (data != NULL) 85 | free(data); 86 | 87 | if (input_fd >= 0) 88 | close(input_fd); 89 | 90 | handlers->poll_fd = -1; 91 | handlers->data = NULL; 92 | 93 | return -1; 94 | } 95 | 96 | int bmp180_deinit(struct noteII_sensors_handlers *handlers) 97 | { 98 | //ALOGD("%s(%p)", __func__, handlers); 99 | 100 | if (handlers == NULL) 101 | return -EINVAL; 102 | 103 | if (handlers->poll_fd >= 0) 104 | close(handlers->poll_fd); 105 | handlers->poll_fd = -1; 106 | 107 | if (handlers->data != NULL) 108 | free(handlers->data); 109 | handlers->data = NULL; 110 | 111 | return 0; 112 | } 113 | 114 | int bmp180_activate(struct noteII_sensors_handlers *handlers) 115 | { 116 | struct bmp180_data *data; 117 | int rc; 118 | 119 | //ALOGD("%s(%p)", __func__, handlers); 120 | 121 | if (handlers == NULL || handlers->data == NULL) 122 | return -EINVAL; 123 | 124 | data = (struct bmp180_data *) handlers->data; 125 | 126 | rc = ssp_sensor_enable(PRESSURE_SENSOR); 127 | if (rc < 0) { 128 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 129 | return -1; 130 | } 131 | 132 | handlers->activated = 1; 133 | 134 | return 0; 135 | } 136 | 137 | int bmp180_deactivate(struct noteII_sensors_handlers *handlers) 138 | { 139 | struct bmp180_data *data; 140 | int rc; 141 | 142 | //ALOGD("%s(%p)", __func__, handlers); 143 | 144 | if (handlers == NULL || handlers->data == NULL) 145 | return -EINVAL; 146 | 147 | data = (struct bmp180_data *) handlers->data; 148 | 149 | rc = ssp_sensor_disable(PRESSURE_SENSOR); 150 | if (rc < 0) { 151 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 152 | return -1; 153 | } 154 | 155 | handlers->activated = 0; 156 | 157 | return 0; 158 | } 159 | 160 | int bmp180_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 161 | { 162 | struct bmp180_data *data; 163 | int rc; 164 | 165 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 166 | 167 | if (handlers == NULL || handlers->data == NULL) 168 | return -EINVAL; 169 | 170 | data = (struct bmp180_data *) handlers->data; 171 | 172 | rc = sysfs_value_write(data->path_delay, (int) delay); 173 | if (rc < 0) { 174 | //ALOGD("%s: Unable to write sysfs value", __func__); 175 | return -1; 176 | } 177 | 178 | return 0; 179 | } 180 | 181 | float bmp180_convert(int value) 182 | { 183 | return value / 100.0f; 184 | } 185 | 186 | int bmp180_get_data(struct noteII_sensors_handlers *handlers, 187 | struct sensors_event_t *event) 188 | { 189 | struct input_event input_event; 190 | int input_fd; 191 | int rc; 192 | int sensorId = SENSOR_TYPE_PRESSURE; 193 | 194 | if (handlers == NULL || event == NULL) 195 | return -EINVAL; 196 | 197 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 198 | sensors_event_t sensor_event; 199 | memset(&sensor_event, 0, sizeof(sensor_event)); 200 | sensor_event.version = META_DATA_VERSION; 201 | sensor_event.type = SENSOR_TYPE_META_DATA; 202 | sensor_event.meta_data.sensor = sensorId; 203 | sensor_event.meta_data.what = 0; 204 | *event++ = sensor_event; 205 | mFlushed &= ~(0x01 << sensorId); 206 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 207 | } 208 | 209 | input_fd = handlers->poll_fd; 210 | if (input_fd < 0) 211 | return -EINVAL; 212 | 213 | memset(event, 0, sizeof(struct sensors_event_t)); 214 | event->version = sizeof(struct sensors_event_t); 215 | event->sensor = handlers->handle; 216 | event->type = handlers->handle; 217 | 218 | do { 219 | rc = read(input_fd, &input_event, sizeof(input_event)); 220 | if (rc < (int) sizeof(input_event)) 221 | break; 222 | 223 | if (input_event.type == EV_REL) { 224 | switch (input_event.code) { 225 | case REL_HWHEEL: 226 | event->pressure = bmp180_convert(input_event.value); 227 | break; 228 | default: 229 | continue; 230 | } 231 | } else if (input_event.type == EV_SYN) { 232 | if (input_event.code == SYN_REPORT && event->pressure != 0) { 233 | event->timestamp = getTimestamp(); 234 | break; 235 | } else { 236 | return -1; 237 | } 238 | } 239 | } while (1); 240 | 241 | return 0; 242 | } 243 | 244 | struct noteII_sensors_handlers bmp180 = { 245 | .name = "BMP180", 246 | .handle = SENSOR_TYPE_PRESSURE, 247 | .init = bmp180_init, 248 | .deinit = bmp180_deinit, 249 | .activate = bmp180_activate, 250 | .deactivate = bmp180_deactivate, 251 | .set_delay = bmp180_set_delay, 252 | .get_data = bmp180_get_data, 253 | .activated = 0, 254 | .needed = 0, 255 | .poll_fd = -1, 256 | .data = NULL, 257 | }; 258 | -------------------------------------------------------------------------------- /libsensors/cm36651_light.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #define LOG_TAG "Light_NoteII" 33 | #include 34 | 35 | #include "noteII_sensors.h" 36 | #include "ssp.h" 37 | 38 | extern int mFlushed; 39 | 40 | struct cm36651_light_data { 41 | char path_delay[PATH_MAX]; 42 | }; 43 | 44 | int cm36651_light_init(struct noteII_sensors_handlers *handlers, 45 | struct smdk4x12_sensors_device *device) 46 | { 47 | struct cm36651_light_data *data = NULL; 48 | char path[PATH_MAX] = { 0 }; 49 | int input_fd = -1; 50 | int rc; 51 | 52 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 53 | 54 | if (handlers == NULL) 55 | return -EINVAL; 56 | 57 | data = (struct cm36651_light_data *) calloc(1, sizeof(struct cm36651_light_data)); 58 | 59 | input_fd = input_open("light_sensor"); 60 | if (input_fd < 0) { 61 | //ALOGD("%s: Unable to open input", __func__); 62 | goto error; 63 | } 64 | 65 | rc = sysfs_path_prefix("light_sensor", (char *) &path); 66 | if (rc < 0 || path[0] == '\0') { 67 | //ALOGD("%s: Unable to open sysfs", __func__); 68 | goto error; 69 | } 70 | 71 | int sf = snprintf(data->path_delay, PATH_MAX, "%s/poll_delay", path); 72 | if(sf <= 0) 73 | { 74 | //ALOGD("Light HAS FAILED !POLL_DELAY!"); 75 | goto error; 76 | } 77 | 78 | handlers->poll_fd = input_fd; 79 | handlers->data = (void *) data; 80 | 81 | return 0; 82 | 83 | error: 84 | if (data != NULL) 85 | free(data); 86 | 87 | if (input_fd >= 0) 88 | close(input_fd); 89 | 90 | handlers->poll_fd = -1; 91 | handlers->data = NULL; 92 | 93 | return -1; 94 | } 95 | 96 | int cm36651_light_deinit(struct noteII_sensors_handlers *handlers) 97 | { 98 | //ALOGD("%s(%p)", __func__, handlers); 99 | 100 | if (handlers == NULL) 101 | return -EINVAL; 102 | 103 | if (handlers->poll_fd >= 0) 104 | close(handlers->poll_fd); 105 | handlers->poll_fd = -1; 106 | 107 | if (handlers->data != NULL) 108 | free(handlers->data); 109 | handlers->data = NULL; 110 | 111 | return 0; 112 | } 113 | 114 | int cm36651_light_activate(struct noteII_sensors_handlers *handlers) 115 | { 116 | struct cm36651_light_data *data; 117 | int rc; 118 | 119 | //ALOGD("%s(%p)", __func__, handlers); 120 | 121 | if (handlers == NULL || handlers->data == NULL) 122 | return -EINVAL; 123 | 124 | data = (struct cm36651_light_data *) handlers->data; 125 | 126 | rc = ssp_sensor_enable(LIGHT_SENSOR); 127 | if (rc < 0) { 128 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 129 | return -1; 130 | } 131 | 132 | handlers->activated = 1; 133 | 134 | return 0; 135 | } 136 | 137 | int cm36651_light_deactivate(struct noteII_sensors_handlers *handlers) 138 | { 139 | struct cm36651_light_data *data; 140 | int rc; 141 | 142 | //ALOGD("%s(%p)", __func__, handlers); 143 | 144 | if (handlers == NULL || handlers->data == NULL) 145 | return -EINVAL; 146 | 147 | data = (struct cm36651_light_data *) handlers->data; 148 | 149 | rc = ssp_sensor_disable(LIGHT_SENSOR); 150 | if (rc < 0) { 151 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 152 | return -1; 153 | } 154 | 155 | handlers->activated = 0; 156 | 157 | return 0; 158 | } 159 | 160 | int cm36651_light_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 161 | { 162 | struct cm36651_light_data *data; 163 | int rc; 164 | 165 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 166 | 167 | if (handlers == NULL || handlers->data == NULL) 168 | return -EINVAL; 169 | 170 | data = (struct cm36651_light_data *) handlers->data; 171 | 172 | rc = sysfs_value_write(data->path_delay, delay); 173 | if (rc < 0) { 174 | //ALOGD("%s: Unable to write sysfs value", __func__); 175 | return -1; 176 | } 177 | 178 | return 0; 179 | } 180 | 181 | float cm36651_light_convert(int value) 182 | { 183 | return (float) value * 1.7f - 0.5f; 184 | } 185 | 186 | int cm36651_light_get_data(struct noteII_sensors_handlers *handlers, 187 | struct sensors_event_t *event) 188 | { 189 | struct input_event input_event; 190 | int input_fd; 191 | int rc; 192 | int sensorId = SENSOR_TYPE_LIGHT; 193 | 194 | if (handlers == NULL || event == NULL) 195 | return -EINVAL; 196 | 197 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 198 | sensors_event_t sensor_event; 199 | memset(&sensor_event, 0, sizeof(sensor_event)); 200 | sensor_event.version = META_DATA_VERSION; 201 | sensor_event.type = SENSOR_TYPE_META_DATA; 202 | sensor_event.meta_data.sensor = sensorId; 203 | sensor_event.meta_data.what = 0; 204 | *event++ = sensor_event; 205 | mFlushed &= ~(0x01 << sensorId); 206 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 207 | } 208 | 209 | input_fd = handlers->poll_fd; 210 | if (input_fd < 0) 211 | return -EINVAL; 212 | 213 | memset(event, 0, sizeof(struct sensors_event_t)); 214 | event->version = sizeof(struct sensors_event_t); 215 | event->sensor = handlers->handle; 216 | event->type = handlers->handle; 217 | 218 | do { 219 | rc = read(input_fd, &input_event, sizeof(input_event)); 220 | if (rc < (int) sizeof(input_event)) 221 | break; 222 | 223 | if (input_event.type == EV_REL) { 224 | if (input_event.code == REL_MISC) 225 | event->light = cm36651_light_convert(input_event.value); 226 | } else if (input_event.type == EV_SYN) { 227 | if (input_event.code == SYN_REPORT) 228 | event->timestamp = getTimestamp(); 229 | } 230 | } while (input_event.type != EV_SYN); 231 | 232 | return 0; 233 | } 234 | 235 | struct noteII_sensors_handlers cm36651_light = { 236 | .name = "CM36651 Light", 237 | .handle = SENSOR_TYPE_LIGHT, 238 | .init = cm36651_light_init, 239 | .deinit = cm36651_light_deinit, 240 | .activate = cm36651_light_activate, 241 | .deactivate = cm36651_light_deactivate, 242 | .set_delay = cm36651_light_set_delay, 243 | .get_data = cm36651_light_get_data, 244 | .activated = 0, 245 | .needed = 0, 246 | .poll_fd = -1, 247 | .data = NULL, 248 | }; 249 | -------------------------------------------------------------------------------- /libsensors/cm36651_proximity.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #define LOG_TAG "Proxy_NoteII" 32 | #include 33 | 34 | #include "noteII_sensors.h" 35 | #include "ssp.h" 36 | 37 | extern int mFlushed; 38 | 39 | struct cm36651_proximity_data { 40 | char path_delay[PATH_MAX]; 41 | }; 42 | 43 | int cm36651_proximity_init(struct noteII_sensors_handlers *handlers, 44 | struct smdk4x12_sensors_device *device) 45 | { 46 | struct cm36651_proximity_data *data = NULL; 47 | char path[PATH_MAX] = { 0 }; 48 | int input_fd = -1; 49 | int rc; 50 | 51 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 52 | 53 | if (handlers == NULL) 54 | return -EINVAL; 55 | 56 | data = (struct cm36651_proximity_data *) calloc(1, sizeof(struct cm36651_proximity_data)); 57 | 58 | input_fd = input_open("proximity_sensor"); 59 | if (input_fd < 0) { 60 | //ALOGD("%s: Unable to open input", __func__); 61 | goto error; 62 | } 63 | 64 | rc = sysfs_path_prefix("proximity_sensor", (char *) &path); 65 | if (rc < 0 || path[0] == '\0') { 66 | //ALOGD("%s: Unable to open sysfs", __func__); 67 | goto error; 68 | } 69 | 70 | int sf = snprintf(data->path_delay, PATH_MAX, "%s/poll_delay", path); 71 | if(sf <= 0) 72 | { 73 | ALOGD("PROX HAS FAILED !POLL_DELAY!"); 74 | goto error; 75 | } 76 | 77 | handlers->poll_fd = input_fd; 78 | handlers->data = (void *) data; 79 | 80 | return 0; 81 | 82 | error: 83 | if (data != NULL) 84 | free(data); 85 | 86 | if (input_fd >= 0) 87 | close(input_fd); 88 | 89 | handlers->poll_fd = -1; 90 | handlers->data = NULL; 91 | 92 | return -1; 93 | } 94 | 95 | int cm36651_proximity_deinit(struct noteII_sensors_handlers *handlers) 96 | { 97 | //ALOGD("%s(%p)", __func__, handlers); 98 | 99 | if (handlers == NULL) 100 | return -EINVAL; 101 | 102 | if (handlers->poll_fd >= 0) 103 | close(handlers->poll_fd); 104 | handlers->poll_fd = -1; 105 | 106 | if (handlers->data != NULL) 107 | free(handlers->data); 108 | handlers->data = NULL; 109 | 110 | return 0; 111 | } 112 | 113 | int cm36651_proximity_activate(struct noteII_sensors_handlers *handlers) 114 | { 115 | usleep(100); 116 | struct cm36651_proximity_data *data; 117 | int rc; 118 | 119 | //ALOGD("%s(%p)", __func__, handlers); 120 | 121 | if (handlers == NULL || handlers->data == NULL) 122 | return -EINVAL; 123 | 124 | data = (struct cm36651_proximity_data *) handlers->data; 125 | 126 | rc = ssp_sensor_enable(PROXIMITY_SENSOR); 127 | if (rc < 0) { 128 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 129 | return -1; 130 | } 131 | 132 | handlers->activated = 1; 133 | 134 | return 0; 135 | } 136 | 137 | int cm36651_proximity_deactivate(struct noteII_sensors_handlers *handlers) 138 | { 139 | usleep(100); 140 | struct cm36651_proximity_data *data; 141 | int rc; 142 | 143 | ALOGD("%s(%p)", __func__, handlers); 144 | 145 | if (handlers == NULL || handlers->data == NULL) 146 | return -EINVAL; 147 | 148 | data = (struct cm36651_proximity_data *) handlers->data; 149 | 150 | rc = ssp_sensor_disable(PROXIMITY_SENSOR); 151 | if (rc < 0) { 152 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 153 | return -1; 154 | } 155 | 156 | handlers->activated = 0; 157 | 158 | return 0; 159 | } 160 | 161 | int cm36651_proximity_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 162 | { 163 | struct cm36651_proximity_data *data; 164 | int rc; 165 | 166 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 167 | 168 | if (handlers == NULL || handlers->data == NULL) 169 | return -EINVAL; 170 | 171 | data = (struct cm36651_proximity_data *) handlers->data; 172 | 173 | rc = sysfs_value_write(data->path_delay, (int) delay); 174 | if (rc < 0) { 175 | //ALOGD("%s: Unable to write sysfs value", __func__); 176 | return -1; 177 | } 178 | 179 | return 0; 180 | } 181 | 182 | float cm36651_proximity_convert(int value) 183 | { 184 | return (float) value * 6.0f; 185 | } 186 | 187 | int cm36651_proximity_get_data(struct noteII_sensors_handlers *handlers, 188 | struct sensors_event_t *event) 189 | { 190 | struct input_event input_event; 191 | int input_fd; 192 | int rc; 193 | int sensorId = SENSOR_TYPE_PROXIMITY; 194 | 195 | if (handlers == NULL || event == NULL) 196 | return -EINVAL; 197 | 198 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 199 | sensors_event_t sensor_event; 200 | memset(&sensor_event, 0, sizeof(sensor_event)); 201 | sensor_event.version = META_DATA_VERSION; 202 | sensor_event.type = SENSOR_TYPE_META_DATA; 203 | sensor_event.meta_data.sensor = sensorId; 204 | sensor_event.meta_data.what = 0; 205 | *event++ = sensor_event; 206 | mFlushed &= ~(0x01 << sensorId); 207 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 208 | } 209 | 210 | input_fd = handlers->poll_fd; 211 | if (input_fd < 0) 212 | return -EINVAL; 213 | 214 | memset(event, 0, sizeof(struct sensors_event_t)); 215 | event->version = sizeof(struct sensors_event_t); 216 | event->sensor = handlers->handle; 217 | event->type = handlers->handle; 218 | 219 | do { 220 | rc = read(input_fd, &input_event, sizeof(input_event)); 221 | if (rc < (int) sizeof(input_event)) 222 | break; 223 | 224 | if (input_event.type == EV_ABS) { 225 | if (input_event.code == ABS_DISTANCE) 226 | event->distance = cm36651_proximity_convert(input_event.value); 227 | } else if (input_event.type == EV_SYN) { 228 | if (input_event.code == SYN_REPORT) 229 | event->timestamp = getTimestamp(); 230 | } 231 | } while (input_event.type != EV_SYN); 232 | 233 | return 0; 234 | } 235 | 236 | struct noteII_sensors_handlers cm36651_proximity = { 237 | .name = "CM36651 Proximity", 238 | .handle = SENSOR_TYPE_PROXIMITY, 239 | .init = cm36651_proximity_init, 240 | .deinit = cm36651_proximity_deinit, 241 | .activate = cm36651_proximity_activate, 242 | .deactivate = cm36651_proximity_deactivate, 243 | .set_delay = cm36651_proximity_set_delay, 244 | .get_data = cm36651_proximity_get_data, 245 | .activated = 0, 246 | .needed = 0, 247 | .poll_fd = -1, 248 | .data = NULL, 249 | }; 250 | -------------------------------------------------------------------------------- /libsensors/input.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define LOG_TAG "NoteII_Input" 30 | #include 31 | 32 | #include "noteII_sensors.h" 33 | 34 | void input_event_set(struct input_event *event, int type, int code, int value) 35 | { 36 | if (event == NULL) 37 | return; 38 | 39 | memset(event, 0, sizeof(struct input_event)); 40 | 41 | event->type = type, 42 | event->code = code; 43 | event->value = value; 44 | 45 | gettimeofday(&event->time, NULL); 46 | } 47 | 48 | int64_t getTimestamp() { 49 | struct timespec t; 50 | t.tv_sec = t.tv_nsec = 0; 51 | clock_gettime(CLOCK_BOOTTIME, &t); 52 | return (int64_t)(t.tv_sec)*1000000000LL + t.tv_nsec; 53 | } 54 | 55 | int64_t timestamp(struct timeval *time) 56 | { 57 | if (time == NULL) 58 | return -1; 59 | 60 | return time->tv_sec * 1000000000LL + time->tv_usec * 1000; 61 | } 62 | 63 | int64_t input_timestamp(struct input_event *event) 64 | { 65 | if (event == NULL) 66 | return -1; 67 | 68 | return timestamp(&event->time); 69 | } 70 | 71 | int uinput_rel_create(const char *name) 72 | { 73 | struct uinput_user_dev uinput_dev; 74 | int uinput_fd; 75 | int rc; 76 | 77 | if (name == NULL) 78 | return -1; 79 | 80 | uinput_fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); 81 | if (uinput_fd < 0) { 82 | //ALOGD("%s: Unable to open uinput device", __func__); 83 | goto error; 84 | } 85 | 86 | memset(&uinput_dev, 0, sizeof(uinput_dev)); 87 | 88 | strncpy(uinput_dev.name, name, sizeof(uinput_dev.name)); 89 | uinput_dev.id.bustype = BUS_I2C; 90 | uinput_dev.id.vendor = 0; 91 | uinput_dev.id.product = 0; 92 | uinput_dev.id.version = 0; 93 | 94 | rc = 0; 95 | rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_REL); 96 | rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_X); 97 | rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Y); 98 | rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_Z); 99 | rc |= ioctl(uinput_fd, UI_SET_RELBIT, REL_MISC); 100 | rc |= ioctl(uinput_fd, UI_SET_EVBIT, EV_SYN); 101 | 102 | if (rc < 0) { 103 | //ALOGD("%s: Unable to set uinput bits", __func__); 104 | goto error; 105 | } 106 | 107 | rc = write(uinput_fd, &uinput_dev, sizeof(uinput_dev)); 108 | if (rc < 0) { 109 | //ALOGD("%s: Unable to write uinput device", __func__); 110 | goto error; 111 | } 112 | 113 | rc = ioctl(uinput_fd, UI_DEV_CREATE); 114 | if (rc < 0) { 115 | //ALOGD("%s: Unable to create uinput device", __func__); 116 | goto error; 117 | } 118 | 119 | usleep(3000); 120 | 121 | return uinput_fd; 122 | 123 | error: 124 | if (uinput_fd >= 0) 125 | close(uinput_fd); 126 | 127 | return -1; 128 | } 129 | 130 | void uinput_destroy(int uinput_fd) 131 | { 132 | if (uinput_fd < 0) 133 | return; 134 | 135 | ioctl(uinput_fd, UI_DEV_DESTROY); 136 | } 137 | 138 | int input_open(char *name) 139 | { 140 | DIR *d; 141 | struct dirent *di; 142 | 143 | char input_name[80] = { 0 }; 144 | char path[PATH_MAX]; 145 | char *c; 146 | int fd; 147 | int rc; 148 | 149 | if (name == NULL) 150 | return -EINVAL; 151 | 152 | d = opendir("/dev/input"); 153 | if (d == NULL) 154 | return -1; 155 | 156 | while ((di = readdir(d))) { 157 | if (di == NULL || strcmp(di->d_name, ".") == 0 || strcmp(di->d_name, "..") == 0) 158 | continue; 159 | 160 | snprintf(path, PATH_MAX, "/dev/input/%s", di->d_name); 161 | fd = open(path, O_RDONLY | O_NONBLOCK); 162 | if (fd < 0) 163 | continue; 164 | 165 | rc = ioctl(fd, EVIOCGNAME(sizeof(input_name) - 1), &input_name); 166 | if (rc < 0) 167 | continue; 168 | 169 | c = strstr((char *) &input_name, "\n"); 170 | if (c != NULL) 171 | *c = '\0'; 172 | 173 | if (strcmp(input_name, name) == 0) 174 | return fd; 175 | else 176 | close(fd); 177 | } 178 | 179 | return -1; 180 | } 181 | 182 | int sysfs_path_prefix(char *name, char *path_prefix) 183 | { 184 | DIR *d; 185 | struct dirent *di; 186 | 187 | char input_name[80] = { 0 }; 188 | char path[PATH_MAX]; 189 | char *c; 190 | int fd; 191 | 192 | if (name == NULL || path_prefix == NULL) 193 | return -EINVAL; 194 | 195 | d = opendir("/sys/class/input"); 196 | if (d == NULL) 197 | return -1; 198 | 199 | while ((di = readdir(d))) { 200 | if (di == NULL || strcmp(di->d_name, ".") == 0 || strcmp(di->d_name, "..") == 0) 201 | continue; 202 | 203 | snprintf(path, PATH_MAX, "/sys/class/input/%s/name", di->d_name); 204 | 205 | fd = open(path, O_RDONLY); 206 | if (fd < 0) 207 | continue; 208 | 209 | read(fd, &input_name, sizeof(input_name)); 210 | close(fd); 211 | 212 | c = strstr((char *) &input_name, "\n"); 213 | if (c != NULL) 214 | *c = '\0'; 215 | 216 | if (strcmp(input_name, name) == 0) { 217 | snprintf(path_prefix, PATH_MAX, "/sys/class/input/%s", di->d_name); 218 | return 0; 219 | } 220 | } 221 | 222 | return -1; 223 | } 224 | 225 | int64_t sysfs_value_read(char *path) 226 | { 227 | char buffer[100]; 228 | int64_t value; 229 | int fd = -1; 230 | int rc; 231 | int i; 232 | 233 | if (path == NULL) 234 | return -1; 235 | 236 | fd = open(path, O_RDONLY); 237 | if (fd < 0) 238 | goto error; 239 | 240 | rc = read(fd, &buffer, sizeof(buffer)); 241 | if (rc <= 0) 242 | goto error; 243 | 244 | i = 0; 245 | while (buffer[i] == ' ' || buffer[i] == '\t') 246 | i++; 247 | 248 | value = (int64_t)strtoimax(&buffer[i], NULL, 10); 249 | goto complete; 250 | 251 | error: 252 | value = -1; 253 | 254 | complete: 255 | if (fd >= 0) 256 | close(fd); 257 | 258 | return value; 259 | } 260 | 261 | int sysfs_value_write(char *path, int64_t value) 262 | { 263 | char buffer[100]; 264 | int fd = -1; 265 | int rc; 266 | 267 | if (path == NULL) 268 | return -1; 269 | 270 | fd = open(path, O_WRONLY); 271 | if (fd < 0) 272 | goto error; 273 | 274 | snprintf((char *) &buffer, sizeof(buffer), "%" PRId64 "\n", value); 275 | 276 | rc = write(fd, buffer, strlen(buffer)); 277 | if (rc < (int) strlen(buffer)) 278 | goto error; 279 | 280 | rc = 0; 281 | goto complete; 282 | 283 | error: 284 | rc = -1; 285 | 286 | complete: 287 | if (fd >= 0) 288 | close(fd); 289 | 290 | return rc; 291 | } 292 | 293 | int sysfs_string_read(char *path, char *buffer, size_t length) 294 | { 295 | int fd = -1; 296 | int rc; 297 | 298 | if (path == NULL || buffer == NULL || length == 0) 299 | return -1; 300 | 301 | fd = open(path, O_RDONLY); 302 | if (fd < 0) 303 | goto error; 304 | 305 | rc = read(fd, buffer, length); 306 | if (rc <= 0) 307 | goto error; 308 | 309 | rc = 0; 310 | goto complete; 311 | 312 | error: 313 | rc = -1; 314 | 315 | complete: 316 | if (fd >= 0) 317 | close(fd); 318 | 319 | return rc; 320 | } 321 | 322 | int sysfs_string_write(char *path, char *buffer, size_t length) 323 | { 324 | int fd = -1; 325 | int rc; 326 | 327 | if (path == NULL || buffer == NULL || length == 0) 328 | return -1; 329 | 330 | fd = open(path, O_WRONLY); 331 | if (fd < 0) 332 | goto error; 333 | 334 | rc = write(fd, buffer, length); 335 | if (rc <= 0) 336 | goto error; 337 | 338 | rc = 0; 339 | goto complete; 340 | 341 | error: 342 | rc = -1; 343 | 344 | complete: 345 | if (fd >= 0) 346 | close(fd); 347 | 348 | return rc; 349 | } 350 | -------------------------------------------------------------------------------- /libsensors/lsm330dlc_acceleration.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #define LOG_TAG "Acc_NoteII" 29 | #include 30 | 31 | #include "noteII_sensors.h" 32 | #include "ssp.h" 33 | 34 | extern int mFlushed; 35 | 36 | struct lsm330dlc_acceleration_data { 37 | char path_delay[PATH_MAX]; 38 | 39 | sensors_vec_t acceleration; 40 | }; 41 | 42 | int lsm330dlc_acceleration_init(struct noteII_sensors_handlers *handlers, 43 | struct smdk4x12_sensors_device *device) 44 | { 45 | struct lsm330dlc_acceleration_data *data = NULL; 46 | char path[PATH_MAX] = { 0 }; 47 | int input_fd = -1; 48 | int rc; 49 | int i; 50 | 51 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 52 | 53 | if (handlers == NULL) 54 | return -EINVAL; 55 | 56 | data = (struct lsm330dlc_acceleration_data *) calloc(1, sizeof(struct lsm330dlc_acceleration_data)); 57 | 58 | input_fd = input_open("accelerometer_sensor"); 59 | if (input_fd < 0) { 60 | //ALOGD("%s: Unable to open input", __func__); 61 | goto error; 62 | } 63 | 64 | rc = sysfs_path_prefix("accelerometer_sensor", (char *) &path); 65 | if (rc < 0 || path[0] == '\0') { 66 | //ALOGD("%s: Unable to open sysfs", __func__); 67 | goto error; 68 | } 69 | 70 | int sf = snprintf(data->path_delay, PATH_MAX, "%s/poll_delay", path); 71 | if(sf <= 0) 72 | { 73 | //ALOGD("ACC HAS FAILED !POLL_DELAY!"); 74 | goto error; 75 | } 76 | 77 | handlers->poll_fd = input_fd; 78 | handlers->data = (void *) data; 79 | 80 | return 0; 81 | 82 | error: 83 | if (data != NULL) 84 | free(data); 85 | 86 | if (input_fd >= 0) 87 | close(input_fd); 88 | 89 | handlers->poll_fd = -1; 90 | handlers->data = NULL; 91 | 92 | return -1; 93 | } 94 | 95 | int lsm330dlc_acceleration_deinit(struct noteII_sensors_handlers *handlers) 96 | { 97 | //ALOGD("%s(%p)", __func__, handlers); 98 | 99 | if (handlers == NULL) 100 | return -EINVAL; 101 | 102 | if (handlers->poll_fd >= 0) 103 | close(handlers->poll_fd); 104 | handlers->poll_fd = -1; 105 | 106 | if (handlers->data != NULL) 107 | free(handlers->data); 108 | handlers->data = NULL; 109 | 110 | return 0; 111 | } 112 | 113 | int lsm330dlc_acceleration_activate(struct noteII_sensors_handlers *handlers) 114 | { 115 | struct lsm330dlc_acceleration_data *data; 116 | int rc; 117 | 118 | //ALOGD("%s(%p)", __func__, handlers); 119 | 120 | if (handlers == NULL || handlers->data == NULL) 121 | return -EINVAL; 122 | 123 | data = (struct lsm330dlc_acceleration_data *) handlers->data; 124 | 125 | rc = ssp_sensor_enable(ACCELEROMETER_SENSOR); 126 | if (rc < 0) { 127 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 128 | return -1; 129 | } 130 | 131 | handlers->activated = 1; 132 | 133 | return 0; 134 | } 135 | 136 | int lsm330dlc_acceleration_deactivate(struct noteII_sensors_handlers *handlers) 137 | { 138 | struct lsm330dlc_acceleration_data *data; 139 | int rc; 140 | 141 | //ALOGD("%s(%p)", __func__, handlers); 142 | 143 | if (handlers == NULL || handlers->data == NULL) 144 | return -EINVAL; 145 | 146 | data = (struct lsm330dlc_acceleration_data *) handlers->data; 147 | 148 | rc = ssp_sensor_disable(ACCELEROMETER_SENSOR); 149 | if (rc < 0) { 150 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 151 | return -1; 152 | } 153 | 154 | handlers->activated = 0; 155 | 156 | return 0; 157 | } 158 | 159 | int lsm330dlc_acceleration_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 160 | { 161 | struct lsm330dlc_acceleration_data *data; 162 | int rc; 163 | 164 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 165 | 166 | if (handlers == NULL || handlers->data == NULL) 167 | return -EINVAL; 168 | 169 | data = (struct lsm330dlc_acceleration_data *) handlers->data; 170 | 171 | rc = sysfs_value_write(data->path_delay, (int) delay); 172 | if (rc < 0) { 173 | //ALOGD("%s: Unable to write sysfs value", __func__); 174 | return -1; 175 | } 176 | 177 | return 0; 178 | } 179 | 180 | float lsm330dlc_acceleration_convert(int value) 181 | { 182 | return (float) value * (GRAVITY_EARTH / 1024.0f); 183 | } 184 | 185 | int lsm330dlc_acceleration_get_data(struct noteII_sensors_handlers *handlers, 186 | struct sensors_event_t *event) 187 | { 188 | struct lsm330dlc_acceleration_data *data; 189 | struct input_event input_event; 190 | int input_fd; 191 | int rc; 192 | int sensorId = SENSOR_TYPE_ACCELEROMETER; 193 | 194 | if (handlers == NULL || handlers->data == NULL || event == NULL) 195 | return -EINVAL; 196 | 197 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 198 | sensors_event_t sensor_event; 199 | memset(&sensor_event, 0, sizeof(sensor_event)); 200 | sensor_event.version = META_DATA_VERSION; 201 | sensor_event.type = SENSOR_TYPE_META_DATA; 202 | sensor_event.meta_data.sensor = sensorId; 203 | sensor_event.meta_data.what = 0; 204 | *event++ = sensor_event; 205 | mFlushed &= ~(0x01 << sensorId); 206 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 207 | } 208 | 209 | data = (struct lsm330dlc_acceleration_data *) handlers->data; 210 | 211 | input_fd = handlers->poll_fd; 212 | if (input_fd < 0) 213 | return -1; 214 | 215 | memset(event, 0, sizeof(struct sensors_event_t)); 216 | event->version = sizeof(struct sensors_event_t); 217 | event->sensor = handlers->handle; 218 | event->type = handlers->handle; 219 | 220 | event->acceleration.x = data->acceleration.x; 221 | event->acceleration.y = data->acceleration.y; 222 | event->acceleration.z = data->acceleration.z; 223 | 224 | event->magnetic.status = SENSOR_STATUS_ACCURACY_MEDIUM; 225 | 226 | do { 227 | rc = read(input_fd, &input_event, sizeof(input_event)); 228 | if (rc < (int) sizeof(input_event)) 229 | break; 230 | 231 | if (input_event.type == EV_REL) { 232 | switch (input_event.code) { 233 | case REL_X: 234 | event->acceleration.x = lsm330dlc_acceleration_convert(input_event.value); 235 | break; 236 | case REL_Y: 237 | event->acceleration.y = lsm330dlc_acceleration_convert(input_event.value); 238 | break; 239 | case REL_Z: 240 | event->acceleration.z = lsm330dlc_acceleration_convert(input_event.value); 241 | break; 242 | default: 243 | continue; 244 | } 245 | } else if (input_event.type == EV_SYN) { 246 | if (input_event.code == SYN_REPORT) 247 | event->timestamp = getTimestamp(); 248 | } 249 | } while (input_event.type != EV_SYN); 250 | 251 | data->acceleration.x = event->acceleration.x; 252 | data->acceleration.y = event->acceleration.y; 253 | data->acceleration.z = event->acceleration.z; 254 | 255 | return 0; 256 | } 257 | 258 | struct noteII_sensors_handlers lsm330dlc_acceleration = { 259 | .name = "LSM330DLC Acceleration", 260 | .handle = SENSOR_TYPE_ACCELEROMETER, 261 | .init = lsm330dlc_acceleration_init, 262 | .deinit = lsm330dlc_acceleration_deinit, 263 | .activate = lsm330dlc_acceleration_activate, 264 | .deactivate = lsm330dlc_acceleration_deactivate, 265 | .set_delay = lsm330dlc_acceleration_set_delay, 266 | .get_data = lsm330dlc_acceleration_get_data, 267 | .activated = 0, 268 | .needed = 0, 269 | .poll_fd = -1, 270 | .data = NULL, 271 | }; 272 | -------------------------------------------------------------------------------- /libsensors/lsm330dlc_gyroscope.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #define LOG_TAG "Gyro_NoteII" 33 | #include 34 | 35 | #include "noteII_sensors.h" 36 | #include "ssp.h" 37 | 38 | extern int mFlushed; 39 | 40 | struct lsm330dlc_gyroscope_data { 41 | char path_delay[PATH_MAX]; 42 | 43 | sensors_vec_t gyro; 44 | }; 45 | 46 | int lsm330dlc_gyroscope_init(struct noteII_sensors_handlers *handlers, 47 | struct smdk4x12_sensors_device *device) 48 | { 49 | struct lsm330dlc_gyroscope_data *data = NULL; 50 | char path[PATH_MAX] = { 0 }; 51 | int input_fd = -1; 52 | int rc; 53 | 54 | //ALOGD("%s(%p, %p)", __func__, handlers, device); 55 | 56 | if (handlers == NULL) 57 | return -EINVAL; 58 | 59 | data = (struct lsm330dlc_gyroscope_data *) calloc(1, sizeof(struct lsm330dlc_gyroscope_data)); 60 | 61 | input_fd = input_open("gyro_sensor"); 62 | if (input_fd < 0) { 63 | //ALOGD("%s: Unable to open input", __func__); 64 | goto error; 65 | } 66 | 67 | rc = sysfs_path_prefix("gyro_sensor", (char *) &path); 68 | if (rc < 0 || path[0] == '\0') { 69 | //ALOGD("%s: Unable to open sysfs", __func__); 70 | goto error; 71 | } 72 | 73 | int sf = snprintf(data->path_delay, PATH_MAX, "%s/poll_delay", path); 74 | if(sf <= 0) 75 | { 76 | //ALOGD("GYRO HAS FAILED !POLL_DELAY!"); 77 | goto error; 78 | } 79 | 80 | handlers->poll_fd = input_fd; 81 | handlers->data = (void *) data; 82 | 83 | return 0; 84 | 85 | error: 86 | if (data != NULL) 87 | free(data); 88 | 89 | if (input_fd >= 0) 90 | close(input_fd); 91 | 92 | handlers->poll_fd = -1; 93 | handlers->data = NULL; 94 | 95 | return -1; 96 | } 97 | 98 | int lsm330dlc_gyroscope_deinit(struct noteII_sensors_handlers *handlers) 99 | { 100 | //ALOGD("%s(%p)", __func__, handlers); 101 | 102 | if (handlers == NULL) 103 | return -EINVAL; 104 | 105 | if (handlers->poll_fd >= 0) 106 | close(handlers->poll_fd); 107 | handlers->poll_fd = -1; 108 | 109 | if (handlers->data != NULL) 110 | free(handlers->data); 111 | handlers->data = NULL; 112 | 113 | return 0; 114 | } 115 | 116 | int lsm330dlc_gyroscope_activate(struct noteII_sensors_handlers *handlers) 117 | { 118 | struct lsm330dlc_gyroscope_data *data; 119 | int rc; 120 | 121 | //ALOGD("%s(%p)", __func__, handlers); 122 | 123 | if (handlers == NULL || handlers->data == NULL) 124 | return -EINVAL; 125 | 126 | data = (struct lsm330dlc_gyroscope_data *) handlers->data; 127 | 128 | rc = ssp_sensor_enable(GYROSCOPE_SENSOR); 129 | if (rc < 0) { 130 | //ALOGD("%s: Unable to enable ssp sensor", __func__); 131 | return -1; 132 | } 133 | 134 | handlers->activated = 1; 135 | 136 | return 0; 137 | } 138 | 139 | int lsm330dlc_gyroscope_deactivate(struct noteII_sensors_handlers *handlers) 140 | { 141 | struct lsm330dlc_gyroscope_data *data; 142 | int rc; 143 | 144 | //ALOGD("%s(%p)", __func__, handlers); 145 | 146 | if (handlers == NULL || handlers->data == NULL) 147 | return -EINVAL; 148 | 149 | data = (struct lsm330dlc_gyroscope_data *) handlers->data; 150 | 151 | rc = ssp_sensor_disable(GYROSCOPE_SENSOR); 152 | if (rc < 0) { 153 | //ALOGD("%s: Unable to disable ssp sensor", __func__); 154 | return -1; 155 | } 156 | 157 | handlers->activated = 1; 158 | return 0; 159 | } 160 | 161 | int lsm330dlc_gyroscope_set_delay(struct noteII_sensors_handlers *handlers, int64_t delay) 162 | { 163 | struct lsm330dlc_gyroscope_data *data; 164 | int rc; 165 | 166 | //ALOGD("%s(%p, %" PRId64 ")", __func__, handlers, delay); 167 | 168 | if (handlers == NULL || handlers->data == NULL) 169 | return -EINVAL; 170 | 171 | data = (struct lsm330dlc_gyroscope_data *) handlers->data; 172 | 173 | rc = sysfs_value_write(data->path_delay, delay); 174 | if (rc < 0) { 175 | //ALOGD("%s: Unable to write sysfs value", __func__); 176 | return -1; 177 | } 178 | 179 | return 0; 180 | } 181 | 182 | float lsm330dlc_gyroscope_convert(int value) 183 | { 184 | return value * (70.0f / 4000.0f) * (3.1415926535f / 180.0f); 185 | } 186 | 187 | int lsm330dlc_gyroscope_get_data(struct noteII_sensors_handlers *handlers, 188 | struct sensors_event_t *event) 189 | { 190 | struct lsm330dlc_gyroscope_data *data; 191 | struct input_event input_event; 192 | int input_fd; 193 | int rc; 194 | int sensorId = SENSOR_TYPE_GYROSCOPE; 195 | 196 | if (handlers == NULL || handlers->data == NULL || event == NULL) 197 | return -EINVAL; 198 | 199 | if (mFlushed & (1 << sensorId)) { /* Send flush META_DATA_FLUSH_COMPLETE immediately */ 200 | sensors_event_t sensor_event; 201 | memset(&sensor_event, 0, sizeof(sensor_event)); 202 | sensor_event.version = META_DATA_VERSION; 203 | sensor_event.type = SENSOR_TYPE_META_DATA; 204 | sensor_event.meta_data.sensor = sensorId; 205 | sensor_event.meta_data.what = 0; 206 | *event++ = sensor_event; 207 | mFlushed &= ~(0x01 << sensorId); 208 | //ALOGD("AkmSensor: %s Flushed sensorId: %d", __func__, sensorId); 209 | } 210 | 211 | data = (struct lsm330dlc_gyroscope_data *) handlers->data; 212 | 213 | input_fd = handlers->poll_fd; 214 | if (input_fd < 0) 215 | return -EINVAL; 216 | 217 | memset(event, 0, sizeof(struct sensors_event_t)); 218 | event->version = sizeof(struct sensors_event_t); 219 | event->sensor = handlers->handle; 220 | event->type = handlers->handle; 221 | 222 | event->gyro.x = data->gyro.x; 223 | event->gyro.y = data->gyro.y; 224 | event->gyro.z = data->gyro.z; 225 | 226 | event->gyro.status = SENSOR_STATUS_ACCURACY_MEDIUM; 227 | 228 | do { 229 | rc = read(input_fd, &input_event, sizeof(input_event)); 230 | if (rc < (int) sizeof(input_event)) 231 | break; 232 | 233 | if (input_event.type == EV_REL) { 234 | switch (input_event.code) { 235 | case REL_RX: 236 | event->gyro.x = lsm330dlc_gyroscope_convert(input_event.value); 237 | break; 238 | case REL_RY: 239 | event->gyro.y = lsm330dlc_gyroscope_convert(input_event.value); 240 | break; 241 | case REL_RZ: 242 | event->gyro.z = lsm330dlc_gyroscope_convert(input_event.value); 243 | break; 244 | default: 245 | continue; 246 | } 247 | } else if (input_event.type == EV_SYN) { 248 | if (input_event.code == SYN_REPORT) 249 | event->timestamp = getTimestamp(); 250 | } 251 | } while (input_event.type != EV_SYN); 252 | 253 | data->gyro.x = event->gyro.x; 254 | data->gyro.y = event->gyro.y; 255 | data->gyro.z = event->gyro.z; 256 | 257 | return 0; 258 | } 259 | 260 | struct noteII_sensors_handlers lsm330dlc_gyroscope = { 261 | .name = "LSM330DLC Gyroscope", 262 | .handle = SENSOR_TYPE_GYROSCOPE, 263 | .init = lsm330dlc_gyroscope_init, 264 | .deinit = lsm330dlc_gyroscope_deinit, 265 | .activate = lsm330dlc_gyroscope_activate, 266 | .deactivate = lsm330dlc_gyroscope_deactivate, 267 | .set_delay = lsm330dlc_gyroscope_set_delay, 268 | .get_data = lsm330dlc_gyroscope_get_data, 269 | .activated = 0, 270 | .needed = 0, 271 | .poll_fd = -1, 272 | .data = NULL, 273 | }; 274 | -------------------------------------------------------------------------------- /libsensors/noteII_sensors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define LOG_TAG "NoteII_sensors" 30 | #include 31 | 32 | #include "noteII_sensors.h" 33 | 34 | int mFlushed; 35 | 36 | /* 37 | * Sensors list 38 | */ 39 | 40 | struct sensor_t smdk4x12_sensors[] = { 41 | { "LSM330DLC 3-Axis Accelerometer", "STMicroelectronics", 1, SENSOR_TYPE_ACCELEROMETER, 42 | SENSOR_TYPE_ACCELEROMETER, 2 * GRAVITY_EARTH, 0.0096f, 0.23f, 20000, 0, 0, SENSOR_STRING_TYPE_ACCELEROMETER, 0, 0, 43 | SENSOR_FLAG_ON_CHANGE_MODE, {}, }, 44 | { "AKM8963 Magnetic Sensor", "Asahi Kasei", 1, SENSOR_TYPE_MAGNETIC_FIELD, 45 | SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, 1.0f/16.0f, 6.8f, 16667, 0, 0, SENSOR_STRING_TYPE_MAGNETIC_FIELD, 0, 0, 46 | SENSOR_FLAG_ON_CHANGE_MODE, {}, }, 47 | { "CM36651 Light Sensor", "Capella", 1, SENSOR_TYPE_LIGHT, 48 | SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.75f, 0, 0, 0, SENSOR_STRING_TYPE_LIGHT, 0, 0, 49 | SENSOR_FLAG_ON_CHANGE_MODE, {}, }, 50 | { "CM36651 Proximity Sensor", "Capella", 1, SENSOR_TYPE_PROXIMITY, 51 | SENSOR_TYPE_PROXIMITY, 5.0f, 5.0f, 0.75f, 0, 0, 0, SENSOR_STRING_TYPE_PROXIMITY, 0, 0, 52 | SENSOR_FLAG_WAKE_UP | SENSOR_FLAG_ON_CHANGE_MODE, {}, }, 53 | { "LSM330DLC Gyroscope Sensor", "STMicroelectronics", 1, SENSOR_TYPE_GYROSCOPE, 54 | SENSOR_TYPE_GYROSCOPE, 500.0f * (3.1415926535f / 180.0f), (70.0f / 4000.0f) * (3.1415926535f / 180.0f), 6.1f, 5000, 0, 0, SENSOR_STRING_TYPE_GYROSCOPE, 0, 0, 55 | SENSOR_FLAG_ON_CHANGE_MODE, {}, }, 56 | { "BMP180 Pressure Sensor", "Bosch", 1, SENSOR_TYPE_PRESSURE, 57 | SENSOR_TYPE_PRESSURE, 1100.0f, 0.01f, 0.06f, 50000, 0, 0, SENSOR_STRING_TYPE_PRESSURE, 0, 20000, 58 | SENSOR_FLAG_CONTINUOUS_MODE, {}, }, 59 | }; 60 | 61 | int smdk4x12_sensors_count = sizeof(smdk4x12_sensors) / sizeof(struct sensor_t); 62 | 63 | struct noteII_sensors_handlers *noteII_sensors_handlers[] = { 64 | &lsm330dlc_acceleration, 65 | &akm8963, 66 | &cm36651_proximity, 67 | &cm36651_light, 68 | &lsm330dlc_gyroscope, 69 | &bmp180, 70 | }; 71 | 72 | int noteII_sensors_handlers_count = sizeof(noteII_sensors_handlers) / 73 | sizeof(struct noteII_sensors_handlers *); 74 | 75 | //NOTEII Sensors 76 | 77 | int smdk4x12_sensors_activate(struct sensors_poll_device_t *dev, int handle, 78 | int enabled) 79 | { 80 | struct smdk4x12_sensors_device *device; 81 | int i; 82 | 83 | //ALOGD("%s(%p, %d, %d)", __func__, dev, handle, enabled); 84 | 85 | if (dev == NULL) 86 | return -EINVAL; 87 | 88 | device = (struct smdk4x12_sensors_device *) dev; 89 | 90 | if (device->handlers == NULL || device->handlers_count <= 0) 91 | return -EINVAL; 92 | 93 | for (i = 0; i < device->handlers_count; i++) { 94 | if (device->handlers[i] == NULL) 95 | continue; 96 | 97 | if (device->handlers[i]->handle == handle) { 98 | if (enabled && device->handlers[i]->activate != NULL) { 99 | device->handlers[i]->needed |= SMDK4x12_SENSORS_NEEDED_API; 100 | if (device->handlers[i]->needed == SMDK4x12_SENSORS_NEEDED_API) 101 | return device->handlers[i]->activate(device->handlers[i]); 102 | else 103 | return 0; 104 | } else if (!enabled && device->handlers[i]->deactivate != NULL) { 105 | device->handlers[i]->needed &= ~SMDK4x12_SENSORS_NEEDED_API; 106 | if (device->handlers[i]->needed == 0) 107 | return device->handlers[i]->deactivate(device->handlers[i]); 108 | else 109 | return 0; 110 | } 111 | } 112 | } 113 | 114 | return -1; 115 | } 116 | 117 | int smdk4x12_sensors_set_delay(struct sensors_poll_device_t *dev, int handle, 118 | int64_t ns) 119 | { 120 | struct smdk4x12_sensors_device *device; 121 | int i; 122 | 123 | //ALOGD("%s(%p, %d, %" PRId64 ")", __func__, dev, handle, ns); 124 | 125 | if (dev == NULL) 126 | return -EINVAL; 127 | 128 | device = (struct smdk4x12_sensors_device *) dev; 129 | 130 | if (device->handlers == NULL || device->handlers_count <= 0) 131 | return -EINVAL; 132 | 133 | for (i = 0; i < device->handlers_count; i++) { 134 | if (device->handlers[i] == NULL) 135 | continue; 136 | 137 | if (device->handlers[i]->handle == handle && device->handlers[i]->set_delay != NULL) 138 | return device->handlers[i]->set_delay(device->handlers[i], ns); 139 | } 140 | 141 | return 0; 142 | } 143 | 144 | static int smdk4x12_sensors_batch(struct sensors_poll_device_1 *dev, int handle, int flags, int64_t period_ns, int64_t timeout) 145 | { 146 | //ALOGD("batch"); 147 | (void)flags; 148 | (void)timeout; 149 | smdk4x12_sensors_set_delay((struct sensors_poll_device_t *)dev, handle, period_ns); 150 | return 0; 151 | } 152 | 153 | static int smdk4x12_sensors_flush(struct sensors_poll_device_1 *dev, int handle) 154 | { 155 | //ALOGD("flush"); 156 | (void)dev; 157 | mFlushed |= (1 << handle); 158 | //ALOGD("%s: handle: %d", __func__, handle); 159 | return 0; 160 | } 161 | 162 | 163 | int smdk4x12_sensors_poll(struct sensors_poll_device_t *dev, 164 | struct sensors_event_t* data, int count) 165 | { 166 | struct smdk4x12_sensors_device *device; 167 | int i, j; 168 | int c, n; 169 | int poll_rc, rc; 170 | 171 | if (dev == NULL) 172 | return -EINVAL; 173 | 174 | device = (struct smdk4x12_sensors_device *) dev; 175 | 176 | if (device->handlers == NULL || device->handlers_count <= 0 || 177 | device->poll_fds == NULL || device->poll_fds_count <= 0) 178 | return -EINVAL; 179 | 180 | n = 0; 181 | 182 | do { 183 | poll_rc = poll(device->poll_fds, device->poll_fds_count, n > 0 ? 0 : -1); 184 | if (poll_rc < 0) 185 | return -1; 186 | 187 | for (i = 0; i < device->poll_fds_count; i++) { 188 | if (!(device->poll_fds[i].revents & POLLIN)) 189 | continue; 190 | 191 | for (j = 0; j < device->handlers_count; j++) { 192 | if (device->handlers[j] == NULL || device->handlers[j]->poll_fd != device->poll_fds[i].fd || device->handlers[j]->get_data == NULL) 193 | continue; 194 | 195 | rc = device->handlers[j]->get_data(device->handlers[j], &data[n]); 196 | if (rc < 0) { 197 | device->poll_fds[i].revents = 0; 198 | poll_rc = -1; 199 | } else { 200 | n++; 201 | count--; 202 | } 203 | } 204 | } 205 | } while ((poll_rc > 0 || n < 1) && count > 0); 206 | 207 | return n; 208 | } 209 | 210 | /* 211 | * Interface 212 | */ 213 | 214 | int smdk4x12_sensors_close(hw_device_t *device) 215 | { 216 | struct smdk4x12_sensors_device *smdk4x12_sensors_device; 217 | int i; 218 | 219 | //ALOGD("%s(%p)", __func__, device); 220 | 221 | if (device == NULL) 222 | return -EINVAL; 223 | 224 | smdk4x12_sensors_device = (struct smdk4x12_sensors_device *) device; 225 | 226 | if (smdk4x12_sensors_device->poll_fds != NULL) 227 | free(smdk4x12_sensors_device->poll_fds); 228 | 229 | for (i = 0; i < smdk4x12_sensors_device->handlers_count; i++) { 230 | if (smdk4x12_sensors_device->handlers[i] == NULL || smdk4x12_sensors_device->handlers[i]->deinit == NULL) 231 | continue; 232 | 233 | smdk4x12_sensors_device->handlers[i]->deinit(smdk4x12_sensors_device->handlers[i]); 234 | } 235 | 236 | free(device); 237 | 238 | return 0; 239 | } 240 | 241 | int smdk4x12_sensors_open(const struct hw_module_t* module, const char *id, 242 | struct hw_device_t** device) 243 | { 244 | android_set_application_target_sdk_version(__ANDROID_API_L_MR1__); 245 | struct smdk4x12_sensors_device *smdk4x12_sensors_device; 246 | int p, i; 247 | 248 | //ALOGD("%s(%p, %s, %p)", __func__, module, id, device); 249 | 250 | if (module == NULL || device == NULL) 251 | return -EINVAL; 252 | 253 | smdk4x12_sensors_device = (struct smdk4x12_sensors_device *) 254 | calloc(1, sizeof(struct smdk4x12_sensors_device)); 255 | smdk4x12_sensors_device->device.common.tag = HARDWARE_DEVICE_TAG; 256 | smdk4x12_sensors_device->device.common.version = SENSORS_DEVICE_API_VERSION_1_3; 257 | smdk4x12_sensors_device->device.common.module = (struct hw_module_t *) module; 258 | smdk4x12_sensors_device->device.common.close = smdk4x12_sensors_close; 259 | smdk4x12_sensors_device->device.activate = smdk4x12_sensors_activate; 260 | smdk4x12_sensors_device->device.setDelay = smdk4x12_sensors_set_delay; 261 | smdk4x12_sensors_device->device.poll = smdk4x12_sensors_poll; 262 | smdk4x12_sensors_device->device.batch = smdk4x12_sensors_batch; 263 | smdk4x12_sensors_device->device.flush = smdk4x12_sensors_flush; 264 | smdk4x12_sensors_device->handlers = noteII_sensors_handlers; 265 | smdk4x12_sensors_device->handlers_count = noteII_sensors_handlers_count; 266 | smdk4x12_sensors_device->poll_fds = (struct pollfd *) 267 | calloc(1, noteII_sensors_handlers_count * sizeof(struct pollfd)); 268 | 269 | p = 0; 270 | for (i = 0; i < noteII_sensors_handlers_count; i++) { 271 | if (noteII_sensors_handlers[i] == NULL || noteII_sensors_handlers[i]->init == NULL) 272 | continue; 273 | 274 | noteII_sensors_handlers[i]->init(noteII_sensors_handlers[i], smdk4x12_sensors_device); 275 | if (noteII_sensors_handlers[i]->poll_fd >= 0) { 276 | smdk4x12_sensors_device->poll_fds[p].fd = noteII_sensors_handlers[i]->poll_fd; 277 | smdk4x12_sensors_device->poll_fds[p].events = POLLIN; 278 | p++; 279 | } 280 | } 281 | 282 | smdk4x12_sensors_device->poll_fds_count = p; 283 | 284 | *device = &(smdk4x12_sensors_device->device.common); 285 | 286 | return 0; 287 | } 288 | 289 | int smdk4x12_sensors_get_sensors_list(struct sensors_module_t* module, 290 | const struct sensor_t **sensors_p) 291 | { 292 | //ALOGD("%s(%p, %p)", __func__, module, sensors_p); 293 | 294 | if (sensors_p == NULL) 295 | return -EINVAL; 296 | 297 | *sensors_p = smdk4x12_sensors; 298 | return smdk4x12_sensors_count; 299 | } 300 | 301 | struct hw_module_methods_t smdk4x12_sensors_module_methods = { 302 | .open = smdk4x12_sensors_open, 303 | }; 304 | 305 | struct sensors_module_t HAL_MODULE_INFO_SYM = { 306 | .common = { 307 | .tag = HARDWARE_MODULE_TAG, 308 | .version_major = 1, 309 | .version_minor = 0, 310 | .id = SENSORS_HARDWARE_MODULE_ID, 311 | .name = "SMDK4x12 Sensors", 312 | .author = "Răileanu Cosmin", 313 | .methods = &smdk4x12_sensors_module_methods, 314 | }, 315 | .get_sensors_list = smdk4x12_sensors_get_sensors_list, 316 | }; 317 | -------------------------------------------------------------------------------- /libsensors/noteII_sensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #define __STDC_FORMAT_MACROS 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #ifndef _NOTE_II_SENSORS_H 28 | #define _NOTE_II_SENSORS_H 29 | 30 | #define SMDK4x12_SENSORS_NEEDED_API (1 << 0) 31 | 32 | struct smdk4x12_sensors_device; 33 | 34 | struct noteII_sensors_handlers { 35 | char *name; 36 | int handle; 37 | 38 | int (*init)(struct noteII_sensors_handlers *handlers, 39 | struct smdk4x12_sensors_device *device); 40 | int (*deinit)(struct noteII_sensors_handlers *handlers); 41 | int (*activate)(struct noteII_sensors_handlers *handlers); 42 | int (*deactivate)(struct noteII_sensors_handlers *handlers); 43 | int (*set_delay)(struct noteII_sensors_handlers *handlers, 44 | int64_t delay); 45 | int (*get_data)(struct noteII_sensors_handlers *handlers, 46 | struct sensors_event_t *event); 47 | 48 | int activated; 49 | int needed; 50 | int poll_fd; 51 | 52 | void *data; 53 | }; 54 | 55 | struct smdk4x12_sensors_device { 56 | sensors_poll_device_1_t device; 57 | 58 | struct noteII_sensors_handlers **handlers; 59 | int handlers_count; 60 | 61 | struct pollfd *poll_fds; 62 | int poll_fds_count; 63 | }; 64 | 65 | extern struct noteII_sensors_handlers *noteII_sensors_handlers[]; 66 | extern int noteII_sensors_handlers_count; 67 | 68 | int smdk4x12_sensors_activate(struct sensors_poll_device_t *dev, int handle, 69 | int enabled); 70 | int smdk4x12_sensors_set_delay(struct sensors_poll_device_t *dev, int handle, 71 | int64_t ns); 72 | int smdk4x12_sensors_poll(struct sensors_poll_device_t *dev, 73 | struct sensors_event_t* data, int count); 74 | 75 | //Input 76 | void input_event_set(struct input_event *event, int type, int code, int value); 77 | int64_t timestamp(struct timeval *time); 78 | int64_t input_timestamp(struct input_event *event); 79 | int uinput_rel_create(const char *name); 80 | void uinput_destroy(int uinput_fd); 81 | int input_open(char *name); 82 | int sysfs_path_prefix(char *name, char *path_prefix); 83 | int64_t sysfs_value_read(char *path); 84 | int sysfs_value_write(char *path, int64_t value); 85 | int sysfs_string_read(char *path, char *buffer, size_t length); 86 | int sysfs_string_write(char *path, char *buffer, size_t length); 87 | //~Input 88 | 89 | //Sensors 90 | //I hate SSP 91 | int ssp_sensor_enable(int sensor_type); 92 | int ssp_sensor_disable(int sensor_type); 93 | 94 | extern struct noteII_sensors_handlers lsm330dlc_acceleration; 95 | extern struct noteII_sensors_handlers akm8963; 96 | extern struct noteII_sensors_handlers cm36651_proximity; 97 | extern struct noteII_sensors_handlers cm36651_light; 98 | extern struct noteII_sensors_handlers lsm330dlc_gyroscope; 99 | extern struct noteII_sensors_handlers bmp180; 100 | //~Sensors 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /libsensors/ssp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Răileanu Cosmin 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #define LOG_TAG "NoteII_ssp" 25 | #include 26 | 27 | #include "noteII_sensors.h" 28 | #include "ssp.h" 29 | 30 | int ssp_sensor_enable(int sensor_type) 31 | { 32 | char path_enable[PATH_MAX] = "/sys/class/sensors/ssp_sensor/enable"; 33 | int value; 34 | int rc; 35 | 36 | //ALOGD("%s(%d)", __func__, sensor_type); 37 | 38 | if (sensor_type < 0 || sensor_type >= SENSOR_FACTORY_MAX) 39 | return -EINVAL; 40 | 41 | value = sysfs_value_read(path_enable); 42 | if (value < 0) 43 | value = 0; 44 | 45 | value |= (1 << sensor_type); 46 | 47 | rc = sysfs_value_write(path_enable, value); 48 | if (rc < 0) 49 | { 50 | //ALOGD("Check path_enable! ERROR! SENSOR: ", sensor_type); 51 | return -1; 52 | } 53 | 54 | return 0; 55 | } 56 | 57 | int ssp_sensor_disable(int sensor_type) 58 | { 59 | char path_enable[PATH_MAX] = "/sys/class/sensors/ssp_sensor/enable"; 60 | int value; 61 | int rc; 62 | 63 | //ALOGD("%s(%d)", __func__, sensor_type); 64 | 65 | if (sensor_type < 0 || sensor_type >= SENSOR_FACTORY_MAX) 66 | return -EINVAL; 67 | 68 | value = sysfs_value_read(path_enable); 69 | if (value < 0) 70 | value = 0; 71 | 72 | value &= ~(1 << sensor_type); 73 | 74 | rc = sysfs_value_write(path_enable, value); 75 | if (rc < 0) 76 | return -1; 77 | 78 | //ALOGD("DISABLED: ", sensor_type); 79 | return 0; 80 | } -------------------------------------------------------------------------------- /libsensors/ssp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012, Samsung Electronics Co. Ltd. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | */ 15 | 16 | #ifndef __SSP_PRJ_H__ 17 | #define __SSP_PRJ_H__ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #define SSP_SW_RESET_TIME 3000 25 | #define DEFUALT_POLLING_DELAY (200 * NSEC_PER_MSEC) 26 | #define PROX_AVG_READ_NUM 80 27 | #define DEFAULT_RETRIES 3 28 | 29 | /* Sensor Sampling Time Define */ 30 | enum { 31 | SENSOR_NS_DELAY_FASTEST = 10000000, /* 10msec */ 32 | SENSOR_NS_DELAY_GAME = 20000000, /* 20msec */ 33 | SENSOR_NS_DELAY_UI = 66700000, /* 66.7msec */ 34 | SENSOR_NS_DELAY_NORMAL = 200000000, /* 200msec */ 35 | }; 36 | 37 | enum { 38 | SENSOR_MS_DELAY_FASTEST = 10, /* 10msec */ 39 | SENSOR_MS_DELAY_GAME = 20, /* 20msec */ 40 | SENSOR_MS_DELAY_UI = 66, /* 66.7msec */ 41 | SENSOR_MS_DELAY_NORMAL = 200, /* 200msec */ 42 | }; 43 | 44 | enum { 45 | SENSOR_CMD_DELAY_FASTEST = 0, /* 10msec */ 46 | SENSOR_CMD_DELAY_GAME, /* 20msec */ 47 | SENSOR_CMD_DELAY_UI, /* 66.7msec */ 48 | SENSOR_CMD_DELAY_NORMAL, /* 200msec */ 49 | }; 50 | 51 | /* 52 | * SENSOR_DELAY_SET_STATE 53 | * Check delay set to avoid sending ADD instruction twice 54 | */ 55 | enum { 56 | INITIALIZATION_STATE = 0, 57 | NO_SENSOR_STATE, 58 | ADD_SENSOR_STATE, 59 | RUNNING_SENSOR_STATE, 60 | }; 61 | 62 | /* Gyroscope DPS */ 63 | #define GYROSCOPE_DPS250 250 64 | #define GYROSCOPE_DPS500 500 65 | #define GYROSCOPE_DPS2000 2000 66 | 67 | /* kernel -> ssp manager cmd*/ 68 | #define SSP_LIBRARY_SLEEP_CMD (1 << 5) 69 | #define SSP_LIBRARY_LARGE_DATA_CMD (1 << 6) 70 | #define SSP_LIBRARY_WAKEUP_CMD (1 << 7) 71 | 72 | /* ioctl command */ 73 | #define AKMIO 0xA1 74 | #define ECS_IOCTL_GET_FUSEROMDATA _IOR(AKMIO, 0x01, unsigned char[3]) 75 | #define ECS_IOCTL_GET_MAGDATA _IOR(AKMIO, 0x02, unsigned char[8]) 76 | #define ECS_IOCTL_GET_ACCDATA _IOR(AKMIO, 0x03, int[3]) 77 | 78 | /* AP -> SSP Instruction */ 79 | #define MSG2SSP_INST_BYPASS_SENSOR_ADD 0xA1 80 | #define MSG2SSP_INST_BYPASS_SENSOR_REMOVE 0xA2 81 | #define MSG2SSP_INST_REMOVE_ALL 0xA3 82 | #define MSG2SSP_INST_CHANGE_DELAY 0xA4 83 | #define MSG2SSP_INST_SENSOR_SELFTEST 0xA8 84 | #define MSG2SSP_INST_LIBRARY_ADD 0xB1 85 | #define MSG2SSP_INST_LIBRARY_REMOVE 0xB2 86 | 87 | #define MSG2SSP_AP_STT 0xC8 88 | #define MSG2SSP_AP_STATUS_WAKEUP 0xD1 89 | #define MSG2SSP_AP_STATUS_SLEEP 0xD2 90 | #define MSG2SSP_AP_STATUS_RESET 0xD3 91 | #define MSG2SSP_AP_WHOAMI 0x0F 92 | #define MSG2SSP_AP_FIRMWARE_REV 0xF0 93 | #define MSG2SSP_AP_SENSOR_FORMATION 0xF1 94 | #define MSG2SSP_AP_SENSOR_PROXTHRESHOLD 0xF2 95 | #define MSG2SSP_AP_SENSOR_BARCODE_EMUL 0xF3 96 | #define MSG2SSP_AP_SENSOR_SCANNING 0xF4 97 | 98 | #define MSG2SSP_AP_FUSEROM 0X01 99 | 100 | /* AP -> SSP Data Protocol Frame Field */ 101 | #define MSG2SSP_SSP_SLEEP 0xC1 102 | #define MSG2SSP_STS 0xC2 /* Start to Send */ 103 | #define MSG2SSP_RTS 0xC4 /* Ready to Send */ 104 | #define MSG2SSP_STT 0xC8 105 | #define MSG2SSP_SRM 0xCA /* Start to Read MSG */ 106 | #define MSG2SSP_SSM 0xCB /* Start to Send MSG */ 107 | #define MSG2SSP_SSD 0xCE /* Start to Send Data Type & Length */ 108 | 109 | /* SSP -> AP ACK about write CMD */ 110 | #define MSG_ACK 0x80 /* ACK from SSP to AP */ 111 | #define MSG_NAK 0x70 /* NAK from SSP to AP */ 112 | 113 | 114 | /* SSP_INSTRUCTION_CMD */ 115 | enum { 116 | REMOVE_SENSOR = 0, 117 | ADD_SENSOR, 118 | CHANGE_DELAY, 119 | GO_SLEEP, 120 | FACTORY_MODE, 121 | REMOVE_LIBRARY, 122 | ADD_LIBRARY, 123 | }; 124 | 125 | /* SENSOR_TYPE */ 126 | enum { 127 | ACCELEROMETER_SENSOR = 0, 128 | GYROSCOPE_SENSOR, 129 | GEOMAGNETIC_SENSOR, 130 | PRESSURE_SENSOR, 131 | GESTURE_SENSOR, 132 | PROXIMITY_SENSOR, 133 | LIGHT_SENSOR, 134 | PROXIMITY_RAW, 135 | SENSOR_MAX, 136 | }; 137 | 138 | /* SENSOR_FACTORY_MODE_TYPE */ 139 | enum { 140 | ACCELEROMETER_FACTORY = 0, 141 | GYROSCOPE_FACTORY, 142 | GEOMAGNETIC_FACTORY, 143 | PRESSURE_FACTORY, 144 | MCU_FACTORY, 145 | GYROSCOPE_TEMP_FACTORY, 146 | GYROSCOPE_DPS_FACTORY, 147 | MCU_SLEEP_FACTORY, 148 | SENSOR_FACTORY_MAX, 149 | }; 150 | 151 | struct sensor_value { 152 | union { 153 | struct { 154 | __s16 x; 155 | __s16 y; 156 | __s16 z; 157 | }; 158 | struct { 159 | __u16 r; 160 | __u16 g; 161 | __u16 b; 162 | __u16 w; 163 | }; 164 | __u8 prox[4]; 165 | __s16 data[4]; 166 | __s32 pressure[3]; 167 | }; 168 | }; 169 | 170 | struct calibraion_data { 171 | int x; 172 | int y; 173 | int z; 174 | }; 175 | 176 | #endif -------------------------------------------------------------------------------- /lineage.dependencies: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "repository": "android_device_samsung_smdk4412-common", 4 | "target_path": "device/samsung/smdk4412-common" 5 | }, 6 | { 7 | "repository": "android_kernel_samsung_smdk4412", 8 | "target_path": "kernel/samsung/smdk4412" 9 | }, 10 | { 11 | "repository": "android_packages_apps_SamsungServiceMode", 12 | "target_path": "packages/apps/SamsungServiceMode" 13 | }, 14 | { 15 | "repository": "android_hardware_samsung", 16 | "target_path": "hardware/samsung" 17 | }, 18 | { 19 | "repository": "android_external_stlport", 20 | "target_path": "external/stlport" 21 | } 22 | ] -------------------------------------------------------------------------------- /lineage_n7100.mk: -------------------------------------------------------------------------------- 1 | # Release name 2 | PRODUCT_RELEASE_NAME := n7100 3 | 4 | # Inherit device configuration 5 | $(call inherit-product, device/samsung/smdk4412-common/common.mk) 6 | $(call inherit-product, device/samsung/n7100/n7100.mk) 7 | 8 | # Inherit from the common Open Source product configuration 9 | $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk) 10 | 11 | # Boot animation 12 | TARGET_SCREEN_HEIGHT := 1280 13 | TARGET_SCREEN_WIDTH := 720 14 | 15 | # Inherit some common stuff. 16 | $(call inherit-product, vendor/lineage/config/common_full_phone.mk) 17 | 18 | # Device identifier. This must come after all inclusions 19 | PRODUCT_DEVICE := n7100 20 | PRODUCT_NAME := lineage_n7100 21 | PRODUCT_BRAND := samsung 22 | PRODUCT_MODEL := GT-N7100 23 | PRODUCT_MANUFACTURER := samsung 24 | 25 | # Set build fingerprint / ID / Product Name ect. 26 | PRODUCT_BUILD_PROP_OVERRIDES += \ 27 | PRODUCT_NAME=t03gxx \ 28 | TARGET_DEVICE=t03g \ 29 | PRIVATE_BUILD_DESC="t03gxx-user 4.3 JSS15J N7100XXUEMK4 release-keys" 30 | 31 | BUILD_FINGERPRINT := samsung/t03gxx/t03g:4.3/JSS15J/N7100XXUEMK4:user/release-keys 32 | -------------------------------------------------------------------------------- /n7100.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 | LOCAL_PATH := device/samsung/n7100 18 | COMMON_PATH := device/samsung/smdk4412-common 19 | 20 | # Overlay 21 | DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay 22 | 23 | # Screen density 24 | PRODUCT_AAPT_CONFIG := normal 25 | PRODUCT_AAPT_PREF_CONFIG := xhdpi 26 | 27 | # Init files 28 | PRODUCT_COPY_FILES += \ 29 | $(LOCAL_PATH)/rootdir/fstab.smdk4x12:root/fstab.smdk4x12 \ 30 | $(LOCAL_PATH)/rootdir/init.target.rc:root/init.target.rc \ 31 | $(LOCAL_PATH)/rootdir/init.target.usb.rc:root/init.target.usb.rc 32 | 33 | # Audio 34 | PRODUCT_COPY_FILES += \ 35 | $(LOCAL_PATH)/configs/tiny_hw.xml:system/etc/sound/t03g 36 | 37 | # Sensors 38 | PRODUCT_PACKAGES += \ 39 | sensors.smdk4x12 40 | 41 | # Gps 42 | PRODUCT_COPY_FILES += \ 43 | $(LOCAL_PATH)/configs/gps.xml:system/vendor/etc/gps.xml \ 44 | $(LOCAL_PATH)/gps_daemon.sh:system/vendor/bin/gps_daemon.sh 45 | 46 | # idc 47 | PRODUCT_COPY_FILES += \ 48 | $(LOCAL_PATH)/idc/sec_e-pen.idc:system/usr/idc/sec_e-pen.idc 49 | 50 | # Keylayout 51 | PRODUCT_COPY_FILES += \ 52 | $(LOCAL_PATH)/keylayout/sec_e-pen.kl:system/usr/keylayout/sec_e-pen.kl \ 53 | $(LOCAL_PATH)/keylayout/sec_touchkey.kl:system/usr/keylayout/sec_touchkey.kl 54 | 55 | # Product specific Packages 56 | PRODUCT_PACKAGES += \ 57 | libsecril-client \ 58 | libsecril-client-sap \ 59 | SamsungServiceMode \ 60 | tinyplay 61 | 62 | # RIL 63 | PRODUCT_PACKAGES += \ 64 | libsecril-shim 65 | 66 | # NFC 67 | PRODUCT_PACKAGES += \ 68 | nfc.exynos4 \ 69 | libnfc \ 70 | libnfc_jni \ 71 | Nfc \ 72 | Tag 73 | 74 | # Camera 75 | PRODUCT_PACKAGES += \ 76 | camera.smdk4x12 77 | 78 | # f2fs 79 | PRODUCT_PACKAGES += \ 80 | fibmap.f2fs \ 81 | fsck.f2fs \ 82 | mkfs.f2fs 83 | 84 | PRODUCT_COPY_FILES += \ 85 | frameworks/base/nfc-extras/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml \ 86 | frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \ 87 | frameworks/native/data/etc/android.hardware.nfc.xml:system/etc/permissions/android.hardware.nfc.xml 88 | 89 | # NFCEE access control 90 | ifeq ($(TARGET_BUILD_VARIANT),user) 91 | NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access.xml 92 | else 93 | NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access_debug.xml 94 | endif 95 | 96 | PRODUCT_COPY_FILES += \ 97 | $(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml 98 | 99 | PRODUCT_PACKAGES += \ 100 | com.android.nfc_extras 101 | 102 | # RIL 103 | PRODUCT_PROPERTY_OVERRIDES += \ 104 | ro.telephony.ril_class=SamsungExynos4RIL \ 105 | ro.telephony.call_ring.multiple=false \ 106 | ro.telephony.call_ring.delay=3000 107 | 108 | # These are the hardware-specific features 109 | PRODUCT_COPY_FILES += \ 110 | frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \ 111 | frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml 112 | 113 | # UMS 114 | PRODUCT_COPY_FILES += \ 115 | $(LOCAL_PATH)/configs/ums_init.sh:system/bin/ums_init.sh 116 | 117 | $(call inherit-product-if-exists, vendor/samsung/n7100/n7100-vendor.mk) 118 | # Vendor properties 119 | -include $(LOCAL_PATH)/vendor_prop.mk 120 | -------------------------------------------------------------------------------- /overlay/frameworks/base/Keyguard/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | true 24 | 25 | 26 | true 27 | 28 | 29 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComicoX/android_device_samsung_n7100/53d6d2b455ec14bf18bacc8b99f00319d14f9e7f/overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_arrow.png -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_anchor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComicoX/android_device_samsung_n7100/53d6d2b455ec14bf18bacc8b99f00319d14f9e7f/overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_anchor.png -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComicoX/android_device_samsung_n7100/53d6d2b455ec14bf18bacc8b99f00319d14f9e7f/overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_hover.png -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComicoX/android_device_samsung_n7100/53d6d2b455ec14bf18bacc8b99f00319d14f9e7f/overlay/frameworks/base/core/res/res/drawable-xhdpi/pointer_spot_touch.png -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 25 | false 26 | 27 | 38 | 39 | 150 40 | 300 41 | 600 42 | 1000 43 | 3000 44 | 8000 45 | 15000 46 | 28000 47 | 41000 48 | 54000 49 | 67000 50 | 80000 51 | 100000 52 | 150000 53 | 200000 54 | 55 | 56 | 60 | 61 | 20 62 | 30 63 | 40 64 | 50 65 | 60 66 | 70 67 | 80 68 | 100 69 | 120 70 | 140 71 | 160 72 | 180 73 | 200 74 | 220 75 | 240 76 | 255 77 | 78 | 79 | 83 | 84 | 0 85 | 0 86 | 0 87 | 0 88 | 0 89 | 0 90 | 0 91 | 0 92 | 0 93 | 0 94 | 0 95 | 0 96 | 0 97 | 0 98 | 0 99 | 0 100 | 0 101 | 0 102 | 0 103 | 0 104 | 0 105 | 106 | 107 | 112 | 113 | 0 114 | 0 115 | 0 116 | 0 117 | 0 118 | 0 119 | 0 120 | 0 121 | 0 122 | 0 123 | 0 124 | 0 125 | 0 126 | 0 127 | 0 128 | 0 129 | 0 130 | 0 131 | 0 132 | 0 133 | 0 134 | 135 | 136 | 138 | 139 | 142 | 144 | 147 | 148 | 149 | "wifi,1,1,1,-1,true" 150 | "mobile,0,0,0,-1,true" 151 | "mobile_mms,2,0,2,60000,true" 152 | "mobile_supl,3,0,2,60000,true" 153 | "mobile_dun,4,0,3,60000,true" 154 | "mobile_hipri,5,0,3,60000,true" 155 | "mobile_bluetooth,7,7,1,-1,true" 156 | "wifi_p2p,13,1,0,-1,true" 157 | 158 | 159 | 162 | 164 | 165 | "1,1" 166 | "0,1" 167 | "7,1" 168 | 169 | 170 | 173 | 174 | "rndis0" 175 | 176 | 177 | 178 | 180 | 181 | 0 182 | 1 183 | 5 184 | 7 185 | 186 | 187 | 188 | pdp0 189 | 190 | 191 | true 192 | 193 | 194 | true 195 | 196 | 197 | 198 | 199 | 200 | #ffffffff 201 | 202 | 203 | 1000 204 | 205 | 206 | 9000 207 | 208 | 209 | true 210 | 211 | 223 | 224 | 225 | 237 | 238 | 239 | 248 | 3 249 | 250 | 259 | 1 260 | 261 | 262 | 263 | 264 | 266 | 267 | 268 | com.android.systemui/com.android.systemui.doze.DozeService 269 | 20 270 | true 271 | true 272 | 273 | 274 | 4 275 | 276 | 277 | false 278 | 279 | 291 | true 292 | 293 | 300 | true 301 | 302 | 303 | true 304 | 305 | 306 | false 307 | 308 | 313 | GPRS|EDGE|WCDMA 314 | 315 | 317 | true 318 | 319 | 320 | 321 | 322 | 323 | true 324 | 325 | 326 | false 327 | 328 | 331 | true 332 | 333 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/pa_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 23 | 24 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/xml/config_webview_packages.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 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 8 | 9 | 10 | 11 | 12 | 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 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/xml/power_profile.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 0 23 | 172 24 | 17 25 | 0.3 26 | 155 27 | 0.3 28 | 96 29 | 70 30 | 50 31 | 270 32 | 250 33 | 82 34 | 1 35 | 36 | 3.4 37 | 3.4 38 | 39 | 40 | 1600000 41 | 1400000 42 | 1200000 43 | 1000000 44 | 800000 45 | 400000 46 | 200000 47 | 48 | 2.0 49 | 50 | 770 51 | 582 52 | 440 53 | 345 54 | 260 55 | 170 56 | 125 57 | 58 | 3100 59 | 60 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | true 25 | 26 | 27 | true 28 | 29 | 30 | true 31 | 32 | 33 | -------------------------------------------------------------------------------- /overlay/packages/apps/CMFileManager/res/xml/command_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /overlay/packages/apps/Camera2/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 21 | true 22 | 23 | -------------------------------------------------------------------------------- /overlay/packages/apps/CarrierConfig/res/xml/vendor.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /overlay/packages/apps/Dialer/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 4 16 | 17 | 18 | true 19 | 20 | -------------------------------------------------------------------------------- /overlay/packages/apps/Lightbulb/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | true 21 | 22 | -------------------------------------------------------------------------------- /overlay/packages/apps/Settings/res/values/bools.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | true 21 | 22 | -------------------------------------------------------------------------------- /overlay/packages/apps/Settings/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | true 21 | 22 | 24 | true 25 | 26 | 28 | 29 | 31 | 32 | -------------------------------------------------------------------------------- /overlay/vendor/lineagesdk/lineage/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 31 | 11 32 | 33 | -------------------------------------------------------------------------------- /proprietary-files.txt: -------------------------------------------------------------------------------- 1 | bin/glgps 2 | lib/hw/gps.exynos4.vendor.so 3 | lib/libakm.so 4 | lib/libsec-ril.so 5 | lib/libstlport.so -------------------------------------------------------------------------------- /recovery.fstab: -------------------------------------------------------------------------------- 1 | # mount point fstype device 2 | /efs ext4 /dev/block/mmcblk0p3 3 | /boot emmc /dev/block/mmcblk0p8 4 | /recovery emmc /dev/block/mmcblk0p9 5 | /cache ext4 /dev/block/mmcblk0p12 6 | /system ext4 /dev/block/mmcblk0p13 7 | /data ext4 /dev/block/mmcblk0p16 length=-16384 8 | /preload ext4 /dev/block/mmcblk0p14 9 | /modem emmc /dev/block/mmcblk0p10 10 | 11 | /sdcard datamedia /dev/null 12 | /external_sd auto /dev/block/mmcblk1p1 /dev/block/mmcblk1 13 | 14 | -------------------------------------------------------------------------------- /rootdir/fstab.smdk4x12: -------------------------------------------------------------------------------- 1 | # Android fstab file. 2 | # 3 | # The filesystem that contains the filesystem checker binary (typically /system) cannot 4 | # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK 5 | # data partition must be located at the bottom for supporting device encryption 6 | 7 | /dev/block/mmcblk0p3 /efs ext4 noatime,nosuid,nodev,journal_async_commit,errors=panic wait 8 | /dev/block/mmcblk0p13 /system ext4 ro,noatime wait 9 | /dev/block/mmcblk0p12 /cache f2fs noatime,discard,inline_xattr,inline_data,nosuid,nodev wait 10 | /dev/block/mmcblk0p12 /cache ext4 noatime,nosuid,nodev,journal_async_commit,errors=panic wait,check 11 | /dev/block/mmcblk0p14 /preload ext4 noatime,nosuid,nodev,journal_async_commit wait 12 | /dev/block/mmcblk0p16 /data f2fs noatime,discard,inline_xattr,inline_data,nosuid,nodev wait,check,encryptable=footer 13 | /dev/block/mmcblk0p16 /data ext4 noatime,nosuid,nodev,noauto_da_alloc,journal_async_commit,errors=panic wait,check,encryptable=footer 14 | /dev/block/platform/dw_mmc/by-name/OTA /misc emmc defaults defaults 15 | 16 | # vold-managed volumes ("block device" is actually a sysfs devpath) 17 | /devices/platform/s3c-sdhci.2/mmc_host/mmc1* /storage/sdcard1 auto defaults voldmanaged=sdcard1:auto,encryptable=userdata 18 | /devices/platform/s5p-ehci* /storage/usbdisk0 auto defaults voldmanaged=usb:auto,noemulatedsd 19 | 20 | # recovery 21 | /dev/block/mmcblk0p8 /boot emmc defaults recoveryonly 22 | /dev/block/mmcblk0p9 /recovery emmc defaults recoveryonly 23 | /dev/block/mmcblk0p10 /modem emmc defaults recoveryonly 24 | 25 | /dev/block/zram0 none swap defaults zramsize=314572800,zramstreams=2 26 | -------------------------------------------------------------------------------- /rootdir/init.target.rc: -------------------------------------------------------------------------------- 1 | import /init.target.usb.rc 2 | 3 | on init 4 | export LD_SHIM_LIBS /system/lib/libsec-ril.so|libsamsung_symbols.so:/system/bin/gpsd|libdmitry.so:/system/lib/libgui.so|libshim_gpsd.so 5 | # Vibetonz 6 | export VIBE_PIPE_PATH /dev/pipes 7 | mkdir /dev/pipes 0771 shell shell 8 | 9 | # SensorHub 10 | chmod 0600 /dev/ssp_sensorhub 11 | chown system system /dev/ssp_sensorhub 12 | chown system radio /sys/class/sensors/ssp_sensor/enable 13 | chown system radio /sys/class/sensors/ssp_sensor/mcu_rev 14 | chown system radio /sys/class/sensors/ssp_sensor/mcu_name 15 | chown system radio /sys/class/sensors/ssp_sensor/mcu_test 16 | chown system radio /sys/class/sensors/ssp_sensor/mcu_reset 17 | chown system radio /sys/class/sensors/ssp_sensor/mcu_update 18 | chown system radio /sys/class/sensors/ssp_sensor/mcu_sleep_test 19 | chown system radio /sys/class/sensors/ssp_sensor/ori_poll_delay 20 | chown system radio /sys/class/sensors/ssp_sensor/mag_poll_delay 21 | # Sensorhub IIO 22 | chown system radio /sys/class/sensors/ssp_sensor/accel_poll_delay 23 | chown system radio /sys/class/sensors/ssp_sensor/rot_poll_delay 24 | chown system radio /sys/class/sensors/ssp_sensor/gyro_poll_delay 25 | chown system radio /sys/class/sensors/ssp_sensor/mag_poll_delay 26 | chown system radio /sys/class/sensors/ssp_sensor/pressure_poll_delay 27 | chown system radio /sys/class/sensors/ssp_sensor/ssp_flush 28 | chmod 0600 /dev/batch_io 29 | chown system system /dev/batch_io 30 | 31 | on post-fs-data 32 | # GPS init 33 | mkdir /data/gps 34 | chown gps system /data/gps 35 | chmod 1770 /data/gps 36 | write /sys/class/sec/gps/GPS_PWR_EN/export 162 37 | write /sys/class/sec/gps/GPS_PWR_EN/value 0 38 | write /sys/class/sec/gps/GPS_PWR_EN/direction out 39 | chown gps system /sys/class/sec/gps/GPS_PWR_EN/value 40 | chmod 0664 /sys/class/sec/gps/GPS_PWR_EN/value 41 | chown gps system /dev/ttySAC1 42 | chmod 0660 /dev/ttySAC1 43 | restorecon /sys/class/sec/gps/export 44 | restorecon /sys/class/sec/gps/GPS_PWR_EN/value 45 | restorecon /sys/class/sec/gps/GPS_PWR_EN/direction 46 | 47 | write /data/.cid.info 0 48 | restorecon /data/.cid.info 49 | restorecon /data/ISP_CV 50 | 51 | on boot 52 | # Flash storage isn't a good entropy source, and only causes 53 | # locking overhead in the kernel. Turn it off. 54 | write /sys/block/mmcblk0/queue/add_random 0 55 | write /sys/block/mmcblk1/queue/add_random 0 56 | 57 | # KSM 58 | write /sys/kernel/mm/ksm/deferred_timer 1 59 | write /sys/kernel/mm/ksm/pages_to_scan 100 60 | write /sys/kernel/mm/ksm/sleep_millisecs 500 61 | write /sys/kernel/mm/ksm/run 0 62 | 63 | # Swapping 1 page at a time is ok 64 | write /proc/sys/vm/page-cluster 0 65 | 66 | write /proc/sys/vm/swappiness 60 67 | 68 | # increase read-ahead value to 256 kb 69 | write /sys/block/mmcblk0/queue/read_ahead_kb 256 70 | 71 | on post-fs-data 72 | # make param block device link for SysScope 73 | symlink /dev/block/mmcblk0p4 /dev/block/param 74 | # Restorecon 75 | restorecon_recursive /efs 76 | 77 | # GPS init 78 | mkdir /data/gps 79 | chown gps system /data/gps 80 | chmod 1770 /data/gps 81 | write /sys/class/sec/gps/GPS_PWR_EN/export 162 82 | write /sys/class/sec/gps/GPS_PWR_EN/value 0 83 | write /sys/class/sec/gps/GPS_PWR_EN/direction out 84 | chown gps system /sys/class/sec/gps/GPS_PWR_EN/value 85 | chmod 0664 /sys/class/sec/gps/GPS_PWR_EN/value 86 | chown gps system /dev/ttySAC1 87 | chmod 0660 /dev/ttySAC1 88 | restorecon /sys/class/sec/gps/export 89 | restorecon /sys/class/sec/gps/GPS_PWR_EN/value 90 | restorecon /sys/class/sec/gps/GPS_PWR_EN/direction 91 | 92 | write /data/.cid.info 0 93 | restorecon /data/.cid.info 94 | restorecon /data/ISP_CV 95 | 96 | on fs 97 | # zram 98 | swapon_all /fstab.x 99 | 100 | on boot 101 | # cbd 102 | service cpboot-daemon /system/bin/cbd -d -p 10 103 | class main 104 | user root 105 | group radio cache inet misc audio sdcard_rw log 106 | seclabel u:r:cpboot-daemon:s0 107 | 108 | # Start GPS daemon 109 | service gps-daemon /system/bin/sh /vendor/bin/gps_daemon.sh 110 | class main 111 | socket gps seqpacket 0660 gps system 112 | user gps 113 | group system inet sdcard_rw gps 114 | seclabel u:r:glgps:s0 115 | -------------------------------------------------------------------------------- /rootdir/init.target.usb.rc: -------------------------------------------------------------------------------- 1 | on property:sys.usb.config=mass_storage 2 | write /sys/class/android_usb/android0/enable 0 3 | write /sys/class/android_usb/android0/idVendor 04E8 4 | write /sys/class/android_usb/android0/idProduct 685B 5 | write /sys/class/android_usb/android0/functions ${sys.usb.config} 6 | write /sys/class/android_usb/android0/enable 1 7 | setprop sys.usb.state ${sys.usb.config} 8 | 9 | on property:sys.usb.config=mass_storage,adb 10 | write /sys/class/android_usb/android0/enable 0 11 | write /sys/class/android_usb/android0/idVendor 04E8 12 | write /sys/class/android_usb/android0/idProduct 685E 13 | write /sys/class/android_usb/android0/functions ${sys.usb.config} 14 | write /sys/class/android_usb/android0/enable 1 15 | start adbd 16 | start umsservice 17 | setprop sys.usb.state ${sys.usb.config} 18 | -------------------------------------------------------------------------------- /shims/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(call all-makefiles-under,$(LOCAL_PATH)) 20 | -------------------------------------------------------------------------------- /shims/libgps-shim/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2016 The CyanogenMod 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 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES := gps.c 20 | 21 | LOCAL_SHARED_LIBRARIES := \ 22 | libcutils \ 23 | liblog \ 24 | libc 25 | 26 | LOCAL_MODULE := gps.$(TARGET_BOOTLOADER_BOARD_NAME) 27 | LOCAL_MODULE_RELATIVE_PATH := hw 28 | LOCAL_VENDOR_MODULE := true 29 | 30 | include $(BUILD_SHARED_LIBRARY) 31 | 32 | -------------------------------------------------------------------------------- /shims/libgps-shim/gps.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The CyanogenMod 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 | #define LOG_TAG "libgps-shim" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "gps.h" 29 | #define REAL_GPS_PATH "/system/vendor/lib/hw/gps.exynos4.vendor.so" 30 | 31 | extern uint32_t android_get_application_target_sdk_version(); 32 | extern void android_set_application_target_sdk_version(uint32_t target); 33 | 34 | const GpsInterface* (*vendor_get_gps_interface)(struct gps_device_t* dev); 35 | const void* (*vendor_get_extension)(const char* name); 36 | void (*vendor_set_ref_location)(const AGpsRefLocationNoLTE *agps_reflocation, size_t sz_struct); 37 | 38 | void shim_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) { 39 | // this is mildly ugly 40 | AGpsRefLocationNoLTE vendor_ref; 41 | if (sizeof(AGpsRefLocationNoLTE) < sz_struct) { 42 | ALOGE("%s: AGpsRefLocation is too small, bailing out!", __func__); 43 | return; 44 | } 45 | ALOGE("%s: shimming AGpsRefLocation", __func__); 46 | // the two structs are identical, so this is ok 47 | memcpy(&vendor_ref, agps_reflocation, sizeof(AGpsRefLocationNoLTE)); 48 | vendor_set_ref_location(&vendor_ref, sizeof(AGpsRefLocationNoLTE)); 49 | // copy it back 50 | memcpy(agps_reflocation, &vendor_ref, sizeof(AGpsRefLocationNoLTE)); 51 | } 52 | 53 | const void* shim_get_extension(const char* name) { 54 | ALOGE("%s(%s)", __func__, name); 55 | if (strcmp(name, AGPS_RIL_INTERFACE) == 0) { 56 | // RIL interface 57 | AGpsRilInterface *ril = (AGpsRilInterface*)vendor_get_extension(name); 58 | // now we shim the ref_location callback 59 | ALOGE("%s: shimming RIL ref_location callback", __func__); 60 | vendor_set_ref_location = ril->set_ref_location; 61 | ril->set_ref_location = shim_set_ref_location; 62 | return ril; 63 | } else { 64 | return vendor_get_extension(name); 65 | } 66 | } 67 | 68 | const GpsInterface* shim_get_gps_interface(struct gps_device_t* dev) { 69 | ALOGE("%s: shimming vendor get_extension", __func__); 70 | GpsInterface *halInterface = vendor_get_gps_interface(dev); 71 | 72 | vendor_get_extension = halInterface->get_extension; 73 | halInterface->get_extension = &shim_get_extension; 74 | 75 | return halInterface; 76 | } 77 | 78 | static int open_gps(const struct hw_module_t* module, char const* name, 79 | struct hw_device_t** device) { 80 | void *realGpsLib; 81 | int gpsHalResult; 82 | struct hw_module_t *realHalSym; 83 | 84 | struct gps_device_t **gps = (struct gps_device_t **)device; 85 | 86 | android_set_application_target_sdk_version(__ANDROID_API_L_MR1__); 87 | realGpsLib = dlopen(REAL_GPS_PATH, RTLD_LOCAL); 88 | if (!realGpsLib) { 89 | ALOGE("Failed to load real GPS HAL '" REAL_GPS_PATH "': %s", dlerror()); 90 | return -EINVAL; 91 | } 92 | 93 | realHalSym = (struct hw_module_t*)dlsym(realGpsLib, HAL_MODULE_INFO_SYM_AS_STR); 94 | if (!realHalSym) { 95 | ALOGE("Failed to locate the GPS HAL module sym: '" HAL_MODULE_INFO_SYM_AS_STR "': %s", dlerror()); 96 | goto dl_err; 97 | } 98 | 99 | int result = realHalSym->methods->open(realHalSym, name, device); 100 | if (result < 0) { 101 | ALOGE("Real GPS open method failed: %d", result); 102 | goto dl_err; 103 | } 104 | ALOGE("Successfully loaded real GPS hal, shimming get_gps_interface..."); 105 | // now, we shim hw_device_t 106 | vendor_get_gps_interface = (*gps)->get_gps_interface; 107 | (*gps)->get_gps_interface = &shim_get_gps_interface; 108 | 109 | return 0; 110 | dl_err: 111 | dlclose(realGpsLib); 112 | return -EINVAL; 113 | } 114 | 115 | static struct hw_module_methods_t gps_module_methods = { 116 | .open = open_gps 117 | }; 118 | 119 | struct hw_module_t HAL_MODULE_INFO_SYM = { 120 | .tag = HARDWARE_MODULE_TAG, 121 | .module_api_version = 1, 122 | .hal_api_version = 0, 123 | .id = GPS_HARDWARE_MODULE_ID, 124 | .name = "BCM451x GPS shim", 125 | .author = "The CyanogenMod Project", 126 | .methods = &gps_module_methods 127 | }; 128 | -------------------------------------------------------------------------------- /shims/libgps-shim/gps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The CyanogenMod 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 | #include 17 | 18 | /* CellID for 2G, 3G and LTE, used in AGPS. */ 19 | typedef struct { 20 | AGpsRefLocationType type; 21 | /** Mobile Country Code. */ 22 | uint16_t mcc; 23 | /** Mobile Network Code .*/ 24 | uint16_t mnc; 25 | /** Location Area Code in 2G, 3G and LTE. In 3G lac is discarded. In LTE, 26 | * lac is populated with tac, to ensure that we don't break old clients that 27 | * might rely in the old (wrong) behavior. 28 | */ 29 | uint16_t lac; 30 | /** Cell id in 2G. Utran Cell id in 3G. Cell Global Id EUTRA in LTE. */ 31 | uint32_t cid; 32 | #if 0 // introduced in N. 33 | /** Tracking Area Code in LTE. */ 34 | uint16_t tac; 35 | /** Physical Cell id in LTE (not used in 2G and 3G) */ 36 | uint16_t pcid; 37 | #endif 38 | } AGpsRefLocationCellIDNoLTE; 39 | 40 | /** Represents ref locations */ 41 | typedef struct { 42 | AGpsRefLocationType type; 43 | union { 44 | AGpsRefLocationCellIDNoLTE cellID; 45 | AGpsRefLocationMac mac; 46 | } u; 47 | } AGpsRefLocationNoLTE; 48 | 49 | 50 | -------------------------------------------------------------------------------- /system.prop: -------------------------------------------------------------------------------- 1 | # 2 | # system.prop for n7100 3 | # 4 | 5 | dalvik.vm.dexopt-data-only=1 6 | dalvik.vm.dex2oat-Xmx=256m 7 | rild.libpath=/system/lib/libsecril-shim.so 8 | rild.libargs=-d /dev/ttyS0 9 | ro.ril.telephony.mqanelements=5 10 | ro.sf.lcd_density=320 11 | ro.lcd_min_brightness=20 12 | ro.ril.telephony.nstrings=4 13 | 14 | # Camera API 15 | persist.camera.HAL3.enabled=1 16 | 17 | # EGL blobs crash on screen off 18 | # ro.egl.destroy_after_detach=true 19 | 20 | # Google Assistant 21 | ro.opa.eligible_device=true 22 | 23 | # sdcardfs 24 | ro.sys.sdcardfs=true 25 | 26 | # 27 | # ~system.prop for n7100 28 | # -------------------------------------------------------------------------------- /vendor_prop.mk: -------------------------------------------------------------------------------- 1 | PRODUCT_PROPERTY_OVERRIDES += \ 2 | ro.vendor.product.name=t0xx \ 3 | ro.vendor.product.device=t03g -------------------------------------------------------------------------------- /vendorsetup.sh: -------------------------------------------------------------------------------- 1 | add_lunch_combo lineage_n7100-userdebug 2 | add_lunch_combo lineage_n7100-eng 3 | --------------------------------------------------------------------------------