summaryrefslogtreecommitdiff
path: root/devices
diff options
context:
space:
mode:
authorEmilian Peev <epeev@google.com>2020-01-31 13:21:50 -0800
committerEmilian Peev <epeev@google.com>2020-01-31 13:38:29 -0800
commitf5c8203f876e66d9a5ad152d6dd58f31b8392452 (patch)
tree83653f357da23a473680311eeb3b11e461599731 /devices
parentec839a4a2cc2388c891b70475e6babbe63a41d75 (diff)
downloadcamera-f5c8203f876e66d9a5ad152d6dd58f31b8392452.tar.gz
EmulatedCamera: Add minimal support for rotate and crop on front camera
Enable minimal rotate and crop result reporting for the front camera. Bug: 148666803 Test: Camera CTS Change-Id: Ic28d80ab4506e85f16d3153de3d966ffafb43079
Diffstat (limited to 'devices')
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedRequestState.cpp22
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedRequestState.h4
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedSensor.cpp13
-rw-r--r--devices/EmulatedCamera/hwl/EmulatedSensor.h3
-rw-r--r--devices/EmulatedCamera/hwl/configs/emu_camera_front.json44
5 files changed, 58 insertions, 28 deletions
diff --git a/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp b/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
index cfb1e6c..987fc4c 100644
--- a/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedRequestState.cpp
@@ -660,11 +660,14 @@ status_t EmulatedRequestState::InitializeSensorSettings(
}
// Check rotate_and_crop setting
- rotate_and_crop_ = false;
ret = request_settings_->Get(ANDROID_SCALER_ROTATE_AND_CROP, &entry);
if ((ret == OK) && (entry.count == 1)) {
- if (entry.data.u8[0] == ANDROID_SCALER_ROTATE_AND_CROP_90) {
- rotate_and_crop_ = true;
+ if (available_rotate_crop_modes_.find(entry.data.u8[0]) !=
+ available_rotate_crop_modes_.end()) {
+ rotate_and_crop_ = entry.data.u8[0];
+ } else {
+ ALOGE("%s: Unsupported rotate and crop mode: %u", __FUNCTION__, entry.data.u8[0]);
+ return BAD_VALUE;
}
}
@@ -750,6 +753,7 @@ status_t EmulatedRequestState::InitializeSensorSettings(
sensor_settings->report_green_split = report_green_split_;
sensor_settings->report_noise_profile = report_noise_profile_;
sensor_settings->zoom_ratio = zoom_ratio_;
+ sensor_settings->report_rotate_and_crop = report_rotate_and_crop_;
sensor_settings->rotate_and_crop = rotate_and_crop_;
return OK;
@@ -2179,8 +2183,6 @@ status_t EmulatedRequestState::InitializeScalerDefaults() {
__FUNCTION__);
return BAD_VALUE;
}
- bool set_rotate_and_crop = false;
- uint8_t rotate_and_crop_value = ANDROID_SCALER_ROTATE_AND_CROP_NONE;
ret = static_metadata_->Get(ANDROID_SCALER_AVAILABLE_ROTATE_AND_CROP_MODES,
&entry);
if ((ret == OK) && (entry.count > 0)) {
@@ -2207,12 +2209,12 @@ status_t EmulatedRequestState::InitializeScalerDefaults() {
__FUNCTION__);
return BAD_VALUE;
}
- set_rotate_and_crop = true;
+ report_rotate_and_crop_ = true;
for (size_t i = 0; i < entry.count; i++) {
if (entry.data.u8[i] == ANDROID_SCALER_ROTATE_AND_CROP_AUTO) {
- rotate_and_crop_value = ANDROID_SCALER_ROTATE_AND_CROP_AUTO;
- break;
+ rotate_and_crop_ = ANDROID_SCALER_ROTATE_AND_CROP_AUTO;
}
+ available_rotate_crop_modes_.insert(entry.data.u8[i]);
}
}
@@ -2224,9 +2226,9 @@ status_t EmulatedRequestState::InitializeScalerDefaults() {
default_requests_[idx]->Set(ANDROID_SCALER_CROP_REGION,
scaler_crop_region_default_,
ARRAY_SIZE(scaler_crop_region_default_));
- if (set_rotate_and_crop) {
+ if (report_rotate_and_crop_) {
default_requests_[idx]->Set(ANDROID_SCALER_ROTATE_AND_CROP,
- &rotate_and_crop_value, 1);
+ &rotate_and_crop_, 1);
}
}
}
diff --git a/devices/EmulatedCamera/hwl/EmulatedRequestState.h b/devices/EmulatedCamera/hwl/EmulatedRequestState.h
index bd71f28..515f35c 100644
--- a/devices/EmulatedCamera/hwl/EmulatedRequestState.h
+++ b/devices/EmulatedCamera/hwl/EmulatedRequestState.h
@@ -202,7 +202,6 @@ class EmulatedRequestState {
uint8_t ae_trigger_ = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
FPSRange ae_target_fps_ = {0, 0};
float zoom_ratio_ = 1.0f;
- bool rotate_and_crop_ = false;
uint8_t bokeh_mode_ = ANDROID_CONTROL_BOKEH_MODE_OFF;
static const int32_t kMinimumStreamingFPS = 20;
bool ae_lock_available_ = false;
@@ -255,7 +254,10 @@ class EmulatedRequestState {
bool report_bokeh_mode_ = false;
// 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};
+ std::set<uint8_t> available_rotate_crop_modes_;
// android.statistics.*
std::set<uint8_t> available_hot_pixel_map_modes_;
diff --git a/devices/EmulatedCamera/hwl/EmulatedSensor.cpp b/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
index 84577bb..f33db06 100644
--- a/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
+++ b/devices/EmulatedCamera/hwl/EmulatedSensor.cpp
@@ -634,10 +634,12 @@ bool EmulatedSensor::threadLoop() {
.height = jpeg_input->height,
.planes = jpeg_input->yuv_planes};
+ bool rotate =
+ device_settings->second.rotate_and_crop == ANDROID_SCALER_ROTATE_AND_CROP_90;
auto ret = ProcessYUV420(
yuv_input, yuv_output, device_settings->second.gain,
reprocess_request, device_settings->second.zoom_ratio,
- device_settings->second.rotate_and_crop, device_chars->second);
+ rotate, device_chars->second);
if (ret != 0) {
(*b)->stream_buffer.status = BufferStatus::kError;
break;
@@ -675,10 +677,12 @@ bool EmulatedSensor::threadLoop() {
YUV420Frame yuv_output{.width = (*b)->width,
.height = (*b)->height,
.planes = (*b)->plane.img_y_crcb};
+ bool rotate =
+ device_settings->second.rotate_and_crop == ANDROID_SCALER_ROTATE_AND_CROP_90;
auto ret = ProcessYUV420(
yuv_input, yuv_output, device_settings->second.gain,
reprocess_request, device_settings->second.zoom_ratio,
- device_settings->second.rotate_and_crop, device_chars->second);
+ rotate, device_chars->second);
if (ret != 0) {
(*b)->stream_buffer.status = BufferStatus::kError;
}
@@ -801,13 +805,16 @@ void EmulatedSensor::ReturnResults(
if (logical_settings->second.report_green_split) {
result->result_metadata->Set(ANDROID_SENSOR_GREEN_SPLIT, &kGreenSplit, 1);
}
-
if (logical_settings->second.report_noise_profile) {
CalculateAndAppendNoiseProfile(
logical_settings->second.gain,
GetBaseGainFactor(device_chars->second.max_raw_value),
result->result_metadata.get());
}
+ if (logical_settings->second.report_rotate_and_crop) {
+ result->result_metadata->Set(ANDROID_SCALER_ROTATE_AND_CROP,
+ &logical_settings->second.rotate_and_crop, 1);
+ }
if (!result->physical_camera_results.empty()) {
for (auto& it : result->physical_camera_results) {
diff --git a/devices/EmulatedCamera/hwl/EmulatedSensor.h b/devices/EmulatedCamera/hwl/EmulatedSensor.h
index 9aca7b4..abdd4a0 100644
--- a/devices/EmulatedCamera/hwl/EmulatedSensor.h
+++ b/devices/EmulatedCamera/hwl/EmulatedSensor.h
@@ -187,7 +187,8 @@ class EmulatedSensor : private Thread, public virtual RefBase {
bool report_green_split = false;
bool report_noise_profile = false;
float zoom_ratio = 1.0f;
- bool rotate_and_crop = false;
+ bool report_rotate_and_crop = false;
+ uint8_t rotate_and_crop = ANDROID_SCALER_ROTATE_AND_CROP_NONE;
};
// Maps physical and logical camera ids to individual device settings
diff --git a/devices/EmulatedCamera/hwl/configs/emu_camera_front.json b/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
index 40812c5..d6ddfe3 100644
--- a/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
+++ b/devices/EmulatedCamera/hwl/configs/emu_camera_front.json
@@ -397,7 +397,8 @@
"524301",
"524295",
"524294",
- "524298"
+ "524298",
+ "851984"
],
"android.request.availableRequestKeys": [
"0",
@@ -456,7 +457,8 @@
"1245185",
"1245186",
"1245187",
- "1441792"
+ "1441792",
+ "851985"
],
"android.request.availableResultKeys": [
"0",
@@ -524,13 +526,14 @@
"1245186",
"1245187",
"1441792",
- "65541",
- "65542",
- "65545",
- "65552",
+ "65541",
+ "65542",
+ "65545",
+ "65552",
"1114123",
"1703938",
- "917530"
+ "917530",
+ "851985"
],
"android.request.maxNumInputStreams": [
"0"
@@ -540,6 +543,9 @@
"3",
"2"
],
+ "android.scaler.availableRotateAndCropModes": [
+ "0"
+ ],
"android.request.partialResultCount": [
"1"
],
@@ -1586,7 +1592,8 @@
"524301",
"524295",
"524294",
- "524298"
+ "524298",
+ "851984"
],
"android.request.availableRequestKeys": [
"0",
@@ -1645,7 +1652,8 @@
"1245185",
"1245186",
"1245187",
- "1441792"
+ "1441792",
+ "851985"
],
"android.request.availableResultKeys": [
"0",
@@ -1718,7 +1726,8 @@
"65545",
"65552",
"1114123",
- "917530"
+ "917530",
+ "851985"
],
"android.request.maxNumInputStreams": [
"0"
@@ -1728,6 +1737,9 @@
"3",
"2"
],
+ "android.scaler.availableRotateAndCropModes": [
+ "0"
+ ],
"android.request.partialResultCount": [
"1"
],
@@ -2779,7 +2791,8 @@
"524301",
"524295",
"524294",
- "524298"
+ "524298",
+ "851984"
],
"android.request.availableRequestKeys": [
"0",
@@ -2838,7 +2851,8 @@
"1245185",
"1245186",
"1245187",
- "1441792"
+ "1441792",
+ "851985"
],
"android.request.availableResultKeys": [
"0",
@@ -2911,7 +2925,8 @@
"65545",
"65552",
"1114123",
- "917530"
+ "917530",
+ "851985"
],
"android.request.maxNumInputStreams": [
"0"
@@ -2921,6 +2936,9 @@
"3",
"2"
],
+ "android.scaler.availableRotateAndCropModes": [
+ "0"
+ ],
"android.request.partialResultCount": [
"1"
],