Camera: Add support for recommended stream configurations

Hal must be able to recommend efficient stream configurations
for common client use cases. Add the necessary
static metadata keys.

Bug: 64029608
Test: Camera CTS
Change-Id: I843401de407ab7327fc9e0d6365f2d27b9cdb435
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index fdf60cc..b035ff3 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -742,6 +742,10 @@
             ><a href="#static_android.scaler.streamConfigurationMap">android.scaler.streamConfigurationMap</a></li>
             <li
             ><a href="#static_android.scaler.croppingType">android.scaler.croppingType</a></li>
+            <li
+            ><a href="#static_android.scaler.availableRecommendedStreamConfigurations">android.scaler.availableRecommendedStreamConfigurations</a></li>
+            <li
+            ><a href="#static_android.scaler.availableRecommendedInputOutputFormatsMap">android.scaler.availableRecommendedInputOutputFormatsMap</a></li>
           </ul>
         </li>
         <li>
@@ -1171,6 +1175,8 @@
             ><a href="#static_android.depth.availableDepthStallDurations">android.depth.availableDepthStallDurations</a></li>
             <li
             ><a href="#static_android.depth.depthIsExclusive">android.depth.depthIsExclusive</a></li>
+            <li
+            ><a href="#static_android.depth.availableRecommendedDepthStreamConfigurations">android.depth.availableRecommendedDepthStreamConfigurations</a></li>
           </ul>
         </li>
       </ul> <!-- toc_section -->
