|
|
|
@ -41,23 +41,29 @@ Parameters::Parameters(int cameraId,
|
|
|
|
|
int cameraFacing) :
|
|
|
|
|
cameraId(cameraId),
|
|
|
|
|
cameraFacing(cameraFacing),
|
|
|
|
|
info(NULL) {
|
|
|
|
|
info(NULL),
|
|
|
|
|
mDefaultSceneMode(ANDROID_CONTROL_SCENE_MODE_DISABLED) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Parameters::~Parameters() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
|
|
|
|
|
status_t Parameters::initialize(CameraDeviceBase *device, int deviceVersion) {
|
|
|
|
|
status_t res;
|
|
|
|
|
if (device == nullptr) {
|
|
|
|
|
ALOGE("%s: device is null!", __FUNCTION__);
|
|
|
|
|
return BAD_VALUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info->entryCount() == 0) {
|
|
|
|
|
const CameraMetadata& info = device->info();
|
|
|
|
|
if (info.entryCount() == 0) {
|
|
|
|
|
ALOGE("%s: No static information provided!", __FUNCTION__);
|
|
|
|
|
return BAD_VALUE;
|
|
|
|
|
}
|
|
|
|
|
Parameters::info = info;
|
|
|
|
|
Parameters::info = &info;
|
|
|
|
|
mDeviceVersion = deviceVersion;
|
|
|
|
|
|
|
|
|
|
res = buildFastInfo();
|
|
|
|
|
res = buildFastInfo(device);
|
|
|
|
|
if (res != OK) return res;
|
|
|
|
|
|
|
|
|
|
res = buildQuirks();
|
|
|
|
@ -557,6 +563,10 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
|
|
|
|
|
noSceneModes = true;
|
|
|
|
|
break;
|
|
|
|
|
case ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY:
|
|
|
|
|
// Face priority can be used as alternate default if supported.
|
|
|
|
|
// Per API contract it shouldn't override the user set flash,
|
|
|
|
|
// white balance and focus modes.
|
|
|
|
|
mDefaultSceneMode = availableSceneModes.data.u8[i];
|
|
|
|
|
// Not in old API
|
|
|
|
|
addComma = false;
|
|
|
|
|
break;
|
|
|
|
@ -761,17 +771,7 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
|
|
|
|
|
focusingAreas.clear();
|
|
|
|
|
focusingAreas.add(Parameters::Area(0,0,0,0,0));
|
|
|
|
|
|
|
|
|
|
if (fastInfo.isExternalCamera) {
|
|
|
|
|
params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, -1.0);
|
|
|
|
|
} else {
|
|
|
|
|
camera_metadata_ro_entry_t availableFocalLengths =
|
|
|
|
|
staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, false);
|
|
|
|
|
if (!availableFocalLengths.count) return NO_INIT;
|
|
|
|
|
|
|
|
|
|
float minFocalLength = availableFocalLengths.data.f[0];
|
|
|
|
|
params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, minFocalLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, fastInfo.defaultFocalLength);
|
|
|
|
|
|
|
|
|
|
float horizFov, vertFov;
|
|
|
|
|
res = calculatePictureFovs(&horizFov, &vertFov);
|
|
|
|
@ -993,7 +993,7 @@ String8 Parameters::get() const {
|
|
|
|
|
return paramsFlattened;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t Parameters::buildFastInfo() {
|
|
|
|
|
status_t Parameters::buildFastInfo(CameraDeviceBase *device) {
|
|
|
|
|
|
|
|
|
|
camera_metadata_ro_entry_t activeArraySize =
|
|
|
|
|
staticInfo(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, 2, 4);
|
|
|
|
@ -1109,20 +1109,12 @@ status_t Parameters::buildFastInfo() {
|
|
|
|
|
focusDistanceCalibration.data.u8[0] !=
|
|
|
|
|
ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
camera_metadata_ro_entry_t hwLevel = staticInfo(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL);
|
|
|
|
|
if (!hwLevel.count) return NO_INIT;
|
|
|
|
|
fastInfo.isExternalCamera =
|
|
|
|
|
hwLevel.data.u8[0] == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL;
|
|
|
|
|
|
|
|
|
|
camera_metadata_ro_entry_t availableFocalLengths =
|
|
|
|
|
staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, /*required*/false);
|
|
|
|
|
if (!availableFocalLengths.count && !fastInfo.isExternalCamera) return NO_INIT;
|
|
|
|
|
res = getDefaultFocalLength(device);
|
|
|
|
|
if (res != OK) return res;
|
|
|
|
|
|
|
|
|
|
SortedVector<int32_t> availableFormats = getAvailableOutputFormats();
|
|
|
|
|
if (!availableFormats.size()) return NO_INIT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sceneModeOverrides.count > 0) {
|
|
|
|
|
// sceneModeOverrides is defined to have 3 entries for each scene mode,
|
|
|
|
|
// which are AE, AWB, and AF override modes the HAL wants for that scene
|
|
|
|
@ -1200,19 +1192,6 @@ status_t Parameters::buildFastInfo() {
|
|
|
|
|
fastInfo.bestFaceDetectMode = bestFaceDetectMode;
|
|
|
|
|
fastInfo.maxFaces = maxFaces;
|
|
|
|
|
|
|
|
|
|
// Find smallest (widest-angle) focal length to use as basis of still
|
|
|
|
|
// picture FOV reporting.
|
|
|
|
|
if (fastInfo.isExternalCamera) {
|
|
|
|
|
fastInfo.minFocalLength = -1.0;
|
|
|
|
|
} else {
|
|
|
|
|
fastInfo.minFocalLength = availableFocalLengths.data.f[0];
|
|
|
|
|
for (size_t i = 1; i < availableFocalLengths.count; i++) {
|
|
|
|
|
if (fastInfo.minFocalLength > availableFocalLengths.data.f[i]) {
|
|
|
|
|
fastInfo.minFocalLength = availableFocalLengths.data.f[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the HAL supports HAL_PIXEL_FORMAT_YCbCr_420_888
|
|
|
|
|
fastInfo.useFlexibleYuv = false;
|
|
|
|
|
for (size_t i = 0; i < availableFormats.size(); i++) {
|
|
|
|
@ -1760,7 +1739,7 @@ status_t Parameters::set(const String8& paramString) {
|
|
|
|
|
|
|
|
|
|
// SCENE_MODE
|
|
|
|
|
validatedParams.sceneMode = sceneModeStringToEnum(
|
|
|
|
|
newParams.get(CameraParameters::KEY_SCENE_MODE) );
|
|
|
|
|
newParams.get(CameraParameters::KEY_SCENE_MODE), mDefaultSceneMode);
|
|
|
|
|
if (validatedParams.sceneMode != sceneMode &&
|
|
|
|
|
validatedParams.sceneMode !=
|
|
|
|
|
ANDROID_CONTROL_SCENE_MODE_DISABLED) {
|
|
|
|
@ -1778,7 +1757,7 @@ status_t Parameters::set(const String8& paramString) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool sceneModeSet =
|
|
|
|
|
validatedParams.sceneMode != ANDROID_CONTROL_SCENE_MODE_DISABLED;
|
|
|
|
|
validatedParams.sceneMode != mDefaultSceneMode;
|
|
|
|
|
|
|
|
|
|
// FLASH_MODE
|
|
|
|
|
if (sceneModeSet) {
|
|
|
|
@ -2157,7 +2136,7 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
|
|
|
|
|
uint8_t reqSceneMode =
|
|
|
|
|
sceneModeActive ? sceneMode :
|
|
|
|
|
enableFaceDetect ? (uint8_t)ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY :
|
|
|
|
|
(uint8_t)ANDROID_CONTROL_SCENE_MODE_DISABLED;
|
|
|
|
|
mDefaultSceneMode;
|
|
|
|
|
res = request->update(ANDROID_CONTROL_SCENE_MODE,
|
|
|
|
|
&reqSceneMode, 1);
|
|
|
|
|
if (res != OK) return res;
|
|
|
|
@ -2446,6 +2425,50 @@ bool Parameters::useZeroShutterLag() const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t Parameters::getDefaultFocalLength(CameraDeviceBase *device) {
|
|
|
|
|
if (device == nullptr) {
|
|
|
|
|
ALOGE("%s: Camera device is nullptr", __FUNCTION__);
|
|
|
|
|
return BAD_VALUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
camera_metadata_ro_entry_t hwLevel = staticInfo(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL);
|
|
|
|
|
if (!hwLevel.count) return NO_INIT;
|
|
|
|
|
fastInfo.isExternalCamera =
|
|
|
|
|
hwLevel.data.u8[0] == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL;
|
|
|
|
|
|
|
|
|
|
camera_metadata_ro_entry_t availableFocalLengths =
|
|
|
|
|
staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, /*required*/false);
|
|
|
|
|
if (!availableFocalLengths.count && !fastInfo.isExternalCamera) return NO_INIT;
|
|
|
|
|
|
|
|
|
|
// Find focal length in PREVIEW template to use as default focal length.
|
|
|
|
|
if (fastInfo.isExternalCamera) {
|
|
|
|
|
fastInfo.defaultFocalLength = -1.0;
|
|
|
|
|
} else {
|
|
|
|
|
// Find smallest (widest-angle) focal length to use as basis of still
|
|
|
|
|
// picture FOV reporting.
|
|
|
|
|
fastInfo.defaultFocalLength = availableFocalLengths.data.f[0];
|
|
|
|
|
for (size_t i = 1; i < availableFocalLengths.count; i++) {
|
|
|
|
|
if (fastInfo.defaultFocalLength > availableFocalLengths.data.f[i]) {
|
|
|
|
|
fastInfo.defaultFocalLength = availableFocalLengths.data.f[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use focal length in preview template if it exists
|
|
|
|
|
CameraMetadata previewTemplate;
|
|
|
|
|
status_t res = device->createDefaultRequest(CAMERA3_TEMPLATE_PREVIEW, &previewTemplate);
|
|
|
|
|
if (res != OK) {
|
|
|
|
|
ALOGE("%s: Failed to create default PREVIEW request: %s (%d)",
|
|
|
|
|
__FUNCTION__, strerror(-res), res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
camera_metadata_entry entry = previewTemplate.find(ANDROID_LENS_FOCAL_LENGTH);
|
|
|
|
|
if (entry.count != 0) {
|
|
|
|
|
fastInfo.defaultFocalLength = entry.data.f[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* Parameters::getStateName(State state) {
|
|
|
|
|
#define CASE_ENUM_TO_CHAR(x) case x: return(#x); break;
|
|
|
|
|
switch(state) {
|
|
|
|
@ -2589,12 +2612,12 @@ int Parameters::abModeStringToEnum(const char *abMode) {
|
|
|
|
|
-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Parameters::sceneModeStringToEnum(const char *sceneMode) {
|
|
|
|
|
int Parameters::sceneModeStringToEnum(const char *sceneMode, uint8_t defaultSceneMode) {
|
|
|
|
|
return
|
|
|
|
|
!sceneMode ?
|
|
|
|
|
ANDROID_CONTROL_SCENE_MODE_DISABLED :
|
|
|
|
|
defaultSceneMode :
|
|
|
|
|
!strcmp(sceneMode, CameraParameters::SCENE_MODE_AUTO) ?
|
|
|
|
|
ANDROID_CONTROL_SCENE_MODE_DISABLED :
|
|
|
|
|
defaultSceneMode :
|
|
|
|
|
!strcmp(sceneMode, CameraParameters::SCENE_MODE_ACTION) ?
|
|
|
|
|
ANDROID_CONTROL_SCENE_MODE_ACTION :
|
|
|
|
|
!strcmp(sceneMode, CameraParameters::SCENE_MODE_PORTRAIT) ?
|
|
|
|
@ -3241,12 +3264,12 @@ status_t Parameters::calculatePictureFovs(float *horizFov, float *vertFov)
|
|
|
|
|
if (horizFov != NULL) {
|
|
|
|
|
*horizFov = 180 / M_PI * 2 *
|
|
|
|
|
atanf(horizCropFactor * sensorSize.data.f[0] /
|
|
|
|
|
(2 * fastInfo.minFocalLength));
|
|
|
|
|
(2 * fastInfo.defaultFocalLength));
|
|
|
|
|
}
|
|
|
|
|
if (vertFov != NULL) {
|
|
|
|
|
*vertFov = 180 / M_PI * 2 *
|
|
|
|
|
atanf(vertCropFactor * sensorSize.data.f[1] /
|
|
|
|
|
(2 * fastInfo.minFocalLength));
|
|
|
|
|
(2 * fastInfo.defaultFocalLength));
|
|
|
|
|
}
|
|
|
|
|
return OK;
|
|
|
|
|
}
|
|
|
|
|