1 /*
2 * Copyright (C) Texas Instruments - http://www.ti.com/
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 /**
18 * @file OMXCap.cpp
19 *
20 * This file implements the OMX Capabilities feature.
21 *
22 */
23
24 #include "CameraHal.h"
25 #include "OMXCameraAdapter.h"
26 #include "ErrorUtils.h"
27 #include "TICameraParameters.h"
28
29 namespace android {
30
31 #undef LOG_TAG
32
33 // Maintain a separate tag for OMXCameraAdapter logs to isolate issues OMX specific
34 #define LOG_TAG "CameraHAL"
35
36 /************************************
37 * global constants and variables
38 *************************************/
39
40 #define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0]))
41 #define FPS_MIN 5
42 #define FPS_STEP 5
43 #define FPS_RANGE_STEP 5
44
45 static const char PARAM_SEP[] = ",";
46 static const int PARAM_SEP_CHAR = ',';
47 static const uint32_t VFR_OFFSET = 8;
48 static const char VFR_BACKET_START[] = "(";
49 static const char VFR_BRACKET_END[] = ")";
50 static const char FRAMERATE_COUNT = 10;
51
52 /**** look up tables to translate OMX Caps to Parameter ****/
53
54 const CapResolution OMXCameraAdapter::mImageCapRes [] = {
55 { 4032, 3024, "4032x3024" },
56 { 4000, 3000, "4000x3000" },
57 { 3648, 2736, "3648x2736" },
58 { 3264, 2448, "3264x2448" },
59 { 2592, 1944, "2592x1944" },
60 { 2048, 1536, "2048x1536" },
61 { 1600, 1200, "1600x1200" },
62 { 1280, 1024, "1280x1024" },
63 { 1152, 864, "1152x864" },
64 { 1280, 960, "1280x960" },
65 { 640, 480, "640x480" },
66 { 320, 240, "320x240" },
67 };
68
69 const CapResolution OMXCameraAdapter::mPreviewRes [] = {
70 { 1920, 1080, "1920x1080" },
71 { 1280, 720, "1280x720" },
72 { 960, 720, "960x720" },
73 { 800, 480, "800x480" },
74 { 720, 576, "720x576" },
75 { 720, 480, "720x480" },
76 { 768, 576, "768x576" },
77 { 640, 480, "640x480" },
78 { 320, 240, "320x240" },
79 { 352, 288, "352x288" },
80 { 240, 160, "240x160" },
81 { 176, 144, "176x144" },
82 { 128, 96, "128x96" },
83 };
84
85 const CapResolution OMXCameraAdapter::mThumbRes [] = {
86 { 640, 480, "640x480" },
87 { 160, 120, "160x120" },
88 { 200, 120, "200x120" },
89 { 320, 240, "320x240" },
90 { 512, 384, "512x384" },
91 { 352, 144, "352x144" },
92 { 176, 144, "176x144" },
93 { 96, 96, "96x96" },
94 };
95
96 const CapPixelformat OMXCameraAdapter::mPixelformats [] = {
97 { OMX_COLOR_FormatCbYCrY, CameraParameters::PIXEL_FORMAT_YUV422I },
98 { OMX_COLOR_FormatYUV420SemiPlanar, CameraParameters::PIXEL_FORMAT_YUV420SP },
99 { OMX_COLOR_Format16bitRGB565, CameraParameters::PIXEL_FORMAT_RGB565 },
100 { OMX_COLOR_FormatRawBayer10bit, TICameraParameters::PIXEL_FORMAT_RAW },
101 { OMX_COLOR_FormatYUV420SemiPlanar, CameraParameters::PIXEL_FORMAT_YUV420P },
102 };
103
104 const CapFramerate OMXCameraAdapter::mFramerates [] = {
105 { 30, "30" },
106 { 15, "15" },
107 };
108
109 const CapZoom OMXCameraAdapter::mZoomStages [] = {
110 { 65536, "100" },
111 { 68157, "104" },
112 { 70124, "107" },
113 { 72745, "111" },
114 { 75366, "115" },
115 { 77988, "119" },
116 { 80609, "123" },
117 { 83231, "127" },
118 { 86508, "132" },
119 { 89784, "137" },
120 { 92406, "141" },
121 { 95683, "146" },
122 { 99615, "152" },
123 { 102892, "157" },
124 { 106168, "162" },
125 { 110100, "168" },
126 { 114033, "174" },
127 { 117965, "180" },
128 { 122552, "187" },
129 { 126484, "193" },
130 { 131072, "200" },
131 { 135660, "207" },
132 { 140247, "214" },
133 { 145490, "222" },
134 { 150733, "230" },
135 { 155976, "238" },
136 { 161219, "246" },
137 { 167117, "255" },
138 { 173015, "264" },
139 { 178913, "273" },
140 { 185467, "283" },
141 { 192020, "293" },
142 { 198574, "303" },
143 { 205783, "314" },
144 { 212992, "325" },
145 { 220201, "336" },
146 { 228065, "348" },
147 { 236585, "361" },
148 { 244449, "373" },
149 { 252969, "386" },
150 { 262144, "400" },
151 { 271319, "414" },
152 { 281149, "429" },
153 { 290980, "444" },
154 { 300810, "459" },
155 { 311951, "476" },
156 { 322437, "492" },
157 { 334234, "510" },
158 { 346030, "528" },
159 { 357827, "546" },
160 { 370934, "566" },
161 { 384041, "586" },
162 { 397148, "606" },
163 { 411566, "628" },
164 { 425984, "650" },
165 { 441057, "673" },
166 { 456131, "696" },
167 { 472515, "721" },
168 { 488899, "746" },
169 { 506593, "773" },
170 { 524288, "800" },
171 };
172
173 const CapISO OMXCameraAdapter::mISOStages [] = {
174 { 0, "auto" },
175 { 100, "100" },
176 { 200, "200"},
177 { 400, "400" },
178 { 800, "800" },
179 { 1000, "1000" },
180 { 1200, "1200" },
181 { 1600, "1600" },
182 };
183
184 // mapped values have to match with new_sensor_MSP.h
185 const CapU32 OMXCameraAdapter::mSensorNames [] = {
186 { 300, "IMX060" },
187 { 301, "OV5650" },
188 { 305, "S5K4E1GA"},
189 { 306, "S5K6A1GX03" }
190 // TODO(XXX): need to account for S3D camera later
191 };
192
193 // values for supported variable framerates sorted in ascending order
194 // CapU32Pair = (max fps, min fps, string representation)
195 const CapU32Pair OMXCameraAdapter::mVarFramerates [] = {
196 { 15, 15, "(15000,15000)"},
197 { 30, 15, "(15000,30000)" },
198 { 30, 24, "(24000,30000)" },
199 // TODO(XXX): Removing 30,30 range to limit 1080p at 24fps. Will put back soon.
200 #if 0
201 { 30, 30, "(30000,30000)" },
202 #endif
203 };
204 /************************************
205 * static helper functions
206 *************************************/
207
208 // utility function to remove last seperator
remove_last_sep(char * buffer)209 void remove_last_sep(char* buffer) {
210 char* last_sep = NULL;
211 last_sep = strrchr(buffer, PARAM_SEP_CHAR);
212 if (last_sep != NULL) {
213 last_sep[0] = '\0';
214 }
215 }
216
217
218 /*****************************************
219 * internal static function declarations
220 *****************************************/
221
222 /**** Utility functions to help translate OMX Caps to Parameter ****/
223
encodePixelformatCap(OMX_COLOR_FORMATTYPE format,const CapPixelformat * cap,size_t capCount,char * buffer,size_t bufferSize)224 status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format,
225 const CapPixelformat *cap,
226 size_t capCount,
227 char * buffer,
228 size_t bufferSize) {
229 status_t ret = NO_ERROR;
230
231 LOG_FUNCTION_NAME;
232
233 if ( ( NULL == buffer ) || ( NULL == cap ) ) {
234 CAMHAL_LOGEA("Invalid input arguments");
235 return -EINVAL;
236 }
237
238 for ( unsigned int i = 0; i < capCount; i++ ) {
239 if ( format == cap[i].pixelformat ) {
240 strncat(buffer, cap[i].param, bufferSize - 1);
241 strncat(buffer, PARAM_SEP, bufferSize - 1);
242 }
243 }
244
245 LOG_FUNCTION_NAME_EXIT;
246
247 return ret;
248 }
249
encodeFramerateCap(OMX_U32 framerateMax,OMX_U32 framerateMin,const CapFramerate * cap,size_t capCount,char * buffer,size_t bufferSize)250 status_t OMXCameraAdapter::encodeFramerateCap(OMX_U32 framerateMax,
251 OMX_U32 framerateMin,
252 const CapFramerate *cap,
253 size_t capCount,
254 char * buffer,
255 size_t bufferSize) {
256 status_t ret = NO_ERROR;
257 bool minInserted = false;
258 bool maxInserted = false;
259 char tmpBuffer[FRAMERATE_COUNT];
260
261 LOG_FUNCTION_NAME;
262
263 if ( ( NULL == buffer ) || ( NULL == cap ) ) {
264 CAMHAL_LOGEA("Invalid input arguments");
265 return -EINVAL;
266 }
267
268 for ( unsigned int i = 0; i < capCount; i++ ) {
269 if ( (framerateMax >= cap[i].num) && (framerateMin <= cap[i].num) ) {
270 strncat(buffer, cap[i].param, bufferSize - 1);
271 strncat(buffer, PARAM_SEP, bufferSize - 1);
272
273 if ( cap[i].num == framerateMin ) {
274 minInserted = true;
275 }
276 }
277 if ( cap[i].num == framerateMax ) {
278 maxInserted = true;
279 }
280 }
281
282 if ( !maxInserted ) {
283 memset(tmpBuffer, 0, FRAMERATE_COUNT);
284 snprintf(tmpBuffer, FRAMERATE_COUNT - 1, "%u,", ( unsigned int ) framerateMax);
285 strncat(buffer, tmpBuffer, bufferSize - 1);
286 strncat(buffer, PARAM_SEP, bufferSize - 1);
287 }
288
289 if ( !minInserted ) {
290 memset(tmpBuffer, 0, FRAMERATE_COUNT);
291 snprintf(tmpBuffer, FRAMERATE_COUNT - 1, "%u,", ( unsigned int ) framerateMin);
292 strncat(buffer, tmpBuffer, bufferSize - 1);
293 strncat(buffer, PARAM_SEP, bufferSize - 1);
294 }
295
296 remove_last_sep(buffer);
297
298 LOG_FUNCTION_NAME_EXIT;
299
300 return ret;
301 }
302
encodeVFramerateCap(OMX_TI_CAPTYPE & caps,const CapU32Pair * cap,size_t capCount,char * buffer,char * defaultRange,size_t bufferSize)303 status_t OMXCameraAdapter::encodeVFramerateCap(OMX_TI_CAPTYPE &caps,
304 const CapU32Pair *cap,
305 size_t capCount,
306 char *buffer,
307 char *defaultRange,
308 size_t bufferSize) {
309 status_t ret = NO_ERROR;
310 uint32_t minVFR, maxVFR;
311 int default_index = -1;
312
313 LOG_FUNCTION_NAME;
314
315 if ( (NULL == buffer) || (NULL == cap) ) {
316 CAMHAL_LOGEA("Invalid input arguments");
317 return -EINVAL;
318 }
319
320 if(caps.ulPrvVarFPSModesCount < 1) {
321 return NO_ERROR;
322 }
323
324 // Assumption: last range in tPrvVarFPSModes will be for S30FPSHD mode
325 minVFR = caps.tPrvVarFPSModes[caps.ulPrvVarFPSModesCount-1].nVarFPSMin >> VFR_OFFSET;
326 maxVFR = caps.tPrvVarFPSModes[caps.ulPrvVarFPSModesCount-1].nVarFPSMax >> VFR_OFFSET;
327
328 if (minVFR < FPS_MIN) {
329 minVFR = FPS_MIN;
330 }
331
332 for (unsigned int i = 0; i < capCount; i++) {
333 // add cap[i] if it is in range and maxVFR != minVFR
334 if ((maxVFR >= cap[i].num1) && (minVFR <= cap[i].num2)) {
335 if (buffer[0] != '\0') {
336 strncat(buffer, PARAM_SEP, bufferSize - 1);
337 }
338 strncat(buffer, cap[i].param, bufferSize - 1);
339
340 // choose the max variable framerate as default
341 if (cap[i].num1 != cap[i].num2) {
342 default_index = i;
343 }
344 }
345 }
346
347 // if we haven't found any caps in the list to populate
348 // just use the min and max
349 if (buffer[0] == '\0') {
350 snprintf(buffer, bufferSize - 1,
351 "(%u,%u)",
352 minVFR * CameraHal::VFR_SCALE,
353 maxVFR * CameraHal::VFR_SCALE);
354 }
355
356 if (default_index != -1) {
357 snprintf(defaultRange, (MAX_PROP_VALUE_LENGTH - 1), "%lu,%lu",
358 cap[default_index].num2 * CameraHal::VFR_SCALE,
359 cap[default_index].num1 * CameraHal::VFR_SCALE);
360 } else {
361 snprintf(defaultRange, (MAX_PROP_VALUE_LENGTH - 1), "%u,%u",
362 minVFR * CameraHal::VFR_SCALE, maxVFR * CameraHal::VFR_SCALE);
363 }
364
365 LOG_FUNCTION_NAME_EXIT;
366
367 return ret;
368 }
369
encodeZoomCap(OMX_S32 maxZoom,const CapZoom * cap,size_t capCount,char * buffer,size_t bufferSize)370 size_t OMXCameraAdapter::encodeZoomCap(OMX_S32 maxZoom,
371 const CapZoom *cap,
372 size_t capCount,
373 char * buffer,
374 size_t bufferSize) {
375 status_t res = NO_ERROR;
376 size_t ret = 0;
377
378 LOG_FUNCTION_NAME;
379
380 if ( (NULL == buffer) || (NULL == cap) ) {
381 CAMHAL_LOGEA("Invalid input arguments");
382 return -EINVAL;
383 }
384
385
386 for ( unsigned int i = 0; i < capCount; i++ ) {
387 if ( cap[i].num <= maxZoom ) {
388 strncat(buffer, cap[i].param, bufferSize - 1);
389 strncat(buffer, PARAM_SEP, bufferSize - 1);
390 ret++;
391 }
392 }
393 remove_last_sep(buffer);
394
395 LOG_FUNCTION_NAME_EXIT;
396
397 return ret;
398 }
399
encodeISOCap(OMX_U32 maxISO,const CapISO * cap,size_t capCount,char * buffer,size_t bufferSize)400 status_t OMXCameraAdapter::encodeISOCap(OMX_U32 maxISO,
401 const CapISO *cap,
402 size_t capCount,
403 char * buffer,
404 size_t bufferSize) {
405 status_t ret = NO_ERROR;
406
407 LOG_FUNCTION_NAME;
408
409 if ( (NULL == buffer) || (NULL == cap) ) {
410 CAMHAL_LOGEA("Invalid input arguments");
411 return -EINVAL;
412 }
413
414 for ( unsigned int i = 0; i < capCount; i++ ) {
415 if ( cap[i].num <= maxISO) {
416 strncat(buffer, cap[i].param, bufferSize - 1);
417 strncat(buffer, PARAM_SEP, bufferSize - 1);
418 }
419 }
420 remove_last_sep(buffer);
421
422 LOG_FUNCTION_NAME_EXIT;
423
424 return ret;
425 }
426
encodeSizeCap(OMX_TI_CAPRESTYPE & res,const CapResolution * cap,size_t capCount,char * buffer,size_t bufferSize)427 status_t OMXCameraAdapter::encodeSizeCap(OMX_TI_CAPRESTYPE &res,
428 const CapResolution *cap,
429 size_t capCount,
430 char * buffer,
431 size_t bufferSize) {
432 status_t ret = NO_ERROR;
433
434 LOG_FUNCTION_NAME;
435
436 if ( (NULL == buffer) || (NULL == cap) ) {
437 CAMHAL_LOGEA("Invalid input arguments");
438 return -EINVAL;
439 }
440
441 for ( unsigned int i = 0 ; i < capCount ; i++ ) {
442 if ( (cap[i].width <= res.nWidthMax) &&
443 (cap[i].height <= res.nHeightMax) &&
444 (cap[i].width >= res.nWidthMin) &&
445 (cap[i].height >= res.nHeightMin) ) {
446 strncat(buffer, cap[i].param, bufferSize -1);
447 strncat(buffer, PARAM_SEP, bufferSize - 1);
448 }
449 }
450
451 LOG_FUNCTION_NAME_EXIT;
452
453 return ret;
454 }
455
insertImageSizes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)456 status_t OMXCameraAdapter::insertImageSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
457 status_t ret = NO_ERROR;
458 char supported[MAX_PROP_VALUE_LENGTH];
459
460 LOG_FUNCTION_NAME;
461
462 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
463
464 ret = encodeSizeCap(caps.tImageResRange,
465 mImageCapRes,
466 ARRAY_SIZE(mImageCapRes),
467 supported,
468 MAX_PROP_VALUE_LENGTH);
469
470 if ( NO_ERROR != ret ) {
471 CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret);
472 } else {
473 remove_last_sep(supported);
474 params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, supported);
475 }
476
477 LOG_FUNCTION_NAME;
478
479 return ret;
480 }
481
insertPreviewSizes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)482 status_t OMXCameraAdapter::insertPreviewSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
483 status_t ret = NO_ERROR;
484 char supported[MAX_PROP_VALUE_LENGTH];
485
486 LOG_FUNCTION_NAME;
487
488 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
489
490 ret = encodeSizeCap(caps.tPreviewResRange,
491 mPreviewRes,
492 ARRAY_SIZE(mPreviewRes),
493 supported,
494 MAX_PROP_VALUE_LENGTH);
495
496 if ( NO_ERROR != ret ) {
497 CAMHAL_LOGEB("Error inserting supported preview sizes 0x%x", ret);
498 } else {
499 remove_last_sep(supported);
500 params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, supported);
501 }
502
503 LOG_FUNCTION_NAME;
504
505 return ret;
506 }
507
insertVideoSizes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)508 status_t OMXCameraAdapter::insertVideoSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
509 status_t ret = NO_ERROR;
510 char supported[MAX_PROP_VALUE_LENGTH];
511
512 LOG_FUNCTION_NAME;
513
514 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
515
516 ret = encodeSizeCap(caps.tPreviewResRange,
517 mPreviewRes,
518 ARRAY_SIZE(mPreviewRes),
519 supported,
520 MAX_PROP_VALUE_LENGTH);
521
522 if ( NO_ERROR != ret ) {
523 CAMHAL_LOGEB("Error inserting supported video sizes 0x%x", ret);
524 } else {
525 remove_last_sep(supported);
526 params->set(CameraProperties::SUPPORTED_VIDEO_SIZES, supported);
527 }
528
529 LOG_FUNCTION_NAME;
530
531 return ret;
532 }
533
insertThumbSizes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)534 status_t OMXCameraAdapter::insertThumbSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
535 status_t ret = NO_ERROR;
536 char supported[MAX_PROP_VALUE_LENGTH];
537
538 LOG_FUNCTION_NAME;
539
540 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
541
542 ret = encodeSizeCap(caps.tThumbResRange,
543 mThumbRes,
544 ARRAY_SIZE(mThumbRes),
545 supported,
546 MAX_PROP_VALUE_LENGTH);
547
548 if ( NO_ERROR != ret ) {
549 CAMHAL_LOGEB("Error inserting supported thumbnail sizes 0x%x", ret);
550 } else {
551 //CTS Requirement: 0x0 should always be supported
552 strncat(supported, "0x0", MAX_PROP_NAME_LENGTH);
553 params->set(CameraProperties::SUPPORTED_THUMBNAIL_SIZES, supported);
554 }
555
556 LOG_FUNCTION_NAME;
557
558 return ret;
559 }
560
insertZoomStages(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)561 status_t OMXCameraAdapter::insertZoomStages(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps)
562 {
563 status_t ret = NO_ERROR;
564 char supported[MAX_PROP_VALUE_LENGTH];
565 size_t zoomStageCount = 0;
566
567 LOG_FUNCTION_NAME;
568
569 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
570
571 zoomStageCount = encodeZoomCap(caps.xMaxWidthZoom,
572 mZoomStages,
573 ARRAY_SIZE(mZoomStages),
574 supported,
575 MAX_PROP_VALUE_LENGTH);
576
577 params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS, supported);
578 params->set(CameraProperties::SUPPORTED_ZOOM_STAGES, zoomStageCount - 1); //As per CTS requirement
579
580 if ( 0 == zoomStageCount ) {
581 params->set(CameraProperties::ZOOM_SUPPORTED, TICameraParameters::ZOOM_UNSUPPORTED);
582 params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, TICameraParameters::ZOOM_UNSUPPORTED);
583 } else {
584 params->set(CameraProperties::ZOOM_SUPPORTED, TICameraParameters::ZOOM_SUPPORTED);
585 params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, TICameraParameters::ZOOM_SUPPORTED);
586 }
587
588 LOG_FUNCTION_NAME;
589
590 return ret;
591 }
592
insertImageFormats(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)593 status_t OMXCameraAdapter::insertImageFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
594 status_t ret = NO_ERROR;
595 char supported[MAX_PROP_VALUE_LENGTH];
596
597 LOG_FUNCTION_NAME;
598
599 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
600
601 for ( int i = 0 ; i < caps.ulImageFormatCount ; i++ ) {
602 ret = encodePixelformatCap(caps.eImageFormats[i],
603 mPixelformats,
604 ARRAY_SIZE(mPixelformats),
605 supported,
606 MAX_PROP_VALUE_LENGTH);
607 if ( NO_ERROR != ret ) {
608 CAMHAL_LOGEB("Error inserting supported picture formats 0x%x", ret);
609 break;
610 }
611 }
612
613 if ( NO_ERROR == ret ) {
614 //jpeg is not supported in OMX capabilies yet
615 strncat(supported, CameraParameters::PIXEL_FORMAT_JPEG, MAX_PROP_VALUE_LENGTH - 1);
616 params->set(CameraProperties::SUPPORTED_PICTURE_FORMATS, supported);
617 }
618
619 LOG_FUNCTION_NAME;
620
621 return ret;
622 }
623
insertPreviewFormats(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)624 status_t OMXCameraAdapter::insertPreviewFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
625 status_t ret = NO_ERROR;
626 char supported[MAX_PROP_VALUE_LENGTH];
627
628 LOG_FUNCTION_NAME;
629
630 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
631
632 for ( int i = 0 ; i < caps.ulPreviewFormatCount; i++ ) {
633 ret = encodePixelformatCap(caps.ePreviewFormats[i],
634 mPixelformats,
635 ARRAY_SIZE(mPixelformats),
636 supported,
637 MAX_PROP_VALUE_LENGTH);
638 if ( NO_ERROR != ret ) {
639 CAMHAL_LOGEB("Error inserting supported preview formats 0x%x", ret);
640 break;
641 }
642 }
643
644 if ( NO_ERROR == ret ) {
645 // need to advertise we support YV12 format
646 // We will program preview port with NV21 when we see application set YV12
647 strncat(supported, CameraParameters::PIXEL_FORMAT_YUV420P, MAX_PROP_VALUE_LENGTH - 1);
648 params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS, supported);
649 }
650
651 LOG_FUNCTION_NAME;
652
653 return ret;
654 }
655
insertFramerates(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)656 status_t OMXCameraAdapter::insertFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
657 status_t ret = NO_ERROR;
658 char supported[MAX_PROP_VALUE_LENGTH];
659
660 LOG_FUNCTION_NAME;
661
662 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
663
664 ret = encodeFramerateCap(caps.xFramerateMax >> VFR_OFFSET,
665 caps.xFramerateMin >> VFR_OFFSET,
666 mFramerates,
667 ARRAY_SIZE(mFramerates),
668 supported,
669 MAX_PROP_VALUE_LENGTH);
670
671 if ( NO_ERROR != ret ) {
672 CAMHAL_LOGEB("Error inserting supported preview framerates 0x%x", ret);
673 } else {
674 params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES, supported);
675 }
676
677 LOG_FUNCTION_NAME;
678
679 return ret;
680 }
681
insertVFramerates(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)682 status_t OMXCameraAdapter::insertVFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
683 status_t ret = NO_ERROR;
684 char supported[MAX_PROP_VALUE_LENGTH];
685 char defaultRange[MAX_PROP_VALUE_LENGTH];
686
687 LOG_FUNCTION_NAME;
688
689 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
690
691 ret = encodeVFramerateCap(caps,
692 mVarFramerates,
693 ARRAY_SIZE(mVarFramerates),
694 supported,
695 defaultRange,
696 MAX_PROP_VALUE_LENGTH);
697
698 if ( NO_ERROR != ret ) {
699 CAMHAL_LOGEB("Error inserting supported preview framerate ranges 0x%x", ret);
700 } else {
701 params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported);
702 CAMHAL_LOGDB("framerate ranges %s", supported);
703 params->set(CameraProperties::FRAMERATE_RANGE, DEFAULT_FRAMERATE_RANGE_IMAGE);
704 params->set(CameraProperties::FRAMERATE_RANGE_VIDEO, DEFAULT_FRAMERATE_RANGE_VIDEO);
705 params->set(CameraProperties::FRAMERATE_RANGE_IMAGE, DEFAULT_FRAMERATE_RANGE_IMAGE);
706 CAMHAL_LOGDB("Default framerate range: [%s]", DEFAULT_FRAMERATE_RANGE_IMAGE);
707 }
708
709 LOG_FUNCTION_NAME;
710
711 return ret;
712 }
713
insertEVs(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)714 status_t OMXCameraAdapter::insertEVs(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
715 status_t ret = NO_ERROR;
716 char supported[MAX_PROP_VALUE_LENGTH];
717
718 LOG_FUNCTION_NAME;
719
720 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
721
722 snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.xEVCompensationMin * 10 ));
723 params->set(CameraProperties::SUPPORTED_EV_MIN, supported);
724
725 snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.xEVCompensationMax * 10 ));
726 params->set(CameraProperties::SUPPORTED_EV_MAX, supported);
727
728 LOG_FUNCTION_NAME;
729
730 return ret;
731 }
732
insertISOModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)733 status_t OMXCameraAdapter::insertISOModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
734 status_t ret = NO_ERROR;
735 char supported[MAX_PROP_VALUE_LENGTH];
736
737 LOG_FUNCTION_NAME;
738
739 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
740
741 ret = encodeISOCap(caps.nSensitivityMax,
742 mISOStages,
743 ARRAY_SIZE(mISOStages),
744 supported,
745 MAX_PROP_VALUE_LENGTH);
746 if ( NO_ERROR != ret ) {
747 CAMHAL_LOGEB("Error inserting supported ISO modes 0x%x", ret);
748 } else {
749 params->set(CameraProperties::SUPPORTED_ISO_VALUES, supported);
750 }
751
752 LOG_FUNCTION_NAME;
753
754 return ret;
755 }
756
insertIPPModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)757 status_t OMXCameraAdapter::insertIPPModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
758 status_t ret = NO_ERROR;
759 char supported[MAX_PROP_VALUE_LENGTH];
760
761 LOG_FUNCTION_NAME;
762
763 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
764
765 //Off is always supported
766 strncat(supported, TICameraParameters::IPP_NONE, MAX_PROP_NAME_LENGTH);
767 strncat(supported, PARAM_SEP, 1);
768
769 if ( caps.bLensDistortionCorrectionSupported ) {
770 strncat(supported, TICameraParameters::IPP_LDC, MAX_PROP_NAME_LENGTH);
771 strncat(supported, PARAM_SEP, 1);
772 }
773
774 if ( caps.bISONoiseFilterSupported ) {
775 strncat(supported, TICameraParameters::IPP_NSF, MAX_PROP_NAME_LENGTH);
776 strncat(supported, PARAM_SEP, 1);
777 }
778
779 if ( caps.bISONoiseFilterSupported && caps.bLensDistortionCorrectionSupported ) {
780 strncat(supported, TICameraParameters::IPP_LDCNSF, MAX_PROP_NAME_LENGTH);
781 strncat(supported, PARAM_SEP, 1);
782 }
783
784 remove_last_sep(supported);
785 params->set(CameraProperties::SUPPORTED_IPP_MODES, supported);
786
787 LOG_FUNCTION_NAME;
788
789 return ret;
790 }
791
insertWBModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)792 status_t OMXCameraAdapter::insertWBModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
793 status_t ret = NO_ERROR;
794 char supported[MAX_PROP_VALUE_LENGTH];
795 const char *p;
796
797 LOG_FUNCTION_NAME;
798
799 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
800
801 for ( unsigned int i = 0 ; i < caps.ulWhiteBalanceCount ; i++ ) {
802 p = getLUTvalue_OMXtoHAL(caps.eWhiteBalanceModes[i], WBalLUT);
803 if ( NULL != p ) {
804 strncat(supported, p, MAX_PROP_NAME_LENGTH);
805 strncat(supported, PARAM_SEP, 1);
806 }
807 }
808
809 params->set(CameraProperties::SUPPORTED_WHITE_BALANCE, supported);
810
811 LOG_FUNCTION_NAME;
812
813 return ret;
814 }
815
insertEffects(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)816 status_t OMXCameraAdapter::insertEffects(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
817 status_t ret = NO_ERROR;
818 char supported[MAX_PROP_VALUE_LENGTH];
819 const char *p;
820
821 LOG_FUNCTION_NAME;
822
823 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
824
825 for ( unsigned int i = 0 ; i < caps.ulColorEffectCount; i++ ) {
826 p = getLUTvalue_OMXtoHAL(caps.eColorEffects[i], EffLUT);
827 if ( NULL != p ) {
828 strncat(supported, p, MAX_PROP_NAME_LENGTH);
829 strncat(supported, PARAM_SEP, 1);
830 }
831 }
832 remove_last_sep(supported);
833 params->set(CameraProperties::SUPPORTED_EFFECTS, supported);
834
835 LOG_FUNCTION_NAME;
836
837 return ret;
838 }
839
insertExpModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)840 status_t OMXCameraAdapter::insertExpModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
841 status_t ret = NO_ERROR;
842 char supported[MAX_PROP_VALUE_LENGTH];
843 const char *p;
844
845 LOG_FUNCTION_NAME;
846
847 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
848
849 for ( unsigned int i = 0 ; i < caps.ulExposureModeCount; i++ ) {
850 p = getLUTvalue_OMXtoHAL(caps.eExposureModes[i], ExpLUT);
851 if ( NULL != p ) {
852 strncat(supported, p, MAX_PROP_NAME_LENGTH);
853 strncat(supported, PARAM_SEP, 1);
854 }
855 }
856
857 params->set(CameraProperties::SUPPORTED_EXPOSURE_MODES, supported);
858
859 LOG_FUNCTION_NAME;
860
861 return ret;
862 }
863
insertFlashModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)864 status_t OMXCameraAdapter::insertFlashModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
865 status_t ret = NO_ERROR;
866 char supported[MAX_PROP_VALUE_LENGTH];
867 const char *p;
868
869 LOG_FUNCTION_NAME;
870
871 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
872
873 for ( unsigned int i = 0 ; i < caps.ulFlashCount; i++ ) {
874 p = getLUTvalue_OMXtoHAL(caps.eFlashModes[i], FlashLUT);
875 if ( NULL != p ) {
876 strncat(supported, p, MAX_PROP_NAME_LENGTH);
877 strncat(supported, PARAM_SEP, 1);
878 }
879 }
880
881 remove_last_sep(supported);
882 params->set(CameraProperties::SUPPORTED_FLASH_MODES, supported);
883
884 LOG_FUNCTION_NAME;
885
886 return ret;
887 }
888
insertSceneModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)889 status_t OMXCameraAdapter::insertSceneModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
890 status_t ret = NO_ERROR;
891 char supported[MAX_PROP_VALUE_LENGTH];
892 const char *p;
893
894 LOG_FUNCTION_NAME;
895
896 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
897
898 for ( unsigned int i = 0 ; i < caps.ulSceneCount; i++ ) {
899 p = getLUTvalue_OMXtoHAL(caps.eSceneModes[i], SceneLUT);
900 if ( NULL != p ) {
901 strncat(supported, p, MAX_PROP_NAME_LENGTH);
902 strncat(supported, PARAM_SEP, 1);
903 }
904 }
905
906 remove_last_sep(supported);
907 params->set(CameraProperties::SUPPORTED_SCENE_MODES, supported);
908
909 LOG_FUNCTION_NAME;
910
911 return ret;
912 }
913
insertFocusModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)914 status_t OMXCameraAdapter::insertFocusModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
915 status_t ret = NO_ERROR;
916 char supported[MAX_PROP_VALUE_LENGTH];
917 const char *p;
918
919 LOG_FUNCTION_NAME;
920
921 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
922
923 for ( unsigned int i = 0 ; i < caps.ulFocusModeCount; i++ ) {
924 p = getLUTvalue_OMXtoHAL(caps.eFocusModes[i], FocusLUT);
925 if ( NULL != p ) {
926 strncat(supported, p, MAX_PROP_NAME_LENGTH);
927 strncat(supported, PARAM_SEP, 1);
928 }
929 }
930
931 // Check if focus is supported by camera
932 if (caps.ulFocusModeCount == 1 &&
933 caps.eFocusModes[0] == OMX_IMAGE_FocusControlOff) {
934 // Focus is not supported by camera
935 // Advertise this to app as infinitiy focus mode
936 strncat(supported, CameraParameters::FOCUS_MODE_INFINITY, MAX_PROP_NAME_LENGTH);
937 } else {
938 // Focus is supported but these modes are not supported by the
939 // capability feature. Apply manually
940 strncat(supported, CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE, MAX_PROP_NAME_LENGTH);
941 }
942
943 params->set(CameraProperties::SUPPORTED_FOCUS_MODES, supported);
944
945 LOG_FUNCTION_NAME;
946
947 return ret;
948 }
949
insertFlickerModes(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)950 status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
951 status_t ret = NO_ERROR;
952 char supported[MAX_PROP_VALUE_LENGTH];
953 const char *p;
954
955 LOG_FUNCTION_NAME;
956
957 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
958
959 for ( unsigned int i = 0 ; i < caps.ulFlickerCount; i++ ) {
960 p = getLUTvalue_OMXtoHAL(caps.eFlicker[i], FlickerLUT);
961 if ( NULL != p ) {
962 strncat(supported, p, MAX_PROP_NAME_LENGTH);
963 strncat(supported, PARAM_SEP, 1);
964 }
965 }
966 remove_last_sep(supported);
967 params->set(CameraProperties::SUPPORTED_ANTIBANDING, supported);
968
969 LOG_FUNCTION_NAME;
970
971 return ret;
972 }
973
insertAreas(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)974 status_t OMXCameraAdapter::insertAreas(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
975 status_t ret = NO_ERROR;
976 char supported[MAX_PROP_VALUE_LENGTH];
977 const char *p;
978
979 LOG_FUNCTION_NAME;
980
981 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
982
983 sprintf(supported, "%d", caps.ulAlgoAreasFocusCount);
984 params->set(CameraProperties::MAX_FOCUS_AREAS, supported);
985 CAMHAL_LOGDB("Maximum supported focus areas %s", supported);
986
987 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
988 sprintf(supported, "%d", caps.ulAlgoAreasExposureCount);
989 params->set(CameraProperties::MAX_NUM_METERING_AREAS, supported);
990 CAMHAL_LOGDB("Maximum supported exposure areas %s", supported);
991
992 LOG_FUNCTION_NAME;
993
994 return ret;
995 }
996
insertLocks(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)997 status_t OMXCameraAdapter::insertLocks(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
998 status_t ret = NO_ERROR;
999
1000 LOG_FUNCTION_NAME
1001
1002 params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, DEFAULT_LOCK_SUPPORTED);
1003 params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, DEFAULT_LOCK_SUPPORTED);
1004
1005 LOG_FUNCTION_NAME
1006
1007 return ret;
1008 }
1009
insertDefaults(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)1010 status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
1011 status_t ret = NO_ERROR;
1012 char supported[MAX_PROP_VALUE_LENGTH];
1013 const char *p;
1014
1015 LOG_FUNCTION_NAME;
1016
1017 params->set(CameraProperties::ANTIBANDING, DEFAULT_ANTIBANDING);
1018 params->set(CameraProperties::BRIGHTNESS, DEFAULT_BRIGHTNESS);
1019 params->set(CameraProperties::CONTRAST, DEFAULT_CONTRAST);
1020 params->set(CameraProperties::EFFECT, DEFAULT_EFFECT);
1021 params->set(CameraProperties::EV_COMPENSATION, DEFAULT_EV_COMPENSATION);
1022 params->set(CameraProperties::SUPPORTED_EV_STEP, DEFAULT_EV_STEP);
1023 params->set(CameraProperties::EXPOSURE_MODE, DEFAULT_EXPOSURE_MODE);
1024 params->set(CameraProperties::FLASH_MODE, DEFAULT_FLASH_MODE);
1025 char *pos = strstr(params->get(CameraProperties::SUPPORTED_FOCUS_MODES), DEFAULT_FOCUS_MODE_PREFERRED);
1026 if ( NULL != pos )
1027 {
1028 params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE_PREFERRED);
1029 }
1030 else
1031 {
1032 params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE);
1033 }
1034 params->set(CameraProperties::IPP, DEFAULT_IPP);
1035 params->set(CameraProperties::GBCE, DEFAULT_GBCE);
1036 params->set(CameraProperties::ISO_MODE, DEFAULT_ISO_MODE);
1037 params->set(CameraProperties::JPEG_QUALITY, DEFAULT_JPEG_QUALITY);
1038 params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, DEFAULT_THUMBNAIL_QUALITY);
1039 params->set(CameraProperties::JPEG_THUMBNAIL_SIZE, DEFAULT_THUMBNAIL_SIZE);
1040 params->set(CameraProperties::PICTURE_FORMAT, DEFAULT_PICTURE_FORMAT);
1041 params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SIZE);
1042 params->set(CameraProperties::PREVIEW_FORMAT, DEFAULT_PREVIEW_FORMAT);
1043 params->set(CameraProperties::PREVIEW_FRAME_RATE, DEFAULT_FRAMERATE);
1044 params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE);
1045 params->set(CameraProperties::REQUIRED_PREVIEW_BUFS, DEFAULT_NUM_PREV_BUFS);
1046 params->set(CameraProperties::REQUIRED_IMAGE_BUFS, DEFAULT_NUM_PIC_BUFS);
1047 params->set(CameraProperties::SATURATION, DEFAULT_SATURATION);
1048 params->set(CameraProperties::SCENE_MODE, DEFAULT_SCENE_MODE);
1049 params->set(CameraProperties::SHARPNESS, DEFAULT_SHARPNESS);
1050 params->set(CameraProperties::VSTAB, DEFAULT_VSTAB);
1051 params->set(CameraProperties::VSTAB_SUPPORTED, DEFAULT_VSTAB_SUPPORTED);
1052 params->set(CameraProperties::WHITEBALANCE, DEFAULT_WB);
1053 params->set(CameraProperties::ZOOM, DEFAULT_ZOOM);
1054 params->set(CameraProperties::MAX_FD_HW_FACES, DEFAULT_MAX_FD_HW_FACES);
1055 params->set(CameraProperties::MAX_FD_SW_FACES, DEFAULT_MAX_FD_SW_FACES);
1056 params->set(CameraProperties::AUTO_EXPOSURE_LOCK, DEFAULT_AE_LOCK);
1057 params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK, DEFAULT_AWB_LOCK);
1058 if(caps.tSenMounting.nSenId == 305) {
1059 params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_PRIMARY);
1060 } else {
1061 params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_SECONDARY);
1062 }
1063 params->set(CameraProperties::HOR_ANGLE, DEFAULT_HOR_ANGLE);
1064 params->set(CameraProperties::VER_ANGLE, DEFAULT_VER_ANGLE);
1065 params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, DEFAULT_VIDEO_SNAPSHOT_SUPPORTED);
1066 params->set(CameraProperties::VIDEO_SIZE, DEFAULT_VIDEO_SIZE);
1067 params->set(CameraProperties::PREFERRED_PREVIEW_SIZE_FOR_VIDEO, DEFAULT_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);
1068
1069 LOG_FUNCTION_NAME;
1070
1071 return ret;
1072 }
1073
insertSenMount(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)1074 status_t OMXCameraAdapter::insertSenMount(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
1075 status_t ret = NO_ERROR;
1076 char supported[MAX_PROP_VALUE_LENGTH];
1077 const char *p;
1078 unsigned int i = 0;
1079
1080 LOG_FUNCTION_NAME;
1081
1082 memset(supported, '\0', MAX_PROP_VALUE_LENGTH);
1083
1084 // 1) Look up and assign sensor name
1085 for (i = 0; i < ARRAY_SIZE(mSensorNames); i++) {
1086 if(mSensorNames[i].num == caps.tSenMounting.nSenId) {
1087 // sensor found
1088 break;
1089 }
1090 }
1091 if ( i == ARRAY_SIZE(mSensorNames) ) {
1092 p = "UNKNOWN_SENSOR";
1093 } else {
1094 p = mSensorNames[i].param;
1095 }
1096 strncat(supported, p, MAX_PROP_NAME_LENGTH);
1097 params->set(CameraProperties::CAMERA_NAME, supported);
1098
1099 // 2) Assign mounting rotation
1100 params->set(CameraProperties::ORIENTATION_INDEX, caps.tSenMounting.nRotation);
1101
1102 LOG_FUNCTION_NAME;
1103
1104 return ret;
1105 }
1106
insertCapabilities(CameraProperties::Properties * params,OMX_TI_CAPTYPE & caps)1107 status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) {
1108 status_t ret = NO_ERROR;
1109 char supported[MAX_PROP_VALUE_LENGTH];
1110
1111 LOG_FUNCTION_NAME;
1112
1113 if ( NO_ERROR == ret ) {
1114 ret = insertImageSizes(params, caps);
1115 }
1116
1117 if ( NO_ERROR == ret ) {
1118 ret = insertPreviewSizes(params, caps);
1119 }
1120
1121 if ( NO_ERROR == ret ) {
1122 ret = insertThumbSizes(params, caps);
1123 }
1124
1125 if ( NO_ERROR == ret ) {
1126 ret = insertZoomStages(params, caps);
1127 }
1128
1129 if ( NO_ERROR == ret ) {
1130 ret = insertImageFormats(params, caps);
1131 }
1132
1133 if ( NO_ERROR == ret ) {
1134 ret = insertPreviewFormats(params, caps);
1135 }
1136
1137 if ( NO_ERROR == ret ) {
1138 ret = insertFramerates(params, caps);
1139 }
1140
1141 if ( NO_ERROR == ret ) {
1142 ret = insertVFramerates(params, caps);
1143 }
1144
1145 if ( NO_ERROR == ret ) {
1146 ret = insertEVs(params, caps);
1147 }
1148
1149 if ( NO_ERROR == ret ) {
1150 ret = insertISOModes(params, caps);
1151 }
1152
1153 if ( NO_ERROR == ret ) {
1154 ret = insertIPPModes(params, caps);
1155 }
1156
1157 if ( NO_ERROR == ret ) {
1158 ret = insertWBModes(params, caps);
1159 }
1160
1161 if ( NO_ERROR == ret ) {
1162 ret = insertEffects(params, caps);
1163 }
1164
1165 if ( NO_ERROR == ret ) {
1166 ret = insertExpModes(params, caps);
1167 }
1168
1169 if ( NO_ERROR == ret ) {
1170 ret = insertFlashModes(params, caps);
1171 }
1172
1173 if ( NO_ERROR == ret ) {
1174 ret = insertSceneModes(params, caps);
1175 }
1176
1177 if ( NO_ERROR == ret ) {
1178 ret = insertFocusModes(params, caps);
1179 }
1180
1181 if ( NO_ERROR == ret ) {
1182 ret = insertFlickerModes(params, caps);
1183 }
1184
1185 if ( NO_ERROR == ret ) {
1186 ret = insertSenMount(params, caps);
1187 }
1188
1189 if ( NO_ERROR == ret ) {
1190 ret = insertLocks(params, caps);
1191 }
1192 if ( NO_ERROR == ret) {
1193 ret = insertAreas(params, caps);
1194
1195 }
1196
1197 //NOTE: Ensure that we always call insertDefaults after inserting the supported capabilities
1198 //as there are checks inside insertDefaults to make sure a certain default is supported
1199 // or not
1200 if ( NO_ERROR == ret ) {
1201 ret = insertVideoSizes(params, caps);
1202 }
1203
1204 if ( NO_ERROR == ret ) {
1205 ret = insertDefaults(params, caps);
1206 }
1207
1208
1209
1210 LOG_FUNCTION_NAME_EXIT;
1211
1212 return ret;
1213 }
1214
1215 /*****************************************
1216 * public exposed function declarations
1217 *****************************************/
1218
getCaps(CameraProperties::Properties * params,OMX_HANDLETYPE handle)1219 status_t OMXCameraAdapter::getCaps(CameraProperties::Properties* params, OMX_HANDLETYPE handle) {
1220 status_t ret = NO_ERROR;
1221 int caps_size = 0;
1222 OMX_ERRORTYPE eError = OMX_ErrorNone;
1223 OMX_TI_CAPTYPE** caps = NULL;;
1224 OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer;
1225 MemoryManager memMgr;
1226
1227 LOG_FUNCTION_NAME;
1228
1229 // allocate tiler (or ion) buffer for caps (size is always a multiple of 4K)
1230 caps_size = ((sizeof(OMX_TI_CAPTYPE)+4095)/4096)*4096;
1231 caps = (OMX_TI_CAPTYPE**) memMgr.allocateBuffer(0, 0, NULL, caps_size, 1);
1232
1233 if (!caps) {
1234 CAMHAL_LOGEB("Error allocating buffer for caps %d", eError);
1235 ret = -ENOMEM;
1236 goto EXIT;
1237 }
1238
1239 // initialize structures to be passed to OMX Camera
1240 OMX_INIT_STRUCT_PTR (caps[0], OMX_TI_CAPTYPE);
1241 caps[0]->nPortIndex = OMX_ALL;
1242
1243 OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER);
1244 sharedBuffer.nPortIndex = OMX_ALL;
1245 sharedBuffer.nSharedBuffSize = caps_size;
1246 sharedBuffer.pSharedBuff = (OMX_U8 *) caps[0];
1247
1248 // Get capabilities from OMX Camera
1249 eError = OMX_GetConfig(handle, (OMX_INDEXTYPE) OMX_TI_IndexConfigCamCapabilities, &sharedBuffer);
1250 if ( OMX_ErrorNone != eError ) {
1251 CAMHAL_LOGEB("Error during capabilities query 0x%x", eError);
1252 ret = UNKNOWN_ERROR;
1253 goto EXIT;
1254 } else {
1255 CAMHAL_LOGDA("OMX capability query success");
1256 }
1257
1258 // Translate and insert Ducati capabilities to CameraProperties
1259 if ( NO_ERROR == ret ) {
1260 ret = insertCapabilities(params, *caps[0]);
1261 }
1262
1263 CAMHAL_LOGDB("sen mount id=%u", (unsigned int)caps[0]->tSenMounting.nSenId);
1264
1265
1266 EXIT:
1267 if (caps) {
1268 memMgr.freeBuffer((void*) caps);
1269 caps = NULL;
1270 }
1271
1272 LOG_FUNCTION_NAME_EXIT;
1273 return ret;
1274 }
1275
1276 };
1277
1278