/* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_INFO_H #define EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_INFO_H #include #include #include #include #include #include #include "hal_camera_metadata.h" #include "hal_types.h" #include "utils/HWLUtils.h" namespace android { using google_camera_hal::HalCameraMetadata; using google_camera_hal::kTemplateCount; using google_camera_hal::RequestTemplate; template T GetClosestValue(T val, T min, T max) { if ((min > max) || ((val >= min) && (val <= max))) { return val; } else if (val > max) { return max; } else { return min; } } struct EmulatedCameraDeviceInfo { static std::unique_ptr Create( std::unique_ptr static_metadata); static std::unique_ptr Clone( const EmulatedCameraDeviceInfo& other); std::unique_ptr static_metadata_; std::unique_ptr default_requests_[kTemplateCount]; static const std::set kSupportedCapabilites; static const std::set kSupportedHWLevels; static const std::vector kSupportedUseCases; static const int32_t kMinimumStreamingFPS = 20; // android.blacklevel.* bool report_black_level_lock_ = false; uint8_t black_level_lock_ = ANDROID_BLACK_LEVEL_LOCK_ON; // android.colorcorrection.* std::set available_color_aberration_modes_; // android.edge.* std::set available_edge_modes_; bool report_edge_mode_ = false; // android.shading.* std::set available_shading_modes_; // android.noiseReduction.* std::set available_noise_reduction_modes_; uint8_t partial_result_count_ = 1; // android.request.* std::set available_capabilities_; std::set available_characteristics_; std::set available_results_; std::set available_requests_; uint8_t max_pipeline_depth_ = 0; bool supports_manual_sensor_ = false; bool supports_manual_post_processing_ = false; bool supports_remosaic_reprocessing_ = false; bool supports_private_reprocessing_ = false; bool supports_yuv_reprocessing_ = false; bool is_backward_compatible_ = false; bool is_raw_capable_ = false; bool supports_stream_use_case_ = false; // android.info.* bool is_level_full_or_higher_ = false; // Set to true if the camera device has HW level FULL or LEVEL3 uint8_t supported_hw_level_ = 0; // android.lens.* float minimum_focus_distance_ = 0.f; float aperture_ = 0.f; float focal_length_ = 0.f; float focus_distance_ = 0.f; bool report_focus_distance_ = false; uint8_t lens_state_ = ANDROID_LENS_STATE_STATIONARY; bool report_focus_range_ = false; float filter_density_ = 0.f; bool report_filter_density_ = false; std::set available_ois_modes_; uint8_t ois_mode_ = ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF; bool report_ois_mode_ = false; float pose_rotation_[4] = {.0f}; float pose_translation_[3] = {.0f}; float distortion_[5] = {.0f}; float intrinsic_calibration_[5] = {.0f}; bool report_pose_rotation_ = false; bool report_pose_translation_ = false; bool report_distortion_ = false; bool report_intrinsic_calibration_ = false; bool report_active_sensor_crop_ = false; bool report_lens_intrinsics_samples_ = false; int32_t shading_map_size_[2] = {0}; // android.control.* struct SceneOverride { uint8_t ae_mode, awb_mode, af_mode; SceneOverride() : ae_mode(ANDROID_CONTROL_AE_MODE_OFF), awb_mode(ANDROID_CONTROL_AWB_MODE_OFF), af_mode(ANDROID_CONTROL_AF_MODE_OFF) { } SceneOverride(uint8_t ae, uint8_t awb, uint8_t af) : ae_mode(ae), awb_mode(awb), af_mode(af) { } }; struct FPSRange { int32_t min_fps, max_fps; FPSRange() : min_fps(-1), max_fps(-1) { } FPSRange(int32_t min, int32_t max) : min_fps(min), max_fps(max) { } }; struct ExtendedSceneModeCapability { int32_t mode, max_width, max_height; float min_zoom, max_zoom; ExtendedSceneModeCapability() : mode(ANDROID_CONTROL_EXTENDED_SCENE_MODE_DISABLED), max_width(-1), max_height(-1), min_zoom(1.0f), max_zoom(1.0f) { } ExtendedSceneModeCapability(int32_t m, int32_t w, int32_t h, float min_z, float max_z) : mode(m), max_width(w), max_height(h), min_zoom(min_z), max_zoom(max_z) { } }; std::set available_control_modes_; std::set available_ae_modes_; std::set available_af_modes_; std::set available_awb_modes_; std::set available_scenes_; std::set available_antibanding_modes_; std::set available_effects_; std::set available_vstab_modes_; std::set available_sensor_pixel_modes_; std::vector available_extended_scene_mode_caps_; std::unordered_map scene_overrides_; std::vector available_fps_ranges_; int32_t exposure_compensation_range_[2] = {0, 0}; float max_zoom_ = 1.0f; bool zoom_ratio_supported_ = false; float min_zoom_ = 1.0f; camera_metadata_rational exposure_compensation_step_ = {0, 1}; bool exposure_compensation_supported_ = false; int32_t exposure_compensation_ = 0; int32_t ae_metering_region_[5] = {0, 0, 0, 0, 0}; int32_t awb_metering_region_[5] = {0, 0, 0, 0, 0}; int32_t af_metering_region_[5] = {0, 0, 0, 0, 0}; size_t max_ae_regions_ = 0; size_t max_awb_regions_ = 0; size_t max_af_regions_ = 0; uint8_t control_mode_ = ANDROID_CONTROL_MODE_AUTO; uint8_t sensor_pixel_mode_ = ANDROID_SENSOR_PIXEL_MODE_DEFAULT; uint8_t scene_mode_ = ANDROID_CONTROL_SCENE_MODE_DISABLED; uint8_t ae_mode_ = ANDROID_CONTROL_AE_MODE_ON; uint8_t awb_mode_ = ANDROID_CONTROL_AWB_MODE_AUTO; uint8_t af_mode_ = ANDROID_CONTROL_AF_MODE_AUTO; uint8_t ae_lock_ = ANDROID_CONTROL_AE_LOCK_OFF; uint8_t ae_state_ = ANDROID_CONTROL_AE_STATE_INACTIVE; uint8_t awb_state_ = ANDROID_CONTROL_AWB_STATE_INACTIVE; uint8_t awb_lock_ = ANDROID_CONTROL_AWB_LOCK_OFF; uint8_t af_state_ = ANDROID_CONTROL_AF_STATE_INACTIVE; uint8_t af_trigger_ = ANDROID_CONTROL_AF_TRIGGER_IDLE; uint8_t ae_trigger_ = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; uint8_t autoframing_ = ANDROID_CONTROL_AUTOFRAMING_OFF; FPSRange ae_target_fps_ = {0, 0}; float zoom_ratio_ = 1.0f; uint8_t extended_scene_mode_ = ANDROID_CONTROL_EXTENDED_SCENE_MODE_DISABLED; bool ae_lock_available_ = false; bool report_ae_lock_ = false; bool scenes_supported_ = false; bool vstab_available_ = false; int32_t post_raw_boost_ = 100; bool report_post_raw_boost_ = false; bool awb_lock_available_ = false; bool report_awb_lock_ = false; bool af_supported_ = false; bool picture_caf_supported_ = false; bool video_caf_supported_ = false; int32_t settings_override_ = ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF; // android.flash.* bool is_flash_supported_ = false; uint8_t flash_state_ = ANDROID_FLASH_STATE_UNAVAILABLE; int32_t flash_strength_level_ = 1; // android.hotpixel.* std::set available_hot_pixel_modes_; // android.scaler.* bool report_rotate_and_crop_ = false; uint8_t rotate_and_crop_ = ANDROID_SCALER_ROTATE_AND_CROP_NONE; int32_t scaler_crop_region_default_[4] = {0, 0, 0, 0}; int32_t scaler_crop_region_max_resolution_[4] = {0, 0, 0, 0}; std::set available_rotate_crop_modes_; // android.sensor.* std::pair sensor_sensitivity_range_; std::pair sensor_exposure_time_range_; nsecs_t sensor_max_frame_duration_ = EmulatedSensor::kSupportedFrameDurationRange[1]; nsecs_t sensor_exposure_time_ = EmulatedSensor::kDefaultExposureTime; nsecs_t sensor_frame_duration_ = EmulatedSensor::kDefaultFrameDuration; int32_t sensor_sensitivity_ = EmulatedSensor::kDefaultSensitivity; bool report_frame_duration_ = false; bool report_sensitivity_ = false; bool report_exposure_time_ = false; std::set available_test_pattern_modes_; bool report_rolling_shutter_skew_ = false; bool report_neutral_color_point_ = false; bool report_green_split_ = false; bool report_noise_profile_ = false; bool report_extended_scene_mode_ = false; uint32_t timestamp_source_ = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; // android.statistics.* uint8_t current_scene_flicker_ = ANDROID_STATISTICS_SCENE_FLICKER_NONE; std::set available_hot_pixel_map_modes_; std::set available_lens_shading_map_modes_; std::set available_face_detect_modes_; bool report_scene_flicker_ = false; // android.tonemap.* std::set available_tonemap_modes_; private: status_t Initialize(unique_ptr staticMetadata) { static_metadata_ = std::move(staticMetadata); return InitializeRequestDefaults(); } status_t InitializeRequestDefaults(); status_t InitializeSensorDefaults(); status_t InitializeFlashDefaults(); status_t InitializeControlDefaults(); status_t InitializeControlAEDefaults(); status_t InitializeControlAWBDefaults(); status_t InitializeControlAFDefaults(); status_t InitializeControlSceneDefaults(); status_t InitializeHotPixelDefaults(); status_t InitializeStatisticsDefaults(); status_t InitializeTonemapDefaults(); status_t InitializeBlackLevelDefaults(); status_t InitializeEdgeDefaults(); status_t InitializeShadingDefaults(); status_t InitializeNoiseReductionDefaults(); status_t InitializeColorCorrectionDefaults(); status_t InitializeScalerDefaults(); status_t InitializeReprocessDefaults(); status_t InitializeMeteringRegionDefault(uint32_t tag, int32_t* region /*out*/); status_t InitializeControlefaults(); status_t InitializeInfoDefaults(); status_t InitializeLensDefaults(); bool SupportsCapability(uint8_t cap); }; } // namespace android #endif // EMULATOR_CAMERA_HAL_HWL_CAMERA_DEVICE_INFO_H