Commit | Line | Data |
---|---|---|
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 | |
57 | namespace 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) | |
52f54308 | 64 | #define NUM_MAX_REQUEST_MGR_ENTRY (4) |
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 | ||
4aa4d739 C |
121 | #ifdef EXYNOS_CAMERA_LOG |
122 | #define CAM_LOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) | |
123 | #define CAM_LOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) | |
124 | #define CAM_LOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) | |
125 | #define CAM_LOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) | |
126 | #else | |
127 | #define CAM_LOGV(...) ((void)0) | |
128 | #define CAM_LOGD(...) ((void)0) | |
129 | #define CAM_LOGW(...) ((void)0) | |
130 | #define CAM_LOGE(...) ((void)0) | |
131 | #endif | |
132 | ||
c15a6b00 JS |
133 | enum sensor_name { |
134 | SENSOR_NAME_S5K3H2 = 1, | |
135 | SENSOR_NAME_S5K6A3 = 2, | |
136 | SENSOR_NAME_S5K4E5 = 3, | |
137 | SENSOR_NAME_S5K3H7 = 4, | |
138 | SENSOR_NAME_CUSTOM = 5, | |
139 | SENSOR_NAME_END | |
140 | }; | |
141 | ||
15fd8231 SK |
142 | enum is_subscenario_id { |
143 | ISS_SUB_SCENARIO_STILL, | |
144 | ISS_SUB_SCENARIO_VIDEO, | |
145 | ISS_SUB_SCENARIO_SCENE1, | |
146 | ISS_SUB_SCENARIO_SCENE2, | |
147 | ISS_SUB_SCENARIO_SCENE3, | |
148 | ISS_SUB_END | |
149 | }; | |
c15a6b00 | 150 | |
2d5e6ec2 SK |
151 | int SUPPORT_THUMBNAIL_REAR_SIZE[][2] = |
152 | { | |
153 | {160, 120}, | |
154 | {160, 90}, | |
155 | {144, 96} | |
156 | }; | |
157 | ||
158 | int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] = | |
159 | { | |
160 | {160, 120}, | |
161 | {160, 160}, | |
162 | {160, 90}, | |
163 | {144, 96} | |
164 | }; | |
165 | ||
e117f756 YJ |
166 | enum is_set_flash_command_state { |
167 | IS_FLASH_STATE_NONE = 0, | |
168 | IS_FLASH_STATE_ON = 1, | |
169 | IS_FLASH_STATE_ON_WAIT, | |
170 | IS_FLASH_STATE_ON_DONE, | |
171 | IS_FLASH_STATE_AUTO_AE_AWB_LOCK, | |
172 | IS_FLASH_STATE_AE_AWB_LOCK_WAIT, | |
173 | IS_FLASH_STATE_AUTO_WAIT, | |
174 | IS_FLASH_STATE_AUTO_DONE, | |
175 | IS_FLASH_STATE_AUTO_OFF, | |
176 | IS_FLASH_STATE_CAPTURE, | |
177 | IS_FLASH_STATE_CAPTURE_WAIT, | |
178 | IS_FLASH_STATE_CAPTURE_JPEG, | |
179 | IS_FLASH_STATE_CAPTURE_END, | |
180 | IS_FALSH_STATE_MAX | |
6f19b6cf YJ |
181 | }; |
182 | ||
53f62ad9 YJ |
183 | enum is_set_command_state { |
184 | IS_COMMAND_NONE = 0, | |
185 | IS_COMMAND_EXECUTION, | |
186 | IS_COMMAND_CLEAR, | |
187 | IS_COMMAND_MAX | |
188 | }; | |
189 | ||
c15a6b00 JS |
190 | typedef struct node_info { |
191 | int fd; | |
192 | int width; | |
193 | int height; | |
194 | int format; | |
195 | int planes; | |
196 | int buffers; | |
c15a6b00 JS |
197 | enum v4l2_memory memory; |
198 | enum v4l2_buf_type type; | |
be494d19 | 199 | ExynosBuffer buffer[NUM_MAX_CAMERA_BUFFERS]; |
15fd8231 | 200 | int status; |
c15a6b00 JS |
201 | } node_info_t; |
202 | ||
203 | ||
204 | typedef struct camera_hw_info { | |
205 | int sensor_id; | |
206 | ||
207 | node_info_t sensor; | |
13d8c7b4 SK |
208 | node_info_t isp; |
209 | node_info_t capture; | |
5506cebf | 210 | node_info_t scp; |
13d8c7b4 SK |
211 | |
212 | /*shot*/ // temp | |
213 | struct camera2_shot_ext dummy_shot; | |
c15a6b00 | 214 | |
c15a6b00 JS |
215 | } camera_hw_info_t; |
216 | ||
13d8c7b4 | 217 | typedef enum request_entry_status { |
c15a6b00 JS |
218 | EMPTY, |
219 | REGISTERED, | |
be494d19 | 220 | REQUESTED, |
2adfa429 JS |
221 | CAPTURED, |
222 | METADONE | |
c15a6b00 JS |
223 | } request_entry_status_t; |
224 | ||
225 | typedef struct request_manager_entry { | |
13d8c7b4 | 226 | request_entry_status_t status; |
13d8c7b4 | 227 | camera_metadata_t *original_request; |
be494d19 | 228 | struct camera2_shot_ext internal_shot; |
13d8c7b4 | 229 | int output_stream_count; |
c15a6b00 JS |
230 | } request_manager_entry_t; |
231 | ||
9a710a45 YJ |
232 | // structure related to a specific function of camera |
233 | typedef struct flash_control_info { | |
234 | // UI flash mode indicator | |
235 | enum aa_aemode i_flashMode; | |
236 | // AF flash | |
237 | bool m_afFlashDoneFlg; | |
9a710a45 YJ |
238 | // Capture flash |
239 | bool m_flashEnableFlg; | |
9a710a45 YJ |
240 | int m_flashFrameCount; |
241 | int m_flashCnt; | |
242 | int m_flashTimeOut; | |
caea49e6 YJ |
243 | // Flash decision |
244 | // At flash auto mode only : 1 -> flash is needed, 0 -> normal case | |
245 | bool m_flashDecisionResult; | |
246 | // torch indicator. this will be replaced by flashMode meta | |
247 | bool m_flashTorchMode; | |
e117f756 YJ |
248 | // for precapture metering |
249 | int m_precaptureState; | |
250 | int m_precaptureTriggerId; | |
9a710a45 YJ |
251 | } ctl_flash_info_t; |
252 | ||
53f62ad9 YJ |
253 | typedef struct awb_control_info { |
254 | // UI awb mode indicator | |
255 | enum aa_awbmode i_awbMode; | |
53f62ad9 YJ |
256 | } ctl_awb_info_t; |
257 | ||
73f5ad60 YJ |
258 | typedef struct ae_control_info { |
259 | // pre-capture notification state | |
260 | enum ae_state aeStateNoti; | |
261 | } ctl_ae_info_t; | |
262 | ||
9a710a45 YJ |
263 | typedef struct request_control_info { |
264 | ctl_flash_info_t flash; | |
53f62ad9 | 265 | ctl_awb_info_t awb; |
73f5ad60 | 266 | ctl_ae_info_t ae; |
9a710a45 YJ |
267 | } ctl_request_info_t; |
268 | ||
c15a6b00 JS |
269 | class RequestManager { |
270 | public: | |
271 | RequestManager(SignalDrivenThread* main_thread); | |
272 | ~RequestManager(); | |
2adfa429 | 273 | void ResetEntry(); |
c15a6b00 JS |
274 | int GetNumEntries(); |
275 | bool IsRequestQueueFull(); | |
13d8c7b4 SK |
276 | |
277 | void RegisterRequest(camera_metadata_t *new_request); | |
278 | void DeregisterRequest(camera_metadata_t **deregistered_request); | |
279 | bool PrepareFrame(size_t *num_entries, size_t *frame_size, | |
0f26b20f SK |
280 | camera_metadata_t **prepared_frame, int afState); |
281 | int MarkProcessingRequest(ExynosBuffer * buf, int *afMode); | |
2adfa429 | 282 | void NotifyStreamOutput(int frameCnt); |
ad37861e | 283 | void ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext); |
13d8c7b4 | 284 | void CheckCompleted(int index); |
53f62ad9 | 285 | void UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt, ctl_request_info_t *ctl_info); |
9dd63e1f | 286 | void RegisterTimestamp(int frameCnt, nsecs_t *frameTime); |
5506cebf SK |
287 | nsecs_t GetTimestampByFrameCnt(int frameCnt); |
288 | nsecs_t GetTimestamp(int index); | |
2f4d175d SK |
289 | uint8_t GetOutputStreamByFrameCnt(int frameCnt); |
290 | uint8_t GetOutputStream(int index); | |
9dd63e1f | 291 | int FindFrameCnt(struct camera2_shot_ext * shot_ext); |
5c88d1f2 C |
292 | #ifdef VDIS_ENABLE |
293 | bool IsVdisEnable(void); | |
294 | #endif | |
9dd63e1f | 295 | int FindEntryIndexByFrameCnt(int frameCnt); |
b5237e6b SK |
296 | void Dump(void); |
297 | int GetNextIndex(int index); | |
298 | void SetDefaultParameters(int cropX); | |
299 | void SetInitialSkip(int count); | |
ad37861e SK |
300 | int GetSkipCnt(); |
301 | void SetFrameIndex(int index); | |
302 | int GetFrameIndex(); | |
52f54308 SK |
303 | void pushSensorQ(int index); |
304 | int popSensorQ(); | |
305 | void releaseSensorQ(); | |
c15a6b00 JS |
306 | private: |
307 | ||
308 | MetadataConverter *m_metadataConverter; | |
309 | SignalDrivenThread *m_mainThread; | |
310 | int m_numOfEntries; | |
311 | int m_entryInsertionIndex; | |
312 | int m_entryProcessingIndex; | |
313 | int m_entryFrameOutputIndex; | |
314 | request_manager_entry_t entries[NUM_MAX_REQUEST_MGR_ENTRY]; | |
13d8c7b4 | 315 | int m_completedIndex; |
c15a6b00 JS |
316 | |
317 | Mutex m_requestMutex; | |
318 | ||
319 | //TODO : alloc dynamically | |
320 | char m_tempFrameMetadataBuf[2000]; | |
321 | camera_metadata_t *m_tempFrameMetadata; | |
9dd63e1f | 322 | |
b5237e6b | 323 | int m_sensorPipelineSkipCnt; |
9dd63e1f | 324 | int m_cropX; |
ad37861e | 325 | int m_frameIndex; |
2bdec060 SK |
326 | int m_lastAeMode; |
327 | int m_lastAaMode; | |
328 | int m_lastAwbMode; | |
329 | int m_lastAeComp; | |
5c88d1f2 C |
330 | #ifdef VDIS_ENABLE |
331 | bool m_vdisBubbleEn; | |
332 | #endif | |
5506cebf | 333 | nsecs_t m_lastTimeStamp; |
52f54308 | 334 | List<int> m_sensorQ; |
c15a6b00 JS |
335 | }; |
336 | ||
9dd63e1f SK |
337 | |
338 | typedef struct bayer_buf_entry { | |
339 | int status; | |
340 | int reqFrameCnt; | |
341 | nsecs_t timeStamp; | |
342 | } bayer_buf_entry_t; | |
343 | ||
344 | ||
345 | class BayerBufManager { | |
346 | public: | |
347 | BayerBufManager(); | |
348 | ~BayerBufManager(); | |
349 | int GetIndexForSensorEnqueue(); | |
350 | int MarkSensorEnqueue(int index); | |
351 | int MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp); | |
352 | int GetIndexForIspEnqueue(int *reqFrameCnt); | |
353 | int GetIndexForIspDequeue(int *reqFrameCnt); | |
354 | int MarkIspEnqueue(int index); | |
355 | int MarkIspDequeue(int index); | |
356 | int GetNumOnSensor(); | |
357 | int GetNumOnHalFilled(); | |
358 | int GetNumOnIsp(); | |
359 | ||
360 | private: | |
361 | int GetNextIndex(int index); | |
362 | ||
363 | int sensorEnqueueHead; | |
364 | int sensorDequeueHead; | |
365 | int ispEnqueueHead; | |
366 | int ispDequeueHead; | |
367 | int numOnSensor; | |
368 | int numOnIsp; | |
369 | int numOnHalFilled; | |
370 | int numOnHalEmpty; | |
371 | ||
372 | bayer_buf_entry_t entries[NUM_BAYER_BUFFERS]; | |
373 | }; | |
374 | ||
375 | ||
13d8c7b4 SK |
376 | #define NOT_AVAILABLE (0) |
377 | #define REQUIRES_DQ_FROM_SVC (1) | |
378 | #define ON_DRIVER (2) | |
379 | #define ON_HAL (3) | |
380 | #define ON_SERVICE (4) | |
381 | ||
382 | #define BAYER_NOT_AVAILABLE (0) | |
383 | #define BAYER_ON_SENSOR (1) | |
384 | #define BAYER_ON_HAL_FILLED (2) | |
385 | #define BAYER_ON_ISP (3) | |
386 | #define BAYER_ON_SERVICE (4) | |
387 | #define BAYER_ON_HAL_EMPTY (5) | |
388 | ||
389 | typedef struct stream_parameters { | |
5506cebf SK |
390 | uint32_t width; |
391 | uint32_t height; | |
392 | int format; | |
c15a6b00 JS |
393 | const camera2_stream_ops_t* streamOps; |
394 | uint32_t usage; | |
13d8c7b4 SK |
395 | int numHwBuffers; |
396 | int numSvcBuffers; | |
be494d19 | 397 | int numOwnSvcBuffers; |
5506cebf | 398 | int planes; |
feb7df4c | 399 | int metaPlanes; |
be494d19 | 400 | int numSvcBufsInHal; |
13d8c7b4 SK |
401 | buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS]; |
402 | ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS]; | |
5506cebf | 403 | ExynosBuffer metaBuffers[NUM_MAX_CAMERA_BUFFERS]; |
13d8c7b4 | 404 | int svcBufStatus[NUM_MAX_CAMERA_BUFFERS]; |
5506cebf SK |
405 | int bufIndex; |
406 | node_info_t *node; | |
407 | int minUndequedBuffer; | |
c15a6b00 JS |
408 | } stream_parameters_t; |
409 | ||
5506cebf SK |
410 | typedef struct substream_parameters { |
411 | int type; | |
412 | uint32_t width; | |
413 | uint32_t height; | |
414 | int format; | |
9dd63e1f SK |
415 | const camera2_stream_ops_t* streamOps; |
416 | uint32_t usage; | |
417 | int numSvcBuffers; | |
be494d19 | 418 | int numOwnSvcBuffers; |
74d78ebe SK |
419 | int internalFormat; |
420 | int internalPlanes; | |
74d78ebe SK |
421 | int svcPlanes; |
422 | buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS]; | |
423 | ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS]; | |
424 | int svcBufStatus[NUM_MAX_CAMERA_BUFFERS]; | |
425 | int svcBufIndex; | |
426 | int numSvcBufsInHal; | |
5506cebf SK |
427 | bool needBufferInit; |
428 | int minUndequedBuffer; | |
429 | } substream_parameters_t; | |
430 | ||
431 | typedef struct substream_entry { | |
432 | int priority; | |
433 | int streamId; | |
434 | } substream_entry_t; | |
74d78ebe | 435 | |
c15a6b00 JS |
436 | class ExynosCameraHWInterface2 : public virtual RefBase { |
437 | public: | |
6044e509 | 438 | ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid); |
c15a6b00 JS |
439 | virtual ~ExynosCameraHWInterface2(); |
440 | ||
441 | virtual void release(); | |
13d8c7b4 | 442 | |
c15a6b00 JS |
443 | inline int getCameraId() const; |
444 | ||
445 | virtual int setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops); | |
446 | virtual int notifyRequestQueueNotEmpty(); | |
447 | virtual int setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops); | |
448 | virtual int getInProgressCount(); | |
449 | virtual int flushCapturesInProgress(); | |
450 | virtual int constructDefaultRequest(int request_template, camera_metadata_t **request); | |
13d8c7b4 | 451 | virtual int allocateStream(uint32_t width, uint32_t height, |
c15a6b00 JS |
452 | int format, const camera2_stream_ops_t *stream_ops, |
453 | uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers); | |
454 | virtual int registerStreamBuffers(uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); | |
455 | virtual int releaseStream(uint32_t stream_id); | |
456 | virtual int allocateReprocessStream(uint32_t width, uint32_t height, | |
457 | uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, | |
458 | uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); | |
5506cebf SK |
459 | virtual int allocateReprocessStreamFromStream(uint32_t output_stream_id, |
460 | const camera2_stream_in_ops_t *reprocess_stream_ops, uint32_t *stream_id); | |
c15a6b00 JS |
461 | virtual int releaseReprocessStream(uint32_t stream_id); |
462 | virtual int triggerAction(uint32_t trigger_id, int ext1, int ext2); | |
463 | virtual int setNotifyCallback(camera2_notify_callback notify_cb, void *user); | |
464 | virtual int getMetadataVendorTagOps(vendor_tag_query_ops_t **ops); | |
465 | virtual int dump(int fd); | |
466 | private: | |
13d8c7b4 SK |
467 | class MainThread : public SignalDrivenThread { |
468 | ExynosCameraHWInterface2 *mHardware; | |
469 | public: | |
470 | MainThread(ExynosCameraHWInterface2 *hw): | |
471 | SignalDrivenThread(), | |
053d38cf | 472 | mHardware(hw) { } |
13d8c7b4 | 473 | ~MainThread(); |
13d8c7b4 | 474 | void threadFunctionInternal() |
053d38cf | 475 | { |
13d8c7b4 SK |
476 | mHardware->m_mainThreadFunc(this); |
477 | return; | |
478 | } | |
479 | void release(void); | |
15fd8231 | 480 | bool m_releasing; |
13d8c7b4 | 481 | }; |
9dd63e1f | 482 | |
c15a6b00 JS |
483 | class SensorThread : public SignalDrivenThread { |
484 | ExynosCameraHWInterface2 *mHardware; | |
485 | public: | |
486 | SensorThread(ExynosCameraHWInterface2 *hw): | |
053d38cf | 487 | SignalDrivenThread(), |
5506cebf | 488 | mHardware(hw) { } |
13d8c7b4 | 489 | ~SensorThread(); |
13d8c7b4 | 490 | void threadFunctionInternal() { |
c15a6b00 JS |
491 | mHardware->m_sensorThreadFunc(this); |
492 | return; | |
493 | } | |
9dd63e1f | 494 | void release(void); |
c15a6b00 | 495 | //private: |
15fd8231 | 496 | bool m_releasing; |
c15a6b00 JS |
497 | }; |
498 | ||
499 | class StreamThread : public SignalDrivenThread { | |
500 | ExynosCameraHWInterface2 *mHardware; | |
501 | public: | |
502 | StreamThread(ExynosCameraHWInterface2 *hw, uint8_t new_index): | |
053d38cf | 503 | SignalDrivenThread(), |
c15a6b00 JS |
504 | mHardware(hw), |
505 | m_index(new_index) { } | |
13d8c7b4 | 506 | ~StreamThread(); |
13d8c7b4 | 507 | void threadFunctionInternal() { |
c15a6b00 JS |
508 | mHardware->m_streamThreadFunc(this); |
509 | return; | |
510 | } | |
13d8c7b4 | 511 | void setParameter(stream_parameters_t * new_parameters); |
5506cebf SK |
512 | status_t attachSubStream(int stream_id, int priority); |
513 | status_t detachSubStream(int stream_id); | |
13d8c7b4 SK |
514 | void release(void); |
515 | int findBufferIndex(void * bufAddr); | |
5506cebf | 516 | int findBufferIndex(buffer_handle_t * bufHandle); |
c15a6b00 | 517 | |
13d8c7b4 | 518 | uint8_t m_index; |
9dd63e1f | 519 | bool m_activated; |
13d8c7b4 SK |
520 | //private: |
521 | stream_parameters_t m_parameters; | |
9dd63e1f | 522 | stream_parameters_t *m_tempParameters; |
5506cebf | 523 | substream_entry_t m_attachedSubStreams[NUM_MAX_SUBSTREAM]; |
13d8c7b4 | 524 | bool m_isBufferInit; |
b5237e6b | 525 | bool m_releasing; |
5506cebf SK |
526 | int streamType; |
527 | int m_numRegisteredStream; | |
13d8c7b4 | 528 | }; |
c15a6b00 JS |
529 | |
530 | sp<MainThread> m_mainThread; | |
531 | sp<SensorThread> m_sensorThread; | |
13d8c7b4 | 532 | sp<StreamThread> m_streamThreads[NUM_MAX_STREAM_THREAD]; |
5506cebf | 533 | substream_parameters_t m_subStreams[STREAM_ID_LAST+1]; |
13d8c7b4 SK |
534 | |
535 | ||
9dd63e1f | 536 | |
c15a6b00 | 537 | RequestManager *m_requestManager; |
9dd63e1f | 538 | BayerBufManager *m_BayerManager; |
daa1fcd6 | 539 | ExynosCamera2 *m_camera2; |
c15a6b00 JS |
540 | |
541 | void m_mainThreadFunc(SignalDrivenThread * self); | |
542 | void m_sensorThreadFunc(SignalDrivenThread * self); | |
c15a6b00 | 543 | void m_streamThreadFunc(SignalDrivenThread * self); |
13d8c7b4 SK |
544 | void m_streamThreadInitialize(SignalDrivenThread * self); |
545 | ||
5506cebf SK |
546 | void m_streamFunc_direct(SignalDrivenThread *self); |
547 | void m_streamFunc_indirect(SignalDrivenThread *self); | |
86646da4 SK |
548 | |
549 | void m_streamBufferInit(SignalDrivenThread *self); | |
550 | ||
5506cebf SK |
551 | int m_runSubStreamFunc(StreamThread *selfThread, ExynosBuffer *srcImageBuf, |
552 | int stream_id, nsecs_t frameTimeStamp); | |
553 | int m_jpegCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp); | |
554 | int m_recordCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp); | |
555 | int m_prvcbCreator(StreamThread *selfThread, ExynosBuffer *srcImageBuf, nsecs_t frameTimeStamp); | |
13d8c7b4 SK |
556 | void m_getAlignedYUVSize(int colorFormat, int w, int h, |
557 | ExynosBuffer *buf); | |
558 | bool m_getRatioSize(int src_w, int src_h, | |
559 | int dst_w, int dst_h, | |
560 | int *crop_x, int *crop_y, | |
561 | int *crop_w, int *crop_h, | |
562 | int zoom); | |
563 | int createIonClient(ion_client ionClient); | |
564 | int deleteIonClient(ion_client ionClient); | |
13d8c7b4 SK |
565 | |
566 | int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum); | |
181e425e | 567 | int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag); |
13d8c7b4 SK |
568 | void freeCameraMemory(ExynosBuffer *buf, int iMemoryNum); |
569 | void initCameraMemory(ExynosBuffer *buf, int iMemoryNum); | |
570 | ||
571 | void DumpInfoWithShot(struct camera2_shot_ext * shot_ext); | |
2d5e6ec2 | 572 | bool m_checkThumbnailSize(int w, int h); |
13d8c7b4 SK |
573 | bool yuv2Jpeg(ExynosBuffer *yuvBuf, |
574 | ExynosBuffer *jpegBuf, | |
575 | ExynosRect *rect); | |
5506cebf | 576 | int InitializeISPChain(); |
ad37861e | 577 | void StartISP(); |
5506cebf | 578 | void StartSCCThread(bool threadExists); |
0f26b20f SK |
579 | int GetAfState(); |
580 | void SetAfMode(enum aa_afmode afMode); | |
8e2c2fdb | 581 | void OnAfTriggerStart(int id); |
0f26b20f SK |
582 | void OnAfTrigger(int id); |
583 | void OnAfTriggerAutoMacro(int id); | |
584 | void OnAfTriggerCAFPicture(int id); | |
585 | void OnAfTriggerCAFVideo(int id); | |
e117f756 | 586 | void OnPrecaptureMeteringTriggerStart(int id); |
0f26b20f SK |
587 | void OnAfCancel(int id); |
588 | void OnAfCancelAutoMacro(int id); | |
589 | void OnAfCancelCAFPicture(int id); | |
590 | void OnAfCancelCAFVideo(int id); | |
73f5ad60 YJ |
591 | void OnPrecaptureMeteringNotificationISP(); |
592 | void OnPrecaptureMeteringNotificationSensor(); | |
0f26b20f SK |
593 | void OnAfNotification(enum aa_afstate noti); |
594 | void OnAfNotificationAutoMacro(enum aa_afstate noti); | |
595 | void OnAfNotificationCAFPicture(enum aa_afstate noti); | |
596 | void OnAfNotificationCAFVideo(enum aa_afstate noti); | |
597 | void SetAfStateForService(int newState); | |
598 | int GetAfStateForService(); | |
13d8c7b4 | 599 | exif_attribute_t mExifInfo; |
eed7ed1b SK |
600 | void m_setExifFixedAttribute(void); |
601 | void m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect, | |
602 | camera2_shot *currentEntry); | |
e117f756 YJ |
603 | void m_preCaptureSetter(struct camera2_shot_ext * shot_ext); |
604 | void m_preCaptureListenerSensor(struct camera2_shot_ext * shot_ext); | |
605 | void m_preCaptureListenerISP(struct camera2_shot_ext * shot_ext); | |
13d8c7b4 | 606 | void *m_exynosPictureCSC; |
9dd63e1f | 607 | void *m_exynosVideoCSC; |
13d8c7b4 | 608 | |
c15a6b00 JS |
609 | |
610 | camera2_request_queue_src_ops_t *m_requestQueueOps; | |
611 | camera2_frame_queue_dst_ops_t *m_frameQueueOps; | |
612 | camera2_notify_callback m_notifyCb; | |
613 | void *m_callbackCookie; | |
614 | ||
615 | int m_numOfRemainingReqInSvc; | |
616 | bool m_isRequestQueuePending; | |
13d8c7b4 SK |
617 | bool m_isRequestQueueNull; |
618 | camera2_device_t *m_halDevice; | |
619 | static gralloc_module_t const* m_grallocHal; | |
c15a6b00 | 620 | |
c15a6b00 | 621 | |
13d8c7b4 | 622 | camera_hw_info_t m_camera_info; |
c15a6b00 JS |
623 | |
624 | ion_client m_ionCameraClient; | |
625 | ||
ad37861e | 626 | bool m_isIspStarted; |
13d8c7b4 | 627 | |
ad37861e | 628 | int m_need_streamoff; |
13d8c7b4 | 629 | |
13d8c7b4 SK |
630 | |
631 | int indexToQueue[3+1]; | |
13d8c7b4 SK |
632 | |
633 | bool m_scp_flushing; | |
634 | bool m_closing; | |
635 | ExynosBuffer m_resizeBuf; | |
2f4d175d | 636 | #ifndef ENABLE_FRAME_SYNC |
5506cebf | 637 | int m_currentOutputStreams; |
2f4d175d | 638 | #endif |
5506cebf | 639 | int m_currentReprocessOutStreams; |
74d78ebe | 640 | ExynosBuffer m_previewCbBuf; |
9dd63e1f SK |
641 | int m_cameraId; |
642 | bool m_scp_closing; | |
643 | bool m_scp_closed; | |
15fd8231 | 644 | bool m_wideAspect; |
8e2c2fdb | 645 | uint32_t lastAfRegion[4]; |
308291de | 646 | float m_zoomRatio; |
ad37861e | 647 | |
5c88d1f2 C |
648 | #ifdef VDIS_ENABLE |
649 | int m_vdisBubbleCnt; | |
650 | int m_vdisDupFrame; | |
651 | #endif | |
652 | ||
5506cebf | 653 | mutable Mutex m_qbufLock; |
ad37861e | 654 | |
0f26b20f SK |
655 | int m_afState; |
656 | int m_afTriggerId; | |
657 | enum aa_afmode m_afMode; | |
658 | enum aa_afmode m_afMode2; | |
659 | bool m_IsAfModeUpdateRequired; | |
660 | bool m_IsAfTriggerRequired; | |
661 | bool m_IsAfLockRequired; | |
662 | int m_serviceAfState; | |
36c106c9 | 663 | bool m_AfHwStateFailed; |
8e2c2fdb SK |
664 | int m_afPendingTriggerId; |
665 | int m_afModeWaitingCnt; | |
eed7ed1b | 666 | struct camera2_shot m_jpegMetadata; |
b55ed664 SK |
667 | int m_scpOutputSignalCnt; |
668 | int m_scpOutputImageCnt; | |
a15b4e3f SK |
669 | int m_nightCaptureCnt; |
670 | int m_nightCaptureFrameCnt; | |
2d5e6ec2 SK |
671 | int m_thumbNailW; |
672 | int m_thumbNailH; | |
5506cebf SK |
673 | int m_reprocessStreamId; |
674 | const camera2_stream_in_ops_t * m_reprocessOps; | |
675 | int m_reprocessOutputStreamId; | |
676 | int m_reprocessingFrameCnt; | |
9a710a45 | 677 | ctl_request_info_t m_ctlInfo; |
c15a6b00 JS |
678 | }; |
679 | ||
680 | }; // namespace android | |
681 | ||
682 | #endif |