diff options
author | Alex Ray <aray@google.com> | 2013-06-28 21:07:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-06-28 21:07:01 +0000 |
commit | c6d5e3757b6dda09a7105d754a7c0929cd03aa91 (patch) | |
tree | f15a8d8a48dd345d30a4e59ac047e1f832fa9d82 /modules/camera/Camera.cpp | |
parent | f37f187bbac1fd7bf884eb3ea5c47aa78cb68cdc (diff) | |
parent | b0be1039c136f85778dffaf761af3d09907e21aa (diff) | |
download | hardware_libhardware-c6d5e3757b6dda09a7105d754a7c0929cd03aa91.zip hardware_libhardware-c6d5e3757b6dda09a7105d754a7c0929cd03aa91.tar.gz hardware_libhardware-c6d5e3757b6dda09a7105d754a7c0929cd03aa91.tar.bz2 |
Merge "modules: camera: add get_camera_info support"
Diffstat (limited to 'modules/camera/Camera.cpp')
-rw-r--r-- | modules/camera/Camera.cpp | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/modules/camera/Camera.cpp b/modules/camera/Camera.cpp index 718d42b..76fe1a0 100644 --- a/modules/camera/Camera.cpp +++ b/modules/camera/Camera.cpp @@ -19,7 +19,9 @@ #include <hardware/camera3.h> #include <sync/sync.h> #include <system/camera_metadata.h> +#include <system/graphics.h> #include "CameraHAL.h" +#include "Metadata.h" #include "Stream.h" //#define LOG_NDEBUG 0 @@ -34,6 +36,8 @@ #define CAMERA_SYNC_TIMEOUT 5000 // in msecs +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + namespace default_camera_hal { extern "C" { @@ -48,6 +52,7 @@ static int close_device(hw_device_t* dev) Camera::Camera(int id) : mId(id), + mStaticInfo(NULL), mBusy(false), mCallbackOps(NULL), mStreams(NULL), @@ -59,6 +64,7 @@ Camera::Camera(int id) memset(&mDevice, 0, sizeof(mDevice)); mDevice.common.tag = HARDWARE_DEVICE_TAG; + mDevice.common.version = CAMERA_DEVICE_API_VERSION_3_0; mDevice.common.close = close_device; mDevice.ops = const_cast<camera3_device_ops_t*>(&sOps); mDevice.priv = this; @@ -88,6 +94,25 @@ int Camera::open(const hw_module_t *module, hw_device_t **device) return 0; } +int Camera::getInfo(struct camera_info *info) +{ + int ret = 0; + + info->facing = CAMERA_FACING_FRONT; + info->orientation = 0; + info->device_version = mDevice.common.version; + + pthread_mutex_lock(&mMutex); + if (mStaticInfo == NULL) { + ret = initStaticInfo(); + } + pthread_mutex_unlock(&mMutex); + + info->static_camera_characteristics = mStaticInfo; + + return ret; +} + int Camera::close() { ALOGI("%s:%d: Closing camera device", __func__, mId); @@ -113,6 +138,141 @@ int Camera::initialize(const camera3_callback_ops_t *callback_ops) return 0; } +int Camera::initStaticInfo() +{ + /* + * Setup static camera info. This will have to customized per camera + * device. + */ + + /* android.control */ + int32_t android_control_ae_available_target_fps_ranges[] = {30, 30}; + mMetadata.addInt32(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + ARRAY_SIZE(android_control_ae_available_target_fps_ranges), + android_control_ae_available_target_fps_ranges); + + int32_t android_control_ae_compensation_range[] = {-4, 4}; + mMetadata.addInt32(ANDROID_CONTROL_AE_COMPENSATION_RANGE, + ARRAY_SIZE(android_control_ae_compensation_range), + android_control_ae_compensation_range); + + camera_metadata_rational_t android_control_ae_compensation_step[] = {{2,1}}; + mMetadata.addRational(ANDROID_CONTROL_AE_COMPENSATION_STEP, + ARRAY_SIZE(android_control_ae_compensation_step), + android_control_ae_compensation_step); + + int32_t android_control_max_regions[] = {1}; + mMetadata.addInt32(ANDROID_CONTROL_MAX_REGIONS, + ARRAY_SIZE(android_control_max_regions), + android_control_max_regions); + + /* android.jpeg */ + int32_t android_jpeg_available_thumbnail_sizes[] = {0, 0, 128, 96}; + mMetadata.addInt32(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, + ARRAY_SIZE(android_jpeg_available_thumbnail_sizes), + android_jpeg_available_thumbnail_sizes); + + /* android.lens */ + float android_lens_info_available_focal_lengths[] = {1.0}; + mMetadata.addFloat(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, + ARRAY_SIZE(android_lens_info_available_focal_lengths), + android_lens_info_available_focal_lengths); + + /* android.request */ + int32_t android_request_max_num_output_streams[] = {0, 3, 1}; + mMetadata.addInt32(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, + ARRAY_SIZE(android_request_max_num_output_streams), + android_request_max_num_output_streams); + + /* android.scaler */ + int32_t android_scaler_available_formats[] = { + HAL_PIXEL_FORMAT_RAW_SENSOR, + HAL_PIXEL_FORMAT_BLOB, + HAL_PIXEL_FORMAT_RGBA_8888, + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, + // These are handled by YCbCr_420_888 + // HAL_PIXEL_FORMAT_YV12, + // HAL_PIXEL_FORMAT_YCrCb_420_SP, + HAL_PIXEL_FORMAT_YCbCr_420_888}; + mMetadata.addInt32(ANDROID_SCALER_AVAILABLE_FORMATS, + ARRAY_SIZE(android_scaler_available_formats), + android_scaler_available_formats); + + int64_t android_scaler_available_jpeg_min_durations[] = {1}; + mMetadata.addInt64(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS, + ARRAY_SIZE(android_scaler_available_jpeg_min_durations), + android_scaler_available_jpeg_min_durations); + + int32_t android_scaler_available_jpeg_sizes[] = {640, 480}; + mMetadata.addInt32(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, + ARRAY_SIZE(android_scaler_available_jpeg_sizes), + android_scaler_available_jpeg_sizes); + + float android_scaler_available_max_digital_zoom[] = {1}; + mMetadata.addFloat(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, + ARRAY_SIZE(android_scaler_available_max_digital_zoom), + android_scaler_available_max_digital_zoom); + + int64_t android_scaler_available_processed_min_durations[] = {1}; + mMetadata.addInt64(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS, + ARRAY_SIZE(android_scaler_available_processed_min_durations), + android_scaler_available_processed_min_durations); + + int32_t android_scaler_available_processed_sizes[] = {640, 480}; + mMetadata.addInt32(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, + ARRAY_SIZE(android_scaler_available_processed_sizes), + android_scaler_available_processed_sizes); + + int64_t android_scaler_available_raw_min_durations[] = {1}; + mMetadata.addInt64(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS, + ARRAY_SIZE(android_scaler_available_raw_min_durations), + android_scaler_available_raw_min_durations); + + int32_t android_scaler_available_raw_sizes[] = {640, 480}; + mMetadata.addInt32(ANDROID_SCALER_AVAILABLE_RAW_SIZES, + ARRAY_SIZE(android_scaler_available_raw_sizes), + android_scaler_available_raw_sizes); + + /* android.sensor */ + + int32_t android_sensor_info_active_array_size[] = {0, 0, 640, 480}; + mMetadata.addInt32(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + ARRAY_SIZE(android_sensor_info_active_array_size), + android_sensor_info_active_array_size); + + int32_t android_sensor_info_available_sensitivities[] = + {100, 200, 400, 800, 1600}; + mMetadata.addInt32(ANDROID_SENSOR_INFO_AVAILABLE_SENSITIVITIES, + ARRAY_SIZE(android_sensor_info_available_sensitivities), + android_sensor_info_available_sensitivities); + + int64_t android_sensor_info_max_frame_duration[] = {30000000000}; + mMetadata.addInt64(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, + ARRAY_SIZE(android_sensor_info_max_frame_duration), + android_sensor_info_max_frame_duration); + + float android_sensor_info_physical_size[] = {3.2, 2.4}; + mMetadata.addFloat(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + ARRAY_SIZE(android_sensor_info_physical_size), + android_sensor_info_physical_size); + + int32_t android_sensor_info_pixel_array_size[] = {640, 480}; + mMetadata.addInt32(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + ARRAY_SIZE(android_sensor_info_pixel_array_size), + android_sensor_info_pixel_array_size); + + int32_t android_sensor_orientation[] = {0}; + mMetadata.addInt32(ANDROID_SENSOR_ORIENTATION, + ARRAY_SIZE(android_sensor_orientation), + android_sensor_orientation); + + /* End of static camera characteristics */ + + mStaticInfo = mMetadata.generate(); + + return 0; +} + int Camera::configureStreams(camera3_stream_configuration_t *stream_config) { camera3_stream_t *astream; |