Merge "Flounder: NFC: Increase WAKE_DELAY." into lmp-dev
diff --git a/VolantisKeyboard/res/raw/keyboard_layout_volantis_japanese.kcm b/VolantisKeyboard/res/raw/keyboard_layout_volantis_japanese.kcm
new file mode 100644
index 0000000..0dc7409
--- /dev/null
+++ b/VolantisKeyboard/res/raw/keyboard_layout_volantis_japanese.kcm
@@ -0,0 +1,311 @@
+# Copyright (C) 2014 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.
+
+#
+# Japanese 109-key keyboard layout.
+#
+
+type OVERLAY
+
+map key 100 ZENKAKU_HANKAKU
+
+### ROW 1
+
+key GRAVE {
+    label:                              '`'
+    base:                               '`'
+    shift:                              '~'
+}
+
+key 1 {
+    label:                              '1'
+    base:                               '1'
+    shift:                              '!'
+}
+
+key 2 {
+    label:                              '2'
+    base:                               '2'
+    shift:                              '@'
+}
+
+key 3 {
+    label:                              '3'
+    base:                               '3'
+    shift:                              '#'
+}
+
+key 4 {
+    label:                              '4'
+    base:                               '4'
+    shift:                              '$'
+}
+
+key 5 {
+    label:                              '5'
+    base:                               '5'
+    shift:                              '%'
+}
+
+key 6 {
+    label:                              '6'
+    base:                               '6'
+    shift:                              '^'
+}
+
+key 7 {
+    label:                              '7'
+    base:                               '7'
+    shift:                              '&'
+}
+
+key 8 {
+    label:                              '8'
+    base:                               '8'
+    shift:                              '*'
+}
+
+key 9 {
+    label:                              '9'
+    base:                               '9'
+    shift:                              '('
+}
+
+key 0 {
+    label:                              '0'
+    base:                               '0'
+    shift:                              ')'
+}
+
+key MINUS {
+    label:                              '-'
+    base:                               '-'
+    shift:                              '_'
+}
+
+key EQUALS {
+    label:                              '='
+    base:                               '='
+    shift:                              '+'
+}
+
+### ROW 2
+
+key Q {
+    label:                              'q'
+    base:                               'q'
+    shift, capslock:                    'Q'
+}
+
+key W {
+    label:                              'w'
+    base:                               'w'
+    shift, capslock:                    'W'
+}
+
+key E {
+    label:                              'e'
+    base:                               'e'
+    shift, capslock:                    'E'
+}
+
+key R {
+    label:                              'r'
+    base:                               'r'
+    shift, capslock:                    'R'
+}
+
+key T {
+    label:                              't'
+    base:                               't'
+    shift, capslock:                    'T'
+}
+
+key Y {
+    label:                              'y'
+    base:                               'y'
+    shift, capslock:                    'Y'
+}
+
+key U {
+    label:                              'u'
+    base:                               'u'
+    shift, capslock:                    'U'
+}
+
+key I {
+    label:                              'i'
+    base:                               'i'
+    shift, capslock:                    'I'
+}
+
+key O {
+    label:                              'o'
+    base:                               'o'
+    shift, capslock:                    'O'
+}
+
+key P {
+    label:                              'p'
+    base:                               'p'
+    shift, capslock:                    'P'
+}
+
+key LEFT_BRACKET {
+    label:                              '['
+    base:                               '['
+    shift:                              '{'
+}
+
+key RIGHT_BRACKET {
+    label:                              ']'
+    base:                               ']'
+    shift:                              '}'
+}
+
+key BACKSLASH {
+    label:                              '\\'
+    base:                               '\\'
+    shift:                              '|'
+}
+
+### ROW 3
+
+key A {
+    label:                              'a'
+    base:                               'a'
+    shift, capslock:                    'A'
+}
+
+key S {
+    label:                              's'
+    base:                               's'
+    shift, capslock:                    'S'
+}
+
+key D {
+    label:                              'd'
+    base:                               'd'
+    shift, capslock:                    'D'
+}
+
+key F {
+    label:                              'f'
+    base:                               'f'
+    shift, capslock:                    'F'
+}
+
+key G {
+    label:                              'g'
+    base:                               'g'
+    shift, capslock:                    'G'
+}
+
+key H {
+    label:                              'h'
+    base:                               'h'
+    shift, capslock:                    'H'
+}
+
+key J {
+    label:                              'j'
+    base:                               'j'
+    shift, capslock:                    'J'
+}
+
+key K {
+    label:                              'k'
+    base:                               'k'
+    shift, capslock:                    'K'
+}
+
+key L {
+    label:                              'l'
+    base:                               'l'
+    shift, capslock:                    'L'
+}
+
+key SEMICOLON {
+    label:                              ';'
+    base:                               ';'
+    shift:                              ':'
+}
+
+key APOSTROPHE {
+    label:                              '\''
+    base:                               '\''
+    shift:                              '"'
+}
+
+### ROW 4
+
+key Z {
+    label:                              'z'
+    base:                               'z'
+    shift, capslock:                    'Z'
+}
+
+key X {
+    label:                              'x'
+    base:                               'x'
+    shift, capslock:                    'X'
+}
+
+key C {
+    label:                              'c'
+    base:                               'c'
+    shift, capslock:                    'C'
+}
+
+key V {
+    label:                              'v'
+    base:                               'v'
+    shift, capslock:                    'V'
+}
+
+key B {
+    label:                              'b'
+    base:                               'b'
+    shift, capslock:                    'B'
+}
+
+key N {
+    label:                              'n'
+    base:                               'n'
+    shift, capslock:                    'N'
+}
+
+key M {
+    label:                              'm'
+    base:                               'm'
+    shift, capslock:                    'M'
+}
+
+key COMMA {
+    label:                              ','
+    base:                               ','
+    shift:                              '<'
+}
+
+key PERIOD {
+    label:                              '.'
+    base:                               '.'
+    shift:                              '>'
+}
+
+key SLASH {
+    label:                              '/'
+    base:                               '/'
+    shift:                              '?'
+}
diff --git a/VolantisKeyboard/res/values/strings.xml b/VolantisKeyboard/res/values/strings.xml
index e4ee7a6..8b8e655 100644
--- a/VolantisKeyboard/res/values/strings.xml
+++ b/VolantisKeyboard/res/values/strings.xml
@@ -18,4 +18,6 @@
     <string name="keyboard_layout_volantis_french_ca_label">Volantis French (Canada)</string>
     <!-- Italian keyboard layout label. [CHAR LIMIT=35] -->
     <string name="keyboard_layout_volantis_italian_label">Volantis Italian</string>
