import exynos 7570 bsp
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / libcamera / common_v2 / ExynosCameraStreamManager.cpp
1 /*
2 * Copyright (C) 2014, Samsung Electronics Co. LTD
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /* #define LOG_NDEBUG 0 */
18 #define LOG_TAG "ExynosCameraStreamManager"
19
20 #include "ExynosCameraStreamManager.h"
21
22 namespace android {
23
24 ExynosCamera3Stream::ExynosCamera3Stream(int id, camera3_stream_t *stream)
25 {
26 m_init();
27 m_id = id;
28 m_stream = stream;
29 }
30
31 ExynosCamera3Stream::~ExynosCamera3Stream()
32 {
33 m_deinit();
34 }
35
36 status_t ExynosCamera3Stream::m_init()
37 {
38 m_stream = NULL;
39 m_id = -1;
40 m_actualFormat = -1;
41 m_planeCount = -1;
42 m_outputPortId = -1;
43 m_registerStream = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
44 m_registerBuffer = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
45 m_requestbuffer = -1;
46 m_bufferManager = NULL;
47
48 return NO_ERROR;
49 }
50
51 status_t ExynosCamera3Stream::m_deinit()
52 {
53 m_stream = NULL;
54 m_id = -2;
55 m_actualFormat = -2;
56 m_planeCount = -2;
57 m_outputPortId = -2;
58 m_registerStream = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
59 m_registerBuffer = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
60 m_requestbuffer = -2;
61
62 if (m_bufferManager != NULL) {
63 delete m_bufferManager;
64 m_bufferManager = NULL;
65 }
66
67 return NO_ERROR;
68 }
69
70 status_t ExynosCamera3Stream::setStream(camera3_stream_t *stream)
71 {
72 status_t ret = NO_ERROR;
73 if (stream == NULL) {
74 ALOGE("ERR(%s[%d]):setStream is NULL ", __FUNCTION__, __LINE__);
75 ret = INVALID_OPERATION;
76 } else {
77 m_stream = stream;
78 }
79
80 return ret;
81 }
82
83 status_t ExynosCamera3Stream::getStream(camera3_stream_t **stream)
84 {
85 status_t ret = NO_ERROR;
86 if (m_stream != NULL) {
87 *stream = m_stream;
88 } else {
89 ALOGE("ERR(%s[%d]):getStream m_stream is NULL ", __FUNCTION__, __LINE__);
90 *stream = NULL;
91 ret = INVALID_OPERATION;
92 }
93 return ret;
94 }
95
96 status_t ExynosCamera3Stream::setID(int id)
97 {
98 status_t ret = NO_ERROR;
99
100 if (id < 0) {
101 ALOGE("ERR(%s[%d]):setStreamID invalid value(%d)", __FUNCTION__, __LINE__, id);
102 ret = INVALID_OPERATION;
103 } else {
104 m_id = id;
105 }
106 return ret;
107 }
108
109 status_t ExynosCamera3Stream::getID(int *id)
110 {
111 status_t ret = NO_ERROR;
112
113 if (m_id < 0) {
114 ALOGE("ERR(%s[%d]):getStreamID invalid value(%d)", __FUNCTION__, __LINE__, m_id);
115 ret = INVALID_OPERATION;
116 } else {
117 *id = m_id;
118 }
119
120 return ret;
121 }
122
123 status_t ExynosCamera3Stream::setFormat(int format)
124 {
125 status_t ret = NO_ERROR;
126
127 if (format < 0) {
128 ALOGE("ERR(%s[%d]):setFormat invalid value(%d)", __FUNCTION__, __LINE__, format);
129 ret = INVALID_OPERATION;
130 } else {
131 m_actualFormat = format;
132 }
133 return ret;
134 }
135
136 status_t ExynosCamera3Stream::getFormat(int *format)
137 {
138 status_t ret = NO_ERROR;
139
140 if (m_actualFormat < 0) {
141 ALOGE("ERR(%s[%d]):getFormat invalid value(%d)", __FUNCTION__, __LINE__, m_actualFormat);
142 ret = INVALID_OPERATION;
143 } else {
144 *format = m_actualFormat;
145 }
146 return ret;
147 }
148
149 status_t ExynosCamera3Stream::setPlaneCount(int planes)
150 {
151 status_t ret = NO_ERROR;
152
153 if (planes < 0) {
154 ALOGE("ERR(%s[%d]):setPlaneCount invalid value(%d)", __FUNCTION__, __LINE__, planes);
155 ret = INVALID_OPERATION;
156 } else {
157 m_planeCount = planes;
158 }
159 return ret;
160 }
161
162 status_t ExynosCamera3Stream::getPlaneCount(int *planes)
163 {
164 status_t ret = NO_ERROR;
165
166 if (m_planeCount < 0) {
167 ALOGE("ERR(%s[%d]):getFormat invalid value(%d)", __FUNCTION__, __LINE__, m_planeCount);
168 ret = INVALID_OPERATION;
169 } else {
170 *planes = m_planeCount;
171 }
172 return ret;
173 }
174
175 status_t ExynosCamera3Stream::setOutputPortId(int id)
176 {
177 status_t ret = NO_ERROR;
178
179 if (id < 0) {
180 ALOGE("ERR(%s[%d]):Invalid outputPortId %d",
181 __FUNCTION__, __LINE__, id);
182 ret = BAD_VALUE;
183 } else {
184 m_outputPortId = id;
185 }
186
187 return ret;
188 }
189
190 status_t ExynosCamera3Stream::getOutputPortId(int *id)
191 {
192 status_t ret = NO_ERROR;
193
194 if (m_outputPortId < 0) {
195 ALOGE("ERR(%s[%d]):Invalid outputPortId %d",
196 __FUNCTION__, __LINE__, m_outputPortId);
197 ret = BAD_VALUE;
198 } else {
199 *id = m_outputPortId;
200 }
201
202 return ret;
203 }
204
205 status_t ExynosCamera3Stream::setRegisterStream(EXYNOS_STREAM::STATE state)
206 {
207 status_t ret = NO_ERROR;
208 switch (state) {
209 case EXYNOS_STREAM::HAL_STREAM_STS_INVALID:
210 case EXYNOS_STREAM::HAL_STREAM_STS_VALID:
211 m_registerStream = state;
212 break;
213 case EXYNOS_STREAM::HAL_STREAM_STS_INIT:
214 default:
215 ALOGE("ERR(%s[%d]):setConfigState invalid value(%d)", __FUNCTION__, __LINE__, state);
216 break;
217 }
218 return ret;
219 }
220
221 status_t ExynosCamera3Stream::getRegisterStream(EXYNOS_STREAM::STATE *state)
222 {
223 status_t ret = NO_ERROR;
224 switch (m_registerStream) {
225 case EXYNOS_STREAM::HAL_STREAM_STS_INIT:
226 case EXYNOS_STREAM::HAL_STREAM_STS_INVALID:
227 case EXYNOS_STREAM::HAL_STREAM_STS_VALID:
228 *state = m_registerStream;
229 break;
230 default:
231 ALOGE("ERR(%s[%d]):setConfigState invalid value(%d)", __FUNCTION__, __LINE__, *state);
232 break;
233 }
234 return ret;
235 }
236
237 status_t ExynosCamera3Stream::setRegisterBuffer(EXYNOS_STREAM::STATE state)
238 {
239 status_t ret = NO_ERROR;
240 switch (state) {
241 case EXYNOS_STREAM::HAL_STREAM_STS_REGISTERED:
242 case EXYNOS_STREAM::HAL_STREAM_STS_UNREGISTERED:
243 m_registerBuffer = state;
244 break;
245 case EXYNOS_STREAM::HAL_STREAM_STS_INIT:
246 default:
247 ALOGE("ERR(%s[%d]):setRegisterBuffer invalid value(%d)", __FUNCTION__, __LINE__, state);
248 break;
249 }
250 return ret;
251 }
252
253 status_t ExynosCamera3Stream::getRegisterBuffer(EXYNOS_STREAM::STATE *state)
254 {
255 status_t ret = NO_ERROR;
256 switch (m_registerBuffer) {
257 case EXYNOS_STREAM::HAL_STREAM_STS_INIT:
258 case EXYNOS_STREAM::HAL_STREAM_STS_REGISTERED:
259 case EXYNOS_STREAM::HAL_STREAM_STS_UNREGISTERED:
260 *state = m_registerBuffer;
261 break;
262 default:
263 ALOGE("ERR(%s[%d]):getRegisterBuffer invalid value(%d)", __FUNCTION__, __LINE__, *state);
264 break;
265 }
266 return ret;
267 }
268
269 status_t ExynosCamera3Stream::setRequestBuffer(int bufferCnt)
270 {
271 status_t ret = NO_ERROR;
272
273 if (bufferCnt < 0) {
274 ALOGE("ERR(%s[%d]):setRequestBuffer invalid value(%d)", __FUNCTION__, __LINE__, bufferCnt);
275 ret = INVALID_OPERATION;
276 } else {
277 m_requestbuffer = bufferCnt;
278 m_stream->max_buffers = m_requestbuffer;
279 }
280 return ret;
281 }
282
283 status_t ExynosCamera3Stream::getRequestBuffer(int *bufferCnt)
284 {
285 status_t ret = NO_ERROR;
286
287 if (m_planeCount < 0) {
288 ALOGE("ERR(%s[%d]):getRequestBuffer invalid value(%d)", __FUNCTION__, __LINE__, m_requestbuffer);
289 ret = INVALID_OPERATION;
290 } else {
291 *bufferCnt = m_requestbuffer;
292 }
293 return ret;
294 }
295
296 status_t ExynosCamera3Stream::setBufferManager(ExynosCameraBufferManager *bufferManager)
297 {
298 status_t ret = NO_ERROR;
299
300 if (m_bufferManager != NULL) {
301 ALOGE("ERR(%s[%d]):m_bufferManager is not NULL", __FUNCTION__, __LINE__);
302 ret = INVALID_OPERATION;
303 bufferManager = NULL;
304 } else {
305 m_bufferManager = bufferManager;
306 ALOGD("DEBUG(%s[%d]):m_bufferManager(%p)", __FUNCTION__, __LINE__, m_bufferManager);
307 }
308
309 return ret;
310 }
311
312 status_t ExynosCamera3Stream::getBufferManager(ExynosCameraBufferManager **bufferManager)
313 {
314 status_t ret = NO_ERROR;
315
316 if (m_bufferManager == NULL) {
317 ALOGE("ERR(%s[%d]):m_bufferManager is NULL", __FUNCTION__, __LINE__);
318 ret = INVALID_OPERATION;
319 *bufferManager = NULL;
320 } else {
321 *bufferManager = m_bufferManager;
322 ALOGV("DEBUG(%s[%d]):m_bufferManager(%p)", __FUNCTION__, __LINE__, m_bufferManager);
323 }
324
325 return ret;
326 }
327
328 ExynosCameraStreamManager::ExynosCameraStreamManager(int cameraId)
329 {
330 ALOGD("DEBUG(%s[%d]):ID(%d)", __FUNCTION__, __LINE__, cameraId);
331 m_cameraId = cameraId;
332 m_init();
333 }
334
335 ExynosCameraStreamManager::~ExynosCameraStreamManager()
336 {
337 ALOGD("DEBUG(%s[%d]):", __FUNCTION__, __LINE__);
338 m_deinit();
339 }
340
341 void ExynosCameraStreamManager::m_init()
342 {
343 ALOGD("DEBUG(%s[%d]):ID(%d)", __FUNCTION__, __LINE__, m_cameraId);
344 m_exynosconfig = NULL;
345 m_streamInfoMap.clear();
346 m_yuvStreamCount = 0;
347 m_yuvStreamMaxCount = 0;
348
349 for (int i = 0; i < MAX_YUV_STREAM_COUNT; i++)
350 m_yuvStreamIdMap[i] = -1;
351 }
352
353 void ExynosCameraStreamManager::m_deinit()
354 {
355 ALOGD("DEBUG(%s[%d]):ID(%d)", __FUNCTION__, __LINE__, m_cameraId);
356 StreamInfoMap::iterator iter;
357
358 ExynosCameraStream *streaminfo = NULL;
359
360 m_streamInfoLock.lock();
361 for (iter = m_streamInfoMap.begin() ; iter != m_streamInfoMap.end() ;) {
362 streaminfo = iter->second;
363 m_streamInfoMap.erase(iter++);
364 delete streaminfo;
365 streaminfo = NULL;
366 }
367 m_streamInfoMap.clear();
368 m_streamInfoLock.unlock();
369 }
370
371 status_t ExynosCameraStreamManager::dumpCurrentStreamList(void)
372 {
373 ALOGD("DEBUG(%s[%d]):Stream List dump-----", __FUNCTION__, __LINE__);
374 status_t ret = NO_ERROR;
375 ExynosCameraStream *streaminfo = NULL;
376 int id = 0;
377 EXYNOS_STREAM::STATE registerStream = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
378 EXYNOS_STREAM::STATE registerBuf = EXYNOS_STREAM::HAL_STREAM_STS_INIT;
379 camera3_stream_t *currentStream = NULL;
380
381
382
383 if (m_streamInfoMap.empty()) {
384 ALOGE("ERR(%s[%d]):list is empty", __FUNCTION__, __LINE__);
385 return NOT_ENOUGH_DATA;
386 }
387
388 for (StreamInfoIterator s = m_streamInfoMap.begin(); s != m_streamInfoMap.end();) {
389 streaminfo = s->second;
390 if (streaminfo == NULL) {
391 ALOGE("ERR(%s[%d]):streaminfo is NULL id(%d)", __FUNCTION__, __LINE__, s->first);
392 s++;
393 continue;
394 }
395
396 ret = streaminfo->getStream(&currentStream);
397 if (ret < 0) {
398 ALOGE("ERR(%s[%d]):m_insert failed -> delete stream, id(%d)", __FUNCTION__, __LINE__, s->first);
399 s++;
400 continue;
401 }
402
403 streaminfo->getID(&id);
404 streaminfo->getRegisterStream(&registerStream);
405 streaminfo->getRegisterBuffer(&registerBuf);
406 ALOGD("DEBUG(%s[%d]):Stream(%p), ID(%d), type(%d), usage(0x%x) format(0x%x) (%d,%d)", __FUNCTION__,
407 __LINE__, currentStream, id,
408 currentStream->stream_type, currentStream->usage, currentStream->format,
409 currentStream->width, currentStream->height);
410 ALOGD("DEBUG(%s[%d]):status %d / %d", __FUNCTION__, __LINE__, registerStream, registerBuf);
411 s++;
412 }
413
414 return OK;
415 }
416
417 status_t ExynosCameraStreamManager::setConfig(struct ExynosConfigInfo *config)
418 {
419 status_t ret = NO_ERROR;
420 m_exynosconfig = config;
421
422 ALOGD("DEBUG(%s[%d]):preview(%d), raw(%d), jpeg(%d), recording(%d), yuvCallback(%d)",
423 __FUNCTION__, __LINE__,
424 m_exynosconfig->current->bufInfo.num_preview_buffers,
425 m_exynosconfig->current->bufInfo.num_bayer_buffers,
426 m_exynosconfig->current->bufInfo.num_picture_buffers,
427 m_exynosconfig->current->bufInfo.num_recording_buffers,
428 m_exynosconfig->current->bufInfo.num_preview_cb_buffers);
429
430 return ret;
431 }
432
433 ExynosCameraStream* ExynosCameraStreamManager::createStream(int id, camera3_stream_t *stream)
434 {
435 int ret = NO_ERROR;
436 ExynosCameraStream *obj = NULL;
437 obj = new ExynosCamera3Stream(id, stream);
438 if (obj == NULL){
439 ALOGE("ERR(%s[%d]):m_insert failed stream id(%d)", __FUNCTION__, __LINE__, id);
440 return NULL;
441 }
442 stream->priv = static_cast<void*>(obj);
443
444 ret = m_insert(id, obj, &m_streamInfoMap, &m_streamInfoLock);
445 if (ret < 0){
446 m_delete(obj);
447 ALOGE("ERR(%s[%d]):m_insert failed -> delete stream, id(%d)", __FUNCTION__, __LINE__, id);
448 }
449 return obj;
450 }
451
452 status_t ExynosCameraStreamManager::deleteStream(int id)
453 {
454 int ret = NO_ERROR;
455
456 ret = m_delete(id, &m_streamInfoMap, &m_streamInfoLock);
457 if (ret < 0) {
458 ALOGE("ERR(%s[%d]):eraseStream failed stream id(%d)", __FUNCTION__, __LINE__, id);
459 }
460
461 ret = m_decreaseYuvStreamCount(id);
462 if (ret != NO_ERROR) {
463 ALOGE("ERR(%s[%d]):Failed to decreaseYuvStreamCount. streamId %d",
464 __FUNCTION__, __LINE__, id);
465 }
466
467 return ret;
468 }
469
470 status_t ExynosCameraStreamManager::getStream(int id, ExynosCameraStream **stream)
471 {
472 status_t ret = NO_ERROR;
473 *stream = NULL;
474
475 ret = m_get(id, stream, &m_streamInfoMap, &m_streamInfoLock);
476
477 if (ret < 0) {
478 *stream = NULL;
479 return BAD_VALUE;
480 }
481
482 return ret;
483 }
484
485 bool ExynosCameraStreamManager::findStream(int id)
486 {
487 status_t ret = NO_ERROR;
488 bool found = true;
489
490 ret = m_find(id, &m_streamInfoMap, &m_streamInfoLock);
491 if (ret != NO_ERROR)
492 found = false;
493
494 return found;
495 }
496
497 status_t ExynosCameraStreamManager::getStreamKeys(List<int> *keylist)
498 {
499 status_t ret = NO_ERROR;
500 StreamInfoIterator iter;
501
502 for (iter = m_streamInfoMap.begin(); iter != m_streamInfoMap.end() ; iter++) {
503 ALOGV("DEBUG(%s[%d]):stream key is(%d)", __FUNCTION__, __LINE__, iter->first);
504
505 keylist->push_back(iter->first);
506 }
507
508 return ret;
509 }
510
511 status_t ExynosCameraStreamManager::setYuvStreamMaxCount(int32_t count)
512 {
513 m_yuvStreamMaxCount = count;
514
515 return NO_ERROR;
516 }
517
518 int32_t ExynosCameraStreamManager::getYuvStreamCount(void)
519 {
520 return m_yuvStreamCount;
521 }
522
523 int ExynosCameraStreamManager::getYuvStreamId(int outputPortId)
524 {
525 if (outputPortId < 0 || outputPortId >= 3) {
526 ALOGE("ERR(%s[%d]):Invalid outputPortId %d",
527 __FUNCTION__, __LINE__, outputPortId);
528 return -1;
529 }
530
531 return m_yuvStreamIdMap[outputPortId];
532 }
533
534 int ExynosCameraStreamManager::getOutputPortId(int streamId)
535 {
536 int outputPortId = -1;
537
538 if (streamId < 0) {
539 ALOGE("ERR(%s[%d]):Invalid streamId %d",
540 __FUNCTION__, __LINE__, streamId);
541 return -1;
542 }
543
544 for (int i = 0; i < 3; i++) {
545 if (m_yuvStreamIdMap[i] == streamId)
546 outputPortId = i;
547 }
548
549 return outputPortId;
550 }
551
552 status_t ExynosCameraStreamManager::m_insert(int id, ExynosCameraStream *item, StreamInfoMap *list, Mutex *lock)
553 {
554 status_t ret = NO_ERROR;
555 lock->lock();
556 pair<StreamInfoMap::iterator,bool> listRet;
557
558 listRet = list->insert( pair<int, ExynosCameraStream*>(id, item));
559
560 while(listRet.second == false) {
561 id += HAL_STREAM_ID_MAX;
562 listRet = list->insert( pair<int, ExynosCameraStream*>(id, item));
563 ALOGW("WARN(%s[%d]):insert id is re-define id + HAL_STREAM_ID_MAX = (%d)", __FUNCTION__, __LINE__, id);
564 }
565
566 if (listRet.second == true) {
567 ALOGI("INFO(%s[%d]):inserted stream and id is (%d)", __FUNCTION__, __LINE__, id);
568 item->setID(id);
569 }
570
571 ret = m_increaseYuvStreamCount(id);
572 if (ret != NO_ERROR) {
573 ALOGE("ERR(%s[%d]):Failed to updateYuvStreamCount. yuvStreamCount %d streamId %d",
574 __FUNCTION__, __LINE__, m_yuvStreamCount, id);
575 return ret;
576 }
577
578 lock->unlock();
579 return ret;
580 }
581
582 status_t ExynosCameraStreamManager::m_erase(int id, ExynosCameraStream **item, StreamInfoMap *list, Mutex *lock)
583 {
584 status_t ret = NO_ERROR;
585 StreamInfoMap::iterator iter;
586
587 lock->lock();
588 iter = list->find(id);
589 if (iter != list->end()) {
590 *item = iter->second;
591 list->erase(iter);
592 } else {
593 ret = BAD_VALUE;
594 ALOGE("ERR(%s[%d]):StreamInfoMap is not EXIST stream id(%d)", __FUNCTION__, __LINE__, id);
595 *item = NULL;
596 }
597 lock->unlock();
598
599 return ret;
600 }
601
602 status_t ExynosCameraStreamManager::m_find(int id, StreamInfoMap *list, Mutex *lock)
603 {
604 status_t ret = NO_ERROR;
605 StreamInfoMap::iterator iter;
606
607 if (list == NULL) {
608 ALOGE("ERR(%s[%d]):list is NULL", __FUNCTION__, __LINE__);
609 return BAD_VALUE;
610 }
611
612 if (lock == NULL) {
613 ALOGE("ERR(%s[%d]):lock is NULL", __FUNCTION__, __LINE__);
614 return BAD_VALUE;
615 }
616
617 lock->lock();
618 iter = list->find(id);
619 if (iter == list->end()) {
620 ret = BAD_VALUE;
621 }
622 lock->unlock();
623
624 return ret;
625 }
626
627 status_t ExynosCameraStreamManager::m_get(int id, ExynosCameraStream **item, StreamInfoMap *list, Mutex *lock)
628 {
629 status_t ret = NO_ERROR;
630 StreamInfoMap::iterator iter;
631
632 lock->lock();
633 iter = list->find(id);
634 if (iter != list->end()) {
635 *item = iter->second;
636 } else {
637 ALOGE("ERR(%s[%d]):StreamInfoMap is not EXIST stream id(%d)", __FUNCTION__, __LINE__, id);
638 ret = BAD_VALUE;
639 }
640 lock->unlock();
641
642 return ret;
643 }
644
645 status_t ExynosCameraStreamManager::m_delete(int id, StreamInfoMap *list, Mutex *lock)
646 {
647 status_t ret = NO_ERROR;
648 StreamInfoMap::iterator iter;
649 ExynosCameraStream *item = NULL;
650
651 lock->lock();
652 iter = list->find(id);
653 if (iter != list->end()) {
654 item = iter->second;
655 list->erase(iter);
656 m_delete(item);
657 } else {
658 ret = BAD_VALUE;
659 ALOGE("ERR(%s[%d]):StreamInfoMap is not EXIST stream id(%d)", __FUNCTION__, __LINE__, id);
660 }
661 lock->unlock();
662
663 return ret;
664 }
665
666 status_t ExynosCameraStreamManager::m_delete(ExynosCameraStream *stream)
667 {
668 status_t ret = NO_ERROR;
669 camera3_stream_t *obj = NULL;
670 int streamId = -1;
671
672 if (stream == NULL){
673 ret = BAD_VALUE;
674 ALOGE("ERR(%s[%d]):StreamInfoMap is not EXIST stream", __FUNCTION__, __LINE__);
675 return ret;
676 }
677
678 ret = stream->getStream(&obj);
679 obj->priv = NULL;
680
681 stream->getID(&streamId);
682
683 delete stream;
684 stream = NULL;
685 return ret;
686 }
687
688 status_t ExynosCameraStreamManager::m_increaseYuvStreamCount(int id)
689 {
690 status_t ret = NO_ERROR;
691
692 switch (id % HAL_STREAM_ID_MAX) {
693 case HAL_STREAM_ID_PREVIEW:
694 case HAL_STREAM_ID_VIDEO:
695 case HAL_STREAM_ID_CALLBACK:
696 m_yuvStreamIdMap[m_yuvStreamCount++] = id;
697 break;
698 case HAL_STREAM_ID_RAW:
699 case HAL_STREAM_ID_JPEG:
700 case HAL_STREAM_ID_ZSL_OUTPUT:
701 case HAL_STREAM_ID_ZSL_INPUT:
702 /* Not YUV streams */
703 break;
704 default:
705 ALOGE("ERR(%s[%d]):Unsupported stream id %d",
706 __FUNCTION__, __LINE__);
707 ret = BAD_VALUE;
708 break;
709 }
710
711 if (m_yuvStreamCount > m_yuvStreamMaxCount) {
712 ALOGE("ERR(%s[%d]):Too many YUV stream!. maxYuvStreamCount %d currentYuvStreamCount %d",
713 __FUNCTION__, __LINE__,
714 m_yuvStreamMaxCount, m_yuvStreamCount);
715 ret = INVALID_OPERATION;
716 }
717
718 return ret;
719 }
720
721 status_t ExynosCameraStreamManager::m_decreaseYuvStreamCount(int id)
722 {
723 if (id < 0) {
724 ALOGE("ERR(%s[%d]):Invalid streamId %d",
725 __FUNCTION__, __LINE__, id);
726 return BAD_VALUE;
727 }
728
729 for (int i = 0; i < 3; i++) {
730 if (m_yuvStreamIdMap[i] == id) {
731 m_yuvStreamIdMap[i] = -1;
732 m_yuvStreamCount--;
733 }
734 }
735
736 return NO_ERROR;
737 }
738
739 }; /* namespace android */