4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 /*===========================================================================================
26 ========================================================================================== */
27 #include "mm_camcorder_internal.h"
28 #include "mm_camcorder_platform.h"
29 #include "mm_camcorder_configure.h"
31 /*---------------------------------------------------------------------------
32 | GLOBAL VARIABLE DEFINITIONS for internal |
33 ---------------------------------------------------------------------------*/
35 /*---------------------------------------------------------------------------
36 | LOCAL VARIABLE DEFINITIONS for internal |
37 ---------------------------------------------------------------------------*/
38 #define MM_CAMCORDER_ATTR_NONE -1
41 // Rule 1. 1:1 match except NONE.
42 // Rule 2. MSL should be Superset.
43 // Rule 3. sensor value should not be same as _MMCAMCORDER_SENSOR_ENUM_NONE.
45 static int __enum_conv_whitebalance[MM_CAMCORDER_WHITE_BALANCE_NUM] ;
47 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_whitebalance =
49 MM_CAMCORDER_WHITE_BALANCE_NUM,
50 __enum_conv_whitebalance,
51 CONFIGURE_CATEGORY_CTRL_EFFECT,
56 static int __enum_conv_colortone[MM_CAMCORDER_COLOR_TONE_NUM];
58 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_colortone =
60 MM_CAMCORDER_COLOR_TONE_NUM,
61 __enum_conv_colortone,
62 CONFIGURE_CATEGORY_CTRL_EFFECT,
67 static int __enum_conv_iso[MM_CAMCORDER_ISO_NUM];
69 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_iso =
73 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
78 static int __enum_conv_prgrm[MM_CAMCORDER_SCENE_MODE_NUM];
80 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_prgrm =
82 MM_CAMCORDER_SCENE_MODE_NUM,
84 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
89 static int __enum_conv_focus_mode[MM_CAMCORDER_FOCUS_MODE_NUM];
91 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_focus_mode =
93 MM_CAMCORDER_FOCUS_MODE_NUM,
94 __enum_conv_focus_mode,
95 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
100 static int __enum_conv_focus_type[MM_CAMCORDER_AUTO_FOCUS_NUM];
102 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_focus_type =
104 MM_CAMCORDER_AUTO_FOCUS_NUM,
105 __enum_conv_focus_type,
106 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
111 static int __enum_conv_ae_type[MM_CAMCORDER_AUTO_EXPOSURE_NUM];
113 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_ae_type =
115 MM_CAMCORDER_AUTO_EXPOSURE_NUM,
117 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
122 static int __enum_conv_strobe_ctrl[MM_CAMCORDER_STROBE_CONTROL_NUM];
124 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_strobe_ctrl =
126 MM_CAMCORDER_STROBE_CONTROL_NUM,
127 __enum_conv_strobe_ctrl,
128 CONFIGURE_CATEGORY_CTRL_STROBE,
133 static int __enum_conv_strobe_mode[MM_CAMCORDER_STROBE_MODE_NUM];
135 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_strobe_mode =
137 MM_CAMCORDER_STROBE_MODE_NUM,
138 __enum_conv_strobe_mode,
139 CONFIGURE_CATEGORY_CTRL_STROBE,
144 static int __enum_conv_wdr_ctrl[MM_CAMCORDER_WDR_NUM];
146 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_wdr_ctrl =
148 MM_CAMCORDER_WDR_NUM,
149 __enum_conv_wdr_ctrl,
150 CONFIGURE_CATEGORY_CTRL_EFFECT,
154 static int __enum_conv_flip_ctrl[MM_CAMCORDER_FLIP_NUM];
156 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_flip_ctrl =
158 MM_CAMCORDER_FLIP_NUM,
159 __enum_conv_flip_ctrl,
160 CONFIGURE_CATEGORY_CTRL_EFFECT,
164 static int __enum_conv_rotation_ctrl[MM_CAMCORDER_ROTATION_NUM];
166 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_rotation_ctrl =
168 MM_CAMCORDER_ROTATION_NUM,
169 __enum_conv_rotation_ctrl,
170 CONFIGURE_CATEGORY_CTRL_EFFECT,
175 static int __enum_conv_ahs[MM_CAMCORDER_AHS_NUM];
177 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_ahs =
179 MM_CAMCORDER_AHS_NUM,
181 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
186 static int __enum_conv_video_stabilization[MM_CAMCORDER_VIDEO_STABILIZATION_NUM];
188 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_video_stabilization =
190 MM_CAMCORDER_VIDEO_STABILIZATION_NUM,
191 __enum_conv_video_stabilization,
192 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
197 static int __enum_conv_hdr_capture[MM_CAMCORDER_HDR_CAPTURE_NUM];
199 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_hdr_capture =
201 MM_CAMCORDER_HDR_CAPTURE_NUM,
202 __enum_conv_hdr_capture,
203 CONFIGURE_CATEGORY_CTRL_CAPTURE,
207 static int __enum_conv_detect_mode[MM_CAMCORDER_DETECT_MODE_NUM];
209 _MMCamcorderEnumConvert _mmcamcorder_enum_conv_detect_mode =
211 MM_CAMCORDER_DETECT_MODE_NUM,
212 __enum_conv_detect_mode,
213 CONFIGURE_CATEGORY_CTRL_DETECT,
219 * Matching table of caminfo index with category enum of attribute.
220 * If predefined item is changed, this static variables should be changed.
221 * For detail information, refer below documents.
224 static _MMCamcorderInfoConverting g_audio_info[] = {
227 CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
229 MM_CAMCORDER_ATTR_NONE,
231 MM_CAMCONVERT_TYPE_INT_ARRAY,
236 static _MMCamcorderInfoConverting g_display_info[] = {
239 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
240 MM_CAM_DISPLAY_DEVICE,
241 MM_CAMCORDER_ATTR_NONE,
243 MM_CAMCONVERT_TYPE_INT_ARRAY,
248 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
250 MM_CAMCORDER_ATTR_NONE,
252 MM_CAMCONVERT_TYPE_INT_ARRAY,
257 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
258 MM_CAM_DISPLAY_SURFACE,
259 MM_CAMCORDER_ATTR_NONE,
261 MM_CAMCONVERT_TYPE_INT_ARRAY,
266 static _MMCamcorderInfoConverting g_caminfo_convert[CAMINFO_CONVERT_NUM] = {
269 CONFIGURE_CATEGORY_CTRL_CAMERA,
270 MM_CAM_CAMERA_DEVICE_NAME,
271 MM_CAMCORDER_ATTR_NONE,
273 MM_CAMCONVERT_TYPE_STRING,
278 CONFIGURE_CATEGORY_CTRL_CAMERA,
280 MM_CAM_CAMERA_HEIGHT,
282 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
287 CONFIGURE_CATEGORY_CTRL_CAMERA,
288 MM_CAM_CAPTURE_WIDTH,
289 MM_CAM_CAPTURE_HEIGHT,
291 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
296 CONFIGURE_CATEGORY_CTRL_CAMERA,
297 MM_CAM_CAMERA_FORMAT,
298 MM_CAMCORDER_ATTR_NONE,
300 MM_CAMCONVERT_TYPE_INT_ARRAY,
305 CONFIGURE_CATEGORY_CTRL_STROBE,
306 MM_CAM_STROBE_CONTROL,
307 MM_CAMCORDER_ATTR_NONE,
309 MM_CAMCONVERT_TYPE_INT_ARRAY,
310 &_mmcamcorder_enum_conv_strobe_ctrl,
314 CONFIGURE_CATEGORY_CTRL_STROBE,
315 MM_CAM_STROBE_CAPABILITIES,
316 MM_CAMCORDER_ATTR_NONE,
317 "StrobeCapabilities",
318 MM_CAMCONVERT_TYPE_INT_ARRAY,
323 CONFIGURE_CATEGORY_CTRL_STROBE,
325 MM_CAMCORDER_ATTR_NONE,
327 MM_CAMCONVERT_TYPE_INT_ARRAY,
328 &_mmcamcorder_enum_conv_strobe_mode,
332 CONFIGURE_CATEGORY_CTRL_EFFECT,
333 MM_CAM_FILTER_BRIGHTNESS,
334 MM_CAMCORDER_ATTR_NONE,
336 MM_CAMCONVERT_TYPE_INT_RANGE,
341 CONFIGURE_CATEGORY_CTRL_EFFECT,
342 MM_CAM_FILTER_CONTRAST,
343 MM_CAMCORDER_ATTR_NONE,
345 MM_CAMCONVERT_TYPE_INT_RANGE,
350 CONFIGURE_CATEGORY_CTRL_EFFECT,
351 MM_CAM_FILTER_SATURATION,
352 MM_CAMCORDER_ATTR_NONE,
354 MM_CAMCONVERT_TYPE_INT_RANGE,
359 CONFIGURE_CATEGORY_CTRL_EFFECT,
361 MM_CAMCORDER_ATTR_NONE,
363 MM_CAMCONVERT_TYPE_INT_RANGE,
368 CONFIGURE_CATEGORY_CTRL_EFFECT,
369 MM_CAM_FILTER_SHARPNESS,
370 MM_CAMCORDER_ATTR_NONE,
372 MM_CAMCONVERT_TYPE_INT_RANGE,
377 CONFIGURE_CATEGORY_CTRL_EFFECT,
379 MM_CAMCORDER_ATTR_NONE,
381 MM_CAMCONVERT_TYPE_INT_ARRAY,
382 &_mmcamcorder_enum_conv_whitebalance,
386 CONFIGURE_CATEGORY_CTRL_EFFECT,
387 MM_CAM_FILTER_COLOR_TONE,
388 MM_CAMCORDER_ATTR_NONE,
390 MM_CAMCONVERT_TYPE_INT_ARRAY,
391 &_mmcamcorder_enum_conv_colortone,
395 CONFIGURE_CATEGORY_CTRL_EFFECT,
397 MM_CAMCORDER_ATTR_NONE,
399 MM_CAMCONVERT_TYPE_INT_ARRAY,
400 &_mmcamcorder_enum_conv_wdr_ctrl,
404 CONFIGURE_CATEGORY_CTRL_EFFECT,
406 MM_CAMCORDER_ATTR_NONE,
408 MM_CAMCONVERT_TYPE_INT_ARRAY,
409 &_mmcamcorder_enum_conv_flip_ctrl,
413 CONFIGURE_CATEGORY_CTRL_EFFECT,
414 MM_CAM_CAMERA_ROTATION,
415 MM_CAMCORDER_ATTR_NONE,
417 MM_CAMCONVERT_TYPE_INT_ARRAY,
418 &_mmcamcorder_enum_conv_rotation_ctrl,
422 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
423 MM_CAM_CAMERA_DIGITAL_ZOOM,
424 MM_CAMCORDER_ATTR_NONE,
426 MM_CAMCONVERT_TYPE_INT_RANGE,
431 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
432 MM_CAM_CAMERA_OPTICAL_ZOOM,
433 MM_CAMCORDER_ATTR_NONE,
435 MM_CAMCONVERT_TYPE_INT_RANGE,
440 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
441 MM_CAM_CAMERA_FOCUS_MODE,
442 MM_CAMCORDER_ATTR_NONE,
444 MM_CAMCONVERT_TYPE_INT_ARRAY,
445 &_mmcamcorder_enum_conv_focus_mode,
449 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
450 MM_CAM_CAMERA_AF_SCAN_RANGE,
451 MM_CAMCORDER_ATTR_NONE,
453 MM_CAMCONVERT_TYPE_INT_ARRAY,
454 &_mmcamcorder_enum_conv_focus_type,
458 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
459 MM_CAM_CAMERA_EXPOSURE_MODE,
460 MM_CAMCORDER_ATTR_NONE,
462 MM_CAMCONVERT_TYPE_INT_ARRAY,
463 &_mmcamcorder_enum_conv_ae_type,
467 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
468 MM_CAM_CAMERA_EXPOSURE_VALUE,
469 MM_CAMCORDER_ATTR_NONE,
471 MM_CAMCONVERT_TYPE_INT_RANGE,
476 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
477 MM_CAM_CAMERA_F_NUMBER,
478 MM_CAMCORDER_ATTR_NONE,
480 MM_CAMCONVERT_TYPE_INT_ARRAY,
485 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
486 MM_CAM_CAMERA_SHUTTER_SPEED,
487 MM_CAMCORDER_ATTR_NONE,
489 MM_CAMCONVERT_TYPE_INT_ARRAY,
494 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
496 MM_CAMCORDER_ATTR_NONE,
498 MM_CAMCONVERT_TYPE_INT_ARRAY,
499 &_mmcamcorder_enum_conv_iso,
503 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
504 MM_CAM_FILTER_SCENE_MODE,
505 MM_CAMCORDER_ATTR_NONE,
507 MM_CAMCONVERT_TYPE_INT_ARRAY,
508 &_mmcamcorder_enum_conv_prgrm,
512 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
513 MM_CAM_CAMERA_ANTI_HANDSHAKE,
514 MM_CAMCORDER_ATTR_NONE,
516 MM_CAMCONVERT_TYPE_INT_ARRAY,
517 &_mmcamcorder_enum_conv_ahs,
521 CONFIGURE_CATEGORY_CTRL_CAPTURE,
522 MM_CAM_CAPTURE_FORMAT,
523 MM_CAMCORDER_ATTR_NONE,
525 MM_CAMCONVERT_TYPE_INT_ARRAY,
530 CONFIGURE_CATEGORY_CTRL_CAPTURE,
531 MM_CAM_IMAGE_ENCODER_QUALITY,
532 MM_CAMCORDER_ATTR_NONE,
534 MM_CAMCONVERT_TYPE_INT_RANGE,
539 CONFIGURE_CATEGORY_CTRL_CAPTURE,
540 MM_CAM_CAPTURE_COUNT,
541 MM_CAMCORDER_ATTR_NONE,
543 MM_CAMCONVERT_TYPE_INT_RANGE,
548 CONFIGURE_CATEGORY_CTRL_CAPTURE,
549 MM_CAM_CAMERA_HDR_CAPTURE,
550 MM_CAMCORDER_ATTR_NONE,
552 MM_CAMCONVERT_TYPE_INT_ARRAY,
553 &_mmcamcorder_enum_conv_hdr_capture,
557 CONFIGURE_CATEGORY_CTRL_DETECT,
559 MM_CAMCORDER_ATTR_NONE,
561 MM_CAMCONVERT_TYPE_INT_ARRAY,
562 &_mmcamcorder_enum_conv_detect_mode,
566 CONFIGURE_CATEGORY_CTRL_DETECT,
567 MM_CAM_DETECT_NUMBER,
568 MM_CAMCORDER_ATTR_NONE,
570 MM_CAMCONVERT_TYPE_INT_RANGE,
575 CONFIGURE_CATEGORY_CTRL_DETECT,
576 MM_CAM_DETECT_FOCUS_SELECT,
577 MM_CAMCORDER_ATTR_NONE,
579 MM_CAMCONVERT_TYPE_INT_RANGE,
584 CONFIGURE_CATEGORY_CTRL_DETECT,
585 MM_CAM_DETECT_SELECT_NUMBER,
586 MM_CAMCORDER_ATTR_NONE,
587 "DetectSelectNumber",
588 MM_CAMCONVERT_TYPE_INT_RANGE,
593 CONFIGURE_CATEGORY_CTRL_DETECT,
594 MM_CAM_DETECT_STATUS,
595 MM_CAMCORDER_ATTR_NONE,
597 MM_CAMCONVERT_TYPE_INT_ARRAY,
602 CONFIGURE_CATEGORY_CTRL_CAMERA,
603 MM_CAM_RECOMMEND_CAMERA_WIDTH,
604 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
605 "RecommendPreviewResolution",
606 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
611 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
612 MM_CAM_CAMERA_VIDEO_STABILIZATION,
613 MM_CAMCORDER_ATTR_NONE,
614 "VideoStabilization",
615 MM_CAMCONVERT_TYPE_INT_ARRAY,
616 &_mmcamcorder_enum_conv_video_stabilization,
620 CONFIGURE_CATEGORY_CTRL_CAMERA,
624 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
629 /*---------------------------------------------------------------------------
630 | LOCAL FUNCTION PROTOTYPES: |
631 ---------------------------------------------------------------------------*/
632 /* STATIC INTERNAL FUNCTION */
633 static int __mmcamcorder_set_info_to_attr( MMHandleType handle, _MMCamcorderInfoConverting *info, int table_size );
634 static int __mmcamcorder_get_valid_array(int * original_array, int original_count, int ** valid_array, int * valid_default );
636 /*===========================================================================================
638 | FUNCTION DEFINITIONS |
640 ========================================================================================== */
641 /*---------------------------------------------------------------------------
642 | GLOBAL FUNCTION DEFINITIONS: |
643 ---------------------------------------------------------------------------*/
644 //convert MSL value to sensor value
645 int _mmcamcorder_convert_msl_to_sensor(MMHandleType handle, int attr_idx, int mslval)
647 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
648 _MMCamcorderInfoConverting *info = NULL;
650 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
652 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
654 //_mmcam_dbg_log("attr_idx(%d), mslval(%d)", attr_idx, mslval);
656 info = hcamcorder->caminfo_convert;
658 for (i = 0; i < size; i++)
660 if (info[i].attr_idx == attr_idx)
662 _MMCamcorderEnumConvert * enum_convert = NULL;
663 enum_convert = info[i].enum_convert;
665 if (enum_convert == NULL)
667 //_mmcam_dbg_log("enum_convert is NULL. Just return the original value.");
671 if (enum_convert->enum_arr == NULL)
673 _mmcam_dbg_warn("Unexpected error. Array pointer of enum_convert is NULL. Just return the original value.");
677 if( enum_convert->total_enum_num > mslval && mslval >= 0 )
679 //_mmcam_dbg_log("original value(%d) -> converted value(%d)", mslval, enum_convert->enum_arr[mslval]);
680 return enum_convert->enum_arr[mslval];
684 _mmcam_dbg_warn( "Input mslval[%d] is invalid(out of array[idx:%d,size:%d]), so can not convert. Just return the original value.", mslval, attr_idx, enum_convert->total_enum_num );
690 _mmcam_dbg_warn("There is no category to match. Just return the original value.");
695 int _mmcamcorder_get_fps_array_by_resolution(MMHandleType handle, int width, int height, MMCamAttrsInfo* fps_info)
697 MMCamAttrsInfo *infoW = NULL;
698 MMCamAttrsInfo *infoH = NULL;
700 char nameFps[5] = {0,};
701 bool valid_check = false;
703 type_int_array *fps_array;
705 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
707 //_mmcam_dbg_log("prev resolution w:%d, h:%d", width, height);
709 infoW = (MMCamAttrsInfo*)calloc(1, sizeof(MMCamAttrsInfo));
710 infoH = (MMCamAttrsInfo*)calloc(1, sizeof(MMCamAttrsInfo));
712 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_WIDTH, infoW);
713 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, infoH);
715 for(i=0; i < infoW->int_array.count; i++) {
716 //_mmcam_dbg_log("width :%d, height : %d\n", infoW->int_array.array[i], infoH->int_array.array[i]);
717 if(infoW->int_array.array[i] == width && infoH->int_array.array[i] == height) {
719 sprintf(nameFps, "FPS%d", i);
720 _mmcam_dbg_log("nameFps : %s!!!", nameFps);
731 _mmcam_dbg_err("FAILED : Can't find the valid resolution from attribute.");
732 return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
735 if (!_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl, CONFIGURE_CATEGORY_CTRL_CAMERA, nameFps, &fps_array)) {
736 _mmcam_dbg_err("FAILED : Can't find the valid FPS array.");
737 return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
740 fps_info->int_array.count = fps_array->count;
741 fps_info->int_array.array = fps_array->value;
742 fps_info->int_array.def = fps_array->default_value;
744 return MM_ERROR_NONE;
747 //convert sensor value to MSL value
748 int _mmcamcorder_convert_sensor_to_msl(MMHandleType handle, int attr_idx, int sensval)
750 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
751 _MMCamcorderInfoConverting *info = NULL;
753 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
755 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
757 info = hcamcorder->caminfo_convert;
759 for( i = 0 ; i < size ; i++ )
761 if( info[i].attr_idx == attr_idx )
763 _MMCamcorderEnumConvert * enum_convert = NULL;
764 enum_convert = info[i].enum_convert;
766 if( enum_convert == NULL )
768 //_mmcam_dbg_log("enum_convert is NULL. Just return the original value.");
772 if( enum_convert->enum_arr == NULL )
774 _mmcam_dbg_warn("Unexpected error. Array pointer of enum_convert is NULL. Just return the original value.");
778 for( j = 0 ; j < enum_convert->total_enum_num ; j++ )
780 if( sensval == enum_convert->enum_arr[j] )
782 //_mmcam_dbg_log("original value(%d) -> converted value(%d)", sensval, j);
787 _mmcam_dbg_warn("There is no sensor value matched with input param. Just return the original value.");
793 _mmcam_dbg_log("There is no category to match. Just return the original value.");
798 __mmcamcorder_get_valid_array(int * original_array, int original_count, int ** valid_array, int * valid_default )
802 int new_default = _MMCAMCORDER_SENSOR_ENUM_NONE;
804 for (i = 0; i < original_count; i++) {
805 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE) {
810 if (valid_count > 0) {
811 *valid_array = (int*)malloc(sizeof(int) * valid_count);
815 for (i = 0; i < original_count; i++) {
816 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE) {
817 (*valid_array)[valid_count++] = i;
818 /*_mmcam_dbg_log( "valid_array[%d] = %d", valid_count-1, (*valid_array)[valid_count-1] );*/
820 if (original_array[i] == *valid_default &&
821 new_default == _MMCAMCORDER_SENSOR_ENUM_NONE) {
823 /*_mmcam_dbg_log( "converted MSL default[%d]", new_default );*/
833 if (new_default != _MMCAMCORDER_SENSOR_ENUM_NONE) {
834 *valid_default = new_default;
841 int _mmcamcorder_init_attr_from_configure(MMHandleType handle, int type)
843 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
844 _MMCamcorderInfoConverting *info = NULL;
847 int ret = MM_ERROR_NONE;
849 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
851 _mmcam_dbg_log("type : %d", type);
853 if (type != MM_VIDEO_DEVICE_NONE) {
854 /* Initialize attribute related to camera control */
855 info = hcamcorder->caminfo_convert;
856 table_size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
857 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
858 if (ret != MM_ERROR_NONE) {
859 _mmcam_dbg_err("camera info set error : 0x%x", ret);
863 /* Initialize attribute related to display */
864 info = g_display_info;
865 table_size = sizeof(g_display_info) / sizeof(_MMCamcorderInfoConverting);
866 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
867 if (ret != MM_ERROR_NONE) {
868 _mmcam_dbg_err("display info set error : 0x%x", ret);
873 /* Initialize attribute related to audio */
875 table_size = sizeof(g_audio_info) / sizeof(_MMCamcorderInfoConverting);
876 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
877 if (ret != MM_ERROR_NONE) {
878 _mmcam_dbg_err("audio info set error : 0x%x", ret);
882 _mmcam_dbg_log("done");
889 __mmcamcorder_set_info_to_attr( MMHandleType handle, _MMCamcorderInfoConverting *info, int table_size )
891 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
892 MMHandleType attrs = 0;
895 int ret = MM_ERROR_NONE;
897 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
899 attrs = MMF_CAMCORDER_ATTRS (handle);
900 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
902 camera_conf *conf_info = NULL;
904 for (i = 0; i < table_size ; i++ )
907 _mmcam_dbg_log( "%d,%d,%d,%d,%s,%d",
911 info[i].attr_idx_sub,
916 if( info[i].type == CONFIGURE_TYPE_MAIN )
918 conf_info = hcamcorder->conf_main;
919 /*_mmcam_dbg_log( "MAIN configure [%s]", info[i].keyword );*/
923 conf_info = hcamcorder->conf_ctrl;
924 /*_mmcam_dbg_log( "CTRL configure [%s]", info[i].keyword );*/
927 switch(info[i].conv_type)
929 case MM_CAMCONVERT_TYPE_INT:
933 if (!_mmcamcorder_conf_get_value_int(handle, conf_info, info[i].category, info[i].keyword, &ivalue))
935 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
939 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, ivalue);
942 case MM_CAMCONVERT_TYPE_INT_ARRAY:
947 type_int_array *tarray = NULL;
949 if (!_mmcamcorder_conf_get_value_int_array( conf_info, info[i].category, info[i].keyword, &tarray ))
951 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
957 idefault = tarray->default_value;
959 if( info[i].enum_convert )
961 iarray_size = __mmcamcorder_get_valid_array(tarray->value, tarray->count, &iarray, &idefault);
965 iarray = tarray->value;
966 iarray_size = tarray->count;
969 if( iarray_size > 0 )
972 _mmcam_dbg_log("INT Array. attr idx=%d array=%p, size=%d, default=%d",
973 info[i].attr_idx, iarray, iarray_size, idefault);
976 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
977 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY);
978 mmf_attrs_set_valid_array(attrs, info[i].attr_idx, iarray, iarray_size, idefault);
980 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, idefault);
984 if (iarray && iarray != tarray->value )
989 case MM_CAMCONVERT_TYPE_INT_RANGE:
991 type_int_range *irange = NULL;
993 if (!_mmcamcorder_conf_get_value_int_range(conf_info, info[i].category, info[i].keyword, &irange))
995 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1001 //_mmcam_dbg_log("INT Range. m:%d, s:%d, min=%d, max=%d", info[i].main_key, info[i].sub_key1, irange->min, irange->max);
1002 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
1003 //mmf_attrs_set_valid_type (attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
1004 mmf_attrs_set_valid_range(attrs, info[i].attr_idx, irange->min, irange->max, irange->default_value);
1006 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, irange->default_value);
1011 case MM_CAMCONVERT_TYPE_STRING:
1013 const char *cString = NULL;
1014 unsigned int iString_len = 0;
1016 if (!_mmcamcorder_conf_get_value_string(handle, conf_info, info[i].category, info[i].keyword, &cString ))
1018 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1019 break; //skip to set
1022 //_mmcam_dbg_log("String. m:%d, s:%d, cString=%s", info[i].main_key, info[i].sub_key1, cString);
1023 //strlen makes a crash when null pointer is passed.
1025 iString_len = strlen(cString);
1029 ret = mm_attrs_set_string(attrs, info[i].attr_idx, cString, iString_len);
1032 case MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY:
1034 type_int_pair_array *pair_array = NULL;
1036 /*_mmcam_dbg_log("INT PAIR Array. type:%d, attr_idx:%d, attr_idx_pair:%d", info[i].type, info[i].attr_idx, info[i].attr_idx_pair);*/
1038 if (!_mmcamcorder_conf_get_value_int_pair_array(conf_info, info[i].category, info[i].keyword, &pair_array))
1040 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1041 break; //skip to set
1044 if( pair_array && pair_array->count > 0 )
1046 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
1047 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY);
1048 mmf_attrs_set_valid_array(attrs, info[i].attr_idx,
1049 pair_array->value[0],
1051 pair_array->default_value[0]);
1052 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
1053 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx_pair, MM_ATTRS_VALID_TYPE_INT_ARRAY);
1054 mmf_attrs_set_valid_array(attrs, info[i].attr_idx_pair,
1055 pair_array->value[1],
1057 pair_array->default_value[1]);
1059 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, pair_array->default_value[0]);
1060 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx_pair, pair_array->default_value[1]);
1065 case MM_CAMCONVERT_TYPE_USER:
1067 _mmcam_dbg_log("default : s:%d", info[i].attr_idx);
1072 if (ret != MM_ERROR_NONE || mmf_attrs_commit(attrs) == -1)
1073 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1075 return MM_ERROR_NONE;
1079 int _mmcamcorder_set_converted_value(MMHandleType handle, _MMCamcorderEnumConvert * convert)
1081 mmf_camcorder_t* hcamcorder = MMF_CAMCORDER(handle);
1082 type_int_array *array = NULL;
1084 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1086 _mmcamcorder_conf_get_value_int_array( hcamcorder->conf_ctrl, convert->category, convert->keyword, &array );
1090 convert->enum_arr = array->value;
1093 return MM_ERROR_NONE;
1097 int _mmcamcorder_init_convert_table(MMHandleType handle)
1099 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1100 int enum_conv_size = sizeof(_MMCamcorderEnumConvert);
1101 int caminfo_conv_size = sizeof(g_caminfo_convert);
1102 int caminfo_conv_length = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
1105 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1107 /* copy default conv data into memory of handle */
1108 memcpy(&(hcamcorder->caminfo_convert), &g_caminfo_convert, caminfo_conv_size);
1109 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]), &_mmcamcorder_enum_conv_whitebalance, enum_conv_size);
1110 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]), &_mmcamcorder_enum_conv_colortone, enum_conv_size);
1111 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ISO]), &_mmcamcorder_enum_conv_iso, enum_conv_size);
1112 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]), &_mmcamcorder_enum_conv_prgrm, enum_conv_size);
1113 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]), &_mmcamcorder_enum_conv_focus_mode, enum_conv_size);
1114 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]), &_mmcamcorder_enum_conv_focus_type, enum_conv_size);
1115 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]), &_mmcamcorder_enum_conv_ae_type, enum_conv_size);
1116 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]), &_mmcamcorder_enum_conv_strobe_mode, enum_conv_size);
1117 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WDR]), &_mmcamcorder_enum_conv_wdr_ctrl, enum_conv_size);
1118 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]), &_mmcamcorder_enum_conv_flip_ctrl, enum_conv_size);
1119 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]), &_mmcamcorder_enum_conv_rotation_ctrl, enum_conv_size);
1120 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]), &_mmcamcorder_enum_conv_ahs, enum_conv_size);
1121 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]), &_mmcamcorder_enum_conv_video_stabilization, enum_conv_size);
1123 /* set ini info to conv data */
1124 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]));
1125 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]));
1126 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]));
1127 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]));
1128 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]));
1129 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]));
1130 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]));
1131 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]));
1132 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]));
1133 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]));
1134 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]));
1135 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]));
1136 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]));
1138 /* set modified conv data to handle */
1139 for (i = 0 ; i < caminfo_conv_length ; i++) {
1140 if (hcamcorder->caminfo_convert[i].type == CONFIGURE_TYPE_CTRL) {
1141 switch (hcamcorder->caminfo_convert[i].category) {
1142 case CONFIGURE_CATEGORY_CTRL_STROBE:
1143 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "StrobeMode")) {
1144 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]);
1147 case CONFIGURE_CATEGORY_CTRL_EFFECT:
1148 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WhiteBalance")) {
1149 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]);
1150 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ColorTone")) {
1151 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]);
1152 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WDR")) {
1153 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]);
1154 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Flip")) {
1155 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]);
1156 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Rotation")) {
1157 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]);
1160 case CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH:
1161 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "FocusMode")) {
1162 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]);
1163 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AFType")) {
1164 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]);
1165 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AEType")) {
1166 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]);
1167 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ISO")) {
1168 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]);
1169 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ProgramMode")) {
1170 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]);
1171 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AntiHandshake")) {
1172 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]);
1173 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "VideoStabilization")) {
1174 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]);
1183 return MM_ERROR_NONE;
1187 double _mmcamcorder_convert_volume(int mslVal)
1199 _mmcam_dbg_warn("out of range");