summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
authorShuzhen Wang <shuzhenwang@google.com>2019-10-28 15:56:42 -0700
committerShuzhen Wang <shuzhenwang@google.com>2019-10-30 16:05:06 -0700
commitf2f502621b60dbcb72114ffeebc7d01c8d9a6b2f (patch)
treede42f2df504429b072e53f95d9e92f5dfbf1a072 /devices
parent6b582c48914b1f491a9cafaf2e325e881061e03b (diff)
downloadcamera-f2f502621b60dbcb72114ffeebc7d01c8d9a6b2f.tar.gz
EmulatedCamera: Add basic Bokeh support
Add basic bokeh support for back and front cameras. Currently only hook up static metadata as well as request/result handling. No bokeh effect is generated. Test: Camera CTS, CtsVerifier Bug: 118258123 Change-Id: Ie05c72a666ce69417c03b4d7c8f3ec90c5f6566d
Diffstat (limited to 'devices')
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedRequestState.cpp65
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedRequestState.h13
-rw-r--r--devices/EmulatedCamera/hwl/configs/emu_camera_back.json11
-rw-r--r--devices/EmulatedCamera/hwl/configs/emu_camera_front.json42
4 files changed, 131 insertions, 0 deletions
diff --git a/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp b/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
index febdfb5..a2929fe 100644
--- a/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
@@ -631,6 +631,25 @@ status_t EmulatedRequestState::InitializeSensorSettings(
}
}
+ ret = request_settings_->Get(ANDROID_CONTROL_BOKEH_MODE, &entry);
+ if ((ret == OK) && (entry.count == 1)) {
+ bool bokeh_mode_valid = false;
+ for (const auto& bokeh_cap : available_bokeh_caps_) {
+ if (bokeh_cap.mode == entry.data.u8[0]) {
+ bokeh_mode_ = entry.data.u8[0];
+ bokeh_mode_valid = true;
+ break;
+ }
+ }
+ if (!bokeh_mode_valid) {
+ ALOGE("%s: Unsupported bokeh mode %d!", __FUNCTION__, entry.data.u8[0]);
+ return BAD_VALUE;
+ }
+ if (bokeh_mode_ != ANDROID_CONTROL_BOKEH_MODE_OFF) {
+ scene_mode_ = ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY;
+ }
+ }
+
// 3A modes are active in case the scene is disabled or set to face priority
// or the control mode is not using scenes
if ((scene_mode_ == ANDROID_CONTROL_SCENE_MODE_DISABLED) ||
@@ -844,6 +863,9 @@ std::unique_ptr<HwlPipelineResult> EmulatedRequestState::InitializeResult(
result->result_metadata->Set(ANDROID_STATISTICS_SCENE_FLICKER,
&current_scene_flicker_, 1);
}
+ if (report_bokeh_mode_) {
+ result->result_metadata->Set(ANDROID_CONTROL_BOKEH_MODE, &bokeh_mode_, 1);
+ }
return result;
}
@@ -1542,6 +1564,9 @@ status_t EmulatedRequestState::InitializeControlDefaults() {
return BAD_VALUE;
}
+ report_bokeh_mode_ = available_results_.find(ANDROID_CONTROL_BOKEH_MODE) !=
+ available_results_.end();
+
if (is_backward_compatible_) {
ret = static_metadata_->Get(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST,
&entry);
@@ -1583,6 +1608,46 @@ status_t EmulatedRequestState::InitializeControlDefaults() {
return BAD_VALUE;
}
+ ret = static_metadata_->Get(ANDROID_CONTROL_AVAILABLE_BOKEH_CAPABILITIES,
+ &entry);
+ if ((ret == OK) && (entry.count > 0)) {
+ if (entry.count % 3 != 0) {
+ ALOGE("%s: Invalid bokeh capabilities!", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ StreamConfigurationMap stream_configuration_map(*static_metadata_);
+ std::set<StreamSize> yuv_sizes = stream_configuration_map.GetOutputSizes(
+ HAL_PIXEL_FORMAT_YCBCR_420_888);
+ bool hasBokehOff = false;
+ for (size_t i = 0; i < entry.count; i += 3) {
+ BokehCapability bokeh(entry.data.i32[i], entry.data.i32[i + 1],
+ entry.data.i32[i + 2]);
+ if (bokeh.mode < ANDROID_CONTROL_BOKEH_MODE_OFF ||
+ bokeh.mode > ANDROID_CONTROL_BOKEH_MODE_CONTINUOUS) {
+ ALOGE("%s: Invalid bokeh mode %d", __FUNCTION__, bokeh.mode);
+ return BAD_VALUE;
+ }
+ if (bokeh.mode == ANDROID_CONTROL_BOKEH_MODE_OFF) {
+ hasBokehOff = true;
+ if (bokeh.max_width != 0 || bokeh.max_height != 0) {
+ ALOGE("%s: Invalid max width or height for BOKEH_MODE_OFF",
+ __FUNCTION__);
+ return BAD_VALUE;
+ }
+ } else if (yuv_sizes.find({bokeh.max_width, bokeh.max_height}) ==
+ yuv_sizes.end()) {
+ ALOGE("%s: Invalid max width or height for bokeh mode %d",
+ __FUNCTION__, bokeh.mode);
+ return BAD_VALUE;
+ }
+ available_bokeh_caps_.push_back(bokeh);
+ }
+ if (!hasBokehOff) {
+ ALOGE("%s: Off bokeh mode not supported!", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ }
+
ret = static_metadata_->Get(ANDROID_CONTROL_MAX_REGIONS, &entry);
if ((ret == OK) && (entry.count == 3)) {
max_ae_regions_ = entry.data.i32[0];
diff --git a/devices/EmulatedCamera/hwl/EmulatedRequestState.h b/devices/EmulatedCamera/hwl/EmulatedRequestState.h
index f2503c8..590da70 100644
--- a/devices/EmulatedCamera/hwl/EmulatedRequestState.h
+++ b/devices/EmulatedCamera/hwl/EmulatedRequestState.h
@@ -149,6 +149,16 @@ class EmulatedRequestState {
}
};
+ struct BokehCapability {
+ int32_t mode, max_width, max_height;
+ BokehCapability()
+ : mode(ANDROID_CONTROL_BOKEH_MODE_OFF), max_width(-1), max_height(-1) {
+ }
+ BokehCapability(int32_t m, int32_t w, int32_t h)
+ : mode(m), max_width(w), max_height(h) {
+ }
+ };
+
std::set<uint8_t> available_control_modes_;
std::set<uint8_t> available_ae_modes_;
std::set<uint8_t> available_af_modes_;
@@ -157,6 +167,7 @@ class EmulatedRequestState {
std::set<uint8_t> available_antibanding_modes_;
std::set<uint8_t> available_effects_;
std::set<uint8_t> available_vstab_modes_;
+ std::vector<BokehCapability> available_bokeh_caps_;
std::unordered_map<uint8_t, SceneOverride> scene_overrides_;
std::vector<FPSRange> available_fps_ranges_;
int32_t exposure_compensation_range_[2] = {0, 0};
@@ -182,6 +193,7 @@ class EmulatedRequestState {
uint8_t af_trigger_ = ANDROID_CONTROL_AF_TRIGGER_IDLE;
uint8_t ae_trigger_ = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
FPSRange ae_target_fps_ = {0, 0};
+ uint8_t bokeh_mode_ = ANDROID_CONTROL_BOKEH_MODE_OFF;
static const int32_t kMinimumStreamingFPS = 20;
bool ae_lock_available_ = false;
bool report_ae_lock_ = false;
@@ -230,6 +242,7 @@ class EmulatedRequestState {
bool report_neutral_color_point_ = false;
bool report_green_split_ = false;
bool report_noise_profile_ = false;
+ bool report_bokeh_mode_ = false;
// android.scaler.*
int32_t scaler_crop_region_default_[4] = {0, 0, 0, 0};
diff --git a/devices/EmulatedCamera/hwl/configs/emu_camera_back.json b/devices/EmulatedCamera/hwl/configs/emu_camera_back.json
index 0bdb7ad..b321c74 100644
--- a/devices/EmulatedCamera/hwl/configs/emu_camera_back.json
+++ b/devices/EmulatedCamera/hwl/configs/emu_camera_back.json
@@ -42,6 +42,14 @@
"3",
"4"
],
+ "android.control.availableBokehCapabilities": [
+ "0",
+ "0",
+ "0",
+ "1",
+ "1856",
+ "1392"
+ ],
"android.control.availableEffects": [
"0"
],
@@ -240,6 +248,7 @@
"786446",
"786447",
"65575",
+ "65579",
"983050",
"393217",
"1572865",
@@ -311,6 +320,7 @@
"3",
"917528",
"65576",
+ "65580",
"-2080374783",
"-2080374782",
"-2080374780"
@@ -386,6 +396,7 @@
"917520",
"917522",
"65576",
+ "65580",
"917523",
"917526",
"-2080374783",
diff --git a/devices/EmulatedCamera/hwl/configs/emu_camera_front.json b/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
index 49a661a..bc8d344 100644
--- a/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
+++ b/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
@@ -46,6 +46,17 @@
"3",
"4"
],
+ "android.control.availableBokehCapabilities": [
+ "0",
+ "0",
+ "0",
+ "1",
+ "1920",
+ "1080",
+ "2",
+ "1920",
+ "1440"
+ ],
"android.control.availableEffects": [
"0"
],
@@ -293,6 +304,7 @@
"65573",
"65574",
"65575",
+ "65579",
"1638402",
"1638401",
"1638403",
@@ -399,6 +411,7 @@
"65552",
"65553",
"65576",
+ "65580",
"1769472",
"196608",
"262146",
@@ -448,6 +461,7 @@
"65570",
"65551",
"65576",
+ "65580",
"196608",
"262146",
"262149",
@@ -1227,6 +1241,17 @@
"3",
"4"
],
+ "android.control.availableBokehCapabilities": [
+ "0",
+ "0",
+ "0",
+ "1",
+ "1920",
+ "1080",
+ "2",
+ "1920",
+ "1440"
+ ],
"android.control.availableEffects": [
"0"
],
@@ -1464,6 +1489,7 @@
"65573",
"65574",
"65575",
+ "65579",
"1638402",
"1638401",
"1638403",
@@ -1570,6 +1596,7 @@
"65552",
"65553",
"65576",
+ "65580",
"1769472",
"196608",
"262146",
@@ -1619,6 +1646,7 @@
"65570",
"65551",
"65576",
+ "65580",
"196608",
"262146",
"262149",
@@ -2401,6 +2429,17 @@
"3",
"4"
],
+ "android.control.availableBokehCapabilities": [
+ "0",
+ "0",
+ "0",
+ "1",
+ "1920",
+ "1080",
+ "2",
+ "1920",
+ "1440"
+ ],
"android.control.availableEffects": [
"0"
],
@@ -2639,6 +2678,7 @@
"65573",
"65574",
"65575",
+ "65579",
"1638402",
"1638401",
"1638403",
@@ -2745,6 +2785,7 @@
"65552",
"65553",
"65576",
+ "65580",
"1769472",
"196608",
"262146",
@@ -2794,6 +2835,7 @@
"65570",
"65551",
"65576",
+ "65580",
"196608",
"262146",
"262149",