Merge "Dynamics Processing Effect" into pi-dev
diff --git a/audio/include/system/audio-base-utils.h b/audio/include/system/audio-base-utils.h
index bd3e763..016a085 100644
--- a/audio/include/system/audio-base-utils.h
+++ b/audio/include/system/audio-base-utils.h
@@ -65,8 +65,8 @@
                                 AUDIO_CHANNEL_OUT_TOP_BACK_LEFT |
                                 AUDIO_CHANNEL_OUT_TOP_BACK_CENTER |
                                 AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT |
-                                AUDIO_CHANNEL_OUT_TOP_CENTER_LEFT |
-                                AUDIO_CHANNEL_OUT_TOP_CENTER_RIGHT,
+                                AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT |
+                                AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT,
 
     AUDIO_CHANNEL_IN_ALL      = AUDIO_CHANNEL_IN_LEFT |
                                 AUDIO_CHANNEL_IN_RIGHT |
diff --git a/audio/include/system/audio-base.h b/audio/include/system/audio-base.h
index 9152084..6d8e08b 100644
--- a/audio/include/system/audio-base.h
+++ b/audio/include/system/audio-base.h
@@ -195,15 +195,15 @@
     AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 32768u,
     AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 65536u,
     AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 131072u,
-    AUDIO_CHANNEL_OUT_TOP_CENTER_LEFT = 262144u,
-    AUDIO_CHANNEL_OUT_TOP_CENTER_RIGHT = 524288u,
+    AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT = 262144u,
+    AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT = 524288u,
     AUDIO_CHANNEL_OUT_MONO = 1u, // OUT_FRONT_LEFT
     AUDIO_CHANNEL_OUT_STEREO = 3u, // (OUT_FRONT_LEFT | OUT_FRONT_RIGHT)
     AUDIO_CHANNEL_OUT_2POINT1 = 11u, // ((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_LOW_FREQUENCY)
-    AUDIO_CHANNEL_OUT_2POINT0POINT2 = 786435u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_TOP_CENTER_LEFT) | OUT_TOP_CENTER_RIGHT)
-    AUDIO_CHANNEL_OUT_2POINT1POINT2 = 786443u, // ((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_TOP_CENTER_LEFT) | OUT_TOP_CENTER_RIGHT) | OUT_LOW_FREQUENCY)
-    AUDIO_CHANNEL_OUT_3POINT0POINT2 = 786439u, // ((((OUT_FRONT_LEFT | OUT_FRONT_CENTER) | OUT_FRONT_RIGHT) | OUT_TOP_CENTER_LEFT) | OUT_TOP_CENTER_RIGHT)
-    AUDIO_CHANNEL_OUT_3POINT1POINT2 = 786447u, // (((((OUT_FRONT_LEFT | OUT_FRONT_CENTER) | OUT_FRONT_RIGHT) | OUT_TOP_CENTER_LEFT) | OUT_TOP_CENTER_RIGHT) | OUT_LOW_FREQUENCY)
+    AUDIO_CHANNEL_OUT_2POINT0POINT2 = 786435u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_2POINT1POINT2 = 786443u, // ((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT) | OUT_LOW_FREQUENCY)
+    AUDIO_CHANNEL_OUT_3POINT0POINT2 = 786439u, // ((((OUT_FRONT_LEFT | OUT_FRONT_CENTER) | OUT_FRONT_RIGHT) | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_3POINT1POINT2 = 786447u, // (((((OUT_FRONT_LEFT | OUT_FRONT_CENTER) | OUT_FRONT_RIGHT) | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT) | OUT_LOW_FREQUENCY)
     AUDIO_CHANNEL_OUT_QUAD = 51u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_BACK_LEFT) | OUT_BACK_RIGHT)
     AUDIO_CHANNEL_OUT_QUAD_BACK = 51u, // OUT_QUAD
     AUDIO_CHANNEL_OUT_QUAD_SIDE = 1539u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
@@ -212,8 +212,12 @@
     AUDIO_CHANNEL_OUT_5POINT1 = 63u, // (((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) | OUT_BACK_RIGHT)
     AUDIO_CHANNEL_OUT_5POINT1_BACK = 63u, // OUT_5POINT1
     AUDIO_CHANNEL_OUT_5POINT1_SIDE = 1551u, // (((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_5POINT1POINT2 = 786495u, // ((OUT_5POINT1 | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_5POINT1POINT4 = 184383u, // ((((OUT_5POINT1 | OUT_TOP_FRONT_LEFT) | OUT_TOP_FRONT_RIGHT) | OUT_TOP_BACK_LEFT) | OUT_TOP_BACK_RIGHT)
     AUDIO_CHANNEL_OUT_6POINT1 = 319u, // ((((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) | OUT_BACK_RIGHT) | OUT_BACK_CENTER)
     AUDIO_CHANNEL_OUT_7POINT1 = 1599u, // (((((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) | OUT_BACK_RIGHT) | OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_7POINT1POINT2 = 788031u, // ((OUT_7POINT1 | OUT_TOP_SIDE_LEFT) | OUT_TOP_SIDE_RIGHT)
+    AUDIO_CHANNEL_OUT_7POINT1POINT4 = 185919u, // ((((OUT_7POINT1 | OUT_TOP_FRONT_LEFT) | OUT_TOP_FRONT_RIGHT) | OUT_TOP_BACK_LEFT) | OUT_TOP_BACK_RIGHT)
     AUDIO_CHANNEL_IN_LEFT = 4u,
     AUDIO_CHANNEL_IN_RIGHT = 8u,
     AUDIO_CHANNEL_IN_FRONT = 16u,
@@ -238,6 +242,10 @@
     AUDIO_CHANNEL_IN_STEREO = 12u, // (IN_LEFT | IN_RIGHT)
     AUDIO_CHANNEL_IN_FRONT_BACK = 48u, // (IN_FRONT | IN_BACK)
     AUDIO_CHANNEL_IN_6 = 252u, // (((((IN_LEFT | IN_RIGHT) | IN_FRONT) | IN_BACK) | IN_LEFT_PROCESSED) | IN_RIGHT_PROCESSED)
+    AUDIO_CHANNEL_IN_2POINT0POINT2 = 6291468u, // (((IN_LEFT | IN_RIGHT) | IN_TOP_LEFT) | IN_TOP_RIGHT)
+    AUDIO_CHANNEL_IN_2POINT1POINT2 = 7340044u, // ((((IN_LEFT | IN_RIGHT) | IN_TOP_LEFT) | IN_TOP_RIGHT) | IN_LOW_FREQUENCY)
+    AUDIO_CHANNEL_IN_3POINT0POINT2 = 6553612u, // ((((IN_LEFT | IN_CENTER) | IN_RIGHT) | IN_TOP_LEFT) | IN_TOP_RIGHT)
+    AUDIO_CHANNEL_IN_3POINT1POINT2 = 7602188u, // (((((IN_LEFT | IN_CENTER) | IN_RIGHT) | IN_TOP_LEFT) | IN_TOP_RIGHT) | IN_LOW_FREQUENCY)
     AUDIO_CHANNEL_IN_5POINT1 = 1507340u, // (((((IN_LEFT | IN_CENTER) | IN_RIGHT) | IN_BACK_LEFT) | IN_BACK_RIGHT) | IN_LOW_FREQUENCY)
     AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = 16400u, // (IN_VOICE_UPLINK | IN_MONO)
     AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = 32784u, // (IN_VOICE_DNLINK | IN_MONO)
diff --git a/audio/include/system/audio.h b/audio/include/system/audio.h
index a0d36c1..713214c 100644
--- a/audio/include/system/audio.h
+++ b/audio/include/system/audio.h
@@ -599,6 +599,11 @@
     return false;
 }
 
+static inline bool audio_is_hearing_aid_out_device(audio_devices_t device)
+{
+    return device == AUDIO_DEVICE_OUT_HEARING_AID;
+}
+
 static inline bool audio_is_usb_out_device(audio_devices_t device)
 {
     return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB));
@@ -818,6 +823,28 @@
             AUDIO_CHANNEL_REPRESENTATION_POSITION, bits);
 }
 
