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_display_info[] = {
227 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
228 MM_CAM_DISPLAY_DEVICE,
229 MM_CAMCORDER_ATTR_NONE,
231 MM_CAMCONVERT_TYPE_INT_ARRAY,
236 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
238 MM_CAMCORDER_ATTR_NONE,
240 MM_CAMCONVERT_TYPE_INT_ARRAY,
245 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
246 MM_CAM_DISPLAY_SURFACE,
247 MM_CAMCORDER_ATTR_NONE,
249 MM_CAMCONVERT_TYPE_INT_ARRAY,
254 static _MMCamcorderInfoConverting g_caminfo_convert[CAMINFO_CONVERT_NUM] = {
257 CONFIGURE_CATEGORY_CTRL_CAMERA,
258 MM_CAM_CAMERA_DEVICE_NAME,
259 MM_CAMCORDER_ATTR_NONE,
261 MM_CAMCONVERT_TYPE_STRING,
266 CONFIGURE_CATEGORY_CTRL_CAMERA,
268 MM_CAM_CAMERA_HEIGHT,
270 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
275 CONFIGURE_CATEGORY_CTRL_CAMERA,
276 MM_CAM_CAPTURE_WIDTH,
277 MM_CAM_CAPTURE_HEIGHT,
279 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
284 CONFIGURE_CATEGORY_CTRL_CAMERA,
285 MM_CAM_CAMERA_FORMAT,
286 MM_CAMCORDER_ATTR_NONE,
288 MM_CAMCONVERT_TYPE_INT_ARRAY,
293 CONFIGURE_CATEGORY_CTRL_STROBE,
294 MM_CAM_STROBE_CONTROL,
295 MM_CAMCORDER_ATTR_NONE,
297 MM_CAMCONVERT_TYPE_INT_ARRAY,
298 &_mmcamcorder_enum_conv_strobe_ctrl,
302 CONFIGURE_CATEGORY_CTRL_STROBE,
303 MM_CAM_STROBE_CAPABILITIES,
304 MM_CAMCORDER_ATTR_NONE,
305 "StrobeCapabilities",
306 MM_CAMCONVERT_TYPE_INT_ARRAY,
311 CONFIGURE_CATEGORY_CTRL_STROBE,
313 MM_CAMCORDER_ATTR_NONE,
315 MM_CAMCONVERT_TYPE_INT_ARRAY,
316 &_mmcamcorder_enum_conv_strobe_mode,
320 CONFIGURE_CATEGORY_CTRL_EFFECT,
321 MM_CAM_FILTER_BRIGHTNESS,
322 MM_CAMCORDER_ATTR_NONE,
324 MM_CAMCONVERT_TYPE_INT_RANGE,
329 CONFIGURE_CATEGORY_CTRL_EFFECT,
330 MM_CAM_FILTER_CONTRAST,
331 MM_CAMCORDER_ATTR_NONE,
333 MM_CAMCONVERT_TYPE_INT_RANGE,
338 CONFIGURE_CATEGORY_CTRL_EFFECT,
339 MM_CAM_FILTER_SATURATION,
340 MM_CAMCORDER_ATTR_NONE,
342 MM_CAMCONVERT_TYPE_INT_RANGE,
347 CONFIGURE_CATEGORY_CTRL_EFFECT,
349 MM_CAMCORDER_ATTR_NONE,
351 MM_CAMCONVERT_TYPE_INT_RANGE,
356 CONFIGURE_CATEGORY_CTRL_EFFECT,
357 MM_CAM_FILTER_SHARPNESS,
358 MM_CAMCORDER_ATTR_NONE,
360 MM_CAMCONVERT_TYPE_INT_RANGE,
365 CONFIGURE_CATEGORY_CTRL_EFFECT,
367 MM_CAMCORDER_ATTR_NONE,
369 MM_CAMCONVERT_TYPE_INT_ARRAY,
370 &_mmcamcorder_enum_conv_whitebalance,
374 CONFIGURE_CATEGORY_CTRL_EFFECT,
375 MM_CAM_FILTER_COLOR_TONE,
376 MM_CAMCORDER_ATTR_NONE,
378 MM_CAMCONVERT_TYPE_INT_ARRAY,
379 &_mmcamcorder_enum_conv_colortone,
383 CONFIGURE_CATEGORY_CTRL_EFFECT,
385 MM_CAMCORDER_ATTR_NONE,
387 MM_CAMCONVERT_TYPE_INT_ARRAY,
388 &_mmcamcorder_enum_conv_wdr_ctrl,
392 CONFIGURE_CATEGORY_CTRL_EFFECT,
394 MM_CAMCORDER_ATTR_NONE,
396 MM_CAMCONVERT_TYPE_INT_ARRAY,
397 &_mmcamcorder_enum_conv_flip_ctrl,
401 CONFIGURE_CATEGORY_CTRL_EFFECT,
402 MM_CAM_CAMERA_ROTATION,
403 MM_CAMCORDER_ATTR_NONE,
405 MM_CAMCONVERT_TYPE_INT_ARRAY,
406 &_mmcamcorder_enum_conv_rotation_ctrl,
410 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
411 MM_CAM_CAMERA_DIGITAL_ZOOM,
412 MM_CAMCORDER_ATTR_NONE,
414 MM_CAMCONVERT_TYPE_INT_RANGE,
419 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
420 MM_CAM_CAMERA_OPTICAL_ZOOM,
421 MM_CAMCORDER_ATTR_NONE,
423 MM_CAMCONVERT_TYPE_INT_RANGE,
428 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
429 MM_CAM_CAMERA_FOCUS_MODE,
430 MM_CAMCORDER_ATTR_NONE,
432 MM_CAMCONVERT_TYPE_INT_ARRAY,
433 &_mmcamcorder_enum_conv_focus_mode,
437 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
438 MM_CAM_CAMERA_AF_SCAN_RANGE,
439 MM_CAMCORDER_ATTR_NONE,
441 MM_CAMCONVERT_TYPE_INT_ARRAY,
442 &_mmcamcorder_enum_conv_focus_type,
446 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
447 MM_CAM_CAMERA_EXPOSURE_MODE,
448 MM_CAMCORDER_ATTR_NONE,
450 MM_CAMCONVERT_TYPE_INT_ARRAY,
451 &_mmcamcorder_enum_conv_ae_type,
455 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
456 MM_CAM_CAMERA_EXPOSURE_VALUE,
457 MM_CAMCORDER_ATTR_NONE,
459 MM_CAMCONVERT_TYPE_INT_RANGE,
464 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
465 MM_CAM_CAMERA_F_NUMBER,
466 MM_CAMCORDER_ATTR_NONE,
468 MM_CAMCONVERT_TYPE_INT_ARRAY,
473 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
474 MM_CAM_CAMERA_SHUTTER_SPEED,
475 MM_CAMCORDER_ATTR_NONE,
477 MM_CAMCONVERT_TYPE_INT_ARRAY,
482 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
484 MM_CAMCORDER_ATTR_NONE,
486 MM_CAMCONVERT_TYPE_INT_ARRAY,
487 &_mmcamcorder_enum_conv_iso,
491 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
492 MM_CAM_FILTER_SCENE_MODE,
493 MM_CAMCORDER_ATTR_NONE,
495 MM_CAMCONVERT_TYPE_INT_ARRAY,
496 &_mmcamcorder_enum_conv_prgrm,
500 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
501 MM_CAM_CAMERA_ANTI_HANDSHAKE,
502 MM_CAMCORDER_ATTR_NONE,
504 MM_CAMCONVERT_TYPE_INT_ARRAY,
505 &_mmcamcorder_enum_conv_ahs,
509 CONFIGURE_CATEGORY_CTRL_CAPTURE,
510 MM_CAM_CAPTURE_FORMAT,
511 MM_CAMCORDER_ATTR_NONE,
513 MM_CAMCONVERT_TYPE_INT_ARRAY,
518 CONFIGURE_CATEGORY_CTRL_CAPTURE,
519 MM_CAM_IMAGE_ENCODER_QUALITY,
520 MM_CAMCORDER_ATTR_NONE,
522 MM_CAMCONVERT_TYPE_INT_RANGE,
527 CONFIGURE_CATEGORY_CTRL_CAPTURE,
528 MM_CAM_CAPTURE_COUNT,
529 MM_CAMCORDER_ATTR_NONE,
531 MM_CAMCONVERT_TYPE_INT_RANGE,
536 CONFIGURE_CATEGORY_CTRL_CAPTURE,
537 MM_CAM_CAMERA_HDR_CAPTURE,
538 MM_CAMCORDER_ATTR_NONE,
540 MM_CAMCONVERT_TYPE_INT_ARRAY,
541 &_mmcamcorder_enum_conv_hdr_capture,
545 CONFIGURE_CATEGORY_CTRL_DETECT,
547 MM_CAMCORDER_ATTR_NONE,
549 MM_CAMCONVERT_TYPE_INT_ARRAY,
550 &_mmcamcorder_enum_conv_detect_mode,
554 CONFIGURE_CATEGORY_CTRL_DETECT,
555 MM_CAM_DETECT_NUMBER,
556 MM_CAMCORDER_ATTR_NONE,
558 MM_CAMCONVERT_TYPE_INT_RANGE,
563 CONFIGURE_CATEGORY_CTRL_DETECT,
564 MM_CAM_DETECT_FOCUS_SELECT,
565 MM_CAMCORDER_ATTR_NONE,
567 MM_CAMCONVERT_TYPE_INT_RANGE,
572 CONFIGURE_CATEGORY_CTRL_DETECT,
573 MM_CAM_DETECT_SELECT_NUMBER,
574 MM_CAMCORDER_ATTR_NONE,
575 "DetectSelectNumber",
576 MM_CAMCONVERT_TYPE_INT_RANGE,
581 CONFIGURE_CATEGORY_CTRL_DETECT,
582 MM_CAM_DETECT_STATUS,
583 MM_CAMCORDER_ATTR_NONE,
585 MM_CAMCONVERT_TYPE_INT_ARRAY,
590 CONFIGURE_CATEGORY_CTRL_CAMERA,
591 MM_CAM_RECOMMEND_CAMERA_WIDTH,
592 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
593 "RecommendPreviewResolution",
594 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
599 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
600 MM_CAM_CAMERA_VIDEO_STABILIZATION,
601 MM_CAMCORDER_ATTR_NONE,
602 "VideoStabilization",
603 MM_CAMCONVERT_TYPE_INT_ARRAY,
604 &_mmcamcorder_enum_conv_video_stabilization,
608 CONFIGURE_CATEGORY_CTRL_CAMERA,
612 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
617 /*---------------------------------------------------------------------------
618 | LOCAL FUNCTION PROTOTYPES: |
619 ---------------------------------------------------------------------------*/
620 /* STATIC INTERNAL FUNCTION */
621 static int __mmcamcorder_set_info_to_attr( MMHandleType handle, _MMCamcorderInfoConverting *info, int table_size );
622 static int __mmcamcorder_get_valid_array(int * original_array, int original_count, int ** valid_array, int * valid_default );
624 /*===========================================================================================
626 | FUNCTION DEFINITIONS |
628 ========================================================================================== */
629 /*---------------------------------------------------------------------------
630 | GLOBAL FUNCTION DEFINITIONS: |
631 ---------------------------------------------------------------------------*/
632 //convert MSL value to sensor value
633 int _mmcamcorder_convert_msl_to_sensor(MMHandleType handle, int attr_idx, int mslval)
635 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
636 _MMCamcorderInfoConverting *info = NULL;
638 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
640 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
642 //_mmcam_dbg_log("attr_idx(%d), mslval(%d)", attr_idx, mslval);
644 info = hcamcorder->caminfo_convert;
646 for (i = 0; i < size; i++)
648 if (info[i].attr_idx == attr_idx)
650 _MMCamcorderEnumConvert * enum_convert = NULL;
651 enum_convert = info[i].enum_convert;
653 if (enum_convert == NULL)
655 //_mmcam_dbg_log("enum_convert is NULL. Just return the original value.");
659 if (enum_convert->enum_arr == NULL)
661 _mmcam_dbg_warn("Unexpected error. Array pointer of enum_convert is NULL. Just return the original value.");
665 if( enum_convert->total_enum_num > mslval && mslval >= 0 )
667 //_mmcam_dbg_log("original value(%d) -> converted value(%d)", mslval, enum_convert->enum_arr[mslval]);
668 return enum_convert->enum_arr[mslval];
672 _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 );
678 _mmcam_dbg_warn("There is no category to match. Just return the original value.");
683 int _mmcamcorder_get_fps_array_by_resolution(MMHandleType handle, int width, int height, MMCamAttrsInfo* fps_info)
685 MMCamAttrsInfo *infoW = NULL;
686 MMCamAttrsInfo *infoH = NULL;
688 char nameFps[5] = {0,};
689 bool valid_check = false;
691 type_int_array *fps_array;
693 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
695 //_mmcam_dbg_log("prev resolution w:%d, h:%d", width, height);
697 infoW = (MMCamAttrsInfo*)calloc(1, sizeof(MMCamAttrsInfo));
698 infoH = (MMCamAttrsInfo*)calloc(1, sizeof(MMCamAttrsInfo));
700 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_WIDTH, infoW);
701 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, infoH);
703 for(i=0; i < infoW->int_array.count; i++) {
704 //_mmcam_dbg_log("width :%d, height : %d\n", infoW->int_array.array[i], infoH->int_array.array[i]);
705 if(infoW->int_array.array[i] == width && infoH->int_array.array[i] == height) {
707 sprintf(nameFps, "FPS%d", i);
708 _mmcam_dbg_log("nameFps : %s!!!", nameFps);
719 _mmcam_dbg_err("FAILED : Can't find the valid resolution from attribute.");
720 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
723 if (!_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl, CONFIGURE_CATEGORY_CTRL_CAMERA, nameFps, &fps_array)) {
724 _mmcam_dbg_err("FAILED : Can't find the valid FPS array.");
725 return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
728 fps_info->int_array.count = fps_array->count;
729 fps_info->int_array.array = fps_array->value;
730 fps_info->int_array.def = fps_array->default_value;
732 return MM_ERROR_NONE;
735 //convert sensor value to MSL value
736 int _mmcamcorder_convert_sensor_to_msl(MMHandleType handle, int attr_idx, int sensval)
738 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
739 _MMCamcorderInfoConverting *info = NULL;
741 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
743 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
745 info = hcamcorder->caminfo_convert;
747 for( i = 0 ; i < size ; i++ )
749 if( info[i].attr_idx == attr_idx )
751 _MMCamcorderEnumConvert * enum_convert = NULL;
752 enum_convert = info[i].enum_convert;
754 if( enum_convert == NULL )
756 //_mmcam_dbg_log("enum_convert is NULL. Just return the original value.");
760 if( enum_convert->enum_arr == NULL )
762 _mmcam_dbg_warn("Unexpected error. Array pointer of enum_convert is NULL. Just return the original value.");
766 for( j = 0 ; j < enum_convert->total_enum_num ; j++ )
768 if( sensval == enum_convert->enum_arr[j] )
770 //_mmcam_dbg_log("original value(%d) -> converted value(%d)", sensval, j);
775 _mmcam_dbg_warn("There is no sensor value matched with input param. Just return the original value.");
781 _mmcam_dbg_log("There is no category to match. Just return the original value.");
786 __mmcamcorder_get_valid_array(int * original_array, int original_count, int ** valid_array, int * valid_default )
790 int new_default = _MMCAMCORDER_SENSOR_ENUM_NONE;
792 for (i = 0; i < original_count; i++) {
793 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE) {
798 if (valid_count > 0) {
799 *valid_array = (int*)malloc(sizeof(int) * valid_count);
803 for (i = 0; i < original_count; i++) {
804 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE) {
805 (*valid_array)[valid_count++] = i;
806 /*_mmcam_dbg_log( "valid_array[%d] = %d", valid_count-1, (*valid_array)[valid_count-1] );*/
808 if (original_array[i] == *valid_default &&
809 new_default == _MMCAMCORDER_SENSOR_ENUM_NONE) {
811 /*_mmcam_dbg_log( "converted MSL default[%d]", new_default );*/
821 if (new_default != _MMCAMCORDER_SENSOR_ENUM_NONE) {
822 *valid_default = new_default;
829 int _mmcamcorder_init_attr_from_configure(MMHandleType handle)
831 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
832 _MMCamcorderInfoConverting *info = NULL;
835 int ret = MM_ERROR_NONE;
837 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
841 /* Initialize attribute related to camera control */
842 info = hcamcorder->caminfo_convert;
843 table_size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
844 ret = __mmcamcorder_set_info_to_attr( handle, info, table_size );
845 if( ret != MM_ERROR_NONE )
847 _mmcam_dbg_err( "ret : %x", ret );
851 /* Initialize attribute related to display */
852 info = g_display_info;
853 table_size = sizeof(g_display_info) / sizeof(_MMCamcorderInfoConverting);
854 ret = __mmcamcorder_set_info_to_attr( handle, info, table_size );
856 _mmcam_dbg_log( "result: %x", ret );
862 __mmcamcorder_set_info_to_attr( MMHandleType handle, _MMCamcorderInfoConverting *info, int table_size )
864 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
865 MMHandleType attrs = 0;
868 int ret = MM_ERROR_NONE;
870 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
872 attrs = MMF_CAMCORDER_ATTRS (handle);
873 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
875 camera_conf *conf_info = NULL;
877 for (i = 0; i < table_size ; i++ )
880 _mmcam_dbg_log( "%d,%d,%d,%d,%s,%d",
884 info[i].attr_idx_sub,
889 if( info[i].type == CONFIGURE_TYPE_MAIN )
891 conf_info = hcamcorder->conf_main;
892 /*_mmcam_dbg_log( "MAIN configure [%s]", info[i].keyword );*/
896 conf_info = hcamcorder->conf_ctrl;
897 /*_mmcam_dbg_log( "CTRL configure [%s]", info[i].keyword );*/
900 switch(info[i].conv_type)
902 case MM_CAMCONVERT_TYPE_INT:
906 if (!_mmcamcorder_conf_get_value_int(handle, conf_info, info[i].category, info[i].keyword, &ivalue))
908 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
912 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, ivalue);
915 case MM_CAMCONVERT_TYPE_INT_ARRAY:
920 type_int_array *tarray = NULL;
922 if (!_mmcamcorder_conf_get_value_int_array( conf_info, info[i].category, info[i].keyword, &tarray ))
924 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
930 idefault = tarray->default_value;
932 if( info[i].enum_convert )
934 iarray_size = __mmcamcorder_get_valid_array(tarray->value, tarray->count, &iarray, &idefault);
938 iarray = tarray->value;
939 iarray_size = tarray->count;
942 if( iarray_size > 0 )
945 _mmcam_dbg_log("INT Array. attr idx=%d array=%p, size=%d, default=%d",
946 info[i].attr_idx, iarray, iarray_size, idefault);
949 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
950 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY);
951 mmf_attrs_set_valid_array(attrs, info[i].attr_idx, iarray, iarray_size, idefault);
953 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, idefault);
957 if (iarray && iarray != tarray->value )
962 case MM_CAMCONVERT_TYPE_INT_RANGE:
964 type_int_range *irange = NULL;
966 if (!_mmcamcorder_conf_get_value_int_range(conf_info, info[i].category, info[i].keyword, &irange))
968 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
974 //_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);
975 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
976 //mmf_attrs_set_valid_type (attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
977 mmf_attrs_set_valid_range(attrs, info[i].attr_idx, irange->min, irange->max, irange->default_value);
979 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, irange->default_value);
984 case MM_CAMCONVERT_TYPE_STRING:
986 const char *cString = NULL;
987 unsigned int iString_len = 0;
989 if (!_mmcamcorder_conf_get_value_string(handle, conf_info, info[i].category, info[i].keyword, &cString ))
991 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
995 //_mmcam_dbg_log("String. m:%d, s:%d, cString=%s", info[i].main_key, info[i].sub_key1, cString);
996 //strlen makes a crash when null pointer is passed.
998 iString_len = strlen(cString);
1002 ret = mm_attrs_set_string(attrs, info[i].attr_idx, cString, iString_len);
1005 case MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY:
1007 type_int_pair_array *pair_array = NULL;
1009 /*_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);*/
1011 if (!_mmcamcorder_conf_get_value_int_pair_array(conf_info, info[i].category, info[i].keyword, &pair_array))
1013 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1014 break; //skip to set
1017 if( pair_array && pair_array->count > 0 )
1019 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
1020 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY);
1021 mmf_attrs_set_valid_array(attrs, info[i].attr_idx,
1022 pair_array->value[0],
1024 pair_array->default_value[0]);
1025 /* "mmf_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
1026 //mmf_attrs_set_valid_type(attrs, info[i].attr_idx_pair, MM_ATTRS_VALID_TYPE_INT_ARRAY);
1027 mmf_attrs_set_valid_array(attrs, info[i].attr_idx_pair,
1028 pair_array->value[1],
1030 pair_array->default_value[1]);
1032 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, pair_array->default_value[0]);
1033 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx_pair, pair_array->default_value[1]);
1038 case MM_CAMCONVERT_TYPE_USER:
1040 _mmcam_dbg_log("default : s:%d", info[i].attr_idx);
1045 if (ret != MM_ERROR_NONE || mmf_attrs_commit(attrs) == -1)
1046 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1048 return MM_ERROR_NONE;
1052 int _mmcamcorder_set_converted_value(MMHandleType handle, _MMCamcorderEnumConvert * convert)
1054 mmf_camcorder_t* hcamcorder = MMF_CAMCORDER(handle);
1055 type_int_array *array = NULL;
1057 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1059 _mmcamcorder_conf_get_value_int_array( hcamcorder->conf_ctrl, convert->category, convert->keyword, &array );
1063 convert->enum_arr = array->value;
1066 return MM_ERROR_NONE;
1070 int _mmcamcorder_init_convert_table(MMHandleType handle)
1072 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1073 int enum_conv_size = sizeof(_MMCamcorderEnumConvert);
1074 int caminfo_conv_size = sizeof(g_caminfo_convert);
1075 int caminfo_conv_length = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
1078 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1080 /* copy default conv data into memory of handle */
1081 memcpy(&(hcamcorder->caminfo_convert), &g_caminfo_convert, caminfo_conv_size);
1082 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]), &_mmcamcorder_enum_conv_whitebalance, enum_conv_size);
1083 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]), &_mmcamcorder_enum_conv_colortone, enum_conv_size);
1084 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ISO]), &_mmcamcorder_enum_conv_iso, enum_conv_size);
1085 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]), &_mmcamcorder_enum_conv_prgrm, enum_conv_size);
1086 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]), &_mmcamcorder_enum_conv_focus_mode, enum_conv_size);
1087 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]), &_mmcamcorder_enum_conv_focus_type, enum_conv_size);
1088 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]), &_mmcamcorder_enum_conv_ae_type, enum_conv_size);
1089 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]), &_mmcamcorder_enum_conv_strobe_mode, enum_conv_size);
1090 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WDR]), &_mmcamcorder_enum_conv_wdr_ctrl, enum_conv_size);
1091 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]), &_mmcamcorder_enum_conv_flip_ctrl, enum_conv_size);
1092 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]), &_mmcamcorder_enum_conv_rotation_ctrl, enum_conv_size);
1093 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]), &_mmcamcorder_enum_conv_ahs, enum_conv_size);
1094 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]), &_mmcamcorder_enum_conv_video_stabilization, enum_conv_size);
1096 /* set ini info to conv data */
1097 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]));
1098 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]));
1099 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]));
1100 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]));
1101 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]));
1102 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]));
1103 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]));
1104 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]));
1105 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]));
1106 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]));
1107 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]));
1108 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]));
1109 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]));
1111 /* set modified conv data to handle */
1112 for (i = 0 ; i < caminfo_conv_length ; i++) {
1113 if (hcamcorder->caminfo_convert[i].type == CONFIGURE_TYPE_CTRL) {
1114 switch (hcamcorder->caminfo_convert[i].category) {
1115 case CONFIGURE_CATEGORY_CTRL_STROBE:
1116 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "StrobeMode")) {
1117 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]);
1120 case CONFIGURE_CATEGORY_CTRL_EFFECT:
1121 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WhiteBalance")) {
1122 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]);
1123 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ColorTone")) {
1124 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]);
1125 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WDR")) {
1126 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]);
1127 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Flip")) {
1128 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]);
1129 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Rotation")) {
1130 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]);
1133 case CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH:
1134 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "FocusMode")) {
1135 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]);
1136 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AFType")) {
1137 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]);
1138 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AEType")) {
1139 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]);
1140 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ISO")) {
1141 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]);
1142 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ProgramMode")) {
1143 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]);
1144 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AntiHandshake")) {
1145 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]);
1146 } else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "VideoStabilization")) {
1147 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]);
1156 return MM_ERROR_NONE;
1160 double _mmcamcorder_convert_volume(int mslVal)
1172 _mmcam_dbg_warn("out of range");