camera/QCamera2/util/QCameraFlash.cpp
/*===========================================================================
 * FUNCTION   : reserveFlashForCamera
 *
 * DESCRIPTION: Give control of the flash to the camera, and notify
 *              framework that the flash has become unavailable.
 *
 * PARAMETERS :
 *   @camera_id : Camera id of the flash.
 *
 * RETURN     :
 *   0        : success
 *   -EINVAL  : No camera present at camera_id or not inited.
 *   -ENOSYS  : No callback available for torch_mode_status_change.
 *==========================================================================*/
FUNCTION   : reserveFlashForCamera
DESCRIPTION: Give control of the flash to the camera, and notify
framework that the flash has become unavailable.

PARAMETERS :
@camera_id : Camera id of the flash.

RETURN     :
0        : success
-EINVAL  : No camera present at camera_id or not inited.
-ENOSYS  : No callback available for torch_mode_status_change.
FUNCTION : reserveFlashForCamera DESCRIPTION : Give control of the flash to the camera and notify framework that the flash has become unavailable . PARAMETERS : @camera_id : Camera id of the flash . RETURN : 0 : success - EINVAL : No camera present at camera_id or not inited . - ENOSYS : No callback available for torch_mode_status_change .
int32_t QCameraFlash::reserveFlashForCamera(const int camera_id)
{
    int32_t retVal = 0;
    if (camera_id < 0 || camera_id >= MM_CAMERA_MAX_NUM_SENSORS) {
        LOGE("Invalid camera id: %d", camera_id);
        retVal = -EINVAL;
    } else if (m_cameraOpen[camera_id]) {
        LOGD("Flash already reserved for camera id: %d",
                camera_id);
    } else {
        if (m_flashOn[camera_id]) {
            setFlashMode(camera_id, false, LED_DUAL);
            deinitFlash(camera_id);
        }
        m_cameraOpen[camera_id] = true;
        if (m_callbacks == NULL ||
                m_callbacks->torch_mode_status_change == NULL) {
            LOGE("Callback is not defined!");
            retVal = -ENOSYS;
        } else if (camera_id != 0) {
            LOGD("Suppressing callback "
                    "because no flash exists for camera id: %d",
                    camera_id);
        } else {
            char cameraIdStr[STRING_LENGTH_OF_64_BIT_NUMBER];
            snprintf(cameraIdStr, STRING_LENGTH_OF_64_BIT_NUMBER,
                    "%d", camera_id);
            m_callbacks->torch_mode_status_change(m_callbacks,
                    cameraIdStr,
                    TORCH_MODE_STATUS_NOT_AVAILABLE);
        }
    }
    return retVal;
}
int32_t QCameraFlash :: reserveFlashForCamera ( const int camera_id ) { int32_t retVal = 0 ; if ( camera_id < 0 || camera_id >= MM_CAMERA_MAX_NUM_SENSORS ) { LOGE ( " " , camera_id ) ; retVal = - EINVAL ; } else if ( m_cameraOpen [ camera_id ] ) { LOGD ( " " , camera_id ) ; } else { if ( m_flashOn [ camera_id ] ) { setFlashMode ( camera_id , false , LED_DUAL ) ; deinitFlash ( camera_id ) ; } m_cameraOpen [ camera_id ] = true ; if ( m_callbacks == NULL || m_callbacks -> torch_mode_status_change == NULL ) { LOGE ( " " ) ; retVal = - ENOSYS ; } else if ( camera_id != 0 ) { LOGD ( " " " " , camera_id ) ; } else { char cameraIdStr [ STRING_LENGTH_OF_64_BIT_NUMBER ] ; snprintf ( cameraIdStr , STRING_LENGTH_OF_64_BIT_NUMBER , " " , camera_id ) ; m_callbacks -> torch_mode_status_change ( m_callbacks , cameraIdStr , TORCH_MODE_STATUS_NOT_AVAILABLE ) ; } } return retVal ; }
FUNCTION   : reserveFlashForCamera
 DESCRIPTION: Give control of the flash to the camera, and notify
              framework that the flash has become unavailable.
FUNCTION : reserveFlashForCamera DESCRIPTION : Give control of the flash to the camera and notify framework that the flash has become unavailable .