+static inline audio_channel_mask_t audio_channel_mask_in_to_out(audio_channel_mask_t in)
+{
+    switch (in) {
+    case AUDIO_CHANNEL_IN_MONO:
+        return AUDIO_CHANNEL_OUT_MONO;
+    case AUDIO_CHANNEL_IN_STEREO:
+        return AUDIO_CHANNEL_OUT_STEREO;
+    case AUDIO_CHANNEL_IN_5POINT1:
+        return AUDIO_CHANNEL_OUT_5POINT1;
+    case AUDIO_CHANNEL_IN_3POINT1POINT2:
+        return AUDIO_CHANNEL_OUT_3POINT1POINT2;
+    case AUDIO_CHANNEL_IN_3POINT0POINT2:
+        return AUDIO_CHANNEL_OUT_3POINT0POINT2;
+    case AUDIO_CHANNEL_IN_2POINT1POINT2:
+        return AUDIO_CHANNEL_OUT_2POINT1POINT2;
+    case AUDIO_CHANNEL_IN_2POINT0POINT2:
+        return AUDIO_CHANNEL_OUT_2POINT0POINT2;
+    default:
+        return AUDIO_CHANNEL_INVALID;
+    }
+}
+
 static inline bool audio_is_valid_format(audio_format_t format)
 {
     switch (format & AUDIO_FORMAT_MAIN_MASK) {
@@ -841,6 +868,8 @@
     case AUDIO_FORMAT_AAC_ADTS:
     case AUDIO_FORMAT_HE_AAC_V1:
     case AUDIO_FORMAT_HE_AAC_V2:
+    case AUDIO_FORMAT_AAC_ELD:
+    case AUDIO_FORMAT_AAC_XHE:
     case AUDIO_FORMAT_VORBIS:
     case AUDIO_FORMAT_OPUS:
     case AUDIO_FORMAT_AC3:
@@ -1070,6 +1099,7 @@
 #define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix"
 #define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload"
 #define AUDIO_HARDWARE_MODULE_ID_STUB "stub"
+#define AUDIO_HARDWARE_MODULE_ID_HEARING_AID "hearing_aid"
 
 /**
  * Multi-Stream Decoder (MSD) HAL service name. MSD HAL is used to mix
@@ -1165,9 +1195,4 @@
 #define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES  "delay_samples"
 #define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES  "padding_samples"
 
-// FIXME: a temporary declaration for the incall music flag, will be removed when
-// declared in types.hal for audio HAL V4.0 and auto imported to audio-base.h
-#define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x10000
-
-
 #endif  // ANDROID_AUDIO_CORE_H
diff --git a/audio/include/system/audio_policy.h b/audio/include/system/audio_policy.h
index 2e2e90b..110b9c6 100644
--- a/audio/include/system/audio_policy.h
+++ b/audio/include/system/audio_policy.h
@@ -67,6 +67,7 @@
     AUDIO_POLICY_FORCE_FOR_SYSTEM,
     AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO,
     AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND,
+    AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING,
 
     AUDIO_POLICY_FORCE_USE_CNT,
     AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1,
diff --git a/camera/Android.bp b/camera/Android.bp
index 4b234be..cee3115 100644
--- a/camera/Android.bp
+++ b/camera/Android.bp
@@ -11,6 +11,7 @@
     include_dirs: ["system/media/private/camera/include"],
     local_include_dirs: ["include"],
     export_include_dirs: ["include"],
+    export_shared_lib_headers: ["libcutils"],
 
     shared_libs: [
         "libcutils",
diff --git a/camera/docs/CameraMetadataKeys.mako b/camera/docs/CameraMetadataKeys.mako
index f9ce15e..6006c8d 100644
--- a/camera/docs/CameraMetadataKeys.mako
+++ b/camera/docs/CameraMetadataKeys.mako
@@ -52,6 +52,7 @@
   % endif
   % if entry.deprecated:
      * @deprecated
+${entry.deprecation_description | javadoc(metadata)}
   % endif
   % if entry.applied_visibility in ('hidden', 'ndk_public'):
      * @hide
diff --git a/camera/docs/HidlMetadata.mako b/camera/docs/HidlMetadata.mako
index 4a307cb..dcbbde7 100644
--- a/camera/docs/HidlMetadata.mako
+++ b/camera/docs/HidlMetadata.mako
@@ -42,6 +42,7 @@
 
 % endif
 <%    gotSections = False %>\
+<%    gotFirstNewSection = False %>\
 % for idx, section in enumerate(find_all_sections_added_in_hal(metadata, hal_major_version(), hal_minor_version())):
   % if idx == 0:
 <%    gotSections = True %>\
@@ -51,9 +52,10 @@
  */
 enum CameraMetadataSection : ${'uint32_t' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '@%d.%d::CameraMetadataSection' % (hal_major_version(), hal_minor_version()-1)} {
   % endif
-  % if first_hal_minor_version(hal_major_version()) != hal_minor_version():
+  % if first_hal_minor_version(hal_major_version()) != hal_minor_version() and not gotFirstNewSection:
     ${path_name(section) | csym} =
         android.hardware.camera.metadata@${hal_major_version()}.${hal_minor_version()-1}::CameraMetadataSection:ANDROID_SECTION_COUNT,
+<% gotFirstNewSection = True %>\
   % else:
     ${path_name(section) | csym},
   % endif
diff --git a/camera/docs/camera_device_info.proto b/camera/docs/camera_device_info.proto
index 392bad9..10b8f87 100644
--- a/camera/docs/camera_device_info.proto
+++ b/camera/docs/camera_device_info.proto
@@ -155,6 +155,7 @@
     optional int32 android_reprocess_maxCaptureStall = 1638400;
     optional bool android_depth_depthIsExclusive = 1703936;
     optional int32 android_logicalMultiCamera_sensorSyncType = 1769472;
+    repeated int32 android_distortionCorrection_availableModes = 1835008;
     // End of codegen fields
   }
 
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 3e4b337..81469ae 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -517,9 +517,12 @@
             <li
             ><a href="#static_android.lens.intrinsicCalibration">android.lens.intrinsicCalibration</a></li>
             <li
+                class="toc_deprecated"
             ><a href="#static_android.lens.radialDistortion">android.lens.radialDistortion</a></li>
             <li
             ><a href="#static_android.lens.poseReference">android.lens.poseReference</a></li>
+            <li
+            ><a href="#static_android.lens.distortion">android.lens.distortion</a></li>
           </ul>
         </li>
         <li>
@@ -546,7 +549,10 @@
             <li
             ><a href="#dynamic_android.lens.intrinsicCalibration">android.lens.intrinsicCalibration</a></li>
             <li
+                class="toc_deprecated"
             ><a href="#dynamic_android.lens.radialDistortion">android.lens.radialDistortion</a></li>
+            <li
+            ><a href="#dynamic_android.lens.distortion">android.lens.distortion</a></li>
           </ul>
         </li>
       </ul> <!-- toc_section -->
@@ -1179,6 +1185,32 @@
         </li>
       </ul> <!-- toc_section -->
     </li>
+    <li>
+      <span class="toc_section_header"><a href="#section_distortionCorrection">distortionCorrection</a></span>
+      <ul class="toc_section">
+        <li>
+          <span class="toc_kind_header">controls</span>
+          <ul class="toc_section">
+            <li
+            ><a href="#controls_android.distortionCorrection.mode">android.distortionCorrection.mode</a></li>
+          </ul>
+        </li>
+        <li>
+          <span class="toc_kind_header">static</span>
+          <ul class="toc_section">
+            <li
+            ><a href="#static_android.distortionCorrection.availableModes">android.distortionCorrection.availableModes</a></li>
+          </ul>
+        </li>
+        <li>
+          <span class="toc_kind_header">dynamic</span>
+          <ul class="toc_section">
+            <li
+            ><a href="#dynamic_android.distortionCorrection.mode">android.distortionCorrection.mode</a></li>
+          </ul>
+        </li>
+      </ul> <!-- toc_section -->
+    </li>
   </ul>
 
 
@@ -2486,8 +2518,8 @@
 for the external flash.<wbr/> Otherwise,<wbr/> this mode acts like ON.<wbr/></p>
 <p>When the external flash is turned off,<wbr/> AE mode should be changed to one of the
 other available AE modes.<wbr/></p>
-<p>If the camera device supports AE external flash mode,<wbr/> aeState must be
-FLASH_<wbr/>REQUIRED after the camera device finishes AE scan and it's too dark without
+<p>If the camera device supports AE external flash mode,<wbr/> <a href="#dynamic_android.control.aeState">android.<wbr/>control.<wbr/>ae<wbr/>State</a> must
+be FLASH_<wbr/>REQUIRED after the camera device finishes AE scan and it's too dark without
 flash.<wbr/></p></span>
                   </li>
                 </ul>
@@ -6385,8 +6417,8 @@
 for the external flash.<wbr/> Otherwise,<wbr/> this mode acts like ON.<wbr/></p>
 <p>When the external flash is turned off,<wbr/> AE mode should be changed to one of the
 other available AE modes.<wbr/></p>
-<p>If the camera device supports AE external flash mode,<wbr/> aeState must be
-FLASH_<wbr/>REQUIRED after the camera device finishes AE scan and it's too dark without
+<p>If the camera device supports AE external flash mode,<wbr/> <a href="#dynamic_android.control.aeState">android.<wbr/>control.<wbr/>ae<wbr/>State</a> must
+be FLASH_<wbr/>REQUIRED after the camera device finishes AE scan and it's too dark without
 flash.<wbr/></p></span>
                   </li>
                 </ul>
@@ -6972,8 +7004,8 @@
 </tbody>
 </table>
 <p>If the camera device supports AE external flash mode (ON_<wbr/>EXTERNAL_<wbr/>FLASH is included in
-<a href="#static_android.control.aeAvailableModes">android.<wbr/>control.<wbr/>ae<wbr/>Available<wbr/>Modes</a>),<wbr/> aeState must be FLASH_<wbr/>REQUIRED after the camera device
-finishes AE scan and it's too dark without flash.<wbr/></p>
+<a href="#static_android.control.aeAvailableModes">android.<wbr/>control.<wbr/>ae<wbr/>Available<wbr/>Modes</a>),<wbr/> <a href="#dynamic_android.control.aeState">android.<wbr/>control.<wbr/>ae<wbr/>State</a> must be FLASH_<wbr/>REQUIRED after
+the camera device finishes AE scan and it's too dark without flash.<wbr/></p>
 <p>For the above table,<wbr/> the camera device may skip reporting any state changes that happen
 without application intervention (i.<wbr/>e.<wbr/> mode switch,<wbr/> trigger,<wbr/> locking).<wbr/> Any state that
 can be skipped in that manner is called a transient state.<wbr/></p>
@@ -13531,7 +13563,7 @@
 from the main sensor along the +X axis (to the right from the user's perspective) will
 report <code>(0.<wbr/>03,<wbr/> 0,<wbr/> 0)</code>.<wbr/></p>
 <p>To transform a pixel coordinates between two cameras facing the same direction,<wbr/> first
-the source camera <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a> must be corrected for.<wbr/>  Then the source
+the source camera <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> must be corrected for.<wbr/>  Then the source
 camera <a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a> needs to be applied,<wbr/> followed by the
 <a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a> of the source camera,<wbr/> the translation of the source camera
 relative to the destination camera,<wbr/> the <a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a> of the destination
@@ -13640,7 +13672,7 @@
 where <code>(0,<wbr/>0)</code> is the top-left of the
 preCorrectionActiveArraySize rectangle.<wbr/> Once the pose and
 intrinsic calibration transforms have been applied to a
-world point,<wbr/> then the <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a>
+world point,<wbr/> then the <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a>
 transform needs to be applied,<wbr/> and the result adjusted to
 be in the <a href="#static_android.sensor.info.activeArraySize">android.<wbr/>sensor.<wbr/>info.<wbr/>active<wbr/>Array<wbr/>Size</a> coordinate
 system (where <code>(0,<wbr/> 0)</code> is the top-left of the
@@ -13657,6 +13689,7 @@
                 
           <tr class="entry" id="static_android.lens.radialDistortion">
             <td class="entry_name
+                entry_name_deprecated
              " rowspan="3">
               android.<wbr/>lens.<wbr/>radial<wbr/>Distortion
             </td>
@@ -13671,6 +13704,7 @@
 
 
 
+              <span class="entry_type_deprecated">[deprecated] </span>
 
 
 
@@ -13688,6 +13722,7 @@
             </td>
 
             <td class="entry_range">
+              <p><span class="entry_range_deprecated">Deprecated</span>. Do not use.</p>
             </td>
 
             <td class="entry_hal_version">
@@ -13802,6 +13837,91 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="static_android.lens.distortion">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>lens.<wbr/>distortion
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name">float</span>
+                <span class="entry_type_container">x</span>
+
+                <span class="entry_type_array">
+                  5
+                </span>
+              <span class="entry_type_visibility"> [public]</span>
+
+
+
+
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>The correction coefficients to correct for this camera device's
+radial and tangential lens distortion.<wbr/></p>
+<p>Replaces the deprecated <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a> field,<wbr/> which was
+inconsistently defined.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+              
+            Unitless coefficients.<wbr/>
+          
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>3</p>
+            </td>
+
+            <td class="entry_tags">
+              <ul class="entry_tags">
+                  <li><a href="#tag_DEPTH">DEPTH</a></li>
+              </ul>
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>Three radial distortion coefficients <code>[kappa_<wbr/>1,<wbr/> kappa_<wbr/>2,<wbr/>
+kappa_<wbr/>3]</code> and two tangential distortion coefficients
+<code>[kappa_<wbr/>4,<wbr/> kappa_<wbr/>5]</code> that can be used to correct the
+lens's geometric distortion with the mapping equations:</p>
+<pre><code> x_<wbr/>c = x_<wbr/>i * ( 1 + kappa_<wbr/>1 * r^2 + kappa_<wbr/>2 * r^4 + kappa_<wbr/>3 * r^6 ) +
+       kappa_<wbr/>4 * (2 * x_<wbr/>i * y_<wbr/>i) + kappa_<wbr/>5 * ( r^2 + 2 * x_<wbr/>i^2 )
+ y_<wbr/>c = y_<wbr/>i * ( 1 + kappa_<wbr/>1 * r^2 + kappa_<wbr/>2 * r^4 + kappa_<wbr/>3 * r^6 ) +
+       kappa_<wbr/>5 * (2 * x_<wbr/>i * y_<wbr/>i) + kappa_<wbr/>4 * ( r^2 + 2 * y_<wbr/>i^2 )
+</code></pre>
+<p>Here,<wbr/> <code>[x_<wbr/>c,<wbr/> y_<wbr/>c]</code> are the coordinates to sample in the
+input image that correspond to the pixel values in the
+corrected image at the coordinate <code>[x_<wbr/>i,<wbr/> y_<wbr/>i]</code>:</p>
+<pre><code> correctedImage(x_<wbr/>i,<wbr/> y_<wbr/>i) = sample_<wbr/>at(x_<wbr/>c,<wbr/> y_<wbr/>c,<wbr/> inputImage)
+</code></pre>
+<p>The pixel coordinates are defined in a coordinate system
+related to the <a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a>
+calibration fields; see that entry for details of the mapping stages.<wbr/>
+Both <code>[x_<wbr/>i,<wbr/> y_<wbr/>i]</code> and <code>[x_<wbr/>c,<wbr/> y_<wbr/>c]</code>
+have <code>(0,<wbr/>0)</code> at the lens optical center <code>[c_<wbr/>x,<wbr/> c_<wbr/>y]</code>,<wbr/> and
+the range of the coordinates depends on the focal length
+terms of the intrinsic calibration.<wbr/></p>
+<p>Finally,<wbr/> <code>r</code> represents the radial distance from the
+optical center,<wbr/> <code>r^2 = x_<wbr/>i^2 + y_<wbr/>i^2</code>.<wbr/></p>
+<p>The distortion model used is the Brown-Conrady model.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
@@ -14460,7 +14580,7 @@
 from the main sensor along the +X axis (to the right from the user's perspective) will
 report <code>(0.<wbr/>03,<wbr/> 0,<wbr/> 0)</code>.<wbr/></p>
 <p>To transform a pixel coordinates between two cameras facing the same direction,<wbr/> first
-the source camera <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a> must be corrected for.<wbr/>  Then the source
+the source camera <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> must be corrected for.<wbr/>  Then the source
 camera <a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a> needs to be applied,<wbr/> followed by the
 <a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a> of the source camera,<wbr/> the translation of the source camera
 relative to the destination camera,<wbr/> the <a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a> of the destination
@@ -14569,7 +14689,7 @@
 where <code>(0,<wbr/>0)</code> is the top-left of the
 preCorrectionActiveArraySize rectangle.<wbr/> Once the pose and
 intrinsic calibration transforms have been applied to a
-world point,<wbr/> then the <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a>
+world point,<wbr/> then the <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a>
 transform needs to be applied,<wbr/> and the result adjusted to
 be in the <a href="#static_android.sensor.info.activeArraySize">android.<wbr/>sensor.<wbr/>info.<wbr/>active<wbr/>Array<wbr/>Size</a> coordinate
 system (where <code>(0,<wbr/> 0)</code> is the top-left of the
@@ -14586,6 +14706,7 @@
                 
           <tr class="entry" id="dynamic_android.lens.radialDistortion">
             <td class="entry_name
+                entry_name_deprecated
              " rowspan="3">
               android.<wbr/>lens.<wbr/>radial<wbr/>Distortion
             </td>
@@ -14600,6 +14721,7 @@
 
 
 
+              <span class="entry_type_deprecated">[deprecated] </span>
 
 
 
@@ -14617,6 +14739,7 @@
             </td>
 
             <td class="entry_range">
+              <p><span class="entry_range_deprecated">Deprecated</span>. Do not use.</p>
             </td>
 
             <td class="entry_hal_version">
@@ -14668,6 +14791,91 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="dynamic_android.lens.distortion">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>lens.<wbr/>distortion
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name">float</span>
+                <span class="entry_type_container">x</span>
+
+                <span class="entry_type_array">
+                  5
+                </span>
+              <span class="entry_type_visibility"> [public]</span>
+
+
+
+
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>The correction coefficients to correct for this camera device's
+radial and tangential lens distortion.<wbr/></p>
+<p>Replaces the deprecated <a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a> field,<wbr/> which was
+inconsistently defined.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+              
+            Unitless coefficients.<wbr/>
+          
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>3</p>
+            </td>
+
+            <td class="entry_tags">
+              <ul class="entry_tags">
+                  <li><a href="#tag_DEPTH">DEPTH</a></li>
+              </ul>
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>Three radial distortion coefficients <code>[kappa_<wbr/>1,<wbr/> kappa_<wbr/>2,<wbr/>
+kappa_<wbr/>3]</code> and two tangential distortion coefficients
+<code>[kappa_<wbr/>4,<wbr/> kappa_<wbr/>5]</code> that can be used to correct the
+lens's geometric distortion with the mapping equations:</p>
+<pre><code> x_<wbr/>c = x_<wbr/>i * ( 1 + kappa_<wbr/>1 * r^2 + kappa_<wbr/>2 * r^4 + kappa_<wbr/>3 * r^6 ) +
+       kappa_<wbr/>4 * (2 * x_<wbr/>i * y_<wbr/>i) + kappa_<wbr/>5 * ( r^2 + 2 * x_<wbr/>i^2 )
+ y_<wbr/>c = y_<wbr/>i * ( 1 + kappa_<wbr/>1 * r^2 + kappa_<wbr/>2 * r^4 + kappa_<wbr/>3 * r^6 ) +
+       kappa_<wbr/>5 * (2 * x_<wbr/>i * y_<wbr/>i) + kappa_<wbr/>4 * ( r^2 + 2 * y_<wbr/>i^2 )
+</code></pre>
+<p>Here,<wbr/> <code>[x_<wbr/>c,<wbr/> y_<wbr/>c]</code> are the coordinates to sample in the
+input image that correspond to the pixel values in the
+corrected image at the coordinate <code>[x_<wbr/>i,<wbr/> y_<wbr/>i]</code>:</p>
+<pre><code> correctedImage(x_<wbr/>i,<wbr/> y_<wbr/>i) = sample_<wbr/>at(x_<wbr/>c,<wbr/> y_<wbr/>c,<wbr/> inputImage)
+</code></pre>
+<p>The pixel coordinates are defined in a coordinate system
+related to the <a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a>
+calibration fields; see that entry for details of the mapping stages.<wbr/>
+Both <code>[x_<wbr/>i,<wbr/> y_<wbr/>i]</code> and <code>[x_<wbr/>c,<wbr/> y_<wbr/>c]</code>
+have <code>(0,<wbr/>0)</code> at the lens optical center <code>[c_<wbr/>x,<wbr/> c_<wbr/>y]</code>,<wbr/> and
+the range of the coordinates depends on the focal length
+terms of the intrinsic calibration.<wbr/></p>
+<p>Finally,<wbr/> <code>r</code> represents the radial distance from the
+optical center,<wbr/> <code>r^2 = x_<wbr/>i^2 + y_<wbr/>i^2</code>.<wbr/></p>
+<p>The distortion model used is the Brown-Conrady model.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
@@ -16777,7 +16985,7 @@
 <li><a href="#static_android.lens.poseTranslation">android.<wbr/>lens.<wbr/>pose<wbr/>Translation</a></li>
 <li><a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a></li>
 <li><a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a></li>
-<li><a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a></li>
+<li><a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a></li>
 </ul>
 </li>
 <li>The <a href="#static_android.depth.depthIsExclusive">android.<wbr/>depth.<wbr/>depth<wbr/>Is<wbr/>Exclusive</a> entry is listed by this device.<wbr/></li>
@@ -16889,7 +17097,7 @@
 <li><a href="#static_android.lens.poseRotation">android.<wbr/>lens.<wbr/>pose<wbr/>Rotation</a></li>
 <li><a href="#static_android.lens.poseTranslation">android.<wbr/>lens.<wbr/>pose<wbr/>Translation</a></li>
 <li><a href="#static_android.lens.intrinsicCalibration">android.<wbr/>lens.<wbr/>intrinsic<wbr/>Calibration</a></li>
-<li><a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a></li>
+<li><a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a></li>
 </ul>
 </li>
 <li>The SENSOR_<wbr/>INFO_<wbr/>TIMESTAMP_<wbr/>SOURCE of the logical device and physical devices must be
@@ -20894,7 +21102,7 @@
 <a href="#static_android.sensor.info.activeArraySize">android.<wbr/>sensor.<wbr/>info.<wbr/>active<wbr/>Array<wbr/>Size</a>.<wbr/></p>
 <p>The currently supported fields that correct for geometric distortion are:</p>
 <ol>
-<li><a href="#static_android.lens.radialDistortion">android.<wbr/>lens.<wbr/>radial<wbr/>Distortion</a>.<wbr/></li>
+<li><a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a>.<wbr/></li>
 </ol>
 <p>If all of the geometric distortion fields are no-ops,<wbr/> this rectangle will be the same
 as the post-distortion-corrected rectangle given in
@@ -24131,7 +24339,7 @@
             </td>
 
             <td class="entry_range">
-              <p>android.<wbr/>Statistics.<wbr/>info.<wbr/>available<wbr/>Ois<wbr/>Data<wbr/>Modes</p>
+              <p><a href="#static_android.statistics.info.availableOisDataModes">android.<wbr/>statistics.<wbr/>info.<wbr/>available<wbr/>Ois<wbr/>Data<wbr/>Modes</a></p>
             </td>
 
             <td class="entry_hal_version">
@@ -25995,7 +26203,7 @@
             </td>
 
             <td class="entry_range">
-              <p>android.<wbr/>Statistics.<wbr/>info.<wbr/>available<wbr/>Ois<wbr/>Data<wbr/>Modes</p>
+              <p><a href="#static_android.statistics.info.availableOisDataModes">android.<wbr/>statistics.<wbr/>info.<wbr/>available<wbr/>Ois<wbr/>Data<wbr/>Modes</a></p>
             </td>
 
             <td class="entry_hal_version">
@@ -29590,6 +29798,339 @@
       </tbody>
 
   <!-- end of section -->
+  <tr><td colspan="7" id="section_distortionCorrection" class="section">distortionCorrection</td></tr>
+
+
+      <tr><td colspan="7" class="kind">controls</td></tr>
+
+      <thead class="entries_header">
+        <tr>
+          <th class="th_name">Property Name</th>
+          <th class="th_type">Type</th>
+          <th class="th_description">Description</th>
+          <th class="th_units">Units</th>
+          <th class="th_range">Range</th>
+          <th class="th_hal_version">Initial HIDL HAL version</th>
+          <th class="th_tags">Tags</th>
+        </tr>
+      </thead>
+
+      <tbody>
+
+        
+
+        
+
+        
+
+        
+
+                
+          <tr class="entry" id="controls_android.distortionCorrection.mode">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>distortion<wbr/>Correction.<wbr/>mode
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [public]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">OFF (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>No distortion correction is applied.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FAST (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>Lens distortion correction is applied without reducing frame rate
+relative to sensor output.<wbr/> It may be the same as OFF if distortion correction would
+reduce frame rate relative to sensor.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">HIGH_QUALITY (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>High-quality distortion correction is applied,<wbr/> at the cost of
+possibly reduced frame rate relative to sensor output.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Mode of operation for the lens distortion correction block.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+              <p><a href="#static_android.distortionCorrection.availableModes">android.<wbr/>distortion<wbr/>Correction.<wbr/>available<wbr/>Modes</a></p>
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>3</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>The lens distortion correction block attempts to improve image quality by fixing
+radial,<wbr/> tangential,<wbr/> or other geometric aberrations in the camera device's optics.<wbr/>  If
+available,<wbr/> the <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> field documents the lens's distortion parameters.<wbr/></p>
+<p>OFF means no distortion correction is done.<wbr/></p>
+<p>FAST/<wbr/>HIGH_<wbr/>QUALITY both mean camera device determined distortion correction will be
+applied.<wbr/> HIGH_<wbr/>QUALITY mode indicates that the camera device will use the highest-quality
+correction algorithms,<wbr/> even if it slows down capture rate.<wbr/> FAST means the camera device
+will not slow down capture rate when applying correction.<wbr/> FAST may be the same as OFF if
+any correction at all would slow down capture rate.<wbr/>  Every output stream will have a
+similar amount of enhancement applied.<wbr/></p>
+<p>The correction only applies to processed outputs such as YUV,<wbr/> JPEG,<wbr/> or DEPTH16; it is not
+applied to any RAW output.<wbr/>  Metadata coordinates such as face rectangles or metering
+regions are also not affected by correction.<wbr/></p>
+<p>Applications enabling distortion correction need to pay extra attention when converting
+image coordinates between corrected output buffers and the sensor array.<wbr/> For example,<wbr/> if
+the app supports tap-to-focus and enables correction,<wbr/> it then has to apply the distortion
+model described in <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> to the image buffer tap coordinates to properly
+calculate the tap position on the sensor active array to be used with
+<a href="#controls_android.control.afRegions">android.<wbr/>control.<wbr/>af<wbr/>Regions</a>.<wbr/> The same applies in reverse to detected face rectangles if
+they need to be drawn on top of the corrected output buffers.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+        
+
+      <!-- end of kind -->
+      </tbody>
+      <tr><td colspan="7" class="kind">static</td></tr>
+
+      <thead class="entries_header">
+        <tr>
+          <th class="th_name">Property Name</th>
+          <th class="th_type">Type</th>
+          <th class="th_description">Description</th>
+          <th class="th_units">Units</th>
+          <th class="th_range">Range</th>
+          <th class="th_hal_version">Initial HIDL HAL version</th>
+          <th class="th_tags">Tags</th>
+        </tr>
+      </thead>
+
+      <tbody>
+
+        
+
+        
+
+        
+
+        
+
+                
+          <tr class="entry" id="static_android.distortionCorrection.availableModes">
+            <td class="entry_name
+             " rowspan="5">
+              android.<wbr/>distortion<wbr/>Correction.<wbr/>available<wbr/>Modes
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name">byte</span>
+                <span class="entry_type_container">x</span>
+
+                <span class="entry_type_array">
+                  n
+                </span>
+              <span class="entry_type_visibility"> [public as enumList]</span>
+
+
+
+
+                <div class="entry_type_notes">list of enums</div>
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>List of distortion correction modes for <a href="#controls_android.distortionCorrection.mode">android.<wbr/>distortion<wbr/>Correction.<wbr/>mode</a> that are
+supported by this camera device.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+              <p>Any value listed in <a href="#controls_android.distortionCorrection.mode">android.<wbr/>distortion<wbr/>Correction.<wbr/>mode</a></p>
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>3</p>
+            </td>
+
+            <td class="entry_tags">
+              <ul class="entry_tags">
+                  <li><a href="#tag_V1">V1</a></li>
+                  <li><a href="#tag_REPROC">REPROC</a></li>
+              </ul>
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>No device is required to support this API; such devices will always list only 'OFF'.<wbr/>
+All devices that support this API will list both FAST and HIGH_<wbr/>QUALITY.<wbr/></p>
+            </td>
+          </tr>
+
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">HAL Implementation Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>HAL must support both FAST and HIGH_<wbr/>QUALITY if distortion correction is available
+on the camera device,<wbr/> but the underlying implementation can be the same for both modes.<wbr/>
+That is,<wbr/> if the highest quality implementation on the camera device does not slow down
+capture rate,<wbr/> then FAST and HIGH_<wbr/>QUALITY will generate the same output.<wbr/></p>
+            </td>
+          </tr>
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+        
+
+      <!-- end of kind -->
+      </tbody>
+      <tr><td colspan="7" class="kind">dynamic</td></tr>
+
+      <thead class="entries_header">
+        <tr>
+          <th class="th_name">Property Name</th>
+          <th class="th_type">Type</th>
+          <th class="th_description">Description</th>
+          <th class="th_units">Units</th>
+          <th class="th_range">Range</th>
+          <th class="th_hal_version">Initial HIDL HAL version</th>
+          <th class="th_tags">Tags</th>
+        </tr>
+      </thead>
+
+      <tbody>
+
+        
+
+        
+
+        
+
+        
+
+                
+          <tr class="entry" id="dynamic_android.distortionCorrection.mode">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>distortion<wbr/>Correction.<wbr/>mode
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [public]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">OFF (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>No distortion correction is applied.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FAST (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>Lens distortion correction is applied without reducing frame rate
+relative to sensor output.<wbr/> It may be the same as OFF if distortion correction would
+reduce frame rate relative to sensor.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">HIGH_QUALITY (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>High-quality distortion correction is applied,<wbr/> at the cost of
+possibly reduced frame rate relative to sensor output.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Mode of operation for the lens distortion correction block.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+              <p><a href="#static_android.distortionCorrection.availableModes">android.<wbr/>distortion<wbr/>Correction.<wbr/>available<wbr/>Modes</a></p>
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>3</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>The lens distortion correction block attempts to improve image quality by fixing
+radial,<wbr/> tangential,<wbr/> or other geometric aberrations in the camera device's optics.<wbr/>  If
+available,<wbr/> the <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> field documents the lens's distortion parameters.<wbr/></p>
+<p>OFF means no distortion correction is done.<wbr/></p>
+<p>FAST/<wbr/>HIGH_<wbr/>QUALITY both mean camera device determined distortion correction will be
+applied.<wbr/> HIGH_<wbr/>QUALITY mode indicates that the camera device will use the highest-quality
+correction algorithms,<wbr/> even if it slows down capture rate.<wbr/> FAST means the camera device
+will not slow down capture rate when applying correction.<wbr/> FAST may be the same as OFF if
+any correction at all would slow down capture rate.<wbr/>  Every output stream will have a
+similar amount of enhancement applied.<wbr/></p>
+<p>The correction only applies to processed outputs such as YUV,<wbr/> JPEG,<wbr/> or DEPTH16; it is not
+applied to any RAW output.<wbr/>  Metadata coordinates such as face rectangles or metering
+regions are also not affected by correction.<wbr/></p>
+<p>Applications enabling distortion correction need to pay extra attention when converting
+image coordinates between corrected output buffers and the sensor array.<wbr/> For example,<wbr/> if
+the app supports tap-to-focus and enables correction,<wbr/> it then has to apply the distortion
+model described in <a href="#static_android.lens.distortion">android.<wbr/>lens.<wbr/>distortion</a> to the image buffer tap coordinates to properly
+calculate the tap position on the sensor active array to be used with
+<a href="#controls_android.control.afRegions">android.<wbr/>control.<wbr/>af<wbr/>Regions</a>.<wbr/> The same applies in reverse to detected face rectangles if
+they need to be drawn on top of the corrected output buffers.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+        
+
+      <!-- end of kind -->
+      </tbody>
+
+  <!-- end of section -->
 <!-- </namespace> -->
   </table>
 
@@ -29712,6 +30253,7 @@
           <li><a href="#dynamic_android.statistics.hotPixelMap">android.statistics.hotPixelMap</a> (dynamic)</li>
           <li><a href="#dynamic_android.sync.frameNumber">android.sync.frameNumber</a> (dynamic)</li>
           <li><a href="#static_android.sync.maxLatency">android.sync.maxLatency</a> (static)</li>
+          <li><a href="#static_android.distortionCorrection.availableModes">android.distortionCorrection.availableModes</a> (static)</li>
           <li><a href="#dynamic_android.edge.mode">android.edge.mode</a> (dynamic)</li>
           <li><a href="#dynamic_android.hotPixel.mode">android.hotPixel.mode</a> (dynamic)</li>
           <li><a href="#dynamic_android.lens.aperture">android.lens.aperture</a> (dynamic)</li>
@@ -29781,6 +30323,7 @@
           <li><a href="#static_android.lens.poseTranslation">android.lens.poseTranslation</a> (static)</li>
           <li><a href="#static_android.lens.intrinsicCalibration">android.lens.intrinsicCalibration</a> (static)</li>
           <li><a href="#static_android.lens.radialDistortion">android.lens.radialDistortion</a> (static)</li>
+          <li><a href="#static_android.lens.distortion">android.lens.distortion</a> (static)</li>
           <li><a href="#static_android.depth.maxDepthSamples">android.depth.maxDepthSamples</a> (static)</li>
           <li><a href="#static_android.depth.availableDepthStreamConfigurations">android.depth.availableDepthStreamConfigurations</a> (static)</li>
           <li><a href="#static_android.depth.availableDepthMinFrameDurations">android.depth.availableDepthMinFrameDurations</a> (static)</li>
@@ -29799,6 +30342,7 @@
           <li><a href="#static_android.scaler.availableInputOutputFormatsMap">android.scaler.availableInputOutputFormatsMap</a> (static)</li>
           <li><a href="#controls_android.reprocess.effectiveExposureFactor">android.reprocess.effectiveExposureFactor</a> (controls)</li>
           <li><a href="#static_android.reprocess.maxCaptureStall">android.reprocess.maxCaptureStall</a> (static)</li>
+          <li><a href="#static_android.distortionCorrection.availableModes">android.distortionCorrection.availableModes</a> (static)</li>
           <li><a href="#dynamic_android.edge.mode">android.edge.mode</a> (dynamic)</li>
           <li><a href="#dynamic_android.noiseReduction.mode">android.noiseReduction.mode</a> (dynamic)</li>
         </ul>
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index f1bba92..48cb694 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -644,8 +644,8 @@
                 When the external flash is turned off, AE mode should be changed to one of the
                 other available AE modes.
 
-                If the camera device supports AE external flash mode, aeState must be
-                FLASH_REQUIRED after the camera device finishes AE scan and it's too dark without
+                If the camera device supports AE external flash mode, android.control.aeState must
+                be FLASH_REQUIRED after the camera device finishes AE scan and it's too dark without
                 flash.
               </notes>
             </value>
@@ -2268,6 +2268,9 @@
         <entry name="aePrecaptureId" type="int32" visibility="system" deprecated="true">
           <description>The ID sent with the latest
           CAMERA2_TRIGGER_PRECAPTURE_METERING call</description>
+          <deprecation_description>
+            Removed in camera HAL v3
+          </deprecation_description>
           <details>Must be 0 if no
           CAMERA2_TRIGGER_PRECAPTURE_METERING trigger received yet
           by HAL. Always updated even if AE algorithm ignores the
@@ -2370,8 +2373,8 @@
           Any state (excluding LOCKED) | android.control.aePrecaptureTrigger is CANCEL| INACTIVE       | Currently active precapture metering sequence is canceled
 
           If the camera device supports AE external flash mode (ON_EXTERNAL_FLASH is included in
-          android.control.aeAvailableModes), aeState must be FLASH_REQUIRED after the camera device
-          finishes AE scan and it's too dark without flash.
+          android.control.aeAvailableModes), android.control.aeState must be FLASH_REQUIRED after
+          the camera device finishes AE scan and it's too dark without flash.
 
           For the above table, the camera device may skip reporting any state changes that happen
           without application intervention (i.e. mode switch, trigger, locking). Any state that
@@ -2570,6 +2573,9 @@
         <entry name="afTriggerId" type="int32" visibility="system" deprecated="true">
           <description>The ID sent with the latest
           CAMERA2_TRIGGER_AUTOFOCUS call</description>
+          <deprecation_description>
+            Removed in camera HAL v3
+          </deprecation_description>
           <details>Must be 0 if no CAMERA2_TRIGGER_AUTOFOCUS trigger
           received yet by HAL. Always updated even if AF algorithm
           ignores the trigger</details>
@@ -3890,7 +3896,7 @@
             report `(0.03, 0, 0)`.
 
             To transform a pixel coordinates between two cameras facing the same direction, first
-            the source camera android.lens.radialDistortion must be corrected for.  Then the source
+            the source camera android.lens.distortion must be corrected for.  Then the source
             camera android.lens.intrinsicCalibration needs to be applied, followed by the
             android.lens.poseRotation of the source camera, the translation of the source camera
             relative to the destination camera, the android.lens.poseRotation of the destination
@@ -4047,7 +4053,7 @@
             where `(0,0)` is the top-left of the
             preCorrectionActiveArraySize rectangle. Once the pose and
             intrinsic calibration transforms have been applied to a
-            world point, then the android.lens.radialDistortion
+            world point, then the android.lens.distortion
             transform needs to be applied, and the result adjusted to
             be in the android.sensor.info.activeArraySize coordinate
             system (where `(0, 0)` is the top-left of the
@@ -4058,7 +4064,7 @@
           <tag id="DEPTH" />
         </entry>
         <entry name="radialDistortion" type="float" visibility="public"
-               container="array">
+               deprecated="true" container="array">
           <array>
             <size>6</size>
           </array>
@@ -4066,6 +4072,10 @@
             The correction coefficients to correct for this camera device's
             radial and tangential lens distortion.
           </description>
+          <deprecation_description>
+            This field was inconsistently defined in terms of its
+            normalization. Use android.lens.distortion instead.
+          </deprecation_description>
           <units>
             Unitless coefficients.
           </units>
@@ -4134,7 +4144,58 @@
             depending on the selected coordinate origin.
           </details>
         </entry>
+        <entry name="distortion" type="float" visibility="public" container="array"
+               hal_version="3.3">
+          <array>
+            <size>5</size>
+          </array>
+          <description>
+            The correction coefficients to correct for this camera device's
+            radial and tangential lens distortion.
+
+            Replaces the deprecated android.lens.radialDistortion field, which was
+            inconsistently defined.
+          </description>
+          <units>
+            Unitless coefficients.
+          </units>
+          <details>
+            Three radial distortion coefficients `[kappa_1, kappa_2,
+            kappa_3]` and two tangential distortion coefficients
+            `[kappa_4, kappa_5]` that can be used to correct the
+            lens's geometric distortion with the mapping equations:
+
+                 x_c = x_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+                       kappa_4 * (2 * x_i * y_i) + kappa_5 * ( r^2 + 2 * x_i^2 )
+                 y_c = y_i * ( 1 + kappa_1 * r^2 + kappa_2 * r^4 + kappa_3 * r^6 ) +
+                       kappa_5 * (2 * x_i * y_i) + kappa_4 * ( r^2 + 2 * y_i^2 )
+
+            Here, `[x_c, y_c]` are the coordinates to sample in the
+            input image that correspond to the pixel values in the
+            corrected image at the coordinate `[x_i, y_i]`:
+
+                 correctedImage(x_i, y_i) = sample_at(x_c, y_c, inputImage)
+
+            The pixel coordinates are defined in a coordinate system
+            related to the android.lens.intrinsicCalibration
+            calibration fields; see that entry for details of the mapping stages.
+            Both `[x_i, y_i]` and `[x_c, y_c]`
+            have `(0,0)` at the lens optical center `[c_x, c_y]`, and
+            the range of the coordinates depends on the focal length
+            terms of the intrinsic calibration.
+
+            Finally, `r` represents the radial distance from the
+            optical center, `r^2 = x_i^2 + y_i^2`.
+
+            The distortion model used is the Brown-Conrady model.
+          </details>
+          <tag id="DEPTH" />
+        </entry>
       </static>
+      <dynamic>
+        <clone entry="android.lens.distortion" kind="static">
+        </clone>
+      </dynamic>
     </section>
     <section name="noiseReduction">
       <controls>
@@ -4270,6 +4331,9 @@
           scale 'normalized' coordinates with respect to the crop
           region. This applies to metering input (a{e,f,wb}Region
           and output (face rectangles).</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <details>Normalized coordinates refer to those in the
           (-1000,1000) range mentioned in the
           android.hardware.Camera API.
@@ -4283,6 +4347,9 @@
           <description>If set to 1, then the camera service always
           switches to FOCUS_MODE_AUTO before issuing a AF
           trigger.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <details>HAL implementations should implement AF trigger
           modes for AUTO, MACRO, CONTINUOUS_FOCUS, and
           CONTINUOUS_PICTURE modes instead of using this flag. Does
@@ -4294,6 +4361,9 @@
           CAMERA2_PIXEL_FORMAT_ZSL instead of
           HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED for the zero
           shutter lag stream</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <details>HAL implementations should use gralloc usage flags
           to determine that a stream will be used for
           zero-shutter-lag, instead of relying on an explicit
@@ -4307,6 +4377,9 @@
           metadata for a single capture into multiple buffers,
           returned using multiple process_capture_result calls.
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer; replaced by better partials mechanism
+          </deprecation_description>
           <details>
           Does not need to be listed in static
           metadata. Support for partial results will be reworked in
@@ -4339,6 +4412,9 @@
           final one for the capture, or only a partial that contains a
           subset of the full set of dynamic metadata
           values.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <range>Optional. Default value is FINAL.</range>
           <details>
           The entries in the result metadata buffers for a
@@ -4366,6 +4442,9 @@
           increases with every new result (that is, each new result has a unique
           frameCount value).
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>incrementing integer</units>
           <range>Any int.</range>
         </entry>
@@ -4384,6 +4463,9 @@
           </array>
           <description>List which camera reprocess stream is used
           for the source of reprocessing data.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>List of camera reprocess stream IDs</units>
           <range>
           Typically, only one entry allowed, must be a valid reprocess stream ID.
@@ -4420,6 +4502,9 @@
           </array>
           <description>Lists which camera output streams image data
           from this capture must be sent to</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>List of camera stream IDs</units>
           <range>List must only include streams that have been
           created</range>
@@ -4444,6 +4529,9 @@
           <description>The type of the request; either CAPTURE or
           REPROCESS. For legacy HAL3, this tag is redundant.
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <tag id="HAL2" />
         </entry>
       </controls>
@@ -4591,6 +4679,9 @@
           </array>
           <description>How many reprocessing streams of any type
           can be allocated at the same time.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <range>&amp;gt;= 0</range>
           <details>
           Only used by HAL2.x.
@@ -4634,6 +4725,9 @@
           <description>A frame counter set by the framework. This value monotonically
           increases with every new result (that is, each new result has a unique
           frameCount value).</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>count of frames</units>
           <range>&amp;gt; 0</range>
           <details>Reset on release()</details>
@@ -5000,7 +5094,7 @@
                   - android.lens.poseTranslation
                   - android.lens.poseRotation
                   - android.lens.intrinsicCalibration
-                  - android.lens.radialDistortion
+                  - android.lens.distortion
               * The android.depth.depthIsExclusive entry is listed by this device.
               * As of Android P, the android.lens.poseReference entry is listed by this device.
               * A LIMITED camera with only the DEPTH_OUTPUT capability does not have to support
@@ -5125,7 +5219,7 @@
                   - android.lens.poseRotation
                   - android.lens.poseTranslation
                   - android.lens.intrinsicCalibration
-                  - android.lens.radialDistortion
+                  - android.lens.distortion
               * The SENSOR_INFO_TIMESTAMP_SOURCE of the logical device and physical devices must be
                 the same.
               * The logical camera device must be LIMITED or higher device.
@@ -5607,6 +5701,9 @@
           </enum>
           <description>The list of image formats that are supported by this
           camera device for output streams.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <details>
           All camera devices will support JPEG and YUV_420_888 formats.
 
@@ -5642,6 +5739,9 @@
           <description>The minimum frame duration that is supported
           for each resolution in android.scaler.availableJpegSizes.
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>Nanoseconds</units>
           <range>TODO: Remove property.</range>
           <details>
@@ -5661,6 +5761,9 @@
             <size>2</size>
           </array>
           <description>The JPEG resolutions that are supported by this camera device.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <range>TODO: Remove property.</range>
           <details>
           The resolutions are listed as `(width, height)` pairs. All camera devices will support
@@ -5701,6 +5804,9 @@
           android.scaler.availableProcessedSizes), this property lists the
           minimum supportable frame duration for that size.
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>Nanoseconds</units>
           <details>
           This should correspond to the frame duration when only that processed
@@ -5722,6 +5828,9 @@
           processed output streams, such as YV12, NV12, and
           platform opaque YUV/RGB streams to the GPU or video
           encoders.</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <details>
           The resolutions are listed as `(width, height)` pairs.
 
@@ -5761,6 +5870,9 @@
           android.scaler.availableRawSizes), this property lists the minimum
           supportable frame duration for that size.
           </description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
           <units>Nanoseconds</units>
           <details>
           Should correspond to the frame duration when only the raw stream is
@@ -5780,6 +5892,9 @@
           <description>The resolutions available for use with raw
           sensor output streams, listed as width,
           height</description>
+          <deprecation_description>
+          Not used in HALv3 or newer
+          </deprecation_description>
         </entry>
       </static>
       <dynamic>
@@ -6649,7 +6764,7 @@
 
             The currently supported fields that correct for geometric distortion are:
 
-            1. android.lens.radialDistortion.
+            1. android.lens.distortion.
 
             If all of the geometric distortion fields are no-ops, this rectangle will be the same
             as the post-distortion-corrected rectangle given in
@@ -8167,6 +8282,9 @@
           <description>The best-fit color channel gains calculated
           by the camera device's statistics units for the current output frame.
           </description>
+          <deprecation_description>
+          Never fully implemented or specified; do not use
+          </deprecation_description>
           <details>
           This may be different than the gains used for this frame,
           since statistics processing on data from a new frame
@@ -8193,6 +8311,9 @@
           <description>The best-fit color transform matrix estimate
           calculated by the camera device's statistics units for the current
           output frame.</description>
+          <deprecation_description>
+          Never fully implemented or specified; do not use
+          </deprecation_description>
           <details>The camera device will provide the estimate from its
           statistics unit on the white balance transforms to use
           for the next frame. These are the values the camera device believes
@@ -8322,7 +8443,7 @@
           </enum>
           <description>A control for selecting whether OIS position information is included in output
           result metadata.</description>
-          <range>android.Statistics.info.availableOisDataModes</range>
+          <range>android.statistics.info.availableOisDataModes</range>
         </entry>
       </controls>
       <dynamic>
@@ -9541,5 +9662,76 @@
         </entry>
       </static>
     </section>
+    <section name="distortionCorrection">
+      <controls>
+        <entry name="mode" type="byte" visibility="public" enum="true" hal_version="3.3">
+          <enum>
+            <value>OFF
+            <notes>No distortion correction is applied.</notes></value>
+            <value>FAST <notes>Lens distortion correction is applied without reducing frame rate
+            relative to sensor output. It may be the same as OFF if distortion correction would
+            reduce frame rate relative to sensor.</notes></value>
+            <value>HIGH_QUALITY <notes>High-quality distortion correction is applied, at the cost of
+            possibly reduced frame rate relative to sensor output.</notes></value>
+          </enum>
+          <description>Mode of operation for the lens distortion correction block.</description>
+          <range>android.distortionCorrection.availableModes</range>
+          <details>The lens distortion correction block attempts to improve image quality by fixing
+          radial, tangential, or other geometric aberrations in the camera device's optics.  If
+          available, the android.lens.distortion field documents the lens's distortion parameters.
+
+          OFF means no distortion correction is done.
+
+          FAST/HIGH_QUALITY both mean camera device determined distortion correction will be
+          applied. HIGH_QUALITY mode indicates that the camera device will use the highest-quality
+          correction algorithms, even if it slows down capture rate. FAST means the camera device
+          will not slow down capture rate when applying correction. FAST may be the same as OFF if
+          any correction at all would slow down capture rate.  Every output stream will have a
+          similar amount of enhancement applied.
+
+          The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not
+          applied to any RAW output.  Metadata coordinates such as face rectangles or metering
+          regions are also not affected by correction.
+
+          Applications enabling distortion correction need to pay extra attention when converting
+          image coordinates between corrected output buffers and the sensor array. For example, if
+          the app supports tap-to-focus and enables correction, it then has to apply the distortion
+          model described in android.lens.distortion to the image buffer tap coordinates to properly
+          calculate the tap position on the sensor active array to be used with
+          android.control.afRegions. The same applies in reverse to detected face rectangles if
+          they need to be drawn on top of the corrected output buffers.
+          </details>
+        </entry>
+      </controls>
+      <static>
+        <entry name="availableModes" type="byte" visibility="public"
+        type_notes="list of enums" container="array" typedef="enumList" hal_version="3.3">
+          <array>
+            <size>n</size>
+          </array>
+          <description>
+          List of distortion correction modes for android.distortionCorrection.mode that are
+          supported by this camera device.
+          </description>
+          <range>Any value listed in android.distortionCorrection.mode</range>
+          <details>
+            No device is required to support this API; such devices will always list only 'OFF'.
+            All devices that support this API will list both FAST and HIGH_QUALITY.
+          </details>
+          <hal_details>
+          HAL must support both FAST and HIGH_QUALITY if distortion correction is available
+          on the camera device, but the underlying implementation can be the same for both modes.
+          That is, if the highest quality implementation on the camera device does not slow down
+          capture rate, then FAST and HIGH_QUALITY will generate the same output.
+          </hal_details>
+          <tag id="V1" />
+          <tag id="REPROC" />
+        </entry>
+      </static>
+      <dynamic>
+        <clone entry="android.distortionCorrection.mode" kind="controls" hal_version="3.3">
+        </clone>
+      </dynamic>
+    </section>
   </namespace>
 </metadata>
diff --git a/camera/docs/metadata_definitions.xsd b/camera/docs/metadata_definitions.xsd
index d8c15ab..8e46cb1 100644
--- a/camera/docs/metadata_definitions.xsd
+++ b/camera/docs/metadata_definitions.xsd
@@ -133,6 +133,9 @@
             <element name="description" type="string" maxOccurs="1"
                 minOccurs="0">
             </element>
+            <element name="deprecation_description" type="string" maxOccurs="1"
+                     minOccurs="0">
+            </element>
             <element name="units" type="string" maxOccurs="1"
                 minOccurs="0">
             </element>
@@ -326,5 +329,6 @@
                 </restriction>
             </simpleType>
         </attribute>
+        <attribute name="hal_version" type="decimal" default="3.2" />
     </complexType>
 </schema>
diff --git a/camera/docs/metadata_helpers.py b/camera/docs/metadata_helpers.py
index 5f03d40..ed303bb 100644
--- a/camera/docs/metadata_helpers.py
+++ b/camera/docs/metadata_helpers.py
@@ -818,7 +818,7 @@
     "    * @see CaptureRequest#CONTROL_MODE\n"
   """
   def javadoc_formatter(text):
-    comment_prefix = " " * indent + " * ";
+    comment_prefix = " " * indent + " * "
 
     # render with markdown => HTML
     javatext = md(text, JAVADOC_IMAGE_SRC_METADATA)
diff --git a/camera/docs/metadata_model.py b/camera/docs/metadata_model.py
index 4485ad8..398e43a 100644
--- a/camera/docs/metadata_model.py
+++ b/camera/docs/metadata_model.py
@@ -416,7 +416,9 @@
       target_kind = p.target_kind
       target_entry = self._entry_map[target_kind].get(p.name)
       p._entry = target_entry
-
+      if (p.hal_major_version == 0):
+        p._hal_major_version = target_entry._hal_major_version
+        p._hal_minor_version = target_entry._hal_minor_version
       # should not throw if we pass validation
       # but can happen when importing obsolete CSV entries
       if target_entry is None:
@@ -1132,6 +1134,8 @@
     tuple_values: A sequence of strings describing the tuple values,
                   None if container is not 'tuple'.
     description: A string description, or None.
+    deprecation_description: A string describing the reason for deprecation. Must be present
+                 if deprecated is true, otherwise may be None.
     range: A string range, or None.
     units: A string units, or None.
     tags: A sequence of Tag nodes associated with this Entry.
@@ -1171,6 +1175,10 @@
       enum_ids: A dictionary of value->id strings.
       enum_hal_versions: A dictionary of value->hal version strings
 
+    Args (if the 'deprecated' attribute is true):
+      deprecation_description: A string explaining the deprecation, to be added
+                               to the Java-layer @deprecated tag
+
     Args (optional):
       description: A string with a description of the entry.
       range: A string with the range of the values of the entry, e.g. '>= 0'
@@ -1246,6 +1254,10 @@
   def deprecated(self):
     return self._deprecated
 
+  @property
+  def deprecation_description(self):
+    return self._deprecation_description
+
   # TODO: optional should just return hwlevel is None
   @property
   def optional(self):
@@ -1355,8 +1367,12 @@
 
     hal_version = kwargs.get('hal_version')
     if hal_version is None:
-      self._hal_major_version = 3
-      self._hal_minor_version = 2
+      if self.is_clone():
+        self._hal_major_version = 0
+        self._hal_minor_version = 0
+      else:
+        self._hal_major_version = 3
+        self._hal_minor_version = 2
     else:
       self._hal_major_version = int(hal_version.partition('.')[0])
       self._hal_minor_version = int(hal_version.partition('.')[2])
@@ -1399,6 +1415,8 @@
     self._synthetic = kwargs.get('synthetic', False)
     self._hwlevel = kwargs.get('hwlevel')
     self._deprecated = kwargs.get('deprecated', False)
+    self._deprecation_description = kwargs.get('deprecation_description')
+
     self._optional = kwargs.get('optional')
     self._ndk_visible = kwargs.get('ndk_visible')
 
@@ -1585,7 +1603,8 @@
       entry: An Entry or Clone instance
     """
     props_distinct = ['description', 'units', 'range', 'details',
-                      'hal_details', 'ndk_details', 'tags', 'kind']
+                      'hal_details', 'ndk_details', 'tags', 'kind',
+                      'deprecation_description']
 
     for p in props_distinct:
       p = '_' + p
diff --git a/camera/docs/metadata_parser_xml.py b/camera/docs/metadata_parser_xml.py
index 1daf02b..91af192 100755
--- a/camera/docs/metadata_parser_xml.py
+++ b/camera/docs/metadata_parser_xml.py
@@ -156,6 +156,8 @@
           # no type_notes since its the same
         }
         d2 = {}
+        if 'hal_version' in entry.attrs:
+          d2['hal_version'] = entry['hal_version']
 
         insert = self.metadata.insert_clone
 
@@ -293,7 +295,8 @@
   def _parse_entry_optional(self, entry):
     d = {}
 
-    optional_elements = ['description', 'range', 'units', 'details', 'hal_details', 'ndk_details']
+    optional_elements = ['description', 'range', 'units', 'details', 'hal_details', 'ndk_details',\
+                         'deprecation_description']
     for i in optional_elements:
       prop = find_child_tag(entry, i)
 
diff --git a/camera/docs/metadata_template.mako b/camera/docs/metadata_template.mako
index fc909c1..02689f0 100644
--- a/camera/docs/metadata_template.mako
+++ b/camera/docs/metadata_template.mako
@@ -69,7 +69,11 @@
 
         <%def name="insert_entry(prop)">
         % if prop.is_clone():
-            <clone entry="${prop.name}" kind="${prop.target_kind}">
+            <clone entry="${prop.name}" kind="${prop.target_kind}"
+          % if ('hal_version' in prop._property_keys):
+                hal_version="${prop.hal_major_version}.${prop.hal_minor_version}"
+          % endif
+            >
 
               % if prop.details is not None:
                 <details>${prop.details}</details>
@@ -180,6 +184,10 @@
                 <description>${prop.description | x}</description>
               % endif
 
+              % if prop.deprecation_description is not None:
+                <deprecation_description>${prop.deprecation_description | x}</deprecation_description>
+              % endif
+
               % if prop.units is not None:
                 <units>${prop.units | x}</units>
               % endif
diff --git a/camera/docs/metadata_validate.py b/camera/docs/metadata_validate.py
index 8260005..ede1449 100755
--- a/camera/docs/metadata_validate.py
+++ b/camera/docs/metadata_validate.py
@@ -222,6 +222,29 @@
       validate_error(error_msg)
       success = False
 
+    if matching_entry is not None:
+      entry_hal_major_version = 3
+      entry_hal_minor_version = 2
+      entry_hal_version = matching_entry.get('hal_version')
+      if entry_hal_version is not None:
+        entry_hal_major_version = int(entry_hal_version.partition('.')[0])
+        entry_hal_minor_version = int(entry_hal_version.partition('.')[2])
+
+      clone_hal_major_version = entry_hal_major_version
+      clone_hal_minor_version = entry_hal_minor_version
+      clone_hal_version = clone.get('hal_version')
+      if clone_hal_version is not None:
+        clone_hal_major_version = int(clone_hal_version.partition('.')[0])
+        clone_hal_minor_version = int(clone_hal_version.partition('.')[2])
+
+      if clone_hal_major_version < entry_hal_major_version or \
+          (clone_hal_major_version == entry_hal_major_version and \
+           clone_hal_minor_version < entry_hal_minor_version):
+        error_msg = ("Clone '%s' HAL version '%d.%d' is older than entry target HAL version '%d.%d'" \
+                   % (clone_name, clone_hal_major_version, clone_hal_minor_version, entry_hal_major_version, entry_hal_minor_version))
+        validate_error(error_msg)
+        success = False
+
   return success
 
 # All <entry> elements with container=$foo have a <$foo> child
@@ -281,6 +304,20 @@
                                   ))
         success = False
 