@@ -19865,6 +19871,218 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="static_android.scaler.availableRecommendedStreamConfigurations">
+            <td class="entry_name
+             " rowspan="5">
+              android.<wbr/>scaler.<wbr/>available<wbr/>Recommended<wbr/>Stream<wbr/>Configurations
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">int32</span>
+                <span class="entry_type_container">x</span>
+
+                <span class="entry_type_array">
+                  n x 5
+                </span>
+              <span class="entry_type_visibility"> [ndk_public as recommendedStreamConfiguration]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">PREVIEW (v3.4)</span>
+                    <span class="entry_type_enum_value">0x0</span>
+                    <span class="entry_type_enum_notes"><p>Preview must only include non-stalling processed stream configurations with
+output formats like YUV_<wbr/>420_<wbr/>888,<wbr/> IMPLEMENTATION_<wbr/>DEFINED,<wbr/> etc.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">RECORD (v3.4)</span>
+                    <span class="entry_type_enum_value">0x1</span>
+                    <span class="entry_type_enum_notes"><p>Video record must include stream configurations that match the advertised
+supported media profiles <a href="https://developer.android.com/reference/android/media/CamcorderProfile.html">CamcorderProfile</a> with
+IMPLEMENTATION_<wbr/>DEFINED format.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">VIDEO_SNAPSHOT (v3.4)</span>
+                    <span class="entry_type_enum_value">0x2</span>
+                    <span class="entry_type_enum_notes"><p>Video snapshot must include stream configurations at least as big as
+the maximum RECORD resolutions and only with format BLOB + DATASPACE_<wbr/>JFIF
+format/<wbr/>dataspace combination (JPEG).<wbr/> Additionally the configurations shouldn't cause
+preview glitches and also be able to run at 30 fps.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">SNAPSHOT (v3.4)</span>
+                    <span class="entry_type_enum_value">0x3</span>
+                    <span class="entry_type_enum_notes"><p>Recommended snapshot stream configurations must include at least one with
+size close to <a href="#static_android.sensor.info.activeArraySize">android.<wbr/>sensor.<wbr/>info.<wbr/>active<wbr/>Array<wbr/>Size</a> with BLOB + DATASPACE_<wbr/>JFIF
+format/<wbr/>dataspace combination (JPEG).<wbr/> Taking into account restrictions on aspect
+ratio,<wbr/> alignment etc.<wbr/> the area of the maximum suggested size shouldn’t be less than
+97% of the sensor array size area.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">ZSL (v3.4)</span>
+                    <span class="entry_type_enum_value">0x4</span>
+                    <span class="entry_type_enum_notes"><p>If supported,<wbr/> recommended input stream configurations must only be advertised with
+ZSL along with other processed and/<wbr/>or stalling output formats.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">RAW (v3.4)</span>
+                    <span class="entry_type_enum_value">0x5</span>
+                    <span class="entry_type_enum_notes"><p>If supported,<wbr/> recommended raw stream configurations must only include RAW based
+output formats.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">PUBLIC_END (v3.4)</span>
+                    <span class="entry_type_enum_value">0x6</span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">VENDOR_START (v3.4)</span>
+                    <span class="entry_type_enum_value">0x18</span>
+                    <span class="entry_type_enum_notes"><p>Vendor defined use cases.<wbr/> These depend on the vendor implementation.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Recommended stream configurations for common client use cases.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>4</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>Optional subset of the <a href="#static_android.scaler.availableStreamConfigurations">android.<wbr/>scaler.<wbr/>available<wbr/>Stream<wbr/>Configurations</a> that contains
+similar tuples listed as
+(i.<wbr/>e.<wbr/> width,<wbr/> height,<wbr/> format,<wbr/> output/<wbr/>input stream,<wbr/> usecase bit field).<wbr/>
+Camera devices will be able to suggest particular stream configurations which are
+power and performance efficient for specific use cases.<wbr/> For more information about
+retrieving the suggestions see
+<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#getRecommendedStreamConfigurationMap">CameraCharacteristics#getRecommendedStreamConfigurationMap</a>.<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>There are some requirements that need to be considered regarding the usecases and the
+suggested configurations:</p>
+<ul>
+<li>If <a href="#static_android.scaler.availableRecommendedStreamConfigurations">android.<wbr/>scaler.<wbr/>available<wbr/>Recommended<wbr/>Stream<wbr/>Configurations</a> is set,<wbr/> then recommended
+stream configurations must be present for all mandatory usecases PREVIEW,<wbr/>
+SNAPSHOT,<wbr/> RECORD,<wbr/> VIDEO_<wbr/>SNAPSHOT.<wbr/> ZSL and RAW are
+required depending on device capabilities see <a href="#static_android.request.availableCapabilities">android.<wbr/>request.<wbr/>available<wbr/>Capabilities</a>.<wbr/></li>
+<li>Non-existing usecases and non-vendor usecases within the range
+(RAW : VENDOR_<wbr/>START] are prohibited as well as stream configurations not
+present in the exhaustive <a href="#static_android.scaler.availableStreamConfigurations">android.<wbr/>scaler.<wbr/>available<wbr/>Stream<wbr/>Configurations</a> list.<wbr/></li>
+</ul>
+<p>For example,<wbr/> in case the camera device supports only 4K and 1080p and both resolutions are
+recommended for the mandatory usecases except preview which can run efficiently only
+on 1080p.<wbr/> The array may look like this:</p>
+<p>[3840,<wbr/> 2160,<wbr/> HAL_<wbr/>PIXEL_<wbr/>FORMAT_<wbr/>IMPLEMENTATION_<wbr/>DEFINED,<wbr/>
+ ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>OUTPUT,<wbr/>
+ (1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>RECORD |<wbr/>
+ 1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>SNAPSHOT |<wbr/>
+ 1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>VIDEO_<wbr/>SNAPSHOT),<wbr/></p>
+<p>1920,<wbr/> 1080,<wbr/> HAL_<wbr/>PIXEL_<wbr/>FORMAT_<wbr/>IMPLEMENTATION_<wbr/>DEFINED,<wbr/>
+ ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>OUTPUT,<wbr/>
+ (1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>PREVIEW |<wbr/>
+ 1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>RECORD |<wbr/>
+ 1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>SNAPSHOT |<wbr/>
+ 1&lt;&lt; ANDROID_<wbr/>SCALER_<wbr/>AVAILABLE_<wbr/>RECOMMENDED_<wbr/>STREAM_<wbr/>CONFIGURATIONS_<wbr/>VIDEO_<wbr/>SNAPSHOT)]</p>
+            </td>
+          </tr>
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+                
+          <tr class="entry" id="static_android.scaler.availableRecommendedInputOutputFormatsMap">
+            <td class="entry_name
+             " rowspan="5">
+              android.<wbr/>scaler.<wbr/>available<wbr/>Recommended<wbr/>Input<wbr/>Output<wbr/>Formats<wbr/>Map
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name">int32</span>
+
+              <span class="entry_type_visibility"> [ndk_public as reprocessFormatsMap]</span>
+
+
+
+
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Recommended mappings of image formats that are supported by this
+camera device for input streams,<wbr/> to their corresponding output formats.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>4</p>
+            </td>
+
+            <td class="entry_tags">
+              <ul class="entry_tags">
+                  <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>This is a recommended subset of the complete list of mappings found in
+<a href="#static_android.scaler.availableInputOutputFormatsMap">android.<wbr/>scaler.<wbr/>available<wbr/>Input<wbr/>Output<wbr/>Formats<wbr/>Map</a>.<wbr/> The same requirements apply here as well.<wbr/>
+The list however doesn't need to contain all available and supported mappings.<wbr/> Instead of
+this developers must list only recommended and efficient entries.<wbr/>
+If set,<wbr/> the information will be available in the ZERO_<wbr/>SHUTTER_<wbr/>LAG recommended stream
+configuration see
+<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#getRecommendedStreamConfigurationMap">CameraCharacteristics#getRecommendedStreamConfigurationMap</a>.<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>For a code sample of the required data encoding please check
+<a href="#static_android.scaler.availableInputOutputFormatsMap">android.<wbr/>scaler.<wbr/>available<wbr/>Input<wbr/>Output<wbr/>Formats<wbr/>Map</a>.<wbr/></p>
+            </td>
+          </tr>
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
@@ -30100,6 +30318,78 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="static_android.depth.availableRecommendedDepthStreamConfigurations">
+            <td class="entry_name
+             " rowspan="5">
+              android.<wbr/>depth.<wbr/>available<wbr/>Recommended<wbr/>Depth<wbr/>Stream<wbr/>Configurations
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name">int32</span>
+                <span class="entry_type_container">x</span>
+
+                <span class="entry_type_array">
+                  n x 5
+                </span>
+              <span class="entry_type_visibility"> [ndk_public as recommendedStreamConfiguration]</span>
+
+
+
+
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Recommended depth stream configurations for common client use cases.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>4</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>Optional subset of the <a href="#static_android.depth.availableDepthStreamConfigurations">android.<wbr/>depth.<wbr/>available<wbr/>Depth<wbr/>Stream<wbr/>Configurations</a> that
+contains similar tuples listed as
+(i.<wbr/>e.<wbr/> width,<wbr/> height,<wbr/> format,<wbr/> output/<wbr/>input stream,<wbr/> usecase bit field).<wbr/>
+Camera devices will be able to suggest particular depth stream configurations which are
+power and performance efficient for specific use cases.<wbr/> For more information about
+retrieving the suggestions see
+<a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#getRecommendedStreamConfigurationMap">CameraCharacteristics#getRecommendedStreamConfigurationMap</a>.<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>Recommended depth configurations are expected to be declared with SNAPSHOT and/<wbr/>or
+ZSL if supported by the device.<wbr/>
+For additional details on how to declare recommended stream configurations,<wbr/> check
+<a href="#static_android.scaler.availableRecommendedStreamConfigurations">android.<wbr/>scaler.<wbr/>available<wbr/>Recommended<wbr/>Stream<wbr/>Configurations</a>.<wbr/>
+For additional requirements on depth streams please consider
+<a href="#static_android.depth.availableDepthStreamConfigurations">android.<wbr/>depth.<wbr/>available<wbr/>Depth<wbr/>Stream<wbr/>Configurations</a>.<wbr/></p>
+            </td>
+          </tr>
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
@@ -30844,6 +31134,7 @@
           <li><a href="#static_android.noiseReduction.availableNoiseReductionModes">android.noiseReduction.availableNoiseReductionModes</a> (static)</li>
           <li><a href="#static_android.request.maxNumInputStreams">android.request.maxNumInputStreams</a> (static)</li>
           <li><a href="#static_android.scaler.availableInputOutputFormatsMap">android.scaler.availableInputOutputFormatsMap</a> (static)</li>
