Camera: Add partialResult quirk metadata fields

To be used by HALs to split up capture results into
multiple batches.

Bug: 11115603

Change-Id: I5cfc26b2812f9bf4613944c0679e0e29cfd43616
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index d4f29fb..0c0b25e 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -386,6 +386,13 @@
             <li><a href="#static_android.quirks.meteringCropRegion">android.quirks.meteringCropRegion</a></li>
             <li><a href="#static_android.quirks.triggerAfWithAuto">android.quirks.triggerAfWithAuto</a></li>
             <li><a href="#static_android.quirks.useZslFormat">android.quirks.useZslFormat</a></li>
+            <li><a href="#static_android.quirks.usePartialResult">android.quirks.usePartialResult</a></li>
+          </ul>
+        </li>
+        <li>
+          <span class="toc_kind_header">dynamic</span>
+          <ul class="toc_section">
+            <li><a href="#dynamic_android.quirks.partialResult">android.quirks.partialResult</a></li>
           </ul>
         </li>
       </ul> <!-- toc_section -->
@@ -6518,6 +6525,129 @@
 
           </tr> <!-- end of entry -->
         
+                
+          <tr class="entry" id="static_android.quirks.usePartialResult">
+            <td class="entry_name">android.<wbr>quirks.<wbr>use<wbr>Partial<wbr>Result</td>
+            <td class="entry_type">
+                <span class="entry_type_name">byte</span>
+
+              <span class="entry_type_visibility"> [system]</span>
+
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              If set to 1,<wbr> the HAL will always split result
+          metadata for a single capture into multiple buffers,<wbr>
+          returned using multiple process_<wbr>capture_<wbr>result calls.<wbr>
+          
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_notes">
+              Does not need to be listed in static
+          metadata.<wbr> Support for partial results will be reworked in
+          future versions of camera service.<wbr> This quirk will stop
+          working at that point; DO NOT USE without careful
+          consideration of future support.<wbr>
+          
+            </td>
+
+            <td class="entry_tags">
+            </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_notes">Notes</th>
+          <th class="th_tags">Tags</th>
+        </tr>
+      </thead>
+
+      <tbody>
+
+        
+
+        
+
+        
+
+        
+
+                
+          <tr class="entry" id="dynamic_android.quirks.partialResult">
+            <td class="entry_name">android.<wbr>quirks.<wbr>partial<wbr>Result</td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [system as boolean]</span>
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">FINAL</span>
+                    <span class="entry_type_enum_notes">The last or only metadata result buffer
+            for this capture.<wbr></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">PARTIAL</span>
+                    <span class="entry_type_enum_notes">A partial buffer of result metadata for this
+            capture.<wbr> More result buffers for this capture will be sent
+            by the HAL,<wbr> the last of which will be marked
+            FINAL.<wbr></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              Whether a result given to the framework is the
+          final one for the capture,<wbr> or only a partial that contains a
+          subset of the full set of dynamic metadata
+          values.<wbr>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+              Optional.<wbr> Default value is FINAL.<wbr>
+            </td>
+
+            <td class="entry_notes">
+              The entries in the result metadata buffers for a
+          single capture may not overlap,<wbr> except for this entry.<wbr> The
+          FINAL buffers must retain FIFO ordering relative to the
+          requests that generate them,<wbr> so the FINAL buffer for frame 3 must
+          always be sent to the framework after the FINAL buffer for frame 2,<wbr> and
+          before the FINAL buffer for frame 4.<wbr> PARTIAL buffers may be returned
+          in any order relative to other frames,<wbr> but all PARTIAL buffers for a given
+          capture must arrive before the FINAL buffer for that capture.<wbr> This entry may
+          only be used by the HAL if quirks.<wbr>usePartialResult is set to 1.<wbr>
+          
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr> <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
diff --git a/camera/docs/metadata_properties.xml b/camera/docs/metadata_properties.xml
index 3e898c6..38f6779 100644
--- a/camera/docs/metadata_properties.xml
+++ b/camera/docs/metadata_properties.xml
@@ -1444,7 +1444,7 @@
     </section>
     <section name="quirks">
       <static>