+    deprecated = entry.attrs.get('deprecated')
+    if deprecated and deprecated == 'true':
+      if entry.deprecation_description is None:
+        validate_error(("Entry '%s' in kind '%s' is deprecated, but missing deprecation description") \
+                       % (fully_qualified_name(entry), find_kind(entry),
+                       ))
+        success = False
+    else:
+      if entry.deprecation_description is not None:
+        validate_error(("Entry '%s' in kind '%s' has deprecation description, but is not deprecated") \
+                       % (fully_qualified_name(entry), find_kind(entry),
+                       ))
+        success = False
+
   return success
 
 def validate_xml(xml):
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 3b57902..d8cd02e 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -62,6 +62,7 @@
     ANDROID_REPROCESS,
     ANDROID_DEPTH,
     ANDROID_LOGICAL_MULTI_CAMERA,
+    ANDROID_DISTORTION_CORRECTION,
     ANDROID_SECTION_COUNT,
 
     VENDOR_SECTION = 0x8000
@@ -101,6 +102,9 @@
     ANDROID_LOGICAL_MULTI_CAMERA_START
                                    = ANDROID_LOGICAL_MULTI_CAMERA
                                                                 << 16,
+    ANDROID_DISTORTION_CORRECTION_START
+                                   = ANDROID_DISTORTION_CORRECTION
+                                                                << 16,
     VENDOR_SECTION_START           = VENDOR_SECTION            << 16
 } camera_metadata_section_start_t;
 
