hwc: Add properties to control hdcp and color range
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos5.git] / libcamera2 / ExynosCameraHWInterface2.h
CommitLineData
c15a6b00
JS
1/*
2**
3** Copyright 2008, The Android Open Source Project
4** Copyright 2012, Samsung Electronics Co. LTD
5**
6** Licensed under the Apache License, Version 2.0 (the "License");
7** you may not use this file except in compliance with the License.
8** You may obtain a copy of the License at
9**
10** http://www.apache.org/licenses/LICENSE-2.0
11**
12** Unless required by applicable law or agreed to in writing, software
13** distributed under the License is distributed on an "AS IS" BASIS,
14** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15** See the License for the specific language governing permissions and
16** limitations under the License.
17*/
18
19/*!
20 * \file ExynosCameraHWInterface2.h
21 * \brief header file for Android Camera API 2.0 HAL
22 * \author Sungjoong Kang(sj3.kang@samsung.com)
13d8c7b4 23 * \date 2012/07/10
c15a6b00
JS
24 *
25 * <b>Revision History: </b>
26 * - 2012/05/31 : Sungjoong Kang(sj3.kang@samsung.com) \n
27 * Initial Release
13d8c7b4
SK
28 *
29 * - 2012/07/10 : Sungjoong Kang(sj3.kang@samsung.com) \n
30 * 2nd Release
31 *
c15a6b00 32 */
13d8c7b4 33
c15a6b00
JS
34#ifndef EXYNOS_CAMERA_HW_INTERFACE_2_H
35#define EXYNOS_CAMERA_HW_INTERFACE_2_H
36
37#include <hardware/camera2.h>
38#include <camera/Camera.h>
39#include <camera/CameraParameters.h>
52f54308 40#include <utils/List.h>
c15a6b00
JS
41#include "SignalDrivenThread.h"
42#include "MetadataConverter.h"
43#include "exynos_v4l2.h"
13d8c7b4
SK
44#include "ExynosRect.h"
45#include "ExynosBuffer.h"
c15a6b00
JS
46#include "videodev2_exynos_camera.h"
47#include "gralloc_priv.h"
13d8c7b4 48#include "ExynosJpegEncoderForCamera.h"
c15a6b00
JS
49#include <fcntl.h>
50#include "fimc-is-metadata.h"
51#include "ion.h"
13d8c7b4
SK
52#include "ExynosExif.h"
53#include "csc.h"
daa1fcd6 54#include "ExynosCamera2.h"
eed7ed1b 55#include "cutils/properties.h"
c15a6b00
JS
56
57namespace android {
58
4aa4d739 59//#define EXYNOS_CAMERA_LOG
2adfa429 60#define ENABLE_FRAME_SYNC
c15a6b00
JS
61#define NODE_PREFIX "/dev/video"
62
63#define NUM_MAX_STREAM_THREAD (5)
1c5e692d 64#define NUM_MAX_REQUEST_MGR_ENTRY (5)
13d8c7b4
SK
65#define NUM_MAX_CAMERA_BUFFERS (16)
66#define NUM_BAYER_BUFFERS (8)
ac8c2060
SK
67#define NUM_SCC_BUFFERS (8)
68#define NUM_SCP_BUFFERS (8)
52f54308 69#define NUM_MIN_SENSOR_QBUF (3)
5506cebf 70#define NUM_MAX_SUBSTREAM (4)
13d8c7b4
SK
71
72#define PICTURE_GSC_NODE_NUM (2)
15fd8231 73#define VIDEO_GSC_NODE_NUM (1)
c15a6b00 74
37e122d5
SK
75#define STREAM_TYPE_DIRECT (0)
76#define STREAM_TYPE_INDIRECT (1)
77
13d8c7b4 78#define SIGNAL_MAIN_REQ_Q_NOT_EMPTY (SIGNAL_THREAD_COMMON_LAST<<1)
5506cebf 79
13d8c7b4
SK
80#define SIGNAL_MAIN_STREAM_OUTPUT_DONE (SIGNAL_THREAD_COMMON_LAST<<3)
81#define SIGNAL_SENSOR_START_REQ_PROCESSING (SIGNAL_THREAD_COMMON_LAST<<4)
5506cebf 82
13d8c7b4 83#define SIGNAL_THREAD_RELEASE (SIGNAL_THREAD_COMMON_LAST<<8)
c15a6b00 84
5506cebf 85#define SIGNAL_STREAM_REPROCESSING_START (SIGNAL_THREAD_COMMON_LAST<<14)
c15a6b00
JS
86#define SIGNAL_STREAM_DATA_COMING (SIGNAL_THREAD_COMMON_LAST<<15)
87
0f26b20f
SK
88#define NO_TRANSITION (0)
89#define HAL_AFSTATE_INACTIVE (1)
90#define HAL_AFSTATE_NEEDS_COMMAND (2)
91#define HAL_AFSTATE_STARTED (3)
92#define HAL_AFSTATE_SCANNING (4)
93#define HAL_AFSTATE_LOCKED (5)
94#define HAL_AFSTATE_FAILED (6)
95#define HAL_AFSTATE_NEEDS_DETERMINATION (7)
96#define HAL_AFSTATE_PASSIVE_FOCUSED (8)
13d8c7b4 97
5506cebf
SK
98#define STREAM_ID_PREVIEW (0)
99#define STREAM_MASK_PREVIEW (1<<STREAM_ID_PREVIEW)
100#define STREAM_ID_RECORD (1)
101#define STREAM_MASK_RECORD (1<<STREAM_ID_RECORD)
102#define STREAM_ID_PRVCB (2)
103#define STREAM_MASK_PRVCB (1<<STREAM_ID_PRVCB)
104#define STREAM_ID_JPEG (4)
105#define STREAM_MASK_JPEG (1<<STREAM_ID_JPEG)
106#define STREAM_ID_ZSL (5)
107#define STREAM_MASK_ZSL (1<<STREAM_ID_ZSL)
108
109#define STREAM_ID_JPEG_REPROCESS (8)
110#define STREAM_ID_LAST STREAM_ID_JPEG_REPROCESS
111
112#define MASK_OUTPUT_SCP (STREAM_MASK_PREVIEW|STREAM_MASK_RECORD|STREAM_MASK_PRVCB)
113#define MASK_OUTPUT_SCC (STREAM_MASK_JPEG|STREAM_MASK_ZSL)
114
115#define SUBSTREAM_TYPE_NONE (0)
116#define SUBSTREAM_TYPE_JPEG (1)
117#define SUBSTREAM_TYPE_RECORD (2)
118#define SUBSTREAM_TYPE_PRVCB (3)
119#define FLASH_STABLE_WAIT_TIMEOUT (10)
120
041f38de
SK
121#define SIG_WAITING_TICK (5000)
122
4aa4d739
C
123#ifdef EXYNOS_CAMERA_LOG
124#define CAM_LOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
125#define CAM_LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
126#define CAM_LOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
127#define CAM_LOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
128#else
129#define CAM_LOGV(...) ((void)0)
130#define CAM_LOGD(...) ((void)0)
131#define CAM_LOGW(...) ((void)0)
132#define CAM_LOGE(...) ((void)0)
133#endif
134
c15a6b00
JS
135enum sensor_name {
136 SENSOR_NAME_S5K3H2 = 1,
137 SENSOR_NAME_S5K6A3 = 2,
138 SENSOR_NAME_S5K4E5 = 3,
139 SENSOR_NAME_S5K3H7 = 4,
140 SENSOR_NAME_CUSTOM = 5,
141 SENSOR_NAME_END
142};
143
15fd8231
SK
144enum is_subscenario_id {
145 ISS_SUB_SCENARIO_STILL,
146 ISS_SUB_SCENARIO_VIDEO,
147 ISS_SUB_SCENARIO_SCENE1,
148 ISS_SUB_SCENARIO_SCENE2,
149 ISS_SUB_SCENARIO_SCENE3,
150 ISS_SUB_END
151};
c15a6b00 152
2d5e6ec2
SK
153int SUPPORT_THUMBNAIL_REAR_SIZE[][2] =
154{
155 {160, 120},
156 {160, 90},
157 {144, 96}
158};
159
160int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] =
161{
162 {160, 120},
163 {160, 160},
164 {160, 90},
165 {144, 96}
166};
167
e117f756
YJ
168enum is_set_flash_command_state {
169 IS_FLASH_STATE_NONE = 0,
170 IS_FLASH_STATE_ON = 1,
171 IS_FLASH_STATE_ON_WAIT,
172 IS_FLASH_STATE_ON_DONE,
173 IS_FLASH_STATE_AUTO_AE_AWB_LOCK,
174 IS_FLASH_STATE_AE_AWB_LOCK_WAIT,
175 IS_FLASH_STATE_AUTO_WAIT,
176 IS_FLASH_STATE_AUTO_DONE,
177 IS_FLASH_STATE_AUTO_OFF,
178 IS_FLASH_STATE_CAPTURE,
179 IS_FLASH_STATE_CAPTURE_WAIT,
180 IS_FLASH_STATE_CAPTURE_JPEG,
181 IS_FLASH_STATE_CAPTURE_END,
182 IS_FALSH_STATE_MAX
6f19b6cf
YJ
183};
184
53f62ad9
YJ
185enum is_set_command_state {
186 IS_COMMAND_NONE = 0,
187 IS_COMMAND_EXECUTION,
188 IS_COMMAND_CLEAR,
189 IS_COMMAND_MAX
190};
191
c15a6b00
JS
192typedef struct node_info {
193 int fd;
194 int width;
195 int height;
196 int format;
197 int planes;
198 int buffers;
c15a6b00
JS
199 enum v4l2_memory memory;
200 enum v4l2_buf_type type;
be494d19 201 ExynosBuffer buffer[NUM_MAX_CAMERA_BUFFERS];
15fd8231 202 int status;
c15a6b00
JS
203} node_info_t;
204
205
206typedef struct camera_hw_info {
207 int sensor_id;
208
209 node_info_t sensor;
13d8c7b4
SK
210 node_info_t isp;
211 node_info_t capture;
5506cebf 212 node_info_t scp;
13d8c7b4
SK
213
214 /*shot*/ // temp
215 struct camera2_shot_ext dummy_shot;
c15a6b00 216
c15a6b00
JS
217} camera_hw_info_t;
218
13d8c7b4 219typedef enum request_entry_status {
c15a6b00
JS
220 EMPTY,
221 REGISTERED,
be494d19 222 REQUESTED,
2adfa429 223 CAPTURED,
f9a06609
SK
224 METADONE,
225 COMPLETED
c15a6b00
JS
226} request_entry_status_t;
227
228typedef struct request_manager_entry {
13d8c7b4 229 request_entry_status_t status;
13d8c7b4 230 camera_metadata_t *original_request;
be494d19 231 struct camera2_shot_ext internal_shot;
13d8c7b4 232 int output_stream_count;
c15a6b00
JS
233} request_manager_entry_t;
234
9a710a45 235// structure related to a specific function of camera
4a9565ae
YJ
236typedef struct af_control_info {
237 int m_afTriggerTimeOut;
238} ctl_af_info_t;
239
9a710a45
YJ
240typedef struct flash_control_info {
241 // UI flash mode indicator
242 enum aa_aemode i_flashMode;
243 // AF flash
244 bool m_afFlashDoneFlg;
9a710a45
YJ
245 // Capture flash
246 bool m_flashEnableFlg;
9a710a45
YJ
247 int m_flashFrameCount;
248 int m_flashCnt;
249 int m_flashTimeOut;
caea49e6
YJ
250 // Flash decision
251 // At flash auto mode only : 1 -> flash is needed, 0 -> normal case
252 bool m_flashDecisionResult;
253 // torch indicator. this will be replaced by flashMode meta
254 bool m_flashTorchMode;
e117f756
YJ
255 // for precapture metering
256 int m_precaptureState;
257 int m_precaptureTriggerId;
9a710a45
YJ
258} ctl_flash_info_t;
259
73f5ad60
YJ
260typedef struct ae_control_info {
261 // pre-capture notification state
262 enum ae_state aeStateNoti;
263} ctl_ae_info_t;
264
275c9744
YJ
265typedef struct scene_control_info {
266 // pre-capture notification state
267 enum aa_scene_mode prevSceneMode;
268} ctl_scene_info_t;
269
9a710a45
YJ
270typedef struct request_control_info {
271 ctl_flash_info_t flash;
73f5ad60 272 ctl_ae_info_t ae;
4a9565ae 273 ctl_af_info_t af;
275c9744 274 ctl_scene_info_t scene;
9a710a45
YJ
275} ctl_request_info_t;
276
c15a6b00
JS
277class RequestManager {
278public:
279 RequestManager(SignalDrivenThread* main_thread);
280 ~RequestManager();
2adfa429 281 void ResetEntry();
c15a6b00
JS
282 int GetNumEntries();
283 bool IsRequestQueueFull();
13d8c7b4
SK
284
285 void RegisterRequest(camera_metadata_t *new_request);
286 void DeregisterRequest(camera_metadata_t **deregistered_request);
287 bool PrepareFrame(size_t *num_entries, size_t *frame_size,
0f26b20f
SK
288 camera_metadata_t **prepared_frame, int afState);
289 int MarkProcessingRequest(ExynosBuffer * buf, int *afMode);
2adfa429 290 void NotifyStreamOutput(int frameCnt);
ad37861e 291 void ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext);
13d8c7b4 292 void CheckCompleted(int index);
53f62ad9 293 void UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt, ctl_request_info_t *ctl_info);
9dd63e1f 294 void RegisterTimestamp(int frameCnt, nsecs_t *frameTime);
5506cebf
SK
295 nsecs_t GetTimestampByFrameCnt(int frameCnt);
296 nsecs_t GetTimestamp(int index);
2f4d175d
SK
297 uint8_t GetOutputStreamByFrameCnt(int frameCnt);
298 uint8_t GetOutputStream(int index);
69d1e6e9
SK
299 camera2_shot_ext * GetInternalShotExtByFrameCnt(int frameCnt);
300 camera2_shot_ext * GetInternalShotExt(int index);
9dd63e1f 301 int FindFrameCnt(struct camera2_shot_ext * shot_ext);
5c88d1f2 302 bool IsVdisEnable(void);
9dd63e1f 303 int FindEntryIndexByFrameCnt(int frameCnt);
b5237e6b
SK
304 void Dump(void);
305 int GetNextIndex(int index);
f9a06609 306 int GetPrevIndex(int index);
b5237e6b
SK
307 void SetDefaultParameters(int cropX);
308 void SetInitialSkip(int count);
ad37861e 309 int GetSkipCnt();
f9a06609 310 int GetCompletedIndex();
041f38de
SK
311 void pushSensorQ(int index);
312 int popSensorQ();
313 void releaseSensorQ();
c15a6b00
JS
314private:
315
316 MetadataConverter *m_metadataConverter;
317 SignalDrivenThread *m_mainThread;
318 int m_numOfEntries;
319 int m_entryInsertionIndex;
320 int m_entryProcessingIndex;
321 int m_entryFrameOutputIndex;
322 request_manager_entry_t entries[NUM_MAX_REQUEST_MGR_ENTRY];
13d8c7b4 323 int m_completedIndex;
c15a6b00
JS
324
325 Mutex m_requestMutex;
326
327 //TODO : alloc dynamically
328 char m_tempFrameMetadataBuf[2000];
329 camera_metadata_t *m_tempFrameMetadata;
9dd63e1f 330
b5237e6b 331 int m_sensorPipelineSkipCnt;
9dd63e1f 332 int m_cropX;
041f38de 333 int m_lastCompletedFrameCnt;
2bdec060
SK
334 int m_lastAeMode;
335 int m_lastAaMode;
336 int m_lastAwbMode;
337 int m_lastAeComp;
5c88d1f2 338 bool m_vdisBubbleEn;
5506cebf 339 nsecs_t m_lastTimeStamp;
52f54308 340 List<int> m_sensorQ;
c15a6b00
JS
341};
342
9dd63e1f
SK
343
344typedef struct bayer_buf_entry {
345 int status;
346 int reqFrameCnt;
347 nsecs_t timeStamp;
348} bayer_buf_entry_t;
349
350
351class BayerBufManager {
352public:
353 BayerBufManager();
354 ~BayerBufManager();
355 int GetIndexForSensorEnqueue();
356 int MarkSensorEnqueue(int index);
357 int MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp);
358 int GetIndexForIspEnqueue(int *reqFrameCnt);
359 int GetIndexForIspDequeue(int *reqFrameCnt);
360 int MarkIspEnqueue(int index);
361 int MarkIspDequeue(int index);
362 int GetNumOnSensor();
363 int GetNumOnHalFilled();
364 int GetNumOnIsp();
365
366private:
367 int GetNextIndex(int index);
368
369 int sensorEnqueueHead;
370 int sensorDequeueHead;
371 int ispEnqueueHead;
372 int ispDequeueHead;
373 int numOnSensor;
374 int numOnIsp;
375 int numOnHalFilled;
376 int numOnHalEmpty;
377
378 bayer_buf_entry_t entries[NUM_BAYER_BUFFERS];
379};
380
381
13d8c7b4
SK
382#define NOT_AVAILABLE (0)
383#define REQUIRES_DQ_FROM_SVC (1)
384#define ON_DRIVER (2)
385#define ON_HAL (3)
386#define ON_SERVICE (4)
387
388#define BAYER_NOT_AVAILABLE (0)
389#define BAYER_ON_SENSOR (1)
390#define BAYER_ON_HAL_FILLED (2)
391#define BAYER_ON_ISP (3)
392#define BAYER_ON_SERVICE (4)
393#define BAYER_ON_HAL_EMPTY (5)
394
395typedef struct stream_parameters {
5506cebf
SK
396 uint32_t width;
397 uint32_t height;
398 int format;
c15a6b00
JS
399 const camera2_stream_ops_t* streamOps;
400 uint32_t usage;
13d8c7b4
SK
401 int numHwBuffers;
402 int numSvcBuffers;
be494d19 403 int numOwnSvcBuffers;
5506cebf 404 int planes;
feb7df4c 405 int metaPlanes;
be494d19 406 int numSvcBufsInHal;
13d8c7b4
SK
407 buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
408 ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS];
5506cebf 409 ExynosBuffer metaBuffers[NUM_MAX_CAMERA_BUFFERS];
13d8c7b4 410 int svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
5506cebf
SK
411 int bufIndex;
412 node_info_t *node;
413 int minUndequedBuffer;
bf96172c 414 bool needsIonMap;
c15a6b00
JS
415} stream_parameters_t;
416
5506cebf
SK
417typedef struct substream_parameters {
418 int type;
419 uint32_t width;
420 uint32_t height;
421 int format;
9dd63e1f
SK
422 const camera2_stream_ops_t* streamOps;
423 uint32_t usage;
424 int numSvcBuffers;
be494d19 425 int numOwnSvcBuffers;
74d78ebe
SK
426 int internalFormat;
427 int internalPlanes;
74d78ebe
SK
428 int svcPlanes;
429 buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS];
430 ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS];
431 int svcBufStatus[NUM_MAX_CAMERA_BUFFERS];
432 int svcBufIndex;
433 int numSvcBufsInHal;
5506cebf
SK
434 bool needBufferInit;
435 int minUndequedBuffer;
436} substream_parameters_t;
437
438typedef struct substream_entry {
439 int priority;
440 int streamId;
441} substream_entry_t;
74d78ebe 442
c15a6b00
JS
443class ExynosCameraHWInterface2 : public virtual RefBase {
444public:
6044e509 445 ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid);
c15a6b00
JS
446 virtual ~ExynosCameraHWInterface2();
447
448 virtual void release();
13d8c7b4 449
c15a6b00
JS
450 inline int getCameraId() const;
451
452 virtual int setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops);
453 virtual int notifyRequestQueueNotEmpty();
454 virtual int setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops);
455 virtual int getInProgressCount();
456 virtual int flushCapturesInProgress();
457 virtual int constructDefaultRequest(int request_template, camera_metadata_t **request);
13d8c7b4 458 virtual int allocateStream(uint32_t width, uint32_t height,
c15a6b00
JS
459 int format, const camera2_stream_ops_t *stream_ops,
460 uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers);
461 virtual int registerStreamBuffers(uint32_t stream_id, int num_buffers, buffer_handle_t *buffers);
462 virtual int releaseStream(uint32_t stream_id);
463 virtual int allocateReprocessStream(uint32_t width, uint32_t height,
464 uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops,
465 uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers);
5506cebf
SK
466 virtual int allocateReprocessStreamFromStream(uint32_t output_stream_id,
467 const camera2_stream_in_ops_t *reprocess_stream_ops, uint32_t *stream_id);
c15a6b00
JS
468 virtual int releaseReprocessStream(uint32_t stream_id);
469 virtual int triggerAction(uint32_t trigger_id, int ext1, int ext2);
470 virtual int setNotifyCallback(camera2_notify_callback notify_cb, void *user);
471 virtual int getMetadataVendorTagOps(vendor_tag_query_ops_t **ops);
472 virtual int dump(int fd);
473private:
13d8c7b4
SK
474class MainThread : public SignalDrivenThread {
475 ExynosCameraHWInterface2 *mHardware;
476 public:
477 MainThread(ExynosCameraHWInterface2 *hw):
478 SignalDrivenThread(),
053d38cf 479 mHardware(hw) { }
13d8c7b4 480 ~MainThread();
13d8c7b4 481 void threadFunctionInternal()
053d38cf 482 {
13d8c7b4
SK
483 mHardware->m_mainThreadFunc(this);
484 return;
485 }
486 void release(void);
15fd8231 487 bool m_releasing;
13d8c7b4 488 };
9dd63e1f 489
c15a6b00
JS
490 class SensorThread : public SignalDrivenThread {
491 ExynosCameraHWInterface2 *mHardware;
492 public:
493 SensorThread(ExynosCameraHWInterface2 *hw):
053d38cf 494 SignalDrivenThread(),
5506cebf 495 mHardware(hw) { }
13d8c7b4 496 ~SensorThread();
13d8c7b4 497 void threadFunctionInternal() {
c15a6b00
JS
498 mHardware->m_sensorThreadFunc(this);
499 return;
500 }
9dd63e1f 501 void release(void);
c15a6b00 502 //private:
15fd8231 503 bool m_releasing;
c15a6b00
JS
504 };
505
506 class StreamThread : public SignalDrivenThread {
507 ExynosCameraHWInterface2 *mHardware;
508 public:
509 StreamThread(ExynosCameraHWInterface2 *hw, uint8_t new_index):
053d38cf 510 SignalDrivenThread(),
c15a6b00
JS
511 mHardware(hw),
512 m_index(new_index) { }
13d8c7b4 513 ~StreamThread();
13d8c7b4 514 void threadFunctionInternal() {
c15a6b00
JS
515 mHardware->m_streamThreadFunc(this);
516 return;
517 }
13d8c7b4 518 void setParameter(stream_parameters_t * new_parameters);
5506cebf
SK
519 status_t attachSubStream(int stream_id, int priority);
520 status_t detachSubStream(int stream_id);
13d8c7b4
SK
521 void release(void);
522 int findBufferIndex(void * bufAddr);
5506cebf 523 int findBufferIndex(buffer_handle_t * bufHandle);
c15a6b00 524
13d8c7b4 525 uint8_t m_index;
9dd63e1f 526 bool m_activated;
13d8c7b4
SK
527 //private:
528 stream_parameters_t m_parameters;
9dd63e1f 529 stream_parameters_t *m_tempParameters;
5506cebf 530 substream_entry_t m_attachedSubStreams[NUM_MAX_SUBSTREAM];
13d8c7b4 531 bool m_isBufferInit;
b5237e6b 532 bool m_releasing;
5506cebf
SK
533 int streamType;
534 int m_numRegisteredStream;
13d8c7b4 535 };
c15a6b00
JS
536
537 sp<MainThread> m_mainThread;
538 sp<SensorThread> m_sensorThread;
13d8c7b4 539 sp<StreamThread> m_streamThreads[NUM_MAX_STREAM_THREAD];
5506cebf 540 substream_parameters_t m_subStreams[STREAM_ID_LAST+1];
13d8c7b4
SK
541
542
9dd63e1f 543
c15a6b00 544 RequestManager *m_requestManager;
9dd63e1f 545 BayerBufManager *m_BayerManager;
daa1fcd6 546 ExynosCamera2 *m_camera2;
c15a6b00
JS
547
548 void m_mainThreadFunc(SignalDrivenThread * self);
549 void m_sensorThreadFunc(SignalDrivenThread * self);
c15a6b00 550 void m_streamThreadFunc(SignalDrivenThread * self);
13d8c7b4
SK
551 void m_streamThreadInitialize(SignalDrivenThread * self);
552
5506cebf
SK
553 void m_streamFunc_direct(SignalDrivenThread *self);
554 void m_streamFunc_indirect(SignalDrivenThread *self);
86646da4
SK
555
556 void m_streamBufferInit(SignalDrivenThread *self);
557
5506cebf
SK
558 int m_runSubStreamFunc(StreamThread *selfThread, ExynosBuffer *srcImageBuf,
559 int stream_id, nsecs_t frameTimeStamp);
560 int m_jpegCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
561 int m_recordCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
562 int m_prvcbCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp);
13d8c7b4
SK
563 void m_getAlignedYUVSize(int colorFormat, int w, int h,
564 ExynosBuffer *buf);
565 bool m_getRatioSize(int src_w, int src_h,
566 int dst_w, int dst_h,
567 int *crop_x, int *crop_y,
568 int *crop_w, int *crop_h,
569 int zoom);
570 int createIonClient(ion_client ionClient);
571 int deleteIonClient(ion_client ionClient);
13d8c7b4
SK
572
573 int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum);
181e425e 574 int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag);
13d8c7b4
SK
575 void freeCameraMemory(ExynosBuffer *buf, int iMemoryNum);
576 void initCameraMemory(ExynosBuffer *buf, int iMemoryNum);
577
578 void DumpInfoWithShot(struct camera2_shot_ext * shot_ext);
2d5e6ec2 579 bool m_checkThumbnailSize(int w, int h);
13d8c7b4
SK
580 bool yuv2Jpeg(ExynosBuffer *yuvBuf,
581 ExynosBuffer *jpegBuf,
582 ExynosRect *rect);
5506cebf 583 int InitializeISPChain();
ad37861e 584 void StartISP();
5506cebf 585 void StartSCCThread(bool threadExists);
0f26b20f
SK
586 int GetAfState();
587 void SetAfMode(enum aa_afmode afMode);
8e2c2fdb 588 void OnAfTriggerStart(int id);
0f26b20f
SK
589 void OnAfTrigger(int id);
590 void OnAfTriggerAutoMacro(int id);
591 void OnAfTriggerCAFPicture(int id);
592 void OnAfTriggerCAFVideo(int id);
e117f756 593 void OnPrecaptureMeteringTriggerStart(int id);
0f26b20f
SK
594 void OnAfCancel(int id);
595 void OnAfCancelAutoMacro(int id);
596 void OnAfCancelCAFPicture(int id);
597 void OnAfCancelCAFVideo(int id);
73f5ad60
YJ
598 void OnPrecaptureMeteringNotificationISP();
599 void OnPrecaptureMeteringNotificationSensor();
0f26b20f
SK
600 void OnAfNotification(enum aa_afstate noti);
601 void OnAfNotificationAutoMacro(enum aa_afstate noti);
602 void OnAfNotificationCAFPicture(enum aa_afstate noti);
603 void OnAfNotificationCAFVideo(enum aa_afstate noti);
604 void SetAfStateForService(int newState);
605 int GetAfStateForService();
13d8c7b4 606 exif_attribute_t mExifInfo;
eed7ed1b
SK
607 void m_setExifFixedAttribute(void);
608 void m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect,
48728d49 609 camera2_shot_ext *currentEntry);
e117f756
YJ
610 void m_preCaptureSetter(struct camera2_shot_ext * shot_ext);
611 void m_preCaptureListenerSensor(struct camera2_shot_ext * shot_ext);
612 void m_preCaptureListenerISP(struct camera2_shot_ext * shot_ext);
cdd53a9f 613 void m_preCaptureAeState(struct camera2_shot_ext * shot_ext);
4a9565ae 614 void m_updateAfRegion(struct camera2_shot_ext * shot_ext);
8a3fc5dd 615 void m_afTrigger(struct camera2_shot_ext * shot_ext, int mode);
13d8c7b4 616 void *m_exynosPictureCSC;
9dd63e1f 617 void *m_exynosVideoCSC;
13d8c7b4 618
c15a6b00
JS
619
620 camera2_request_queue_src_ops_t *m_requestQueueOps;
621 camera2_frame_queue_dst_ops_t *m_frameQueueOps;
622 camera2_notify_callback m_notifyCb;
623 void *m_callbackCookie;
624
625 int m_numOfRemainingReqInSvc;
626 bool m_isRequestQueuePending;
13d8c7b4
SK
627 bool m_isRequestQueueNull;
628 camera2_device_t *m_halDevice;
629 static gralloc_module_t const* m_grallocHal;
c15a6b00 630
c15a6b00 631
13d8c7b4 632 camera_hw_info_t m_camera_info;
c15a6b00
JS
633
634 ion_client m_ionCameraClient;
635
ad37861e 636 bool m_isIspStarted;
13d8c7b4 637
ad37861e 638 int m_need_streamoff;
90e439c1
SK
639 ExynosBuffer m_sccLocalBuffer[NUM_MAX_CAMERA_BUFFERS];
640 bool m_sccLocalBufferValid;
13d8c7b4
SK
641
642 int indexToQueue[3+1];
13d8c7b4
SK
643
644 bool m_scp_flushing;
645 bool m_closing;
646 ExynosBuffer m_resizeBuf;
2f4d175d 647#ifndef ENABLE_FRAME_SYNC
5506cebf 648 int m_currentOutputStreams;
2f4d175d 649#endif
5506cebf 650 int m_currentReprocessOutStreams;
74d78ebe 651 ExynosBuffer m_previewCbBuf;
9dd63e1f
SK
652 int m_cameraId;
653 bool m_scp_closing;
654 bool m_scp_closed;
15fd8231 655 bool m_wideAspect;
8e2c2fdb 656 uint32_t lastAfRegion[4];
308291de 657 float m_zoomRatio;
ad37861e 658
5c88d1f2
C
659 int m_vdisBubbleCnt;
660 int m_vdisDupFrame;
5c88d1f2 661
5506cebf 662 mutable Mutex m_qbufLock;
32cf9401
SK
663 mutable Mutex m_jpegEncoderLock;
664 int m_jpegEncodingCount;
ad37861e 665
f9a06609 666 bool m_scpForceSuspended;
0f26b20f
SK
667 int m_afState;
668 int m_afTriggerId;
669 enum aa_afmode m_afMode;
670 enum aa_afmode m_afMode2;
671 bool m_IsAfModeUpdateRequired;
672 bool m_IsAfTriggerRequired;
673 bool m_IsAfLockRequired;
674 int m_serviceAfState;
36c106c9 675 bool m_AfHwStateFailed;
8e2c2fdb
SK
676 int m_afPendingTriggerId;
677 int m_afModeWaitingCnt;
48728d49 678 struct camera2_shot_ext m_jpegMetadata;
b55ed664
SK
679 int m_scpOutputSignalCnt;
680 int m_scpOutputImageCnt;
a15b4e3f
SK
681 int m_nightCaptureCnt;
682 int m_nightCaptureFrameCnt;
572470e2 683 int m_lastSceneMode;
2d5e6ec2
SK
684 int m_thumbNailW;
685 int m_thumbNailH;
5506cebf
SK
686 int m_reprocessStreamId;
687 const camera2_stream_in_ops_t * m_reprocessOps;
688 int m_reprocessOutputStreamId;
689 int m_reprocessingFrameCnt;
9a710a45 690 ctl_request_info_t m_ctlInfo;
c15a6b00
JS
691};
692
693}; // namespace android
694
695#endif