merge in mnc-dr-release history after reset to mnc-dr-dev
diff --git a/audio/include/system/audio.h b/audio/include/system/audio.h
index 8e71b9b..1fb0dac 100644
--- a/audio/include/system/audio.h
+++ b/audio/include/system/audio.h
@@ -1420,7 +1420,7 @@
 static inline bool audio_device_is_digital(audio_devices_t device) {
     if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
         // input
-        return (device & (AUDIO_DEVICE_IN_ALL_USB |
+        return (~AUDIO_DEVICE_BIT_IN & device & (AUDIO_DEVICE_IN_ALL_USB |
                           AUDIO_DEVICE_IN_HDMI |
                           AUDIO_DEVICE_IN_SPDIF |
                           AUDIO_DEVICE_IN_IP)) != 0;
diff --git a/audio_utils/include/audio_utils/spdif/FrameScanner.h b/audio_utils/include/audio_utils/spdif/FrameScanner.h
index 7b88ae2..6d391ee 100644
--- a/audio_utils/include/audio_utils/spdif/FrameScanner.h
+++ b/audio_utils/include/audio_utils/spdif/FrameScanner.h
@@ -97,6 +97,11 @@
      */
     virtual bool isLastInBurst()  = 0;
 
+    /**
+     * Most compression types use a lengthCode expressed in bits.
+     */
+    virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const { return numBytes * 8; }
+
 protected:
     uint32_t  mBytesSkipped;     // how many bytes were skipped looking for the start of a frame
     const uint8_t *mSyncBytes;   // pointer to the sync word specific to a format
diff --git a/audio_utils/spdif/AC3FrameScanner.cpp b/audio_utils/spdif/AC3FrameScanner.cpp
index 7f8068d..ffbedb5 100644
--- a/audio_utils/spdif/AC3FrameScanner.cpp
+++ b/audio_utils/spdif/AC3FrameScanner.cpp
@@ -126,6 +126,12 @@
     }
 }
 
+// Per IEC 61973-3:5.3.3, for E-AC3 burst-length shall be in bytes.
+uint16_t AC3FrameScanner::convertBytesToLengthCode(uint16_t numBytes) const
+{
+    return (mDataType == SPDIF_DATA_TYPE_E_AC3) ? numBytes : numBytes * 8;
+}
+
 // per IEC 61973-3 Paragraph 5.3.3
 // We have to send 6 audio blocks on all active substreams.
 // Substream zero must be the first.
@@ -204,7 +210,10 @@
         // Keep track of how many audio blocks we have for each substream.
         // This should be safe because mSubstreamID is ANDed with 0x07 above.
         // And the array is allocated as [8].
-        mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame;
+        if ((mStreamType == AC3_STREAM_TYPE_0)
+                || (mStreamType == AC3_STREAM_TYPE_2)) {
+            mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame;
+        }
 
         // Print enough so we can see all the substreams.
         ALOGD_IF((mFormatDumpCount < 3*8 ),
diff --git a/audio_utils/spdif/AC3FrameScanner.h b/audio_utils/spdif/AC3FrameScanner.h
index f944dcc..1ef5610 100644
--- a/audio_utils/spdif/AC3FrameScanner.h
+++ b/audio_utils/spdif/AC3FrameScanner.h
@@ -47,6 +47,8 @@
     virtual bool isLastInBurst();
     virtual void resetBurst();
 
+    virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const;
+
 protected:
     // Keep track of how many of each substream blocks have been accumulated.
     // We need all of each substream before sending block data burst.
diff --git a/audio_utils/spdif/SPDIFEncoder.cpp b/audio_utils/spdif/SPDIFEncoder.cpp
index 7a54627..2eeeba6 100644
--- a/audio_utils/spdif/SPDIFEncoder.cpp
+++ b/audio_utils/spdif/SPDIFEncoder.cpp
@@ -175,9 +175,9 @@
 {
     const int preambleSize = 4 * sizeof(uint16_t);
     if (mByteCursor > preambleSize) {
-        // Set number of bits for valid payload before zeroPad.
-        uint16_t lengthCode = (mByteCursor - preambleSize) * 8;
-        mBurstBuffer[3] = lengthCode;
+        // Set lengthCode for valid payload before zeroPad.
+        uint16_t numBytes = (mByteCursor - preambleSize);
+        mBurstBuffer[3] = mFramer->convertBytesToLengthCode(numBytes);
 
         sendZeroPad();
         writeOutput(mBurstBuffer, mByteCursor);
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 2116bbd..b336045 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -3852,9 +3852,8 @@
                     <span class="entry_type_enum_name">HIGH_SPEED_VIDEO</span>
                     <span class="entry_type_enum_deprecated">[deprecated]</span>
                     <span class="entry_type_enum_optional">[optional]</span>
-                    <span class="entry_type_enum_notes"><p>This is deprecated,<wbr/> please use
-<a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>
-and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedRequestList">CameraDevice#createConstrainedHighSpeedRequestList</a>
+                    <span class="entry_type_enum_notes"><p>This is deprecated,<wbr/> please use <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>
+and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession.html#createHighSpeedRequestList">CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList</a>
 for high speed video recording.<wbr/></p>
 <p>Optimized for high speed video recording (frame rate &gt;=60fps) use case.<wbr/></p>
 <p>The supported high speed video sizes and fps ranges are specified in
@@ -5155,7 +5154,7 @@
 the max possible number of frames the camera device will group together for this high
 speed stream configuration.<wbr/> This max batch size will be used to generate a high speed
 recording request list by
-<a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedRequestList">CameraDevice#createConstrainedHighSpeedRequestList</a>.<wbr/>
+<a href="https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession.html#createHighSpeedRequestList">CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList</a>.<wbr/>
 The max batch size for each configuration will satisfy below conditions:</p>
 <ul>
 <li>Each max batch size will be a divisor of its corresponding fps_<wbr/>max /<wbr/> 30.<wbr/> For example,<wbr/>
@@ -8323,9 +8322,8 @@
                     <span class="entry_type_enum_name">HIGH_SPEED_VIDEO</span>
                     <span class="entry_type_enum_deprecated">[deprecated]</span>
                     <span class="entry_type_enum_optional">[optional]</span>
-                    <span class="entry_type_enum_notes"><p>This is deprecated,<wbr/> please use
-<a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>
-and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedRequestList">CameraDevice#createConstrainedHighSpeedRequestList</a>
+                    <span class="entry_type_enum_notes"><p>This is deprecated,<wbr/> please use <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>
+and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession.html#createHighSpeedRequestList">CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList</a>
 for high speed video recording.<wbr/></p>
 <p>Optimized for high speed video recording (frame rate &gt;=60fps) use case.<wbr/></p>
 <p>The supported high speed video sizes and fps ranges are specified in
@@ -15449,8 +15447,8 @@
                     <span class="entry_type_enum_notes"><p>The device supports constrained high speed video recording (frame rate &gt;=120fps)
 use case.<wbr/> The camera device will support high speed capture session created by
 <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>,<wbr/> which
-only accepts high speed request list created by
-<a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedRequestList">CameraDevice#createConstrainedHighSpeedRequestList</a>.<wbr/></p>
+only accepts high speed request lists created by
+<a href="https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession.html#createHighSpeedRequestList">CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList</a>.<wbr/></p>
 <p>A camera device can still support high speed video streaming by advertising the high speed
 FPS ranges in <a href="#static_android.control.aeAvailableTargetFpsRanges">android.<wbr/>control.<wbr/>ae<wbr/>Available<wbr/>Target<wbr/>Fps<wbr/>Ranges</a>.<wbr/> For this case,<wbr/> all normal
 capture request per frame control and synchronization requirements will apply to
@@ -15511,9 +15509,9 @@
 <li>The FPS ranges are selected from
 <a href="https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap.html#getHighSpeedVideoFpsRanges">StreamConfigurationMap#getHighSpeedVideoFpsRanges</a>.<wbr/></li>
 </ul>
-<p>When above conditions are NOT satistied,<wbr/> the
+<p>When above conditions are NOT satistied,<wbr/>
 <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedCaptureSession">CameraDevice#createConstrainedHighSpeedCaptureSession</a>
-and <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createConstrainedHighSpeedRequestList">CameraDevice#createConstrainedHighSpeedRequestList</a> will fail.<wbr/></p>
+will fail.<wbr/></p>
 <p>Switching to a FPS range that has different maximum FPS may trigger some camera device
 reconfigurations,<wbr/> which may introduce extra latency.<wbr/> It is recommended that
 the application avoids unnecessary maximum target FPS changes as much as possible
diff --git a/camera/docs/metadata_properties.xml b/camera/docs/metadata_properties.xml
index 874ce0c..8422704 100644
--- a/camera/docs/metadata_properties.xml
+++ b/camera/docs/metadata_properties.xml
@@ -1601,9 +1601,10 @@
             </value>
             <value deprecated="true" optional="true">HIGH_SPEED_VIDEO
               <notes>
-              This is deprecated, please use
-              {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedCaptureSession}
-              and {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedRequestList}
+              This is deprecated, please use {@link
+              android.hardware.camera2.CameraDevice#createConstrainedHighSpeedCaptureSession}
+              and {@link
+              android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}
               for high speed video recording.
 
               Optimized for high speed video recording (frame rate >=60fps) use case.
@@ -2604,7 +2605,7 @@
           the max possible number of frames the camera device will group together for this high
           speed stream configuration. This max batch size will be used to generate a high speed
           recording request list by
-          {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedRequestList}.
+          {@link android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}.
           The max batch size for each configuration will satisfy below conditions:
 
           * Each max batch size will be a divisor of its corresponding fps_max / 30. For example,
@@ -4729,8 +4730,8 @@
               The device supports constrained high speed video recording (frame rate >=120fps)
               use case. The camera device will support high speed capture session created by
               {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedCaptureSession}, which
-              only accepts high speed request list created by
-              {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedRequestList}.
+              only accepts high speed request lists created by
+              {@link android.hardware.camera2.CameraConstrainedHighSpeedCaptureSession#createHighSpeedRequestList}.
 
               A camera device can still support high speed video streaming by advertising the high speed
               FPS ranges in android.control.aeAvailableTargetFpsRanges. For this case, all normal
@@ -4795,9 +4796,9 @@
               * The FPS ranges are selected from
               {@link android.hardware.camera2.params.StreamConfigurationMap#getHighSpeedVideoFpsRanges}.
 
-              When above conditions are NOT satistied, the
+              When above conditions are NOT satistied,
               {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedCaptureSession}
-              and {@link android.hardware.camera2.CameraDevice#createConstrainedHighSpeedRequestList} will fail.
+              will fail.
 
               Switching to a FPS range that has different maximum FPS may trigger some camera device
               reconfigurations, which may introduce extra latency. It is recommended that