@@ -224,6 +228,7 @@
     ANDROID_LENS_INTRINSIC_CALIBRATION,               // float[]      | public       | HIDL v3.2
     ANDROID_LENS_RADIAL_DISTORTION,                   // float[]      | public       | HIDL v3.2
     ANDROID_LENS_POSE_REFERENCE,                      // enum         | public       | HIDL v3.3
+    ANDROID_LENS_DISTORTION,                          // float[]      | public       | HIDL v3.3
     ANDROID_LENS_END,
 
     ANDROID_LENS_INFO_AVAILABLE_APERTURES =           // float[]      | public       | HIDL v3.2
@@ -434,6 +439,11 @@
     ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE,    // enum         | public       | HIDL v3.3
     ANDROID_LOGICAL_MULTI_CAMERA_END,
 
+    ANDROID_DISTORTION_CORRECTION_MODE =              // enum         | public       | HIDL v3.3
+            ANDROID_DISTORTION_CORRECTION_START,
+    ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES,    // byte[]       | public       | HIDL v3.3
+    ANDROID_DISTORTION_CORRECTION_END,
+
 } camera_metadata_tag_t;
 
 /**
@@ -984,3 +994,11 @@
 } camera_metadata_enum_android_logical_multi_camera_sensor_sync_type_t;
 
 
+// ANDROID_DISTORTION_CORRECTION_MODE
+typedef enum camera_metadata_enum_android_distortion_correction_mode {
+    ANDROID_DISTORTION_CORRECTION_MODE_OFF                          , // HIDL v3.3
+    ANDROID_DISTORTION_CORRECTION_MODE_FAST                         , // HIDL v3.3
+    ANDROID_DISTORTION_CORRECTION_MODE_HIGH_QUALITY                 , // HIDL v3.3
+} camera_metadata_enum_android_distortion_correction_mode_t;
+
+
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index e943f79..0d7b679 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -58,6 +58,8 @@
     [ANDROID_REPROCESS]            = "android.reprocess",
     [ANDROID_DEPTH]                = "android.depth",
     [ANDROID_LOGICAL_MULTI_CAMERA] = "android.logicalMultiCamera",
+    [ANDROID_DISTORTION_CORRECTION]
+                                    = "android.distortionCorrection",
 };
 
 unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2] = {
@@ -115,6 +117,9 @@
                                        ANDROID_DEPTH_END },
     [ANDROID_LOGICAL_MULTI_CAMERA] = { ANDROID_LOGICAL_MULTI_CAMERA_START,
                                        ANDROID_LOGICAL_MULTI_CAMERA_END },
+    [ANDROID_DISTORTION_CORRECTION]
+                                    = { ANDROID_DISTORTION_CORRECTION_START,
+                                       ANDROID_DISTORTION_CORRECTION_END },
 };
 
 static tag_info_t android_color_correction[ANDROID_COLOR_CORRECTION_END -
@@ -325,6 +330,8 @@
     { "radialDistortion",              TYPE_FLOAT  },
     [ ANDROID_LENS_POSE_REFERENCE - ANDROID_LENS_START ] =
     { "poseReference",                 TYPE_BYTE   },
+    [ ANDROID_LENS_DISTORTION - ANDROID_LENS_START ] =
+    { "distortion",                    TYPE_FLOAT  },
 };
 
 static tag_info_t android_lens_info[ANDROID_LENS_INFO_END -
@@ -707,6 +714,14 @@
     { "sensorSyncType",                TYPE_BYTE   },
 };
 
+static tag_info_t android_distortion_correction[ANDROID_DISTORTION_CORRECTION_END -
+        ANDROID_DISTORTION_CORRECTION_START] = {
+    [ ANDROID_DISTORTION_CORRECTION_MODE - ANDROID_DISTORTION_CORRECTION_START ] =
+    { "mode",                          TYPE_BYTE   },
+    [ ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES - ANDROID_DISTORTION_CORRECTION_START ] =
+    { "availableModes",                TYPE_BYTE   },
+};
+
 
 tag_info_t *tag_info[ANDROID_SECTION_COUNT] = {
     android_color_correction,
@@ -736,6 +751,7 @@
     android_reprocess,
     android_depth,
     android_logical_multi_camera,
+    android_distortion_correction,
 };
 
 int camera_metadata_enum_snprint(uint32_t tag,
@@ -1693,6 +1709,9 @@
             }
             break;
         }
+        case ANDROID_LENS_DISTORTION: {
+            break;
+        }
 
         case ANDROID_LENS_INFO_AVAILABLE_APERTURES: {
             break;
@@ -2753,6 +2772,29 @@
             break;
         }
 
+        case ANDROID_DISTORTION_CORRECTION_MODE: {
+            switch (value) {
+                case ANDROID_DISTORTION_CORRECTION_MODE_OFF:
+                    msg = "OFF";
+                    ret = 0;
+                    break;
+                case ANDROID_DISTORTION_CORRECTION_MODE_FAST:
+                    msg = "FAST";
+                    ret = 0;
+                    break;
+                case ANDROID_DISTORTION_CORRECTION_MODE_HIGH_QUALITY:
+                    msg = "HIGH_QUALITY";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
+        case ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES: {
+            break;
+        }
+
     }
 
     strncpy(dst, msg, size - 1);