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"
30 #include "mm_camcorder_capability.h"
32 /*---------------------------------------------------------------------------
33 | GLOBAL VARIABLE DEFINITIONS for internal |
34 ---------------------------------------------------------------------------*/
36 /*---------------------------------------------------------------------------
37 | LOCAL VARIABLE DEFINITIONS for internal |
38 ---------------------------------------------------------------------------*/
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.
46 static int __enum_conv_whitebalance[MM_CAMCORDER_WHITE_BALANCE_NUM] ;
48 static _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 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_colortone = {
59 MM_CAMCORDER_COLOR_TONE_NUM,
60 __enum_conv_colortone,
61 CONFIGURE_CATEGORY_CTRL_EFFECT,
66 static int __enum_conv_iso[MM_CAMCORDER_ISO_NUM];
68 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_iso = {
71 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
76 static int __enum_conv_prgrm[MM_CAMCORDER_SCENE_MODE_NUM];
78 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_prgrm = {
79 MM_CAMCORDER_SCENE_MODE_NUM,
81 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
86 static int __enum_conv_focus_mode[MM_CAMCORDER_FOCUS_MODE_NUM];
88 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_focus_mode = {
89 MM_CAMCORDER_FOCUS_MODE_NUM,
90 __enum_conv_focus_mode,
91 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
96 static int __enum_conv_focus_type[MM_CAMCORDER_AUTO_FOCUS_NUM];
98 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_focus_type = {
99 MM_CAMCORDER_AUTO_FOCUS_NUM,
100 __enum_conv_focus_type,
101 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
106 static int __enum_conv_ae_type[MM_CAMCORDER_AUTO_EXPOSURE_NUM];
108 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_ae_type = {
109 MM_CAMCORDER_AUTO_EXPOSURE_NUM,
111 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
116 static int __enum_conv_strobe_ctrl[MM_CAMCORDER_STROBE_CONTROL_NUM];
118 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_strobe_ctrl = {
119 MM_CAMCORDER_STROBE_CONTROL_NUM,
120 __enum_conv_strobe_ctrl,
121 CONFIGURE_CATEGORY_CTRL_STROBE,
126 static int __enum_conv_strobe_mode[MM_CAMCORDER_STROBE_MODE_NUM];
128 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_strobe_mode = {
129 MM_CAMCORDER_STROBE_MODE_NUM,
130 __enum_conv_strobe_mode,
131 CONFIGURE_CATEGORY_CTRL_STROBE,
136 static int __enum_conv_wdr_ctrl[MM_CAMCORDER_WDR_NUM];
138 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_wdr_ctrl = {
139 MM_CAMCORDER_WDR_NUM,
140 __enum_conv_wdr_ctrl,
141 CONFIGURE_CATEGORY_CTRL_EFFECT,
145 static int __enum_conv_flip_ctrl[MM_CAMCORDER_FLIP_NUM];
147 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_flip_ctrl = {
148 MM_CAMCORDER_FLIP_NUM,
149 __enum_conv_flip_ctrl,
150 CONFIGURE_CATEGORY_CTRL_EFFECT,
154 static int __enum_conv_rotation_ctrl[MM_CAMCORDER_ROTATION_NUM];
156 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_rotation_ctrl = {
157 MM_CAMCORDER_ROTATION_NUM,
158 __enum_conv_rotation_ctrl,
159 CONFIGURE_CATEGORY_CTRL_EFFECT,
164 static int __enum_conv_ahs[MM_CAMCORDER_AHS_NUM];
166 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_ahs = {
167 MM_CAMCORDER_AHS_NUM,
169 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
174 static int __enum_conv_video_stabilization[MM_CAMCORDER_VIDEO_STABILIZATION_NUM];
176 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_video_stabilization = {
177 MM_CAMCORDER_VIDEO_STABILIZATION_NUM,
178 __enum_conv_video_stabilization,
179 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
184 static int __enum_conv_hdr_capture[MM_CAMCORDER_HDR_CAPTURE_NUM];
186 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_hdr_capture = {
187 MM_CAMCORDER_HDR_CAPTURE_NUM,
188 __enum_conv_hdr_capture,
189 CONFIGURE_CATEGORY_CTRL_CAPTURE,
193 static int __enum_conv_detect_mode[MM_CAMCORDER_DETECT_MODE_NUM];
195 static _MMCamcorderEnumConvert _mmcamcorder_enum_conv_detect_mode = {
196 MM_CAMCORDER_DETECT_MODE_NUM,
197 __enum_conv_detect_mode,
198 CONFIGURE_CATEGORY_CTRL_DETECT,
204 * Matching table of caminfo index with category enum of attribute.
205 * If predefined item is changed, this static variables should be changed.
206 * For detail information, refer below documents.
209 static _MMCamcorderInfoConverting g_audio_info[] = {
212 CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
214 MM_CAMCORDER_ATTR_NONE,
216 MM_CAMCONVERT_TYPE_INT_ARRAY,
221 static _MMCamcorderInfoConverting g_display_info[] = {
224 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
225 MM_CAM_DISPLAY_DEVICE,
226 MM_CAMCORDER_ATTR_NONE,
228 MM_CAMCONVERT_TYPE_INT_ARRAY,
233 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
235 MM_CAMCORDER_ATTR_NONE,
237 MM_CAMCONVERT_TYPE_INT_ARRAY,
242 CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
243 MM_CAM_DISPLAY_SURFACE,
244 MM_CAMCORDER_ATTR_NONE,
246 MM_CAMCONVERT_TYPE_INT_ARRAY,
251 static _MMCamcorderInfoConverting g_caminfo_convert[CAMINFO_CONVERT_NUM] = {
254 CONFIGURE_CATEGORY_CTRL_CAMERA,
255 MM_CAM_CAMERA_DEVICE_NAME,
256 MM_CAMCORDER_ATTR_NONE,
258 MM_CAMCONVERT_TYPE_STRING,
263 CONFIGURE_CATEGORY_CTRL_CAMERA,
265 MM_CAM_CAMERA_HEIGHT,
267 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
272 CONFIGURE_CATEGORY_CTRL_CAMERA,
273 MM_CAM_CAPTURE_WIDTH,
274 MM_CAM_CAPTURE_HEIGHT,
276 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
281 CONFIGURE_CATEGORY_CTRL_CAMERA,
282 MM_CAM_CAMERA_FORMAT,
283 MM_CAMCORDER_ATTR_NONE,
285 MM_CAMCONVERT_TYPE_INT_ARRAY,
290 CONFIGURE_CATEGORY_CTRL_STROBE,
291 MM_CAM_STROBE_CONTROL,
292 MM_CAMCORDER_ATTR_NONE,
294 MM_CAMCONVERT_TYPE_INT_ARRAY,
295 &_mmcamcorder_enum_conv_strobe_ctrl,
299 CONFIGURE_CATEGORY_CTRL_STROBE,
300 MM_CAM_STROBE_CAPABILITIES,
301 MM_CAMCORDER_ATTR_NONE,
302 "StrobeCapabilities",
303 MM_CAMCONVERT_TYPE_INT_ARRAY,
308 CONFIGURE_CATEGORY_CTRL_STROBE,
310 MM_CAMCORDER_ATTR_NONE,
312 MM_CAMCONVERT_TYPE_INT_ARRAY,
313 &_mmcamcorder_enum_conv_strobe_mode,
317 CONFIGURE_CATEGORY_CTRL_EFFECT,
318 MM_CAM_FILTER_BRIGHTNESS,
319 MM_CAMCORDER_ATTR_NONE,
321 MM_CAMCONVERT_TYPE_INT_RANGE,
326 CONFIGURE_CATEGORY_CTRL_EFFECT,
327 MM_CAM_FILTER_CONTRAST,
328 MM_CAMCORDER_ATTR_NONE,
330 MM_CAMCONVERT_TYPE_INT_RANGE,
335 CONFIGURE_CATEGORY_CTRL_EFFECT,
336 MM_CAM_FILTER_SATURATION,
337 MM_CAMCORDER_ATTR_NONE,
339 MM_CAMCONVERT_TYPE_INT_RANGE,
344 CONFIGURE_CATEGORY_CTRL_EFFECT,
346 MM_CAMCORDER_ATTR_NONE,
348 MM_CAMCONVERT_TYPE_INT_RANGE,
353 CONFIGURE_CATEGORY_CTRL_EFFECT,
354 MM_CAM_FILTER_SHARPNESS,
355 MM_CAMCORDER_ATTR_NONE,
357 MM_CAMCONVERT_TYPE_INT_RANGE,
362 CONFIGURE_CATEGORY_CTRL_EFFECT,
364 MM_CAMCORDER_ATTR_NONE,
366 MM_CAMCONVERT_TYPE_INT_ARRAY,
367 &_mmcamcorder_enum_conv_whitebalance,
371 CONFIGURE_CATEGORY_CTRL_EFFECT,
372 MM_CAM_FILTER_COLOR_TONE,
373 MM_CAMCORDER_ATTR_NONE,
375 MM_CAMCONVERT_TYPE_INT_ARRAY,
376 &_mmcamcorder_enum_conv_colortone,
380 CONFIGURE_CATEGORY_CTRL_EFFECT,
382 MM_CAMCORDER_ATTR_NONE,
384 MM_CAMCONVERT_TYPE_INT_ARRAY,
385 &_mmcamcorder_enum_conv_wdr_ctrl,
389 CONFIGURE_CATEGORY_CTRL_EFFECT,
391 MM_CAMCORDER_ATTR_NONE,
393 MM_CAMCONVERT_TYPE_INT_ARRAY,
394 &_mmcamcorder_enum_conv_flip_ctrl,
398 CONFIGURE_CATEGORY_CTRL_EFFECT,
399 MM_CAM_CAMERA_ROTATION,
400 MM_CAMCORDER_ATTR_NONE,
402 MM_CAMCONVERT_TYPE_INT_ARRAY,
403 &_mmcamcorder_enum_conv_rotation_ctrl,
407 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
408 MM_CAM_CAMERA_DIGITAL_ZOOM,
409 MM_CAMCORDER_ATTR_NONE,
411 MM_CAMCONVERT_TYPE_INT_RANGE,
416 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
417 MM_CAM_CAMERA_OPTICAL_ZOOM,
418 MM_CAMCORDER_ATTR_NONE,
420 MM_CAMCONVERT_TYPE_INT_RANGE,
425 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
426 MM_CAM_CAMERA_FOCUS_MODE,
427 MM_CAMCORDER_ATTR_NONE,
429 MM_CAMCONVERT_TYPE_INT_ARRAY,
430 &_mmcamcorder_enum_conv_focus_mode,
434 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
435 MM_CAM_CAMERA_AF_SCAN_RANGE,
436 MM_CAMCORDER_ATTR_NONE,
438 MM_CAMCONVERT_TYPE_INT_ARRAY,
439 &_mmcamcorder_enum_conv_focus_type,
443 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
444 MM_CAM_CAMERA_EXPOSURE_MODE,
445 MM_CAMCORDER_ATTR_NONE,
447 MM_CAMCONVERT_TYPE_INT_ARRAY,
448 &_mmcamcorder_enum_conv_ae_type,
452 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
453 MM_CAM_CAMERA_EXPOSURE_VALUE,
454 MM_CAMCORDER_ATTR_NONE,
456 MM_CAMCONVERT_TYPE_INT_RANGE,
461 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
462 MM_CAM_CAMERA_F_NUMBER,
463 MM_CAMCORDER_ATTR_NONE,
465 MM_CAMCONVERT_TYPE_INT_ARRAY,
470 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
471 MM_CAM_CAMERA_SHUTTER_SPEED,
472 MM_CAMCORDER_ATTR_NONE,
474 MM_CAMCONVERT_TYPE_INT_ARRAY,
479 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
481 MM_CAMCORDER_ATTR_NONE,
483 MM_CAMCONVERT_TYPE_INT_ARRAY,
484 &_mmcamcorder_enum_conv_iso,
488 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
489 MM_CAM_FILTER_SCENE_MODE,
490 MM_CAMCORDER_ATTR_NONE,
492 MM_CAMCONVERT_TYPE_INT_ARRAY,
493 &_mmcamcorder_enum_conv_prgrm,
497 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
498 MM_CAM_CAMERA_ANTI_HANDSHAKE,
499 MM_CAMCORDER_ATTR_NONE,
501 MM_CAMCONVERT_TYPE_INT_ARRAY,
502 &_mmcamcorder_enum_conv_ahs,
506 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
507 MM_CAM_CAMERA_PAN_MECHA,
508 MM_CAMCORDER_ATTR_NONE,
510 MM_CAMCONVERT_TYPE_INT_RANGE,
515 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
516 MM_CAM_CAMERA_PAN_ELEC,
517 MM_CAMCORDER_ATTR_NONE,
519 MM_CAMCONVERT_TYPE_INT_RANGE,
524 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
525 MM_CAM_CAMERA_TILT_MECHA,
526 MM_CAMCORDER_ATTR_NONE,
528 MM_CAMCONVERT_TYPE_INT_RANGE,
533 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
534 MM_CAM_CAMERA_TILT_ELEC,
535 MM_CAMCORDER_ATTR_NONE,
537 MM_CAMCONVERT_TYPE_INT_RANGE,
542 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
543 MM_CAM_CAMERA_PTZ_TYPE,
544 MM_CAMCORDER_ATTR_NONE,
546 MM_CAMCONVERT_TYPE_INT_ARRAY,
551 CONFIGURE_CATEGORY_CTRL_CAPTURE,
552 MM_CAM_CAPTURE_FORMAT,
553 MM_CAMCORDER_ATTR_NONE,
555 MM_CAMCONVERT_TYPE_INT_ARRAY,
560 CONFIGURE_CATEGORY_CTRL_CAPTURE,
561 MM_CAM_IMAGE_ENCODER_QUALITY,
562 MM_CAMCORDER_ATTR_NONE,
564 MM_CAMCONVERT_TYPE_INT_RANGE,
569 CONFIGURE_CATEGORY_CTRL_CAPTURE,
570 MM_CAM_CAPTURE_COUNT,
571 MM_CAMCORDER_ATTR_NONE,
573 MM_CAMCONVERT_TYPE_INT_RANGE,
578 CONFIGURE_CATEGORY_CTRL_CAPTURE,
579 MM_CAM_CAMERA_HDR_CAPTURE,
580 MM_CAMCORDER_ATTR_NONE,
582 MM_CAMCONVERT_TYPE_INT_ARRAY,
583 &_mmcamcorder_enum_conv_hdr_capture,
587 CONFIGURE_CATEGORY_CTRL_DETECT,
589 MM_CAMCORDER_ATTR_NONE,
591 MM_CAMCONVERT_TYPE_INT_ARRAY,
592 &_mmcamcorder_enum_conv_detect_mode,
596 CONFIGURE_CATEGORY_CTRL_DETECT,
597 MM_CAM_DETECT_NUMBER,
598 MM_CAMCORDER_ATTR_NONE,
600 MM_CAMCONVERT_TYPE_INT_RANGE,
605 CONFIGURE_CATEGORY_CTRL_DETECT,
606 MM_CAM_DETECT_FOCUS_SELECT,
607 MM_CAMCORDER_ATTR_NONE,
609 MM_CAMCONVERT_TYPE_INT_RANGE,
614 CONFIGURE_CATEGORY_CTRL_DETECT,
615 MM_CAM_DETECT_SELECT_NUMBER,
616 MM_CAMCORDER_ATTR_NONE,
617 "DetectSelectNumber",
618 MM_CAMCONVERT_TYPE_INT_RANGE,
623 CONFIGURE_CATEGORY_CTRL_DETECT,
624 MM_CAM_DETECT_STATUS,
625 MM_CAMCORDER_ATTR_NONE,
627 MM_CAMCONVERT_TYPE_INT_ARRAY,
632 CONFIGURE_CATEGORY_CTRL_CAMERA,
633 MM_CAM_RECOMMEND_CAMERA_WIDTH,
634 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
635 "RecommendPreviewResolution",
636 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
641 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
642 MM_CAM_CAMERA_VIDEO_STABILIZATION,
643 MM_CAMCORDER_ATTR_NONE,
644 "VideoStabilization",
645 MM_CAMCONVERT_TYPE_INT_ARRAY,
646 &_mmcamcorder_enum_conv_video_stabilization,
650 CONFIGURE_CATEGORY_CTRL_CAMERA,
654 MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY,
659 CONFIGURE_CATEGORY_CTRL_STROBE,
660 MM_CAM_STROBE_BRIGHTNESS,
661 MM_CAMCORDER_ATTR_NONE,
663 MM_CAMCONVERT_TYPE_INT_RANGE,
668 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
669 MM_CAM_CAMERA_FOCUS_LEVEL,
670 MM_CAMCORDER_ATTR_NONE,
672 MM_CAMCONVERT_TYPE_INT_RANGE,
677 CONFIGURE_CATEGORY_CTRL_EFFECT,
678 MM_CAM_FILTER_WB_TEMPERATURE,
679 MM_CAMCORDER_ATTR_NONE,
680 "WhiteBalanceTemperature",
681 MM_CAMCONVERT_TYPE_INT_RANGE,
686 CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH,
688 MM_CAMCORDER_ATTR_NONE,
690 MM_CAMCONVERT_TYPE_INT_RANGE,
695 /*---------------------------------------------------------------------------
696 | LOCAL FUNCTION PROTOTYPES: |
697 ---------------------------------------------------------------------------*/
698 /* STATIC INTERNAL FUNCTION */
699 static int __mmcamcorder_get_valid_array(int *original_array, int original_count, int **valid_array, int *valid_default);
701 /*===========================================================================================
703 | FUNCTION DEFINITIONS |
705 ========================================================================================== */
706 /*---------------------------------------------------------------------------
707 | GLOBAL FUNCTION DEFINITIONS: |
708 ---------------------------------------------------------------------------*/
709 /* convert MSL value to sensor value */
710 int _mmcamcorder_convert_msl_to_sensor(MMHandleType handle, int attr_idx, int mslval)
712 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
713 _MMCamcorderInfoConverting *info = NULL;
715 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
717 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
719 info = hcamcorder->caminfo_convert;
721 for (i = 0; i < size; i++) {
722 if (info[i].attr_idx == attr_idx) {
723 _MMCamcorderEnumConvert * enum_convert = NULL;
724 enum_convert = info[i].enum_convert;
726 if (enum_convert == NULL) {
727 MMCAM_LOG_VERBOSE("[attr:%d] NULL enum_convert, just return original[%d]",
732 if (enum_convert->enum_arr == NULL) {
733 MMCAM_LOG_WARNING("[attr:%d] NULL array pointer, just return original[%d]",
738 if (enum_convert->total_enum_num > mslval && mslval >= 0) {
739 MMCAM_LOG_VERBOSE("[attr:%d] original[%d] -> converted[%d]",
740 attr_idx, mslval, enum_convert->enum_arr[mslval]);
741 return enum_convert->enum_arr[mslval];
743 MMCAM_LOG_WARNING("[attr:%d] invalid input mslval[%d][size:%d], just return original.",
744 attr_idx, mslval, enum_convert->total_enum_num);
750 MMCAM_LOG_WARNING("[attr:%d] no category to match, just return original[%d]",
756 int _mmcamcorder_get_fps_array_by_resolution(MMHandleType handle, int width, int height, MMCamAttrsInfo* fps_info)
759 char nameFps[16] = {0, };
760 bool valid_check = false;
762 MMCamAttrsInfo infoW;
763 MMCamAttrsInfo infoH;
764 type_int_array *fps_array = NULL;
766 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
768 MMCAM_LOG_DEBUG("resolution %dx%d", width, height);
770 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_WIDTH, &infoW);
771 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &infoH);
773 for (i = 0; i < infoW.int_array.count; i++) {
774 MMCAM_LOG_VERBOSE("check resolution %dx%d", infoW.int_array.array[i], infoH.int_array.array[i]);
775 if (infoW.int_array.array[i] == width && infoH.int_array.array[i] == height) {
777 snprintf(nameFps, sizeof(nameFps), "FPS%d", i);
778 MMCAM_LOG_INFO("nameFps[%s]", nameFps);
784 MMCAM_LOG_ERROR("FAILED : Can't find the valid resolution from attribute.");
785 return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
788 /* get fps list from capability first. */
789 if (_mmcamcorder_capability_get_preview_fps_list_by_resolution(handle, width, height,
790 &fps_info->int_array.array, &fps_info->int_array.count, &fps_info->int_array.def) == MM_ERROR_NONE)
791 return MM_ERROR_NONE;
793 /* get fps list from ini if it's failed from capability. */
794 if (!_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl, CONFIGURE_CATEGORY_CTRL_CAMERA, nameFps, &fps_array)) {
795 MMCAM_LOG_ERROR("FAILED : Can't find the valid FPS array.");
796 return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
799 fps_info->int_array.count = fps_array->count;
800 fps_info->int_array.array = fps_array->value;
801 fps_info->int_array.def = fps_array->default_value;
803 return MM_ERROR_NONE;
806 /* convert sensor value to MSL value */
807 int _mmcamcorder_convert_sensor_to_msl(MMHandleType handle, int attr_idx, int sensval)
809 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
810 _MMCamcorderInfoConverting *info = NULL;
812 int size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
814 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
816 info = hcamcorder->caminfo_convert;
818 for (i = 0 ; i < size ; i++) {
819 if (info[i].attr_idx == attr_idx) {
820 _MMCamcorderEnumConvert * enum_convert = NULL;
821 enum_convert = info[i].enum_convert;
823 if (enum_convert == NULL) {
824 MMCAM_LOG_VERBOSE("[attr:%d] NULL enum_convert, just return original[%d]",
829 if (enum_convert->enum_arr == NULL) {
830 MMCAM_LOG_WARNING("[attr:%d] NULL array pointer, just return original[%d]",
835 for (j = 0 ; j < enum_convert->total_enum_num ; j++) {
836 if (sensval == enum_convert->enum_arr[j]) {
837 MMCAM_LOG_VERBOSE("[attr:%d] original[%d] -> converted[%d]",
838 attr_idx, sensval, j);
843 MMCAM_LOG_WARNING("[attr:%d] no sensor value matched, just return original[%d]",
851 MMCAM_LOG_INFO("[attr:%d] no category to match, just return original[%d]",
857 static int __mmcamcorder_get_valid_array(int *original_array, int original_count, int **valid_array, int *valid_default)
861 int new_default = _MMCAMCORDER_SENSOR_ENUM_NONE;
863 for (i = 0; i < original_count; i++) {
864 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE)
868 if (valid_count > 0) {
869 *valid_array = (int*)malloc(sizeof(int) * valid_count);
873 for (i = 0; i < original_count; i++) {
874 if (original_array[i] != _MMCAMCORDER_SENSOR_ENUM_NONE) {
875 (*valid_array)[valid_count++] = i;
876 MMCAM_LOG_VERBOSE("valid_array[%d] = %d", valid_count-1, (*valid_array)[valid_count-1]);
878 if (original_array[i] == *valid_default &&
879 new_default == _MMCAMCORDER_SENSOR_ENUM_NONE) {
881 MMCAM_LOG_VERBOSE("converted MSL default[%d]", new_default);
890 if (new_default != _MMCAMCORDER_SENSOR_ENUM_NONE)
891 *valid_default = new_default;
897 int _mmcamcorder_init_attr_from_configure(MMHandleType handle, MMCamConvertingCategory category)
899 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
900 _MMCamcorderInfoConverting *info = NULL;
903 int ret = MM_ERROR_NONE;
905 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
907 MMCAM_LOG_INFO("category : %d", category);
909 if (category & MM_CAMCONVERT_CATEGORY_CAMERA) {
910 /* Initialize attribute related to camera control */
911 info = hcamcorder->caminfo_convert;
912 table_size = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
913 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
914 if (ret != MM_ERROR_NONE) {
915 MMCAM_LOG_ERROR("camera info set error : 0x%x", ret);
920 if (category & MM_CAMCONVERT_CATEGORY_DISPLAY) {
921 /* Initialize attribute related to display */
922 info = g_display_info;
923 table_size = sizeof(g_display_info) / sizeof(_MMCamcorderInfoConverting);
924 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
925 if (ret != MM_ERROR_NONE) {
926 MMCAM_LOG_ERROR("display info set error : 0x%x", ret);
931 if (category & MM_CAMCONVERT_CATEGORY_AUDIO) {
932 /* Initialize attribute related to audio */
934 table_size = sizeof(g_audio_info) / sizeof(_MMCamcorderInfoConverting);
935 ret = __mmcamcorder_set_info_to_attr(handle, info, table_size);
936 if (ret != MM_ERROR_NONE) {
937 MMCAM_LOG_ERROR("audio info set error : 0x%x", ret);
942 hcamcorder->is_configured = TRUE;
944 MMCAM_LOG_INFO("done");
950 int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverting *info, int table_size)
952 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
953 MMHandleType attrs = 0;
956 int ret = MM_ERROR_NONE;
958 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
960 attrs = MMF_CAMCORDER_ATTRS(handle);
961 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
963 camera_conf *conf_info = NULL;
965 for (i = 0; i < table_size; i++) {
966 MMCAM_LOG_VERBOSE("[type:%d][cat:%d][attr:%d][attr_pair:%d][key:%s][ctype:%d]",
970 info[i].attr_idx_pair,
974 if (ret != MM_ERROR_NONE)
977 if (info[i].type == CONFIGURE_TYPE_MAIN)
978 conf_info = hcamcorder->conf_main;
980 conf_info = hcamcorder->conf_ctrl;
982 switch (info[i].conv_type) {
983 case MM_CAMCONVERT_TYPE_INT:
987 if (!_mmcamcorder_conf_get_value_int(handle, conf_info, info[i].category, info[i].keyword, &ivalue)) {
988 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
989 break; /* skip to set */
992 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, ivalue);
995 case MM_CAMCONVERT_TYPE_INT_ARRAY:
1000 type_int_array *tarray = NULL;
1002 if (!_mmcamcorder_conf_get_value_int_array(conf_info, info[i].category, info[i].keyword, &tarray))
1003 break; /* skip to set, but not error */
1006 idefault = tarray->default_value;
1008 if (info[i].enum_convert) {
1009 iarray_size = __mmcamcorder_get_valid_array(tarray->value, tarray->count, &iarray, &idefault);
1011 iarray = tarray->value;
1012 iarray_size = tarray->count;
1015 if (iarray_size > 0) {
1016 MMCAM_LOG_DEBUG("[%s] INT Array - size[%d], default[%d]",
1017 info[i].keyword, iarray_size, idefault);
1019 mm_attrs_set_valid_array(attrs, info[i].attr_idx, iarray, iarray_size, idefault);
1020 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, idefault);
1024 if (iarray && iarray != tarray->value)
1029 case MM_CAMCONVERT_TYPE_INT_RANGE:
1031 type_int_range *irange = NULL;
1033 if (!_mmcamcorder_conf_get_value_int_range(conf_info, info[i].category, info[i].keyword, &irange))
1034 break; /* skip to set, but not error */
1037 MMCAM_LOG_DEBUG("[%s] INT Range - min[%d], max[%d]",
1038 info[i].keyword, irange->min, irange->max);
1040 mm_attrs_set_valid_range(attrs, info[i].attr_idx, irange->min, irange->max, irange->default_value);
1041 ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, irange->default_value);
1046 case MM_CAMCONVERT_TYPE_STRING:
1048 const char *cString = NULL;
1050 if (!_mmcamcorder_conf_get_value_string(handle, conf_info, info[i].category, info[i].keyword, &cString)) {
1051 ret = MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
1052 break; /* skip to set */
1055 MMCAM_LOG_DEBUG("[%s] String - string[%s]", info[i].keyword, cString);
1056 ret = mm_attrs_set_string(attrs, info[i].attr_idx, cString, cString ? strlen(cString) : 0);
1059 case MM_CAMCONVERT_TYPE_INT_PAIR_ARRAY:
1061 type_int_pair_array *pair_array = NULL;
1063 if (!_mmcamcorder_conf_get_value_int_pair_array(conf_info, info[i].category, info[i].keyword, &pair_array))
1064 break; /* skip to set, but not error */
1066 if (pair_array && pair_array->count > 0) {
1067 mm_attrs_set_valid_array(attrs, info[i].attr_idx,
1068 pair_array->value[0],
1070 pair_array->default_value[0]);
1071 mm_attrs_set_valid_array(attrs, info[i].attr_idx_pair,
1072 pair_array->value[1],
1074 pair_array->default_value[1]);
1076 MMCAM_LOG_DEBUG("[%s] INT PAIR Array - default[%d,%d]",
1077 info[i].keyword, pair_array->default_value[0], pair_array->default_value[1]);
1079 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, pair_array->default_value[0]);
1080 mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx_pair, pair_array->default_value[1]);
1085 case MM_CAMCONVERT_TYPE_USER:
1087 MMCAM_LOG_WARNING("default - [attr:%d]", info[i].attr_idx);
1092 if (ret != MM_ERROR_NONE || mm_attrs_commit_all(attrs) == -1)
1093 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1095 return MM_ERROR_NONE;
1099 int _mmcamcorder_set_converted_value(MMHandleType handle, _MMCamcorderEnumConvert * convert)
1101 mmf_camcorder_t* hcamcorder = MMF_CAMCORDER(handle);
1102 type_int_array *array = NULL;
1104 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1106 _mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl, convert->category, convert->keyword, &array);
1109 convert->enum_arr = array->value;
1111 return MM_ERROR_NONE;
1115 int _mmcamcorder_init_convert_table(MMHandleType handle)
1117 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1118 size_t enum_conv_size = sizeof(_MMCamcorderEnumConvert);
1119 size_t caminfo_conv_size = sizeof(g_caminfo_convert);
1120 size_t caminfo_conv_length = sizeof(g_caminfo_convert) / sizeof(_MMCamcorderInfoConverting);
1123 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1125 /* copy default conv data into memory of handle */
1126 memcpy(&(hcamcorder->caminfo_convert), &g_caminfo_convert, caminfo_conv_size);
1127 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]), &_mmcamcorder_enum_conv_whitebalance, enum_conv_size);
1128 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]), &_mmcamcorder_enum_conv_colortone, enum_conv_size);
1129 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ISO]), &_mmcamcorder_enum_conv_iso, enum_conv_size);
1130 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]), &_mmcamcorder_enum_conv_prgrm, enum_conv_size);
1131 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]), &_mmcamcorder_enum_conv_focus_mode, enum_conv_size);
1132 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]), &_mmcamcorder_enum_conv_focus_type, enum_conv_size);
1133 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]), &_mmcamcorder_enum_conv_ae_type, enum_conv_size);
1134 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]), &_mmcamcorder_enum_conv_strobe_mode, enum_conv_size);
1135 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_WDR]), &_mmcamcorder_enum_conv_wdr_ctrl, enum_conv_size);
1136 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]), &_mmcamcorder_enum_conv_flip_ctrl, enum_conv_size);
1137 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]), &_mmcamcorder_enum_conv_rotation_ctrl, enum_conv_size);
1138 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]), &_mmcamcorder_enum_conv_ahs, enum_conv_size);
1139 memcpy(&(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]), &_mmcamcorder_enum_conv_video_stabilization, enum_conv_size);
1141 /* set ini info to conv data */
1142 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]));
1143 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]));
1144 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]));
1145 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]));
1146 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]));
1147 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]));
1148 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]));
1149 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]));
1150 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]));
1151 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]));
1152 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]));
1153 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]));
1154 _mmcamcorder_set_converted_value(handle, &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]));
1156 /* set modified conv data to handle */
1157 for (i = 0 ; i < caminfo_conv_length ; i++) {
1158 if (hcamcorder->caminfo_convert[i].type == CONFIGURE_TYPE_CTRL) {
1159 switch (hcamcorder->caminfo_convert[i].category) {
1160 case CONFIGURE_CATEGORY_CTRL_STROBE:
1161 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "StrobeMode"))
1162 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_STROBE_MODE]);
1164 case CONFIGURE_CATEGORY_CTRL_EFFECT:
1165 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WhiteBalance"))
1166 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WHITE_BALANCE]);
1167 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ColorTone"))
1168 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_COLOR_TONE]);
1169 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "WDR"))
1170 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_WDR]);
1171 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Flip"))
1172 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FLIP]);
1173 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "Rotation"))
1174 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ROTATION]);
1176 case CONFIGURE_CATEGORY_CTRL_PHOTOGRAPH:
1177 if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "FocusMode"))
1178 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_FOCUS_MODE]);
1179 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AFType"))
1180 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_AF_RANGE]);
1181 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AEType"))
1182 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_EXPOSURE_MODE]);
1183 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ISO"))
1184 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ISO]);
1185 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "ProgramMode"))
1186 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_PROGRAM_MODE]);
1187 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "AntiHandshake"))
1188 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_ANTI_HAND_SHAKE]);
1189 else if (!strcmp(hcamcorder->caminfo_convert[i].keyword, "VideoStabilization"))
1190 hcamcorder->caminfo_convert[i].enum_convert = &(hcamcorder->enum_conv[ENUM_CONVERT_VIDEO_STABILIZATION]);
1198 return MM_ERROR_NONE;
1202 double _mmcamcorder_convert_volume(int mslVal)
1213 MMCAM_LOG_WARNING("out of range");