-        <entry name="meteringCropRegion" type="byte" visibility="system">
+        <entry name="meteringCropRegion" type="byte" visibility="system" optional="true">
           <description>If set to 1, the camera service does not
           scale 'normalized' coordinates with respect to the crop
           region. This applies to metering input (a{e,f,wb}Region
@@ -1458,7 +1458,7 @@
           not need to be listed in static metadata. Support will be
           removed in future versions of camera service.</notes>
         </entry>
-        <entry name="triggerAfWithAuto" type="byte" visibility="system">
+        <entry name="triggerAfWithAuto" type="byte" visibility="system" optional="true">
           <description>If set to 1, then the camera service always
           switches to FOCUS_MODE_AUTO before issuing a AF
           trigger.</description>
@@ -1468,7 +1468,7 @@
           not need to be listed in static metadata. Support will be
           removed in future versions of camera service</notes>
         </entry>
-        <entry name="useZslFormat" type="byte" visibility="system">
+        <entry name="useZslFormat" type="byte" visibility="system" optional="true">
           <description>If set to 1, the camera service uses
           CAMERA2_PIXEL_FORMAT_ZSL instead of
           HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED for the zero
@@ -1480,7 +1480,51 @@
           metadata. Support will be removed in future versions of
           camera service.</notes>
         </entry>
+        <entry name="usePartialResult" type="byte" visibility="system" optional="true">
+          <description>If set to 1, the HAL will always split result
+          metadata for a single capture into multiple buffers,
+          returned using multiple process_capture_result calls.
+          </description>
+          <notes>Does not need to be listed in static
+          metadata. Support for partial results will be reworked in
+          future versions of camera service. This quirk will stop
+          working at that point; DO NOT USE without careful
+          consideration of future support.
+          </notes>
+        </entry>
+
       </static>
+      <dynamic>
+        <entry name="partialResult" type="byte" visibility="system" optional="true" enum="true" typedef="boolean">
+          <enum>
+            <value>FINAL
+            <notes>The last or only metadata result buffer
+            for this capture.</notes>
+            </value>
+            <value>PARTIAL
+            <notes>A partial buffer of result metadata for this
+            capture. More result buffers for this capture will be sent
+            by the HAL, the last of which will be marked
+            FINAL.</notes>
+            </value>
+          </enum>
+          <description>Whether a result given to the framework is the
+          final one for the capture, or only a partial that contains a
+          subset of the full set of dynamic metadata
+          values.</description>
+          <range>Optional. Default value is FINAL.</range>
+          <notes>The entries in the result metadata buffers for a
+          single capture may not overlap, except for this entry. The
+          FINAL buffers must retain FIFO ordering relative to the
+          requests that generate them, so the FINAL buffer for frame 3 must
+          always be sent to the framework after the FINAL buffer for frame 2, and
+          before the FINAL buffer for frame 4. PARTIAL buffers may be returned
+          in any order relative to other frames, but all PARTIAL buffers for a given
+          capture must arrive before the FINAL buffer for that capture. This entry may
+          only be used by the HAL if quirks.usePartialResult is set to 1.
+          </notes>
+        </entry>
+      </dynamic>
     </section>
     <section name="request">
       <controls>
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 70e8894..1585e06 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -233,6 +233,8 @@
             ANDROID_QUIRKS_START,
     ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,              // byte         | system
     ANDROID_QUIRKS_USE_ZSL_FORMAT,                    // byte         | system
+    ANDROID_QUIRKS_USE_PARTIAL_RESULT,                // byte         | system
+    ANDROID_QUIRKS_PARTIAL_RESULT,                    // enum         | system
     ANDROID_QUIRKS_END,
 
     ANDROID_REQUEST_FRAME_COUNT =                     // int32        | public
@@ -587,6 +589,12 @@
 } camera_metadata_enum_android_noise_reduction_mode_t;
 
 
+// ANDROID_QUIRKS_PARTIAL_RESULT
+typedef enum camera_metadata_enum_android_quirks_partial_result {
+    ANDROID_QUIRKS_PARTIAL_RESULT_FINAL,
+    ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL,
+} camera_metadata_enum_android_quirks_partial_result_t;
+
 
 // ANDROID_REQUEST_METADATA_MODE
 typedef enum camera_metadata_enum_android_request_metadata_mode {
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index 1a0dc11..7511249 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -342,6 +342,10 @@
     { "triggerAfWithAuto",             TYPE_BYTE   },
     [ ANDROID_QUIRKS_USE_ZSL_FORMAT - ANDROID_QUIRKS_START ] =
     { "useZslFormat",                  TYPE_BYTE   },
+    [ ANDROID_QUIRKS_USE_PARTIAL_RESULT - ANDROID_QUIRKS_START ] =
+    { "usePartialResult",              TYPE_BYTE   },
+    [ ANDROID_QUIRKS_PARTIAL_RESULT - ANDROID_QUIRKS_START ] =
+    { "partialResult",                 TYPE_BYTE   },
 };
 
 static tag_info_t android_request[ANDROID_REQUEST_END -
@@ -1432,6 +1436,24 @@
         case ANDROID_QUIRKS_USE_ZSL_FORMAT: {
             break;
         }
+        case ANDROID_QUIRKS_USE_PARTIAL_RESULT: {
+            break;
+        }
+        case ANDROID_QUIRKS_PARTIAL_RESULT: {
+            switch (value) {
+                case ANDROID_QUIRKS_PARTIAL_RESULT_FINAL:
+                    msg = "FINAL";
+                    ret = 0;
+                    break;
+                case ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL:
+                    msg = "PARTIAL";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
 
         case ANDROID_REQUEST_FRAME_COUNT: {
             break;