+    <!-- Japanese keyboard layout label. [CHAR LIMIT=35] -->
+    <string name="keyboard_layout_volantis_japanese_label">Volantis Japanese</string>
 </resources>
diff --git a/VolantisKeyboard/res/xml/keyboard_layouts.xml b/VolantisKeyboard/res/xml/keyboard_layouts.xml
index cbd52cb..dae9120 100644
--- a/VolantisKeyboard/res/xml/keyboard_layouts.xml
+++ b/VolantisKeyboard/res/xml/keyboard_layouts.xml
@@ -21,4 +21,7 @@
     <keyboard-layout android:name="keyboard_layout_volantis_italian"
             android:label="@string/keyboard_layout_volantis_italian_label"
             android:keyboardLayout="@raw/keyboard_layout_volantis_italian" />
+    <keyboard-layout android:name="keyboard_layout_volantis_japanese"
+            android:label="@string/keyboard_layout_volantis_japanese_label"
+            android:keyboardLayout="@raw/keyboard_layout_volantis_japanese" />
 </keyboard-layouts>
diff --git a/VolantisLayout/Android.mk b/VolantisLayout/Android.mk
new file mode 100644
index 0000000..5529559
--- /dev/null
+++ b/VolantisLayout/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := VolantisLayout
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/VolantisLayout/AndroidManifest.xml b/VolantisLayout/AndroidManifest.xml
new file mode 100644
index 0000000..4ee1759
--- /dev/null
+++ b/VolantisLayout/AndroidManifest.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.google.android.launcher.layouts.volantis">
+
+    <application android:label="@string/app_label">
+
+        <!-- This isn't a real receiver, it's only used as a marker interface. -->
+        <receiver android:name=".PartnerCustomizationReceiver">
+            <intent-filter>
+                <action android:name="com.android.launcher3.action.PARTNER_CUSTOMIZATION" />
+            </intent-filter>
+        </receiver>
+    </application>
+</manifest>
diff --git a/VolantisLayout/res/values/strings.xml b/VolantisLayout/res/values/strings.xml
new file mode 100644
index 0000000..81f3e53
--- /dev/null
+++ b/VolantisLayout/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<resources>
+    <string name="app_label">Nexus 9 Home Screen</string>
+    <string name="google_folder_title">Google</string>
+    <string name="create_folder_title">Create</string>
+    <!--Play here refers to the brand -->
+    <string name="play_folder_title">Play</string>
+</resources>
diff --git a/VolantisLayout/res/xml/partner_default_layout.xml b/VolantisLayout/res/xml/partner_default_layout.xml
new file mode 100644
index 0000000..f60afd2
--- /dev/null
+++ b/VolantisLayout/res/xml/partner_default_layout.xml
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<!-- Google-specific version of Launcher3/res/xml/default_workspace.xml -->
+<favorites>
+
+    <!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
+    <!-- Hangouts Gmail Chrome [All Apps] YouTube Photos Camera -->
+
+	<favorite
+        container="-101"
+        screen="0"
+        x="0"
+        y="0"
+        packageName="com.google.android.talk"
+		className="com.google.android.talk.SigningInActivity"
+        />
+
+	<favorite
+        container="-101"
+        screen="1"
+        x="0"
+        y="0"
+        packageName="com.google.android.gm"
+        className="com.google.android.gm.ConversationListActivityGmail"
+        />
+
+	<favorite
+        container="-101"
+        screen="2"
+        x="0"
+        y="0"
+        packageName="com.android.chrome"
+        className="com.google.android.apps.chrome.Main"
+    />
+
+	<favorite
+        container="-101"
+        screen="4"
+        x="0"
+        y="0"
+        packageName="com.google.android.youtube"
+		className="com.google.android.youtube.app.honeycomb.Shell$HomeActivity"
+        />
+
+	<favorite
+        container="-101"
+        screen="5"
+        x="0"
+        y="0"
+		packageName="com.google.android.apps.plus"
+		className="com.google.android.apps.plus.phone.ConversationListActivity"
+		/>
+
+    <favorite
+        container="-101"
+        screen="6"
+        x="0"
+        y="0"
+        packageName="com.google.android.GoogleCamera"
+        className="com.android.camera.CameraActivity"
+    />
+
+    <!-- In Launcher3, workspaces extend infinitely to the right, incrementing from zero -->
+
+	<!-- Google folder -->
+	<!-- Google, Maps, G+, Calendar, Contacts, News & Weather -->
+
+	<folder
+			title="@string/google_folder_title"
+			screen="0"
+			x="0"
+			y="4">
+
+			<favorite
+	                packageName="com.google.android.googlequicksearchbox"
+	                className="com.google.android.googlequicksearchbox.SearchActivity"
+	                />
+
+			<favorite
+		            packageName="com.google.android.apps.maps"
+					className="com.google.android.maps.MapsActivity"
+			        />
+
+			<favorite
+				    packageName="com.google.android.apps.plus"
+					className="com.google.android.apps.plus.phone.HomeActivity"
+					/>
+
+			<favorite
+	                packageName="com.google.android.calendar"
+	                className="com.android.calendar.AllInOneActivity"
+	                />
+
+			<favorite
+	                packageName="com.google.android.contacts"
+	                className="/com.android.contacts.activities.PeopleActivity"
+	                />
+
+			<favorite
+		            packageName="com.google.android.apps.genie.geniewidget"
+					className="com.google.android.apps.genie.geniewidget.activities.NewsActivity"
+			        />
+
+	</folder>
+
+	<!-- Create folder -->
+	<!-- Docs, Sheets, Slides, Drive, Keep -->
+
+	<folder
+			title="@string/create_folder_title"
+			screen="0"
+			x="1"
+			y="4">
+
+			<favorite
+	                packageName="com.google.android.apps.docs.editors.docs"
+	                className="com.google.android.apps.docs.app.NewMainProxyActivity"
+	                />
+
+			<favorite
+			packageName="com.google.android.apps.docs.editors.sheets"
+			        className="com.google.android.apps.docs.app.NewMainProxyActivity"
+			        />
+
+			<favorite
+			packageName="com.google.android.apps.docs.editors.slides"
+			        className="com.google.android.apps.docs.app.NewMainProxyActivity"
+			        />
+
+			<favorite
+	                packageName="com.google.android.apps.docs"
+	                className="com.google.android.apps.docs.app.NewMainProxyActivity"
+	                />
+
+			<favorite
+		            packageName="com.google.android.keep"
+					className="com.google.android.keep.activities.BrowseActivity"
+			        />
+
+	</folder>
+
+	<!-- Play folder -->
+	<!-- Movies, Music, Games, Books, Newsstand -->
+
+	<folder
+			title="@string/play_folder_title"
+			screen="0"
+			x="4"
+			y="4">
+
+			<favorite
+	                packageName="com.google.android.play.games"
+	                className="com.google.android.gms.games.ui.destination.main.MainActivity"
+	                />
+
+			<favorite
+		            packageName="com.google.android.videos"
+					className="com.google.android.youtube.videos.EntryPoint"
+			        />
+
+			<favorite
+	                packageName="com.google.android.music"
+	                className="com.android.music.activitymanagement.TopLevelActivity"
+	                />
+
+			<favorite
+		            packageName="com.google.android.apps.books"
+					className="com.google.android.apps.books.app.BooksActivity"
+			        />
+
+			<favorite
+	                packageName="com.google.android.apps.magazines"
+	                className="com.google.apps.dots.android.app.activity.CurrentsStartActivity"
+	                />
+
+	</folder>
+
+	<favorite
+        screen="0"
+        x="5"
+        y="4"
+        packageName="com.android.vending"
+        className="com.android.vending.AssetBrowserActivity"
+    />
+
+    <!-- Any other installed apps will appear in All Apps -->
+
+</favorites>
diff --git a/VolantisLayout/src/com/google/android/launcher/layouts/volantis/PartnerCustomizationReceiver.java b/VolantisLayout/src/com/google/android/launcher/layouts/volantis/PartnerCustomizationReceiver.java
new file mode 100644
index 0000000..01bc543
--- /dev/null
+++ b/VolantisLayout/src/com/google/android/launcher/layouts/volantis/PartnerCustomizationReceiver.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.google.android.launcher.layouts.volantis;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class PartnerCustomizationReceiver extends BroadcastReceiver {
+
+    public PartnerCustomizationReceiver() {
+    }
+
+    public void onReceive(Context context, Intent intent) {
+    }
+}
\ No newline at end of file
diff --git a/audio/hal/audio_hw.c b/audio/hal/audio_hw.c
index 818e793..d4a5360 100644
--- a/audio/hal/audio_hw.c
+++ b/audio/hal/audio_hw.c
@@ -4253,8 +4253,10 @@
             retry_count = RETRY_NUMBER;
             while (!adev->dummybuf_thread_active && retry_count-- > 0)
                 usleep(10000);
