2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <system_info.h>
24 #define METHOD_IS_AVAILABLE "IRIsAvailable"
25 #define METHOD_TRANSMIT "TransmitIR"
26 #define IR_FEATURE "http://tizen.org/feature/consumer_ir"
29 int device_ir_is_available(bool *available)
35 return DEVICE_ERROR_INVALID_PARAMETER;
37 ret = system_info_get_platform_bool(IR_FEATURE, &ir_avail);
41 return DEVICE_ERROR_OPERATION_FAILED;
42 } else if (ret == 0 && !ir_avail) {
44 return DEVICE_ERROR_NOT_SUPPORTED;
47 ret = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_IR,
48 DEVICED_INTERFACE_IR, METHOD_IS_AVAILABLE,
53 return DEVICE_ERROR_OPERATION_FAILED;
56 *available = ir_avail;
57 return DEVICE_ERROR_NONE;
60 int device_ir_transmit(int carrier_frequency, int *pattern, int size)
63 struct dbus_int pattern_list;
64 int freq_pattern[size + 1];
69 ret = device_ir_is_available(&ir_avail);
72 _E("IR is not supported or IR operation failed");
75 _E("IR is not supported");
76 return DEVICE_ERROR_OPERATION_FAILED;
80 return DEVICE_ERROR_INVALID_PARAMETER;
82 _E("IR pattern size is invalid");
83 return DEVICE_ERROR_INVALID_PARAMETER;
86 freq_pattern[0] = carrier_frequency;
87 for (i = 1; i <= size; i++)
88 freq_pattern[i] = pattern[i-1];
90 pattern_list.list = freq_pattern;
91 pattern_list.size = size + 1;
92 arr[0] = (char *)&pattern_list;
94 ret = dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_IR,
95 DEVICED_INTERFACE_IR, METHOD_TRANSMIT,
99 return DEVICE_ERROR_OPERATION_FAILED;
101 return DEVICE_ERROR_NONE;