1 /* Copyright (c) 2012-2015, The Linux Foundataion. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __QCAMERA2HARDWAREINTERFACE_H__ 31 #define __QCAMERA2HARDWAREINTERFACE_H__ 32 33 #include <hardware/camera.h> 34 #include <hardware/power.h> 35 #include <utils/Log.h> 36 #include <utils/Mutex.h> 37 #include <utils/Condition.h> 38 #include <QCameraParameters.h> 39 40 #include "QCameraQueue.h" 41 #include "QCameraCmdThread.h" 42 #include "QCameraChannel.h" 43 #include "QCameraStream.h" 44 #include "QCameraStateMachine.h" 45 #include "QCameraAllocator.h" 46 #include "QCameraPostProc.h" 47 #include "QCameraThermalAdapter.h" 48 #include "QCameraMem.h" 49 50 extern "C" { 51 #include <mm_camera_interface.h> 52 #include <mm_jpeg_interface.h> 53 } 54 55 #if DISABLE_DEBUG_LOG 56 57 inline void __null_log(int, const char *, const char *, ...) {} 58 59 #ifdef ALOGD 60 #undef ALOGD 61 #define ALOGD(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0) 62 #endif 63 64 #ifdef ALOGI 65 #undef ALOGI 66 #define ALOGI(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0) 67 #endif 68 69 #ifdef CDBG 70 #undef CDBG 71 #define CDBG(...) do{} while(0) 72 #endif 73 74 #else 75 76 77 #ifdef CDBG 78 #undef CDBG 79 #endif //#ifdef CDBG 80 #define CDBG(fmt, args...) ALOGD_IF(gCamHalLogLevel >= 2, fmt, ##args) 81 82 #ifdef CDBG_HIGH 83 #undef CDBG_HIGH 84 #endif //#ifdef CDBG_HIGH 85 #define CDBG_HIGH(fmt, args...) ALOGD_IF(gCamHalLogLevel >= 1, fmt, ##args) 86 87 #endif // DISABLE_DEBUG_LOG 88 89 namespace qcamera { 90 91 #ifndef TRUE 92 #define TRUE 1 93 #endif 94 95 #ifndef FALSE 96 #define FALSE 0 97 #endif 98 99 typedef enum { 100 QCAMERA_CH_TYPE_ZSL, 101 QCAMERA_CH_TYPE_CAPTURE, 102 QCAMERA_CH_TYPE_PREVIEW, 103 QCAMERA_CH_TYPE_VIDEO, 104 QCAMERA_CH_TYPE_SNAPSHOT, 105 QCAMERA_CH_TYPE_RAW, 106 QCAMERA_CH_TYPE_METADATA, 107 QCAMERA_CH_TYPE_ANALYSIS, 108 QCAMERA_CH_TYPE_MAX 109 } qcamera_ch_type_enum_t; 110 111 typedef struct { 112 int32_t msg_type; 113 int32_t ext1; 114 int32_t ext2; 115 } qcamera_evt_argm_t; 116 117 #define QCAMERA_DUMP_FRM_PREVIEW 1 118 #define QCAMERA_DUMP_FRM_VIDEO (1<<1) 119 #define QCAMERA_DUMP_FRM_SNAPSHOT (1<<2) 120 #define QCAMERA_DUMP_FRM_THUMBNAIL (1<<3) 121 #define QCAMERA_DUMP_FRM_RAW (1<<4) 122 #define QCAMERA_DUMP_FRM_JPEG (1<<5) 123 124 #define QCAMERA_DUMP_FRM_MASK_ALL 0x000000ff 125 126 #define QCAMERA_ION_USE_CACHE true 127 #define QCAMERA_ION_USE_NOCACHE false 128 #define MAX_ONGOING_JOBS 25 129 130 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 131 132 extern volatile uint32_t gCamHalLogLevel; 133 134 typedef enum { 135 QCAMERA_NOTIFY_CALLBACK, 136 QCAMERA_DATA_CALLBACK, 137 QCAMERA_DATA_TIMESTAMP_CALLBACK, 138 QCAMERA_DATA_SNAPSHOT_CALLBACK 139 } qcamera_callback_type_m; 140 141 typedef void (*camera_release_callback)(void *user_data, 142 void *cookie, 143 int32_t cb_status); 144 145 typedef struct { 146 qcamera_callback_type_m cb_type; // event type 147 int32_t msg_type; // msg type 148 int32_t ext1; // extended parameter 149 int32_t ext2; // extended parameter 150 camera_memory_t * data; // ptr to data memory struct 151 unsigned int index; // index of the buf in the whole buffer 152 int64_t timestamp; // buffer timestamp 153 camera_frame_metadata_t *metadata; // meta data 154 void *user_data; // any data needs to be released after callback 155 void *cookie; // release callback cookie 156 camera_release_callback release_cb; // release callback 157 } qcamera_callback_argm_t; 158 159 class QCameraCbNotifier { 160 public: 161 QCameraCbNotifier(QCamera2HardwareInterface *parent) : 162 mNotifyCb (NULL), 163 mDataCb (NULL), 164 mDataCbTimestamp (NULL), 165 mCallbackCookie (NULL), 166 mParent (parent), 167 mDataQ(releaseNotifications, this), 168 mActive(false){} 169 170 virtual ~QCameraCbNotifier(); 171 172 virtual int32_t notifyCallback(qcamera_callback_argm_t &cbArgs); 173 virtual void setCallbacks(camera_notify_callback notifyCb, 174 camera_data_callback dataCb, 175 camera_data_timestamp_callback dataCbTimestamp, 176 void *callbackCookie); 177 virtual int32_t startSnapshots(); 178 virtual void stopSnapshots(); 179 virtual void exit(); 180 static void * cbNotifyRoutine(void * data); 181 static void releaseNotifications(void *data, void *user_data); 182 static bool matchSnapshotNotifications(void *data, void *user_data); 183 static bool matchPreviewNotifications(void *data, void *user_data); 184 virtual int32_t flushPreviewNotifications(); 185 private: 186 187 camera_notify_callback mNotifyCb; 188 camera_data_callback mDataCb; 189 camera_data_timestamp_callback mDataCbTimestamp; 190 void *mCallbackCookie; 191 QCamera2HardwareInterface *mParent; 192 193 QCameraQueue mDataQ; 194 QCameraCmdThread mProcTh; 195 bool mActive; 196 }; 197 class QCamera2HardwareInterface : public QCameraAllocator, 198 public QCameraThermalCallback, public QCameraAdjustFPS 199 { 200 public: 201 /* static variable and functions accessed by camera service */ 202 static camera_device_ops_t mCameraOps; 203 204 static int set_preview_window(struct camera_device *, 205 struct preview_stream_ops *window); 206 static void set_CallBacks(struct camera_device *, 207 camera_notify_callback notify_cb, 208 camera_data_callback data_cb, 209 camera_data_timestamp_callback data_cb_timestamp, 210 camera_request_memory get_memory, 211 void *user); 212 static void enable_msg_type(struct camera_device *, int32_t msg_type); 213 static void disable_msg_type(struct camera_device *, int32_t msg_type); 214 static int msg_type_enabled(struct camera_device *, int32_t msg_type); 215 static int start_preview(struct camera_device *); 216 static void stop_preview(struct camera_device *); 217 static int preview_enabled(struct camera_device *); 218 static int store_meta_data_in_buffers(struct camera_device *, int enable); 219 static int start_recording(struct camera_device *); 220 static void stop_recording(struct camera_device *); 221 static int recording_enabled(struct camera_device *); 222 static void release_recording_frame(struct camera_device *, const void *opaque); 223 static int auto_focus(struct camera_device *); 224 static int cancel_auto_focus(struct camera_device *); 225 static int take_picture(struct camera_device *); 226 int takeLiveSnapshot_internal(); 227 int takeBackendPic_internal(bool *JpegMemOpt, char *raw_format); 228 void clearIntPendingEvents(); 229 void checkIntPicPending(bool JpegMemOpt, char *raw_format); 230 static int cancel_picture(struct camera_device *); 231 static int set_parameters(struct camera_device *, const char *parms); 232 static char* get_parameters(struct camera_device *); 233 static void put_parameters(struct camera_device *, char *); 234 static int send_command(struct camera_device *, 235 int32_t cmd, int32_t arg1, int32_t arg2); 236 static void release(struct camera_device *); 237 static int dump(struct camera_device *, int fd); 238 static int close_camera_device(hw_device_t *); 239 240 static int register_face_image(struct camera_device *, 241 void *img_ptr, 242 cam_pp_offline_src_config_t *config); 243 public: 244 QCamera2HardwareInterface(uint32_t cameraId); 245 virtual ~QCamera2HardwareInterface(); 246 int openCamera(struct hw_device_t **hw_device); 247 248 static int getCapabilities(uint32_t cameraId, struct camera_info *info); 249 static int initCapabilities(uint32_t cameraId, mm_camera_vtbl_t *cameraHandle); 250 251 // Implementation of QCameraAllocator 252 virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type, 253 size_t size, int stride, int scanline, uint8_t &bufferCnt); 254 virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj, 255 size_t size, uint8_t &bufferCnt); 256 257 virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type); 258 virtual QCameraHeapMemory *allocateMiscBuf(cam_stream_info_t *streamInfo); 259 virtual QCameraMemory *allocateStreamUserBuf(cam_stream_info_t *streamInfo); 260 261 // Implementation of QCameraThermalCallback 262 virtual int thermalEvtHandle(qcamera_thermal_level_enum_t *level, 263 void *userdata, void *data); 264 265 virtual int recalcFPSRange(int &minFPS, int &maxFPS, 266 cam_fps_range_t &adjustedRange); 267 268 friend class QCameraStateMachine; 269 friend class QCameraPostProcessor; 270 friend class QCameraCbNotifier; 271 272 private: 273 int setPreviewWindow(struct preview_stream_ops *window); 274 int setCallBacks( 275 camera_notify_callback notify_cb, 276 camera_data_callback data_cb, 277 camera_data_timestamp_callback data_cb_timestamp, 278 camera_request_memory get_memory, 279 void *user); 280 int enableMsgType(int32_t msg_type); 281 int disableMsgType(int32_t msg_type); 282 int msgTypeEnabled(int32_t msg_type); 283 int msgTypeEnabledWithLock(int32_t msg_type); 284 int startPreview(); 285 int stopPreview(); 286 int storeMetaDataInBuffers(int enable); 287 int startRecording(); 288 int stopRecording(); 289 int releaseRecordingFrame(const void *opaque); 290 int autoFocus(); 291 int cancelAutoFocus(); 292 int takePicture(); 293 int stopCaptureChannel(bool destroy); 294 int cancelPicture(); 295 int takeLiveSnapshot(); 296 int takePictureInternal(); 297 int cancelLiveSnapshot(); 298 char* getParameters(); 299 int putParameters(char *); 300 int sendCommand(int32_t cmd, int32_t &arg1, int32_t &arg2); 301 int release(); 302 int dump(int fd); 303 int registerFaceImage(void *img_ptr, 304 cam_pp_offline_src_config_t *config, 305 int32_t &faceID); 306 int32_t longShot(); 307 308 int openCamera(); 309 int closeCamera(); 310 311 int processAPI(qcamera_sm_evt_enum_t api, void *api_payload); 312 int processEvt(qcamera_sm_evt_enum_t evt, void *evt_payload); 313 int processSyncEvt(qcamera_sm_evt_enum_t evt, void *evt_payload); 314 void lockAPI(); 315 void waitAPIResult(qcamera_sm_evt_enum_t api_evt, qcamera_api_result_t *apiResult); 316 void unlockAPI(); 317 void signalAPIResult(qcamera_api_result_t *result); 318 void signalEvtResult(qcamera_api_result_t *result); 319 320 int calcThermalLevel(qcamera_thermal_level_enum_t level, 321 const int minFPSi, const int maxFPSi, cam_fps_range_t &adjustedRange, 322 enum msm_vfe_frame_skip_pattern &skipPattern); 323 int updateThermalLevel(void *level); 324 325 // update entris to set parameters and check if restart is needed 326 int updateParameters(const char *parms, bool &needRestart); 327 // send request to server to set parameters 328 int commitParameterChanges(); 329 330 bool isCaptureShutterEnabled(); 331 bool needDebugFps(); 332 bool isRegularCapture(); 333 bool isCACEnabled(); 334 bool is4k2kResolution(cam_dimension_t* resolution); 335 bool isAFRunning(); 336 bool isPreviewRestartEnabled(); 337 bool needReprocess(); 338 bool needRotationReprocess(); 339 bool needScaleReprocess(); 340 void debugShowVideoFPS(); 341 void debugShowPreviewFPS(); 342 void dumpJpegToFile(const void *data, size_t size, uint32_t index); 343 void dumpFrameToFile(QCameraStream *stream, 344 mm_camera_buf_def_t *frame, uint32_t dump_type); 345 void dumpMetadataToFile(QCameraStream *stream, 346 mm_camera_buf_def_t *frame,char *type); 347 void releaseSuperBuf(mm_camera_super_buf_t *super_buf); 348 void playShutter(); 349 void getThumbnailSize(cam_dimension_t &dim); 350 uint32_t getJpegQuality(); 351 inline bool getCancelAutoFocus(){ return mCancelAutoFocus; } 352 inline void setCancelAutoFocus(bool flag){ mCancelAutoFocus = flag; } 353 QCameraExif *getExifData(); 354 cam_sensor_t getSensorType(); 355 356 int32_t processAutoFocusEvent(cam_auto_focus_data_t &focus_data); 357 int32_t processZoomEvent(cam_crop_data_t &crop_info); 358 int32_t processPrepSnapshotDoneEvent(cam_prep_snapshot_state_t prep_snapshot_state); 359 int32_t processASDUpdate(cam_auto_scene_t scene); 360 int32_t processJpegNotify(qcamera_jpeg_evt_payload_t *jpeg_job); 361 int32_t processHDRData(cam_asd_hdr_scene_data_t hdr_scene); 362 int32_t processRetroAECUnlock(); 363 int32_t processZSLCaptureDone(); 364 int32_t processSceneData(cam_scene_mode_type scene); 365 int32_t transAwbMetaToParams(cam_awb_params_t &awb_params); 366 int32_t processFocusPositionInfo(cam_focus_pos_info_t &cur_pos_info); 367 int32_t processAEInfo(cam_3a_params_t &ae_params); 368 369 int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2); 370 int32_t sendDataNotify(int32_t msg_type, 371 camera_memory_t *data, 372 uint8_t index, 373 camera_frame_metadata_t *metadata); 374 375 int32_t sendPreviewCallback(QCameraStream *stream, 376 QCameraGrallocMemory *memory, uint32_t idx); 377 int32_t selectScene(QCameraChannel *pChannel, 378 mm_camera_super_buf_t *recvd_frame); 379 380 int32_t addChannel(qcamera_ch_type_enum_t ch_type); 381 int32_t startChannel(qcamera_ch_type_enum_t ch_type); 382 int32_t stopChannel(qcamera_ch_type_enum_t ch_type); 383 int32_t delChannel(qcamera_ch_type_enum_t ch_type, bool destroy = true); 384 int32_t addPreviewChannel(); 385 int32_t addSnapshotChannel(); 386 int32_t addVideoChannel(); 387 int32_t addZSLChannel(); 388 int32_t addCaptureChannel(); 389 int32_t addRawChannel(); 390 int32_t addMetaDataChannel(); 391 int32_t addAnalysisChannel(); 392 QCameraReprocessChannel *addReprocChannel(QCameraChannel *pInputChannel); 393 QCameraReprocessChannel *addOfflineReprocChannel( 394 cam_pp_offline_src_config_t &img_config, 395 cam_pp_feature_config_t &pp_feature, 396 stream_cb_routine stream_cb, 397 void *userdata); 398 int32_t addStreamToChannel(QCameraChannel *pChannel, 399 cam_stream_type_t streamType, 400 stream_cb_routine streamCB, 401 void *userData); 402 int32_t preparePreview(); 403 void unpreparePreview(); 404 int32_t prepareRawStream(QCameraChannel *pChannel); 405 QCameraChannel *getChannelByHandle(uint32_t channelHandle); 406 mm_camera_buf_def_t *getSnapshotFrame(mm_camera_super_buf_t *recvd_frame); 407 int32_t processFaceDetectionResult(cam_face_detection_data_t *fd_data); 408 int32_t processHistogramStats(cam_hist_stats_t &stats_data); 409 int32_t setHistogram(bool histogram_en); 410 int32_t setFaceDetection(bool enabled); 411 int32_t prepareHardwareForSnapshot(int32_t afNeeded); 412 bool needProcessPreviewFrame(); 413 bool isNoDisplayMode() {return mParameters.isNoDisplayMode();}; 414 bool isZSLMode() {return mParameters.isZSLMode();}; 415 bool isRdiMode() {return mParameters.isRdiMode();}; 416 uint8_t numOfSnapshotsExpected() { 417 return mParameters.getNumOfSnapshots();}; 418 bool isSecureMode() {return mParameters.isSecureMode();}; 419 bool isLongshotEnabled() { return mLongshotEnabled; }; 420 bool isHFRMode() {return mParameters.isHfrMode();}; 421 bool isLiveSnapshot() {return m_stateMachine.isRecording();}; 422 void setRetroPicture(bool enable) { bRetroPicture = enable; }; 423 bool isRetroPicture() {return bRetroPicture; }; 424 bool isHDRMode() {return mParameters.isHDREnabled();}; 425 uint8_t getBufNumRequired(cam_stream_type_t stream_type); 426 bool needFDMetadata(qcamera_ch_type_enum_t channel_type); 427 int32_t configureOnlineRotation(QCameraChannel &ch); 428 int32_t declareSnapshotStreams(); 429 int32_t unconfigureAdvancedCapture(); 430 int32_t configureAdvancedCapture(); 431 int32_t configureAFBracketing(bool enable = true); 432 int32_t configureHDRBracketing(); 433 int32_t stopAdvancedCapture(QCameraPicChannel *pChannel); 434 int32_t startAdvancedCapture(QCameraPicChannel *pChannel); 435 int32_t configureOptiZoom(); 436 int32_t configureStillMore(); 437 int32_t configureAEBracketing(); 438 int32_t updatePostPreviewParameters(); 439 inline void setOutputImageCount(uint32_t aCount) {mOutputCount = aCount;} 440 inline uint32_t getOutputImageCount() {return mOutputCount;} 441 bool processUFDumps(qcamera_jpeg_evt_payload_t *evt); 442 void captureDone(); 443 int32_t updateMetadata(metadata_buffer_t *pMetaData); 444 445 int32_t getPPConfig(cam_pp_feature_config_t &pp_config, int curCount); 446 static void camEvtHandle(uint32_t camera_handle, 447 mm_camera_event_t *evt, 448 void *user_data); 449 static void jpegEvtHandle(jpeg_job_status_t status, 450 uint32_t client_hdl, 451 uint32_t jobId, 452 mm_jpeg_output_t *p_buf, 453 void *userdata); 454 455 static void *evtNotifyRoutine(void *data); 456 457 // functions for different data notify cb 458 static void zsl_channel_cb(mm_camera_super_buf_t *recvd_frame, void *userdata); 459 static void capture_channel_cb_routine(mm_camera_super_buf_t *recvd_frame, 460 void *userdata); 461 static void postproc_channel_cb_routine(mm_camera_super_buf_t *recvd_frame, 462 void *userdata); 463 static void rdi_mode_stream_cb_routine(mm_camera_super_buf_t *frame, 464 QCameraStream *stream, 465 void *userdata); 466 static void nodisplay_preview_stream_cb_routine(mm_camera_super_buf_t *frame, 467 QCameraStream *stream, 468 void *userdata); 469 static void preview_stream_cb_routine(mm_camera_super_buf_t *frame, 470 QCameraStream *stream, 471 void *userdata); 472 static void postview_stream_cb_routine(mm_camera_super_buf_t *frame, 473 QCameraStream *stream, 474 void *userdata); 475 static void video_stream_cb_routine(mm_camera_super_buf_t *frame, 476 QCameraStream *stream, 477 void *userdata); 478 static void snapshot_channel_cb_routine(mm_camera_super_buf_t *frame, 479 void *userdata); 480 static void raw_stream_cb_routine(mm_camera_super_buf_t *frame, 481 QCameraStream *stream, 482 void *userdata); 483 static void preview_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame, 484 QCameraStream * stream, 485 void * userdata); 486 static void snapshot_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame, 487 QCameraStream * stream, 488 void * userdata); 489 static void metadata_stream_cb_routine(mm_camera_super_buf_t *frame, 490 QCameraStream *stream, 491 void *userdata); 492 static void reprocess_stream_cb_routine(mm_camera_super_buf_t *frame, 493 QCameraStream *stream, 494 void *userdata); 495 496 static void releaseCameraMemory(void *data, 497 void *cookie, 498 int32_t cbStatus); 499 static void returnStreamBuffer(void *data, 500 void *cookie, 501 int32_t cbStatus); 502 static void getLogLevel(); 503 504 private: 505 camera_device_t mCameraDevice; 506 uint32_t mCameraId; 507 mm_camera_vtbl_t *mCameraHandle; 508 bool mCameraOpened; 509 510 preview_stream_ops_t *mPreviewWindow; 511 QCameraParameters mParameters; 512 int32_t mMsgEnabled; 513 int mStoreMetaDataInFrame; 514 515 camera_notify_callback mNotifyCb; 516 camera_data_callback mDataCb; 517 camera_data_timestamp_callback mDataCbTimestamp; 518 camera_request_memory mGetMemory; 519 void *mCallbackCookie; 520 521 QCameraStateMachine m_stateMachine; // state machine 522 bool m_smThreadActive; 523 QCameraPostProcessor m_postprocessor; // post processor 524 QCameraThermalAdapter &m_thermalAdapter; 525 QCameraCbNotifier m_cbNotifier; 526 pthread_mutex_t m_lock; 527 pthread_cond_t m_cond; 528 api_result_list *m_apiResultList; 529 QCameraMemoryPool m_memoryPool; 530 531 pthread_mutex_t m_evtLock; 532 pthread_cond_t m_evtCond; 533 qcamera_api_result_t m_evtResult; 534 535 pthread_mutex_t m_parm_lock; 536 537 QCameraChannel *m_channels[QCAMERA_CH_TYPE_MAX]; // array holding channel ptr 538 539 bool m_bPreviewStarted; //flag indicates first preview frame callback is received 540 bool m_bRecordStarted; //flag indicates Recording is started for first time 541 542 // Signifies if ZSL Retro Snapshots are enabled 543 bool bRetroPicture; 544 // Signifies AEC locked during zsl snapshots 545 bool m_bLedAfAecLock; 546 cam_autofocus_state_t m_currentFocusState; 547 548 power_module_t *m_pPowerModule; // power module 549 550 uint32_t mDumpFrmCnt; // frame dump count 551 uint32_t mDumpSkipCnt; // frame skip count 552 mm_jpeg_exif_params_t mExifParams; 553 qcamera_thermal_level_enum_t mThermalLevel; 554 bool mCancelAutoFocus; 555 bool m_HDRSceneEnabled; 556 bool mLongshotEnabled; 557 558 int32_t m_max_pic_width; 559 int32_t m_max_pic_height; 560 pthread_t mLiveSnapshotThread; 561 pthread_t mIntPicThread; 562 bool mFlashNeeded; 563 uint32_t mDeviceRotation; 564 uint32_t mCaptureRotation; 565 uint32_t mJpegExifRotation; 566 bool mUseJpegExifRotation; 567 bool mIs3ALocked; 568 bool mPrepSnapRun; 569 int32_t mZoomLevel; 570 571 int mVFrameCount; 572 int mVLastFrameCount; 573 nsecs_t mVLastFpsTime; 574 double mVFps; 575 int mPFrameCount; 576 int mPLastFrameCount; 577 nsecs_t mPLastFpsTime; 578 double mPFps; 579 580 //eztune variables for communication with eztune server at backend 581 bool m_bIntJpegEvtPending; 582 bool m_bIntRawEvtPending; 583 char m_BackendFileName[QCAMERA_MAX_FILEPATH_LENGTH]; 584 size_t mBackendFileSize; 585 pthread_mutex_t m_int_lock; 586 pthread_cond_t m_int_cond; 587 588 enum DefferedWorkCmd { 589 CMD_DEFF_ALLOCATE_BUFF, 590 CMD_DEFF_PPROC_START, 591 CMD_DEFF_MAX 592 }; 593 594 typedef struct { 595 QCameraChannel *ch; 596 cam_stream_type_t type; 597 } DefferAllocBuffArgs; 598 599 typedef union { 600 DefferAllocBuffArgs allocArgs; 601 QCameraChannel *pprocArgs; 602 } DefferWorkArgs; 603 604 bool mDeffOngoingJobs[MAX_ONGOING_JOBS]; 605 606 struct DeffWork 607 { 608 DeffWork(DefferedWorkCmd cmd_, 609 uint32_t id_, 610 DefferWorkArgs args_) 611 : cmd(cmd_), 612 id(id_), 613 args(args_){}; 614 615 DefferedWorkCmd cmd; 616 uint32_t id; 617 DefferWorkArgs args; 618 }; 619 620 QCameraCmdThread mDefferedWorkThread; 621 QCameraQueue mCmdQueue; 622 623 Mutex mDeffLock; 624 Condition mDeffCond; 625 626 int32_t queueDefferedWork(DefferedWorkCmd cmd, 627 DefferWorkArgs args); 628 int32_t waitDefferedWork(int32_t &job_id); 629 static void *defferedWorkRoutine(void *obj); 630 631 int32_t mSnapshotJob; 632 int32_t mPostviewJob; 633 int32_t mMetadataJob; 634 int32_t mReprocJob; 635 int32_t mRawdataJob; 636 uint32_t mOutputCount; 637 uint32_t mInputCount; 638 bool mAdvancedCaptureConfigured; 639 bool mHDRBracketingEnabled; 640 }; 641 642 }; // namespace qcamera 643 644 #endif /* __QCAMERA2HARDWAREINTERFACE_H__ */ 645