-            if(adev->dummybuf_thread_active)
+            if(adev->dummybuf_thread_active) {
+                usleep(10000); /* tfa9895 spk amp need more than 1ms i2s signal before giving dsp related i2c commands*/
                 adev->tfa9895_init = adev->htc_acoustic_set_amp_mode(0, AUDIO_DEVICE_OUT_SPEAKER, 0, 0, false);
+            }
             dummybuf_thread_close(adev);
         }
 
diff --git a/audio/soundtrigger/sound_trigger_hw.c b/audio/soundtrigger/sound_trigger_hw.c
index 5398ca8..cdea49e 100644
--- a/audio/soundtrigger/sound_trigger_hw.c
+++ b/audio/soundtrigger/sound_trigger_hw.c
@@ -86,6 +86,13 @@
 };
 
 
+static void stdev_dsp_set_power(struct flounder_sound_trigger_device *stdev,
+                                int val)
+{
+    mixer_ctl_set_value(stdev->ctl_dsp, 0, val);
+    mixer_ctl_set_value(stdev->ctl_mic, 0, val);
+}
+
 static int stdev_init_mixer(struct flounder_sound_trigger_device *stdev)
 {
     int ret = -1;
@@ -108,6 +115,8 @@
     if (!stdev->ctl_dsp)
         goto err;
 
+    stdev_dsp_set_power(stdev, 0); // Reset DSP at the beginning
+
     return 0;
 
 err:
@@ -260,8 +269,7 @@
     fds[1].events = POLLIN;
     fds[1].fd = stdev->term_sock;
 
-    mixer_ctl_set_value(stdev->ctl_dsp, 0, 1);
-    mixer_ctl_set_value(stdev->ctl_mic, 0, 1);
+    stdev_dsp_set_power(stdev, 1);
 
     pthread_mutex_unlock(&stdev->lock);
 
@@ -313,8 +321,7 @@
     stdev->recognition_callback = NULL;
     stdev_close_term_sock(stdev);
 
-    mixer_ctl_set_value(stdev->ctl_dsp, 0, 0);
-    mixer_ctl_set_value(stdev->ctl_mic, 0, 0);
+    stdev_dsp_set_power(stdev, 0);
 
     pthread_mutex_unlock(&stdev->lock);
 
diff --git a/audio_policy.conf b/audio_policy.conf
index b509b90..ef136a7 100644
--- a/audio_policy.conf
+++ b/audio_policy.conf
@@ -9,7 +9,7 @@
 global_configuration {
   attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
   default_output_device AUDIO_DEVICE_OUT_SPEAKER
-  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC
+  attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX
   speaker_drc_enabled TRUE
 }
 
diff --git a/board-info.txt b/board-info.txt
index b83794c..4ccc175 100644
--- a/board-info.txt
+++ b/board-info.txt
@@ -1,2 +1,2 @@
 board=flounder|flounder_lte
-require version-bootloader=3.34.0.2106
+require version-bootloader=3.34.0.2108
diff --git a/device.mk b/device.mk
index faf0b86..d8cbb0e 100644
--- a/device.mk
+++ b/device.mk
@@ -62,6 +62,10 @@
     $(LOCAL_PATH)/touch/touch_fusion:$(TARGET_COPY_OUT_VENDOR)/bin/touch_fusion \
     $(LOCAL_PATH)/touch/synaptics-dsx.idc:system/usr/idc/synaptics-dsx.idc
 
+# headset keylayout
+PRODUCT_COPY_FILES += \
+    $(LOCAL_PATH)/h2w_headset.kl:system/usr/keylayout/h2w_headset.kl
+
 PRODUCT_PACKAGES += \
     libwpa_client \
     hostapd \
@@ -182,7 +186,6 @@
     wifi.interface=wlan0 \
     ro.opengles.version=196609 \
     ro.sf.lcd_density=320 \
-    ro.zygote.disable_gl_preload=true \
     ro.hwui.texture_cache_size=72 \
     ro.hwui.layer_cache_size=48 \
     ro.hwui.r_buffer_cache_size=8 \
@@ -229,6 +232,10 @@
 PRODUCT_PACKAGES += \
 	VolantisKeyboard
 
+# for launcher layout
+PRODUCT_PACKAGES += \
+    VolantisLayout
+
 # Allows healthd to boot directly from charger mode rather than initiating a reboot.
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.enable_boot_charger_mode=1
diff --git a/gps/bcm/gpsconfig.xml b/gps/bcm/gpsconfig.xml
index 9a62be9..56dc570 100644
--- a/gps/bcm/gpsconfig.xml
+++ b/gps/bcm/gpsconfig.xml
@@ -4,8 +4,8 @@
   <hal
     PortName="/dev/ttyTHS1"
     BaudRate="921600"
-    LogEnabled="false"
-    Log="DAEMON"
+    LogEnabled="true"
+    Log="LOGCAT"
     LogDirectory="/data/gps/gpslog/"
     NmeaOutName="/data/gps/nmea_out"
     CtrlPipe="/data/gps/glgpsctrl"
diff --git a/gps/qct/gps.conf b/gps/qct/gps.conf
index fcc101a..9dd5223 100644
--- a/gps/qct/gps.conf
+++ b/gps/qct/gps.conf
@@ -10,4 +10,4 @@
 SUPL_VER=0x20000
 PHONE_TYPE=UMTS
 DBUG_LEVEL = 5
-CAPABILITIES=0x1
+CAPABILITIES=0x33
diff --git a/media_profiles.xml b/media_profiles.xml
index eba3a1d..8199e1f 100644
--- a/media_profiles.xml
+++ b/media_profiles.xml
@@ -114,7 +114,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="qcif" fileFormat="3gp" duration="30">
@@ -153,7 +153,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="720p" fileFormat="3gp" duration="30">
@@ -166,7 +166,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="1080p" fileFormat="3gp" duration="30">
@@ -179,7 +179,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30">
@@ -213,7 +213,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30">
@@ -264,7 +264,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapse720p" fileFormat="3gp" duration="30">
@@ -281,7 +281,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapse1080p" fileFormat="3gp" duration="30">
@@ -298,7 +298,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <ImageEncoding quality="90" />
@@ -316,7 +316,7 @@
              bitRate="384000"
              width="176"
              height="144"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="amrnb"
              bitRate="12200"
@@ -329,12 +329,12 @@
              bitRate="8000000"
              width="1280"
              height="720"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="720p" fileFormat="3gp" duration="30">
@@ -342,12 +342,12 @@
              bitRate="8000000"
              width="1280"
              height="720"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="qcif" fileFormat="3gp" duration="30">
@@ -355,7 +355,7 @@
              bitRate="384000"
              width="176"
              height="144"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="amrnb"
              bitRate="12200"
@@ -368,7 +368,7 @@
              bitRate="1536000"
              width="352"
              height="288"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="amrnb"
              bitRate="12200"
@@ -381,12 +381,12 @@
              bitRate="4000000"
              width="640"
              height="480"
-             frameRate="30" />
+             frameRate="20" />
 
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapselow" fileFormat="3gp" duration="30">
@@ -394,7 +394,7 @@
              bitRate="384000"
              width="176"
              height="144"
-             frameRate="30" />
+             frameRate="20" />
 
       <!--
             The Audio part of the profile will not be used since time lapse mode
@@ -411,7 +411,7 @@
              bitRate="4000000"
              width="640"
              height="480"
-             frameRate="30" />
+             frameRate="20" />
 
       <!--
             The Audio part of the profile will not be used since time lapse mode
@@ -420,7 +420,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30">
@@ -428,7 +428,7 @@
              bitRate="384000"
              width="176"
              height="144"
-             frameRate="30" />
+             frameRate="20" />
 
       <!--
             The Audio part of the profile will not be used since time lapse mode
@@ -445,7 +445,7 @@
              bitRate="1536000"
              width="352"
              height="288"
-             frameRate="30" />
+             frameRate="20" />
 
       <!--
             The Audio part of the profile will not be used since time lapse mode
@@ -462,7 +462,7 @@
              bitRate="4000000"
              width="640"
              height="480"
-             frameRate="30" />
+             frameRate="20" />
 
       <!--
             The Audio part of the profile will not be used since time lapse mode
@@ -471,7 +471,7 @@
       <Audio codec="aac"
              bitRate="96000"
              sampleRate="48000"
-             channels="1" />
+             channels="2" />
     </EncoderProfile>
 
     <ImageEncoding quality="90" />
@@ -509,7 +509,7 @@
   <AudioEncoderCap name="aac" enabled="true"
       minBitRate="8000" maxBitRate="320000"
       minSampleRate="8000" maxSampleRate="48000"
-      minChannels="1" maxChannels="1" />
+      minChannels="1" maxChannels="2" />
 
   <AudioEncoderCap name="amrwb" enabled="true"
         minBitRate="6600" maxBitRate="23050"
diff --git a/mixer_paths_0.xml b/mixer_paths_0.xml
index 29c1243..bd51e0b 100644
--- a/mixer_paths_0.xml
+++ b/mixer_paths_0.xml
@@ -54,7 +54,8 @@
 
   <path name="camcorder-mic">
     <ctl name="Mono ADC MIXL ADC2 Switch" value="1"/>
-    <ctl name="TDM1 Mode" value="LL Copy"/>
+    <ctl name="Mono ADC MIXR ADC2 Switch" value="1"/>
+    <ctl name="TDM1 Mode" value="Normal"/>
     <ctl name="Int Mic Switch" value="1"/>
   </path>
 
diff --git a/nfc/libnfc-brcm-20795a10.conf b/nfc/libnfc-brcm-20795a10.conf
index 97b5ea5..b22ca69 100644
--- a/nfc/libnfc-brcm-20795a10.conf
+++ b/nfc/libnfc-brcm-20795a10.conf
@@ -25,13 +25,13 @@
 #  By default, LPTD is enabled and default settings are used.
 #                  00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23x24x25 26 27 28x29x30 31 32x33x34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79x80x81 82 83 84 85 86 87 88 89 90 91 92 93
 #LPTD_CFG={66:B9:64:01:00:FF:FF:40:00:8B:13:00:10:00:04:00:00:00:00:03:00:00:00:03:00:0C:00:04:00:00:00:00:03:00:00:00:03:00:0C:00:00:0D:00:00:00:00:00:00:00:00:00:00:33:23:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:03:00:02:53:3B:0F:00:00:00:00:00:00:00:00:00:00:00:00:04:00:00:00:0E:00:00:00}
-LPTD_CFG={03:B9:01:00}
+LPTD_CFG={66:B9:64:01:00:FF:FF:50:00:8B:13:00:10:00:22:00:00:00:00:03:00:00:00:03:00:0C:00:04:00:00:00:00:03:00:00:00:03:00:0C:00:00:0D:00:00:00:00:00:00:00:00:00:00:33:23:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:03:00:02:53:3B:0F:00:00:00:00:00:00:00:00:00:00:00:00:04:00:00:00:0E:00:00:00}
 
 ###############################################################################
 # Startup Configuration (256 bytes maximum)
 #
 # This is applied at stack startup.
-NFA_DM_START_UP_CFG={AA:80:01:01:B0:05:01:03:03:03:08:B5:03:01:03:FF:C9:0D:24:00:00:00:01:00:BB:00:E4:00:0A:01:00:D6:0D:00:02:02:00:00:00:00:01:00:01:59:00:85:B2:02:E8:03:C8:1E:06:1F:00:0A:09:30:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:59:01:00:00:40:04:D7:01:07:DD:32:06:00:00:10:22:08:08:06:04:03:02:00:09:27:0A:72:20:00:74:20:00:00:00:01:85:00:00:32:1F:1D:1D:14:14:12:00:02:55:55:55:55:55:55:55:55:55:55:55:55:55:1D:CA:20:00:00:00:00:08:E8:03:00:00:90:01:00:00:FF:FF:00:00:00:00:00:00:00:00:00:00:00:20:14:01:00:00:00}
+NFA_DM_START_UP_CFG={AA:80:01:01:B0:05:01:03:03:03:08:B5:03:01:03:FF:C9:0D:24:00:00:00:01:00:BB:00:E4:00:0A:01:02:D6:0D:00:02:02:00:00:00:00:01:00:01:59:00:85:B2:02:A1:05:C8:1E:06:1F:00:0A:09:30:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:59:01:00:00:40:04:D7:01:07:DD:32:06:00:00:10:22:08:08:06:04:03:02:00:09:27:0A:72:20:00:74:20:00:00:00:01:85:00:00:32:1F:1D:1D:14:14:12:00:02:55:55:55:55:55:55:55:55:55:55:55:55:55:1D:CA:20:00:00:00:00:08:E8:03:00:00:90:01:00:00:FF:FF:00:00:00:00:00:00:00:00:00:00:00:20:14:01:00:00:00}
 
 ###############################################################################
 # Pre-Discovery Startup Configuration (256 bytes maximum)
diff --git a/power/power_flounder.c b/power/power_flounder.c
index 62f7f3a..730fa7f 100644
--- a/power/power_flounder.c
+++ b/power/power_flounder.c
@@ -35,8 +35,10 @@
 #define CPU_MAX_FREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq"
 #define FACEDOWN_PATH "/sys/class/htc_sensorhub/sensor_hub/facedown_enabled"
 #define TOUCH_SYNA_INTERACTIVE_PATH "/sys/devices/platform/spi-tegra114.2/spi_master/spi2/spi2.0/input/input0/interactive"
+#define GPU_BOOST_PATH "/dev/constraint_gpu_freq"
 #define LOW_POWER_MAX_FREQ "1020000"
 #define NORMAL_MAX_FREQ "2901000"
+#define GPU_FREQ_CONSTRAINT "852000 852000 -1 2000"
 
 struct flounder_power_module {
     struct power_module base;
@@ -106,6 +108,8 @@
 static int boostpulse_open(struct flounder_power_module *flounder)
 {
     char buf[80];
+    int len;
+    static int gpu_boost_fd = -1;
 
     pthread_mutex_lock(&flounder->lock);
 
@@ -120,6 +124,22 @@
             }
         }
     }
