summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <codeworkx@cyanogenmod.org>2013-02-04 17:01:15 +0000
committercodeworkx <codeworkx@cyanogenmod.org>2013-02-08 16:31:33 +0000
commit5c27960bc1122f9235f5395b8f7bcc5382389ea8 (patch)
tree6d0eb5a46364b4a8157022edc2379d88795e8ec8
downloaddevice_samsung_i9305-5c27960bc1122f9235f5395b8f7bcc5382389ea8.zip
device_samsung_i9305-5c27960bc1122f9235f5395b8f7bcc5382389ea8.tar.gz
device_samsung_i9305-5c27960bc1122f9235f5395b8f7bcc5382389ea8.tar.bz2
initial commit
-rw-r--r--Android.mk23
-rw-r--r--AndroidProducts.mk18
-rw-r--r--BoardConfig.mk41
-rw-r--r--DeviceSettings/Android.mk15
-rw-r--r--DeviceSettings/AndroidManifest.xml31
-rwxr-xr-xDeviceSettings/res/drawable/ic_launcher_cmdevicesettings.pngbin0 -> 8207 bytes
-rwxr-xr-xDeviceSettings/res/layout/top.xml5
-rw-r--r--DeviceSettings/res/values-de/arrays.xml56
-rw-r--r--DeviceSettings/res/values-de/strings.xml34
-rw-r--r--DeviceSettings/res/values-es/arrays.xml48
-rw-r--r--DeviceSettings/res/values-es/strings.xml28
-rw-r--r--DeviceSettings/res/values-hu/arrays.xml56
-rw-r--r--DeviceSettings/res/values-hu/strings.xml34
-rwxr-xr-xDeviceSettings/res/values-pt-rBR/arrays.xml55
-rwxr-xr-xDeviceSettings/res/values-pt-rBR/strings.xml28
-rw-r--r--DeviceSettings/res/values-ru/arrays.xml54
-rw-r--r--DeviceSettings/res/values-ru/strings.xml34
-rw-r--r--DeviceSettings/res/values-zh-rCN/arrays.xml56
-rw-r--r--DeviceSettings/res/values-zh-rCN/strings.xml33
-rw-r--r--DeviceSettings/res/values/arrays.xml109
-rw-r--r--DeviceSettings/res/values/strings.xml34
-rw-r--r--DeviceSettings/res/xml/haptic_preferences.xml13
-rw-r--r--DeviceSettings/res/xml/radio_preferences.xml12
-rw-r--r--DeviceSettings/res/xml/screen_preferences.xml65
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java166
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java66
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java67
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java66
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java102
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java38
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java143
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java59
-rw-r--r--README4
-rw-r--r--audio/Android.mk33
-rw-r--r--audio/audio_hw.c3234
-rw-r--r--audio/audio_hw.h302
-rw-r--r--bluetooth/bdroid_buildcfg.h23
-rw-r--r--cm.dependencies14
-rw-r--r--cm.mk25
-rw-r--r--configs/80cfw10
-rw-r--r--configs/gps.conf102
-rw-r--r--configs/nfcee_access.xml11
-rw-r--r--configs/nfcee_access_debug.xml17
-rw-r--r--configs/tiny_hw.xml353
-rwxr-xr-xextract-files.sh105
-rw-r--r--full_i9305.mk35
-rw-r--r--i9305.mk96
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml118
-rw-r--r--overlay/frameworks/base/core/res/res/xml/power_profile.xml69
-rw-r--r--overlay/frameworks/base/core/res/res/xml/storage_list.xml52
-rw-r--r--overlay/frameworks/base/packages/SystemUI/res/values/config.xml26
-rw-r--r--overlay/packages/apps/Phone/res/values/config.xml30
-rw-r--r--overlay/packages/apps/Torch/res/values/config.xml36
-rw-r--r--proprietary-files.txt49
-rw-r--r--recovery.fstab12
-rw-r--r--rootdir/fstab.smdk4x1211
-rwxr-xr-xrootdir/init.smdk4x12.rc609
-rw-r--r--rootdir/lpm.rc77
-rw-r--r--rootdir/ueventd.smdk4x12.rc109
-rw-r--r--system.prop17
65 files changed, 7463 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..e187cd5
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(TARGET_DEVICE),i9305)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
new file mode 100644
index 0000000..549de4c
--- /dev/null
+++ b/AndroidProducts.mk
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/full_i9305.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
new file mode 100644
index 0000000..c405919
--- /dev/null
+++ b/BoardConfig.mk
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This variable is set first, so it can be overridden
+# by BoardConfigVendor.mk
+
+-include device/samsung/smdk4412-common/BoardCommonConfig.mk
+
+LOCAL_PATH := device/samsung/i9305
+
+# Bluetooth
+BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(LOCAL_PATH)/bluetooth
+
+# RIL
+COMMON_GLOBAL_CFLAGS += -DPROPERTY_PERMS_APPEND='{ "ril.ks.status", AID_SYSTEM, 0 },'
+
+# Camera
+COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM
+
+# Kernel
+TARGET_KERNEL_SOURCE := kernel/samsung/smdk4412
+TARGET_KERNEL_CONFIG := cyanogenmod_i9305_defconfig
+
+# assert
+TARGET_OTA_ASSERT_DEVICE := m3,m3xx,i9305,GT-I9305
+
+# inherit from the proprietary version
+-include vendor/samsung/i9305/BoardConfigVendor.mk
diff --git a/DeviceSettings/Android.mk b/DeviceSettings/Android.mk
new file mode 100644
index 0000000..12c8de5
--- /dev/null
+++ b/DeviceSettings/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := GalaxyS3Settings
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/DeviceSettings/AndroidManifest.xml b/DeviceSettings/AndroidManifest.xml
new file mode 100644
index 0000000..d373ded
--- /dev/null
+++ b/DeviceSettings/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.cyanogenmod.settings.device"
+ android:sharedUserId="android.uid.system" >
+
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+
+ <application android:label="@string/app_name">
+ <activity
+ android:name="com.cyanogenmod.settings.device.DeviceSettings"
+ android:icon="@drawable/ic_launcher_cmdevicesettings"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="com.cyanogenmod.action.LAUNCH_DEVICE_SETTINGS" />
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ <receiver android:name=".Startup">
+ <intent-filter android:priority="100">
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
+ <activity android:name=".HapticFragmentActivity" />
+ <activity android:name=".RadioFragmentActivity" />
+ <activity android:name=".ScreenFragmentActivity" />
+
+ </application>
+</manifest>
diff --git a/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png
new file mode 100755
index 0000000..66de9c3
--- /dev/null
+++ b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png
Binary files differ
diff --git a/DeviceSettings/res/layout/top.xml b/DeviceSettings/res/layout/top.xml
new file mode 100755
index 0000000..744b568
--- /dev/null
+++ b/DeviceSettings/res/layout/top.xml
@@ -0,0 +1,5 @@
+<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/viewPager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml
new file mode 100644
index 0000000..9edf346
--- /dev/null
+++ b/DeviceSettings/res/values-de/arrays.xml
@@ -0,0 +1,56 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Standard)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>Nur UMTS</item>
+ <item>Nur HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (Standard)</item>
+ <item>UI</item>
+ <item>Video</item>
+ <item>Video warm</item>
+ <item>Video kalt</item>
+ <item>Kamera</item>
+ <item>Navigation</item>
+ <item>Gallerie</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Dynamisch (Standard)</item>
+ <item>Standard</item>
+ <item>Natürlich</item>
+ <item>Film</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Invertiert</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>Blinken</item>
+ <item>Verblassen</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Niemals</item>
+ <item>1 Sekunde</item>
+ <item>2 Sekunden</item>
+ <item>3 Sekunden (Standard)</item>
+ <item>4 Sekunden</item>
+ <item>5 Sekunden</item>
+ <item>6 Sekunden</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml
new file mode 100644
index 0000000..50c66a6
--- /dev/null
+++ b/DeviceSettings/res/values-de/strings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III Einstellungen</string>
+
+ <string name="category_haptic_title">Haptik</string>
+ <string name="vibrator_subcat_title">Vibrator</string>
+ <string name="vibrator_intensity_title_head">Vibrator Intensität</string>
+ <string name="vibrator_intensity_summary_head">Wähle Vibrator Intensität</string>
+
+ <string name="category_radio_title">Mobilfunk</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Aktiviere HSDPA/HSUPA</string>
+
+ <string name="category_screen_title">Display</string>
+ <string name="mdnie_subcat_title">Farben</string>
+ <string name="mdnie_scenario_title_head">Szenario</string>
+ <string name="mdnie_scenario_summary_head">Wähle das mDNIe Szenario</string>
+ <string name="mdnie_mode_title_head">Modus</string>
+ <string name="mdnie_mode_summary_head">Wähle den mDNIe Modus</string>
+ <string name="mdnie_negative_title_head">Negativ Modus</string>
+ <string name="mdnie_negative_summary_head">Invertiere Farben</string>
+
+ <string name="led_subcat_title">Benachrichtigungslicht</string>
+ <string name="led_fade_title_head">Modus</string>
+ <string name="led_fade_summary_head">Wähle zwischen sanftem Verblassen und Blinken</string>
+
+ <string name="touchkey_subcat_title">Touchkeys</string>
+ <string name="touchkey_light_title_head">Beleuchtung</string>
+ <string name="touchkey_light_summary_off">Aktiviere Beleuchtung</string>
+ <string name="touchkey_light_summary_on">Deaktiviere Beleuchtung</string>
+ <string name="touchkey_timeout_title_head">Zeitabschaltung der Beleuchtung</string>
+ <string name="touchkey_timeout_summary_head">Setze Zeit für automatische Abschaltung</string>
+
+</resources>
diff --git a/DeviceSettings/res/values-es/arrays.xml b/DeviceSettings/res/values-es/arrays.xml
new file mode 100644
index 0000000..fd55bc4
--- /dev/null
+++ b/DeviceSettings/res/values-es/arrays.xml
@@ -0,0 +1,48 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (por defecto)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+ <string-array name="hspa_entries">
+ <item>Solo UMTS</item>
+ <item>Solo HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (por defecto)</item>
+ <item>UI</item>
+ <item>Vídeo</item>
+ <item>Vídeo cálido</item>
+ <item>Vídeo frío</item>
+ <item>Camara</item>
+ <item>Navegación</item>
+ <item>Galería</item>
+ <item>VT</item>
+ </string-array>
+ <string-array name="mdnie_mode_entries">
+ <item>Estándar (por defecto)</item>
+ <item>Dinámico</item>
+ <item>Natural</item>
+ <item>Película</item>
+ </string-array>
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Invertido</item>
+ </string-array>
+ <string-array name="led_fade_entries">
+ <item>Parpadeo</item>
+ <item>Fundido</item>
+ </string-array>
+ <string-array name="touchkey_timeout_entries">
+ <item>Nunca</item>
+ <item>1 segundo</item>
+ <item>2 segundos</item>
+ <item>3 segundos (por defecto)</item>
+ <item>4 segundos</item>
+ <item>5 segundos</item>
+ <item>6 segundos</item>
+ </string-array>
+</resources>
diff --git a/DeviceSettings/res/values-es/strings.xml b/DeviceSettings/res/values-es/strings.xml
new file mode 100644
index 0000000..50674d3
--- /dev/null
+++ b/DeviceSettings/res/values-es/strings.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">"Ajustes Galaxy S III"</string>
+ <string name="category_haptic_title">"Háptica"</string>
+ <string name="vibrator_subcat_title">"Vibración"</string>
+ <string name="vibrator_intensity_title_head">"Intensidad de vibración"</string>
+ <string name="vibrator_intensity_summary_head">"Establecer la intensidad de vibración"</string>
+ <string name="category_radio_title">"Radio"</string>
+ <string name="hspa_title_head">"HSPA"</string>
+ <string name="hspa_summary_head">"Habilitar HSDPA/HSUPA"</string>
+ <string name="category_screen_title">"Pantalla"</string>
+ <string name="mdnie_subcat_title">"Colores"</string>
+ <string name="mdnie_scenario_title_head">"Escenario"</string>
+ <string name="mdnie_scenario_summary_head">"Establecer escenario mDNIe"</string>
+ <string name="mdnie_mode_title_head">"Modo"</string>
+ <string name="mdnie_mode_summary_head">"Establecer modo mDNIe"</string>
+ <string name="mdnie_negative_title_head">"Modo negativo"</string>
+ <string name="mdnie_negative_summary_head">"Habilitar/deshabilitar colores invertidos"</string>
+ <string name="led_subcat_title">"Notificación LED"</string>
+ <string name="led_fade_title_head">"Fundido LED"</string>
+ <string name="led_fade_summary_head">"Habilitar fundido suave en vez de parpadeo intenso"</string>
+ <string name="touchkey_subcat_title">"Teclas táctiles"</string>
+ <string name="touchkey_light_title_head">"Retroiluminación"</string>
+ <string name="touchkey_light_summary_off">"Habilitar retroiluminación"</string>
+ <string name="touchkey_light_summary_on">"Deshabilitar retroiluminación"</string>
+ <string name="touchkey_timeout_title_head">"Tiempo de espera de retroiluminación"</string>
+ <string name="touchkey_timeout_summary_head">"Tiempo tras pulsar una tecla antes de apagar la retroiluminación"</string>
+</resources>
diff --git a/DeviceSettings/res/values-hu/arrays.xml b/DeviceSettings/res/values-hu/arrays.xml
new file mode 100644
index 0000000..824296d
--- /dev/null
+++ b/DeviceSettings/res/values-hu/arrays.xml
@@ -0,0 +1,56 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Alapbeállítás)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>UMTS</item>
+ <item>HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (Alapbeállítás)</item>
+ <item>Felhasználói felület</item>
+ <item>Videó</item>
+ <item>Videó (Meleg árnyalat)</item>
+ <item>Videó (Hideg árnyalat)</item>
+ <item>Kamera</item>
+ <item>Navigáció</item>
+ <item>Galéria</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Dinamikus (Alapbeállítás)</item>
+ <item>Hagyományos</item>
+ <item>Természetes</item>
+ <item>Film</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Normál</item>
+ <item>Fordított</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>Villogás</item>
+ <item>Elhalványulás</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Soha</item>
+ <item>1 másodperc</item>
+ <item>2 másodperc</item>
+ <item>3 másodperc (Alapbeállítás)</item>
+ <item>4 másodperc</item>
+ <item>5 másodperc</item>
+ <item>6 másodperc</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values-hu/strings.xml b/DeviceSettings/res/values-hu/strings.xml
new file mode 100644
index 0000000..aecbf59
--- /dev/null
+++ b/DeviceSettings/res/values-hu/strings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III Beállítások</string>
+
+ <string name="category_haptic_title">Érintési visszajelzés</string>
+ <string name="vibrator_subcat_title">Rezgés</string>
+ <string name="vibrator_intensity_title_head">Rezgés erőssége</string>
+ <string name="vibrator_intensity_summary_head">Rezgés erősségének beállítása</string>
+
+ <string name="category_radio_title">GSM Rádió</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">HSDPA/HSUPA engedélyezése</string>
+
+ <string name="category_screen_title">Kijelző</string>
+ <string name="mdnie_subcat_title">Színek</string>
+ <string name="mdnie_scenario_title_head">Megjelenítés</string>
+ <string name="mdnie_scenario_summary_head">mDNIe megjelenítési beállítások</string>
+ <string name="mdnie_mode_title_head">Üzemmód</string>
+ <string name="mdnie_mode_summary_head">mDNIe üzemmódok</string>
+ <string name="mdnie_negative_title_head">Negatív üzemmód</string>
+ <string name="mdnie_negative_summary_head">Fordított színek ki/be</string>
+
+ <string name="led_subcat_title">LED értesítés</string>
+ <string name="led_fade_title_head">LED halványítás</string>
+ <string name="led_fade_summary_head">LED elhalványítása villogtatás helyett</string>
+
+ <string name="touchkey_subcat_title">Érintőgombok</string>
+ <string name="touchkey_light_title_head">Háttérvilágítás</string>
+ <string name="touchkey_light_summary_off">Háttérvilágítás engedélyezése</string>
+ <string name="touchkey_light_summary_on">Háttérvilágítás tiltása</string>
+ <string name="touchkey_timeout_title_head">Háttérvilágítás időkorlátja</string>
+ <string name="touchkey_timeout_summary_head">Háttérvilágítás késleltetése</string>
+
+</resources>
diff --git a/DeviceSettings/res/values-pt-rBR/arrays.xml b/DeviceSettings/res/values-pt-rBR/arrays.xml
new file mode 100755
index 0000000..7ade7ea
--- /dev/null
+++ b/DeviceSettings/res/values-pt-rBR/arrays.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Padrão)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>Somente UMTS</item>
+ <item>Somente HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (Padrão)</item>
+ <item>IU</item>
+ <item>Vídeo</item>
+ <item>Vídeo Quente</item>
+ <item>Vídeo Frio</item>
+ <item>Câmera</item>
+ <item>Navegação</item>
+ <item>Galeria</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Padrão</item>
+ <item>Dinâmico</item>
+ <item>Natural</item>
+ <item>Filme</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Invertido</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>Piscando</item>
+ <item>Desvanecimento</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Nunca</item>
+ <item>1 segundo</item>
+ <item>2 segundos</item>
+ <item>3 segundos (Padrão)</item>
+ <item>4 segundos</item>
+ <item>5 segundos</item>
+ <item>6 segundos</item>
+ </string-array>
+</resources>
diff --git a/DeviceSettings/res/values-pt-rBR/strings.xml b/DeviceSettings/res/values-pt-rBR/strings.xml
new file mode 100755
index 0000000..668c59c
--- /dev/null
+++ b/DeviceSettings/res/values-pt-rBR/strings.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Config. Galaxy S III</string>
+ <string name="category_haptic_title">Resposta Tátil</string>
+ <string name="vibrator_subcat_title">Vibração</string>
+ <string name="vibrator_intensity_title_head">Intensidade da Vibração</string>
+ <string name="vibrator_intensity_summary_head">Define a intensidade da vibração</string>
+ <string name="category_radio_title">Rádio</string>
+ <string name="hspa_summary_head">Ativar HSDPA/HSUPA</string>
+ <string name="category_screen_title">Tela</string>
+ <string name="mdnie_subcat_title">Cores</string>
+ <string name="mdnie_scenario_title_head">Cenário</string>
+ <string name="mdnie_scenario_summary_head">Define o Cenário mDNIe</string>
+ <string name="mdnie_mode_title_head">Modo</string>
+ <string name="mdnie_mode_summary_head">Define o Modo mDNIe</string>
+ <string name="mdnie_negative_title_head">Modo Negativo</string>
+ <string name="mdnie_negative_summary_head">Ativar/Desativar cores invertidas</string>
+ <string name="led_subcat_title">Notificação com LED</string>
+ <string name="led_fade_title_head">Desvanecimento LED</string>
+ <string name="led_fade_summary_head">Ativar desvanecimento suave do LED em vez de piscar.</string>
+ <string name="touchkey_subcat_title">Teclas sensíveis ao toque</string>
+ <string name="touchkey_light_title_head">Luz de fundo</string>
+ <string name="touchkey_light_summary_off">Ativar luz de fundo</string>
+ <string name="touchkey_light_summary_on">Desativar luz de fundo</string>
+ <string name="touchkey_timeout_title_head">Tempo limite da luz de fundo</string>
+ <string name="touchkey_timeout_summary_head">Define o tempo limite para a luz de fundo</string>
+ <string name="hspa_title_head">HSPA</string>
+</resources> \ No newline at end of file
diff --git a/DeviceSettings/res/values-ru/arrays.xml b/DeviceSettings/res/values-ru/arrays.xml
new file mode 100644
index 0000000..ed61b6e
--- /dev/null
+++ b/DeviceSettings/res/values-ru/arrays.xml
@@ -0,0 +1,54 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (По умолч.)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>Только UMTS</item>
+ <item>Только HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (По умолч.)</item>
+ <item>Видео</item>
+ <item>Видео (тёпл.)</item>
+ <item>Видео (хол.)</item>
+ <item>Камера</item>
+ <item>Навигация</item>
+ <item>Галерея</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Динамический (По умолч.)</item>
+ <item>Стандартный</item>
+ <item>Натуральный</item>
+ <item>Кино</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Нормально</item>
+ <item>Инверсия</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>Мигание</item>
+ <item>Затухание</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Никогда</item>
+ <item>1 секунда</item>
+ <item>2 секунды</item>
+ <item>3 секунды (По умолч.)</item>
+ <item>4 секунды</item>
+ <item>5 секунд</item>
+ <item>6 секунд</item>
+ </string-array>
+</resources>
diff --git a/DeviceSettings/res/values-ru/strings.xml b/DeviceSettings/res/values-ru/strings.xml
new file mode 100644
index 0000000..d6d44b8
--- /dev/null
+++ b/DeviceSettings/res/values-ru/strings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Настройки Galaxy S III</string>
+
+ <string name="category_haptic_title">Отклик</string>
+ <string name="vibrator_subcat_title">Вибрация</string>
+ <string name="vibrator_intensity_title_head">Интенсивность вибрации</string>
+ <string name="vibrator_intensity_summary_head">Установка интенсивности вибрации</string>
+
+ <string name="category_radio_title">Модем</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Включить HSDPA/HSUPA</string>
+
+ <string name="category_screen_title">Экран</string>
+ <string name="mdnie_subcat_title">Цвета</string>
+ <string name="mdnie_scenario_title_head">Сценарий</string>
+ <string name="mdnie_scenario_summary_head">Установка сценария mDNIe</string>
+ <string name="mdnie_mode_title_head">Режим</string>
+ <string name="mdnie_mode_summary_head">Установка режима mDNIe</string>
+ <string name="mdnie_negative_title_head">Негатив</string>
+ <string name="mdnie_negative_summary_head">Вкл./выкл. инверсии цветов</string>
+
+ <string name="led_subcat_title">Индикатор событий</string>
+ <string name="led_fade_title_head">Режим</string>
+ <string name="led_fade_summary_head">Плавное затухание или резкое мигание</string>
+
+ <string name="touchkey_subcat_title">Сенсорные клавиши</string>
+ <string name="touchkey_light_title_head">Подсветка</string>
+ <string name="touchkey_light_summary_off">Подсветка включена</string>
+ <string name="touchkey_light_summary_on">Подсветка выключена</string>
+ <string name="touchkey_timeout_title_head">Тайм-аут подсветки</string>
+ <string name="touchkey_timeout_summary_head">Установка тайм-аута подсветки</string>
+
+</resources>
diff --git a/DeviceSettings/res/values-zh-rCN/arrays.xml b/DeviceSettings/res/values-zh-rCN/arrays.xml
new file mode 100644
index 0000000..3fe1780
--- /dev/null
+++ b/DeviceSettings/res/values-zh-rCN/arrays.xml
@@ -0,0 +1,56 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (默认)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>仅使用 UMTS</item>
+ <item>仅使用 HSDPA</item>
+ <item>使用 HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (默认)</item>
+ <item>界面</item>
+ <item>影片</item>
+ <item>影片 (温)</item>
+ <item>影片 (冷)</item>
+ <item>相机</item>
+ <item>导航</item>
+ <item>图库</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>动态 (默认)</item>
+ <item>标准</item>
+ <item>自然</item>
+ <item>电影</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>正常</item>
+ <item>反色</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>闪烁</item>
+ <item>淡出</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>从不</item>
+ <item>1 秒</item>
+ <item>2 秒</item>
+ <item>3 秒 (默认)</item>
+ <item>4 秒</item>
+ <item>5 秒</item>
+ <item>6 秒</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values-zh-rCN/strings.xml b/DeviceSettings/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..17451bd
--- /dev/null
+++ b/DeviceSettings/res/values-zh-rCN/strings.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III 设置</string>
+
+ <string name="category_haptic_title">振动</string>
+ <string name="vibrator_subcat_title">振动器</string>
+ <string name="vibrator_intensity_title_head">振动器强度</string>
+ <string name="vibrator_intensity_summary_head">设置振动器强度</string>
+
+ <string name="category_radio_title">无线电</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">启用 HSDPA/HSUPA</string>
+
+ <string name="category_screen_title">屏幕</string>
+ <string name="mdnie_subcat_title">颜色</string>
+ <string name="mdnie_scenario_title_head">场景</string>
+ <string name="mdnie_scenario_summary_head">设置 mDNIe 场景</string>
+ <string name="mdnie_mode_title_head">模式</string>
+ <string name="mdnie_mode_summary_head">设置 mDNIe 模式</string>
+ <string name="mdnie_negative_title_head">负极模式</string>
+ <string name="mdnie_negative_summary_head">启用/禁用反色</string>
+
+ <string name="led_subcat_title">LED 指示灯</string>
+ <string name="led_fade_title_head">LED 淡出</string>
+ <string name="led_fade_summary_head">启用后 LED 指示灯将会产生淡出效果而替代闪烁效果.</string>
+
+ <string name="touchkey_subcat_title">触摸键</string>
+ <string name="touchkey_light_title_head">背光灯</string>
+ <string name="touchkey_light_summary_off">启用背光灯</string>
+ <string name="touchkey_light_summary_on">禁用背光灯</string>
+ <string name="touchkey_timeout_title_head">背光灯超时</string>
+ <string name="touchkey_timeout_summary_head">设置背光灯超时时间</string>
+</resources>
diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml
new file mode 100644
index 0000000..d82ffbc
--- /dev/null
+++ b/DeviceSettings/res/values/arrays.xml
@@ -0,0 +1,109 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Default)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="vibrator_intensity_entries_values" translatable="false">
+ <item>0</item>
+ <item>25</item>
+ <item>50</item>
+ <item>75</item>
+ <item>100</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>UMTS Only</item>
+ <item>HSDPA Only</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="hspa_entries_values" translatable="false">
+ <item>21</item>
+ <item>22</item>
+ <item>23</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries">
+ <item>CyanogenMod (Default)</item>
+ <item>UI</item>
+ <item>Video</item>
+ <item>Video Warm</item>
+ <item>Video Cold</item>
+ <item>Camera</item>
+ <item>Navigation</item>
+ <item>Gallery</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_scenario_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ <item>6</item>
+ <item>7</item>
+ <item>8</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Dynamic (Default)</item>
+ <item>Standard</item>
+ <item>Natural</item>
+ <item>Movie</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Inverted</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ </string-array>
+
+ <string-array name="led_fade_entries">
+ <item>Blinking</item>
+ <item>Fading</item>
+ </string-array>
+
+ <string-array name="led_fade_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Never</item>
+ <item>1 second</item>
+ <item>2 seconds</item>
+ <item>3 seconds (Default)</item>
+ <item>4 seconds</item>
+ <item>5 seconds</item>
+ <item>6 seconds</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ <item>6</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml
new file mode 100644
index 0000000..e842ae4
--- /dev/null
+++ b/DeviceSettings/res/values/strings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III Settings</string>
+
+ <string name="category_haptic_title">Haptic</string>
+ <string name="vibrator_subcat_title">Vibrator</string>
+ <string name="vibrator_intensity_title_head">Vibrator Intensity</string>
+ <string name="vibrator_intensity_summary_head">Set vibrator intensity</string>
+
+ <string name="category_radio_title">Radio</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
+
+ <string name="category_screen_title">Screen</string>
+ <string name="mdnie_subcat_title">Colors</string>
+ <string name="mdnie_scenario_title_head">Scenario</string>
+ <string name="mdnie_scenario_summary_head">Set the mDNIe Scenario</string>
+ <string name="mdnie_mode_title_head">Mode</string>
+ <string name="mdnie_mode_summary_head">Set the mDNIe Mode</string>
+ <string name="mdnie_negative_title_head">Negative Mode</string>
+ <string name="mdnie_negative_summary_head">Enable/Disable inverted colors</string>
+
+ <string name="led_subcat_title">Notification LED</string>
+ <string name="led_fade_title_head">LED Fading</string>
+ <string name="led_fade_summary_head">Enable LED smooth fading instead of sharp blinking.</string>
+
+ <string name="touchkey_subcat_title">Touchkeys</string>
+ <string name="touchkey_light_title_head">Backlight</string>
+ <string name="touchkey_light_summary_off">Enable backlight</string>
+ <string name="touchkey_light_summary_on">Disable backlight</string>
+ <string name="touchkey_timeout_title_head">Backlight timeout</string>
+ <string name="touchkey_timeout_summary_head">Set timeout for the backlight</string>
+
+</resources>
diff --git a/DeviceSettings/res/xml/haptic_preferences.xml b/DeviceSettings/res/xml/haptic_preferences.xml
new file mode 100644
index 0000000..31c0e21
--- /dev/null
+++ b/DeviceSettings/res/xml/haptic_preferences.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory
+ android:title="@string/vibrator_subcat_title">
+ <com.cyanogenmod.settings.device.VibratorIntensity
+ android:key="vibrator_intensity"
+ android:title="@string/vibrator_intensity_title_head"
+ android:summary="@string/vibrator_intensity_summary_head"
+ android:entries="@array/vibrator_intensity_entries"
+ android:entryValues="@array/vibrator_intensity_entries_values"
+ android:defaultValue="50" />
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/DeviceSettings/res/xml/radio_preferences.xml b/DeviceSettings/res/xml/radio_preferences.xml
new file mode 100644
index 0000000..c173db7
--- /dev/null
+++ b/DeviceSettings/res/xml/radio_preferences.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Hspa modes -->
+ <com.cyanogenmod.settings.device.Hspa
+ android:key="hspa"
+ android:title="@string/hspa_title_head"
+ android:summary="@string/hspa_summary_head"
+ android:entries="@array/hspa_entries"
+ android:entryValues="@array/hspa_entries_values"
+ android:defaultValue="23" />
+
+</PreferenceScreen>
diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml
new file mode 100644
index 0000000..aff39c0
--- /dev/null
+++ b/DeviceSettings/res/xml/screen_preferences.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <PreferenceCategory
+ android:title="@string/mdnie_subcat_title">
+ <!-- mDNIe Scenario modes -->
+ <com.cyanogenmod.settings.device.mDNIeScenario
+ android:key="mdnie_scenario"
+ android:title="@string/mdnie_scenario_title_head"
+ android:summary="@string/mdnie_scenario_summary_head"
+ android:entries="@array/mdnie_scenario_entries"
+ android:entryValues="@array/mdnie_scenario_entries_values"
+ android:defaultValue="0" />
+
+ <!-- mDNIe Mode -->
+ <com.cyanogenmod.settings.device.mDNIeMode
+ android:key="mdnie_mode"
+ android:title="@string/mdnie_mode_title_head"
+ android:summary="@string/mdnie_mode_summary_head"
+ android:entries="@array/mdnie_mode_entries"
+ android:entryValues="@array/mdnie_mode_entries_values"
+ android:defaultValue="0" />
+
+ <!-- mDNIe Negative mode -->
+ <com.cyanogenmod.settings.device.mDNIeNegative
+ android:key="mdnie_negative"
+ android:title="@string/mdnie_negative_title_head"
+ android:summary="@string/mdnie_negative_summary_head"
+ android:entries="@array/mdnie_negative_entries"
+ android:entryValues="@array/mdnie_negative_entries_values"
+ android:defaultValue="0" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="@string/led_subcat_title">
+ <!-- LED fading mode -->
+ <com.cyanogenmod.settings.device.LedFade
+ android:key="led_fade"
+ android:title="@string/led_fade_title_head"
+ android:summary="@string/led_fade_summary_head"
+ android:entries="@array/led_fade_entries"
+ android:entryValues="@array/led_fade_entries_values"
+ android:defaultValue="1" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="@string/touchkey_subcat_title">
+ <!-- Touchkey backlight -->
+ <CheckBoxPreference
+ android:key="touchkey_light"
+ android:title="@string/touchkey_light_title_head"
+ android:summaryOff="@string/touchkey_light_summary_off"
+ android:summaryOn="@string/touchkey_light_summary_on"
+ android:defaultValue="true"
+ />
+ <com.cyanogenmod.settings.device.TouchkeyTimeout
+ android:key="touchkey_timeout"
+ android:title="@string/touchkey_timeout_title_head"
+ android:summary="@string/touchkey_timeout_summary_head"
+ android:entries="@array/touchkey_timeout_entries"
+ android:entryValues="@array/touchkey_timeout_entries_values"
+ android:defaultValue="3" />
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
new file mode 100644
index 0000000..152e361
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v13.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.MenuItem;
+
+import com.cyanogenmod.settings.device.R;
+
+import java.util.ArrayList;
+
+public class DeviceSettings extends FragmentActivity {
+
+ public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device";
+ public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE";
+ public static final String KEY_HSPA = "hspa";
+ public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity";
+ public static final String KEY_MDNIE_SCENARIO = "mdnie_scenario";
+ public static final String KEY_MDNIE_MODE = "mdnie_mode";
+ public static final String KEY_MDNIE_NEGATIVE = "mdnie_negative";
+ public static final String KEY_LED_FADE = "led_fade";
+ public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light";
+ public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout";
+
+ ViewPager mViewPager;
+ TabsAdapter mTabsAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mViewPager = new ViewPager(this);
+ mViewPager.setId(R.id.viewPager);
+ setContentView(mViewPager);
+
+ final ActionBar bar = getActionBar();
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
+ bar.setTitle(R.string.app_name);
+ bar.setDisplayHomeAsUpEnabled(true);
+
+ mTabsAdapter = new TabsAdapter(this, mViewPager);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_radio_title),
+ RadioFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title),
+ ScreenFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title),
+ HapticFragmentActivity.class, null);
+
+
+ if (savedInstanceState != null) {
+ bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
+ }
+
+ public static class TabsAdapter extends FragmentPagerAdapter
+ implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
+ private final Context mContext;
+ private final ActionBar mActionBar;
+ private final ViewPager mViewPager;
+ private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+ static final class TabInfo {
+ private final Class<?> clss;
+ private final Bundle args;
+
+ TabInfo(Class<?> _class, Bundle _args) {
+ clss = _class;
+ args = _args;
+ }
+ }
+
+ public TabsAdapter(Activity activity, ViewPager pager) {
+ super(activity.getFragmentManager());
+ mContext = activity;
+ mActionBar = activity.getActionBar();
+ mViewPager = pager;
+ mViewPager.setAdapter(this);
+ mViewPager.setOnPageChangeListener(this);
+ }
+
+ public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
+ TabInfo info = new TabInfo(clss, args);
+ tab.setTag(info);
+ tab.setTabListener(this);
+ mTabs.add(info);
+ mActionBar.addTab(tab);
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public int getCount() {
+ return mTabs.size();
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ TabInfo info = mTabs.get(position);
+ return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+ }
+
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
+
+ public void onPageSelected(int position) {
+ mActionBar.setSelectedNavigationItem(position);
+ }
+
+ public void onPageScrollStateChanged(int state) {
+ }
+
+ public void onTabSelected(Tab tab, FragmentTransaction ft) {
+ Object tag = tab.getTag();
+ for (int i=0; i<mTabs.size(); i++) {
+ if (mTabs.get(i) == tag) {
+ mViewPager.setCurrentItem(i);
+ }
+ }
+ }
+
+ public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+ }
+
+ public void onTabReselected(Tab tab, FragmentTransaction ft) {
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ DeviceSettings.this.onBackPressed();
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
new file mode 100644
index 0000000..0f3313d
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class HapticFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyS3Settings_Haptic";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.haptic_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ String boxValue;
+ String key = preference.getKey();
+
+ Log.w(TAG, "key: " + key);
+
+ return true;
+ }
+
+ public static boolean isSupported(String FILE) {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
new file mode 100644
index 0000000..f19eff7
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.util.AttributeSet;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class Hspa extends ListPreference implements OnPreferenceChangeListener {
+
+ private static final String FILE = "/system/app/SamsungServiceMode.apk";
+ private Context mCtx;
+
+ public Hspa(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ mCtx = context;
+ }
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore hspa setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ sendIntent(context, sharedPrefs.getString(DeviceSettings.KEY_HSPA, "23"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ sendIntent(mCtx, (String) newValue);
+ return true;
+ }
+
+ private static void sendIntent(Context context, String value) {
+ Intent i = new Intent("com.cyanogenmod.SamsungServiceMode.EXECUTE");
+ i.putExtra("sub_type", 20); // HSPA Setting
+ i.putExtra("data", value);
+ context.sendBroadcast(i);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java b/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java
new file mode 100644
index 0000000..6d11947
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class LedFade extends ListPreference implements OnPreferenceChangeListener {
+
+ public LedFade(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/class/sec/led/led_fade";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore led fading mode setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_LED_FADE, "1"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
new file mode 100644
index 0000000..62b855c
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class RadioFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyS2Parts_Radio";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.radio_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ String boxValue;
+ String key = preference.getKey();
+
+ Log.w(TAG, "key: " + key);
+
+ return true;
+ }
+
+ public static boolean isSupported(String FILE) {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
new file mode 100644
index 0000000..36180ae
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class ScreenFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyS3Settings_Screen";
+ private mDNIeScenario mmDNIeScenario;
+ private mDNIeMode mmDNIeMode;
+ private mDNIeNegative mmDNIeNegative;
+ private LedFade mLedFade;
+
+ private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness";
+ private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.screen_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+ mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO);
+ mmDNIeScenario.setEnabled(mDNIeScenario.isSupported());
+
+ mmDNIeMode = (mDNIeMode) findPreference(DeviceSettings.KEY_MDNIE_MODE);
+ mmDNIeMode.setEnabled(mDNIeMode.isSupported());
+
+ mmDNIeNegative = (mDNIeNegative) findPreference(DeviceSettings.KEY_MDNIE_NEGATIVE);
+ mmDNIeNegative.setEnabled(mDNIeNegative.isSupported());
+
+ mLedFade = (LedFade) findPreference(DeviceSettings.KEY_LED_FADE);
+ mLedFade.setEnabled(LedFade.isSupported());
+
+ if (((CheckBoxPreference)prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT)).isChecked()) {
+ prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
+ } else {
+ prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ String key = preference.getKey();
+ Log.w(TAG, "key: " + key);
+
+ if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) {
+ if (((CheckBoxPreference)preference).isChecked()) {
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0");
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1");
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
+ } else {
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1");
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2");
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ }
+ }
+ return true;
+ }
+
+ public static boolean isSupported(String FILE) {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true);
+
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, light ? "0" : "1");
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, light ? "1" : "2");
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
new file mode 100644
index 0000000..dc9ec9c
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class Startup extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(final Context context, final Intent bootintent) {
+ HapticFragmentActivity.restore(context);
+ Hspa.restore(context);
+ RadioFragmentActivity.restore(context);
+ ScreenFragmentActivity.restore(context);
+ mDNIeScenario.restore(context);
+ mDNIeMode.restore(context);
+ mDNIeNegative.restore(context);
+ LedFade.restore(context);
+ VibratorIntensity.restore(context);
+ TouchkeyTimeout.restore(context);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
new file mode 100644
index 0000000..6ea9bfb
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class TouchkeyTimeout extends ListPreference implements OnPreferenceChangeListener {
+
+ public TouchkeyTimeout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE_TOUCHKEY_TIMEOUT = "/sys/class/sec/sec_touchkey/timeout";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE_TOUCHKEY_TIMEOUT);
+ }
+
+ /**
+ * Restore touchscreen sensitivity setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_TIMEOUT, "3"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
new file mode 100644
index 0000000..d4df92f
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.SyncFailedException;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Context;
+
+public class Utils {
+
+ private static final String TAG = "GalaxyS3Settings_Utils";
+ private static final String TAG_READ = "GalaxyS3Settings_Utils_Read";
+ private static final String TAG_WRITE = "GalaxyS3Settings_Utils_Write";
+
+ /**
+ * Write a string value to the specified file.
+ *
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, String value) {
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(new File(filename), false);
+ fos.write(value.getBytes());
+ fos.flush();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + value);
+ fos.close();
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException while closing synced file: ", ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while closing file: ", ex);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Write a string value to the specified file.
+ *
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, Boolean value) {
+ FileOutputStream fos = null;
+ String sEnvia;
+ try {
+ fos = new FileOutputStream(new File(filename), false);
+ if (value)
+ sEnvia = "1";
+ else
+ sEnvia = "0";
+ fos.write(sEnvia.getBytes());
+ fos.flush();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + value);
+ fos.close();
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException while closing synced file: ", ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while closing file: ", ex);
+ }
+ }
+ }
+ }
+
+ /**
+ * Write the "color value" to the specified file. The value is scaled from
+ * an integer to an unsigned integer by multiplying by 2.
+ * @param filename The filename
+ * @param value The value of max value Integer.MAX
+ */
+ public static void writeColor(String filename, int value) {
+ writeValue(filename, String.valueOf((long) value * 2));
+ }
+
+ /**
+ * Check if the specified file exists.
+ * @param filename The filename
+ * @return Whether the file exists or not
+ */
+ public static boolean fileExists(String filename) {
+ return new File(filename).exists();
+ }
+
+
+ public static void showDialog(Context ctx, String title, String message) {
+ final AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
+ alertDialog.setTitle(title);
+ alertDialog.setMessage(message);
+ alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ alertDialog.dismiss();
+ }
+ });
+ alertDialog.show();
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
new file mode 100644
index 0000000..7a809a5
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class VibratorIntensity extends ListPreference implements OnPreferenceChangeListener {
+
+ public VibratorIntensity(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/vibrator/pwm_val";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore vibrator intensity setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_VIBRATOR_INTENSITY, "50"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java
new file mode 100644
index 0000000..7969637
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+
+import android.content.SharedPreferences;
+import android.util.AttributeSet;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class mDNIeMode extends ListPreference implements OnPreferenceChangeListener {
+
+ public mDNIeMode(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/class/mdnie/mdnie/mode";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore mdnie user mode setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_MODE, "0"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java
new file mode 100644
index 0000000..c2ccc7b
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class mDNIeNegative extends ListPreference implements OnPreferenceChangeListener {
+
+ public mDNIeNegative(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/class/mdnie/mdnie/negative";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore mdnie user mode setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_NEGATIVE, "0"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java
new file mode 100644
index 0000000..a9c935a
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+
+import android.content.SharedPreferences;
+import android.util.AttributeSet;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class mDNIeScenario extends ListPreference implements OnPreferenceChangeListener {
+
+ public mDNIeScenario(Context context, AttributeSet attrs) {
+ super(context,attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/class/mdnie/mdnie/scenario";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore mdnie "camera" setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE_SCENARIO, "0"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/README b/README
new file mode 100644
index 0000000..a263ed6
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+Samsung Galaxy S III LTE (GSM)
+
+Supported variants:
+ - GT-I9305 (INTL)
diff --git a/audio/Android.mk b/audio/Android.mk
new file mode 100644
index 0000000..03a39b1
--- /dev/null
+++ b/audio/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := audio.primary.$(TARGET_BOOTLOADER_BOARD_NAME)
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := audio_hw.c
+
+LOCAL_C_INCLUDES += \
+ external/tinyalsa/include \
+ external/expat/lib \
+ $(call include-path-for, audio-utils) \
+ $(call include-path-for, audio-effects)
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl libexpat
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
new file mode 100644
index 0000000..b687139
--- /dev/null
+++ b/audio/audio_hw.c
@@ -0,0 +1,3234 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2012 Wolfson Microelectronics plc
+ * Copyright (C) 2012 The CyanogenMod Project
+ * Daniel Hillenbrand <codeworkx@cyanogenmod.com>
+ * Guillaume "XpLoDWilD" Lesniak <xplodgui@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "audio_hw_primary"
+#define LOG_NDEBUG 0
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <expat.h>
+#include <dlfcn.h>
+
+#include <cutils/log.h>
+#include <cutils/str_parms.h>
+#include <cutils/properties.h>
+
+#include <hardware/hardware.h>
+#include <system/audio.h>
+#include <hardware/audio.h>
+
+#include <tinyalsa/asoundlib.h>
+#include <audio_utils/resampler.h>
+#include <audio_utils/echo_reference.h>
+#include <hardware/audio_effect.h>
+#include <audio_effects/effect_aec.h>
+
+#include "audio_hw.h"
+
+struct pcm_config pcm_config_mm = {
+ .channels = 2,
+ .rate = MM_FULL_POWER_SAMPLING_RATE,
+ .period_size = DEEP_BUFFER_LONG_PERIOD_SIZE,
+ .period_count = PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT,
+ .format = PCM_FORMAT_S16_LE,
+};
+
+struct pcm_config pcm_config_tones = {
+ .channels = 2,
+ .rate = MM_FULL_POWER_SAMPLING_RATE,
+ .period_size = SHORT_PERIOD_SIZE,
+ .period_count = PLAYBACK_SHORT_PERIOD_COUNT,
+ .format = PCM_FORMAT_S16_LE,
+ .start_threshold = 0,
+ .avail_min = 0,
+};
+
+struct pcm_config pcm_config_capture = {
+ .channels = 2,
+ .rate = DEFAULT_IN_SAMPLING_RATE,
+ .period_size = CAPTURE_PERIOD_SIZE,
+ .period_count = CAPTURE_PERIOD_COUNT,
+ .format = PCM_FORMAT_S16_LE,
+};
+
+struct pcm_config pcm_config_vx = {
+ .channels = 2,
+ .rate = VX_WB_SAMPLING_RATE,
+ .period_size = 160,
+ .period_count = 2,
+ .format = PCM_FORMAT_S16_LE,
+};
+
+#define MIN(x, y) ((x) > (y) ? (y) : (x))
+
+struct m0_audio_device {
+ struct audio_hw_device hw_device;
+
+ pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ struct m0_dev_cfg *dev_cfgs;
+ int num_dev_cfgs;
+ struct mixer *mixer;
+ struct mixer_ctls mixer_ctls;
+ audio_mode_t mode;
+ int active_out_device;
+ int out_device;
+ int active_in_device;
+ int in_device;
+ struct pcm *pcm_modem_dl;
+ struct pcm *pcm_modem_ul;
+ struct pcm *pcm_bt_dl;
+ struct pcm *pcm_bt_ul;
+ int in_call;
+ float voice_volume;
+ struct m0_stream_in *active_input;
+ struct m0_stream_out *outputs[OUTPUT_TOTAL];
+ bool mic_mute;
+ int tty_mode;
+ struct echo_reference_itfe *echo_reference;
+ bool bluetooth_nrec;
+ bool screen_off;
+};
+
+struct m0_stream_out {
+ struct audio_stream_out stream;
+
+ pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ struct pcm_config config[PCM_TOTAL];
+ struct pcm *pcm[PCM_TOTAL];
+ struct resampler_itfe *resampler;
+ char *buffer;
+ size_t buffer_frames;
+ int standby;
+ struct echo_reference_itfe *echo_reference;
+ int write_threshold;
+ bool use_long_periods;
+ audio_channel_mask_t channel_mask;
+ audio_channel_mask_t sup_channel_masks[3];
+
+ struct m0_audio_device *dev;
+};
+
+#define MAX_PREPROCESSORS 3 /* maximum one AGC + one NS + one AEC per input stream */
+
+struct effect_info_s {
+ effect_handle_t effect_itfe;
+ size_t num_channel_configs;
+ channel_config_t* channel_configs;
+};
+
+#define NUM_IN_AUX_CNL_CONFIGS 2
+channel_config_t in_aux_cnl_configs[NUM_IN_AUX_CNL_CONFIGS] = {
+ { AUDIO_CHANNEL_IN_FRONT , AUDIO_CHANNEL_IN_BACK},
+ { AUDIO_CHANNEL_IN_STEREO , AUDIO_CHANNEL_IN_RIGHT}
+};
+
+struct m0_stream_in {
+ struct audio_stream_in stream;
+
+ pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ struct pcm_config config;
+ struct pcm *pcm;
+ int device;
+ struct resampler_itfe *resampler;
+ struct resampler_buffer_provider buf_provider;
+ unsigned int requested_rate;
+ int standby;
+ int source;
+ struct echo_reference_itfe *echo_reference;
+ bool need_echo_reference;
+
+ int16_t *read_buf;
+ size_t read_buf_size;
+ size_t read_buf_frames;
+
+ int16_t *proc_buf_in;
+ int16_t *proc_buf_out;
+ size_t proc_buf_size;
+ size_t proc_buf_frames;
+
+ int16_t *ref_buf;
+ size_t ref_buf_size;
+ size_t ref_buf_frames;
+
+ int read_status;
+
+ int num_preprocessors;
+ struct effect_info_s preprocessors[MAX_PREPROCESSORS];
+
+ bool aux_channels_changed;
+ uint32_t main_channels;
+ uint32_t aux_channels;
+ struct m0_audio_device *dev;
+};
+
+struct m0_dev_cfg {
+ int mask;
+
+ struct route_setting *on;
+ unsigned int on_len;
+
+ struct route_setting *off;
+ unsigned int off_len;
+};
+
+/* QCOM CSD-Client */
+#define CSD_CLIENT_LIBPATH "/system/lib/libcsd-client.so"
+
+void *mCsdHandle;
+int rx_dev_id, tx_dev_id;
+
+static int (*csd_client_init)();
+static int (*csd_client_deinit)();
+static int (*csd_start_playback)();
+static int (*csd_stop_playback)();
+static int (*csd_disable_device)();
+static int (*csd_enable_device)(int, int, uint32_t);
+static int (*csd_switch_device)(int,int);
+static int (*csd_volume)(int);
+static int (*csd_mic_mute)(int);
+static int (*csd_wide_voice)(uint8_t);
+static int (*csd_slow_talk)(uint8_t);
+static int (*csd_fens)(uint8_t);
+static int (*csd_volume_index)(int);
+static int (*csd_start_voice)(int,int,int);
+static int (*csd_stop_voice)(int);
+static int (*csd_client_volume)(int);
+static int (*csd_client_mic_mute)(int);
+static int (*csd_client_pcm_loopback_start)(int,int);
+static int (*csd_client_pcm_loopback_stop)(int);
+
+void setCsdHandle(void* handle)
+{
+ void *mcsd_handle;
+ mcsd_handle = (void*)handle;
+ ALOGD("%s csd_handle: %p", __func__, mcsd_handle);
+
+ csd_start_voice = (int (*)(int,int,int)) dlsym(mcsd_handle,"csd_client_start_voice");
+ csd_enable_device = (int (*)(int,int,uint32_t)) dlsym(mcsd_handle,"csd_client_enable_device");
+ csd_disable_device = (int (*)()) dlsym(mcsd_handle,"csd_client_disable_device");
+ //csd_client_start_record
+ //csd_client_stop_record
+ csd_start_playback = (int (*)()) dlsym(mcsd_handle,"csd_client_start_playback");
+ csd_stop_playback = (int (*)()) dlsym(mcsd_handle,"csd_client_stop_playback");
+ csd_volume = (int (*)(int)) dlsym(mcsd_handle,"csd_client_volume");
+ csd_mic_mute = (int (*)(int)) dlsym(mcsd_handle,"csd_client_mic_mute");
+ csd_wide_voice = (int (*)(uint8_t)) dlsym(mcsd_handle,"csd_client_wide_voice");
+ csd_slow_talk = (int (*)(uint8_t)) dlsym(mcsd_handle,"csd_client_slow_talk");
+ csd_fens = (int (*)(uint8_t)) dlsym(mcsd_handle,"csd_client_fens");
+ csd_volume_index = (int (*)(int)) dlsym(mcsd_handle,"csd_client_volume_index");
+ csd_switch_device = (int (*)(int,int)) dlsym(mcsd_handle,"csd_client_switch_device");
+ //csd_client_stream_mute
+ csd_client_pcm_loopback_start = (int (*)(int,int)) dlsym(mcsd_handle,"csd_client_pcm_loopback_start");
+ csd_client_pcm_loopback_stop = (int (*)(int)) dlsym(mcsd_handle,"csd_client_pcm_loopback_stop");
+ //csd_client_tty
+ csd_client_init = (int (*)()) dlsym(mcsd_handle,"csd_client_init_lb");
+ csd_client_deinit = (int (*)()) dlsym(mcsd_handle,"csd_client_deinit_lb");
+ csd_stop_voice = (int (*)(int)) dlsym(mcsd_handle,"csd_client_stop_voice");
+}
+
+/**
+ * NOTE: when multiple mutexes have to be acquired, always respect the following order:
+ * hw device > in stream > out stream
+ */
+
+static void select_output_device(struct m0_audio_device *adev);
+static void select_input_device(struct m0_audio_device *adev);
+static int adev_set_voice_volume(struct audio_hw_device *dev, float volume);
+static int do_input_standby(struct m0_stream_in *in);
+static int do_output_standby(struct m0_stream_out *out);
+static void in_update_aux_channels(struct m0_stream_in *in, effect_handle_t effect);
+
+/* The enable flag when 0 makes the assumption that enums are disabled by
+ * "Off" and integers/booleans by 0 */
+static int set_bigroute_by_array(struct mixer *mixer, struct route_setting *route,
+ int enable)
+{
+ struct mixer_ctl *ctl;
+ unsigned int i, j, ret;
+
+ /* Go through the route array and set each value */
+ i = 0;
+ while (route[i].ctl_name) {
+ ctl = mixer_get_ctl_by_name(mixer, route[i].ctl_name);
+ if (!ctl) {
+ ALOGE("Unknown control '%s'\n", route[i].ctl_name);
+ return -EINVAL;
+ }
+
+ if (route[i].strval) {
+ if (enable) {
+ ret = mixer_ctl_set_enum_by_string(ctl, route[i].strval);
+ if (ret != 0) {
+ ALOGE("Failed to set '%s' to '%s'\n", route[i].ctl_name, route[i].strval);
+ } else {
+ ALOGV("Set '%s' to '%s'\n", route[i].ctl_name, route[i].strval);
+ }
+ } else {
+ ret = mixer_ctl_set_enum_by_string(ctl, "Off");
+ if (ret != 0) {
+ ALOGE("Failed to set '%s' to '%s'\n", route[i].ctl_name, route[i].strval);
+ } else {
+ ALOGV("Set '%s' to '%s'\n", route[i].ctl_name, "Off");
+ }
+ }
+ } else {
+ /* This ensures multiple (i.e. stereo) values are set jointly */
+ for (j = 0; j < mixer_ctl_get_num_values(ctl); j++) {
+ if (enable) {
+ ret = mixer_ctl_set_value(ctl, j, route[i].intval);
+ if (ret != 0) {
+ ALOGE("Failed to set '%s' to '%d'\n", route[i].ctl_name, route[i].intval);
+ } else {
+ ALOGV("Set '%s' to '%d'\n", route[i].ctl_name, route[i].intval);
+ }
+ } else {
+ ret = mixer_ctl_set_value(ctl, j, 0);
+ if (ret != 0) {
+ ALOGE("Failed to set '%s' to '%d'\n", route[i].ctl_name, route[i].intval);
+ } else {
+ ALOGV("Set '%s' to '%d'\n", route[i].ctl_name, 0);
+ }
+ }
+ }
+ }
+ i++;
+ }
+
+ return 0;
+}
+
+/* The enable flag when 0 makes the assumption that enums are disabled by
+ * "Off" and integers/booleans by 0 */
+static int set_route_by_array(struct mixer *mixer, struct route_setting *route,
+ unsigned int len)
+{
+ struct mixer_ctl *ctl;
+ unsigned int i, j, ret;
+
+ /* Go through the route array and set each value */
+ for (i = 0; i < len; i++) {
+ ctl = mixer_get_ctl_by_name(mixer, route[i].ctl_name);
+ if (!ctl) {
+ ALOGE("Unknown control '%s'\n", route[i].ctl_name);
+ return -EINVAL;
+ }
+
+ if (route[i].strval) {
+ ret = mixer_ctl_set_enum_by_string(ctl, route[i].strval);
+ if (ret != 0) {
+ ALOGE("Failed to set '%s' to '%s'\n",
+ route[i].ctl_name, route[i].strval);
+ } else {
+ ALOGV("Set '%s' to '%s'\n",
+ route[i].ctl_name, route[i].strval);
+ }
+
+ } else {
+ /* This ensures multiple (i.e. stereo) values are set jointly */
+ for (j = 0; j < mixer_ctl_get_num_values(ctl); j++) {
+ ret = mixer_ctl_set_value(ctl, j, route[i].intval);
+ if (ret != 0) {
+ ALOGE("Failed to set '%s'.%d to %d\n",
+ route[i].ctl_name, j, route[i].intval);
+ } else {
+ ALOGV("Set '%s'.%d to %d\n",
+ route[i].ctl_name, j, route[i].intval);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* Must be called with lock */
+void select_devices(struct m0_audio_device *adev)
+{
+ int i;
+
+ if (adev->active_out_device == adev->out_device && adev->active_in_device == adev->in_device)
+ return;
+
+ ALOGV("Changing output device %x => %x\n", adev->active_out_device, adev->out_device);
+ ALOGV("Changing input device %x => %x\n", adev->active_in_device, adev->in_device);
+
+ /* Turn on new devices first so we don't glitch due to powerdown... */
+ for (i = 0; i < adev->num_dev_cfgs; i++)
+ if ((adev->out_device & adev->dev_cfgs[i].mask) &&
+ !(adev->active_out_device & adev->dev_cfgs[i].mask))
+ set_route_by_array(adev->mixer, adev->dev_cfgs[i].on,
+ adev->dev_cfgs[i].on_len);
+
+ for (i = 0; i < adev->num_dev_cfgs; i++)
+ if ((adev->in_device & adev->dev_cfgs[i].mask) &&
+ !(adev->active_in_device & adev->dev_cfgs[i].mask))
+ set_route_by_array(adev->mixer, adev->dev_cfgs[i].on,
+ adev->dev_cfgs[i].on_len);
+
+ /* ...then disable old ones. */
+ for (i = 0; i < adev->num_dev_cfgs; i++)
+ if (!(adev->out_device & adev->dev_cfgs[i].mask) &&
+ (adev->active_out_device & adev->dev_cfgs[i].mask))
+ set_route_by_array(adev->mixer, adev->dev_cfgs[i].off,
+ adev->dev_cfgs[i].off_len);
+
+ for (i = 0; i < adev->num_dev_cfgs; i++)
+ if (!(adev->in_device & adev->dev_cfgs[i].mask) &&
+ (adev->active_in_device & adev->dev_cfgs[i].mask))
+ set_route_by_array(adev->mixer, adev->dev_cfgs[i].off,
+ adev->dev_cfgs[i].off_len);
+
+ adev->active_out_device = adev->out_device;
+ adev->active_in_device = adev->in_device;
+}
+
+static int start_call(struct m0_audio_device *adev)
+{
+ ALOGV("Opening modem PCMs");
+ int bt_on;
+
+ bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO;
+
+ /* use amr-wb by default */
+ pcm_config_vx.rate = VX_WB_SAMPLING_RATE;
+
+ /* Open modem PCM channels */
+ if (adev->pcm_modem_dl == NULL) {
+ ALOGD("Opening PCM modem DL stream");
+ adev->pcm_modem_dl = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_OUT, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_modem_dl)) {
+ ALOGE("cannot open PCM modem DL stream: %s", pcm_get_error(adev->pcm_modem_dl));
+ goto err_open_dl;
+ }
+ }
+
+ if (adev->pcm_modem_ul == NULL) {
+ ALOGD("Opening PCM modem UL stream");
+ adev->pcm_modem_ul = pcm_open(CARD_DEFAULT, PORT_MODEM, PCM_IN, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_modem_ul)) {
+ ALOGE("cannot open PCM modem UL stream: %s", pcm_get_error(adev->pcm_modem_ul));
+ goto err_open_ul;
+ }
+ }
+
+ ALOGD("Starting PCM modem streams");
+ pcm_start(adev->pcm_modem_dl);
+ pcm_start(adev->pcm_modem_ul);
+
+ /* Open bluetooth PCM channels */
+ if (bt_on) {
+ ALOGV("Opening bluetooth PCMs");
+ /* use amr-nb for bluetooth */
+ pcm_config_vx.rate = VX_NB_SAMPLING_RATE;
+
+ if (adev->pcm_bt_dl == NULL) {
+ ALOGD("Opening PCM bluetooth DL stream");
+ adev->pcm_bt_dl = pcm_open(CARD_DEFAULT, PORT_BT, PCM_OUT, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_bt_dl)) {
+ ALOGE("cannot open PCM bluetooth DL stream: %s", pcm_get_error(adev->pcm_bt_dl));
+ goto err_open_dl;
+ }
+ }
+
+ if (adev->pcm_bt_ul == NULL) {
+ ALOGD("Opening PCM bluetooth UL stream");
+ adev->pcm_bt_ul = pcm_open(CARD_DEFAULT, PORT_BT, PCM_IN, &pcm_config_vx);
+ if (!pcm_is_ready(adev->pcm_bt_ul)) {
+ ALOGE("cannot open PCM bluetooth UL stream: %s", pcm_get_error(adev->pcm_bt_ul));
+ goto err_open_ul;
+ }
+ }
+ ALOGD("Starting PCM bluetooth streams");
+ pcm_start(adev->pcm_bt_dl);
+ pcm_start(adev->pcm_bt_ul);
+ }
+
+ return 0;
+
+err_open_ul:
+ pcm_close(adev->pcm_modem_ul);
+ adev->pcm_modem_ul = NULL;
+ pcm_close(adev->pcm_bt_ul);
+ adev->pcm_bt_ul = NULL;
+err_open_dl:
+ pcm_close(adev->pcm_modem_dl);
+ adev->pcm_modem_dl = NULL;
+ pcm_close(adev->pcm_bt_dl);
+ adev->pcm_bt_dl = NULL;
+
+ return -ENOMEM;
+}
+
+static void end_call(struct m0_audio_device *adev)
+{
+ int bt_on;
+ bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO;
+
+ if (adev->pcm_modem_dl != NULL) {
+ ALOGD("Stopping modem DL PCM");
+ pcm_stop(adev->pcm_modem_dl);
+ ALOGV("Closing modem DL PCM");
+ pcm_close(adev->pcm_modem_dl);
+ }
+ if (adev->pcm_modem_ul != NULL) {
+ ALOGD("Stopping modem UL PCM");
+ pcm_stop(adev->pcm_modem_ul);
+ ALOGV("Closing modem UL PCM");
+ pcm_close(adev->pcm_modem_ul);
+ }
+ adev->pcm_modem_dl = NULL;
+ adev->pcm_modem_ul = NULL;
+
+ if (bt_on) {
+ if (adev->pcm_bt_dl != NULL) {
+ ALOGD("Stopping bluetooth DL PCM");
+ pcm_stop(adev->pcm_bt_dl);
+ ALOGV("Closing bluetooth DL PCM");
+ pcm_close(adev->pcm_bt_dl);
+ }
+ if (adev->pcm_bt_ul != NULL) {
+ ALOGD("Stopping bluetooth UL PCM");
+ pcm_stop(adev->pcm_bt_ul);
+ ALOGV("Closing bluetooth UL PCM");
+ pcm_close(adev->pcm_bt_ul);
+ }
+ }
+ adev->pcm_bt_dl = NULL;
+ adev->pcm_bt_ul = NULL;
+}
+
+static void set_eq_filter(struct m0_audio_device *adev)
+{
+}
+
+static void set_incall_device(struct m0_audio_device *adev)
+{
+ int err;
+ uint32_t mDevSettingsFlag = TTY_OFF;
+
+ switch(adev->out_device) {
+ case AUDIO_DEVICE_OUT_EARPIECE:
+ rx_dev_id = DEVICE_HANDSET_RX_ACDB_ID;
+ tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID;
+ break;
+ case AUDIO_DEVICE_OUT_SPEAKER:
+ case AUDIO_DEVICE_OUT_AUX_DIGITAL:
+ case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET:
+ rx_dev_id = DEVICE_SPEAKER_MONO_RX_ACDB_ID;
+ tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID;
+ break;
+ case AUDIO_DEVICE_OUT_WIRED_HEADSET:
+ case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
+ rx_dev_id = DEVICE_HEADSET_RX_ACDB_ID;
+ tx_dev_id = DEVICE_HEADSET_TX_ACDB_ID;
+ break;
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
+ case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
+ if (adev->bluetooth_nrec) {
+ rx_dev_id = DEVICE_BT_SCO_RX_ACDB_ID;
+ tx_dev_id = DEVICE_BT_SCO_TX_ACDB_ID;
+ } else {
+ rx_dev_id = DEVICE_BT_SCO_RX_ACDB_ID;
+ tx_dev_id = DEVICE_BT_SCO_TX_ACDB_ID;
+ }
+ break;
+ default:
+ rx_dev_id = DEVICE_HANDSET_RX_ACDB_ID;
+ tx_dev_id = DEVICE_HANDSET_TX_ACDB_ID;
+ break;
+ }
+
+ ALOGV("rx_dev_id=%d, tx_dev_id=%d\n", rx_dev_id, tx_dev_id);
+
+ /* QCOM CSD-CLIENT */
+ if (!adev->in_call) {
+ if (csd_start_voice == NULL) {
+ ALOGE("dlsym:Error:%s Loading csd_client_start_voice", dlerror());
+ } else {
+ ALOGD("%s: calling csd_start_voice", __func__);
+ err = csd_start_voice(rx_dev_id, tx_dev_id, 1);
+ if (err < 0) {
+ ALOGE("%s: csd_start_voice error %d\n", __func__, err);
+ }
+ }
+ }
+
+ if (csd_switch_device == NULL) {
+ ALOGE("dlsym:Error:%s Loading csd_client_switch_device", dlerror());
+ } else {
+ ALOGD("%s: calling csd_switch_device", __func__);
+ err = csd_switch_device(rx_dev_id, tx_dev_id);
+ if (err < 0) {
+ ALOGE("%s: csd_switch_device failed, error %d", __func__, err);
+ }
+ }
+}
+
+static void set_input_volumes(struct m0_audio_device *adev, int main_mic_on,
+ int headset_mic_on, int sub_mic_on)
+{
+}
+
+static void set_output_volumes(struct m0_audio_device *adev, bool tty_volume)
+{
+}
+
+static void force_all_standby(struct m0_audio_device *adev)
+{
+ struct m0_stream_in *in;
+ struct m0_stream_out *out;
+
+ /* only needed for low latency output streams as other streams are not used
+ * for voice use cases */
+ if (adev->outputs[OUTPUT_LOW_LATENCY] != NULL &&
+ !adev->outputs[OUTPUT_LOW_LATENCY]->standby) {
+ out = adev->outputs[OUTPUT_LOW_LATENCY];
+ pthread_mutex_lock(&out->lock);
+ do_output_standby(out);
+ pthread_mutex_unlock(&out->lock);
+ }
+
+ if (adev->active_input) {
+ in = adev->active_input;
+ pthread_mutex_lock(&in->lock);
+ do_input_standby(in);
+ pthread_mutex_unlock(&in->lock);
+ }
+}
+
+static void select_mode(struct m0_audio_device *adev)
+{
+ int err;
+
+ if (adev->mode == AUDIO_MODE_IN_CALL) {
+ ALOGE("Entering IN_CALL state, in_call=%d", adev->in_call);
+ if (!adev->in_call) {
+ force_all_standby(adev);
+ /* force earpiece route for in call state if speaker is the
+ only currently selected route. This prevents having to tear
+ down the modem PCMs to change route from speaker to earpiece
+ after the ringtone is played, but doesn't cause a route
+ change if a headset or bt device is already connected. If
+ speaker is not the only thing active, just remove it from
+ the route. We'll assume it'll never be used initally during
+ a call. This works because we're sure that the audio policy
+ manager will update the output device after the audio mode
+ change, even if the device selection did not change. */
+ if (adev->out_device == AUDIO_DEVICE_OUT_SPEAKER) {
+ adev->out_device = AUDIO_DEVICE_OUT_EARPIECE;
+ adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN;
+ } else
+ adev->out_device &= ~AUDIO_DEVICE_OUT_SPEAKER;
+ select_output_device(adev);
+ start_call(adev);
+ adev_set_voice_volume(&adev->hw_device, adev->voice_volume);
+ adev->in_call = 1;
+ }
+ } else {
+ ALOGE("Leaving IN_CALL state, in_call=%d, mode=%d",
+ adev->in_call, adev->mode);
+ if (adev->in_call) {
+ adev->in_call = 0;
+ end_call(adev);
+
+ /* QCOM CSD-Client */
+ if (csd_stop_voice == NULL) {
+ ALOGE("dlsym:Error:%s Loading csd_client_disable_device", dlerror());
+ } else {
+ ALOGD("%s: calling csd_stop_voice", __func__);
+ err = csd_stop_voice(1);
+ if (err < 0) {
+ ALOGE("%s: csd_stop_voice error %d\n", __func__, err);
+ }
+ }
+
+ force_all_standby(adev);
+ select_output_device(adev);
+ select_input_device(adev);
+ }
+ }
+}
+
+static void select_output_device(struct m0_audio_device *adev)
+{
+ int headset_on;
+ int headphone_on;
+ int speaker_on;
+ int earpiece_on;
+ int bt_on;
+ bool tty_volume = false;
+ unsigned int channel;
+
+ headset_on = adev->out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET;
+ headphone_on = adev->out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
+ speaker_on = adev->out_device & AUDIO_DEVICE_OUT_SPEAKER;
+ earpiece_on = adev->out_device & AUDIO_DEVICE_OUT_EARPIECE;
+ bt_on = adev->out_device & AUDIO_DEVICE_OUT_ALL_SCO;
+
+ switch(adev->out_device) {
+ case AUDIO_DEVICE_OUT_SPEAKER:
+ ALOGD("%s: AUDIO_DEVICE_OUT_SPEAKER", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_WIRED_HEADSET:
+ ALOGD("%s: AUDIO_DEVICE_OUT_WIRED_HEADSET", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
+ ALOGD("%s: AUDIO_DEVICE_OUT_WIRED_HEADPHONE", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_EARPIECE:
+ ALOGD("%s: AUDIO_DEVICE_OUT_EARPIECE", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET:
+ ALOGD("%s: AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET:
+ ALOGD("%s: AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET", __func__);
+ break;
+ case AUDIO_DEVICE_OUT_ALL_SCO:
+ ALOGD("%s: AUDIO_DEVICE_OUT_ALL_SCO", __func__);
+ break;
+ default:
+ ALOGD("%s: AUDIO_DEVICE_OUT_ALL", __func__);
+ break;
+ }
+
+ select_devices(adev);
+
+ set_eq_filter(adev);
+
+ if (adev->mode == AUDIO_MODE_IN_CALL) {
+ if (!bt_on) {
+ /* force tx path according to TTY mode when in call */
+ switch(adev->tty_mode) {
+ case TTY_MODE_FULL:
+ case TTY_MODE_HCO:
+ /* tx path from headset mic */
+ headphone_on = 0;
+ headset_on = 1;
+ speaker_on = 0;
+ earpiece_on = 0;
+ break;
+ case TTY_MODE_VCO:
+ /* tx path from device sub mic */
+ headphone_on = 0;
+ headset_on = 0;
+ speaker_on = 1;
+ earpiece_on = 0;
+ break;
+ case TTY_MODE_OFF:
+ default:
+ break;
+ }
+ }
+
+ if (headset_on || headphone_on || speaker_on || earpiece_on) {
+ ALOGD("%s: set voicecall route: voicecall_default", __func__);
+ set_bigroute_by_array(adev->mixer, voicecall_default, 1);
+ } else {
+ ALOGD("%s: set voicecall route: voicecall_default_disable", __func__);
+ set_bigroute_by_array(adev->mixer, voicecall_default_disable, 1);
+ }
+
+ if (speaker_on || earpiece_on || headphone_on) {
+ ALOGD("%s: set voicecall route: default_input", __func__);
+ set_bigroute_by_array(adev->mixer, default_input, 1);
+ } else {
+ ALOGD("%s: set voicecall route: default_input_disable", __func__);
+ set_bigroute_by_array(adev->mixer, default_input_disable, 1);
+ }
+
+ if (headset_on) {
+ ALOGD("%s: set voicecall route: headset_input", __func__);
+ set_bigroute_by_array(adev->mixer, headset_input, 1);
+ } else {
+ ALOGD("%s: set voicecall route: headset_input_disable", __func__);
+ set_bigroute_by_array(adev->mixer, headset_input_disable, 1);
+ }
+
+ if (bt_on) {
+ // bt uses a different port (PORT_BT) for playback, reopen the pcms
+ end_call(adev);
+ start_call(adev);
+ ALOGD("%s: set voicecall route: bt_input", __func__);
+ set_bigroute_by_array(adev->mixer, bt_input, 1);
+ ALOGD("%s: set voicecall route: bt_output", __func__);
+ set_bigroute_by_array(adev->mixer, bt_output, 1);
+ } else {
+ ALOGD("%s: set voicecall route: bt_disable", __func__);
+ set_bigroute_by_array(adev->mixer, bt_disable, 1);
+ }
+ set_incall_device(adev);
+ }
+}
+
+static void select_input_device(struct m0_audio_device *adev)
+{
+ switch(adev->in_device) {
+ case AUDIO_DEVICE_IN_BUILTIN_MIC:
+ ALOGD("%s: AUDIO_DEVICE_IN_BUILTIN_MIC", __func__);
+ break;
+ case AUDIO_DEVICE_IN_BACK_MIC:
+ ALOGD("%s: AUDIO_DEVICE_IN_BACK_MIC", __func__);
+ break;
+ case AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET:
+ ALOGD("%s: AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET", __func__);
+ break;
+ case AUDIO_DEVICE_IN_WIRED_HEADSET:
+ ALOGD("%s: AUDIO_DEVICE_IN_WIRED_HEADSET", __func__);
+ break;
+ default:
+ break;
+ }
+
+ select_devices(adev);
+}
+
+/* must be called with hw device and output stream mutexes locked */
+static int start_output_stream_low_latency(struct m0_stream_out *out)
+{
+ struct m0_audio_device *adev = out->dev;
+ unsigned int flags = PCM_OUT;
+ int i;
+ bool success = true;
+
+ if (adev->mode != AUDIO_MODE_IN_CALL) {
+ select_output_device(adev);
+ }
+
+ /* default to low power: will be corrected in out_write if necessary before first write to
+ * tinyalsa.
+ */
+
+ if (adev->out_device & ~(AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
+ /* Something not a dock in use */
+ out->config[PCM_NORMAL] = pcm_config_tones;
+ out->config[PCM_NORMAL].rate = MM_FULL_POWER_SAMPLING_RATE;
+ out->pcm[PCM_NORMAL] = pcm_open(CARD_DEFAULT, PORT_PLAYBACK,
+ flags, &out->config[PCM_NORMAL]);
+ }
+
+ if (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
+ /* SPDIF output in use */
+ out->config[PCM_SPDIF] = pcm_config_tones;
+ out->config[PCM_SPDIF].rate = MM_FULL_POWER_SAMPLING_RATE;
+ out->pcm[PCM_SPDIF] = pcm_open(CARD_DEFAULT, PORT_PLAYBACK,
+ flags, &out->config[PCM_SPDIF]);
+ }
+
+ /* Close any PCMs that could not be opened properly and return an error */
+ for (i = 0; i < PCM_TOTAL; i++) {
+ if (out->pcm[i] && !pcm_is_ready(out->pcm[i])) {
+ ALOGE("%s: cannot open pcm_out driver %d: %s", __func__ , i, pcm_get_error(out->pcm[i]));
+ pcm_close(out->pcm[i]);
+ out->pcm[i] = NULL;
+ success = false;
+ }
+ }
+
+ if (success) {
+ out->buffer_frames = pcm_config_tones.period_size * 2;
+ if (out->buffer == NULL)
+ out->buffer = malloc(out->buffer_frames * audio_stream_frame_size(&out->stream.common));
+
+ if (adev->echo_reference != NULL)
+ out->echo_reference = adev->echo_reference;
+ out->resampler->reset(out->resampler);
+
+ return 0;
+ }
+
+ return -ENOMEM;
+}
+
+/* must be called with hw device and output stream mutexes locked */
+static int start_output_stream_deep_buffer(struct m0_stream_out *out)
+{
+ struct m0_audio_device *adev = out->dev;
+
+ if (adev->mode != AUDIO_MODE_IN_CALL) {
+ select_output_device(adev);
+ }
+
+ out->write_threshold = PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT * DEEP_BUFFER_LONG_PERIOD_SIZE;
+ out->use_long_periods = true;
+
+ out->config[PCM_NORMAL] = pcm_config_mm;
+ out->config[PCM_NORMAL].rate = MM_FULL_POWER_SAMPLING_RATE;
+ out->pcm[PCM_NORMAL] = pcm_open(CARD_DEFAULT, PORT_PLAYBACK,
+ PCM_OUT | PCM_MMAP | PCM_NOIRQ, &out->config[PCM_NORMAL]);
+ if (out->pcm[PCM_NORMAL] && !pcm_is_ready(out->pcm[PCM_NORMAL])) {
+ ALOGE("%s: cannot open pcm_out driver: %s", __func__, pcm_get_error(out->pcm[PCM_NORMAL]));
+ pcm_close(out->pcm[PCM_NORMAL]);
+ out->pcm[PCM_NORMAL] = NULL;
+ return -ENOMEM;
+ }
+ out->buffer_frames = DEEP_BUFFER_SHORT_PERIOD_SIZE * 2;
+ if (out->buffer == NULL)
+ out->buffer = malloc(PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT * DEEP_BUFFER_LONG_PERIOD_SIZE);
+
+ return 0;
+}
+
+static int check_input_parameters(uint32_t sample_rate, audio_format_t format, int channel_count)
+{
+ if (format != AUDIO_FORMAT_PCM_16_BIT)
+ return -EINVAL;
+
+ if ((channel_count < 1) || (channel_count > 2))
+ return -EINVAL;
+
+ switch(sample_rate) {
+ case 8000:
+ case 11025:
+ case 16000:
+ case 22050:
+ case 24000:
+ case 32000:
+ case 44100:
+ case 48000:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static size_t get_input_buffer_size(uint32_t sample_rate, audio_format_t format, int channel_count)
+{
+ size_t size;
+ size_t device_rate;
+
+ if (check_input_parameters(sample_rate, format, channel_count) != 0)
+ return 0;
+
+ /* take resampling into account and return the closest majoring
+ multiple of 16 frames, as audioflinger expects audio buffers to
+ be a multiple of 16 frames */
+ size = (pcm_config_capture.period_size * sample_rate) / pcm_config_capture.rate;
+ size = ((size + 15) / 16) * 16;
+
+ return size * channel_count * sizeof(short);
+}
+
+static void add_echo_reference(struct m0_stream_out *out,
+ struct echo_reference_itfe *reference)
+{
+ pthread_mutex_lock(&out->lock);
+ out->echo_reference = reference;
+ pthread_mutex_unlock(&out->lock);
+}
+
+static void remove_echo_reference(struct m0_stream_out *out,
+ struct echo_reference_itfe *reference)
+{
+ pthread_mutex_lock(&out->lock);
+ if (out->echo_reference == reference) {
+ /* stop writing to echo reference */
+ reference->write(reference, NULL);
+ out->echo_reference = NULL;
+ }
+ pthread_mutex_unlock(&out->lock);
+}
+
+static void put_echo_reference(struct m0_audio_device *adev,
+ struct echo_reference_itfe *reference)
+{
+ if (adev->echo_reference != NULL &&
+ reference == adev->echo_reference) {
+ /* echo reference is taken from the low latency output stream used
+ * for voice use cases */
+ if (adev->outputs[OUTPUT_LOW_LATENCY] != NULL &&
+ !adev->outputs[OUTPUT_LOW_LATENCY]->standby)
+ remove_echo_reference(adev->outputs[OUTPUT_LOW_LATENCY], reference);
+ release_echo_reference(reference);
+ adev->echo_reference = NULL;
+ }
+}
+
+static struct echo_reference_itfe *get_echo_reference(struct m0_audio_device *adev,
+ audio_format_t format,
+ uint32_t channel_count,
+ uint32_t sampling_rate)
+{
+ put_echo_reference(adev, adev->echo_reference);
+ /* echo reference is taken from the low latency output stream used
+ * for voice use cases */
+ if (adev->outputs[OUTPUT_LOW_LATENCY] != NULL &&
+ !adev->outputs[OUTPUT_LOW_LATENCY]->standby) {
+ struct audio_stream *stream =
+ &adev->outputs[OUTPUT_LOW_LATENCY]->stream.common;
+ uint32_t wr_channel_count = popcount(stream->get_channels(stream));
+ uint32_t wr_sampling_rate = stream->get_sample_rate(stream);
+
+ int status = create_echo_reference(AUDIO_FORMAT_PCM_16_BIT,
+ channel_count,
+ sampling_rate,
+ AUDIO_FORMAT_PCM_16_BIT,
+ wr_channel_count,
+ wr_sampling_rate,
+ &adev->echo_reference);
+ if (status == 0)
+ add_echo_reference(adev->outputs[OUTPUT_LOW_LATENCY],
+ adev->echo_reference);
+ }
+ return adev->echo_reference;
+}
+
+static int get_playback_delay(struct m0_stream_out *out,
+ size_t frames,
+ struct echo_reference_buffer *buffer)
+{
+ size_t kernel_frames;
+ int status;
+ int primary_pcm = 0;
+
+ /* Find the first active PCM to act as primary */
+ while ((primary_pcm < PCM_TOTAL) && !out->pcm[primary_pcm])
+ primary_pcm++;
+
+ status = pcm_get_htimestamp(out->pcm[primary_pcm], &kernel_frames, &buffer->time_stamp);
+ if (status < 0) {
+ buffer->time_stamp.tv_sec = 0;
+ buffer->time_stamp.tv_nsec = 0;
+ buffer->delay_ns = 0;
+ ALOGV("%s: pcm_get_htimestamp error,"
+ "setting playbackTimestamp to 0", __func__);
+ return status;
+ }
+
+ kernel_frames = pcm_get_buffer_size(out->pcm[primary_pcm]) - kernel_frames;
+
+ /* adjust render time stamp with delay added by current driver buffer.
+ * Add the duration of current frame as we want the render time of the last
+ * sample being written. */
+ buffer->delay_ns = (long)(((int64_t)(kernel_frames + frames)* 1000000000)/
+ MM_FULL_POWER_SAMPLING_RATE);
+
+ return 0;
+}
+
+static uint32_t out_get_sample_rate(const struct audio_stream *stream)
+{
+ return DEFAULT_OUT_SAMPLING_RATE;
+}
+
+static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+{
+ return 0;
+}
+
+static size_t out_get_buffer_size_low_latency(const struct audio_stream *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ /* take resampling into account and return the closest majoring
+ multiple of 16 frames, as audioflinger expects audio buffers to
+ be a multiple of 16 frames. Note: we use the default rate here
+ from pcm_config_tones.rate. */
+ size_t size = (SHORT_PERIOD_SIZE * DEFAULT_OUT_SAMPLING_RATE) / pcm_config_tones.rate;
+ size = ((size + 15) / 16) * 16;
+ return size * audio_stream_frame_size((struct audio_stream *)stream);
+}
+
+static size_t out_get_buffer_size_deep_buffer(const struct audio_stream *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ /* take resampling into account and return the closest majoring
+ multiple of 16 frames, as audioflinger expects audio buffers to
+ be a multiple of 16 frames. Note: we use the default rate here
+ from pcm_config_mm.rate. */
+ size_t size = (DEEP_BUFFER_SHORT_PERIOD_SIZE * DEFAULT_OUT_SAMPLING_RATE) /
+ pcm_config_mm.rate;
+ size = ((size + 15) / 16) * 16;
+ return size * audio_stream_frame_size((struct audio_stream *)stream);
+}
+
+static audio_channel_mask_t out_get_channels(const struct audio_stream *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ return out->channel_mask;
+}
+
+static audio_format_t out_get_format(const struct audio_stream *stream)
+{
+ return AUDIO_FORMAT_PCM_16_BIT;
+}
+
+static int out_set_format(struct audio_stream *stream, audio_format_t format)
+{
+ return 0;
+}
+
+/* must be called with hw device and output stream mutexes locked */
+static int do_output_standby(struct m0_stream_out *out)
+{
+ struct m0_audio_device *adev = out->dev;
+ int i;
+ bool all_outputs_in_standby = true;
+
+ if (!out->standby) {
+ out->standby = 1;
+
+ for (i = 0; i < PCM_TOTAL; i++) {
+ if (out->pcm[i]) {
+ pcm_close(out->pcm[i]);
+ out->pcm[i] = NULL;
+ }
+ }
+
+ for (i = 0; i < OUTPUT_TOTAL; i++) {
+ if (adev->outputs[i] != NULL && !adev->outputs[i]->standby) {
+ all_outputs_in_standby = false;
+ break;
+ }
+ }
+
+ /* force standby on low latency output stream so that it can reuse HDMI driver if
+ * necessary when restarted */
+ if (out == adev->outputs[OUTPUT_HDMI]) {
+ if (adev->outputs[OUTPUT_LOW_LATENCY] != NULL &&
+ !adev->outputs[OUTPUT_LOW_LATENCY]->standby) {
+ struct m0_stream_out *ll_out = adev->outputs[OUTPUT_LOW_LATENCY];
+ pthread_mutex_lock(&ll_out->lock);
+ do_output_standby(ll_out);
+ pthread_mutex_unlock(&ll_out->lock);
+ }
+ }
+
+ /* stop writing to echo reference */
+ if (out->echo_reference != NULL) {
+ out->echo_reference->write(out->echo_reference, NULL);
+ out->echo_reference = NULL;
+ }
+ }
+ return 0;
+}
+
+static int out_standby(struct audio_stream *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+ int status;
+
+ pthread_mutex_lock(&out->dev->lock);
+ pthread_mutex_lock(&out->lock);
+ status = do_output_standby(out);
+ pthread_mutex_unlock(&out->lock);
+ pthread_mutex_unlock(&out->dev->lock);
+ return status;
+}
+
+static int out_dump(const struct audio_stream *stream, int fd)
+{
+ return 0;
+}
+
+static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+ struct m0_audio_device *adev = out->dev;
+ struct m0_stream_in *in;
+ struct str_parms *parms;
+ char *str;
+ char value[32];
+ int ret, val = 0;
+ bool force_input_standby = false;
+
+ parms = str_parms_create_str(kvpairs);
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value);
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&out->lock);
+ if (((adev->out_device) != val) && (val != 0)) {
+ /* this is needed only when changing device on low latency output
+ * as other output streams are not used for voice use cases nor
+ * handle duplication to HDMI or SPDIF */
+ if (out == adev->outputs[OUTPUT_LOW_LATENCY] && !out->standby) {
+ /* a change in output device may change the microphone selection */
+ if (adev->active_input &&
+ adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+ force_input_standby = true;
+ }
+ /* force standby if moving to/from HDMI/SPDIF or if the output
+ * device changes when in HDMI/SPDIF mode */
+ /* FIXME also force standby when in call as some audio path switches do not work
+ * while in call and an output stream is active (e.g BT SCO => earpiece) */
+
+ /* FIXME workaround for audio being dropped when switching path without forcing standby
+ * (several hundred ms of audio can be lost: e.g beginning of a ringtone. We must understand
+ * the root cause in audio HAL, driver or ABE.
+ if (((val & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
+ (adev->out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) ||
+ ((val & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) ^
+ (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
+ (adev->out_device & (AUDIO_DEVICE_OUT_AUX_DIGITAL |
+ AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)))
+ */
+ if (((val & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
+ (adev->out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) ||
+ ((val & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) ^
+ (adev->out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
+ (adev->out_device & (AUDIO_DEVICE_OUT_AUX_DIGITAL |
+ AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) ||
+ ((val & AUDIO_DEVICE_OUT_SPEAKER) ^
+ (adev->out_device & AUDIO_DEVICE_OUT_SPEAKER)) ||
+ (adev->mode == AUDIO_MODE_IN_CALL))
+ do_output_standby(out);
+ }
+ if (out != adev->outputs[OUTPUT_HDMI]) {
+ adev->out_device = val;
+ select_output_device(adev);
+ }
+ }
+ pthread_mutex_unlock(&out->lock);
+ if (force_input_standby) {
+ in = adev->active_input;
+ pthread_mutex_lock(&in->lock);
+ do_input_standby(in);
+ pthread_mutex_unlock(&in->lock);
+ }
+ pthread_mutex_unlock(&adev->lock);
+ }
+
+ str_parms_destroy(parms);
+ return ret;
+}
+
+static char * out_get_parameters(const struct audio_stream *stream, const char *keys)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ struct str_parms *query = str_parms_create_str(keys);
+ char *str;
+ char value[256];
+ struct str_parms *reply = str_parms_create();
+ size_t i, j;
+ int ret;
+ bool first = true;
+
+ ret = str_parms_get_str(query, AUDIO_PARAMETER_STREAM_SUP_CHANNELS, value, sizeof(value));
+ if (ret >= 0) {
+ value[0] = '\0';
+ i = 0;
+ while (out->sup_channel_masks[i] != 0) {
+ for (j = 0; j < ARRAY_SIZE(out_channels_name_to_enum_table); j++) {
+ if (out_channels_name_to_enum_table[j].value == out->sup_channel_masks[i]) {
+ if (!first) {
+ strcat(value, "|");
+ }
+ strcat(value, out_channels_name_to_enum_table[j].name);
+ first = false;
+ break;
+ }
+ }
+ i++;
+ }
+ str_parms_add_str(reply, AUDIO_PARAMETER_STREAM_SUP_CHANNELS, value);
+ str = strdup(str_parms_to_str(reply));
+ } else {
+ str = strdup(keys);
+ }
+ str_parms_destroy(query);
+ str_parms_destroy(reply);
+ return str;
+}
+
+static uint32_t out_get_latency_low_latency(const struct audio_stream_out *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ /* Note: we use the default rate here from pcm_config_mm.rate */
+ return (SHORT_PERIOD_SIZE * PLAYBACK_SHORT_PERIOD_COUNT * 1000) / pcm_config_tones.rate;
+}
+
+static uint32_t out_get_latency_deep_buffer(const struct audio_stream_out *stream)
+{
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+
+ /* Note: we use the default rate here from pcm_config_mm.rate */
+ return (DEEP_BUFFER_LONG_PERIOD_SIZE * PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT * 1000) /
+ pcm_config_mm.rate;
+}
+
+static int out_set_volume(struct audio_stream_out *stream, float left,
+ float right)
+{
+ return -ENOSYS;
+}
+
+static ssize_t out_write_low_latency(struct audio_stream_out *stream, const void* buffer,
+ size_t bytes)
+{
+ int ret;
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+ struct m0_audio_device *adev = out->dev;
+ size_t frame_size = audio_stream_frame_size(&out->stream.common);
+ size_t in_frames = bytes / frame_size;
+ size_t out_frames = in_frames;
+ bool force_input_standby = false;
+ struct m0_stream_in *in;
+ int i;
+
+ /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
+ * on the output stream mutex - e.g. executing select_mode() while holding the hw device
+ * mutex
+ */
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&out->lock);
+ if (out->standby) {
+ ret = start_output_stream_low_latency(out);
+ if (ret != 0) {
+ pthread_mutex_unlock(&adev->lock);
+ goto exit;
+ }
+ out->standby = 0;
+ /* a change in output device may change the microphone selection */
+ if (adev->active_input &&
+ adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION)
+ force_input_standby = true;
+ }
+ pthread_mutex_unlock(&adev->lock);
+
+ for (i = 0; i < PCM_TOTAL; i++) {
+ /* only use resampler if required */
+ if (out->pcm[i] && (out->config[i].rate != DEFAULT_OUT_SAMPLING_RATE)) {
+ out_frames = out->buffer_frames;
+ out->resampler->resample_from_input(out->resampler,
+ (int16_t *)buffer,
+ &in_frames,
+ (int16_t *)out->buffer,
+ &out_frames);
+ break;
+ }
+ }
+
+ if (out->echo_reference != NULL) {
+ struct echo_reference_buffer b;
+ b.raw = (void *)buffer;
+ b.frame_count = in_frames;
+
+ get_playback_delay(out, out_frames, &b);
+ out->echo_reference->write(out->echo_reference, &b);
+ }
+
+ /* Write to all active PCMs */
+ for (i = 0; i < PCM_TOTAL; i++) {
+ if (out->pcm[i]) {
+ if (out->config[i].rate == DEFAULT_OUT_SAMPLING_RATE) {
+ /* PCM uses native sample rate */
+ ret = PCM_WRITE(out->pcm[i], (void *)buffer, bytes);
+ } else {
+ /* PCM needs resampler */
+ ret = PCM_WRITE(out->pcm[i], (void *)out->buffer, out_frames * frame_size);
+ }
+ if (ret)
+ break;
+ }
+ }
+
+exit:
+ pthread_mutex_unlock(&out->lock);
+
+ if (ret != 0) {
+ usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
+ out_get_sample_rate(&stream->common));
+ }
+
+ if (force_input_standby) {
+ pthread_mutex_lock(&adev->lock);
+ if (adev->active_input) {
+ in = adev->active_input;
+ pthread_mutex_lock(&in->lock);
+ do_input_standby(in);
+ pthread_mutex_unlock(&in->lock);
+ }
+ pthread_mutex_unlock(&adev->lock);
+ }
+
+ return bytes;
+}
+
+static ssize_t out_write_deep_buffer(struct audio_stream_out *stream, const void* buffer,
+ size_t bytes)
+{
+ int ret;
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+ struct m0_audio_device *adev = out->dev;
+ size_t frame_size = audio_stream_frame_size(&out->stream.common);
+ size_t in_frames = bytes / frame_size;
+ size_t out_frames;
+ bool use_long_periods;
+ int kernel_frames;
+ void *buf;
+
+ /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
+ * on the output stream mutex - e.g. executing select_mode() while holding the hw device
+ * mutex
+ */
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&out->lock);
+ if (out->standby) {
+ ret = start_output_stream_deep_buffer(out);
+ if (ret != 0) {
+ pthread_mutex_unlock(&adev->lock);
+ goto exit;
+ }
+ out->standby = 0;
+ }
+ use_long_periods = adev->screen_off && !adev->active_input;
+ pthread_mutex_unlock(&adev->lock);
+
+ if (use_long_periods != out->use_long_periods) {
+ size_t period_size;
+ size_t period_count;
+
+ if (use_long_periods) {
+ period_size = DEEP_BUFFER_LONG_PERIOD_SIZE;
+ period_count = PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT;
+ } else {
+ period_size = DEEP_BUFFER_SHORT_PERIOD_SIZE;
+ period_count = PLAYBACK_DEEP_BUFFER_SHORT_PERIOD_COUNT;
+ }
+ out->write_threshold = period_size * period_count;
+ pcm_set_avail_min(out->pcm[PCM_NORMAL], period_size);
+ out->use_long_periods = use_long_periods;
+ }
+
+ /* only use resampler if required */
+ if (out->config[PCM_NORMAL].rate != DEFAULT_OUT_SAMPLING_RATE) {
+ out_frames = out->buffer_frames;
+ out->resampler->resample_from_input(out->resampler,
+ (int16_t *)buffer,
+ &in_frames,
+ (int16_t *)out->buffer,
+ &out_frames);
+ buf = (void *)out->buffer;
+ } else {
+ out_frames = in_frames;
+ buf = (void *)buffer;
+ }
+
+ /* do not allow more than out->write_threshold frames in kernel pcm driver buffer */
+ do {
+ struct timespec time_stamp;
+
+ if (pcm_get_htimestamp(out->pcm[PCM_NORMAL],
+ (unsigned int *)&kernel_frames, &time_stamp) < 0)
+ break;
+ kernel_frames = pcm_get_buffer_size(out->pcm[PCM_NORMAL]) - kernel_frames;
+
+ if (kernel_frames > out->write_threshold) {
+ unsigned long time = (unsigned long)
+ (((int64_t)(kernel_frames - out->write_threshold) * 1000000) /
+ MM_FULL_POWER_SAMPLING_RATE);
+ if (time < MIN_WRITE_SLEEP_US)
+ time = MIN_WRITE_SLEEP_US;
+ usleep(time);
+ }
+ } while (kernel_frames > out->write_threshold);
+
+ ret = pcm_mmap_write(out->pcm[PCM_NORMAL], buf, out_frames * frame_size);
+
+exit:
+ pthread_mutex_unlock(&out->lock);
+
+ if (ret != 0) {
+ usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
+ out_get_sample_rate(&stream->common));
+ }
+
+ return bytes;
+}
+
+static int out_get_render_position(const struct audio_stream_out *stream,
+ uint32_t *dsp_frames)
+{
+ return -EINVAL;
+}
+
+static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ return 0;
+}
+
+static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
+{
+ return 0;
+}
+
+/** audio_stream_in implementation **/
+
+/* must be called with hw device and input stream mutexes locked */
+static int start_input_stream(struct m0_stream_in *in)
+{
+ int ret = 0;
+ struct m0_audio_device *adev = in->dev;
+
+ adev->active_input = in;
+
+ if (adev->mode != AUDIO_MODE_IN_CALL) {
+ adev->in_device = in->device;
+ select_input_device(adev);
+ }
+
+ if (in->aux_channels_changed)
+ {
+ in->aux_channels_changed = false;
+ in->config.channels = popcount(in->main_channels | in->aux_channels);
+
+ if (in->resampler) {
+ /* release and recreate the resampler with the new number of channel of the input */
+ release_resampler(in->resampler);
+ in->resampler = NULL;
+ ret = create_resampler(in->config.rate,
+ in->requested_rate,
+ in->config.channels,
+ RESAMPLER_QUALITY_DEFAULT,
+ &in->buf_provider,
+ &in->resampler);
+ }
+ ALOGV("%s: New channel configuration, "
+ "main_channels = [%04x], aux_channels = [%04x], config.channels = %d",
+ __func__, in->main_channels, in->aux_channels, in->config.channels);
+ }
+
+ if (in->need_echo_reference && in->echo_reference == NULL)
+ in->echo_reference = get_echo_reference(adev,
+ AUDIO_FORMAT_PCM_16_BIT,
+ popcount(in->main_channels),
+ in->requested_rate);
+
+ /* this assumes routing is done previously */
+ in->pcm = pcm_open(CARD_DEFAULT, PORT_CAPTURE, PCM_IN, &in->config);
+ if (!pcm_is_ready(in->pcm)) {
+ ALOGE("cannot open pcm_in driver: %s", pcm_get_error(in->pcm));
+ pcm_close(in->pcm);
+ adev->active_input = NULL;
+ return -ENOMEM;
+ }
+
+ /* force read and proc buf reallocation case of frame size or channel count change */
+ in->read_buf_frames = 0;
+ in->read_buf_size = 0;
+ in->proc_buf_frames = 0;
+ in->proc_buf_size = 0;
+ /* if no supported sample rate is available, use the resampler */
+ if (in->resampler) {
+ in->resampler->reset(in->resampler);
+ }
+ return 0;
+}
+
+static uint32_t in_get_sample_rate(const struct audio_stream *stream)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+
+ return in->requested_rate;
+}
+
+static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
+{
+ return 0;
+}
+
+static size_t in_get_buffer_size(const struct audio_stream *stream)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+
+ return get_input_buffer_size(in->requested_rate,
+ AUDIO_FORMAT_PCM_16_BIT,
+ popcount(in->main_channels));
+}
+
+static audio_channel_mask_t in_get_channels(const struct audio_stream *stream)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+
+ return in->main_channels;
+}
+
+static audio_format_t in_get_format(const struct audio_stream *stream)
+{
+ return AUDIO_FORMAT_PCM_16_BIT;
+}
+
+static int in_set_format(struct audio_stream *stream, audio_format_t format)
+{
+ return 0;
+}
+
+/* must be called with hw device and input stream mutexes locked */
+static int do_input_standby(struct m0_stream_in *in)
+{
+ struct m0_audio_device *adev = in->dev;
+
+ if (!in->standby) {
+ pcm_close(in->pcm);
+ in->pcm = NULL;
+
+ adev->active_input = 0;
+ if (adev->mode != AUDIO_MODE_IN_CALL) {
+ adev->in_device = AUDIO_DEVICE_NONE;
+ select_input_device(adev);
+ }
+
+ if (in->echo_reference != NULL) {
+ /* stop reading from echo reference */
+ in->echo_reference->read(in->echo_reference, NULL);
+ put_echo_reference(adev, in->echo_reference);
+ in->echo_reference = NULL;
+ }
+
+ in->standby = 1;
+ }
+ return 0;
+}
+
+static int in_standby(struct audio_stream *stream)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ int status;
+
+ pthread_mutex_lock(&in->dev->lock);
+ pthread_mutex_lock(&in->lock);
+ status = do_input_standby(in);
+ pthread_mutex_unlock(&in->lock);
+ pthread_mutex_unlock(&in->dev->lock);
+ return status;
+}
+
+static int in_dump(const struct audio_stream *stream, int fd)
+{
+ return 0;
+}
+
+static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ struct m0_audio_device *adev = in->dev;
+ struct str_parms *parms;
+ char *str;
+ char value[32];
+ int ret, val = 0;
+ bool do_standby = false;
+
+ parms = str_parms_create_str(kvpairs);
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_INPUT_SOURCE, value, sizeof(value));
+
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&in->lock);
+ if (ret >= 0) {
+ val = atoi(value);
+ /* no audio source uses val == 0 */
+ if ((in->source != val) && (val != 0)) {
+ in->source = val;
+ do_standby = true;
+ }
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
+ if (ret >= 0) {
+ val = atoi(value) & ~AUDIO_DEVICE_BIT_IN;
+ if ((in->device != val) && (val != 0)) {
+ in->device = val;
+ do_standby = true;
+ /* make sure new device selection is incompatible with multi-mic pre processing
+ * configuration */
+ in_update_aux_channels(in, NULL);
+ }
+ }
+
+ if (do_standby)
+ do_input_standby(in);
+ pthread_mutex_unlock(&in->lock);
+ pthread_mutex_unlock(&adev->lock);
+
+ str_parms_destroy(parms);
+ return ret;
+}
+
+static char * in_get_parameters(const struct audio_stream *stream,
+ const char *keys)
+{
+ return strdup("");
+}
+
+static int in_set_gain(struct audio_stream_in *stream, float gain)
+{
+ return 0;
+}
+
+static void get_capture_delay(struct m0_stream_in *in,
+ size_t frames,
+ struct echo_reference_buffer *buffer)
+{
+
+ /* read frames available in kernel driver buffer */
+ size_t kernel_frames;
+ struct timespec tstamp;
+ long buf_delay;
+ long rsmp_delay;
+ long kernel_delay;
+ long delay_ns;
+
+ if (pcm_get_htimestamp(in->pcm, &kernel_frames, &tstamp) < 0) {
+ buffer->time_stamp.tv_sec = 0;
+ buffer->time_stamp.tv_nsec = 0;
+ buffer->delay_ns = 0;
+ ALOGW("%s: pcm_htimestamp error", __func__);
+ return;
+ }
+
+ /* read frames available in audio HAL input buffer
+ * add number of frames being read as we want the capture time of first sample
+ * in current buffer */
+ /* frames in in->buffer are at driver sampling rate while frames in in->proc_buf are
+ * at requested sampling rate */
+ buf_delay = (long)(((int64_t)(in->read_buf_frames) * 1000000000) / in->config.rate +
+ ((int64_t)(in->proc_buf_frames) * 1000000000) /
+ in->requested_rate);
+
+ /* add delay introduced by resampler */
+ rsmp_delay = 0;
+ if (in->resampler) {
+ rsmp_delay = in->resampler->delay_ns(in->resampler);
+ }
+
+ kernel_delay = (long)(((int64_t)kernel_frames * 1000000000) / in->config.rate);
+
+ delay_ns = kernel_delay + buf_delay + rsmp_delay;
+
+ buffer->time_stamp = tstamp;
+ buffer->delay_ns = delay_ns;
+ ALOGV("%s: time_stamp = [%ld].[%ld], delay_ns: [%d],"
+ " kernel_delay:[%ld], buf_delay:[%ld], rsmp_delay:[%ld], kernel_frames:[%d], "
+ "in->read_buf_frames:[%d], in->proc_buf_frames:[%d], frames:[%d]",
+ __func__, buffer->time_stamp.tv_sec , buffer->time_stamp.tv_nsec, buffer->delay_ns,
+ kernel_delay, buf_delay, rsmp_delay, kernel_frames,
+ in->read_buf_frames, in->proc_buf_frames, frames);
+
+}
+
+static int32_t update_echo_reference(struct m0_stream_in *in, size_t frames)
+{
+ struct echo_reference_buffer b;
+ b.delay_ns = 0;
+
+ ALOGV("%s: frames = [%d], in->ref_frames_in = [%d], "
+ "b.frame_count = [%d]",
+ __func__, frames, in->ref_buf_frames, frames - in->ref_buf_frames);
+ if (in->ref_buf_frames < frames) {
+ if (in->ref_buf_size < frames) {
+ in->ref_buf_size = frames;
+ in->ref_buf = (int16_t *)realloc(in->ref_buf, pcm_frames_to_bytes(in->pcm, frames));
+ ALOG_ASSERT((in->ref_buf != NULL),
+ "%s failed to reallocate ref_buf", __func__);
+ ALOGV("%s: ref_buf %p extended to %d bytes",
+ __func__, in->ref_buf, pcm_frames_to_bytes(in->pcm, frames));
+ }
+ b.frame_count = frames - in->ref_buf_frames;
+ b.raw = (void *)(in->ref_buf + in->ref_buf_frames * in->config.channels);
+
+ get_capture_delay(in, frames, &b);
+
+ if (in->echo_reference->read(in->echo_reference, &b) == 0)
+ {
+ in->ref_buf_frames += b.frame_count;
+ ALOGD("%s: in->ref_buf_frames:[%d], "
+ "in->ref_buf_size:[%d], frames:[%d], b.frame_count:[%d]",
+ __func__, in->ref_buf_frames, in->ref_buf_size, frames, b.frame_count);
+ }
+ } else
+ ALOGW("%s: NOT enough frames to read ref buffer", __func__);
+ return b.delay_ns;
+}
+
+static int set_preprocessor_param(effect_handle_t handle,
+ effect_param_t *param)
+{
+ uint32_t size = sizeof(int);
+ uint32_t psize = ((param->psize - 1) / sizeof(int) + 1) * sizeof(int) +
+ param->vsize;
+
+ int status = (*handle)->command(handle,
+ EFFECT_CMD_SET_PARAM,
+ sizeof (effect_param_t) + psize,
+ param,
+ &size,
+ &param->status);
+ if (status == 0)
+ status = param->status;
+
+ return status;
+}
+
+static int set_preprocessor_echo_delay(effect_handle_t handle,
+ int32_t delay_us)
+{
+ uint32_t buf[sizeof(effect_param_t) / sizeof(uint32_t) + 2];
+ effect_param_t *param = (effect_param_t *)buf;
+
+ param->psize = sizeof(uint32_t);
+ param->vsize = sizeof(uint32_t);
+ *(uint32_t *)param->data = AEC_PARAM_ECHO_DELAY;
+ *((int32_t *)param->data + 1) = delay_us;
+
+ return set_preprocessor_param(handle, param);
+}
+
+static void push_echo_reference(struct m0_stream_in *in, size_t frames)
+{
+ /* read frames from echo reference buffer and update echo delay
+ * in->ref_buf_frames is updated with frames available in in->ref_buf */
+ int32_t delay_us = update_echo_reference(in, frames)/1000;
+ int i;
+ audio_buffer_t buf;
+
+ if (in->ref_buf_frames < frames)
+ frames = in->ref_buf_frames;
+
+ buf.frameCount = frames;
+ buf.raw = in->ref_buf;
+
+ for (i = 0; i < in->num_preprocessors; i++) {
+ if ((*in->preprocessors[i].effect_itfe)->process_reverse == NULL)
+ continue;
+
+ (*in->preprocessors[i].effect_itfe)->process_reverse(in->preprocessors[i].effect_itfe,
+ &buf,
+ NULL);
+ set_preprocessor_echo_delay(in->preprocessors[i].effect_itfe, delay_us);
+ }
+
+ in->ref_buf_frames -= buf.frameCount;
+ if (in->ref_buf_frames) {
+ memcpy(in->ref_buf,
+ in->ref_buf + buf.frameCount * in->config.channels,
+ in->ref_buf_frames * in->config.channels * sizeof(int16_t));
+ }
+}
+
+static int get_next_buffer(struct resampler_buffer_provider *buffer_provider,
+ struct resampler_buffer* buffer)
+{
+ struct m0_stream_in *in;
+
+ if (buffer_provider == NULL || buffer == NULL)
+ return -EINVAL;
+
+ in = (struct m0_stream_in *)((char *)buffer_provider -
+ offsetof(struct m0_stream_in, buf_provider));
+
+ if (in->pcm == NULL) {
+ buffer->raw = NULL;
+ buffer->frame_count = 0;
+ in->read_status = -ENODEV;
+ return -ENODEV;
+ }
+
+ if (in->read_buf_frames == 0) {
+ size_t size_in_bytes = pcm_frames_to_bytes(in->pcm, in->config.period_size);
+ if (in->read_buf_size < in->config.period_size) {
+ in->read_buf_size = in->config.period_size;
+ in->read_buf = (int16_t *) realloc(in->read_buf, size_in_bytes);
+ ALOG_ASSERT((in->read_buf != NULL),
+ "%s failed to reallocate read_buf", __func__);
+ ALOGV("%s: read_buf %p extended to %d bytes",
+ __func__, in->read_buf, size_in_bytes);
+ }
+
+ in->read_status = pcm_read(in->pcm, (void*)in->read_buf, size_in_bytes);
+
+ if (in->read_status != 0) {
+ ALOGE("%s: pcm_read error %d", __func__, in->read_status);
+ buffer->raw = NULL;
+ buffer->frame_count = 0;
+ return in->read_status;
+ }
+ in->read_buf_frames = in->config.period_size;
+ }
+
+ buffer->frame_count = (buffer->frame_count > in->read_buf_frames) ?
+ in->read_buf_frames : buffer->frame_count;
+ buffer->i16 = in->read_buf + (in->config.period_size - in->read_buf_frames) *
+ in->config.channels;
+
+ return in->read_status;
+
+}
+
+static void release_buffer(struct resampler_buffer_provider *buffer_provider,
+ struct resampler_buffer* buffer)
+{
+ struct m0_stream_in *in;
+
+ if (buffer_provider == NULL || buffer == NULL)
+ return;
+
+ in = (struct m0_stream_in *)((char *)buffer_provider -
+ offsetof(struct m0_stream_in, buf_provider));
+
+ in->read_buf_frames -= buffer->frame_count;
+}
+
+/* read_frames() reads frames from kernel driver, down samples to capture rate
+ * if necessary and output the number of frames requested to the buffer specified */
+static ssize_t read_frames(struct m0_stream_in *in, void *buffer, ssize_t frames)
+{
+ ssize_t frames_wr = 0;
+
+ while (frames_wr < frames) {
+ size_t frames_rd = frames - frames_wr;
+ if (in->resampler != NULL) {
+ in->resampler->resample_from_provider(in->resampler,
+ (int16_t *)((char *)buffer +
+ pcm_frames_to_bytes(in->pcm ,frames_wr)),
+ &frames_rd);
+
+ } else {
+ struct resampler_buffer buf = {
+ { raw : NULL, },
+ frame_count : frames_rd,
+ };
+ get_next_buffer(&in->buf_provider, &buf);
+ if (buf.raw != NULL) {
+ memcpy((char *)buffer +
+ pcm_frames_to_bytes(in->pcm, frames_wr),
+ buf.raw,
+ pcm_frames_to_bytes(in->pcm, buf.frame_count));
+ frames_rd = buf.frame_count;
+ }
+ release_buffer(&in->buf_provider, &buf);
+ }
+ /* in->read_status is updated by getNextBuffer() also called by
+ * in->resampler->resample_from_provider() */
+ if (in->read_status != 0)
+ return in->read_status;
+
+ frames_wr += frames_rd;
+ }
+ return frames_wr;
+}
+
+/* process_frames() reads frames from kernel driver (via read_frames()),
+ * calls the active audio pre processings and output the number of frames requested
+ * to the buffer specified */
+static ssize_t process_frames(struct m0_stream_in *in, void* buffer, ssize_t frames)
+{
+ ssize_t frames_wr = 0;
+ audio_buffer_t in_buf;
+ audio_buffer_t out_buf;
+ int i;
+ bool has_aux_channels = (~in->main_channels & in->aux_channels);
+ void *proc_buf_out;
+
+ if (has_aux_channels)
+ proc_buf_out = in->proc_buf_out;
+ else
+ proc_buf_out = buffer;
+
+ /* since all the processing below is done in frames and using the config.channels
+ * as the number of channels, no changes is required in case aux_channels are present */
+ while (frames_wr < frames) {
+ /* first reload enough frames at the end of process input buffer */
+ if (in->proc_buf_frames < (size_t)frames) {
+ ssize_t frames_rd;
+
+ if (in->proc_buf_size < (size_t)frames) {
+ size_t size_in_bytes = pcm_frames_to_bytes(in->pcm, frames);
+
+ in->proc_buf_size = (size_t)frames;
+ in->proc_buf_in = (int16_t *)realloc(in->proc_buf_in, size_in_bytes);
+ ALOG_ASSERT((in->proc_buf_in != NULL),
+ "%s failed to reallocate proc_buf_in", __func__);
+ if (has_aux_channels) {
+ in->proc_buf_out = (int16_t *)realloc(in->proc_buf_out, size_in_bytes);
+ ALOG_ASSERT((in->proc_buf_out != NULL),
+ "%s failed to reallocate proc_buf_out", __func__);
+ proc_buf_out = in->proc_buf_out;
+ }
+ ALOGV("process_frames(): proc_buf_in %p extended to %d bytes",
+ in->proc_buf_in, size_in_bytes);
+ }
+ frames_rd = read_frames(in,
+ in->proc_buf_in +
+ in->proc_buf_frames * in->config.channels,
+ frames - in->proc_buf_frames);
+ if (frames_rd < 0) {
+ frames_wr = frames_rd;
+ break;
+ }
+ in->proc_buf_frames += frames_rd;
+ }
+
+ if (in->echo_reference != NULL)
+ push_echo_reference(in, in->proc_buf_frames);
+
+ /* in_buf.frameCount and out_buf.frameCount indicate respectively
+ * the maximum number of frames to be consumed and produced by process() */
+ in_buf.frameCount = in->proc_buf_frames;
+ in_buf.s16 = in->proc_buf_in;
+ out_buf.frameCount = frames - frames_wr;
+ out_buf.s16 = (int16_t *)proc_buf_out + frames_wr * in->config.channels;
+
+ /* FIXME: this works because of current pre processing library implementation that
+ * does the actual process only when the last enabled effect process is called.
+ * The generic solution is to have an output buffer for each effect and pass it as
+ * input to the next.
+ */
+ for (i = 0; i < in->num_preprocessors; i++) {
+ (*in->preprocessors[i].effect_itfe)->process(in->preprocessors[i].effect_itfe,
+ &in_buf,
+ &out_buf);
+ }
+
+ /* process() has updated the number of frames consumed and produced in
+ * in_buf.frameCount and out_buf.frameCount respectively
+ * move remaining frames to the beginning of in->proc_buf_in */
+ in->proc_buf_frames -= in_buf.frameCount;
+
+ if (in->proc_buf_frames) {
+ memcpy(in->proc_buf_in,
+ in->proc_buf_in + in_buf.frameCount * in->config.channels,
+ in->proc_buf_frames * in->config.channels * sizeof(int16_t));
+ }
+
+ /* if not enough frames were passed to process(), read more and retry. */
+ if (out_buf.frameCount == 0) {
+ ALOGW("No frames produced by preproc");
+ continue;
+ }
+
+ if ((frames_wr + (ssize_t)out_buf.frameCount) <= frames) {
+ frames_wr += out_buf.frameCount;
+ } else {
+ /* The effect does not comply to the API. In theory, we should never end up here! */
+ ALOGE("%s: preprocessing produced too many frames: %d + %d > %d !", __func__,
+ (unsigned int)frames_wr, out_buf.frameCount, (unsigned int)frames);
+ frames_wr = frames;
+ }
+ }
+
+ /* Remove aux_channels that have been added on top of main_channels
+ * Assumption is made that the channels are interleaved and that the main
+ * channels are first. */
+ if (has_aux_channels)
+ {
+ size_t src_channels = in->config.channels;
+ size_t dst_channels = popcount(in->main_channels);
+ int16_t* src_buffer = (int16_t *)proc_buf_out;
+ int16_t* dst_buffer = (int16_t *)buffer;
+
+ if (dst_channels == 1) {
+ for (i = frames_wr; i > 0; i--)
+ {
+ *dst_buffer++ = *src_buffer;
+ src_buffer += src_channels;
+ }
+ } else {
+ for (i = frames_wr; i > 0; i--)
+ {
+ memcpy(dst_buffer, src_buffer, dst_channels*sizeof(int16_t));
+ dst_buffer += dst_channels;
+ src_buffer += src_channels;
+ }
+ }
+ }
+
+ return frames_wr;
+}
+
+static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
+ size_t bytes)
+{
+ int ret = 0;
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ struct m0_audio_device *adev = in->dev;
+ size_t frames_rq = bytes / audio_stream_frame_size(&stream->common);
+
+ /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
+ * on the input stream mutex - e.g. executing select_mode() while holding the hw device
+ * mutex
+ */
+ pthread_mutex_lock(&adev->lock);
+ pthread_mutex_lock(&in->lock);
+ if (in->standby) {
+ ret = start_input_stream(in);
+ if (ret == 0)
+ in->standby = 0;
+ }
+ pthread_mutex_unlock(&adev->lock);
+
+ if (ret < 0)
+ goto exit;
+
+ if (in->num_preprocessors != 0)
+ ret = process_frames(in, buffer, frames_rq);
+ else if (in->resampler != NULL)
+ ret = read_frames(in, buffer, frames_rq);
+ else
+ ret = pcm_read(in->pcm, buffer, bytes);
+
+ if (ret > 0)
+ ret = 0;
+
+ if (ret == 0 && adev->mic_mute)
+ memset(buffer, 0, bytes);
+
+exit:
+ if (ret < 0)
+ usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) /
+ in_get_sample_rate(&stream->common));
+
+ pthread_mutex_unlock(&in->lock);
+ return bytes;
+}
+
+static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
+{
+ return 0;
+}
+
+#define GET_COMMAND_STATUS(status, fct_status, cmd_status) \
+ do { \
+ if (fct_status != 0) \
+ status = fct_status; \
+ else if (cmd_status != 0) \
+ status = cmd_status; \
+ } while(0)
+
+static int in_configure_reverse(struct m0_stream_in *in)
+{
+ int32_t cmd_status;
+ uint32_t size = sizeof(int);
+ effect_config_t config;
+ int32_t status = 0;
+ int32_t fct_status = 0;
+ int i;
+
+ if (in->num_preprocessors > 0) {
+ config.inputCfg.channels = in->main_channels;
+ config.outputCfg.channels = in->main_channels;
+ config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+ config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+ config.inputCfg.samplingRate = in->requested_rate;
+ config.outputCfg.samplingRate = in->requested_rate;
+ config.inputCfg.mask =
+ ( EFFECT_CONFIG_SMP_RATE | EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT );
+ config.outputCfg.mask =
+ ( EFFECT_CONFIG_SMP_RATE | EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT );
+
+ for (i = 0; i < in->num_preprocessors; i++)
+ {
+ if ((*in->preprocessors[i].effect_itfe)->process_reverse == NULL)
+ continue;
+ fct_status = (*(in->preprocessors[i].effect_itfe))->command(
+ in->preprocessors[i].effect_itfe,
+ EFFECT_CMD_SET_CONFIG_REVERSE,
+ sizeof(effect_config_t),
+ &config,
+ &size,
+ &cmd_status);
+ GET_COMMAND_STATUS(status, fct_status, cmd_status);
+ }
+ }
+ return status;
+}
+
+#define MAX_NUM_CHANNEL_CONFIGS 10
+
+static void in_read_audio_effect_channel_configs(struct m0_stream_in *in,
+ struct effect_info_s *effect_info)
+{
+ /* size and format of the cmd are defined in hardware/audio_effect.h */
+ effect_handle_t effect = effect_info->effect_itfe;
+ uint32_t cmd_size = 2 * sizeof(uint32_t);
+ uint32_t cmd[] = { EFFECT_FEATURE_AUX_CHANNELS, MAX_NUM_CHANNEL_CONFIGS };
+ /* reply = status + number of configs (n) + n x channel_config_t */
+ uint32_t reply_size =
+ 2 * sizeof(uint32_t) + (MAX_NUM_CHANNEL_CONFIGS * sizeof(channel_config_t));
+ int32_t reply[reply_size];
+ int32_t cmd_status;
+
+ ALOG_ASSERT((effect_info->num_channel_configs == 0),
+ "in_read_audio_effect_channel_configs() num_channel_configs not cleared");
+ ALOG_ASSERT((effect_info->channel_configs == NULL),
+ "in_read_audio_effect_channel_configs() channel_configs not cleared");
+
+ /* if this command is not supported, then the effect is supposed to return -EINVAL.
+ * This error will be interpreted as if the effect supports the main_channels but does not
+ * support any aux_channels */
+ cmd_status = (*effect)->command(effect,
+ EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,
+ cmd_size,
+ (void*)&cmd,
+ &reply_size,
+ (void*)&reply);
+
+ if (cmd_status != 0) {
+ ALOGI("%s: fx->command returned %d", __func__, cmd_status);
+ return;
+ }
+
+ if (reply[0] != 0) {
+ ALOGW("%s: "
+ "command EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS error %d num configs %d",
+ __func__, reply[0], (reply[0] == -ENOMEM) ? reply[1] : MAX_NUM_CHANNEL_CONFIGS);
+ return;
+ }
+
+ /* the feature is not supported */
+ ALOGI("in_read_audio_effect_channel_configs()(): "
+ "Feature supported and adding %d channel configs to the list", reply[1]);
+ effect_info->num_channel_configs = reply[1];
+ effect_info->channel_configs =
+ (channel_config_t *) malloc(sizeof(channel_config_t) * reply[1]); /* n x configs */
+ memcpy(effect_info->channel_configs, (reply + 2), sizeof(channel_config_t) * reply[1]);
+}
+
+
+static uint32_t in_get_aux_channels(struct m0_stream_in *in)
+{
+ int i;
+ channel_config_t new_chcfg = {0, 0};
+
+ if (in->num_preprocessors == 0)
+ return 0;
+
+ /* do not enable dual mic configurations when capturing from other microphones than
+ * main or sub */
+ if (!(in->device & (AUDIO_DEVICE_IN_BUILTIN_MIC | AUDIO_DEVICE_IN_BACK_MIC)))
+ return 0;
+
+ /* retain most complex aux channels configuration compatible with requested main channels and
+ * supported by audio driver and all pre processors */
+ for (i = 0; i < NUM_IN_AUX_CNL_CONFIGS; i++) {
+ channel_config_t *cur_chcfg = &in_aux_cnl_configs[i];
+ if (cur_chcfg->main_channels == in->main_channels) {
+ size_t match_cnt;
+ size_t idx_preproc;
+ for (idx_preproc = 0, match_cnt = 0;
+ /* no need to continue if at least one preprocessor doesn't match */
+ idx_preproc < (size_t)in->num_preprocessors && match_cnt == idx_preproc;
+ idx_preproc++) {
+ struct effect_info_s *effect_info = &in->preprocessors[idx_preproc];
+ size_t idx_chcfg;
+
+ for (idx_chcfg = 0; idx_chcfg < effect_info->num_channel_configs; idx_chcfg++) {
+ if (memcmp(effect_info->channel_configs + idx_chcfg,
+ cur_chcfg,
+ sizeof(channel_config_t)) == 0) {
+ match_cnt++;
+ break;
+ }
+ }
+ }
+ /* if all preprocessors match, we have a candidate */
+ if (match_cnt == (size_t)in->num_preprocessors) {
+ /* retain most complex aux channels configuration */
+ if (popcount(cur_chcfg->aux_channels) > popcount(new_chcfg.aux_channels)) {
+ new_chcfg = *cur_chcfg;
+ }
+ }
+ }
+ }
+
+ ALOGI("in_get_aux_channels(): return %04x", new_chcfg.aux_channels);
+
+ return new_chcfg.aux_channels;
+}
+
+static int in_configure_effect_channels(effect_handle_t effect,
+ channel_config_t *channel_config)
+{
+ int status = 0;
+ int fct_status;
+ int32_t cmd_status;
+ uint32_t reply_size;
+ effect_config_t config;
+ uint32_t cmd[(sizeof(uint32_t) + sizeof(channel_config_t) - 1) / sizeof(uint32_t) + 1];
+
+ ALOGI("in_configure_effect_channels(): configure effect with channels: [%04x][%04x]",
+ channel_config->main_channels,
+ channel_config->aux_channels);
+
+ config.inputCfg.mask = EFFECT_CONFIG_CHANNELS;
+ config.outputCfg.mask = EFFECT_CONFIG_CHANNELS;
+ reply_size = sizeof(effect_config_t);
+ fct_status = (*effect)->command(effect,
+ EFFECT_CMD_GET_CONFIG,
+ 0,
+ NULL,
+ &reply_size,
+ &config);
+ if (fct_status != 0) {
+ ALOGE("in_configure_effect_channels(): EFFECT_CMD_GET_CONFIG failed");
+ return fct_status;
+ }
+
+ config.inputCfg.channels = channel_config->main_channels | channel_config->aux_channels;
+ config.outputCfg.channels = config.inputCfg.channels;
+ reply_size = sizeof(uint32_t);
+ fct_status = (*effect)->command(effect,
+ EFFECT_CMD_SET_CONFIG,
+ sizeof(effect_config_t),
+ &config,
+ &reply_size,
+ &cmd_status);
+ GET_COMMAND_STATUS(status, fct_status, cmd_status);
+
+ cmd[0] = EFFECT_FEATURE_AUX_CHANNELS;
+ memcpy(cmd + 1, channel_config, sizeof(channel_config_t));
+ reply_size = sizeof(uint32_t);
+ fct_status = (*effect)->command(effect,
+ EFFECT_CMD_SET_FEATURE_CONFIG,
+ sizeof(cmd), //sizeof(uint32_t) + sizeof(channel_config_t),
+ cmd,
+ &reply_size,
+ &cmd_status);
+ GET_COMMAND_STATUS(status, fct_status, cmd_status);
+
+ /* some implementations need to be re-enabled after a config change */
+ reply_size = sizeof(uint32_t);
+ fct_status = (*effect)->command(effect,
+ EFFECT_CMD_ENABLE,
+ 0,
+ NULL,
+ &reply_size,
+ &cmd_status);
+ GET_COMMAND_STATUS(status, fct_status, cmd_status);
+
+ return status;
+}
+
+static int in_reconfigure_channels(struct m0_stream_in *in,
+ effect_handle_t effect,
+ channel_config_t *channel_config,
+ bool config_changed) {
+
+ int status = 0;
+
+ ALOGI("%s: config_changed %d effect %p",
+ __func__, config_changed, effect);
+
+ /* if config changed, reconfigure all previously added effects */
+ if (config_changed) {
+ int i;
+ for (i = 0; i < in->num_preprocessors; i++)
+ {
+ int cur_status = in_configure_effect_channels(in->preprocessors[i].effect_itfe,
+ channel_config);
+ if (cur_status != 0) {
+ ALOGI("%s: error %d configuring effect "
+ "%d with channels: [%04x][%04x]",
+ __func__,
+ cur_status,
+ i,
+ channel_config->main_channels,
+ channel_config->aux_channels);
+ status = cur_status;
+ }
+ }
+ } else if (effect != NULL && channel_config->aux_channels) {
+ /* if aux channels config did not change but aux channels are present,
+ * we still need to configure the effect being added */
+ status = in_configure_effect_channels(effect, channel_config);
+ }
+ return status;
+}
+
+static void in_update_aux_channels(struct m0_stream_in *in,
+ effect_handle_t effect)
+{
+ uint32_t aux_channels;
+ channel_config_t channel_config;
+ int status;
+
+ aux_channels = in_get_aux_channels(in);
+
+ channel_config.main_channels = in->main_channels;
+ channel_config.aux_channels = aux_channels;
+ status = in_reconfigure_channels(in,
+ effect,
+ &channel_config,
+ (aux_channels != in->aux_channels));
+
+ if (status != 0) {
+ ALOGI("%s: in_reconfigure_channels error %d", __func__, status);
+ /* resetting aux channels configuration */
+ aux_channels = 0;
+ channel_config.aux_channels = 0;
+ in_reconfigure_channels(in, effect, &channel_config, true);
+ }
+ if (in->aux_channels != aux_channels) {
+ in->aux_channels_changed = true;
+ in->aux_channels = aux_channels;
+ do_input_standby(in);
+ }
+}
+
+static int in_add_audio_effect(const struct audio_stream *stream,
+ effect_handle_t effect)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ int status;
+ effect_descriptor_t desc;
+
+ pthread_mutex_lock(&in->dev->lock);
+ pthread_mutex_lock(&in->lock);
+ if (in->num_preprocessors >= MAX_PREPROCESSORS) {
+ status = -ENOSYS;
+ goto exit;
+ }
+
+ status = (*effect)->get_descriptor(effect, &desc);
+ if (status != 0)
+ goto exit;
+
+ in->preprocessors[in->num_preprocessors].effect_itfe = effect;
+ /* add the supported channel of the effect in the channel_configs */
+ in_read_audio_effect_channel_configs(in, &in->preprocessors[in->num_preprocessors]);
+
+ in->num_preprocessors++;
+
+ /* check compatibility between main channel supported and possible auxiliary channels */
+ in_update_aux_channels(in, effect);
+
+ ALOGV("%s: effect type: %08x", __func__, desc.type.timeLow);
+
+ if (memcmp(&desc.type, FX_IID_AEC, sizeof(effect_uuid_t)) == 0) {
+ in->need_echo_reference = true;
+ do_input_standby(in);
+ in_configure_reverse(in);
+ }
+
+exit:
+
+ ALOGW_IF(status != 0, "%s: error %d", __func__, status);
+ pthread_mutex_unlock(&in->lock);
+ pthread_mutex_unlock(&in->dev->lock);
+ return status;
+}
+
+static int in_remove_audio_effect(const struct audio_stream *stream,
+ effect_handle_t effect)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ int i;
+ int status = -EINVAL;
+ effect_descriptor_t desc;
+
+ pthread_mutex_lock(&in->dev->lock);
+ pthread_mutex_lock(&in->lock);
+ if (in->num_preprocessors <= 0) {
+ status = -ENOSYS;
+ goto exit;
+ }
+
+ for (i = 0; i < in->num_preprocessors; i++) {
+ if (status == 0) { /* status == 0 means an effect was removed from a previous slot */
+ in->preprocessors[i - 1].effect_itfe = in->preprocessors[i].effect_itfe;
+ in->preprocessors[i - 1].channel_configs = in->preprocessors[i].channel_configs;
+ in->preprocessors[i - 1].num_channel_configs = in->preprocessors[i].num_channel_configs;
+ ALOGI("in_remove_audio_effect moving fx from %d to %d", i, i - 1);
+ continue;
+ }
+ if (in->preprocessors[i].effect_itfe == effect) {
+ ALOGI("in_remove_audio_effect found fx at index %d", i);
+ free(in->preprocessors[i].channel_configs);
+ status = 0;
+ }
+ }
+
+ if (status != 0)
+ goto exit;
+
+ in->num_preprocessors--;
+ /* if we remove one effect, at least the last preproc should be reset */
+ in->preprocessors[in->num_preprocessors].num_channel_configs = 0;
+ in->preprocessors[in->num_preprocessors].effect_itfe = NULL;
+ in->preprocessors[in->num_preprocessors].channel_configs = NULL;
+
+ /* check compatibility between main channel supported and possible auxiliary channels */
+ in_update_aux_channels(in, NULL);
+
+ status = (*effect)->get_descriptor(effect, &desc);
+ if (status != 0)
+ goto exit;
+
+ ALOGI("%s: effect type: %08x", __func__, desc.type.timeLow);
+
+ if (memcmp(&desc.type, FX_IID_AEC, sizeof(effect_uuid_t)) == 0) {
+ in->need_echo_reference = false;
+ do_input_standby(in);
+ }
+
+exit:
+
+ ALOGW_IF(status != 0, "%s: error %d", __func__, status);
+ pthread_mutex_unlock(&in->lock);
+ pthread_mutex_unlock(&in->dev->lock);
+ return status;
+}
+
+static int adev_open_output_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ audio_output_flags_t flags,
+ struct audio_config *config,
+ struct audio_stream_out **stream_out)
+{
+ struct m0_audio_device *ladev = (struct m0_audio_device *)dev;
+ struct m0_stream_out *out;
+ int ret;
+ int output_type;
+ *stream_out = NULL;
+
+ out = (struct m0_stream_out *)calloc(1, sizeof(struct m0_stream_out));
+ if (!out)
+ return -ENOMEM;
+
+ out->sup_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
+ out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+
+ if (ladev->outputs[OUTPUT_DEEP_BUF] != NULL) {
+ ret = -ENOSYS;
+ goto err_open;
+ }
+ output_type = OUTPUT_DEEP_BUF;
+ out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+ out->stream.common.get_buffer_size = out_get_buffer_size_deep_buffer;
+ out->stream.common.get_sample_rate = out_get_sample_rate;
+ out->stream.get_latency = out_get_latency_deep_buffer;
+ out->stream.write = out_write_deep_buffer;
+
+ ret = create_resampler(DEFAULT_OUT_SAMPLING_RATE,
+ MM_FULL_POWER_SAMPLING_RATE,
+ 2,
+ RESAMPLER_QUALITY_DEFAULT,
+ NULL,
+ &out->resampler);
+ if (ret != 0)
+ goto err_open;
+
+ out->stream.common.set_sample_rate = out_set_sample_rate;
+ out->stream.common.get_channels = out_get_channels;
+ out->stream.common.get_format = out_get_format;
+ out->stream.common.set_format = out_set_format;
+ out->stream.common.standby = out_standby;
+ out->stream.common.dump = out_dump;
+ out->stream.common.set_parameters = out_set_parameters;
+ out->stream.common.get_parameters = out_get_parameters;
+ out->stream.common.add_audio_effect = out_add_audio_effect;
+ out->stream.common.remove_audio_effect = out_remove_audio_effect;
+ out->stream.set_volume = out_set_volume;
+ out->stream.get_render_position = out_get_render_position;
+
+ out->dev = ladev;
+ out->standby = 1;
+
+ /* FIXME: when we support multiple output devices, we will want to
+ * do the following:
+ * adev->out_device = out->device;
+ * select_output_device(adev);
+ * This is because out_set_parameters() with a route is not
+ * guaranteed to be called after an output stream is opened. */
+
+ config->format = out->stream.common.get_format(&out->stream.common);
+ config->channel_mask = out->stream.common.get_channels(&out->stream.common);
+ config->sample_rate = out->stream.common.get_sample_rate(&out->stream.common);
+
+ *stream_out = &out->stream;
+ ladev->outputs[output_type] = out;
+
+ return 0;
+
+err_open:
+ free(out);
+ return ret;
+}
+
+static void adev_close_output_stream(struct audio_hw_device *dev,
+ struct audio_stream_out *stream)
+{
+ struct m0_audio_device *ladev = (struct m0_audio_device *)dev;
+ struct m0_stream_out *out = (struct m0_stream_out *)stream;
+ int i;
+
+ out_standby(&stream->common);
+ for (i = 0; i < OUTPUT_TOTAL; i++) {
+ if (ladev->outputs[i] == out) {
+ ladev->outputs[i] = NULL;
+ break;
+ }
+ }
+
+ if (out->buffer)
+ free(out->buffer);
+ if (out->resampler)
+ release_resampler(out->resampler);
+ free(stream);
+}
+
+static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)dev;
+ struct str_parms *parms;
+ char *str;
+ char value[32];
+ int ret;
+
+ parms = str_parms_create_str(kvpairs);
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
+ if (ret >= 0) {
+ int tty_mode;
+
+ if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF) == 0)
+ tty_mode = TTY_MODE_OFF;
+ else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_VCO) == 0)
+ tty_mode = TTY_MODE_VCO;
+ else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_HCO) == 0)
+ tty_mode = TTY_MODE_HCO;
+ else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_FULL) == 0)
+ tty_mode = TTY_MODE_FULL;
+ else
+ return -EINVAL;
+
+ pthread_mutex_lock(&adev->lock);
+ if (tty_mode != adev->tty_mode) {
+ adev->tty_mode = tty_mode;
+ if (adev->mode == AUDIO_MODE_IN_CALL)
+ select_output_device(adev);
+ }
+ pthread_mutex_unlock(&adev->lock);
+ }
+
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_BT_NREC, value, sizeof(value));
+ if (ret >= 0) {
+ if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
+ adev->bluetooth_nrec = true;
+ else
+ adev->bluetooth_nrec = false;
+ }
+
+ ret = str_parms_get_str(parms, "screen_off", value, sizeof(value));
+ if (ret >= 0) {
+ if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0)
+ adev->screen_off = false;
+ else
+ adev->screen_off = true;
+ }
+
+ // Wideband AMR
+ ret = str_parms_get_str(parms, "wb_amr", value, sizeof(value));
+ if (ret >= 0) {
+ if (csd_wide_voice == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_wide_voice", dlerror());
+ } else {
+ if (strcmp(value, "on") == 0) {
+ ALOGE("%s: enabling csd_wide_voice", __func__);
+ csd_wide_voice(VX_WB_SAMPLING_RATE);
+ } else {
+ ALOGE("%s: disabling csd_wide_voice", __func__);
+ csd_wide_voice(VX_NB_SAMPLING_RATE);
+ }
+ }
+ }
+
+ // FIXME
+ ret = str_parms_get_str(parms, "noise_suppression", value, sizeof(value));
+ if (ret >= 0) {
+ if (strcmp(value, "true") == 0) {
+ ALOGE("%s: enabling two mic control", __func__);
+ /* sub mic */
+ set_bigroute_by_array(adev->mixer, noise_suppression, 1);
+ } else {
+ ALOGE("%s: disabling two mic control", __func__);
+ /* sub mic */
+ set_bigroute_by_array(adev->mixer, noise_suppression_disable, 1);
+ }
+ }
+
+ str_parms_destroy(parms);
+ return ret;
+}
+
+static char * adev_get_parameters(const struct audio_hw_device *dev,
+ const char *keys)
+{
+ return strdup("");
+}
+
+static int adev_init_check(const struct audio_hw_device *dev)
+{
+ return 0;
+}
+
+static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)dev;
+
+ adev->voice_volume = volume;
+
+ if (adev->mode == AUDIO_MODE_IN_CALL) {
+ if (csd_volume_index == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_volume_index", dlerror());
+ } else {
+ volume = volume * 5;
+ ALOGD("%s: calling csd_volume_index(%f)", __func__, volume);
+ csd_volume_index(volume);
+ }
+ }
+ return 0;
+}
+
+static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
+{
+ return -ENOSYS;
+}
+
+static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)dev;
+
+ pthread_mutex_lock(&adev->lock);
+ if (adev->mode != mode) {
+ adev->mode = mode;
+ select_mode(adev);
+ }
+ pthread_mutex_unlock(&adev->lock);
+
+ return 0;
+}
+
+static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)dev;
+
+ adev->mic_mute = state;
+
+ if (adev->mode == AUDIO_MODE_IN_CALL) {
+ if (csd_mic_mute == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_mic_mute", dlerror());
+ } else {
+ ALOGD("%s: calling csd_mic_mute, state=%d", __func__, adev->mic_mute);
+ csd_mic_mute(adev->mic_mute);
+ }
+ }
+
+ return 0;
+}
+
+static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)dev;
+
+ *state = adev->mic_mute;
+
+ return 0;
+}
+
+static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
+ const struct audio_config *config)
+{
+ size_t size;
+ int channel_count = popcount(config->channel_mask);
+ if (check_input_parameters(config->sample_rate, config->format, channel_count) != 0)
+ return 0;
+
+ return get_input_buffer_size(config->sample_rate, config->format, channel_count);
+}
+
+static int adev_open_input_stream(struct audio_hw_device *dev,
+ audio_io_handle_t handle,
+ audio_devices_t devices,
+ struct audio_config *config,
+ struct audio_stream_in **stream_in)
+{
+ struct m0_audio_device *ladev = (struct m0_audio_device *)dev;
+ struct m0_stream_in *in;
+ int ret;
+
+ /* Respond with a request for stereo if a different format is given. */
+ if (config->channel_mask != AUDIO_CHANNEL_IN_STEREO) {
+ config->channel_mask = AUDIO_CHANNEL_IN_STEREO;
+ return -EINVAL;
+ }
+
+ int channel_count = popcount(config->channel_mask);
+
+ *stream_in = NULL;
+
+ if (check_input_parameters(config->sample_rate, config->format, channel_count) != 0)
+ return -EINVAL;
+
+ in = (struct m0_stream_in *)calloc(1, sizeof(struct m0_stream_in));
+ if (!in)
+ return -ENOMEM;
+
+ in->stream.common.get_sample_rate = in_get_sample_rate;
+ in->stream.common.set_sample_rate = in_set_sample_rate;
+ in->stream.common.get_buffer_size = in_get_buffer_size;
+ in->stream.common.get_channels = in_get_channels;
+ in->stream.common.get_format = in_get_format;
+ in->stream.common.set_format = in_set_format;
+ in->stream.common.standby = in_standby;
+ in->stream.common.dump = in_dump;
+ in->stream.common.set_parameters = in_set_parameters;
+ in->stream.common.get_parameters = in_get_parameters;
+ in->stream.common.add_audio_effect = in_add_audio_effect;
+ in->stream.common.remove_audio_effect = in_remove_audio_effect;
+ in->stream.set_gain = in_set_gain;
+ in->stream.read = in_read;
+ in->stream.get_input_frames_lost = in_get_input_frames_lost;
+
+ in->requested_rate = config->sample_rate;
+
+ memcpy(&in->config, &pcm_config_capture, sizeof(pcm_config_capture));
+ in->config.channels = channel_count;
+
+ in->main_channels = config->channel_mask;
+
+ /* initialisation of preprocessor structure array is implicit with the calloc.
+ * same for in->aux_channels and in->aux_channels_changed */
+
+ if (in->requested_rate != in->config.rate) {
+ in->buf_provider.get_next_buffer = get_next_buffer;
+ in->buf_provider.release_buffer = release_buffer;
+
+ ret = create_resampler(in->config.rate,
+ in->requested_rate,
+ in->config.channels,
+ RESAMPLER_QUALITY_DEFAULT,
+ &in->buf_provider,
+ &in->resampler);
+ if (ret != 0) {
+ ret = -EINVAL;
+ goto err;
+ }
+ }
+
+ in->dev = ladev;
+ in->standby = 1;
+ in->device = devices & ~AUDIO_DEVICE_BIT_IN;
+
+ *stream_in = &in->stream;
+ return 0;
+
+err:
+ if (in->resampler)
+ release_resampler(in->resampler);
+
+ free(in);
+ return ret;
+}
+
+static void adev_close_input_stream(struct audio_hw_device *dev,
+ struct audio_stream_in *stream)
+{
+ struct m0_stream_in *in = (struct m0_stream_in *)stream;
+ int i;
+
+ in_standby(&stream->common);
+
+ for (i = 0; i < in->num_preprocessors; i++) {
+ free(in->preprocessors[i].channel_configs);
+ }
+
+ free(in->read_buf);
+ if (in->resampler) {
+ release_resampler(in->resampler);
+ }
+ if (in->proc_buf_in)
+ free(in->proc_buf_in);
+ if (in->proc_buf_out)
+ free(in->proc_buf_out);
+ if (in->ref_buf)
+ free(in->ref_buf);
+
+ free(stream);
+ return;
+}
+
+static int adev_dump(const audio_hw_device_t *device, int fd)
+{
+ return 0;
+}
+
+static int adev_close(hw_device_t *device)
+{
+ struct m0_audio_device *adev = (struct m0_audio_device *)device;
+
+ /* QCOM CSD-Client */
+ if (mCsdHandle) {
+ if (csd_client_deinit == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_client_deinit", dlerror());
+ } else {
+ ALOGD("%s: calling csd_client_deinit", __func__);
+ csd_client_deinit();
+ }
+ dlclose(mCsdHandle);
+ mCsdHandle = NULL;
+ }
+
+ mixer_close(adev->mixer);
+ free(device);
+ return 0;
+}
+
+struct config_parse_state {
+ struct m0_audio_device *adev;
+ struct m0_dev_cfg *dev;
+ bool on;
+
+ struct route_setting *path;
+ unsigned int path_len;
+};
+
+static const struct {
+ int mask;
+ const char *name;
+} dev_names[] = {
+ { AUDIO_DEVICE_OUT_SPEAKER, "speaker" },
+ { AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE, "headphone" },
+ { AUDIO_DEVICE_OUT_EARPIECE, "earpiece" },
+ { AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, "analog-dock" },
+ { AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, "digital-dock" },
+ { AUDIO_DEVICE_OUT_ALL_SCO, "sco-out" },
+
+ { AUDIO_DEVICE_IN_BUILTIN_MIC, "builtin-mic" },
+ { AUDIO_DEVICE_IN_BACK_MIC, "back-mic" },
+ { AUDIO_DEVICE_IN_WIRED_HEADSET, "headset-in" },
+ { AUDIO_DEVICE_IN_ALL_SCO, "sco-in" },
+};
+
+static void adev_config_start(void *data, const XML_Char *elem,
+ const XML_Char **attr)
+{
+ struct config_parse_state *s = data;
+ struct m0_dev_cfg *dev_cfg;
+ const XML_Char *name = NULL;
+ const XML_Char *val = NULL;
+ unsigned int i, j;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "name") == 0)
+ name = attr[i + 1];
+
+ if (strcmp(attr[i], "val") == 0)
+ val = attr[i + 1];
+ }
+
+ if (strcmp(elem, "device") == 0) {
+ if (!name) {
+ ALOGE("Unnamed device\n");
+ return;
+ }
+
+ for (i = 0; i < sizeof(dev_names) / sizeof(dev_names[0]); i++) {
+ if (strcmp(dev_names[i].name, name) == 0) {
+ ALOGI("Allocating device %s\n", name);
+ dev_cfg = realloc(s->adev->dev_cfgs,
+ (s->adev->num_dev_cfgs + 1)
+ * sizeof(*dev_cfg));
+ if (!dev_cfg) {
+ ALOGE("Unable to allocate dev_cfg\n");
+ return;
+ }
+
+ s->dev = &dev_cfg[s->adev->num_dev_cfgs];
+ memset(s->dev, 0, sizeof(*s->dev));
+ s->dev->mask = dev_names[i].mask;
+
+ s->adev->dev_cfgs = dev_cfg;
+ s->adev->num_dev_cfgs++;
+ }
+ }
+
+ } else if (strcmp(elem, "path") == 0) {
+ if (s->path_len)
+ ALOGW("Nested paths\n");
+
+ /* If this a path for a device it must have a role */
+ if (s->dev) {
+ /* Need to refactor a bit... */
+ if (strcmp(name, "on") == 0) {
+ s->on = true;
+ } else if (strcmp(name, "off") == 0) {
+ s->on = false;
+ } else {
+ ALOGW("Unknown path name %s\n", name);
+ }
+ }
+
+ } else if (strcmp(elem, "ctl") == 0) {
+ struct route_setting *r;
+
+ if (!name) {
+ ALOGE("Unnamed control\n");
+ return;
+ }
+
+ if (!val) {
+ ALOGE("No value specified for %s\n", name);
+ return;
+ }
+
+ ALOGV("Parsing control %s => %s\n", name, val);
+
+ r = realloc(s->path, sizeof(*r) * (s->path_len + 1));
+ if (!r) {
+ ALOGE("Out of memory handling %s => %s\n", name, val);
+ return;
+ }
+
+ r[s->path_len].ctl_name = strdup(name);
+ r[s->path_len].strval = NULL;
+
+ /* This can be fooled but it'll do */
+ r[s->path_len].intval = atoi(val);
+ if (!r[s->path_len].intval && strcmp(val, "0") != 0)
+ r[s->path_len].strval = strdup(val);
+
+ s->path = r;
+ s->path_len++;
+ }
+}
+
+static void adev_config_end(void *data, const XML_Char *name)
+{
+ struct config_parse_state *s = data;
+ unsigned int i;
+
+ if (strcmp(name, "path") == 0) {
+ if (!s->path_len)
+ ALOGW("Empty path\n");
+
+ if (!s->dev) {
+ ALOGV("Applying %d element default route\n", s->path_len);
+
+ set_route_by_array(s->adev->mixer, s->path, s->path_len);
+
+ for (i = 0; i < s->path_len; i++) {
+ free(s->path[i].ctl_name);
+ free(s->path[i].strval);
+ }
+
+ free(s->path);
+
+ /* Refactor! */
+ } else if (s->on) {
+ ALOGV("%d element on sequence\n", s->path_len);
+ s->dev->on = s->path;
+ s->dev->on_len = s->path_len;
+
+ } else {
+ ALOGV("%d element off sequence\n", s->path_len);
+
+ /* Apply it, we'll reenable anything that's wanted later */
+ set_route_by_array(s->adev->mixer, s->path, s->path_len);
+
+ s->dev->off = s->path;
+ s->dev->off_len = s->path_len;
+ }
+
+ s->path_len = 0;
+ s->path = NULL;
+
+ } else if (strcmp(name, "device") == 0) {
+ s->dev = NULL;
+ }
+}
+
+static int adev_config_parse(struct m0_audio_device *adev)
+{
+ struct config_parse_state s;
+ FILE *f;
+ XML_Parser p;
+ char property[PROPERTY_VALUE_MAX];
+ char file[80];
+ int ret = 0;
+ bool eof = false;
+ int len;
+
+ property_get("ro.product.device", property, "tiny_hw");
+ snprintf(file, sizeof(file), "/system/etc/sound/%s", property);
+
+ ALOGV("Reading configuration from %s\n", file);
+ f = fopen(file, "r");
+ if (!f) {
+ ALOGE("Failed to open %s\n", file);
+ return -ENODEV;
+ }
+
+ p = XML_ParserCreate(NULL);
+ if (!p) {
+ ALOGE("Failed to create XML parser\n");
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ memset(&s, 0, sizeof(s));
+ s.adev = adev;
+ XML_SetUserData(p, &s);
+
+ XML_SetElementHandler(p, adev_config_start, adev_config_end);
+
+ while (!eof) {
+ len = fread(file, 1, sizeof(file), f);
+ if (ferror(f)) {
+ ALOGE("I/O error reading config\n");
+ ret = -EIO;
+ goto out_parser;
+ }
+ eof = feof(f);
+
+ if (XML_Parse(p, file, len, eof) == XML_STATUS_ERROR) {
+ ALOGE("Parse error at line %u:\n%s\n",
+ (unsigned int)XML_GetCurrentLineNumber(p),
+ XML_ErrorString(XML_GetErrorCode(p)));
+ ret = -EINVAL;
+ goto out_parser;
+ }
+ }
+
+ out_parser:
+ XML_ParserFree(p);
+ out:
+ fclose(f);
+
+ return ret;
+}
+
+static int adev_open(const hw_module_t* module, const char* name,
+ hw_device_t** device)
+{
+ struct m0_audio_device *adev;
+ int ret;
+
+ if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)
+ return -EINVAL;
+
+ adev = calloc(1, sizeof(struct m0_audio_device));
+ if (!adev)
+ return -ENOMEM;
+
+ adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
+ adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
+ adev->hw_device.common.module = (struct hw_module_t *) module;
+ adev->hw_device.common.close = adev_close;
+
+ adev->hw_device.init_check = adev_init_check;
+ adev->hw_device.set_voice_volume = adev_set_voice_volume;
+ adev->hw_device.set_master_volume = adev_set_master_volume;
+ adev->hw_device.set_mode = adev_set_mode;
+ adev->hw_device.set_mic_mute = adev_set_mic_mute;
+ adev->hw_device.get_mic_mute = adev_get_mic_mute;
+ adev->hw_device.set_parameters = adev_set_parameters;
+ adev->hw_device.get_parameters = adev_get_parameters;
+ adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size;
+ adev->hw_device.open_output_stream = adev_open_output_stream;
+ adev->hw_device.close_output_stream = adev_close_output_stream;
+ adev->hw_device.open_input_stream = adev_open_input_stream;
+ adev->hw_device.close_input_stream = adev_close_input_stream;
+ adev->hw_device.dump = adev_dump;
+
+ adev->mixer = mixer_open(CARD_DEFAULT);
+ if (!adev->mixer) {
+ free(adev);
+ ALOGE("Unable to open the mixer, aborting.");
+ return -EINVAL;
+ }
+
+ /* +30db boost for mics */
+ adev->mixer_ctls.mixinl_in1l_volume = mixer_get_ctl_by_name(adev->mixer, "MIXINL IN1L Volume");
+ adev->mixer_ctls.mixinl_in2l_volume = mixer_get_ctl_by_name(adev->mixer, "MIXINL IN2L Volume");
+
+ ret = adev_config_parse(adev);
+ if (ret != 0)
+ goto err_mixer;
+
+ /* Set the default route before the PCM stream is opened */
+ pthread_mutex_lock(&adev->lock);
+ adev->mode = AUDIO_MODE_NORMAL;
+ adev->out_device = AUDIO_DEVICE_OUT_SPEAKER;
+ adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN;
+ select_devices(adev);
+
+ adev->pcm_modem_dl = NULL;
+ adev->pcm_modem_ul = NULL;
+ adev->pcm_bt_dl = NULL;
+ adev->pcm_bt_ul = NULL;
+ adev->voice_volume = 1.0f;
+ adev->tty_mode = TTY_MODE_OFF;
+ adev->bluetooth_nrec = true;
+
+ /* QCOM CSD-Client */
+ mCsdHandle = dlopen(CSD_CLIENT_LIBPATH, RTLD_NOW);
+ if (mCsdHandle == NULL) {
+ ALOGE("DLOPEN not successful for CSD CLIENT");
+ } else {
+ ALOGD("DLOPEN successful for CSD CLIENT");
+ setCsdHandle(mCsdHandle);
+
+ if (csd_client_init == NULL) {
+ ALOGE("dlsym: Error:%s Loading csd_client_init", dlerror());
+ } else {
+ ALOGD("%s: calling csd_client_init", __func__);
+ csd_client_init();
+ }
+ }
+
+ pthread_mutex_unlock(&adev->lock);
+
+ *device = &adev->hw_device.common;
+
+ return 0;
+
+err_mixer:
+ mixer_close(adev->mixer);
+err:
+ return -EINVAL;
+}
+
+static struct hw_module_methods_t hal_module_methods = {
+ .open = adev_open,
+};
+
+struct audio_module HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = AUDIO_MODULE_API_VERSION_0_1,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = AUDIO_HARDWARE_MODULE_ID,
+ .name = "T0LTE audio HW HAL",
+ .author = "The CyanogenMod Project",
+ .methods = &hal_module_methods,
+ },
+};
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
new file mode 100644
index 0000000..30bdf01
--- /dev/null
+++ b/audio/audio_hw.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2012 Wolfson Microelectronics plc
+ * Copyright (C) 2012 The CyanogenMod Project
+ * Daniel Hillenbrand <codeworkx@cyanogenmod.com>
+ * Guillaume "XpLoDWilD" Lesniak <xplodgui@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ALSA cards for WM1811 */
+#define CARD_DEFAULT 0
+
+#define PORT_PLAYBACK 0
+#define PORT_MODEM 1
+#define PORT_BT 2
+#define PORT_CAPTURE 3
+
+#define PCM_WRITE pcm_write
+
+#define PLAYBACK_PERIOD_SIZE 880
+#define PLAYBACK_PERIOD_COUNT 8
+#define PLAYBACK_SHORT_PERIOD_COUNT 2
+
+#define CAPTURE_PERIOD_SIZE 1056
+#define CAPTURE_PERIOD_COUNT 2
+
+#define SHORT_PERIOD_SIZE 192
+
+//
+// deep buffer
+//
+/* screen on */
+#define DEEP_BUFFER_SHORT_PERIOD_SIZE 1056
+#define PLAYBACK_DEEP_BUFFER_SHORT_PERIOD_COUNT 4
+/* screen off */
+#define DEEP_BUFFER_LONG_PERIOD_SIZE 880
+#define PLAYBACK_DEEP_BUFFER_LONG_PERIOD_COUNT 8
+
+
+/* minimum sleep time in out_write() when write threshold is not reached */
+#define MIN_WRITE_SLEEP_US 5000
+
+#define RESAMPLER_BUFFER_FRAMES (PLAYBACK_PERIOD_SIZE * 2)
+#define RESAMPLER_BUFFER_SIZE (4 * RESAMPLER_BUFFER_FRAMES)
+
+#define DEFAULT_OUT_SAMPLING_RATE 44100
+#define MM_LOW_POWER_SAMPLING_RATE 44100
+#define MM_FULL_POWER_SAMPLING_RATE 44100
+#define DEFAULT_IN_SAMPLING_RATE 44100
+
+/* sampling rate when using VX port for narrow band */
+#define VX_NB_SAMPLING_RATE 8000
+/* sampling rate when using VX port for wide band */
+#define VX_WB_SAMPLING_RATE 16000
+
+/* product-specific defines */
+#define PRODUCT_DEVICE_PROPERTY "ro.product.device"
+#define PRODUCT_NAME_PROPERTY "ro.product.name"
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define STRING_TO_ENUM(string) { #string, string }
+
+struct string_to_enum {
+ const char *name;
+ uint32_t value;
+};
+
+const struct string_to_enum out_channels_name_to_enum_table[] = {
+ STRING_TO_ENUM(AUDIO_CHANNEL_OUT_STEREO),
+ STRING_TO_ENUM(AUDIO_CHANNEL_OUT_5POINT1),
+ STRING_TO_ENUM(AUDIO_CHANNEL_OUT_7POINT1),
+};
+
+enum pcm_type {
+ PCM_NORMAL = 0,
+ PCM_SPDIF,
+ PCM_HDMI,
+ PCM_TOTAL,
+};
+
+enum output_type {
+ OUTPUT_DEEP_BUF, // deep PCM buffers output stream
+ OUTPUT_LOW_LATENCY, // low latency output stream
+ OUTPUT_HDMI,
+ OUTPUT_TOTAL
+};
+
+enum tty_modes {
+ TTY_MODE_OFF,
+ TTY_MODE_VCO,
+ TTY_MODE_HCO,
+ TTY_MODE_FULL
+};
+
+/* ACDB Device ID macros */
+#define DEVICE_HANDSET_RX_ACDB_ID 7 // HANDSET_SPKR
+#define DEVICE_HANDSET_TX_ACDB_ID 4 // HANDSET_MIC
+#define DEVICE_SPEAKER_RX_ACDB_ID 15// SPKR_PHONE_SPKR_STEREO
+#define DEVICE_SPEAKER_MONO_RX_ACDB_ID 14// SPKR_PHONE_SPKR_MONO
+#define DEVICE_SPEAKER_STEREO_RX_ACDB_ID 15// SPKR_PHONE_SPKR_STEREO
+#define DEVICE_SPEAKER_TX_ACDB_ID 11// SPKR_PHONE_MIC
+#define DEVICE_HEADSET_RX_ACDB_ID 10// HEADSET_SPKR_STEREO
+#define DEVICE_HEADSET_TX_ACDB_ID 8 // HEADSET_MIC
+#define DEVICE_DUALMIC_HANDSET_TX_BROADSIDE_ACDB_ID 5 // HANDSET_MIC_BROADSIDE
+#define DEVICE_DUALMIC_HANDSET_TX_ENDFIRE_ACDB_ID 6 // HANDSET_MIC_ENDFIRE
+#define DEVICE_DUALMIC_SPEAKER_TX_BROADSIDE_ACDB_ID 12// SPKR_PHONE_MIC_BROADSIDE
+#define DEVICE_DUALMIC_SPEAKER_TX_ENDFIRE_ACDB_ID 13// SPKR_PHONE_MIC_ENDFIRE
+#define DEVICE_DUALMIC_HANDSET_STEREO_ACDB_ID 34
+#define DEVICE_DUALMIC_SPEAKER_PHONE_STEREO_ACDB_ID 35
+#define DEVICE_TTY_HEADSET_MONO_RX_ACDB_ID 17// TTY_HEADSET_SPKR
+#define DEVICE_TTY_HEADSET_MONO_TX_ACDB_ID 16// TTY_HEADSET_MIC
+#define DEVICE_BT_SCO_RX_ACDB_ID 22// BT_SCO_SPKR
+#define DEVICE_BT_SCO_TX_ACDB_ID 21// BT_SCO_SPKR
+#define DEVICE_BT_SCO_RX_WB_ACDB_ID 39// BT_SCO_WB_SPKR
+#define DEVICE_BT_SCO_TX_WB_ACDB_ID 38// BT_SCO_WB_MIC
+#define DEVICE_SPEAKER_HEADSET_RX_ACDB_ID DEVICE_HEADSET_RX_ACDB_ID // Use headset calibration
+#define DEVICE_HDMI_STEREO_RX_ACDB_ID 18// HDMI_SPKR
+#define DEVICE_ANC_HEADSET_STEREO_RX_ACDB_ID 26// ANC RX, same as regular headset
+#define DEVICE_QUADMIC_ACDB_ID 19// QUADMIC_SKPR
+#define DEVICE_PROXY_RX_ACDB_ID DEVICE_HDMI_STEREO_RX_ACDB_ID
+#define DEVICE_TTY_VCO_HANDSET_TX_ACDB_ID 36// TTY_VCO_HANDSET_MIC
+#define DEVICE_TTY_HCO_HANDSET_RX_ACDB_ID 37// TTY_HCO_HANDSET_SPRK
+#define DEVICE_HANDSET_TX_FV5_ACDB_ID 40
+#define DEVICE_DUALMIC_HANDSET_TX_ENDFIRE_FV5_ACDB_ID 41
+#define DEVICE_SPEAKER_TX_FV5_ACDB_ID 42
+#define DEVICE_DUALMIC_SPEAKER_TX_ENDFIRE_FV5_ACDB_ID 43
+#define DEVICE_INCALL_VOICE_RECORD_STEREO_ACDB_ID 45
+#define DEVICE_INCALL_MUSIC_DELIVERY_MONO_ACDB_ID 46
+#define DEVICE_INCALL_VOICE_RECORD_MONO_ACDB_ID 47
+#define DEVICE_CAMCORDER_TX_ACDB_ID 61// CAMCORDER_TX
+#define DEVICE_VOICE_RECOGNITION_ACDB_ID 62// VOICE_RECOGNITION
+
+#define ANC_FLAG 0x00000001
+#define DMIC_FLAG 0x00000002
+#define QMIC_FLAG 0x00000004
+#define TTY_OFF 0x00000010
+#define TTY_FULL 0x00000020
+#define TTY_VCO 0x00000040
+#define TTY_HCO 0x00000080
+#define TTY_CLEAR 0xFFFFFF0F
+
+struct mixer_ctls
+{
+ struct mixer_ctl *mixinl_in1l_volume;
+ struct mixer_ctl *mixinl_in2l_volume;
+};
+
+struct route_setting
+{
+ char *ctl_name;
+ int intval;
+ char *strval;
+};
+
+struct route_setting voicecall_default[] = {
+ { .ctl_name = "AIF2 Mode", .intval = 0, },
+ { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF2DAC Mux", .strval = "AIF2DACDAT", },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting voicecall_default_disable[] = {
+ { .ctl_name = "AIF2 Mode", .intval = 0, },
+ { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF2DAC Mux", .strval = "AIF3DACDAT", },
+ { .ctl_name = "Main Mic Switch", .intval = 0, },
+ { .ctl_name = "MIXINL IN2L Switch", .intval = 0, },
+ { .ctl_name = "Sub Mic Switch", .intval = 0, },
+ { .ctl_name = "MIXINR IN1R Switch", .intval = 0, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting default_input[] = {
+ { .ctl_name = "Main Mic Switch", .intval = 1, },
+ { .ctl_name = "MainMicBias Mode", .intval = 1, },
+ { .ctl_name = "IN2L Volume", .intval = 28, },
+ { .ctl_name = "MIXINL IN2L Switch", .intval = 1, },
+ { .ctl_name = "MIXINL IN2L Volume", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 1, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting default_input_disable[] = {
+ { .ctl_name = "Main Mic Switch", .intval = 0, },
+ { .ctl_name = "IN2L Volume", .intval = 4, },
+ { .ctl_name = "MIXINL IN2L Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting noise_suppression[] = {
+ { .ctl_name = "Sub Mic Switch", .intval = 1, },
+ { .ctl_name = "IN1R Volume", .intval = 25, },
+ { .ctl_name = "MIXINR IN1R Switch", .intval = 1, },
+ { .ctl_name = "MIXINR IN1R Volume", .intval = 0, },
+ { .ctl_name = "AIF1ADCR Source", .intval = 1, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting noise_suppression_disable[] = {
+ { .ctl_name = "Sub Mic Switch", .intval = 0, },
+ { .ctl_name = "IN1R Volume", .intval = 7, },
+ { .ctl_name = "MIXINR IN1R Switch", .intval = 0, },
+ { .ctl_name = "MIXINR IN1R Volume", .intval = 0, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting headset_input[] = {
+ { .ctl_name = "MIXINL IN2L Switch", .intval = 0, },
+ { .ctl_name = "MIXINR IN1R Switch", .intval = 0, },
+ { .ctl_name = "Headset Mic Switch", .intval = 1, },
+ { .ctl_name = "IN1L Volume", .intval = 18, },
+ { .ctl_name = "MIXINL IN1L Switch", .intval = 1, },
+ { .ctl_name = "MIXINL IN1L Volume", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 1, },
+ { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1 Volume", .intval = 96, },
+ { .ctl_name = "AIF1ADCL Source", .intval = 0, },
+ { .ctl_name = "AIF1ADCR Source", .intval = 0, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting headset_input_disable[] = {
+ { .ctl_name = "Headset Mic Switch", .intval = 0, },
+ { .ctl_name = "MIXINL IN1L Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Mode", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting bt_output[] = {
+ { .ctl_name = "AIF1DAC1 Volume", .intval = 96, },
+ { .ctl_name = "AIF1 Boost Volume", .intval = 0, },
+ { .ctl_name = "DAC2 Volume", .intval = 96, },
+ { .ctl_name = "AIF2ADC Volume", .intval = 96, },
+ { .ctl_name = "DAC1L Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "DAC1R Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "AIF3ADC Mux", .intval = 1, },
+ { .ctl_name = "AIF2DAC2L Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "AIF2DAC2R Mixer AIF1.1 Switch", .intval = 1, },
+ { .ctl_name = "AIF2DAC Volume", .intval = 96, },
+ { .ctl_name = "MIXINL IN1L Volume", .intval = 1, },
+ { .ctl_name = "IN2L Volume", .intval = 25, },
+ { .ctl_name = "IN1R Volume", .intval = 25, },
+ { .ctl_name = "LINEOUT1N Switch", .intval = 0, },
+ { .ctl_name = "LINEOUT1P Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1 HPF Switch", .intval = 0, },
+ { .ctl_name = "AIF2ADC HPF Mode", .intval = 3, },
+ { .ctl_name = "AIF2ADC HPF Switch", .intval = 1, },
+ { .ctl_name = "AIF2DAC Mux", .strval = "AIF2DACDAT", },
+ { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting bt_input[] = {
+ { .ctl_name = "AIF2ADC Mux", .intval = 1, },
+ { .ctl_name = "AIF1ADCL Source", .intval = 0, },
+ { .ctl_name = "AIF1ADCR Source", .intval = 1, },
+ { .ctl_name = "DAC1L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "DAC1R Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 1, },
+ { .ctl_name = "AIF1ADC1 Volume", .intval = 96, },
+ { .ctl_name = "AIF2DAC Volume", .intval = 96, },
+ { .ctl_name = NULL, },
+};
+
+struct route_setting bt_disable[] = {
+ { .ctl_name = "AIF1DAC1 Volume", .intval = 96, },
+ { .ctl_name = "AIF1 Boost Volume", .intval = 0, },
+ { .ctl_name = "DAC2 Volume", .intval = 96, },
+ { .ctl_name = "AIF2ADC Volume", .intval = 96, },
+ { .ctl_name = "AIF2ADC Mux", .intval = 0, },
+ { .ctl_name = "MIXINL IN1L Volume", .intval = 0, },
+ { .ctl_name = "LINEOUT1N Switch", .intval = 1, },
+ { .ctl_name = "LINEOUT1P Switch", .intval = 1, },
+ { .ctl_name = "AIF2ADC HPF Mode", .intval = 0, },
+ { .ctl_name = "AIF2ADC HPF Switch", .intval = 0, },
+ { .ctl_name = "AIF2DAC2R Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF2DAC2L Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1R Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = "AIF1ADC1L Mixer AIF2 Switch", .intval = 0, },
+ { .ctl_name = NULL, },
+};
diff --git a/bluetooth/bdroid_buildcfg.h b/bluetooth/bdroid_buildcfg.h
new file mode 100644
index 0000000..6aa5a1b
--- /dev/null
+++ b/bluetooth/bdroid_buildcfg.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2012 The CyanogenMod Project <http://www.cyanogenmod.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BDROID_BUILDCFG_H
+#define _BDROID_BUILDCFG_H
+
+#define BTM_DEF_LOCAL_NAME "Galaxy S III LTE"
+
+#endif
diff --git a/cm.dependencies b/cm.dependencies
new file mode 100644
index 0000000..a1ab9d7
--- /dev/null
+++ b/cm.dependencies
@@ -0,0 +1,14 @@
+[
+ {
+ "repository": "android_device_samsung_smdk4412-common",
+ "target_path": "device/samsung/smdk4412-common"
+ },
+ {
+ "repository": "android_kernel_samsung_smdk4412",
+ "target_path": "kernel/samsung/smdk4412"
+ },
+ {
+ "repository": "android_hardware_samsung",
+ "target_path": "hardware/samsung"
+ }
+]
diff --git a/cm.mk b/cm.mk
new file mode 100644
index 0000000..4fc3092
--- /dev/null
+++ b/cm.mk
@@ -0,0 +1,25 @@
+# Specify phone tech before including full_phone
+$(call inherit-product, vendor/cm/config/gsm.mk)
+
+# Release name
+PRODUCT_RELEASE_NAME := i9305
+
+# Boot animation
+TARGET_SCREEN_HEIGHT := 1280
+TARGET_SCREEN_WIDTH := 720
+
+# Inherit some common CM stuff.
+$(call inherit-product, vendor/cm/config/common_full_phone.mk)
+
+# Inherit device configuration
+$(call inherit-product, device/samsung/i9305/full_i9305.mk)
+
+# Device identifier. This must come after all inclusions
+PRODUCT_DEVICE := i9305
+PRODUCT_NAME := cm_i9305
+PRODUCT_BRAND := samsung
+PRODUCT_MODEL := GT-I9305
+PRODUCT_MANUFACTURER := samsung
+
+# Set build fingerprint / ID / Product Name ect.
+PRODUCT_BUILD_PROP_OVERRIDES += PRODUCT_NAME=m3xx TARGET_DEVICE=m3 BUILD_FINGERPRINT="samsung/m3xx/m3:4.1.2/JZO54K/I9305XXBMA6:user/release-keys" PRIVATE_BUILD_DESC="m3xx-user 4.1.2 JZO54K I9305XXBMA6 release-keys"
diff --git a/configs/80cfw b/configs/80cfw
new file mode 100644
index 0000000..ba04436
--- /dev/null
+++ b/configs/80cfw
@@ -0,0 +1,10 @@
+#!/system/bin/sh
+#
+# Copy camera firmware to /data/cfw
+#
+
+busybox cp /system/vendor/firmware/SlimISP_GD.bin /data/cfw/SlimISP_GD.bin
+busybox cp /system/vendor/firmware/SlimISP_ZD.bin /data/cfw/SlimISP_ZD.bin
+busybox chown system /data/cfw/*
+busybox chgrp media /data/cfw/*
+busybox chmod 0775 /data/cfw/*
diff --git a/configs/gps.conf b/configs/gps.conf
new file mode 100644
index 0000000..6576285
--- /dev/null
+++ b/configs/gps.conf
@@ -0,0 +1,102 @@
+#Test
+NTP_SERVER=time.gpsonextra.net
+#Asia
+# NTP_SERVER=asia.pool.ntp.org
+#Europe
+# NTP_SERVER=europe.pool.ntp.org
+#North America
+# NTP_SERVER=north-america.pool.ntp.org
+
+XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
+XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
+XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
+
+# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
+# 4 - Debug, 5 - Verbose
+DEBUG_LEVEL = 4
+
+# Intermediate position report, 1=enable, 0=disable
+INTERMEDIATE_POS=0
+
+# supl version 1.0
+SUPL_VER=0x10000
+
+# Error Estimate
+# _SET = 1
+# _CLEAR = 0
+ERR_ESTIMATE=0
+
+# GPS Capabilities bit mask
+# SCHEDULING = 1
+# MSB = 2
+# MSA = 4
+# ULP = 0x20
+# ON_DEMAND_TIME = 0x10 // yunu.lee
+# default = MSA | MSB | SCHEDULING | ULP
+CAPABILITIES=0x16
+
+# Accuracy threshold for intermediate positions
+# less accurate positions are ignored, 0 for passing all positions
+# ACCURACY_THRES=5000
+
+################################
+##### AGPS server settings #####
+################################
+
+# FOR SUPL SUPPORT, set the following
+# SUPL_HOST=supl.host.com or IP
+# SUPL_PORT=1234
+
+# FOR C2K PDE SUPPORT, set the following
+# C2K_HOST=c2k.pde.com or IP
+# C2K_PORT=1234
+
+################################
+# Sensor Settings
+################################
+
+# Needs to be set explicitly based on sensor
+# There is no default value.
+GYRO_BIAS_RANDOM_WALK=0.00001
+
+# Sensor Sampling Rate Parameters for Low-Data Rate Filter (should be greater than 0)
+SENSOR_ACCEL_BATCHES_PER_SEC=3
+SENSOR_ACCEL_SAMPLES_PER_BATCH=5
+SENSOR_GYRO_BATCHES_PER_SEC=3
+SENSOR_GYRO_SAMPLES_PER_BATCH=5
+# Sensor Sampling Rate Parameters for High-Data Rate Filter (should be greater than 0)
+SENSOR_ACCEL_BATCHES_PER_SEC_HIGH=4
+SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH=25
+SENSOR_GYRO_BATCHES_PER_SEC_HIGH=4
+SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH=25
+
+# INS Filter Mode (0=Enable, 1=Disable)
+SENSOR_ALGORITHM_CONFIG_MASK=1
+
+# Sensor Control Mode (0=AUTO, 1=FORCE_ON)
+SENSOR_CONTROL_MODE=0
+
+# Enable or Disable Sensors for GPS use (0=Enable, 1=Disable)
+SENSOR_USAGE=0
+
+# Choose GSIFF sensor provider (1=DSPS, 2=Android NDK)
+SENSOR_PROVIDER=2
+
+################################
+# Indoor Positioning Settings
+################################
+# 0: QUIPC disabled, 1: QUIPC enabled, 2: forced QUIPC only
+QUIPC_ENABLED = 0
+
+################################
+# EXTRA SETTINGS
+################################
+# Enable or Disable Wiper (1=Enable, 0=Disable)
+ENABLE_WIPER=0
+
+####################################
+# LTE Positioning Profile Settings
+####################################
+# 0: Enable RRLP on LTE(Default) 1: Enable LPP_User_Plane on LTE
+LPP_PROFILE = 0
+
diff --git a/configs/nfcee_access.xml b/configs/nfcee_access.xml
new file mode 100644
index 0000000..02e12fd
--- /dev/null
+++ b/configs/nfcee_access.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Applications granted NFCEE access on user builds
+
+ See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+ -->
+
+ <!-- Google wallet release signature -->
+ <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+</resources>
diff --git a/configs/nfcee_access_debug.xml b/configs/nfcee_access_debug.xml
new file mode 100644
index 0000000..a96a2d1
--- /dev/null
+++ b/configs/nfcee_access_debug.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Applications granted NFCEE access on userdebug/eng builds
+
+ See packages/apps/Nfc/etc/sample_nfcee_access.xml for full documentation.
+ -->
+
+ <!-- Google Wallet dev signature -->
+ <signer android:signature="3082044c30820334a003020102020900de7695041d7650c0300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303332345a170d3338303830393031303332345a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100e6ff3defe92aa10d71eb0fa6408bc036b7e243eeed68a6a4763dc7a52a31757cdac61fe510bb73c716e4000104265b347fcecef4c42bf1e1379dd0a876f028227fbbc1f9bdd5d713b2f6a935a379d2cba9c96f92d2d0787c11f1eb19548008a6a072b34b91836cfa0ae1276780e9007530166986a11c9cef46cef7c704806dde9431fb60284d120ab0e7de1d633f07687d468c51139afffdc6bc9a207ca904b8be1da0aa7b4e97756f43606488be5cae3c68e8bb7942cdf51607c930a2fcda655b75d0759cba89ad06e739bd0ba29b1f404296c2c0a85a847f5ab0d067c6c3ec9c49212042ac63a7e53b546c65b46080b4e3e680e23e1f77cfe7f6de744b1a65020103a381dc3081d9301d0603551d0e04160414a2e89064b05d08865c34db930a9d840050117aec3081a90603551d230481a130819e8014a2e89064b05d08865c34db930a9d840050117aeca17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900de7695041d7650c0300c0603551d13040530030101ff300d06092a864886f70d010105050003820101003771870ce87c3c52ea84899230c6e962d94b4d5f1293c25d88261541fd90b5555d1285cef3b8312c3f5df691a8aae04cb981b305e427fd1d2d9e1987e1d29078f13c8452990f1821980263d8d4bd36519348d8d8ba26d8b99fbf09f5fd3ebb0ea3c2f0c9376f1e1fca76f3a6a405429d081b752a7a90b756e9ab44da41abc8e1e8f88ac2758da743fb73e650719a57840ccb6b7add21b99fc681e456e1872c223d5c074adf55f6abda268c2d8b64ea0a8845eecd968f92b493127e75c753c3ff30cbc678b51c9f52961472f17da20a0dc6274aa2463434c1a9b614df697d8ff5ca8101e7a25c7db3fb055d65569c04b01d389cabba57b3a1703ec2e74a88d334" />
+
+ <!-- Google wallet release signature -->
+ <signer android:signature="3082044c30820334a003020102020900a8cd17c93da5d990300d06092a864886f70d01010505003077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643301e170d3131303332343031303635335a170d3338303830393031303635335a3077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e464330820120300d06092a864886f70d01010105000382010d00308201080282010100c30f88add9b492096a2c586a5a9a80356bfa026958f8ff0c5dfaf59f49268ad870dee821a53e1f5b170fc96245a3c982a7cb4527053be35e34f396d24b2291ec0c528d6e26927465e06875ea621f7ff98c40e3345b204907cc9354743acdaace65565f48ba74cd4121cdc876df3522badb095c20d934c56a3e5c393ee5f0e02f8fe0621f918d1f35a82489252c6fa6b63392a7686b3e48612d06a9cf6f49bff11d5d96289c9dfe14ac5762439697dd29eafdb9810de3263513a905ac8e8eaf20907e46750a5ab7bf9a77262f47b03f5a3c6e6d7b51343f69c7f725f70bcc1b4ad592250b705a86e6e83ee2ae37fe5701bcbdb26feefdfff60f6a5bdfb5b64793020103a381dc3081d9301d0603551d0e041604141ccece0eea4dc1121fc7515f0d0a0c72e08cc96d3081a90603551d230481a130819e80141ccece0eea4dc1121fc7515f0d0a0c72e08cc96da17ba4793077310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f6964311330110603550403130a476f6f676c65204e4643820900a8cd17c93da5d990300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100a470c728e1d31b06d9af6ae768b565046c57806b9843724931d75d4ca10c321520d33ccfed2aa65462234c9ef9b6f910cc676b99cb7f9895d6c06763574fbb78331275dc5cf38fbaa918d7938c051ffba2ade8f303cde8d9e68a048d1fdb9e7c9f2a49b222c68fff422bf15569b85eeeedb04aa30873dbe64b9c9e74f8f2c2f6c40124aaa8d1780d18512b540add28b3e9581971a4170dd868cf5f31e44712b2c23bb51037d7ef9f87a6e5bdb35e2ceb6bb022636c17a56a96bc7a50258c0bd2ed7b31555a18452e17321a0d52838c82f63f742d74ff79586a5cbb7faf7198a84bcf744310e9e927597f00a23dd00660800c2238d90b2fb372dfdbba75bd852e" />
+
+ <!-- Platform dev-keys signature -->
+ <signer android:signature="308204a830820390a003020102020900bcdfe81405d5c69e300d06092a864886f70d0101050500308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d301e170d3131303931393230303634325a170d3339303230343230303634325a308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d30820120300d06092a864886f70d01010105000382010d00308201080282010100ef7a8a34d8151d0479a239903261fe5026c520d5d88cd65920c98e096d2770f49636da9ffc4e80c472b05bd62a435f8266912aa2a34a18f6f4856f9ef52c10b88c267627136726823e8f3389b051ba92920e10bbaae0e38879efbe681b05863b655d81a6f3b75a85eb230b38b23ea4ef56f2161ff01652ae2049881adbe60d3bf8b5386a81f7404c0cf0c111c0a35ab0a9760426e4af12add73327ec433e047e3517f47a2d3674c2b819354d56eb7fd6c9aa67dd05b4bb1ca8a7e1946c2494e9364ea677a25481ac81f434bff3dd56e93e59fccef0e24a753461cd1cf15f22b62251d07416057ac5ca3e03a24f7f4eca876bacc5a1828acbde04c5cfdb608c47020103a381fc3081f9301d0603551d0e0416041402f997668541fa74693bea699a5766893a362a5d3081c90603551d230481c13081be801402f997668541fa74693bea699a5766893a362a5da1819aa48197308194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d820900bcdfe81405d5c69e300c0603551d13040530030101ff300d06092a864886f70d0101050500038201010047d6fb32cadeae4444c379b3441ff9ba10990c23d10472c54fb7ebd9c33b2a173836337e1c175c980847a8894f6a99782e9c2e2133629254295fe52749f93ec1e39d213dd06d0ba99de3b6b5d4d856fafe74e08113b7b23a1b56f4918ed41218a03b9564456480b665200267d3770a9463db413c6a47bd81d725cb7d39c9d0941693c59cbe727d40415f0815c3c8363fb8fa2e028ceeb3bbfbc6b119db5b72f0edb0bb417bfcbf74d9fa069de22afe56a50bcde7ea1078749bb9ec0adc0e6de045641ee3a82c576645160b4ab9710d3cb3201f23957da8de9084c0bec93ad1c8c2054195f13c926db07c8bdf15673acf6d791ec1d3a0d7e1b3470447acd95873" />
+
+</resources>
diff --git a/configs/tiny_hw.xml b/configs/tiny_hw.xml
new file mode 100644
index 0000000..365f5d1
--- /dev/null
+++ b/configs/tiny_hw.xml
@@ -0,0 +1,353 @@
+<!-- TinyHAL configuration file for Samsung Galaxy S III -->
+<tinyhal>
+<!--
+We are able to have most of our routing static so do that
+-->
+<path>
+ <!-- don't change adc&dac source of AIF -->
+ <ctl name="AIF2DACL Source" val="0"/>
+ <ctl name="AIF2DACR Source" val="0"/>
+ <ctl name="AIF2ADCL Source" val="0"/>
+ <ctl name="AIF2ADCR Source" val="1"/>
+
+ <!-- AIF1->DAC1 -->
+ <ctl name="DAC1 Switch" val="1"/>
+
+ <ctl name="IN1L ZC Switch" val="0"/>
+ <ctl name="IN1R ZC Switch" val="0"/>
+ <ctl name="IN2L ZC Switch" val="0"/>
+ <ctl name="IN2R ZC Switch" val="0"/>
+ <ctl name="Output ZC Switch" val="0"/>
+ <ctl name="Speaker ZC Switch" val="0"/>
+ <ctl name="Headphone ZC Switch" val="0"/>
+
+ <!-- AIF1->DAC1 -->
+ <ctl name="DAC1L Mixer AIF1.1 Switch" val="1"/>
+ <ctl name="DAC1R Mixer AIF1.1 Switch" val="1"/>
+ <ctl name="DAC1 Switch" val="1"/>
+
+ <!-- ADC->AIF2 -->
+ <ctl name="AIF2DAC2L Mixer Left Sidetone Switch" val="1"/>
+ <ctl name="AIF2DAC2L Mixer Right Sidetone Switch" val="0"/>
+ <ctl name="AIF2DAC2R Mixer Left Sidetone Switch" val="0"/>
+ <ctl name="AIF2DAC2R Mixer Right Sidetone Switch" val="1"/>
+ <ctl name="DAC2 Left Sidetone Volume" val="12"/>
+ <ctl name="DAC2 Right Sidetone Volume" val="12"/>
+ <ctl name="DAC2 Switch" val="1"/>
+
+ <!-- DAC1->HP -->
+ <ctl name="Left Headphone Mux" val="Mixer"/>
+ <ctl name="Right Headphone Mux" val="Mixer"/>
+
+ <!-- DAC1->SPKL/R->SPKL/R Boost->SPK -->
+ <ctl name="SPKL DAC1 Switch" val="1"/>
+ <ctl name="SPKR DAC1 Switch" val="1"/>
+ <ctl name="SPKL Boost SPKL Switch" val="1"/>
+ <ctl name="SPKL Boost SPKR Switch" val="1"/>
+ <ctl name="SPKR Boost SPKL Switch" val="0"/>
+ <ctl name="SPKR Boost SPKR Switch" val="0"/>
+ <ctl name="Speaker Mixer Volume" val="3"/>
+
+ <!-- DAC->Output mixer->Earpiece -->
+ <ctl name="Left Output Mixer DAC Switch" val="1"/>
+ <ctl name="Right Output Mixer DAC Switch" val="1"/>
+ <ctl name="Earpiece Mixer Left Output Switch" val="1"/>
+ <ctl name="Earpiece Mixer Right Output Switch" val="1"/>
+ <ctl name="Earpiece Switch" val="1"/>
+
+ <!-- LINEOUT -->
+ <ctl name="LINEOUT2N Mixer Left Output Switch" val="1"/>
+ <ctl name="LINEOUT2P Mixer Right Output Switch" val="1"/>
+ <ctl name="LINEOUT1N Mixer Right Output Switch" val="1"/>
+ <ctl name="LINEOUT1P Mixer Left Output Switch" val="1"/>
+
+ <!-- Input mixer->ADC->AIF1.1 -->
+ <ctl name="AIF1ADC1L Mixer ADC/DMIC Switch" val="1"/>
+ <ctl name="AIF1ADC1R Mixer ADC/DMIC Switch" val="1"/>
+
+ <!-- Main Mic->IN1LP/N->Input Mixer with +30dB at mixer -->
+ <ctl name="IN1L PGA IN1LP Switch" val="1"/>
+ <ctl name="IN1L PGA IN1LN Switch" val="1"/>
+ <ctl name="MIXINL IN1L Volume" val="1"/>
+ <ctl name="IN1L Switch" val="1"/>
+
+ <!-- Sub Mic->IN1RP/N->Input Mixer with +30dB at mixer -->
+ <ctl name="IN1R PGA IN1RP Switch" val="1"/>
+ <ctl name="IN1R PGA IN1RN Switch" val="1"/>
+ <ctl name="MIXINR IN1R Volume" val="1"/>
+ <ctl name="IN1R Switch" val="1"/>
+
+ <!-- FM Radio->IN2RP/N->Input Mixer with +30dB at mixer -->
+ <ctl name="IN2R PGA IN2RP Switch" val="1"/>
+ <ctl name="IN2R PGA IN2RN Switch" val="1"/>
+ <ctl name="MIXINR IN2R Volume" val="1"/>
+ <ctl name="IN2R Switch" val="1"/>
+
+ <!-- Ear Mic->IN2LP/N->Input Mixer with +30dB at mixer -->
+ <ctl name="IN2L PGA IN2LP Switch" val="1"/>
+ <ctl name="IN2L PGA IN2LN Switch" val="1"/>
+ <ctl name="MIXINL IN2L Volume" val="1"/>
+ <ctl name="IN2L Switch" val="1"/>
+
+ <!-- Input mixer->ADC->AIF1 -->
+ <ctl name="AIF1ADC1L Mixer ADC/DMIC Switch" val="1"/>
+ <ctl name="AIF1ADC1R Mixer ADC/DMIC Switch" val="1"/>
+ <ctl name="ADCL Mux" val="ADC"/>
+
+ <!-- HPF on to take out some bounce -->
+ <ctl name="Sidetone HPF Switch" val="0"/>
+
+ <!-- Work around core issue -->
+ <ctl name="ADCL Mux" val="DMIC"/>
+ <ctl name="ADCL Mux" val="ADC"/>
+ <ctl name="ADCR Mux" val="DMIC"/>
+ <ctl name="ADCR Mux" val="ADC"/>
+
+ <!-- AIF2ADCDAT to AIF3ADC mux -->
+ <ctl name="AIF3ADC Mux" val="1"/>
+
+ <!-- Default all outputs off -->
+ <ctl name="HP Switch" val="0"/>
+ <ctl name="SPK Switch" val="0"/>
+ <ctl name="RCV Switch" val="0"/>
+ <ctl name="LINE Switch" val="0"/>
+ <ctl name="HDMI Switch" val="0"/>
+
+ <!-- Default all inputs off -->
+ <ctl name="Main Mic Switch" val="0"/>
+ <ctl name="Sub Mic Switch" val="0"/>
+ <ctl name="Headset Mic Switch" val="0"/>
+ <ctl name="FM In Switch" val="0"/>
+
+</path>
+<device name="speaker">
+ <path name="on">
+ <ctl name="SPK Switch" val="1"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="SPKL DAC1 Volume" val="1"/>
+ <ctl name="SPKR DAC1 Volume" val="1"/>
+ <ctl name="Speaker Mixer Volume" val="3"/>
+ <ctl name="Speaker Boost Volume" val="4"/>
+ <ctl name="Speaker Volume" val="57"/>
+ <ctl name="AIF1DAC1 EQ Switch" val="1"/>
+ <ctl name="AIF1DAC1 EQ1 Volume" val="9"/>
+ <ctl name="AIF1DAC1 EQ2 Volume" val="7"/>
+ <ctl name="AIF1DAC1 EQ3 Volume" val="10"/>
+ <ctl name="AIF1DAC1 EQ4 Volume" val="13"/>
+ <ctl name="AIF1DAC1 EQ5 Volume" val="12"/>
+ </path>
+ <path name="off">
+ <ctl name="SPK Switch" val="0"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="SPKL DAC1 Volume" val="1"/>
+ <ctl name="SPKR DAC1 Volume" val="1"/>
+ <ctl name="Speaker Mixer Volume" val="0"/>
+ <ctl name="Speaker Volume" val="0"/>
+ <ctl name="Speaker Boost Volume" val="0"/>
+ <ctl name="AIF1DAC1 EQ Switch" val="0"/>
+ </path>
+</device>
+<device name="earpiece">
+ <path name="on">
+ <ctl name="RCV Switch" val="1"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="Output Volume" val="57"/>
+ <ctl name="Earpiece Volume" val="1"/>
+ <ctl name="Speaker Mixer Volume" val="1"/>
+ </path>
+ <path name="off">
+ <ctl name="RCV Switch" val="0"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="Output Volume" val="57"/>
+ <ctl name="Earpiece Volume" val="1"/>
+ </path>
+</device>
+<device name="headphone">
+ <path name="on">
+ <ctl name="HP Switch" val="1"/>
+ <ctl name="Headphone Volume" val="50"/>
+ <ctl name="Headphone ZC Switch" val="0"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="AIF1DAC1 EQ Switch" val="1"/>
+ <ctl name="AIF1DAC1 EQ1 Volume" val="16"/>
+ <ctl name="AIF1DAC1 EQ2 Volume" val="14"/>
+ <ctl name="AIF1DAC1 EQ3 Volume" val="12"/>
+ <ctl name="AIF1DAC1 EQ4 Volume" val="14"/>
+ <ctl name="AIF1DAC1 EQ5 Volume" val="16"/>
+ </path>
+ <path name="off">
+ <ctl name="HP Switch" val="0"/>
+ <ctl name="AIF1DAC1 EQ Switch" val="0"/>
+ </path>
+</device>
+<device name="sco-out">
+ <path name="on">
+ <ctl name="AIF3ADC Mux" val="1"/>
+ <ctl name="AIF2DAC2L Mixer AIF1.1 Switch" val="1"/>
+ <ctl name="AIF2DAC2R Mixer AIF1.1 Switch" val="1"/>
+ <ctl name="AIF2DAC Volume" val="96"/>
+ <ctl name="DAC2 Volume" val="96"/>
+ <ctl name="AIF2ADC Volume" val="96"/>
+ <ctl name="Speaker Mixer Volume" val="1"/>
+ </path>
+ <path name="off">
+ <ctl name="AIF2DAC2L Mixer AIF1.1 Switch" val="0"/>
+ <ctl name="AIF2DAC2R Mixer AIF1.1 Switch" val="0"/>
+ <ctl name="Speaker Mixer Volume" val="1"/>
+ </path>
+</device>
+<device name="analog-dock">
+ <path name="on">
+ <ctl name="LINEOUT2N Switch" val="1"/>
+ <ctl name="LINEOUT2P Switch" val="1"/>
+ <ctl name="LINEOUT2N Mixer Left Output Switch" val="1"/>
+ <ctl name="LINEOUT2P Mixer Right Output Switch" val="1"/>
+ <ctl name="LINE Switch" val="1"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="Output Volume" val="55"/>
+ <ctl name="Earpiece Volume" val="1"/>
+ </path>
+ <path name="off">
+ <ctl name="LINEOUT2N Switch" val="0"/>
+ <ctl name="LINEOUT2P Switch" val="0"/>
+ <ctl name="LINE Switch" val="0"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="Left Output Mixer DAC Volume" val="7"/>
+ <ctl name="Right Output Mixer DAC Volume" val="7"/>
+ <ctl name="Output Volume" val="57"/>
+ <ctl name="LINEOUT2 Volume" val="1"/>
+ </path>
+</device>
+<device name="digital-dock">
+ <path name="on">
+ <ctl name="LINEOUT1N Switch" val="1"/>
+ <ctl name="LINEOUT1P Switch" val="1"/>
+ <ctl name="HDMI Switch" val="1"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ </path>
+ <path name="off">
+ <ctl name="LINEOUT1N Switch" val="1"/>
+ <ctl name="LINEOUT1P Switch" val="1"/>
+ <ctl name="HDMI Switch" val="1"/>
+ <ctl name="AIF1DAC1 Volume" val="96"/>
+ <ctl name="AIF1 Boost Volume" val="0"/>
+ <ctl name="DAC1 Volume" val="96"/>
+ <ctl name="SPKL DAC1 Volume" val="1"/>
+ <ctl name="SPKR DAC1 Volume" val="1"/>
+ <ctl name="Speaker Mixer Volume" val="0"/>
+ <ctl name="Speaker Boost Volume" val="0"/>
+ </path>
+</device>
+<device name="builtin-mic">
+ <path name="on">
+ <ctl name="Main Mic Switch" val="1"/>
+ <ctl name="MainMicBias Mode" val="1"/>
+ <ctl name="IN2L Volume" val="22"/>
+ <ctl name="MIXINL IN2L Switch" val="1"/>
+ <ctl name="MIXINL IN2L Volume" val="1"/>
+ <ctl name="AIF1ADCL Source" val="0"/>
+ <ctl name="AIF1ADC1 HPF Mode" val="0"/>
+ <ctl name="AIF1ADC1 HPF Switch" val="1"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ </path>
+ <path name="off">
+ <ctl name="Main Mic Switch" val="0"/>
+ <ctl name="MainMicBias Mode" val="0"/>
+ <ctl name="MIXINL IN2L Switch" val="0"/>
+ <ctl name="MIXINL IN2L Volume" val="0"/>
+ <ctl name="IN2L Volume" val="10"/>
+ </path>
+</device>
+<device name="back-mic">
+ <path name="on">
+ <ctl name="Sub Mic Switch" val="1"/>
+ <ctl name="SubMicBias Mode" val="1"/>
+ <ctl name="IN1R Volume" val="22"/>
+ <ctl name="MIXINR IN1R Switch" val="1"/>
+ <ctl name="MIXINR IN1R Volume" val="1"/>
+ <ctl name="AIF1ADCR Source" val="1"/>
+ <ctl name="AIF1ADC1 HPF Mode" val="1"/>
+ <ctl name="AIF1ADC1 HPF Switch" val="1"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ </path>
+ <path name="off">
+ <ctl name="Sub Mic Switch" val="0"/>
+ <ctl name="SubMicBias Mode" val="0"/>
+ <ctl name="MIXINR IN1R Switch" val="0"/>
+ <ctl name="IN1R Volume" val="10"/>
+ </path>
+</device>
+<device name="headset-in">
+ <path name="on">
+ <ctl name="MIXINL IN1L Switch" val="0"/>
+ <ctl name="Headset Mic Switch" val="1"/>
+ <ctl name="IN1L Volume" val="22"/>
+ <ctl name="MIXINL IN1L Switch" val="1"/>
+ <ctl name="MIXINL IN1L Volume" val="1"/>
+ <ctl name="AIF1ADC1 HPF Mode" val="1"/>
+ <ctl name="AIF1ADC1 HPF Switch" val="1"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ <ctl name="AIF1ADCL Source" val="0"/>
+ <ctl name="AIF1ADCR Source" val="0"/>
+ </path>
+ <path name="off">
+ <ctl name="Headset Mic Switch" val="0"/>
+ <ctl name="IN1L Volume" val="10"/>
+ <ctl name="MIXINL IN1L Switch" val="0"/>
+ <ctl name="MIXINL IN1L Volume" val="0"/>
+ <ctl name="AIF1ADC1 HPF Mode" val="0"/>
+ <ctl name="AIF1ADC1 HPF Switch" val="0"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ </path>
+</device>
+<device name="sco-in">
+ <path name="on">
+ <ctl name="AIF2ADC Mux" val="1"/>
+ <ctl name="AIF1ADC1R Mixer AIF2 Switch" val="1"/>
+ <ctl name="AIF1ADC1L Mixer AIF2 Switch" val="1"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ <ctl name="AIF2DAC Volume" val="96"/>
+ </path>
+ <path name="off">
+ <ctl name="AIF2ADC Mux" val="0"/>
+ <ctl name="AIF1ADC1R Mixer AIF2 Switch" val="0"/>
+ <ctl name="AIF1ADC1L Mixer AIF2 Switch" val="0"/>
+ <ctl name="AIF1ADC1 Volume" val="96"/>
+ <ctl name="AIF2DAC Volume" val="96"/>
+ </path>
+</device>
+<device name="fmradio">
+ <path name="on">
+ <ctl name="DAC1L Mixer AIF1.1 Switch" val="1"/>
+ <ctl name="DAC1L Mixer AIF1.1 Switch" val="1"/>
+ </path>
+ <path name="off">
+ <ctl name="MIXINL Output Record Volume" val="0"/>
+ <ctl name="MIXINR Output Record Volume" val="0"/>
+ </path>
+</device>
+</tinyhal>
diff --git a/extract-files.sh b/extract-files.sh
new file mode 100755
index 0000000..b65c3dd
--- /dev/null
+++ b/extract-files.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT
+
+VENDOR=samsung
+DEVICE=i9305
+
+mkdir -p ../../../vendor/$VENDOR/$DEVICE/proprietary
+
+adb root
+adb wait-for-device
+
+echo "Pulling proprietary files..."
+for FILE in `cat proprietary-files.txt | grep -v ^# | grep -v ^$`; do
+ DIR=`dirname $FILE`
+ if [ ! -d ../../../vendor/$VENDOR/$DEVICE/proprietary/$DIR ]; then
+ mkdir -p ../../../vendor/$VENDOR/$DEVICE/proprietary/$DIR
+ fi
+ adb pull /$FILE ../../../vendor/$VENDOR/$DEVICE/proprietary/$FILE
+done
+
+
+(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__VENDOR__/$VENDOR/g > ../../../vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := vendor/__VENDOR__/__DEVICE__
+
+PRODUCT_COPY_FILES += \\
+EOF
+
+LINEEND=" \\"
+COUNT=`cat proprietary-files.txt | grep -v ^# | grep -v ^$ | wc -l | awk {'print $1'}`
+for FILE in `cat proprietary-files.txt | grep -v ^# | grep -v ^$`; do
+ COUNT=`expr $COUNT - 1`
+ if [ $COUNT = "0" ]; then
+ LINEEND=""
+ fi
+ echo " \$(LOCAL_PATH)/proprietary/$FILE:$FILE$LINEEND" >> ../../../vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk
+done
+
+(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__VENDOR__/$VENDOR/g > ../../../vendor/$VENDOR/$DEVICE/$DEVICE-vendor.mk
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Pick up overlay for features that depend on non-open-source files
+DEVICE_PACKAGE_OVERLAYS += vendor/__VENDOR__/__DEVICE__/overlay
+
+\$(call inherit-product, vendor/__VENDOR__/__DEVICE__/__DEVICE__-vendor-blobs.mk)
+EOF
+
+(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__VENDOR__/$VENDOR/g > ../../../vendor/$VENDOR/$DEVICE/BoardConfigVendor.mk
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+EOF
+
+./../../../device/samsung/smdk4412-common/extract-files.sh
diff --git a/full_i9305.mk b/full_i9305.mk
new file mode 100644
index 0000000..9e02ef2
--- /dev/null
+++ b/full_i9305.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This file is the build configuration for a full Android
+# build for toro hardware. This cleanly combines a set of
+# device-specific aspects (drivers) with a device-agnostic
+# product configuration (apps). Except for a few implementation
+# details, it only fundamentally contains two inherit-product
+# lines, full and toro, hence its name.
+#
+
+# Inherit from those products. Most specific first.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+# This is where we'd set a backup provider if we had one
+#$(call inherit-product, device/sample/products/backup_overlay.mk)
+$(call inherit-product, device/samsung/i9305/i9305.mk)
+
+# Discard inherited values and use our own instead.
+PRODUCT_NAME := full_i9305
+PRODUCT_DEVICE := i9305
+PRODUCT_BRAND := samsung
+PRODUCT_MANUFACTURER := samsung
+PRODUCT_MODEL := GT-I9305
diff --git a/i9305.mk b/i9305.mk
new file mode 100644
index 0000000..81bf693
--- /dev/null
+++ b/i9305.mk
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2013 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := device/samsung/i9305
+
+# Overlay
+DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay
+
+# This device is xhdpi. However the platform doesn't
+# currently contain all of the bitmaps at xhdpi density so
+# we do this little trick to fall back to the hdpi version
+# if the xhdpi doesn't exist.
+PRODUCT_AAPT_CONFIG := normal hdpi xhdpi
+PRODUCT_AAPT_PREF_CONFIG := xhdpi
+
+# Init files
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/rootdir/fstab.smdk4x12:root/fstab.smdk4x12 \
+ $(LOCAL_PATH)/rootdir/init.smdk4x12.rc:root/init.smdk4x12.rc \
+ $(LOCAL_PATH)/rootdir/lpm.rc:root/lpm.rc \
+ $(LOCAL_PATH)/rootdir/ueventd.smdk4x12.rc:root/ueventd.smdk4x12.rc
+
+# Audio
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/tiny_hw.xml:system/etc/sound/m3
+
+# Gps
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/gps.conf:system/etc/gps.conf
+
+# Camera FW
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/80cfw:system/etc/init.d/80cfw
+
+# Product specific Packages
+PRODUCT_PACKAGES += \
+ GalaxyS3Settings
+
+# NFC
+PRODUCT_PACKAGES += \
+ nfc.exynos4 \
+ libnfc \
+ libnfc_jni \
+ Nfc \
+ Tag
+
+PRODUCT_COPY_FILES += \
+ packages/apps/Nfc/migrate_nfc.txt:system/etc/updatecmds/migrate_nfc.txt \
+ frameworks/base/nfc-extras/com.android.nfc_extras.xml:system/etc/permissions/com.android.nfc_extras.xml \
+ frameworks/native/data/etc/android.hardware.nfc.xml:system/etc/permissions/android.hardware.nfc.xml
+
+# NFCEE access control
+ifeq ($(TARGET_BUILD_VARIANT),user)
+ NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access.xml
+else
+ NFCEE_ACCESS_PATH := $(LOCAL_PATH)/configs/nfcee_access_debug.xml
+endif
+
+PRODUCT_COPY_FILES += \
+ $(NFCEE_ACCESS_PATH):system/etc/nfcee_access.xml
+
+PRODUCT_PACKAGES += \
+ com.android.nfc_extras
+
+$(call inherit-product, vendor/cm/config/nfc_enhanced.mk)
+
+# RIL
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.telephony.ril_class=SamsungQualcommD2RIL \
+ telephony.lteOnGsmDevice=1 \
+ mobiledata.interfaces=pdp0,wlan0,gprs,ppp0 \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10
+
+# These are the hardware-specific features
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \
+ frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml
+
+# Include common makefile
+$(call inherit-product, device/samsung/smdk4412-common/common.mk)
+
+$(call inherit-product-if-exists, vendor/samsung/i9305/i9305-vendor.mk)
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
new file mode 100644
index 0000000..7ac03e4
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+ <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
+ autodetected from the Configuration. -->
+ <bool name="config_showNavigationBar">false</bool>
+
+ <!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION.
+ Please don't copy them, copy anything else. -->
+
+ <!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
+ [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
+ <!-- the 5th element "resore-time" indicates the number of milliseconds to delay
+ before automatically restore the default connection. Set -1 if the connection
+ does not require auto-restore. -->
+ <!-- the 6th element indicates boot-time dependency-met value. -->
+ <string-array translatable="false" name="networkAttributes">
+ <item>"wifi,1,1,1,-1,true"</item>
+ <item>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,true"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,0,3,60000,true"</item>
+ <item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"mobile_bluetooth,7,7,1,-1,true"</item>
+ <item>"wifi_p2p,13,1,0,-1,true"</item>
+ </string-array>
+
+ <!-- An Array of "[ConnectivityManager connectionType],
+ [# simultaneous connection types]" -->
+ <string-array translatable="false" name="radioAttributes">
+ <item>"1,1"</item>
+ <item>"0,1"</item>
+ <item>"7,1"</item>
+ </string-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ USB interfaces. If the device doesn't want to support tething over USB this should
+ be empty. An example would be "usb.*" -->
+ <string-array translatable="false" name="config_tether_usb_regexs">
+ <item>"rndis0"</item>
+ </string-array>
+
+ <!-- Array of ConnectivityManager.TYPE_xxxx values allowable for tethering -->
+ <!-- Common options are [1, 4] for TYPE_WIFI and TYPE_MOBILE_DUN or
+ <!== [0,1,5,7] for TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI and TYPE_BLUETOOTH -->
+ <integer-array translatable="false" name="config_tether_upstream_types">
+ <item>0</item>
+ <item>1</item>
+ <item>5</item>
+ <item>7</item>
+ </integer-array>
+
+ <!-- The default iface on which to monitor data use -->
+ <string name="config_datause_iface">pdp0</string>
+
+ <!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveNotificationLed">true</bool>
+
+ <!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
+ <bool name="config_intrusiveBatteryLed">true</bool>
+
+ <!-- Does the battery LED support multiple colors? Used to decide if the user can change the colors -->
+ <bool name="config_multiColorBatteryLed">true</bool>
+
+ <!-- Default color for notification LED is white. -->
+ <color name="config_defaultNotificationColor">#ffffffff</color>
+
+ <!-- Default LED on time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOn">1000</integer>
+
+ <!-- Default LED off time for notification LED in milliseconds. -->
+ <integer name="config_defaultNotificationLedOff">9000</integer>
+
+ <!-- Allow the menu hard key to be disabled in LockScreen on some devices -->
+ <bool name="config_disableMenuKeyInLockScreen">true</bool>
+
+ <!-- Disable the home key unlock setting -->
+ <bool name="config_disableHomeUnlockSetting">false</bool>
+
+ <!-- Workaround for devices with broken keyboards -->
+ <bool name="config_forceDisableHardwareKeyboard">true</bool>
+
+ <!-- Hardware 'face' keys present on the device, stored as a bit field.
+ This integer should equal the sum of the corresponding value for each
+ of the following keys present:
+ 1 - Home
+ 2 - Back
+ 4 - Menu
+ 8 - Assistant (search)
+ 16 - App switch
+ For example, a device with Home, Back and Menu keys would set this
+ config to 7. -->
+ <integer name="config_deviceHardwareKeys">7</integer>
+
+ <!-- Boolean to enable stk functionality on Samsung phones -->
+ <bool name="config_samsung_stk">true</bool>
+
+</resources>
diff --git a/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/overlay/frameworks/base/core/res/res/xml/power_profile.xml
new file mode 100644
index 0000000..3501baa
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/xml/power_profile.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License")
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<device name="Android">
+ <!-- All values are in mAh except as noted -->
+ <item name="none">0</item>
+ <item name="screen.on">71</item>
+ <item name="bluetooth.active">17</item>
+ <item name="bluetooth.on">0.3</item>
+ <item name="bluetooth.at">35690</item>
+ <item name="screen.full">380</item>
+ <item name="wifi.on">0.3</item>
+ <item name="wifi.active">96</item>
+ <item name="wifi.scan">70</item>
+ <item name="dsp.audio">44</item>
+ <item name="dsp.video">280</item>
+ <item name="radio.active">250</item>
+ <!-- The current consumed by the radio when it is scanning for a signal -->
+ <item name="radio.scanning">82</item>
+ <item name="gps.on">50</item>
+ <!-- Current consumed by the radio at different signal strengths, when paging -->
+ <array name="radio.on"> <!-- Strength 0 to BINS-1 -->
+ <value>3.4</value>
+ <value>3.4</value>
+ </array>
+ <!-- Different CPU speeds as reported in
+ /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state -->
+ <array name="cpu.speeds">
+ <value>200000</value>
+ <value>500000</value>
+ <value>800000</value>
+ <value>1000000</value>
+ <value>1200000</value>
+ <value>1400000</value>
+ <value>1600000</value>
+ </array>
+ <!-- Power consumption when CPU is idle -->
+ <item name="cpu.idle">4</item>
+ <!-- Power consumption due to wake lock held -->
+ <item name="cpu.awake">44</item>
+ <!-- Power consumption at different speeds -->
+ <array name="cpu.active">
+ <value>55.4</value>
+ <value>82.1</value>
+ <value>113.7</value>
+ <value>140.0</value>
+ <value>170.0</value>
+ <value>200.0</value>
+ <value>230.0</value>
+ </array>
+ <!-- This is the battery capacity in mAh -->
+ <item name="battery.capacity">3100</item>
+</device>
diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
new file mode 100644
index 0000000..d9247c5
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License")
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- The <device> element should contain one or more <storage> elements.
+ Exactly one of these should have the attribute primary="true".
+ This storage will be the primary external storage and should have mountPoint="/mnt/sdcard".
+ Each storage should have both a mountPoint and storageDescription attribute.
+ The following attributes are optional:
+
+ primary: (boolean) this storage is the primary external storage
+ removable: (boolean) this is removable storage (for example, a real SD card)
+ emulated: (boolean) the storage is emulated via the FUSE sdcard daemon
+ mtpReserve: (integer) number of megabytes of storage MTP should reserve for free storage
+ (used for emulated storage that is shared with system's data partition)
+
+ A storage should not have both emulated and removable set to true
+-->
+
+<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
+ <storage android:mountPoint="/storage/sdcard0"
+ android:storageDescription="@string/storage_internal"
+ android:primary="true"
+ android:emulated="true"
+ android:mtpReserve="100" />
+
+ <storage android:mountPoint="/storage/sdcard1"
+ android:storageDescription="@string/storage_sd_card"
+ android:primary="false"
+ android:removable="true"
+ android:allowMassStorage="true" />
+
+ <storage android:mountPoint="/storage/usbdisk0"
+ android:storageDescription="@string/storage_usb"
+ android:primary="false"
+ android:removable="true" />
+</StorageList>
diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
new file mode 100644
index 0000000..88851f7
--- /dev/null
+++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, The CyanogenMod Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+ <!-- Control whether status bar should distinguish HSPA data icon form UMTS data icon on devices -->
+ <bool name="config_hspa_data_distinguishable">true</bool>
+</resources>
+
diff --git a/overlay/packages/apps/Phone/res/values/config.xml b/overlay/packages/apps/Phone/res/values/config.xml
new file mode 100644
index 0000000..35eae87
--- /dev/null
+++ b/overlay/packages/apps/Phone/res/values/config.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Phone app resources that may need to be customized
+ for different hardware or product builds. -->
+<resources>
+ <!-- Determines if device implements a noise suppression device for in call audio-->
+ <bool name="has_in_call_noise_suppression">true</bool>
+
+ <!-- Audio parameter for setting noise suppression-->
+ <string name="in_call_noise_suppression_audioparameter">noise_suppression=true=false</string>
+
+ <!-- Determine whether calls to mute the microphone in PhoneUtils
+ are routed through the android.media.AudioManager class (true) or through
+ the com.android.internal.telephony.Phone interface (false). -->
+ <bool name="send_mic_mute_to_AudioManager">true</bool>
+</resources>
diff --git a/overlay/packages/apps/Torch/res/values/config.xml b/overlay/packages/apps/Torch/res/values/config.xml
new file mode 100644
index 0000000..d4611e2
--- /dev/null
+++ b/overlay/packages/apps/Torch/res/values/config.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, The CyanogenMod Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+ <!-- If there is no sysfs-based control mechanism, enable this -->
+ <bool name="useCameraInterface">false</bool>
+
+ <!-- Full path to the sysfs toggle -->
+ <string name="flashDevice">/sys/class/camera/flash/rear_flash</string>
+
+ <!-- Lowest setting -->
+ <integer name="valueOn">1</integer>
+ <!-- Middle setting -->
+ <integer name="valueHigh">10</integer>
+ <!-- Highest setting, leave -1 if it doesn't exist -->
+ <integer name="valueDeathRay">15</integer>
+
+</resources>
diff --git a/proprietary-files.txt b/proprietary-files.txt
new file mode 100644
index 0000000..ce78ef5
--- /dev/null
+++ b/proprietary-files.txt
@@ -0,0 +1,49 @@
+system/bin/at_distributor
+system/bin/efsks
+system/bin/gsiff_daemon
+system/bin/ks
+system/bin/netmgrd
+system/bin/qcks
+system/bin/qmiproxy
+system/bin/qmuxd
+system/bin/rild
+system/bin/sec-ril
+system/bin/smdexe
+system/etc/Diag.cfg
+system/etc/Diag_zero.cfg
+system/lib/libakm.so
+system/lib/libatparser.so
+system/lib/libcsd-client.so
+system/lib/libdiag.so
+system/lib/libdsi_netctrl.so
+system/lib/libdsutils.so
+system/lib/libfactoryutil.so
+system/lib/libgps.so
+system/lib/libgps.utils.so
+system/lib/libidl.so
+system/lib/libloc_adapter.so
+system/lib/libloc_api_v02.so
+system/lib/libloc_eng.so
+system/lib/libnetmgr.so
+system/lib/libomission_avoidance.so
+system/lib/libqcci_legacy.so
+system/lib/libqdi.so
+system/lib/libqdp.so
+system/lib/libqmi.so
+system/lib/libqmi_cci.so
+system/lib/libqmi_client_qmux.so
+system/lib/libqmi_common_so.so
+system/lib/libqmi_csi.so
+system/lib/libqmi_encdec.so
+system/lib/libqmiservices.so
+system/lib/libril.so
+system/lib/libril-qc-qmi-1.so
+system/lib/libril-qcril-hook-oem.so
+system/lib/libsecnativefeature.so
+system/lib/libsecril-client.so
+system/lib/hw/vendor-camera.exynos4.so
+system/lib/hw/gps.default.so
+system/lib/hw/sensors.smdk4x12.so
+system/usr/keylayout/sec_touchkey.kl
+system/vendor/firmware/SlimISP_GD.bin
+system/vendor/firmware/SlimISP_ZD.bin
diff --git a/recovery.fstab b/recovery.fstab
new file mode 100644
index 0000000..14e7e67
--- /dev/null
+++ b/recovery.fstab
@@ -0,0 +1,12 @@
+# mount point fstype device device2
+/efs ext4 /dev/block/mmcblk0p3
+/boot emmc /dev/block/mmcblk0p8
+/recovery emmc /dev/block/mmcblk0p9
+/cache ext4 /dev/block/mmcblk0p12
+/system ext4 /dev/block/mmcblk0p13
+/data ext4 /dev/block/mmcblk0p16 length=-16384
+/preload ext4 /dev/block/mmcblk0p14
+/modem emmc /dev/block/mmcblk0p10
+
+/sdcard datamedia /dev/null
+/external_sd vfat /dev/block/mmcblk1p1
diff --git a/rootdir/fstab.smdk4x12 b/rootdir/fstab.smdk4x12
new file mode 100644
index 0000000..d4c03f3
--- /dev/null
+++ b/rootdir/fstab.smdk4x12
@@ -0,0 +1,11 @@
+# Android fstab file.
+#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
+# The filesystem that contains the filesystem checker binary (typically /system) cannot
+# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
+# data partition must be located at the bottom for supporting device encryption
+
+/dev/block/mmcblk0p13 /system ext4 ro wait
+/dev/block/mmcblk0p3 /efs ext4 noatime,nosuid,nodev,journal_async_commit,errors=panic wait,check
+/dev/block/mmcblk0p12 /cache ext4 noatime,nosuid,nodev,journal_async_commit,errors=panic wait,check
+/dev/block/mmcblk0p16 /data ext4 noatime,nosuid,nodev,discard,noauto_da_alloc,journal_async_commit,errors=panic wait,check,encryptable=footer
+/dev/block/mmcblk0p11 /tombstones ext4 noatime,nosuid,nodev,journal_async_commit,errors=panic wait,check
diff --git a/rootdir/init.smdk4x12.rc b/rootdir/init.smdk4x12.rc
new file mode 100755
index 0000000..936e87a
--- /dev/null
+++ b/rootdir/init.smdk4x12.rc
@@ -0,0 +1,609 @@
+import init.smdk4x12.usb.rc
+import init.bt.rc
+
+on init
+ mkdir /mnt/shell/emulated 0700 shell shell
+ mkdir /storage 0550 system sdcard_r
+ mkdir /storage/emulated 0555 root root
+ mkdir /storage/sdcard1 0775 system system
+ mkdir /storage/usbdisk0 0775 system system
+
+ export EXTERNAL_STORAGE /storage/emulated/legacy
+ export SECONDARY_STORAGE /storage/sdcard1
+ export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
+ export EMULATED_STORAGE_TARGET /storage/emulated
+
+ # for backwards compatibility
+ symlink /storage/emulated/legacy /sdcard
+ symlink /storage/emulated/legacy /mnt/sdcard
+ symlink /storage/emulated/legacy /storage/sdcard0
+ symlink /mnt/shell/emulated/0 /storage/emulated/legacy
+ symlink /storage/sdcard1 /extSdCard
+ symlink /storage/sdcard1 /mnt/extSdCard
+ symlink /storage/usbdisk0 /usbdisk0
+ symlink /storage/usbdisk0 /mnt/usbdisk0
+
+ mkdir /efs 0771 radio system
+ mkdir /tombstones
+ symlink /efs /factory
+
+# ko files for FM Radio
+ insmod /system/lib/modules/Si4709_driver.ko
+
+on init
+ # WFD CES Demo
+ chmod 0666 /dev/graphics/fb5
+
+ # Vibetonz
+ export VIBE_PIPE_PATH /dev/pipes
+ mkdir /dev/pipes 0771 shell shell
+
+on fs
+ mount_all /fstab.smdk4x12
+
+ setprop ro.crypto.fuse_sdcard true
+
+ chown radio system /efs
+ chmod 0771 /efs
+
+#MDM requirement
+ mkdir /firmware 0771 system system
+ mount vfat /dev/block/mmcblk0p10 /firmware ro shortname=lower fmask=0133,dmask=0022
+ chown system system /tombstones
+ chmod 0775 /tombstones
+ mkdir /tombstones/modem 0775 system system
+ mkdir /tombstones/lpass 0775 system system
+ mkdir /tombstones/wcnss 0775 system system
+ mkdir /tombstones/dsps 0775 system system
+ rmdir /tombstones/qcks
+ mkdir /tombstones/qcks 771 system system
+ rmdir /tombstones/efs
+ mkdir /tombstones/efs 771 system system
+
+ chown system radio /dev/block/platform/dw_mmc/by-name
+ chmod 0775 /dev/block/platform/dw_mmc/by-name
+
+on post-fs-data
+ # we will remap this as /mnt/sdcard with the sdcard fuse tool
+ mkdir /data/media 0775 media_rw media_rw
+ chown media_rw media_rw /data/media
+
+#QCRIL
+
+ #Create QMUX deamon socket area
+ mkdir /dev/socket/qmux_radio 0770 radio radio
+ chmod 2770 /dev/socket/qmux_radio
+ mkdir /dev/socket/qmux_audio 0770 media audio
+ chmod 2770 /dev/socket/qmux_audio
+ mkdir /dev/socket/qmux_gps 0770 gps gps
+ chmod 2770 /dev/socket/qmux_gps
+
+ # Allow QMUX daemon to assign port open wait time
+ chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
+
+ # To prevent out of order acknowledgements from making
+ # connection tracking to treat them as not belonging to
+ # the connection they belong to.
+ # Otherwise, a weird issue happens in which some long
+ # connections on high-throughput links get dropped when
+ # an ack packet comes out of order
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1
+
+# for AT distributor
+ chown system radio /sys/module/cpuidle_exynos4/parameters/enable_mask
+ chmod 0664 /sys/module/cpuidle_exynos4/parameters/enable_mask
+
+# Waketime fot fast dormancy
+ chown system radio /sys/devices/platform/mdm_hsic_pm0/waketime
+ chmod 0660 /sys/devices/platform/mdm_hsic_pm0/waketime
+
+# data/log
+ mkdir /data/log 0775 system log
+ chown system log /data/log
+ chmod 0775 /data/log
+ chmod 0775 /data/anr
+
+ # create data/gps for GPS demon
+ chown root system /dev/ttySAC1
+ chmod 0660 /dev/ttySAC1
+ chown root system /sys/class/sec/gps/GPS_PWR_EN/value
+ chmod 0664 /sys/class/sec/gps/GPS_PWR_EN/value
+ chown root system /sys/class/sec/gps/GPS_nRST/value
+ chmod 0664 /sys/class/sec/gps/GPS_nRST/value
+ mkdir /data/gps 771 system system
+ chown system system /data/gps
+
+ mkdir /data/misc/radio 0775 radio system
+ chmod 0775 /data/misc/radio
+ mkdir /efs/imei 0775 radio system
+
+# HDCP 2.x
+ mkdir /data/system/hdcp2 0775 system system
+
+# h2k permission
+ chmod 0644 /efs/redata.bin
+ chmod 0644 /efs/h2k.dat
+
+# Camera firmware
+ mkdir /data/cfw 0775 system system
+ chown system media /data/cfw/SlimISP_GD.bin
+ chmod 0775 /data/cfw/SlimISP_GD.bin
+ chown system media /data/cfw/SlimISP_ZD.bin
+ chmod 0775 /data/cfw/SlimISP_ZD.bin
+
+# Camera
+ chown system radio /sys/class/camera/rear/rear_camfw
+ chown system radio /sys/class/camera/rear/rear_camtype
+ chown system radio /sys/class/camera/rear/rear_flash
+ chmod 0666 /sys/class/camera/flash/rear_flash
+ chown system radio /sys/class/camera/rear/isp_core
+ chown system radio /sys/class/camera/front/front_camfw
+ chown system radio /sys/class/camera/front/front_camtype
+ chown system radio /sys/class/camera/flash/rear_flash
+ chown radio system /sys/devices/platform/samsung-pd.5/s3c-fimc.2/range_mode
+ chmod 0660 /sys/devices/platform/samsung-pd.5/s3c-fimc.2/range_mode
+ write /data/ISP_CV 1
+
+ symlink /dev/block/mmcblk0p7 /dev/block/param
+
+# Permissions for bluetooth
+ setprop ro.bt.bdaddr_path "/efs/bluetooth/bt_addr"
+ chown bluetooth bluetooth ro.bt.bdaddr_path
+ chown bluetooth bluetooth /dev/ttySAC0
+ chmod 0600 /dev/ttySAC0
+ chmod 0660 /sys/class/rfkill/rfkill0/state
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
+
+# NFC
+ setprop ro.nfc.port "I2C"
+ chmod 0600 /dev/pn544
+ chown nfc nfc /dev/pn544
+
+# Vibrator
+ chmod 0660 /dev/tspdrv
+ chown root shell /dev/tspdrv
+ chmod 0660 /sys/vibrator/pwm_val
+ chown system system /sys/vibrator/pwm_val
+
+# LED
+ chmod 0660 /sys/class/sec/led/led_fade
+ chown system system /sys/class/sec/led/led_fade
+
+# Touchkey
+ chmod 0660 /sys/class/sec/sec_touchkey/timeout
+ chown system system /sys/class/sec/sec_touchkey/timeout
+ chmod 0660 /sys/class/sec/sec_touchkey/force_disable
+ chown system system /sys/class/sec/sec_touchkey/force_disable
+
+# Permissions for LCD
+ chown system radio /sys/class/lcd/panel/lcd_power
+ chown system radio /sys/class/lcd/panel/lcd_type
+ chown system radio /sys/class/lcd/panel/device/hs_toggle
+ chown system media_rw /sys/class/lcd/panel/power_reduce
+ chown system system /sys/class/backlight/panel/auto_brightness
+ chown system system /sys/class/backlight/panel/brightness
+ chown system system /sys/class/graphics/fb0/lcdfreq/level
+
+# Permissions for mDNIe
+ chown system media_rw /sys/class/mdnie/mdnie/mode
+ chown system media_rw /sys/class/mdnie/mdnie/outdoor
+ chown system media_rw /sys/class/mdnie/mdnie/scenario
+ chown system system /sys/class/mdnie/mdnie/negative
+ write /sys/class/mdnie/mdnie/scenario 0
+ write /sys/class/mdnie/mdnie/mode 0
+
+# Permissions for System Server and daemons.
+ chown radio system /sys/android_power/state
+ chown radio system /sys/android_power/request_state
+ chown radio system /sys/android_power/acquire_full_wake_lock
+ chown radio system /sys/android_power/acquire_partial_wake_lock
+ chown radio system /sys/android_power/release_wake_lock
+ chown radio system /sys/power/state
+ chown radio system /sys/power/wake_lock
+ chown radio system /sys/power/wake_unlock
+ chown radio system /sys/power/cpufreq_table
+ chown radio system /sys/power/cpufreq_max_limit
+ chown radio system /sys/power/cpufreq_min_limit
+ chown radio system /sys/power/mali_lock
+ chown radio system /sys/class/power_supply/battery/siop_activated
+ chown radio system /sys/devices/system/cpu/cpufreq/pegasusq/max_cpu_lock
+ chown radio system /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_lock
+ chown radio system /sys/devices/system/cpu/busfreq/curr_freq
+ chown radio system /sys/module/mali/parameters/mali_dvfs_control
+ chown system radio /sys/bus/platform/devices/s5p-tmu/lot_id
+ chmod 0660 /sys/power/state
+ chmod 0660 /sys/power/wake_lock
+ chmod 0660 /sys/power/wake_unlock
+ chmod 0660 /sys/power/cpufreq_table
+ chmod 0660 /sys/power/cpufreq_max_limit
+ chmod 0660 /sys/power/cpufreq_min_limit
+ chmod 0660 /sys/power/mali_lock
+ chmod 0660 /sys/class/power_supply/battery/siop_activated
+ chmod 0660 /sys/devices/system/cpu/cpufreq/pegasusq/max_cpu_lock
+ chmod 0660 /sys/devices/system/cpu/cpufreq/pegasusq/hotplug_lock
+ chmod 0660 /sys/devices/system/cpu/busfreq/curr_freq
+ chmod 0660 /sys/module/mali/parameters/mali_dvfs_control
+ chmod 0664 /sys/bus/platform/devices/s5p-tmu/lot_id
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/class/leds/keyboard-backlight/brightness
+ chown system system /sys/class/leds/lcd-backlight/brightness
+ chown system system /sys/class/backlight/panel/brightness
+ chown system system /sys/class/leds/button-backlight/brightness
+ chown system system /sys/class/sec/sec_touchkey/brightness
+ chown system system /sys/class/leds/jogball-backlight/brightness
+ chown system system /sys/class/leds/red/brightness
+ chown system system /sys/class/leds/green/brightness
+ chown system system /sys/class/leds/blue/brightness
+ chown system system /sys/class/leds/red/device/grpfreq
+ chown system system /sys/class/leds/red/device/grppwm
+ chown system system /sys/class/leds/red/device/blink
+ chown system system /sys/class/leds/red/brightness
+ chown system system /sys/class/leds/green/brightness
+ chown system system /sys/class/leds/blue/brightness
+ chown system system /sys/class/leds/red/device/grpfreq
+ chown system system /sys/class/leds/red/device/grppwm
+ chown system system /sys/class/leds/red/device/blink
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/module/sco/parameters/disable_esco
+ chown system system /sys/kernel/ipv4/tcp_wmem_min
+ chown system system /sys/kernel/ipv4/tcp_wmem_def
+ chown system system /sys/kernel/ipv4/tcp_wmem_max
+ chown system system /sys/kernel/ipv4/tcp_rmem_min
+ chown system system /sys/kernel/ipv4/tcp_rmem_def
+ chown system system /sys/kernel/ipv4/tcp_rmem_max
+ chown root radio /proc/cmdline
+
+# Audio (Earjack)
+ chown system radio /sys/class/audio/earjack/select_jack
+ chown system radio /sys/class/audio/earjack/key_state
+ chown system radio /sys/class/audio/earjack/state
+ chown media system /sys/class/audio/earjack/reselect_jack
+
+# Battery node
+ chown system radio /sys/class/power_supply/battery/batt_reset_soc
+ chown system radio /sys/class/power_supply/battery/batt_read_raw_soc
+ chown system radio /sys/class/power_supply/battery/batt_read_adj_soc
+ chown system radio /sys/class/power_supply/battery/batt_type
+ chown system radio /sys/class/power_supply/battery/batt_temp_adc
+ chown system radio /sys/class/power_supply/battery/batt_temp_aver
+ chown system radio /sys/class/power_supply/battery/batt_temp_adc_aver
+ chown system radio /sys/class/power_supply/battery/batt_vfocv
+ chown system radio /sys/class/power_supply/battery/batt_lp_charging
+ chown system radio /sys/class/power_supply/battery/batt_charging_source
+ chown system radio /sys/class/power_supply/battery/test_mode
+ chown system radio /sys/class/power_supply/battery/wc_status
+ chown system radio /sys/class/power_supply/battery/wpc_pin_state
+
+# Thermistor node
+ chown radio system /sys/devices/platform/sec-thermistor/temp_adc
+ chown radio system /sys/devices/platform/sec-thermistor/temperature
+
+# Permissions for touch
+ chown system radio /sys/class/sec/tsp/cmd
+
+# Permissions for Touchkey
+ chown system radio /sys/class/sec/sec_touchkey/enable_disable
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_brightness
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_menu
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_back
+ chown system radio /sys/class/sec/sec_touchkey/touch_update
+ chown system radio /sys/class/sec/sec_touchkey/touch_version
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_firm_version_panel
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_firm_version_phone
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_firm_update_status
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_firm_update
+ chown system radio /sys/class/sec/sec_touchkey/touch_sensitivity
+ chown system radio /sys/class/sec/sec_touchkey/touchkey_threshold
+ chown system system /sys/devices/virtual/sec/sec_touchkey/brightness
+
+# Permissions for gpio_keys
+ chown radio system /sys/class/sec/sec_key/wakeup_keys
+ write /sys/class/sec/sec_key/wakeup_keys 116,172
+
+# Switch Device
+ chown system system /sys/class/sec/switch/uart_sel
+ chown system system /sys/class/sec/switch/usb_sel
+ chown system system /sys/class/sec/switch/otg_test
+ chown system radio /sys/class/sec/switch/adc
+
+# SVC LED
+ chown system system /sys/class/sec/led/led_r
+ chown system system /sys/class/sec/led/led_g
+ chown system system /sys/class/sec/led/led_b
+
+ chown system system /sys/class/leds/led_r/brightness
+ chown system system /sys/class/leds/led_g/brightness
+ chown system system /sys/class/leds/led_b/brightness
+ chown system system /sys/class/leds/led_r/delay_on
+ chown system system /sys/class/leds/led_g/delay_on
+ chown system system /sys/class/leds/led_b/delay_on
+ chown system system /sys/class/leds/led_r/delay_off
+ chown system system /sys/class/leds/led_g/delay_off
+ chown system system /sys/class/leds/led_b/delay_off
+ chown system system /sys/class/leds/led_r/blink
+ chown system system /sys/class/leds/led_g/blink
+ chown system system /sys/class/leds/led_b/blink
+
+ chown system system /sys/class/sec/led/led_pattern
+ chown system system /sys/class/sec/led/led_blink
+ chown system system /sys/class/sec/led/led_br_lev
+
+# <Sensors & NFC>
+# Input Events
+ chown system radio /sys/class/input/input2/enable
+ chown system radio /sys/class/input/input2/poll_delay
+ chown system radio /sys/class/input/input3/enable
+ chown system radio /sys/class/input/input3/poll_delay
+ chown system radio /sys/class/input/input4/enable
+ chown system radio /sys/class/input/input4/poll_delay
+ chown system radio /sys/class/input/input5/enable
+ chown system radio /sys/class/input/input5/poll_delay
+ chown system radio /sys/class/input/input6/enable
+ chown system radio /sys/class/input/input6/poll_delay
+ chown system radio /sys/class/input/input7/enable
+ chown system radio /sys/class/input/input7/poll_delay
+ chown system radio /sys/class/input/input8/enable
+ chown system radio /sys/class/input/input8/poll_delay
+ chown system radio /sys/class/input/input9/enable
+ chown system radio /sys/class/input/input9/poll_delay
+# Accelerometer_sensor
+ chown system radio /dev/accelerometer
+ chown system radio /sys/class/sensors/accelerometer_sensor
+ chown system radio /sys/class/sensors/accelerometer_sensor/raw_data
+ chown system radio /sys/class/sensors/accelerometer_sensor/calibration
+ chown system radio /sys/class/sensors/accelerometer_sensor/reactive_alert
+ chown system radio /sys/class/sensors/accelerometer_sensor/vendor
+ chown system radio /sys/class/sensors/accelerometer_sensor/name
+# Proximity_sensor
+ chown system radio /sys/class/sensors/proximity_sensor/state
+ chown system radio /sys/class/sensors/proximity_sensor/prox_avg
+ chown system radio /sys/class/sensors/proximity_sensor/prox_cal
+ chown system radio /sys/class/sensors/proximity_sensor/vendor
+ chown system radio /sys/class/sensors/proximity_sensor/name
+ chown system radio /sys/class/sensors/proximity_sensor/prox_thresh
+# Light_sensor
+ chown system radio /sys/class/input/input7/enable
+ chown system radio /sys/class/input/input7/poll_delay
+ chown system radio /sys/class/sensors/light_sensor/lux
+ chown system radio /sys/class/sensors/light_sensor/raw_data
+ chown system radio /sys/class/sensors/light_sensor/vendor
+ chown system radio /sys/class/sensors/light_sensor/name
+# Gyro_sensor
+ chown system radio /dev/lsm330dlc_gyro_misc
+ chown system radio /sys/class/sensors/gyro_sensor/power_on
+ chown system radio /sys/class/sensors/gyro_sensor/power_off
+ chown system radio /sys/class/sensors/gyro_sensor/temperature
+ chown system radio /sys/class/sensors/gyro_sensor/selftest
+ chown system radio /sys/class/sensors/gyro_sensor/selftest_dps
+ chown system radio /sys/class/sensors/gyro_sensor/vendor
+ chown system radio /sys/class/sensors/gyro_sensor/name
+# Barometer_sensor
+ chown system radio /sys/class/input/input5/pressure_reference_level
+ chown system radio /sys/class/input/input5/temperature_reference_level
+ chown system radio /sys/class/input/input5/enable_autozero
+ chown system radio /sys/class/input/input5/compensation_param
+ chown system radio /sys/class/input/input5/reg_value
+ chown system radio /sys/class/input/input5/reg_addr
+ chown system radio /sys/class/sensors/barometer_sensor/sea_level_pressure
+ chown system radio /sys/class/sensors/barometer_sensor/vendor
+ chown system radio /sys/class/sensors/barometer_sensor/name
+ chown system radio /sys/class/sensors/barometer_sensor/calibration
+# Magnetic_sensor
+ chown system radio /dev/akm8975
+ chown system radio /sys/class/sensors/magnetic_sensor/raw_data
+ chown system radio /sys/class/sensors/magnetic_sensor/vendor
+ chown system radio /sys/class/sensors/magnetic_sensor/name
+
+# for datarouter
+ chown system system /dev/dun
+ chown system system /dev/ttyGS0
+ chown system system /dev/ttyGS1
+ chown system system /dev/ttyGS2
+ chown system system /dev/ttyGS3
+
+# for wifi
+ mkdir /data/misc/wifi/sockets 0770 wifi wifi
+ mkdir /data/misc/dhcp 0775 dhcp dhcp
+ chown dhcp dhcp /data/misc/dhcp
+
+# for TRP/TIS
+ write /data/.psm.info 1
+ chown system root /data/.psm.info
+ chmod 0660 /data/.psm.info
+
+ # Set indication (checked by vold) that we have finished this action
+ setprop vold.post_fs_data_done 1
+
+on boot
+ mount debugfs /sys/kernel/debug /sys/kernel/debug
+
+ setprop ro.build.product smdk4x12
+ setprop ro.product.device smdk4x12
+ setprop ro.radio.noril yes
+ setprop wifi.interface wlan0
+
+# fake some battery state
+ setprop status.battery.state Slow
+ setprop status.battery.level 5
+ setprop status.battery.level_raw 50
+ setprop status.battery.level_scale 9
+
+# wifi display
+ write /proc/sys/net/core/wmem_max 262144
+
+ # Set permission for Widevine DRM temporarily
+ chmod 0777 /dev/s5p-smem
+ rm /data/app/tlcd_sock
+
+ # make param block device link for SysScope
+ symlink /dev/block/mmcblk0p7 /dev/block/param
+
+# serial keyboard port
+ chown root system /dev/ttySAC2
+ chmod 0660 /dev/ttySAC2
+
+# touchscreen
+ chown radio system /sys/class/sec/tsp/cmd
+ chown media_rw media_rw /sys/class/sec/tsp/set_jitter
+
+# epen
+ chown radio system /sys/class/sec/sec_epen/epen_firm_update
+ chown radio system /sys/class/sec/sec_epen/epen_checksum
+ chown radio system /sys/class/sec/sec_epen/epen_checksum_result
+ chown radio system /sys/class/sec/sec_epen/epen_reset
+
+# wakeup keys
+ chown radio system /sys/class/sec/sec_key/wakeup_keys
+ write /sys/class/sec/sec_key/wakeup_keys 116,172
+
+# serial keyboard daemon
+service sec_keyboard /system/bin/sec_keyboard /dev/ttySAC2
+ class late_start
+ disabled
+ group system
+
+# SISO-ANDR_PERF :: START Changing scheduler to cfq and reseting cpu min freq to -1 after boot complete
+on property:sys.boot_completed=1
+ write /sys/block/mmcblk0/queue/scheduler cfq
+ write /sys/power/cpufreq_min_limit -1
+# write /proc/sys/net/ipv6/conf/rmnet_usb0/accept_ra 2
+# write /proc/sys/net/ipv6/conf/rmnet_usb1/accept_ra 2
+# write /proc/sys/net/ipv6/conf/rmnet_usb2/accept_ra 2
+# write /proc/sys/net/ipv6/conf/rmnet_usb3/accept_ra 2
+# SISO-ANDR_PERF :: END
+
+on property:ro.uart_debug=0
+ start sec_keyboard
+
+# create virtual SD card at /mnt/sdcard, based on the /data/media directory
+# daemon will drop to user/group system/media_rw after initializing
+# underlying files in /data/media wil be created with user and group media_rw (1023)
+service sdcard /system/bin/sdcard /data/media /mnt/shell/emulated 1023 1023
+ class late_start
+
+# AT Distributor for factory test
+service at_distributor /system/bin/at_distributor
+ class main
+ user root
+ group radio log
+
+# diag app for cp uart
+service diag_uart_log /system/bin/diag_uart_log
+ class main
+ user root
+ group radio
+
+#service cpboot-daemon /sbin/cbd -d -p 10
+# class main
+# user root
+# group radio cache inet misc audio sdcard_rw log
+
+service p2p_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -N \
+ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin \
+ -puse_p2p_group_interface=1
+ # we will start as root and wpa_supplicant will switch to user wifi
+ # after setting up the capabilities required for WEXT
+ # user wifi
+ # group wifi inet keystore
+ class main
+ socket wpa_wlan0 dgram 660 wifi wifi
+ disabled
+ oneshot
+
+service wpa_supplicant /system/bin/wpa_supplicant \
+ -Dnl80211 -iwlan0 -e/data/misc/wifi/entropy.bin \
+ -c/data/misc/wifi/wpa_supplicant.conf
+ # we will start as root and wpa_supplicant will switch to user wifi
+ # after setting up the capabilities required for WEXT
+ # user wifi
+ # group wifi inet keystore
+ class main
+ socket wpa_wlan0 dgram 660 wifi wifi
+ disabled
+ oneshot
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
+ class main
+ disabled
+ oneshot
+
+service dhcpcd_p2p /system/bin/dhcpcd -aABKL
+ class main
+ disabled
+ oneshot
+
+service dhcpcd_bnep0 /system/bin/dhcpcd -ABKL
+ class main
+ disabled
+ oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+service iprenew_p2p /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+service iprenew_bnep0 /system/bin/dhcpcd -n
+ class main
+ disabled
+ oneshot
+
+#service secstarter /system/bin/secstarter
+#NOT NEEDED
+# class main
+# user system
+# group system
+
+service macloader /system/bin/macloader
+ class main
+ oneshot
+
+service netmgrd /system/bin/netmgrd
+ class late_start
+
+service SMD-daemon /system/bin/smdexe
+ class main
+ user root
+ group system radio inet net_raw
+
+service qc_kickstart /system/bin/qcks s
+ class core
+ user root
+ group radio cache inet misc audio sdcard_rw log
+
+service secril-daemon /system/bin/sec-ril
+ class main
+ user root
+ group radio cache inet misc audio sdcard_rw qcom_diag log
+
+#For EncryptionMode - remove disabled, Modify class main
+service qmiproxy /system/bin/qmiproxy
+ class main
+ user radio
+ group radio gps
+
+service qmuxd /system/bin/qmuxd
+ class main
+ user root
+ group radio log audio bluetooth gps log
+
+#start GNSS/Sensor interface daemon
+service gsiff_daemon /system/bin/gsiff_daemon
+ class late_start
+ user system
+ group qcom_oncrpc gps
+
+# TVout
+service TvoutService_C /system/bin/bintvoutservice
+ class main
+ user system
+ group graphics
+
+on property:ro.tvout.enable=false
+ stop TvoutService_C
diff --git a/rootdir/lpm.rc b/rootdir/lpm.rc
new file mode 100644
index 0000000..c21c887
--- /dev/null
+++ b/rootdir/lpm.rc
@@ -0,0 +1,77 @@
+on early-init
+ start ueventd
+
+on init
+ export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
+ export LD_LIBRARY_PATH /vendor/lib:/system/lib
+ export ANDROID_ROOT /system
+ export ANDROID_DATA /data
+ export EXTERNAL_STORAGE /sdcard
+
+ symlink /system/etc /etc
+
+ mkdir /sdcard
+ mkdir /preload
+ mkdir /system
+ mkdir /data
+ mkdir /cache
+ mkdir /efs
+ mkdir /tmp
+ mkdir /dbdata
+ mkdir /mnt 0775 root root
+ #mount /tmp /tmp tmpfs
+
+on early-fs
+ mount ext4 /dev/block/mmcblk0p13 /system ro wait noatime
+
+ mkdir /data/log 0777
+ chmod 0666 /dev/log/radio
+ chmod 0666 /dev/log/main
+ chmod 0666 /dev/log/event
+
+on boot
+# write /sys/class/sec/switch/usb_sel PDA
+
+# CPU Frequency Governor
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor pegasusq
+
+# EHCI runtime enable for LPA
+ write /sys/devices/platform/s5p-ehci/power/control auto
+
+ ifup lo
+ hostname localhost
+ domainname localdomain
+
+ class_start default
+
+service debuggerd /system/bin/debuggerd
+
+service ueventd /sbin/ueventd
+ critical
+
+service console /system/bin/sh
+ console
+
+service playlpm /system/bin/playlpm
+ user root
+
+service immvibed /system/bin/immvibed
+ oneshot
+
+service lpmkey /system/bin/lpmkey
+ user root
+
+# adbd is controlled by the persist.service.adb.enable system property
+service adbd /sbin/adbd
+ disabled
+
+# adbd on at boot in emulator
+on property:ro.kernel.qemu=1
+ start adbd
+
+on property:persist.service.adb.enable=1
+ start adbd
+
+on property:persist.service.adb.enable=0
+ stop adbd
+
diff --git a/rootdir/ueventd.smdk4x12.rc b/rootdir/ueventd.smdk4x12.rc
new file mode 100644
index 0000000..39089e3
--- /dev/null
+++ b/rootdir/ueventd.smdk4x12.rc
@@ -0,0 +1,109 @@
+/dev/mali 0666 system system
+/dev/ump 0666 system graphics
+/dev/ion 0666 system system
+/dev/exynos-mem 0660 system camera
+
+/dev/media0 0660 system system
+/dev/media1 0660 system camera
+/dev/media2 0660 system camera
+/dev/v4l-subdev0 0660 system system
+/dev/v4l-subdev1 0660 system system
+/dev/v4l-subdev3 0660 system system
+/dev/v4l-subdev4 0660 system system
+/dev/v4l-subdev5 0660 system system
+/dev/v4l-subdev6 0660 system system
+/dev/v4l-subdev7 0660 system system
+/dev/v4l-subdev8 0660 system system
+/dev/v4l-subdev9 0660 system system
+/dev/v4l-subdev10 0660 system system
+/dev/v4l-subdev11 0660 system system
+/dev/v4l-subdev12 0660 system system
+/dev/v4l-subdev13 0660 system system
+/dev/v4l-subdev14 0660 system system
+/dev/v4l-subdev15 0660 system system
+/dev/v4l-subdev16 0660 system system
+/dev/v4l-subdev17 0660 system system
+
+/dev/video0 0666 system system
+/dev/video1 0666 system camera
+/dev/video2 0666 system system
+/dev/video3 0666 system system
+/dev/video4 0666 system system
+/dev/video11 0666 system system
+/dev/video12 0666 system system
+/dev/video16 0666 system system
+/dev/video20 0666 system system
+/dev/video6 0660 media graphics
+/dev/video7 0660 media graphics
+
+/dev/video11 0666 system graphics
+/dev/video12 0660 system camera
+
+/dev/video16 0660 system system
+/dev/video17 0660 system system
+/dev/video18 0660 system system
+/dev/video19 0660 system system
+
+# Rotator
+/dev/video21 0660 system system
+
+/dev/video23 0660 system system
+/dev/video24 0660 system system
+/dev/video25 0660 system camera
+/dev/video26 0666 media camera
+/dev/video29 0666 media camera
+/dev/video32 0660 media camera
+
+/dev/video33 0660 system system
+/dev/video34 0660 system system
+
+/dev/video40 0660 system camera
+/dev/video41 0660 system camera
+/dev/video42 0660 system camera
+/dev/video43 0660 system camera
+
+/dev/i2c-2 0660 system system
+/dev/i2c-5 0660 system system
+/dev/i2c-6 0660 system system
+/dev/CEC 0660 system system
+/dev/HPD 0660 system system
+/dev/fimg2d 0666 system graphics
+/dev/fmradio 0660 system audio
+
+#ALP Audio
+/dev/srp 0660 system audio
+
+/dev/s3c-mfc 0666 system graphics
+/dev/s5p-mfc 0666 system graphics
+
+/dev/block/mmcblk0p7 0660 system root
+/dev/block/mmcblk0p10 0660 system radio
+/dev/block/mmcblk0p4 0660 system radio
+/dev/block/mmcblk0p5 0660 system radio
+/dev/block/mmcblk0p6 0660 system radio
+/dev/block/mmcblk0p11 0660 system radio
+/dev/mdm 0660 system system
+#CPRM
+/dev/block/mmcblk1 0660 root system
+/dev/ttyUSB0 0666 system system
+/dev/ttyUSB1 0666 system system
+/dev/ttyUSB2 0666 system system
+/dev/hsic* 0660 system radio
+/dev/usb/lp* 0660 system usb
+
+/dev/ttySAC* 0660 root system
+/dev/umts* 0660 system radio
+/dev/lte* 0660 system radio
+/dev/cdma* 0660 system radio
+/dev/link_pm 0660 system radio
+
+# for felica
+/dev/felica 0666 root root
+/dev/felica_pon 0666 root root
+/dev/felica_cen 0666 root root
+/dev/felica_rfs 0444 root root
+/dev/felica_rws 0666 root root
+/dev/felica_ant 0666 root root
+/dev/felica_int_poll 0400 root root
+/dev/felica_uid 0222 root root
+# for felica end
diff --git a/system.prop b/system.prop
new file mode 100644
index 0000000..fbfaa1f
--- /dev/null
+++ b/system.prop
@@ -0,0 +1,17 @@
+#
+# system.prop for i9305
+#
+
+rild.libpath=/system/lib/libril-qc-qmi-1.so
+rild.libargs=-d /dev/ttyS0
+ro.sf.lcd_density=320
+ro.lcd_min_brightness=20
+
+# System property ril adb log on
+persist.radio.adb_log_on=1
+
+# For sys info indication
+persist.radio.add_power_save=1
+
+# System property for SIM
+persist.radio.apm_sim_not_pwdn=1