+          <li><a href="#static_android.scaler.availableRecommendedInputOutputFormatsMap">android.scaler.availableRecommendedInputOutputFormatsMap</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>
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index e8036bc..2b7a1c8 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -76,6 +76,10 @@
     <typedef name="streamConfiguration">
       <language name="java">android.hardware.camera2.params.StreamConfiguration</language>
     </typedef>
+    <typedef name="recommendedStreamConfiguration">
+      <language
+      name="java">android.hardware.camera2.params.RecommendedStreamConfiguration</language>
+    </typedef>
     <typedef name="streamConfigurationDuration">
       <language name="java">android.hardware.camera2.params.StreamConfigurationDuration</language>
     </typedef>
@@ -6486,6 +6490,160 @@
           LEGACY capability devices will only support CENTER_ONLY cropping.
           </details>
         </entry>
+        <entry name="availableRecommendedStreamConfigurations" type="int32" visibility="ndk_public"
+            optional="true" enum="true" container="array" typedef="recommendedStreamConfiguration"
+            hal_version="3.4">
+          <array>
+            <size>n</size>
+            <size>5</size>
+          </array>
+          <enum>
+            <value id="0x0">PREVIEW
+            <notes>
+                Preview must only include non-stalling processed stream configurations with
+                output formats like YUV_420_888, IMPLEMENTATION_DEFINED, etc.
+            </notes>
+            </value>
+            <value id="0x1">RECORD
+            <notes>
+                Video record must include stream configurations that match the advertised
+                supported media profiles {@link android.media.CamcorderProfile} with
+                IMPLEMENTATION_DEFINED format.
+            </notes>
+            </value>
+            <value id="0x2">VIDEO_SNAPSHOT
+            <notes>
+                Video snapshot must include stream configurations at least as big as
+                the maximum RECORD resolutions and only with format BLOB + DATASPACE_JFIF
+                format/dataspace combination (JPEG). Additionally the configurations shouldn't cause
+                preview glitches and also be able to run at 30 fps.
+            </notes>
+            </value>
+            <value id="0x3">SNAPSHOT
+            <notes>
+                Recommended snapshot stream configurations must include at least one with
+                size close to android.sensor.info.activeArraySize with BLOB + DATASPACE_JFIF
+                format/dataspace combination (JPEG). Taking into account restrictions on aspect
+                ratio, alignment etc. the area of the maximum suggested size shouldn’t be less than
+                97% of the sensor array size area.
+            </notes>
+            </value>
+            <value id="0x4">ZSL
+            <notes>
+                If supported, recommended input stream configurations must only be advertised with
+                ZSL along with other processed and/or stalling output formats.
+            </notes>
+            </value>
+            <value id="0x5">RAW
+            <notes>
+                If supported, recommended raw stream configurations must only include RAW based
+                output formats.
+            </notes>
+            </value>
+            <value id="0x6">PUBLIC_END
+            </value>
+            <value id="0x18">VENDOR_START
+            <notes>
+                Vendor defined use cases. These depend on the vendor implementation.
+            </notes>
+            </value>
+          </enum>
+          <description>Recommended stream configurations for common client use cases.
+          </description>
+          <details>Optional subset of the android.scaler.availableStreamConfigurations that contains
+          similar tuples listed as
+          (i.e. width, height, format, output/input stream, usecase bit field).
+          Camera devices will be able to suggest particular stream configurations which are
+          power and performance efficient for specific use cases. For more information about
+          retrieving the suggestions see
+          {@link android.hardware.camera2.CameraCharacteristics#getRecommendedStreamConfigurationMap}.
+          </details>
+          <ndk_details>
+          The data representation is int[5], which maps to
+          (width, height, format, output/input stream, usecase bit field). The array can be
+          parsed using the following pseudo code:
+
+          struct StreamConfiguration {
+          int32_t format;
+          int32_t width;
+          int32_t height;
+          int32_t isInput; };
+
+          void getPreferredStreamConfigurations(
+              int32_t *array, size_t count, int32_t usecaseId,
+              Vector &lt; StreamConfiguration &gt; * scs) {
+              const size_t STREAM_CONFIGURATION_SIZE = 5;
+              const size_t STREAM_WIDTH_OFFSET = 0;
+              const size_t STREAM_HEIGHT_OFFSET = 1;
+              const size_t STREAM_FORMAT_OFFSET = 2;
+              const size_t STREAM_IS_INPUT_OFFSET = 3;
+              const size_t STREAM_USECASE_BITMAP_OFFSET = 4;
+
+              for (size_t i = 0; i &lt; count; i+= STREAM_CONFIGURATION_SIZE) {
+                  int32_t width = array[i + STREAM_WIDTH_OFFSET];
+                  int32_t height = array[i + STREAM_HEIGHT_OFFSET];
+                  int32_t format = array[i + STREAM_FORMAT_OFFSET];
+                  int32_t isInput = array[i + STREAM_IS_INPUT_OFFSET];
+                  int32_t supportedUsecases = array[i + STREAM_USECASE_BITMAP_OFFSET];
+                  if (supportedUsecases &amp; (1 &lt;&lt; usecaseId)) {
+                      StreamConfiguration sc = {format, width, height, isInput};
+                      scs->add(sc);
+                  }
+              }
+          }
+
+          </ndk_details>
+          <hal_details>
+          There are some requirements that need to be considered regarding the usecases and the
+          suggested configurations:
+
+          * If android.scaler.availableRecommendedStreamConfigurations is set, then recommended
+          stream configurations must be present for all mandatory usecases PREVIEW,
+          SNAPSHOT, RECORD, VIDEO_SNAPSHOT. ZSL and RAW are
+          required depending on device capabilities see android.request.availableCapabilities.
+          * Non-existing usecases and non-vendor usecases within the range
+          (RAW : VENDOR_START] are prohibited as well as stream configurations not
+          present in the exhaustive android.scaler.availableStreamConfigurations list.
+
+          For example, in case the camera device supports only 4K and 1080p and both resolutions are
+          recommended for the mandatory usecases except preview which can run efficiently only
+          on 1080p. The array may look like this:
+
+          [3840, 2160, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
+           ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,
+           (1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RECORD |
+           1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_SNAPSHOT |
+           1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VIDEO_SNAPSHOT),
+
+           1920, 1080, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
+           ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,
+           (1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PREVIEW |
+           1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RECORD |
+           1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_SNAPSHOT |
+           1&lt;&lt; ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VIDEO_SNAPSHOT)]
+
+          </hal_details>
+        </entry>
+        <entry name="availableRecommendedInputOutputFormatsMap" type="int32" visibility="ndk_public"
+          optional="true" typedef="reprocessFormatsMap" hal_version="3.4">
+          <description>Recommended mappings of image formats that are supported by this
+          camera device for input streams, to their corresponding output formats.
+          </description>
+          <details>
+          This is a recommended subset of the complete list of mappings found in
+          android.scaler.availableInputOutputFormatsMap. The same requirements apply here as well.
+          The list however doesn't need to contain all available and supported mappings. Instead of
+          this developers must list only recommended and efficient entries.
+          If set, the information will be available in the ZERO_SHUTTER_LAG recommended stream
+          configuration see
+          {@link android.hardware.camera2.CameraCharacteristics#getRecommendedStreamConfigurationMap}.
+          </details>
+          <hal_details>
+          For a code sample of the required data encoding please check
+          android.scaler.availableInputOutputFormatsMap.
+          </hal_details>
+          <tag id="REPROC" />
+        </entry>
       </static>
     </section>
     <section name="sensor">
@@ -9882,6 +10040,36 @@
           corrupted during depth measurement.
           </details>
         </entry>
+        <entry name="availableRecommendedDepthStreamConfigurations" type="int32"
+            visibility="ndk_public" optional="true" container="array"
+            typedef="recommendedStreamConfiguration" hal_version="3.4">
+          <array>
+            <size>n</size>
+            <size>5</size>
+          </array>
+          <description>Recommended depth stream configurations for common client use cases.
+          </description>
+          <details>Optional subset of the android.depth.availableDepthStreamConfigurations that
+          contains similar tuples listed as
+          (i.e. width, height, format, output/input stream, usecase bit field).
+          Camera devices will be able to suggest particular depth stream configurations which are
+          power and performance efficient for specific use cases. For more information about
+          retrieving the suggestions see
+          {@link android.hardware.camera2.CameraCharacteristics#getRecommendedStreamConfigurationMap}.
+          </details>
+          <ndk_details>
+          For data representation please refer to
+          android.scaler.availableRecommendedStreamConfigurations
+          </ndk_details>
+          <hal_details>
+          Recommended depth configurations are expected to be declared with SNAPSHOT and/or
+          ZSL if supported by the device.
+          For additional details on how to declare recommended stream configurations, check
+          android.scaler.availableRecommendedStreamConfigurations.
+          For additional requirements on depth streams please consider
+          android.depth.availableDepthStreamConfigurations.
+          </hal_details>
+        </entry>
       </static>
     </section>
     <section name="logicalMultiCamera">
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 3c9f1d7..6777321 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -296,6 +296,10 @@
     ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,     // int64[]      | ndk_public   | HIDL v3.2
     ANDROID_SCALER_AVAILABLE_STALL_DURATIONS,         // int64[]      | ndk_public   | HIDL v3.2
     ANDROID_SCALER_CROPPING_TYPE,                     // enum         | public       | HIDL v3.2
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS,
+                                                      // enum[]       | ndk_public   | HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_INPUT_OUTPUT_FORMATS_MAP,
+                                                      // int32        | ndk_public   | HIDL v3.4
     ANDROID_SCALER_END,
 
     ANDROID_SENSOR_EXPOSURE_TIME =                    // int64        | public       | HIDL v3.2
@@ -435,6 +439,8 @@
     ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS,// int64[]      | ndk_public   | HIDL v3.2
     ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS,    // int64[]      | ndk_public   | HIDL v3.2
     ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE,                 // enum         | public       | HIDL v3.2
+    ANDROID_DEPTH_AVAILABLE_RECOMMENDED_DEPTH_STREAM_CONFIGURATIONS,
+                                                      // int32[]      | ndk_public   | HIDL v3.4
     ANDROID_DEPTH_END,
 
     ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS =       // byte[]       | hidden       | HIDL v3.3
@@ -808,6 +814,24 @@
     ANDROID_SCALER_CROPPING_TYPE_FREEFORM                           , // HIDL v3.2
 } camera_metadata_enum_android_scaler_cropping_type_t;
 
+// ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS
+typedef enum camera_metadata_enum_android_scaler_available_recommended_stream_configurations {
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PREVIEW
+                                                                      = 0x0, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RECORD
+                                                                      = 0x1, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VIDEO_SNAPSHOT
+                                                                      = 0x2, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_SNAPSHOT
+                                                                      = 0x3, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_ZSL   = 0x4, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RAW   = 0x5, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PUBLIC_END
+                                                                      = 0x6, // HIDL v3.4
+    ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VENDOR_START
+                                                                      = 0x18, // HIDL v3.4
+} camera_metadata_enum_android_scaler_available_recommended_stream_configurations_t;
+
 
 // ANDROID_SENSOR_REFERENCE_ILLUMINANT1
 typedef enum camera_metadata_enum_android_sensor_reference_illuminant1 {
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index e38120d..a337faa 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -454,6 +454,12 @@
     { "availableStallDurations",       TYPE_INT64  },
     [ ANDROID_SCALER_CROPPING_TYPE - ANDROID_SCALER_START ] =
     { "croppingType",                  TYPE_BYTE   },
+    [ ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS - ANDROID_SCALER_START ] =
+    { "availableRecommendedStreamConfigurations",
+                                        TYPE_INT32  },
+    [ ANDROID_SCALER_AVAILABLE_RECOMMENDED_INPUT_OUTPUT_FORMATS_MAP - ANDROID_SCALER_START ] =
+    { "availableRecommendedInputOutputFormatsMap",
+                                        TYPE_INT32  },
 };
 
 static tag_info_t android_sensor[ANDROID_SENSOR_END -
@@ -710,6 +716,9 @@
     { "availableDepthStallDurations",  TYPE_INT64  },
     [ ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE - ANDROID_DEPTH_START ] =
     { "depthIsExclusive",              TYPE_BYTE   },
+    [ ANDROID_DEPTH_AVAILABLE_RECOMMENDED_DEPTH_STREAM_CONFIGURATIONS - ANDROID_DEPTH_START ] =
+    { "availableRecommendedDepthStreamConfigurations",
+                                        TYPE_INT32  },
 };
 
 static tag_info_t android_logical_multi_camera[ANDROID_LOGICAL_MULTI_CAMERA_END -
@@ -2077,6 +2086,48 @@
             }
             break;
         }
+        case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS: {
+            switch (value) {
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PREVIEW:
+                    msg = "PREVIEW";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RECORD:
+                    msg = "RECORD";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VIDEO_SNAPSHOT:
+                    msg = "VIDEO_SNAPSHOT";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_SNAPSHOT:
+                    msg = "SNAPSHOT";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_ZSL:
+                    msg = "ZSL";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_RAW:
+                    msg = "RAW";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_PUBLIC_END:
+                    msg = "PUBLIC_END";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_AVAILABLE_RECOMMENDED_STREAM_CONFIGURATIONS_VENDOR_START:
+                    msg = "VENDOR_START";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
+        case ANDROID_SCALER_AVAILABLE_RECOMMENDED_INPUT_OUTPUT_FORMATS_MAP: {
+            break;
+        }
 
         case ANDROID_SENSOR_EXPOSURE_TIME: {
             break;
@@ -2795,6 +2846,9 @@
             }
             break;
         }
+        case ANDROID_DEPTH_AVAILABLE_RECOMMENDED_DEPTH_STREAM_CONFIGURATIONS: {
+            break;
+        }
 
         case ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS: {
             break;