+    {
+        if ( gpu_boost_fd == -1 )
+            gpu_boost_fd = open(GPU_BOOST_PATH, O_WRONLY);
+
+        if (gpu_boost_fd < 0) {
+            strerror_r(errno, buf, sizeof(buf));
+            ALOGE("Error opening %s: %s\n", GPU_BOOST_PATH, buf);
+        } else {
+            len = write(gpu_boost_fd, GPU_FREQ_CONSTRAINT,
+                        strlen(GPU_FREQ_CONSTRAINT));
+            if (len < 0) {
+                strerror_r(errno, buf, sizeof(buf));
+                ALOGE("Error writing to %s: %s\n", GPU_BOOST_PATH, buf);
+            }
+        }
+    }
 
     pthread_mutex_unlock(&flounder->lock);
     return flounder->boostpulse_fd;
diff --git a/sensor_hub/libsensors/CwMcuSensor.cpp b/sensor_hub/libsensors/CwMcuSensor.cpp
index 71953a8..27aaba9 100644
--- a/sensor_hub/libsensors/CwMcuSensor.cpp
+++ b/sensor_hub/libsensors/CwMcuSensor.cpp
@@ -51,6 +51,10 @@
 
 static const char iio_dir[] = "/sys/bus/iio/devices/";
 
