In android, Camera obtains the scenario modes supported by the system.
When we adjust the camera, we often do not support the scenario model of the camera. Next we will analyze how to view the camera scene mode of the android system. Let's take MTK implementation as an example.
In the bottom-layer mediatek/proprietary/custom/mt8127/hal/sendepfeature/ov2680_raw/config. ftbl. ov2680_mipi_rastmh file, which of the following scenario modes are supported by our camera?
#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
This file defines the scene modes supported by our camera, SCENE_MODE_HDR, HDR mode, SCENE_MODE_NIGHT night view mode ........
With this, the android framework will perform corresponding processing based on this, and then pass it to the upper layer. The upper-layer java can determine whether we can support this mode,
At the hal layer, in CameraHardwareInterface. h
status_t initialize(hw_module_t *module){ ...... camera_module_t *cameraModule = reinterpret_cast
(module); camera_info info; status_t res = cameraModule->get_camera_info(atoi(mName.string()), &info); ......}
Initialize the information about Camera. The expected scenario is saved in the structure camera_info.
Get the CameraInfo information in the getCameraCharacteristics () method of CameraService. cpp.
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;}