1 /*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "vsock_camera_metadata.h"
17
18 #include <hardware/camera3.h>
19 #include <utils/misc.h>
20 #include <vector>
21
22 namespace android::hardware::camera::device::V3_4::implementation {
23
24 namespace {
25 // Mostly copied from ExternalCameraDevice
26 const uint8_t kHardwarelevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL;
27 const uint8_t kAberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;
28 const uint8_t kAvailableAberrationModes[] = {
29 ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF};
30 const int32_t kExposureCompensation = 0;
31 const uint8_t kAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
32 const int32_t kControlMaxRegions[] = {/*AE*/ 0, /*AWB*/ 0, /*AF*/ 0};
33 const uint8_t kVideoStabilizationMode =
34 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF;
35 const uint8_t kAwbAvailableMode = ANDROID_CONTROL_AWB_MODE_AUTO;
36 const uint8_t kAePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
37 const uint8_t kAeAvailableMode = ANDROID_CONTROL_AE_MODE_ON;
38 const uint8_t kAvailableFffect = ANDROID_CONTROL_EFFECT_MODE_OFF;
39 const uint8_t kControlMode = ANDROID_CONTROL_MODE_AUTO;
40 const uint8_t kControlAvailableModes[] = {ANDROID_CONTROL_MODE_OFF,
41 ANDROID_CONTROL_MODE_AUTO};
42 const uint8_t kEdgeMode = ANDROID_EDGE_MODE_OFF;
43 const uint8_t kFlashInfo = ANDROID_FLASH_INFO_AVAILABLE_FALSE;
44 const uint8_t kFlashMode = ANDROID_FLASH_MODE_OFF;
45 const uint8_t kHotPixelMode = ANDROID_HOT_PIXEL_MODE_OFF;
46 const uint8_t kJpegQuality = 90;
47 const int32_t kJpegOrientation = 0;
48 const int32_t kThumbnailSize[] = {240, 180};
49 const int32_t kJpegAvailableThumbnailSizes[] = {0, 0, 240, 180};
50 const uint8_t kFocusDistanceCalibration =
51 ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED;
52 const uint8_t kOpticalStabilizationMode =
53 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
54 const uint8_t kFacing = ANDROID_LENS_FACING_EXTERNAL;
55 const float kLensMinFocusDistance = 0.0f;
56 const uint8_t kNoiseReductionMode = ANDROID_NOISE_REDUCTION_MODE_OFF;
57 const int32_t kPartialResultCount = 1;
58 const uint8_t kRequestPipelineMaxDepth = 4;
59 const int32_t kRequestMaxNumInputStreams = 0;
60 const float kScalerAvailableMaxDigitalZoom[] = {1};
61 const uint8_t kCroppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY;
62 const int32_t kTestPatternMode = ANDROID_SENSOR_TEST_PATTERN_MODE_OFF;
63 const int32_t kTestPatternModes[] = {ANDROID_SENSOR_TEST_PATTERN_MODE_OFF};
64 const uint8_t kTimestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;
65 const int32_t kOrientation = 0;
66 const uint8_t kAvailableShadingMode = ANDROID_SHADING_MODE_OFF;
67 const uint8_t kFaceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
68 const int32_t kMaxFaceCount = 0;
69 const uint8_t kAvailableHotpixelMode =
70 ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF;
71 const uint8_t kLensShadingMapMode =
72 ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF;
73 const int32_t kMaxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
74 const int32_t kControlAeCompensationRange[] = {0, 0};
75 const camera_metadata_rational_t kControlAeCompensationStep[] = {{0, 1}};
76 const uint8_t kAfTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;
77 const uint8_t kAfMode = ANDROID_CONTROL_AF_MODE_OFF;
78 const uint8_t kAfAvailableModes[] = {ANDROID_CONTROL_AF_MODE_OFF};
79 const uint8_t kAvailableSceneMode = ANDROID_CONTROL_SCENE_MODE_DISABLED;
80 const uint8_t kAeLockAvailable = ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE;
81 const uint8_t kAwbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE;
82 const int32_t kHalFormats[] = {HAL_PIXEL_FORMAT_BLOB,
83 HAL_PIXEL_FORMAT_YCbCr_420_888,
84 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED};
85 const int32_t kRequestMaxNumOutputStreams[] = {
86 /*RAW*/ 0,
87 /*Processed*/ 2,
88 /*Stall*/ 1};
89 const uint8_t kAvailableCapabilities[] = {
90 ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE};
91 const int32_t kAvailableRequestKeys[] = {
92 ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
93 ANDROID_CONTROL_AE_ANTIBANDING_MODE,
94 ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
95 ANDROID_CONTROL_AE_LOCK,
96 ANDROID_CONTROL_AE_MODE,
97 ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
98 ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
99 ANDROID_CONTROL_AF_MODE,
100 ANDROID_CONTROL_AF_TRIGGER,
101 ANDROID_CONTROL_AWB_LOCK,
102 ANDROID_CONTROL_AWB_MODE,
103 ANDROID_CONTROL_CAPTURE_INTENT,
104 ANDROID_CONTROL_EFFECT_MODE,
105 ANDROID_CONTROL_MODE,
106 ANDROID_CONTROL_SCENE_MODE,
107 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
108 ANDROID_FLASH_MODE,
109 ANDROID_JPEG_ORIENTATION,
110 ANDROID_JPEG_QUALITY,
111 ANDROID_JPEG_THUMBNAIL_QUALITY,
112 ANDROID_JPEG_THUMBNAIL_SIZE,
113 ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
114 ANDROID_NOISE_REDUCTION_MODE,
115 ANDROID_SCALER_CROP_REGION,
116 ANDROID_SENSOR_TEST_PATTERN_MODE,
117 ANDROID_STATISTICS_FACE_DETECT_MODE,
118 ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE};
119 const int32_t kAvailableResultKeys[] = {
120 ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
121 ANDROID_CONTROL_AE_ANTIBANDING_MODE,
122 ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
123 ANDROID_CONTROL_AE_LOCK,
124 ANDROID_CONTROL_AE_MODE,
125 ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
126 ANDROID_CONTROL_AE_STATE,
127 ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
128 ANDROID_CONTROL_AF_MODE,
129 ANDROID_CONTROL_AF_STATE,
130 ANDROID_CONTROL_AF_TRIGGER,
131 ANDROID_CONTROL_AWB_LOCK,
132 ANDROID_CONTROL_AWB_MODE,
133 ANDROID_CONTROL_AWB_STATE,
134 ANDROID_CONTROL_CAPTURE_INTENT,
135 ANDROID_CONTROL_EFFECT_MODE,
136 ANDROID_CONTROL_MODE,
137 ANDROID_CONTROL_SCENE_MODE,
138 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
139 ANDROID_FLASH_MODE,
140 ANDROID_FLASH_STATE,
141 ANDROID_JPEG_ORIENTATION,
142 ANDROID_JPEG_QUALITY,
143 ANDROID_JPEG_THUMBNAIL_QUALITY,
144 ANDROID_JPEG_THUMBNAIL_SIZE,
145 ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
146 ANDROID_NOISE_REDUCTION_MODE,
147 ANDROID_REQUEST_PIPELINE_DEPTH,
148 ANDROID_SCALER_CROP_REGION,
149 ANDROID_SENSOR_TIMESTAMP,
150 ANDROID_STATISTICS_FACE_DETECT_MODE,
151 ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE,
152 ANDROID_STATISTICS_LENS_SHADING_MAP_MODE,
153 ANDROID_STATISTICS_SCENE_FLICKER};
154 const int32_t kAvailableCharacteristicsKeys[] = {
155 ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
156 ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
157 ANDROID_CONTROL_AE_AVAILABLE_MODES,
158 ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
159 ANDROID_CONTROL_AE_COMPENSATION_RANGE,
160 ANDROID_CONTROL_AE_COMPENSATION_STEP,
161 ANDROID_CONTROL_AE_LOCK_AVAILABLE,
162 ANDROID_CONTROL_AF_AVAILABLE_MODES,
163 ANDROID_CONTROL_AVAILABLE_EFFECTS,
164 ANDROID_CONTROL_AVAILABLE_MODES,
165 ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
166 ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
167 ANDROID_CONTROL_AWB_AVAILABLE_MODES,
168 ANDROID_CONTROL_AWB_LOCK_AVAILABLE,
169 ANDROID_CONTROL_MAX_REGIONS,
170 ANDROID_FLASH_INFO_AVAILABLE,
171 ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,
172 ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
173 ANDROID_LENS_FACING,
174 ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
175 ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,
176 ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,
177 ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
178 ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
179 ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,
180 ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,
181 ANDROID_REQUEST_PARTIAL_RESULT_COUNT,
182 ANDROID_REQUEST_PIPELINE_MAX_DEPTH,
183 ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
184 ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
185 ANDROID_SCALER_CROPPING_TYPE,
186 ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE,
187 ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
188 ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
189 ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
190 ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
191 ANDROID_SENSOR_ORIENTATION,
192 ANDROID_SHADING_AVAILABLE_MODES,
193 ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
194 ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES,
195 ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
196 ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
197 ANDROID_SYNC_MAX_LATENCY};
198 const std::map<RequestTemplate, uint8_t> kTemplateToIntent = {
199 {RequestTemplate::PREVIEW, ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW},
200 {RequestTemplate::STILL_CAPTURE,
201 ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE},
202 {RequestTemplate::VIDEO_RECORD,
203 ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD},
204 {RequestTemplate::VIDEO_SNAPSHOT,
205 ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT},
206 };
207 } // namespace
208
209 // Constructor sets the default characteristics for vsock camera
VsockCameraMetadata(int32_t width,int32_t height,int32_t fps)210 VsockCameraMetadata::VsockCameraMetadata(int32_t width, int32_t height,
211 int32_t fps)
212 : width_(width), height_(height), fps_(fps) {
213 update(ANDROID_CONTROL_AE_COMPENSATION_RANGE, kControlAeCompensationRange,
214 NELEM(kControlAeCompensationRange));
215 update(ANDROID_CONTROL_AE_COMPENSATION_STEP, kControlAeCompensationStep,
216 NELEM(kControlAeCompensationStep));
217 update(ANDROID_CONTROL_AF_AVAILABLE_MODES, kAfAvailableModes,
218 NELEM(kAfAvailableModes));
219 update(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, &kAvailableSceneMode, 1);
220 update(ANDROID_CONTROL_AE_LOCK_AVAILABLE, &kAeLockAvailable, 1);
221 update(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, &kAwbLockAvailable, 1);
222 update(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
223 kScalerAvailableMaxDigitalZoom, NELEM(kScalerAvailableMaxDigitalZoom));
224 update(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, kAvailableCapabilities,
225 NELEM(kAvailableCapabilities));
226 update(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, &kHardwarelevel, 1);
227 update(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
228 kAvailableAberrationModes, NELEM(kAvailableAberrationModes));
229 update(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, &kAntibandingMode, 1);
230 update(ANDROID_CONTROL_MAX_REGIONS, kControlMaxRegions,
231 NELEM(kControlMaxRegions));
232 update(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
233 &kVideoStabilizationMode, 1);
234 update(ANDROID_CONTROL_AWB_AVAILABLE_MODES, &kAwbAvailableMode, 1);
235 update(ANDROID_CONTROL_AE_AVAILABLE_MODES, &kAeAvailableMode, 1);
236 update(ANDROID_CONTROL_AVAILABLE_EFFECTS, &kAvailableFffect, 1);
237 update(ANDROID_CONTROL_AVAILABLE_MODES, kControlAvailableModes,
238 NELEM(kControlAvailableModes));
239 update(ANDROID_EDGE_AVAILABLE_EDGE_MODES, &kEdgeMode, 1);
240 update(ANDROID_FLASH_INFO_AVAILABLE, &kFlashInfo, 1);
241 update(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES, &kHotPixelMode, 1);
242 update(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, kJpegAvailableThumbnailSizes,
243 NELEM(kJpegAvailableThumbnailSizes));
244 update(ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,
245 &kFocusDistanceCalibration, 1);
246 update(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, &kLensMinFocusDistance, 1);
247 update(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
248 &kOpticalStabilizationMode, 1);
249 update(ANDROID_LENS_FACING, &kFacing, 1);
250 update(ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
251 &kNoiseReductionMode, 1);
252 update(ANDROID_NOISE_REDUCTION_MODE, &kNoiseReductionMode, 1);
253 update(ANDROID_REQUEST_PARTIAL_RESULT_COUNT, &kPartialResultCount, 1);
254 update(ANDROID_REQUEST_PIPELINE_MAX_DEPTH, &kRequestPipelineMaxDepth, 1);
255 update(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, kRequestMaxNumOutputStreams,
256 NELEM(kRequestMaxNumOutputStreams));
257 update(ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, &kRequestMaxNumInputStreams, 1);
258 update(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
259 kScalerAvailableMaxDigitalZoom, NELEM(kScalerAvailableMaxDigitalZoom));
260 update(ANDROID_SCALER_CROPPING_TYPE, &kCroppingType, 1);
261 update(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, kTestPatternModes,
262 NELEM(kTestPatternModes));
263 update(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, &kTimestampSource, 1);
264 update(ANDROID_SENSOR_ORIENTATION, &kOrientation, 1);
265 update(ANDROID_SHADING_AVAILABLE_MODES, &kAvailableShadingMode, 1);
266 update(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, &kFaceDetectMode,
267 1);
268 update(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, &kMaxFaceCount, 1);
269 update(ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES,
270 &kAvailableHotpixelMode, 1);
271 update(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
272 &kLensShadingMapMode, 1);
273 update(ANDROID_SYNC_MAX_LATENCY, &kMaxLatency, 1);
274 update(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, kAvailableRequestKeys,
275 NELEM(kAvailableRequestKeys));
276 update(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, kAvailableResultKeys,
277 NELEM(kAvailableResultKeys));
278 update(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
279 kAvailableCharacteristicsKeys, NELEM(kAvailableCharacteristicsKeys));
280
281 // assume max 2bytes/pixel + info because client might provide us pngs
282 const int32_t jpeg_max_size = width * height * 2 + sizeof(camera3_jpeg_blob);
283 update(ANDROID_JPEG_MAX_SIZE, &jpeg_max_size, 1);
284
285 std::vector<int64_t> min_frame_durations;
286 std::vector<int32_t> stream_configurations;
287 std::vector<int64_t> stall_durations;
288
289 int64_t frame_duration = 1000000000L / fps;
290 for (const auto& format : kHalFormats) {
291 stream_configurations.push_back(format);
292 min_frame_durations.push_back(format);
293 stall_durations.push_back(format);
294 stream_configurations.push_back(width);
295 min_frame_durations.push_back(width);
296 stall_durations.push_back(width);
297 stream_configurations.push_back(height);
298 min_frame_durations.push_back(height);
299 stall_durations.push_back(height);
300 stream_configurations.push_back(
301 ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT);
302 min_frame_durations.push_back(frame_duration);
303 stall_durations.push_back((format == HAL_PIXEL_FORMAT_BLOB) ? 2000000000L
304 : 0);
305 }
306 update(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
307 stream_configurations.data(), stream_configurations.size());
308 update(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,
309 min_frame_durations.data(), min_frame_durations.size());
310 update(ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, stall_durations.data(),
311 stall_durations.size());
312
313 int32_t active_array_size[] = {0, 0, width, height};
314 update(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
315 active_array_size, NELEM(active_array_size));
316 update(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, active_array_size,
317 NELEM(active_array_size));
318
319 int32_t pixel_array_size[] = {width, height};
320 update(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, pixel_array_size,
321 NELEM(pixel_array_size));
322
323 int32_t max_frame_rate = fps;
324 int32_t min_frame_rate = max_frame_rate / 2;
325 int32_t frame_rates[] = {min_frame_rate, max_frame_rate};
326 update(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, frame_rates,
327 NELEM(frame_rates));
328 int64_t max_frame_duration = 1000000000L / min_frame_rate;
329 update(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, &max_frame_duration, 1);
330 }
331
VsockCameraRequestMetadata(int32_t fps,RequestTemplate type)332 VsockCameraRequestMetadata::VsockCameraRequestMetadata(int32_t fps,
333 RequestTemplate type) {
334 update(ANDROID_COLOR_CORRECTION_ABERRATION_MODE, &kAberrationMode, 1);
335 update(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, &kExposureCompensation, 1);
336 update(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &kVideoStabilizationMode, 1);
337 update(ANDROID_CONTROL_AWB_MODE, &kAwbAvailableMode, 1);
338 update(ANDROID_CONTROL_AE_MODE, &kAeAvailableMode, 1);
339 update(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, &kAePrecaptureTrigger, 1);
340 update(ANDROID_CONTROL_AF_MODE, &kAfMode, 1);
341 update(ANDROID_CONTROL_AF_TRIGGER, &kAfTrigger, 1);
342 update(ANDROID_CONTROL_SCENE_MODE, &kAvailableSceneMode, 1);
343 update(ANDROID_CONTROL_EFFECT_MODE, &kAvailableFffect, 1);
344 update(ANDROID_FLASH_MODE, &kFlashMode, 1);
345 update(ANDROID_JPEG_THUMBNAIL_SIZE, kThumbnailSize, NELEM(kThumbnailSize));
346 update(ANDROID_JPEG_QUALITY, &kJpegQuality, 1);
347 update(ANDROID_JPEG_THUMBNAIL_QUALITY, &kJpegQuality, 1);
348 update(ANDROID_JPEG_ORIENTATION, &kJpegOrientation, 1);
349 update(ANDROID_LENS_OPTICAL_STABILIZATION_MODE, &kOpticalStabilizationMode,
350 1);
351 update(ANDROID_NOISE_REDUCTION_MODE, &kNoiseReductionMode, 1);
352 update(ANDROID_SENSOR_TEST_PATTERN_MODE, &kTestPatternMode, 1);
353 update(ANDROID_STATISTICS_FACE_DETECT_MODE, &kFaceDetectMode, 1);
354 update(ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, &kAvailableHotpixelMode, 1);
355
356 int32_t max_frame_rate = fps;
357 int32_t min_frame_rate = max_frame_rate / 2;
358 int32_t frame_rates[] = {min_frame_rate, max_frame_rate};
359 update(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, frame_rates, NELEM(frame_rates));
360
361 update(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &kAntibandingMode, 1);
362 update(ANDROID_CONTROL_MODE, &kControlMode, 1);
363
364 auto it = kTemplateToIntent.find(type);
365 if (it != kTemplateToIntent.end()) {
366 auto intent = it->second;
367 update(ANDROID_CONTROL_CAPTURE_INTENT, &intent, 1);
368 is_valid_ = true;
369 } else {
370 is_valid_ = false;
371 }
372 }
373
374 } // namespace android::hardware::camera::device::V3_4::implementation
375