13d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 23d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * 33d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * Redistribution and use in source and binary forms, with or without 43d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * modification, are permitted provided that the following conditions are 53d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * met: 63d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * * Redistributions of source code must retain the above copyright 73d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * notice, this list of conditions and the following disclaimer. 83d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * * Redistributions in binary form must reproduce the above 93d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * copyright notice, this list of conditions and the following 103d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * disclaimer in the documentation and/or other materials provided 113d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * with the distribution. 123d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * * Neither the name of The Linux Foundation nor the names of its 133d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * contributors may be used to endorse or promote products derived 143d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * from this software without specific prior written permission. 153d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * 163d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 173d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 183d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 193d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 203d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 213d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 223d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 233d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 243d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 253d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 263d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel * 283d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel */ 293d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 303d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#ifndef __QCAMERA_STATEMACHINE_H__ 313d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#define __QCAMERA_STATEMACHINE_H__ 323d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 333d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel// System dependencies 343d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include <pthread.h> 353d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 363d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel// Camera dependencies 373d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include "QCameraQueue.h" 383d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include "QCameraChannel.h" 393d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include "cam_semaphore.h" 403d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 413d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelextern "C" { 423d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#include "mm_camera_interface.h" 433d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} 443d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 453d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelnamespace qcamera { 463d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 473d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelclass QCamera2HardwareInterface; 483d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 493d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef enum { 503d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel /*******BEGIN OF: API EVT*********/ 513d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_PREVIEW_WINDOW = 1, // set preview window 523d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_CALLBACKS, // set callbacks 533d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_ENABLE_MSG_TYPE, // enable msg type 543d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_DISABLE_MSG_TYPE, // disable msg type 553d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_MSG_TYPE_ENABLED, // query certain msg type is enabled 563d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 573d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_PARAMS, // set parameters 583d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_PARAMS_STOP, // stop camera after set params, if necessary 593d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_PARAMS_COMMIT, // commit set params 603d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SET_PARAMS_RESTART, // restart after set params, if necessary 613d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_GET_PARAMS, // get parameters 623d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PUT_PARAMS, // put parameters, release param buf 633d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 643d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PREPARE_PREVIEW, // prepare preview (zsl, camera mode, camcorder mode) 653d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_START_PREVIEW, // start preview (zsl, camera mode, camcorder mode) 663d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_START_NODISPLAY_PREVIEW, // start no display preview (zsl, camera mode, camcorder mode) 673d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_STOP_PREVIEW, // stop preview (zsl, camera mode, camcorder mode) 683d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PREVIEW_ENABLED, // query if preview is running 693d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 703d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS, // request to store meta data in video buffers 713d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PRE_START_RECORDING, // pre start recording, to prepare for recording 723d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_START_RECORDING, // start recording 733d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_STOP_RECORDING, // stop recording 743d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RECORDING_ENABLED, // query if recording is running 753d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RELEASE_RECORIDNG_FRAME, // release recording frame 763d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 773d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PREPARE_SNAPSHOT, // prepare snapshot in case LED needs to be flashed 783d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_PRE_TAKE_PICTURE, // pre take picutre (to restart preview if necessary) 793d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_TAKE_PICTURE, // take picutre (zsl, regualr capture, live snapshot 803d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_CANCEL_PICTURE, // cancel picture 813d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 823d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_START_AUTO_FOCUS, // start auto focus 833d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_STOP_AUTO_FOCUS, // stop auto focus 843d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SEND_COMMAND, // send command 853d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 863d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RELEASE, // release camera resource 873d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_DUMP, // dump 883d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_REG_FACE_IMAGE, // register a face image in imaging lib 893d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel /*******END OF: API EVT*********/ 903d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 913d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_EVT_INTERNAL, // internal evt notify 923d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_EVT_NOTIFY, // evt notify from server 933d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_JPEG_EVT_NOTIFY, // evt notify from jpeg 943d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SNAPSHOT_DONE, // internal evt that snapshot is done 953d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_THERMAL_NOTIFY, // evt notify from thermal daemon 963d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_STOP_CAPTURE_CHANNEL, // stop capture channel 973d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RESTART_PERVIEW, // internal preview restart 983d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_DELAYED_RESTART, // preview restart needs delay (dual camera mode) 993d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_SEND_COMMAND_RESTART, // restart after send command (if necessary) 1003d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RESTART_START_PREVIEW, // preview start as part of restart (dual camera mode) 1013d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_RESTART_STOP_PREVIEW, // preview stop as part of restart (dual camera mode) 1023d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_EVT_MAX 1033d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_sm_evt_enum_t; 1043d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1053d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef enum { 1063d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_API_RESULT_TYPE_DEF, // default type, no additional info 1073d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_API_RESULT_TYPE_ENABLE_FLAG, // msg_enabled, preview_enabled, recording_enabled 1083d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_API_RESULT_TYPE_PARAMS, // returned parameters in string 1093d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_API_RESULT_TYPE_HANDLE, // returned handle in int 1103d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_API_RESULT_TYPE_MAX 1113d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_api_result_type_t; 1123d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1133d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct { 1143d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t status; // api call status 1153d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_sm_evt_enum_t request_api; // api evt requested 1163d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_api_result_type_t result_type; // result type 1173d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel union { 1183d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int enabled; // result_type == QCAMERA_API_RESULT_TYPE_ENABLE_FLAG 1193d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel char *params; // result_type == QCAMERA_API_RESULT_TYPE_PARAMS 1203d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int handle; // result_type ==QCAMERA_API_RESULT_TYPE_HANDLE 1213d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel }; 1223d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_api_result_t; 1233d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1243d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct api_result_list { 1253d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_api_result_t result; 1263d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel struct api_result_list *next; 1273d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel}api_result_list; 1283d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1293d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel// definition for payload type of setting callback 1303d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct { 1313d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel camera_notify_callback notify_cb; 1323d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel camera_data_callback data_cb; 1333d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel camera_data_timestamp_callback data_cb_timestamp; 1343d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel camera_request_memory get_memory; 1353d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel void *user; 1363d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_sm_evt_setcb_payload_t; 1373d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1383d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel// definition for payload type of sending command 1393d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct { 1403d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t cmd; 1413d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t arg1; 1423d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t arg2; 1433d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_sm_evt_command_payload_t; 1443d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1453d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel// definition for payload type of sending command 1463d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct { 1473d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel void *img_ptr; 1483d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_pp_offline_src_config_t *config; 1493d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_sm_evt_reg_face_payload_t; 1503d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1513d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef enum { 1523d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_FOCUS_UPDATE, // focus updating result 1533d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_PREP_SNAPSHOT_DONE, // prepare snapshot done 1543d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_FACE_DETECT_RESULT, // face detection result 1553d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_HISTOGRAM_STATS, // histogram 1563d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_CROP_INFO, // crop info 1573d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_ASD_UPDATE, // asd update result 1583d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_READY_FOR_SNAPSHOT, // Ready for Prepare Snapshot 1599ec39c64004dda78086849a21087cb217d0bf6acThierry Strudel QCAMERA_INTERNAL_EVT_LED_MODE_OVERRIDE, // Led mode override 1603d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_AWB_UPDATE, // awb update result 1613d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_AE_UPDATE, // ae update result 1623d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_FOCUS_POS_UPDATE, // focus position update result 1633d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_HDR_UPDATE, // HDR scene update 1643d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_RETRO_AEC_UNLOCK, // retro burst AEC unlock event 1653d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_ZSL_CAPTURE_DONE, // ZSL capture done event 166cca4d9c3be40fe18502f3237f7993b41175ef3a7Thierry Strudel QCAMERA_INTERNAL_EVT_DUAL_CAMERA_FOV_CONTROL, // FOV Control event 1679ec39c64004dda78086849a21087cb217d0bf6acThierry Strudel QCAMERA_INTERNAL_EVT_LED_CALIB_UPDATE, //LED calibration result update 1683d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_INTERNAL_EVT_MAX 1693d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_internal_evt_type_t; 1703d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1713d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudeltypedef struct { 1723d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_internal_evt_type_t evt_type; 1733d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel union { 1743d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_auto_focus_data_t focus_data; 1753d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_prep_snapshot_state_t prep_snapshot_state; 1763d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_faces_data_t faces_data; 1773d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_hist_stats_t stats_data; 1783d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_crop_data_t crop_data; 1793d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_asd_decision_t asd_data; 1803d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_flash_mode_t led_data; 1813d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_awb_params_t awb_data; 1823d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_3a_params_t ae_data; 1833d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_focus_pos_info_t focus_pos; 1843d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_asd_hdr_scene_data_t hdr_data; 1859ec39c64004dda78086849a21087cb217d0bf6acThierry Strudel int32_t led_calib_result; 1863d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel }; 1873d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel} qcamera_sm_internal_evt_payload_t; 1883d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1893d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelclass QCameraStateMachine 1903d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel{ 1913d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelpublic: 1923d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCameraStateMachine(QCamera2HardwareInterface *ctrl); 1933d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel virtual ~QCameraStateMachine(); 1943d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procAPI(qcamera_sm_evt_enum_t evt, void *api_payload); 1953d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvt(qcamera_sm_evt_enum_t evt, void *evt_payload); 1963d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 1973d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isPreviewRunning(); // check if preview is running 1983d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isPreviewReady(); // check if preview is ready 1993d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isCaptureRunning(); // check if image capture is running 2003d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isNonZSLCaptureRunning(); // check if image capture is running in non ZSL mode 2013d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel String8 dump(); //returns the state information in a string 2023d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isPrepSnapStateRunning(); 2033d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isRecording(); 2043d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel void releaseThread(); 2053d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2063d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool isPreviewCallbackNeeded() { return m_bPreviewCallbackNeeded; }; 2073d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t setPreviewCallbackNeeded(bool enabled) {m_bPreviewCallbackNeeded=enabled; return 0;}; 2083d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudelprivate: 2093d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel typedef enum { 2103d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PREVIEW_STOPPED, // preview is stopped 2113d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PREVIEW_READY, // preview started but preview window is not set yet 2123d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PREVIEWING, // previewing 2133d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PREPARE_SNAPSHOT, // prepare snapshot in case aec estimation is 2143d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel // needed for LED flash 2153d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PIC_TAKING, // taking picture (preview stopped) 2163d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_RECORDING, // recording (preview running) 2173d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_VIDEO_PIC_TAKING, // taking live snapshot during recording (preview running) 2183d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_STATE_PREVIEW_PIC_TAKING // taking ZSL/live snapshot (recording stopped but preview running) 2193d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel } qcamera_state_enum_t; 2203d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2213d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel typedef enum 2223d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel { 2233d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_CMD_TYPE_API, // cmd from API 2243d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_CMD_TYPE_EVT, // cmd from mm-camera-interface/mm-jpeg-interface event 2253d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_CMD_TYPE_EXIT, // cmd for exiting statemachine cmdThread 2263d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCAMERA_SM_CMD_TYPE_MAX 2273d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel } qcamera_sm_cmd_type_t; 2283d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2293d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel typedef struct { 2303d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_sm_cmd_type_t cmd; // cmd type (where it comes from) 2313d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_sm_evt_enum_t evt; // event type 2323d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel void *evt_payload; // ptr to payload 2333d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel } qcamera_sm_cmd_t; 2343d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2353d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t stateMachine(qcamera_sm_evt_enum_t evt, void *payload); 2363d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPreviewStoppedState(qcamera_sm_evt_enum_t evt, void *payload); 2373d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPreviewReadyState(qcamera_sm_evt_enum_t evt, void *payload); 2383d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPreviewingState(qcamera_sm_evt_enum_t evt, void *payload); 2393d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPrepareSnapshotState(qcamera_sm_evt_enum_t evt, void *payload); 2403d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPicTakingState(qcamera_sm_evt_enum_t evt, void *payload); 2413d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtRecordingState(qcamera_sm_evt_enum_t evt, void *payload); 2423d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtVideoPicTakingState(qcamera_sm_evt_enum_t evt, void *payload); 2433d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t procEvtPreviewPicTakingState(qcamera_sm_evt_enum_t evt, void *payload); 2443d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2453d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel // main statemachine process routine 2463d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel static void *smEvtProcRoutine(void *data); 2473d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2483d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t applyDelayedMsgs(); 2493d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2503d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCamera2HardwareInterface *m_parent; // ptr to HWI 2513d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel qcamera_state_enum_t m_state; // statemachine state 2523d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCameraQueue api_queue; // cmd queue for APIs 2533d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel QCameraQueue evt_queue; // cmd queue for evt from mm-camera-intf/mm-jpeg-intf 2543d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel pthread_t cmd_pid; // cmd thread ID 2553d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel cam_semaphore_t cmd_sem; // semaphore for cmd thread 2563d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool m_bDelayPreviewMsgs; // Delay preview callback enable during ZSL snapshot 2573d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool m_bPreviewNeedsRestart; // Preview needs restart 2583d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool m_bPreviewDelayedRestart; // Preview delayed restart 2593d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel int32_t m_DelayedMsgs; 2603d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool m_RestoreZSL; 2613d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel bool m_bPreviewCallbackNeeded; 2623d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel}; 2633d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2643d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel}; // namespace qcamera 2653d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel 2663d63919a23d7e7954e160c48c36713267106c3c2Thierry Strudel#endif /* __QCAMERA_STATEMACHINE_H__ */ 267