4 * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
7 * Manoj Kumar K <manojkumar.k@samsung.com>, Hyunil Park <hyunil46.park@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #include "mm_wfd_sink_attrs.h"
24 #include "mm_wfd_sink_dlog.h"
25 #include "mm_wfd_sink_priv.h"
35 mm_wfd_sink_commit_func_t attr_commit;
38 static void __mm_wfd_sink_print_attrs(const char *attr_name, const MMAttrsValue * value, const char *prefix)
40 switch (value->type) {
41 case MM_ATTRS_TYPE_INT:
42 wfd_sink_debug("[ %s : %s : %d ]", prefix, attr_name, value->value.i_val);
44 case MM_ATTRS_TYPE_DOUBLE:
45 wfd_sink_debug("[ %s : %s : %f ]", prefix, attr_name, value->value.d_val);
47 case MM_ATTRS_TYPE_STRING:
48 wfd_sink_debug("[ %s : %s : %s ]", prefix, attr_name, value->value.s_val);
50 case MM_ATTRS_TYPE_DATA:
51 wfd_sink_debug("[ %s : %s : %p ]", prefix, attr_name, value->value.p_val);
60 static bool _mmwfd_set_display_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value);
62 MMWfdAttrsSpec wfd_attrs[] = {
68 MM_ATTRS_VALID_TYPE_NONE,
74 (char *)"server_port",
78 MM_ATTRS_VALID_TYPE_NONE,
84 (char *)"max_client_count",
88 MM_ATTRS_VALID_TYPE_INT_RANGE,
93 /* Initialized with invalid native type, if a valid value is set then only this atribute will be considered */
95 (char *)"native_resolution",
99 MM_ATTRS_VALID_TYPE_INT_RANGE,
104 /* Initialized with invalid resolution, if a valid value is set then only this atribute will be considered */
106 (char *)"prefered_resolutions",
110 MM_ATTRS_VALID_TYPE_INT_RANGE,
115 /* Initialized with invalid uibc option, if a valid value is set then only this atribute will be considered */
121 MM_ATTRS_VALID_TYPE_INT_RANGE,
127 (char *)"display_rotate",
131 MM_ATTRS_VALID_TYPE_INT_RANGE,
137 (char *)"display_src_crop_x",
141 MM_ATTRS_VALID_TYPE_INT_RANGE,
147 (char *)"display_src_crop_y",
151 MM_ATTRS_VALID_TYPE_INT_RANGE,
157 (char *)"display_src_crop_width",
161 MM_ATTRS_VALID_TYPE_INT_RANGE,
167 (char *)"display_src_crop_height",
171 MM_ATTRS_VALID_TYPE_INT_RANGE,
177 (char *)"display_roi_x",
181 MM_ATTRS_VALID_TYPE_INT_RANGE,
187 (char *)"display_roi_y",
191 MM_ATTRS_VALID_TYPE_INT_RANGE,
197 (char *)"display_roi_width",
201 MM_ATTRS_VALID_TYPE_INT_RANGE,
207 (char *)"display_roi_height",
211 MM_ATTRS_VALID_TYPE_INT_RANGE,
217 (char *)"display_roi_mode",
220 (void *) MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
221 MM_ATTRS_VALID_TYPE_INT_RANGE,
222 MM_DISPLAY_METHOD_CUSTOM_ROI_FULL_SCREEN,
223 MM_DISPLAY_METHOD_CUSTOM_ROI_LETER_BOX,
227 (char *)"display_rotation",
230 (void *) MM_DISPLAY_ROTATION_NONE,
231 MM_ATTRS_VALID_TYPE_INT_RANGE,
232 MM_DISPLAY_ROTATION_NONE,
233 MM_DISPLAY_ROTATION_270,
237 (char *)"display_visible",
241 MM_ATTRS_VALID_TYPE_INT_RANGE,
247 (char *)"display_method",
250 (void *) MM_DISPLAY_METHOD_LETTER_BOX,
251 MM_ATTRS_VALID_TYPE_INT_RANGE,
252 MM_DISPLAY_METHOD_LETTER_BOX,
253 MM_DISPLAY_METHOD_CUSTOM_ROI,
257 (char *)"display_overlay",
261 MM_ATTRS_VALID_TYPE_NONE,
264 _mmwfd_set_display_info,
267 (char *)"display_overlay_user_data",
271 MM_ATTRS_VALID_TYPE_NONE,
277 (char *)"display_zoom",
278 MM_ATTRS_TYPE_DOUBLE,
281 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
287 (char *)"display_surface_type",
290 (void *) MM_DISPLAY_SURFACE_OVERLAY,
291 MM_ATTRS_VALID_TYPE_INT_RANGE,
292 MM_DISPLAY_SURFACE_OVERLAY,
293 MM_DISPLAY_SURFACE_REMOTE,
297 (char *)"display_width", /* dest width of fimcconvert ouput */
301 MM_ATTRS_VALID_TYPE_INT_RANGE,
307 (char *)"display_height", /* dest height of fimcconvert ouput */
311 MM_ATTRS_VALID_TYPE_INT_RANGE,
317 (char *)"display_evas_do_scaling",
321 MM_ATTRS_VALID_TYPE_INT_RANGE,
331 MM_ATTRS_VALID_TYPE_INT_RANGE,
341 MM_ATTRS_VALID_TYPE_INT_RANGE,
347 (char *)"hdcp_version",
351 MM_ATTRS_VALID_TYPE_INT_RANGE,
361 MM_ATTRS_VALID_TYPE_INT_RANGE,
367 (char *)"hdcp_handle",
371 MM_ATTRS_VALID_TYPE_NONE,
377 (char *)"window_width",
381 MM_ATTRS_VALID_TYPE_INT_RANGE,
387 (char *)"window_height",
391 MM_ATTRS_VALID_TYPE_INT_RANGE,
397 (char *)"resource_priority",
401 MM_ATTRS_VALID_TYPE_INT_RANGE,
408 bool _mm_wfd_sink_commit_wfd_attrs(int attr_idx, const char *attr_name, const MMAttrsValue * value, void *commit_param)
411 return_val_if_fail(commit_param, FALSE);
412 return_val_if_fail(attr_idx >= 0, FALSE);
413 return_val_if_fail(attr_name, FALSE);
414 return_val_if_fail(value, FALSE);
416 if (wfd_attrs[attr_idx].attr_commit) {
417 __mm_wfd_sink_print_attrs(attr_name, value, "Dynamic");
418 ret = wfd_attrs[attr_idx].attr_commit((MMHandleType) commit_param, attr_idx, value);
420 __mm_wfd_sink_print_attrs(attr_name, value, "Static");
427 _mmwfd_construct_attribute(MMHandleType handle)
430 MMHandleType attrs = NULL;
431 int num_of_attrs = 0;
432 MMAttrsConstructInfo *base = NULL;
433 int ret = MM_ERROR_NONE;
435 wfd_sink_debug_fenter();
437 return_val_if_fail(handle, (MMHandleType) NULL);
439 num_of_attrs = ARRAY_SIZE(wfd_attrs);
441 base = (MMAttrsConstructInfo *)malloc(num_of_attrs * sizeof(MMAttrsConstructInfo));
444 wfd_sink_error("Cannot create mmwfd attribute\n");
448 /* initialize values of attributes */
449 for (idx = 0; idx < num_of_attrs; idx++) {
450 base[idx].name = wfd_attrs[idx].name;
451 base[idx].value_type = wfd_attrs[idx].value_type;
452 base[idx].flags = wfd_attrs[idx].flags;
453 base[idx].default_value = wfd_attrs[idx].default_value;
460 _mm_wfd_sink_commit_wfd_attrs,
461 (void *)handle, &attrs);
468 if (ret != MM_ERROR_NONE) {
469 wfd_sink_error("Cannot create mmwfd attribute\n");
473 /* set validity type and range */
474 for (idx = 0; idx < num_of_attrs; idx++) {
475 switch (wfd_attrs[idx].valid_type) {
476 case MM_ATTRS_VALID_TYPE_INT_RANGE: {
477 mm_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
478 mm_attrs_set_valid_range(attrs, idx,
479 wfd_attrs[idx].value_min,
480 wfd_attrs[idx].value_max,
481 (int)wfd_attrs[idx].default_value);
485 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
486 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
487 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
493 wfd_sink_debug_fleave();
498 _mmwfd_deconstruct_attribute(attrs);
500 return (MMHandleType)NULL;
504 _mmwfd_deconstruct_attribute(MMHandleType handle)
506 wfd_sink_debug_fenter();
508 return_if_fail(handle);
511 mm_attrs_free(handle);
513 wfd_sink_debug_fleave();
517 _mmwfd_get_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
519 int result = MM_ERROR_NONE;
520 MMHandleType attrs = 0;
522 wfd_sink_debug_fenter();
524 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
525 /* if it's not want to know it. */
526 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
527 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
531 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
533 result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
535 if (result != MM_ERROR_NONE)
536 wfd_sink_error("failed to get %s attribute\n", attribute_name);
538 wfd_sink_debug_fleave();
544 _mmwfd_set_attribute(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list args_list)
546 int result = MM_ERROR_NONE;
547 MMHandleType attrs = 0;
549 wfd_sink_debug_fenter();
551 /* NOTE : Don't need to check err_attr_name because it can be set NULL */
552 /* if it's not want to know it. */
553 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
554 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
558 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
560 /* set attributes and commit them */
561 result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
563 if (result != MM_ERROR_NONE) {
564 wfd_sink_error("failed to set %s attribute\n", attribute_name);
568 /*__mmwfd_apply_attribute(handle, attribute_name); */
570 wfd_sink_debug_fleave();
576 _mmwfd_get_attributes_info(MMHandleType handle, const char *attribute_name, MMWfdAttrsInfo *dst_info)
578 int result = MM_ERROR_NONE;
579 MMHandleType attrs = 0;
580 MMAttrsInfo src_info = {0, };
582 wfd_sink_debug_fenter();
584 return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
585 return_val_if_fail(dst_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
586 return_val_if_fail(handle, MM_ERROR_COMMON_INVALID_ARGUMENT);
590 return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
592 result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
594 if (result != MM_ERROR_NONE) {
595 wfd_sink_error("failed to get attribute info\n");
599 memset(dst_info, 0x00, sizeof(MMWfdAttrsInfo));
601 dst_info->type = src_info.type;
602 dst_info->flag = src_info.flag;
603 dst_info->validity_type = src_info.validity_type;
605 switch (src_info.validity_type) {
606 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
607 dst_info->int_array.array = src_info.int_array.array;
608 dst_info->int_array.count = src_info.int_array.count;
609 dst_info->int_array.d_val = src_info.int_array.dval;
612 case MM_ATTRS_VALID_TYPE_INT_RANGE:
613 dst_info->int_range.min = src_info.int_range.min;
614 dst_info->int_range.max = src_info.int_range.max;
615 dst_info->int_range.d_val = src_info.int_range.dval;
618 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
619 dst_info->double_array.array = src_info.double_array.array;
620 dst_info->double_array.count = src_info.double_array.count;
621 dst_info->double_array.d_val = src_info.double_array.dval;
624 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
625 dst_info->double_range.min = src_info.double_range.min;
626 dst_info->double_range.max = src_info.double_range.max;
627 dst_info->double_range.d_val = src_info.double_range.dval;
634 wfd_sink_debug_fleave();
640 static bool _mmwfd_set_display_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
642 gint surface_type = MM_DISPLAY_SURFACE_OVERLAY;
643 mm_wfd_sink_t *wfd_sink = MMWFDSINK_CAST(handle);
645 wfd_sink_debug_fenter();
647 /* update display surface */
648 mm_attrs_get_int_by_name(MMWFDSINK_GET_ATTRS(wfd_sink), "display_surface_type", &surface_type);
649 wfd_sink_info("check display surface type attribute: %d", surface_type);
651 /* configuring display */
652 switch (surface_type) {
653 case MM_DISPLAY_SURFACE_EVAS:
656 case MM_DISPLAY_SURFACE_OVERLAY:
657 if (MM_ERROR_NONE != _mm_wfd_sink_set_display_overlay(wfd_sink, value->value.p_val)) {
658 wfd_sink_error("Setting overlay display is failed.");
662 case MM_DISPLAY_SURFACE_NULL:
664 wfd_sink_error("Not Supported Surface. surface_type: [%d]", surface_type);
668 wfd_sink_debug_fleave();