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 <utils/Log.h>
35 #include <utils/Mutex.h>
36 #include <utils/Condition.h>
37 #include <QCameraParameters.h>
38
39 #include "QCameraQueue.h"
40 #include "QCameraCmdThread.h"
41 #include "QCameraChannel.h"
42 #include "QCameraStream.h"
43 #include "QCameraStateMachine.h"
44 #include "QCameraAllocator.h"
45 #include "QCameraPostProc.h"
46 #include "QCameraThermalAdapter.h"
47 #include "QCameraMem.h"
48 #include "QCameraPerf.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
__null_log(int,const char *,const char *,...)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:
QCameraCbNotifier(QCamera2HardwareInterface * parent)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 cam_capability_t *getCamHalCapabilities();
251
252 // Implementation of QCameraAllocator
253 virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type,
254 size_t size, int stride, int scanline, uint8_t &bufferCnt);
255 virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj,
256 size_t size, uint8_t &bufferCnt);
257
258 virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type);
259 virtual QCameraHeapMemory *allocateMiscBuf(cam_stream_info_t *streamInfo);
260 virtual QCameraMemory *allocateStreamUserBuf(cam_stream_info_t *streamInfo);
261
262 // Implementation of QCameraThermalCallback
263 virtual int thermalEvtHandle(qcamera_thermal_level_enum_t *level,
264 void *userdata, void *data);
265
266 virtual int recalcFPSRange(int &minFPS, int &maxFPS,
267 cam_fps_range_t &adjustedRange);
268
269 friend class QCameraStateMachine;
270 friend class QCameraPostProcessor;
271 friend class QCameraCbNotifier;
272
273 private:
274 int setPreviewWindow(struct preview_stream_ops *window);
275 int setCallBacks(
276 camera_notify_callback notify_cb,
277 camera_data_callback data_cb,
278 camera_data_timestamp_callback data_cb_timestamp,
279 camera_request_memory get_memory,
280 void *user);
281 int enableMsgType(int32_t msg_type);
282 int disableMsgType(int32_t msg_type);
283 int msgTypeEnabled(int32_t msg_type);
284 int msgTypeEnabledWithLock(int32_t msg_type);
285 int startPreview();
286 int stopPreview();
287 int storeMetaDataInBuffers(int enable);
288 int startRecording();
289 int stopRecording();
290 int releaseRecordingFrame(const void *opaque);
291 int autoFocus();
292 int cancelAutoFocus();
293 int takePicture();
294 int stopCaptureChannel(bool destroy);
295 int cancelPicture();
296 int takeLiveSnapshot();
297 int takePictureInternal();
298 int cancelLiveSnapshot();
299 char* getParameters();
300 int putParameters(char *);
301 int sendCommand(int32_t cmd, int32_t &arg1, int32_t &arg2);
302 int release();
303 int dump(int fd);
304 int registerFaceImage(void *img_ptr,
305 cam_pp_offline_src_config_t *config,
306 int32_t &faceID);
307 int32_t longShot();
308
309 int openCamera();
310 int closeCamera();
311
312 int processAPI(qcamera_sm_evt_enum_t api, void *api_payload);
313 int processEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
314 int processSyncEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
315 void lockAPI();
316 void waitAPIResult(qcamera_sm_evt_enum_t api_evt, qcamera_api_result_t *apiResult);
317 void unlockAPI();
318 void signalAPIResult(qcamera_api_result_t *result);
319 void signalEvtResult(qcamera_api_result_t *result);
320
321 int calcThermalLevel(qcamera_thermal_level_enum_t level,
322 const int minFPSi, const int maxFPSi, cam_fps_range_t &adjustedRange,
323 enum msm_vfe_frame_skip_pattern &skipPattern);
324 int updateThermalLevel(void *level);
325
326 // update entris to set parameters and check if restart is needed
327 int updateParameters(const char *parms, bool &needRestart);
328 // send request to server to set parameters
329 int commitParameterChanges();
330
331 bool isCaptureShutterEnabled();
332 bool needDebugFps();
333 bool isRegularCapture();
334 bool isCACEnabled();
335 bool is4k2kResolution(cam_dimension_t* resolution);
336 bool isAFRunning();
337 bool isPreviewRestartEnabled();
338 bool needReprocess();
339 bool needRotationReprocess();
340 bool needScaleReprocess();
341 void debugShowVideoFPS();
342 void debugShowPreviewFPS();
343 void dumpJpegToFile(const void *data, size_t size, uint32_t index);
344 void dumpFrameToFile(QCameraStream *stream,
345 mm_camera_buf_def_t *frame, uint32_t dump_type);
346 void dumpMetadataToFile(QCameraStream *stream,
347 mm_camera_buf_def_t *frame,char *type);
348 void releaseSuperBuf(mm_camera_super_buf_t *super_buf);
349 void playShutter();
350 void getThumbnailSize(cam_dimension_t &dim);
351 uint32_t getJpegQuality();
getCancelAutoFocus()352 inline bool getCancelAutoFocus(){ return mCancelAutoFocus; }
setCancelAutoFocus(bool flag)353 inline void setCancelAutoFocus(bool flag){ mCancelAutoFocus = flag; }
354 QCameraExif *getExifData();
355 cam_sensor_t getSensorType();
356
357 int32_t processAutoFocusEvent(cam_auto_focus_data_t &focus_data);
358 int32_t processZoomEvent(cam_crop_data_t &crop_info);
359 int32_t processPrepSnapshotDoneEvent(cam_prep_snapshot_state_t prep_snapshot_state);
360 int32_t processASDUpdate(cam_auto_scene_t scene);
361 int32_t processJpegNotify(qcamera_jpeg_evt_payload_t *jpeg_job);
362 int32_t processHDRData(cam_asd_hdr_scene_data_t hdr_scene);
363 int32_t processRetroAECUnlock();
364 int32_t processZSLCaptureDone();
365 int32_t processSceneData(cam_scene_mode_type scene);
366 int32_t transAwbMetaToParams(cam_awb_params_t &awb_params);
367 int32_t processFocusPositionInfo(cam_focus_pos_info_t &cur_pos_info);
368 int32_t processAEInfo(cam_3a_params_t &ae_params);
369
370 int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2);
371 int32_t sendDataNotify(int32_t msg_type,
372 camera_memory_t *data,
373 uint8_t index,
374 camera_frame_metadata_t *metadata);
375
376 int32_t sendPreviewCallback(QCameraStream *stream,
377 QCameraGrallocMemory *memory, uint32_t idx);
378 int32_t selectScene(QCameraChannel *pChannel,
379 mm_camera_super_buf_t *recvd_frame);
380
381 int32_t addChannel(qcamera_ch_type_enum_t ch_type);
382 int32_t startChannel(qcamera_ch_type_enum_t ch_type);
383 int32_t stopChannel(qcamera_ch_type_enum_t ch_type);
384 int32_t delChannel(qcamera_ch_type_enum_t ch_type, bool destroy = true);
385 int32_t addPreviewChannel();
386 int32_t addSnapshotChannel();
387 int32_t addVideoChannel();
388 int32_t addZSLChannel();
389 int32_t addCaptureChannel();
390 int32_t addRawChannel();
391 int32_t addMetaDataChannel();
392 int32_t addAnalysisChannel();
393 QCameraReprocessChannel *addReprocChannel(QCameraChannel *pInputChannel);
394 QCameraReprocessChannel *addOfflineReprocChannel(
395 cam_pp_offline_src_config_t &img_config,
396 cam_pp_feature_config_t &pp_feature,
397 stream_cb_routine stream_cb,
398 void *userdata);
399 int32_t addStreamToChannel(QCameraChannel *pChannel,
400 cam_stream_type_t streamType,
401 stream_cb_routine streamCB,
402 void *userData);
403 int32_t preparePreview();
404 void unpreparePreview();
405 int32_t prepareRawStream(QCameraChannel *pChannel);
406 QCameraChannel *getChannelByHandle(uint32_t channelHandle);
407 mm_camera_buf_def_t *getSnapshotFrame(mm_camera_super_buf_t *recvd_frame);
408 int32_t processFaceDetectionResult(cam_face_detection_data_t *fd_data);
409 int32_t processHistogramStats(cam_hist_stats_t &stats_data);
410 int32_t setHistogram(bool histogram_en);
411 int32_t setFaceDetection(bool enabled);
412 int32_t prepareHardwareForSnapshot(int32_t afNeeded);
413 bool needProcessPreviewFrame();
isNoDisplayMode()414 bool isNoDisplayMode() {return mParameters.isNoDisplayMode();};
isZSLMode()415 bool isZSLMode() {return mParameters.isZSLMode();};
isRdiMode()416 bool isRdiMode() {return mParameters.isRdiMode();};
numOfSnapshotsExpected()417 uint8_t numOfSnapshotsExpected() {
418 return mParameters.getNumOfSnapshots();};
isSecureMode()419 bool isSecureMode() {return mParameters.isSecureMode();};
isLongshotEnabled()420 bool isLongshotEnabled() { return mLongshotEnabled; };
isHFRMode()421 bool isHFRMode() {return mParameters.isHfrMode();};
isLiveSnapshot()422 bool isLiveSnapshot() {return m_stateMachine.isRecording();};
setRetroPicture(bool enable)423 void setRetroPicture(bool enable) { bRetroPicture = enable; };
isRetroPicture()424 bool isRetroPicture() {return bRetroPicture; };
isHDRMode()425 bool isHDRMode() {return mParameters.isHDREnabled();};
426 uint8_t getBufNumRequired(cam_stream_type_t stream_type);
427 bool needFDMetadata(qcamera_ch_type_enum_t channel_type);
428 int32_t configureOnlineRotation(QCameraChannel &ch);
429 int32_t declareSnapshotStreams();
430 int32_t unconfigureAdvancedCapture();
431 int32_t configureAdvancedCapture();
432 int32_t configureAFBracketing(bool enable = true);
433 int32_t configureHDRBracketing();
434 int32_t stopAdvancedCapture(QCameraPicChannel *pChannel);
435 int32_t startAdvancedCapture(QCameraPicChannel *pChannel);
436 int32_t configureOptiZoom();
437 int32_t configureStillMore();
438 int32_t configureAEBracketing();
439 int32_t updatePostPreviewParameters();
setOutputImageCount(uint32_t aCount)440 inline void setOutputImageCount(uint32_t aCount) {mOutputCount = aCount;}
getOutputImageCount()441 inline uint32_t getOutputImageCount() {return mOutputCount;}
442 bool processUFDumps(qcamera_jpeg_evt_payload_t *evt);
443 void captureDone();
444 int32_t updateMetadata(metadata_buffer_t *pMetaData);
445
446 int32_t getPPConfig(cam_pp_feature_config_t &pp_config, int curCount);
447 static void camEvtHandle(uint32_t camera_handle,
448 mm_camera_event_t *evt,
449 void *user_data);
450 static void jpegEvtHandle(jpeg_job_status_t status,
451 uint32_t client_hdl,
452 uint32_t jobId,
453 mm_jpeg_output_t *p_buf,
454 void *userdata);
455
456 static void *evtNotifyRoutine(void *data);
457
458 // functions for different data notify cb
459 static void zsl_channel_cb(mm_camera_super_buf_t *recvd_frame, void *userdata);
460 static void capture_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
461 void *userdata);
462 static void postproc_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
463 void *userdata);
464 static void rdi_mode_stream_cb_routine(mm_camera_super_buf_t *frame,
465 QCameraStream *stream,
466 void *userdata);
467 static void nodisplay_preview_stream_cb_routine(mm_camera_super_buf_t *frame,
468 QCameraStream *stream,
469 void *userdata);
470 static void preview_stream_cb_routine(mm_camera_super_buf_t *frame,
471 QCameraStream *stream,
472 void *userdata);
473 static void postview_stream_cb_routine(mm_camera_super_buf_t *frame,
474 QCameraStream *stream,
475 void *userdata);
476 static void video_stream_cb_routine(mm_camera_super_buf_t *frame,
477 QCameraStream *stream,
478 void *userdata);
479 static void snapshot_channel_cb_routine(mm_camera_super_buf_t *frame,
480 void *userdata);
481 static void raw_stream_cb_routine(mm_camera_super_buf_t *frame,
482 QCameraStream *stream,
483 void *userdata);
484 static void preview_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame,
485 QCameraStream * stream,
486 void * userdata);
487 static void snapshot_raw_stream_cb_routine(mm_camera_super_buf_t * super_frame,
488 QCameraStream * stream,
489 void * userdata);
490 static void metadata_stream_cb_routine(mm_camera_super_buf_t *frame,
491 QCameraStream *stream,
492 void *userdata);
493 static void reprocess_stream_cb_routine(mm_camera_super_buf_t *frame,
494 QCameraStream *stream,
495 void *userdata);
496
497 static void releaseCameraMemory(void *data,
498 void *cookie,
499 int32_t cbStatus);
500 static void returnStreamBuffer(void *data,
501 void *cookie,
502 int32_t cbStatus);
503 static void getLogLevel();
504
505 private:
506 camera_device_t mCameraDevice;
507 uint32_t mCameraId;
508 mm_camera_vtbl_t *mCameraHandle;
509 bool mCameraOpened;
510
511 preview_stream_ops_t *mPreviewWindow;
512 QCameraParameters mParameters;
513 int32_t mMsgEnabled;
514 int mStoreMetaDataInFrame;
515
516 camera_notify_callback mNotifyCb;
517 camera_data_callback mDataCb;
518 camera_data_timestamp_callback mDataCbTimestamp;
519 camera_request_memory mGetMemory;
520 void *mCallbackCookie;
521
522 QCameraStateMachine m_stateMachine; // state machine
523 bool m_smThreadActive;
524 QCameraPostProcessor m_postprocessor; // post processor
525 QCameraThermalAdapter &m_thermalAdapter;
526 QCameraCbNotifier m_cbNotifier;
527 QCameraPerfLock m_perfLock;
528 pthread_mutex_t m_lock;
529 pthread_cond_t m_cond;
530 api_result_list *m_apiResultList;
531 QCameraMemoryPool m_memoryPool;
532
533 pthread_mutex_t m_evtLock;
534 pthread_cond_t m_evtCond;
535 qcamera_api_result_t m_evtResult;
536
537 pthread_mutex_t m_parm_lock;
538
539 QCameraChannel *m_channels[QCAMERA_CH_TYPE_MAX]; // array holding channel ptr
540
541 bool m_bPreviewStarted; //flag indicates first preview frame callback is received
542 bool m_bRecordStarted; //flag indicates Recording is started for first time
543
544 // Signifies if ZSL Retro Snapshots are enabled
545 bool bRetroPicture;
546 // Signifies AEC locked during zsl snapshots
547 bool m_bLedAfAecLock;
548 cam_autofocus_state_t m_currentFocusState;
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 {
DeffWorkDeffWork608 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