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> | |
40 | #include "SignalDrivenThread.h" | |
41 | #include "MetadataConverter.h" | |
42 | #include "exynos_v4l2.h" | |
13d8c7b4 SK |
43 | #include "ExynosRect.h" |
44 | #include "ExynosBuffer.h" | |
c15a6b00 JS |
45 | #include "videodev2_exynos_camera.h" |
46 | #include "gralloc_priv.h" | |
13d8c7b4 | 47 | #include "ExynosJpegEncoderForCamera.h" |
c15a6b00 JS |
48 | #include <fcntl.h> |
49 | #include "fimc-is-metadata.h" | |
50 | #include "ion.h" | |
13d8c7b4 SK |
51 | #include "ExynosExif.h" |
52 | #include "csc.h" | |
daa1fcd6 | 53 | #include "ExynosCamera2.h" |
eed7ed1b | 54 | #include "cutils/properties.h" |
c15a6b00 JS |
55 | |
56 | namespace android { | |
57 | ||
feb7df4c | 58 | //#define ENABLE_FRAME_SYNC |
c15a6b00 JS |
59 | #define NODE_PREFIX "/dev/video" |
60 | ||
61 | #define NUM_MAX_STREAM_THREAD (5) | |
13d8c7b4 | 62 | #define NUM_MAX_REQUEST_MGR_ENTRY (10) |
ad37861e | 63 | #define NUM_MAX_DEQUEUED_REQUEST NUM_MAX_REQUEST_MGR_ENTRY |
c15a6b00 | 64 | #define MAX_CAMERA_MEMORY_PLANE_NUM (4) |
13d8c7b4 SK |
65 | #define NUM_MAX_CAMERA_BUFFERS (16) |
66 | #define NUM_BAYER_BUFFERS (8) | |
b56dcc00 | 67 | #define NUM_SENSOR_QBUF (3) |
13d8c7b4 SK |
68 | |
69 | #define PICTURE_GSC_NODE_NUM (2) | |
15fd8231 | 70 | #define VIDEO_GSC_NODE_NUM (1) |
c15a6b00 | 71 | |
37e122d5 SK |
72 | #define STREAM_TYPE_DIRECT (0) |
73 | #define STREAM_TYPE_INDIRECT (1) | |
74 | ||
13d8c7b4 SK |
75 | #define SIGNAL_MAIN_REQ_Q_NOT_EMPTY (SIGNAL_THREAD_COMMON_LAST<<1) |
76 | #define SIGNAL_MAIN_REPROCESS_Q_NOT_EMPTY (SIGNAL_THREAD_COMMON_LAST<<2) | |
77 | #define SIGNAL_MAIN_STREAM_OUTPUT_DONE (SIGNAL_THREAD_COMMON_LAST<<3) | |
78 | #define SIGNAL_SENSOR_START_REQ_PROCESSING (SIGNAL_THREAD_COMMON_LAST<<4) | |
c15a6b00 JS |
79 | #define SIGNAL_STREAM_GET_BUFFER (SIGNAL_THREAD_COMMON_LAST<<5) |
80 | #define SIGNAL_STREAM_PUT_BUFFER (SIGNAL_THREAD_COMMON_LAST<<6) | |
81 | #define SIGNAL_STREAM_CHANGE_PARAMETER (SIGNAL_THREAD_COMMON_LAST<<7) | |
13d8c7b4 SK |
82 | #define SIGNAL_THREAD_RELEASE (SIGNAL_THREAD_COMMON_LAST<<8) |
83 | #define SIGNAL_ISP_START_BAYER_INPUT (SIGNAL_THREAD_COMMON_LAST<<9) | |
9dd63e1f | 84 | #define SIGNAL_ISP_START_BAYER_DEQUEUE (SIGNAL_THREAD_COMMON_LAST<<10) |
c15a6b00 JS |
85 | |
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 | |
c15a6b00 JS |
98 | enum sensor_name { |
99 | SENSOR_NAME_S5K3H2 = 1, | |
100 | SENSOR_NAME_S5K6A3 = 2, | |
101 | SENSOR_NAME_S5K4E5 = 3, | |
102 | SENSOR_NAME_S5K3H7 = 4, | |
103 | SENSOR_NAME_CUSTOM = 5, | |
104 | SENSOR_NAME_END | |
105 | }; | |
106 | ||
15fd8231 SK |
107 | enum is_subscenario_id { |
108 | ISS_SUB_SCENARIO_STILL, | |
109 | ISS_SUB_SCENARIO_VIDEO, | |
110 | ISS_SUB_SCENARIO_SCENE1, | |
111 | ISS_SUB_SCENARIO_SCENE2, | |
112 | ISS_SUB_SCENARIO_SCENE3, | |
113 | ISS_SUB_END | |
114 | }; | |
c15a6b00 | 115 | |
2d5e6ec2 SK |
116 | int SUPPORT_THUMBNAIL_REAR_SIZE[][2] = |
117 | { | |
118 | {160, 120}, | |
119 | {160, 90}, | |
120 | {144, 96} | |
121 | }; | |
122 | ||
123 | int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] = | |
124 | { | |
125 | {160, 120}, | |
126 | {160, 160}, | |
127 | {160, 90}, | |
128 | {144, 96} | |
129 | }; | |
130 | ||
6f19b6cf YJ |
131 | enum is_flash_scenario_state { |
132 | IS_FLASH_ON = 1, | |
133 | IS_FLASH_ON_DONE = 2, | |
134 | IS_FLASH_AUTO_AE_AWB_LOCK = 10, | |
6f19b6cf | 135 | IS_FLASH_CAPTURE, |
9a710a45 | 136 | IS_FLASH_CAPTURE_WAIT, |
6f19b6cf YJ |
137 | IS_FLASH_CAPTURE_JPEG, |
138 | IS_FLASH_CAPTURE_END, | |
139 | IS_FLASH_MAX | |
140 | }; | |
141 | ||
142 | enum is_af_flash_scenario_state { | |
143 | IS_FLASH_AF_ON = 1, | |
144 | IS_FLASH_AF_ON_START, | |
145 | IS_FLASH_AF_ON_DONE, | |
9a710a45 YJ |
146 | IS_FLASH_AF_AUTO_AE_AWB_LOCK, |
147 | IS_FLASH_AF_AUTO_END, | |
6f19b6cf YJ |
148 | IF_FLASH_AF_OFF, |
149 | IS_FLASH_AF_MAX | |
150 | }; | |
151 | ||
c15a6b00 JS |
152 | typedef struct node_info { |
153 | int fd; | |
154 | int width; | |
155 | int height; | |
156 | int format; | |
157 | int planes; | |
158 | int buffers; | |
c15a6b00 JS |
159 | enum v4l2_memory memory; |
160 | enum v4l2_buf_type type; | |
be494d19 SK |
161 | ion_client ionClient; |
162 | ExynosBuffer buffer[NUM_MAX_CAMERA_BUFFERS]; | |
15fd8231 | 163 | int status; |
c15a6b00 JS |
164 | } node_info_t; |
165 | ||
166 | ||
167 | typedef struct camera_hw_info { | |
168 | int sensor_id; | |
169 | ||
170 | node_info_t sensor; | |
13d8c7b4 SK |
171 | node_info_t isp; |
172 | node_info_t capture; | |
173 | ||
174 | /*shot*/ // temp | |
175 | struct camera2_shot_ext dummy_shot; | |
c15a6b00 | 176 | |
c15a6b00 JS |
177 | } camera_hw_info_t; |
178 | ||
13d8c7b4 | 179 | typedef enum request_entry_status { |
c15a6b00 JS |
180 | EMPTY, |
181 | REGISTERED, | |
be494d19 SK |
182 | REQUESTED, |
183 | CAPTURED | |
c15a6b00 JS |
184 | } request_entry_status_t; |
185 | ||
186 | typedef struct request_manager_entry { | |
13d8c7b4 | 187 | request_entry_status_t status; |
13d8c7b4 | 188 | camera_metadata_t *original_request; |
be494d19 | 189 | struct camera2_shot_ext internal_shot; |
13d8c7b4 SK |
190 | int output_stream_count; |
191 | bool dynamic_meta_vaild; | |
c15a6b00 JS |
192 | } request_manager_entry_t; |
193 | ||
9a710a45 YJ |
194 | // structure related to a specific function of camera |
195 | typedef struct flash_control_info { | |
196 | // UI flash mode indicator | |
197 | enum aa_aemode i_flashMode; | |
198 | // AF flash | |
199 | bool m_afFlashDoneFlg; | |
200 | bool m_afFlashEnableFlg; | |
201 | int m_afFlashCnt; | |
202 | // Capture flash | |
203 | bool m_flashEnableFlg; | |
204 | bool m_flashCaptured; | |
205 | int m_flashFrameCount; | |
206 | int m_flashCnt; | |
207 | int m_flashTimeOut; | |
208 | int m_flashWaitCnt; | |
209 | } ctl_flash_info_t; | |
210 | ||
211 | typedef struct request_control_info { | |
212 | ctl_flash_info_t flash; | |
213 | ||
214 | } ctl_request_info_t; | |
215 | ||
c15a6b00 JS |
216 | class RequestManager { |
217 | public: | |
218 | RequestManager(SignalDrivenThread* main_thread); | |
219 | ~RequestManager(); | |
220 | int GetNumEntries(); | |
221 | bool IsRequestQueueFull(); | |
13d8c7b4 SK |
222 | |
223 | void RegisterRequest(camera_metadata_t *new_request); | |
224 | void DeregisterRequest(camera_metadata_t **deregistered_request); | |
225 | bool PrepareFrame(size_t *num_entries, size_t *frame_size, | |
0f26b20f SK |
226 | camera_metadata_t **prepared_frame, int afState); |
227 | int MarkProcessingRequest(ExynosBuffer * buf, int *afMode); | |
9dd63e1f | 228 | void NotifyStreamOutput(int frameCnt, int stream_id); |
13d8c7b4 | 229 | void DumpInfoWithIndex(int index); |
ad37861e | 230 | void ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext); |
13d8c7b4 | 231 | void CheckCompleted(int index); |
ef6f83ca | 232 | void UpdateIspParameters(struct camera2_shot_ext *shot_ext, int frameCnt); |
9dd63e1f SK |
233 | void RegisterTimestamp(int frameCnt, nsecs_t *frameTime); |
234 | uint64_t GetTimestamp(int frameCnt); | |
235 | int FindFrameCnt(struct camera2_shot_ext * shot_ext); | |
236 | int FindEntryIndexByFrameCnt(int frameCnt); | |
b5237e6b SK |
237 | void Dump(void); |
238 | int GetNextIndex(int index); | |
239 | void SetDefaultParameters(int cropX); | |
240 | void SetInitialSkip(int count); | |
ad37861e SK |
241 | int GetSkipCnt(); |
242 | void SetFrameIndex(int index); | |
243 | int GetFrameIndex(); | |
c15a6b00 JS |
244 | private: |
245 | ||
246 | MetadataConverter *m_metadataConverter; | |
247 | SignalDrivenThread *m_mainThread; | |
248 | int m_numOfEntries; | |
249 | int m_entryInsertionIndex; | |
250 | int m_entryProcessingIndex; | |
251 | int m_entryFrameOutputIndex; | |
252 | request_manager_entry_t entries[NUM_MAX_REQUEST_MGR_ENTRY]; | |
13d8c7b4 | 253 | int m_completedIndex; |
c15a6b00 JS |
254 | |
255 | Mutex m_requestMutex; | |
256 | ||
257 | //TODO : alloc dynamically | |
258 | char m_tempFrameMetadataBuf[2000]; | |
259 | camera_metadata_t *m_tempFrameMetadata; | |
9dd63e1f | 260 | |
b5237e6b | 261 | int m_sensorPipelineSkipCnt; |
9dd63e1f | 262 | int m_cropX; |
ad37861e | 263 | int m_frameIndex; |
2bdec060 SK |
264 | int m_lastAeMode; |
265 | int m_lastAaMode; | |
266 | int m_lastAwbMode; | |
267 | int m_lastAeComp; | |
c15a6b00 JS |
268 | }; |
269 | ||
9dd63e1f SK |
270 | |
271 | typedef struct bayer_buf_entry { | |
272 | int status; | |
273 | int reqFrameCnt; | |
274 | nsecs_t timeStamp; | |
275 | } bayer_buf_entry_t; | |
276 | ||
277 | ||
278 | class BayerBufManager { | |
279 | public: | |
280 | BayerBufManager(); | |
281 | ~BayerBufManager(); | |
282 | int GetIndexForSensorEnqueue(); | |
283 | int MarkSensorEnqueue(int index); | |
284 | int MarkSensorDequeue(int index, int reqFrameCnt, nsecs_t *timeStamp); | |
285 | int GetIndexForIspEnqueue(int *reqFrameCnt); | |
286 | int GetIndexForIspDequeue(int *reqFrameCnt); | |
287 | int MarkIspEnqueue(int index); | |
288 | int MarkIspDequeue(int index); | |
289 | int GetNumOnSensor(); | |
290 | int GetNumOnHalFilled(); | |
291 | int GetNumOnIsp(); | |
292 | ||
293 | private: | |
294 | int GetNextIndex(int index); | |
295 | ||
296 | int sensorEnqueueHead; | |
297 | int sensorDequeueHead; | |
298 | int ispEnqueueHead; | |
299 | int ispDequeueHead; | |
300 | int numOnSensor; | |
301 | int numOnIsp; | |
302 | int numOnHalFilled; | |
303 | int numOnHalEmpty; | |
304 | ||
305 | bayer_buf_entry_t entries[NUM_BAYER_BUFFERS]; | |
306 | }; | |
307 | ||
308 | ||
13d8c7b4 SK |
309 | #define NOT_AVAILABLE (0) |
310 | #define REQUIRES_DQ_FROM_SVC (1) | |
311 | #define ON_DRIVER (2) | |
312 | #define ON_HAL (3) | |
313 | #define ON_SERVICE (4) | |
314 | ||
315 | #define BAYER_NOT_AVAILABLE (0) | |
316 | #define BAYER_ON_SENSOR (1) | |
317 | #define BAYER_ON_HAL_FILLED (2) | |
318 | #define BAYER_ON_ISP (3) | |
319 | #define BAYER_ON_SERVICE (4) | |
320 | #define BAYER_ON_HAL_EMPTY (5) | |
321 | ||
322 | typedef struct stream_parameters { | |
323 | int streamType; | |
324 | uint32_t outputWidth; | |
325 | uint32_t outputHeight; | |
326 | uint32_t nodeWidth; | |
327 | uint32_t nodeHeight; | |
328 | int outputFormat; | |
329 | int nodeFormat; | |
c15a6b00 JS |
330 | const camera2_stream_ops_t* streamOps; |
331 | uint32_t usage; | |
13d8c7b4 SK |
332 | int numHwBuffers; |
333 | int numSvcBuffers; | |
be494d19 | 334 | int numOwnSvcBuffers; |
c15a6b00 | 335 | int fd; |
13d8c7b4 SK |
336 | int svcPlanes; |
337 | int nodePlanes; | |
feb7df4c | 338 | int metaPlanes; |
13d8c7b4 SK |
339 | enum v4l2_memory memory; |
340 | enum v4l2_buf_type halBuftype; | |
be494d19 | 341 | int numSvcBufsInHal; |
13d8c7b4 SK |
342 | buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS]; |
343 | ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS]; | |
feb7df4c | 344 | ExynosBuffer metaBuffers[NUM_MAX_CAMERA_BUFFERS]; |
13d8c7b4 | 345 | int svcBufStatus[NUM_MAX_CAMERA_BUFFERS]; |
be494d19 SK |
346 | int svcBufIndex; |
347 | ion_client ionClient; | |
13d8c7b4 | 348 | node_info_t node; |
c15a6b00 JS |
349 | } stream_parameters_t; |
350 | ||
9dd63e1f SK |
351 | typedef struct record_parameters { |
352 | uint32_t outputWidth; | |
353 | uint32_t outputHeight; | |
354 | int outputFormat; | |
355 | const camera2_stream_ops_t* streamOps; | |
356 | uint32_t usage; | |
357 | int numSvcBuffers; | |
be494d19 | 358 | int numOwnSvcBuffers; |
9dd63e1f SK |
359 | int svcPlanes; |
360 | buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS]; | |
361 | ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS]; | |
362 | int svcBufStatus[NUM_MAX_CAMERA_BUFFERS]; | |
be494d19 SK |
363 | int svcBufIndex; |
364 | int numSvcBufsInHal; | |
9dd63e1f | 365 | } record_parameters_t; |
13d8c7b4 | 366 | |
74d78ebe SK |
367 | typedef struct callback_parameters { |
368 | uint32_t outputWidth; | |
369 | uint32_t outputHeight; | |
370 | int outputFormat; | |
371 | int internalFormat; | |
372 | int internalPlanes; | |
373 | const camera2_stream_ops_t* streamOps; | |
374 | uint32_t usage; | |
375 | int numSvcBuffers; | |
376 | int numOwnSvcBuffers; | |
377 | int svcPlanes; | |
378 | buffer_handle_t svcBufHandle[NUM_MAX_CAMERA_BUFFERS]; | |
379 | ExynosBuffer svcBuffers[NUM_MAX_CAMERA_BUFFERS]; | |
380 | int svcBufStatus[NUM_MAX_CAMERA_BUFFERS]; | |
381 | int svcBufIndex; | |
382 | int numSvcBufsInHal; | |
383 | } callback_parameters_t; | |
384 | ||
c15a6b00 JS |
385 | class ExynosCameraHWInterface2 : public virtual RefBase { |
386 | public: | |
6044e509 | 387 | ExynosCameraHWInterface2(int cameraId, camera2_device_t *dev, ExynosCamera2 * camera, int *openInvalid); |
c15a6b00 JS |
388 | virtual ~ExynosCameraHWInterface2(); |
389 | ||
390 | virtual void release(); | |
13d8c7b4 | 391 | |
c15a6b00 JS |
392 | inline int getCameraId() const; |
393 | ||
394 | virtual int setRequestQueueSrcOps(const camera2_request_queue_src_ops_t *request_src_ops); | |
395 | virtual int notifyRequestQueueNotEmpty(); | |
396 | virtual int setFrameQueueDstOps(const camera2_frame_queue_dst_ops_t *frame_dst_ops); | |
397 | virtual int getInProgressCount(); | |
398 | virtual int flushCapturesInProgress(); | |
399 | virtual int constructDefaultRequest(int request_template, camera_metadata_t **request); | |
13d8c7b4 | 400 | virtual int allocateStream(uint32_t width, uint32_t height, |
c15a6b00 JS |
401 | int format, const camera2_stream_ops_t *stream_ops, |
402 | uint32_t *stream_id, uint32_t *format_actual, uint32_t *usage, uint32_t *max_buffers); | |
403 | virtual int registerStreamBuffers(uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); | |
404 | virtual int releaseStream(uint32_t stream_id); | |
405 | virtual int allocateReprocessStream(uint32_t width, uint32_t height, | |
406 | uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, | |
407 | uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); | |
408 | virtual int releaseReprocessStream(uint32_t stream_id); | |
409 | virtual int triggerAction(uint32_t trigger_id, int ext1, int ext2); | |
410 | virtual int setNotifyCallback(camera2_notify_callback notify_cb, void *user); | |
411 | virtual int getMetadataVendorTagOps(vendor_tag_query_ops_t **ops); | |
412 | virtual int dump(int fd); | |
413 | private: | |
13d8c7b4 SK |
414 | class MainThread : public SignalDrivenThread { |
415 | ExynosCameraHWInterface2 *mHardware; | |
416 | public: | |
417 | MainThread(ExynosCameraHWInterface2 *hw): | |
418 | SignalDrivenThread(), | |
419 | mHardware(hw) { | |
420 | // Start("MainThread", PRIORITY_DEFAULT, 0); | |
421 | } | |
422 | ~MainThread(); | |
423 | status_t readyToRunInternal() | |
424 | { | |
425 | return NO_ERROR; | |
426 | } | |
427 | void threadFunctionInternal() | |
428 | { | |
429 | mHardware->m_mainThreadFunc(this); | |
430 | return; | |
431 | } | |
432 | void release(void); | |
15fd8231 | 433 | bool m_releasing; |
13d8c7b4 | 434 | }; |
9dd63e1f | 435 | |
c15a6b00 JS |
436 | class SensorThread : public SignalDrivenThread { |
437 | ExynosCameraHWInterface2 *mHardware; | |
438 | public: | |
439 | SensorThread(ExynosCameraHWInterface2 *hw): | |
440 | SignalDrivenThread("SensorThread", PRIORITY_DEFAULT, 0), | |
441 | mHardware(hw), | |
442 | m_isBayerOutputEnabled(false) { } | |
13d8c7b4 | 443 | ~SensorThread(); |
c15a6b00 | 444 | status_t readyToRunInternal() { |
13d8c7b4 | 445 | mHardware->m_sensorThreadInitialize(this); |
c15a6b00 JS |
446 | return NO_ERROR; |
447 | } | |
13d8c7b4 | 448 | void threadFunctionInternal() { |
c15a6b00 JS |
449 | mHardware->m_sensorThreadFunc(this); |
450 | return; | |
451 | } | |
9dd63e1f | 452 | void release(void); |
c15a6b00 JS |
453 | //private: |
454 | bool m_isBayerOutputEnabled; | |
455 | int m_sensorFd; | |
15fd8231 | 456 | bool m_releasing; |
13d8c7b4 SK |
457 | }; |
458 | ||
459 | class IspThread : public SignalDrivenThread { | |
460 | ExynosCameraHWInterface2 *mHardware; | |
461 | public: | |
462 | IspThread(ExynosCameraHWInterface2 *hw): | |
463 | SignalDrivenThread("IspThread", PRIORITY_DEFAULT, 0), | |
464 | mHardware(hw) { } | |
465 | ~IspThread(); | |
466 | status_t readyToRunInternal() { | |
467 | mHardware->m_ispThreadInitialize(this); | |
468 | return NO_ERROR; | |
469 | } | |
470 | void threadFunctionInternal() { | |
471 | mHardware->m_ispThreadFunc(this); | |
472 | return; | |
473 | } | |
474 | void release(void); | |
475 | //private: | |
c15a6b00 | 476 | int m_ispFd; |
15fd8231 | 477 | bool m_releasing; |
c15a6b00 JS |
478 | }; |
479 | ||
480 | class StreamThread : public SignalDrivenThread { | |
481 | ExynosCameraHWInterface2 *mHardware; | |
482 | public: | |
483 | StreamThread(ExynosCameraHWInterface2 *hw, uint8_t new_index): | |
484 | SignalDrivenThread("StreamThread", PRIORITY_DEFAULT, 0), | |
485 | mHardware(hw), | |
486 | m_index(new_index) { } | |
13d8c7b4 | 487 | ~StreamThread(); |
c15a6b00 | 488 | status_t readyToRunInternal() { |
13d8c7b4 | 489 | mHardware->m_streamThreadInitialize(this); |
c15a6b00 JS |
490 | return NO_ERROR; |
491 | } | |
13d8c7b4 | 492 | void threadFunctionInternal() { |
c15a6b00 JS |
493 | mHardware->m_streamThreadFunc(this); |
494 | return; | |
495 | } | |
9dd63e1f | 496 | void setRecordingParameter(record_parameters_t * recordParm); |
74d78ebe | 497 | void setCallbackParameter(callback_parameters_t * callbackParm); |
13d8c7b4 SK |
498 | void setParameter(stream_parameters_t * new_parameters); |
499 | void applyChange(void); | |
500 | void release(void); | |
501 | int findBufferIndex(void * bufAddr); | |
c15a6b00 | 502 | |
c15a6b00 | 503 | |
13d8c7b4 | 504 | uint8_t m_index; |
9dd63e1f | 505 | bool m_activated; |
13d8c7b4 SK |
506 | //private: |
507 | stream_parameters_t m_parameters; | |
9dd63e1f SK |
508 | stream_parameters_t *m_tempParameters; |
509 | record_parameters_t m_recordParameters; | |
74d78ebe | 510 | callback_parameters_t m_previewCbParameters; |
13d8c7b4 | 511 | bool m_isBufferInit; |
b5237e6b | 512 | bool m_releasing; |
13d8c7b4 | 513 | }; |
c15a6b00 JS |
514 | |
515 | sp<MainThread> m_mainThread; | |
516 | sp<SensorThread> m_sensorThread; | |
13d8c7b4 SK |
517 | sp<IspThread> m_ispThread; |
518 | sp<StreamThread> m_streamThreads[NUM_MAX_STREAM_THREAD]; | |
519 | ||
520 | ||
9dd63e1f | 521 | |
c15a6b00 | 522 | RequestManager *m_requestManager; |
9dd63e1f | 523 | BayerBufManager *m_BayerManager; |
daa1fcd6 | 524 | ExynosCamera2 *m_camera2; |
c15a6b00 JS |
525 | |
526 | void m_mainThreadFunc(SignalDrivenThread * self); | |
527 | void m_sensorThreadFunc(SignalDrivenThread * self); | |
13d8c7b4 SK |
528 | void m_sensorThreadInitialize(SignalDrivenThread * self); |
529 | void m_ispThreadFunc(SignalDrivenThread * self); | |
530 | void m_ispThreadInitialize(SignalDrivenThread * self); | |
c15a6b00 | 531 | void m_streamThreadFunc(SignalDrivenThread * self); |
13d8c7b4 SK |
532 | void m_streamThreadInitialize(SignalDrivenThread * self); |
533 | ||
86646da4 SK |
534 | void m_streamFunc0(SignalDrivenThread *self); |
535 | void m_streamFunc1(SignalDrivenThread *self); | |
536 | ||
537 | void m_streamBufferInit(SignalDrivenThread *self); | |
538 | ||
13d8c7b4 SK |
539 | void m_getAlignedYUVSize(int colorFormat, int w, int h, |
540 | ExynosBuffer *buf); | |
541 | bool m_getRatioSize(int src_w, int src_h, | |
542 | int dst_w, int dst_h, | |
543 | int *crop_x, int *crop_y, | |
544 | int *crop_w, int *crop_h, | |
545 | int zoom); | |
546 | int createIonClient(ion_client ionClient); | |
547 | int deleteIonClient(ion_client ionClient); | |
13d8c7b4 SK |
548 | |
549 | int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum); | |
181e425e | 550 | int allocCameraMemory(ion_client ionClient, ExynosBuffer *buf, int iMemoryNum, int cacheFlag); |
13d8c7b4 SK |
551 | void freeCameraMemory(ExynosBuffer *buf, int iMemoryNum); |
552 | void initCameraMemory(ExynosBuffer *buf, int iMemoryNum); | |
553 | ||
554 | void DumpInfoWithShot(struct camera2_shot_ext * shot_ext); | |
2d5e6ec2 | 555 | bool m_checkThumbnailSize(int w, int h); |
13d8c7b4 SK |
556 | bool yuv2Jpeg(ExynosBuffer *yuvBuf, |
557 | ExynosBuffer *jpegBuf, | |
558 | ExynosRect *rect); | |
6044e509 | 559 | int InitializeISPChain(); |
ad37861e | 560 | void StartISP(); |
0f26b20f SK |
561 | int GetAfState(); |
562 | void SetAfMode(enum aa_afmode afMode); | |
8e2c2fdb | 563 | void OnAfTriggerStart(int id); |
0f26b20f SK |
564 | void OnAfTrigger(int id); |
565 | void OnAfTriggerAutoMacro(int id); | |
566 | void OnAfTriggerCAFPicture(int id); | |
567 | void OnAfTriggerCAFVideo(int id); | |
568 | void OnAfCancel(int id); | |
569 | void OnAfCancelAutoMacro(int id); | |
570 | void OnAfCancelCAFPicture(int id); | |
571 | void OnAfCancelCAFVideo(int id); | |
572 | void OnAfNotification(enum aa_afstate noti); | |
573 | void OnAfNotificationAutoMacro(enum aa_afstate noti); | |
574 | void OnAfNotificationCAFPicture(enum aa_afstate noti); | |
575 | void OnAfNotificationCAFVideo(enum aa_afstate noti); | |
576 | void SetAfStateForService(int newState); | |
577 | int GetAfStateForService(); | |
13d8c7b4 | 578 | exif_attribute_t mExifInfo; |
eed7ed1b SK |
579 | void m_setExifFixedAttribute(void); |
580 | void m_setExifChangedAttribute(exif_attribute_t *exifInfo, ExynosRect *rect, | |
581 | camera2_shot *currentEntry); | |
6f19b6cf YJ |
582 | void flashSetter(struct camera2_shot_ext * shot_ext); |
583 | void flashListener(struct camera2_shot_ext * shot_ext); | |
9a710a45 | 584 | void flashListenerCapture(struct camera2_shot_ext * shot_ext); |
13d8c7b4 | 585 | void *m_exynosPictureCSC; |
9dd63e1f | 586 | void *m_exynosVideoCSC; |
13d8c7b4 | 587 | |
9dd63e1f | 588 | int m_jpegEncodingFrameCnt; |
c15a6b00 JS |
589 | |
590 | camera2_request_queue_src_ops_t *m_requestQueueOps; | |
591 | camera2_frame_queue_dst_ops_t *m_frameQueueOps; | |
592 | camera2_notify_callback m_notifyCb; | |
593 | void *m_callbackCookie; | |
594 | ||
595 | int m_numOfRemainingReqInSvc; | |
596 | bool m_isRequestQueuePending; | |
13d8c7b4 SK |
597 | bool m_isRequestQueueNull; |
598 | camera2_device_t *m_halDevice; | |
599 | static gralloc_module_t const* m_grallocHal; | |
c15a6b00 | 600 | |
c15a6b00 | 601 | |
13d8c7b4 | 602 | camera_hw_info_t m_camera_info; |
c15a6b00 JS |
603 | |
604 | ion_client m_ionCameraClient; | |
605 | ||
13d8c7b4 SK |
606 | bool m_isSensorThreadOn; |
607 | bool m_isSensorStarted; | |
ad37861e | 608 | bool m_isIspStarted; |
13d8c7b4 | 609 | |
ad37861e | 610 | int m_need_streamoff; |
13d8c7b4 SK |
611 | |
612 | bool m_initFlag1; | |
613 | bool m_initFlag2; | |
13d8c7b4 SK |
614 | |
615 | int indexToQueue[3+1]; | |
616 | int m_fd_scp; | |
617 | ||
618 | bool m_scp_flushing; | |
619 | bool m_closing; | |
620 | ExynosBuffer m_resizeBuf; | |
9dd63e1f SK |
621 | bool m_recordingEnabled; |
622 | int m_previewOutput; | |
623 | int m_recordOutput; | |
624 | bool m_needsRecordBufferInit; | |
74d78ebe SK |
625 | ExynosBuffer m_previewCbBuf; |
626 | int m_previewCbEnabled; | |
627 | int m_previewCbOutput; | |
628 | bool m_needsPreviewCbBufferInit; | |
9dd63e1f | 629 | int lastFrameCnt; |
9dd63e1f SK |
630 | int m_cameraId; |
631 | bool m_scp_closing; | |
632 | bool m_scp_closed; | |
15fd8231 | 633 | bool m_wideAspect; |
b55ed664 | 634 | bool m_aspectChanged; |
8e2c2fdb | 635 | uint32_t lastAfRegion[4]; |
308291de | 636 | float m_zoomRatio; |
ad37861e SK |
637 | |
638 | mutable Mutex m_qbufLock; | |
639 | ||
0f26b20f SK |
640 | int m_afState; |
641 | int m_afTriggerId; | |
642 | enum aa_afmode m_afMode; | |
643 | enum aa_afmode m_afMode2; | |
644 | bool m_IsAfModeUpdateRequired; | |
645 | bool m_IsAfTriggerRequired; | |
646 | bool m_IsAfLockRequired; | |
647 | int m_serviceAfState; | |
36c106c9 | 648 | bool m_AfHwStateFailed; |
8e2c2fdb SK |
649 | int m_afPendingTriggerId; |
650 | int m_afModeWaitingCnt; | |
eed7ed1b | 651 | struct camera2_shot m_jpegMetadata; |
b55ed664 SK |
652 | int m_scpOutputSignalCnt; |
653 | int m_scpOutputImageCnt; | |
a15b4e3f SK |
654 | int m_nightCaptureCnt; |
655 | int m_nightCaptureFrameCnt; | |
2d5e6ec2 SK |
656 | int m_thumbNailW; |
657 | int m_thumbNailH; | |
9a710a45 | 658 | ctl_request_info_t m_ctlInfo; |
c15a6b00 JS |
659 | }; |
660 | ||
661 | }; // namespace android | |
662 | ||
663 | #endif |