标签:
在我们调相机时, 经常有测试提出相机的模型情景模式不支持。下面我们来分析下怎样看android系统相机的情景模式。我们以MTK的实现为例。
在底层mediatek/proprietary/custom/mt8127/hal/sendepfeature/ov2680_raw/config.ftbl.ov2680_mipi_raw.h 这个文件定义的我们的相机支持哪些情景模式
#if 1 // Scene Mode FTABLE_CONFIG_AS_TYPE_OF_DEFAULT_VALUES( KEY_AS_(MtkCameraParameters::KEY_SCENE_MODE), SCENE_AS_DEFAULT_SCENE( ITEM_AS_DEFAULT_(MtkCameraParameters::SCENE_MODE_AUTO), ITEM_AS_VALUES_( MtkCameraParameters::SCENE_MODE_AUTO, // MtkCameraParameters::SCENE_MODE_NORMAL, MtkCameraParameters::SCENE_MODE_PORTRAIT, MtkCameraParameters::SCENE_MODE_LANDSCAPE, MtkCameraParameters::SCENE_MODE_NIGHT, MtkCameraParameters::SCENE_MODE_NIGHT_PORTRAIT, MtkCameraParameters::SCENE_MODE_THEATRE, MtkCameraParameters::SCENE_MODE_BEACH, MtkCameraParameters::SCENE_MODE_SNOW, MtkCameraParameters::SCENE_MODE_SUNSET, MtkCameraParameters::SCENE_MODE_STEADYPHOTO, // MtkCameraParameters::SCENE_MODE_FIREWORKS, MtkCameraParameters::SCENE_MODE_SPORTS, MtkCameraParameters::SCENE_MODE_PARTY, MtkCameraParameters::SCENE_MODE_CANDLELIGHT, // MtkCameraParameters::SCENE_MODE_HDR, ) ), ) #endif
这个文件定义的我们的相机支持的哪些情景模式,SCENE_MODE_HDR,, HDR模式, SCENE_MODE_NIGHT夜景模式........
有了这个后, android framework会根据这些做相应的处理, 然后传入到上层, 上层java就可以判断我们是否能支持该模式,
在hal层, CameraHardwareInterface.h中
status_t initialize(hw_module_t *module) { ...... camera_module_t *cameraModule = reinterpret_cast<camera_module_t *>(module); camera_info info; status_t res = cameraModule->get_camera_info(atoi(mName.string()), &info); ...... }
这里进行初始化Camera的相关信息, 我们所需要的情景模式保存在结构体 camera_info中。
在CameraService.cpp中getCameraCharacteristics()方法中获取CameraInfo信息
status_t CameraService::getCameraCharacteristics(int cameraId, CameraMetadata* cameraInfo) { if (!cameraInfo) { ALOGE("%s: cameraInfo is NULL", __FUNCTION__); return BAD_VALUE; } if (!mModule) { ALOGE("%s: camera hardware module doesn't exist", __FUNCTION__); return -ENODEV; } if (cameraId < 0 || cameraId >= mNumberOfCameras) { ALOGE("%s: Invalid camera id: %d", __FUNCTION__, cameraId); return BAD_VALUE; } int facing; status_t ret = OK; if (mModule->common.module_api_version < CAMERA_MODULE_API_VERSION_2_0 || getDeviceVersion(cameraId, &facing) <= CAMERA_DEVICE_API_VERSION_2_1 ) { /** * Backwards compatibility mode for old HALs: * - Convert CameraInfo into static CameraMetadata properties. * - Retrieve cached CameraParameters for this camera. If none exist, * attempt to open CameraClient and retrieve the CameraParameters. * - Convert cached CameraParameters into static CameraMetadata * properties. */ ALOGI("%s: Switching to HAL1 shim implementation...", __FUNCTION__); if ((ret = generateShimMetadata(cameraId, cameraInfo)) != OK) { return ret; } } else { /** * Normal HAL 2.1+ codepath. */ struct camera_info info; ret = filterGetInfoErrorCode(mModule->get_camera_info(cameraId, &info)); *cameraInfo = info.static_camera_characteristics; } return ret; }
标签:
原文地址:http://blog.csdn.net/sdsdfser/article/details/45872625