@ -48,17 +48,22 @@ Parameters::Parameters(int cameraId,
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 ( ) ;
@ -766,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 ) ;
@ -998,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 ) ;
@ -1114,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
@ -1205,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 + + ) {
@ -2451,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 ) {
@ -3246,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 . min FocalLength) ) ;
( 2 * fastInfo . default FocalLength) ) ;
}
if ( vertFov ! = NULL ) {
* vertFov = 180 / M_PI * 2 *
atanf ( vertCropFactor * sensorSize . data . f [ 1 ] /
( 2 * fastInfo . min FocalLength) ) ;
( 2 * fastInfo . default FocalLength) ) ;
}
return OK ;
}