+static int min(int a, int b) {
+    return (a < b) ? a : b;
+}
+
 static int chomp(char *buf, size_t len) {
     if (buf == NULL)
         return -1;
@@ -174,8 +178,8 @@
     int fd;
     char buf[24];
     int err;
-    int64_t mcu_current_time;
-    int64_t cpu_current_time;
+    uint64_t mcu_current_time;
+    uint64_t cpu_current_time;
     int open_errno;
 
     ALOGV("sync_time_thread_in_class++:\n");
@@ -194,38 +198,42 @@
             ALOGE("sync_time_thread_in_class: read fail, err = %d\n", err);
         } else {
             buf[err] = '\0';
-            mcu_current_time = strtoll(buf, NULL, 10) * NS_PER_US;
+            mcu_current_time = strtoull(buf, NULL, 10) * NS_PER_US;
             if (errno == ERANGE) {
                 ALOGE("sync_time_thread_in_class: strtoll fails, strerr = %s, buf = %s\n",
                       strerror(errno), buf);
             } else {
                 pthread_mutex_lock(&sync_timestamp_algo_mutex);
 
-                cpu_to_mcu_time_offset = cpu_current_time - mcu_current_time;
-                ALOGV("Syncronization: cpu_to_mcu_time_offset = %" PRId64 " us\n", cpu_to_mcu_time_offset / NS_PER_US);
-
-                if (mcu_current_time != last_mcu_sync_time) {
-                    cpu_divided_by_mcu = (float)(cpu_current_time - last_cpu_sync_time) /
-                                         (float)(mcu_current_time - last_mcu_sync_time);
+                if (mcu_current_time == 0) {
+                    // Do a recovery mechanism of timestamp estimation when the sensor_hub reset happened
+                    ALOGE("Sync: sensor hub is on reset\n");
+                    time_slope = 1;
+                    memset(last_mcu_timestamp, 0, sizeof(last_mcu_timestamp));
+                    memset(last_cpu_timestamp, 0, sizeof(last_cpu_timestamp));
+                    for (int i=0; i<numSensors; i++) {
+                        offset_reset[i] = true;
+                    }
+                } else if ((mcu_current_time <= last_mcu_sync_time) || (last_mcu_sync_time == 0)) {
+                    ALOGV("Sync: time_slope was not estimated yet\n");
+                    time_slope = 1;
+                    time_offset = cpu_current_time - mcu_current_time;
+                    for (int i=0; i<numSensors; i++) {
+                        offset_reset[i] = true;
+                    }
                 } else {
-                    ALOGE("mcu_current_time == last_mcu_sync_time, unexpected\n");
+                    time_slope = (float)(cpu_current_time - last_cpu_sync_time) /
+                                 (float)(mcu_current_time - last_mcu_sync_time);
+                    time_offset = cpu_current_time - mcu_current_time;
                 }
+                ALOGV("Sync: time_offset = %" PRId64 ", time_slope = %f\n", time_offset, time_slope);
+                ALOGV("Sync: mcu_current_time = %" PRId64 ", last_mcu_sync_time = %" PRId64 "\n", mcu_current_time, last_mcu_sync_time);
+                ALOGV("Sync: cpu_current_time = %" PRId64 ", last_cpu_sync_time = %" PRId64 "\n", cpu_current_time, last_cpu_sync_time);
+
                 last_mcu_sync_time = mcu_current_time;
                 last_cpu_sync_time = cpu_current_time;
-                ALOGV("Syncronization: cpu_divided_by_mcu = %f\n", cpu_divided_by_mcu);
-
-                /*** weighted cpu_divided_by_mcu estimated algorithm ***/
-                if (last_cpu_divided_by_mcu == 0) {
-                    last_cpu_divided_by_mcu = cpu_divided_by_mcu;
-                }
-                cpu_divided_by_mcu = (cpu_divided_by_mcu + last_cpu_divided_by_mcu) * 0.5;
-                ALOGV("Syncronization: weighted cpu_divided_by_mcu = %f\n", cpu_divided_by_mcu);
-                last_cpu_divided_by_mcu = cpu_divided_by_mcu;
-                /*** weighted cpu_divided_by_mcu estimated algorithm ***/
 
                 pthread_mutex_unlock(&sync_timestamp_algo_mutex);
-
-                offset_changed = true;
             }
         }
         close(fd);
@@ -253,13 +261,18 @@
     : SensorBase(NULL, "CwMcuSensor")
     , mEnabled(0)
     , mInputReader(IIO_MAX_BUFF_SIZE)
-    , offset_changed(true)
-    , cpu_divided_by_mcu(0)
-    , cpu_to_mcu_time_offset(0)
+    , time_slope(1)
+    , time_offset(0)
     , init_trigger_done(false) {
 
     int rc;
 
+    memset(last_mcu_timestamp, 0, sizeof(last_mcu_timestamp));
+    memset(last_cpu_timestamp, 0, sizeof(last_cpu_timestamp));
+    for (int i=0; i<numSensors; i++) {
+        offset_reset[i] = true;
+    }
+
     mPendingEvents[CW_ACCELERATION].version = sizeof(sensors_event_t);
     mPendingEvents[CW_ACCELERATION].sensor = ID_A;
     mPendingEvents[CW_ACCELERATION].type = SENSOR_TYPE_ACCELEROMETER;
@@ -410,6 +423,7 @@
 
     if (data_fd >= 0) {
         int i;
+        int fd;
 
         ALOGV("%s: 11 Before pthread_mutex_lock()\n", __func__);
         pthread_mutex_lock(&sys_fs_mutex);
@@ -454,6 +468,21 @@
             ALOGE("CwMcuSensor::CwMcuSensor: set IIO buffer enable failed22: %s\n", strerror(errno));
         }
 
+        strcpy(&fixed_sysfs_path[fixed_sysfs_path_len], "calibrator_en");
+        fd = open(fixed_sysfs_path, O_RDWR);
+        if (fd >= 0) {
+            static const char buf[] = "12";
+
+            rc = write(fd, buf, sizeof(buf) - 1);
+            if (rc < 0) {
+                ALOGE("%s: write buf = %s, failed: %s", __func__, buf, strerror(errno));
+            }
+
+            close(fd);
+        } else {
+            ALOGE("%s open %s failed: %s", __func__, fixed_sysfs_path, strerror(errno));
+        }
+
         pthread_mutex_unlock(&sys_fs_mutex);
 
         ALOGV("%s: data_fd = %d", __func__, data_fd);
@@ -714,10 +743,6 @@
     return  0;
 }
 
-static int min(int a, int b) {
-    return (a < b) ? a : b;
-}
-
 int CwMcuSensor::setEnable(int32_t handle, int en) {
 
     int what;
@@ -740,7 +765,7 @@
     what = find_sensor(handle);
 
     ALOGD("CwMcuSensor::setEnable: "
-          "[v07-Support Non-wake up FIFO] handle = %d, en = %d, what = %d\n",
+          "[v10-Pass correct timestamp for Step and Significant], handle = %d, en = %d, what = %d\n",
           handle, en, what);
 
     if (uint32_t(what) >= numSensors) {
@@ -748,6 +773,7 @@
         return -EINVAL;
     }
 
+    offset_reset[what] = !!flags;
 
     strcpy(&fixed_sysfs_path[fixed_sysfs_path_len], "enable");
     fd = open(fixed_sysfs_path, O_RDWR);
@@ -1034,45 +1060,29 @@
             /*** The algorithm which parsed mcu_time into cpu_time for each event ***/
             uint64_t event_mcu_time = mPendingEvents[id].timestamp;
             uint64_t event_cpu_time;
-            if (offset_changed) {
-                pthread_mutex_lock(&sync_timestamp_algo_mutex);
-                if (cpu_to_mcu_time_offset == 0) {
-                    pthread_mutex_unlock(&sync_timestamp_algo_mutex);
-                    ALOGI("Not syncronized, cpu_to_mcu_time_offset == 0\n");
-                    sync_time_thread_in_class();
-                    pthread_mutex_lock(&sync_timestamp_algo_mutex);
-                }
-                algo_mcu_base = event_mcu_time;
-                algo_cpu_base = algo_mcu_base + cpu_to_mcu_time_offset;
 
-                pthread_mutex_unlock(&sync_timestamp_algo_mutex);
-
-                event_cpu_time = algo_cpu_base;
-                offset_changed = false;
-            } else {
-                pthread_mutex_lock(&sync_timestamp_algo_mutex);
-                if (cpu_divided_by_mcu == 0) {
-                    pthread_mutex_unlock(&sync_timestamp_algo_mutex);
-                    ALOGV("Not syncronized, cpu_divided_by_mcu == 0\n");
-                    sync_time_thread_in_class();
-                    pthread_mutex_lock(&sync_timestamp_algo_mutex);
-                }
-
-                uint64_t algo_mcu_diff = event_mcu_time - algo_mcu_base;
-                uint64_t algo_cpu_diff = algo_mcu_diff * cpu_divided_by_mcu;
-
-                pthread_mutex_unlock(&sync_timestamp_algo_mutex);
-
-                event_cpu_time = algo_cpu_base + algo_cpu_diff;
+            if (event_mcu_time < last_mcu_timestamp[id]) {
+                ALOGE("Do syncronization due to wrong delta mcu_timestamp\n");
+                sync_time_thread_in_class();
             }
 
+            pthread_mutex_lock(&sync_timestamp_algo_mutex);
+
+            if (offset_reset[id]) {
+                ALOGV("offset changed, id = %d, offset = %" PRId64 "\n", id, time_offset);
+                offset_reset[id] = false;
+                event_cpu_time = event_mcu_time + time_offset;
+            } else {
+                int64_t event_mcu_diff = (event_mcu_time - last_mcu_timestamp[id]);
+                int64_t event_cpu_diff = event_mcu_diff * time_slope;
+                event_cpu_time = last_cpu_timestamp[id] + event_cpu_diff;
+            }
+            last_mcu_timestamp[id] = event_mcu_time;
+            last_cpu_timestamp[id] = event_cpu_time;
+            pthread_mutex_unlock(&sync_timestamp_algo_mutex);
+
             pthread_mutex_lock(&last_timestamp_mutex);
 
-            if ((event_cpu_time - last_timestamp[id]) <= 0) {
-                ALOGV("Filter event which delta_timestamp <= 0, delta = %" PRId64 " us\n",
-                      (event_cpu_time - last_timestamp[id]) / NS_PER_US);
-                event_cpu_time = last_timestamp[id];
-            }
             ALOGV("readEvents: id = %d,"
                   " mcu_time = %" PRId64 " ms,"
                   " cpu_time = %" PRId64 " ns,"
@@ -1184,8 +1194,7 @@
     case CW_SIGNIFICANT_MOTION:
         mPendingMask.markBit(sensorsid);
         mPendingEvents[sensorsid].data[0] = 1.0;
-        mPendingEvents[sensorsid].timestamp = getTimestamp();
-        ALOGV("sensors_id = %d, data = %p", sensorsid, data);
+        ALOGV("SIGNIFICANT timestamp = %" PRIu64 "\n", mPendingEvents[sensorsid].timestamp);
         break;
     case CW_LIGHT:
         mPendingMask.markBit(sensorsid);
@@ -1195,13 +1204,14 @@
     case CW_STEP_DETECTOR_W:
         mPendingMask.markBit(sensorsid);
         mPendingEvents[sensorsid].data[0] = data[0];
-        mPendingEvents[sensorsid].timestamp = getTimestamp();
+        ALOGV("STEP_DETECTOR, timestamp = %" PRIu64 "\n", mPendingEvents[sensorsid].timestamp);
         break;
     case CW_STEP_COUNTER:
     case CW_STEP_COUNTER_W:
         mPendingMask.markBit(sensorsid);
         // We use 4 bytes in SensorHUB
         mPendingEvents[sensorsid].u64.step_counter = *(uint32_t *)&data[0];
+        mPendingEvents[sensorsid].u64.step_counter += 0x100000000LL * (*(uint32_t *)&bias[0]);
         ALOGV("processEvent: step counter = %" PRId64 "\n",
               mPendingEvents[sensorsid].u64.step_counter);
         break;
diff --git a/sensor_hub/libsensors/CwMcuSensor.h b/sensor_hub/libsensors/CwMcuSensor.h
index 8deb8b4..5d1ea14 100644
--- a/sensor_hub/libsensors/CwMcuSensor.h
+++ b/sensor_hub/libsensors/CwMcuSensor.h
@@ -82,7 +82,7 @@
 
 #define TIMESTAMP_SYNC_CODE        (98)
 
-#define PERIODIC_SYNC_TIME_SEC     (30)
+#define PERIODIC_SYNC_TIME_SEC     (5)
 
 class CwMcuSensor : public SensorBase {
 
@@ -98,16 +98,16 @@
         char mDevPath[PATH_MAX];
         char mTriggerName[PATH_MAX];
 
-        bool offset_changed;
-        float cpu_divided_by_mcu;
-        float last_cpu_divided_by_mcu;
-        int64_t last_timestamp[numSensors];
-        int64_t last_mcu_sync_time;
-        int64_t last_cpu_sync_time;
-        int64_t cpu_to_mcu_time_offset;
+        float time_slope;
+        int64_t time_offset;
+        uint64_t last_mcu_sync_time;
+        uint64_t last_cpu_sync_time;
+
+        bool offset_reset[numSensors];
+        uint64_t last_mcu_timestamp[numSensors];
+        uint64_t last_cpu_timestamp[numSensors];
+        uint64_t last_timestamp[numSensors];
         pthread_t sync_time_thread;
-        uint64_t algo_cpu_base;
-        uint64_t algo_mcu_base;
 
         bool init_trigger_done;
 
diff --git a/sensor_hub/libsensors/SensorBase.cpp b/sensor_hub/libsensors/SensorBase.cpp
index 0f3e346..6fcf871 100644
--- a/sensor_hub/libsensors/SensorBase.cpp
+++ b/sensor_hub/libsensors/SensorBase.cpp
@@ -109,7 +109,7 @@
 int64_t SensorBase::getTimestamp() {
     struct timespec t;
     t.tv_sec = t.tv_nsec = 0;
-    clock_gettime(CLOCK_MONOTONIC, &t);
+    clock_gettime(CLOCK_BOOTTIME, &t);
     return int64_t(t.tv_sec)*NS_PER_SEC + t.tv_nsec;
 }
 
diff --git a/sepolicy/device.te b/sepolicy/device.te
index 16c7745..32f49c1 100644
--- a/sepolicy/device.te
+++ b/sepolicy/device.te
@@ -3,3 +3,6 @@
 
 # Radio related block device
 type efs_block_device, dev_type;
+
+# GPU Frequency Constraint device
+type gpu_freq_device, dev_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index fbafc5d..cc2b74c 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -8,6 +8,8 @@
 /dev/nvhost-vic			u:object_r:gpu_device:s0
 /dev/nvmap			u:object_r:gpu_device:s0
 /dev/nvhdcp0			u:object_r:gpu_device:s0
+# gpu freq
+/dev/constraint_gpu_freq	u:object_r:gpu_freq_device:s0
 # enable UART port permission
 /dev/ttyTHS2			u:object_r:hci_attach_dev:s0
 # nfc
@@ -52,6 +54,7 @@
 /dev/hsicctl[0-3]                      u:object_r:radio_device:s0
 /dev/ks_hsic_bridge                    u:object_r:kickstart_device:s0
 /dev/efs_hsic_bridge                   u:object_r:kickstart_device:s0
+/dev/diag_mdm                          u:object_r:kickstart_device:s0
 # RCA, EF1, EF2, CDR labeling
 /dev/block/mmcblk0p8                   u:object_r:efs_block_device:s0
 /dev/block/mmcblk0p21                  u:object_r:efs_block_device:s0
diff --git a/sepolicy/radio.te b/sepolicy/radio.te
index 229051b..36ed9ef 100644
--- a/sepolicy/radio.te
+++ b/sepolicy/radio.te
@@ -1,2 +1,9 @@
 # Talk to qmuxd (/dev/socket/qmux_radio)
 qmux_socket(radio)
+
+# The following 3 are needed for QXDM Logger
+userdebug_or_eng(`
+  allow radio radio_data_file:file { execute execute_no_trans };
+  allow radio kickstart_device:chr_file rw_file_perms;
+  allow radio su_exec:file getattr;
+')
diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te
index 8f82558..7ab1c16 100644
--- a/sepolicy/system_server.te
+++ b/sepolicy/system_server.te
@@ -1,5 +1,6 @@
 # allow power hal to adjust max frequency
 allow system_server sysfs_devices_system_cpu:file w_file_perms;
+allow system_server gpu_freq_device:chr_file w_file_perms;
 
 allow system_server gps_data_file:fifo_file { setattr create_file_perms };
 allow system_server gps_data_file:dir rw_dir_perms;
diff --git a/ueventd.flounder.rc b/ueventd.flounder.rc
index 29d81b0..477c521 100644
--- a/ueventd.flounder.rc
+++ b/ueventd.flounder.rc
@@ -21,6 +21,7 @@
 /dev/tfa9895    0660    system  audio
 /dev/tfa9895l   0660    system  audio
 /dev/tegra_dc*  0660    system  system
+/dev/constraint_gpu_freq 0660 system system
 /dev/ttyACM*    0660    radio   system
 /dev/ttyACM2    0660    radio   log
 /dev/nvhdcp0    0666    system  system