diff options
author | pr.jung <pr.jung@samsung.com> | 2016-02-17 15:26:59 +0900 |
---|---|---|
committer | pr.jung <pr.jung@samsung.com> | 2016-02-23 11:20:06 +0900 |
commit | 2cef1dd68c2a9a6745964bacadbb785d7b5f7491 (patch) | |
tree | 6c0b493d39c488e4cc3292b12b95e6542fb5de23 /hw | |
parent | e9da24bf7aee4608a2506c8cb36c0e72d0f9c0ad (diff) | |
download | device-tm1-2cef1dd68c2a9a6745964bacadbb785d7b5f7491.tar.gz device-tm1-2cef1dd68c2a9a6745964bacadbb785d7b5f7491.tar.bz2 device-tm1-2cef1dd68c2a9a6745964bacadbb785d7b5f7491.zip |
ir: Implement ir HAL
Change-Id: Ie4c0b0b82f4c85cf197a6348ce04e1d112583f83
Signed-off-by: pr.jung <pr.jung@samsung.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ir/CMakeLists.txt | 16 | ||||
-rw-r--r-- | hw/ir/ir.c | 93 |
2 files changed, 109 insertions, 0 deletions
diff --git a/hw/ir/CMakeLists.txt b/hw/ir/CMakeLists.txt new file mode 100644 index 0000000..ab104e7 --- /dev/null +++ b/hw/ir/CMakeLists.txt @@ -0,0 +1,16 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(ir C) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED dlog hwcommon) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} MODULE ir.c ../shared.c) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries) diff --git a/hw/ir/ir.c b/hw/ir/ir.c new file mode 100644 index 0000000..82a36f7 --- /dev/null +++ b/hw/ir/ir.c @@ -0,0 +1,93 @@ +/* + * device-node + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <linux/limits.h> +#include <dirent.h> + +#include <hw/ir.h> +#include "../shared.h" + +#define IRLED_CONTROL_PATH "/sys/class/sec/sec_ir/ir_send" + +static int ir_is_available(bool *available) +{ + *available = true; + return 0; +} + +static int ir_transmit(int *frequency_pattern, int size) +{ + int i, ret; + + if (!frequency_pattern) + return -EINVAL; + + for (i = 0; i < size; i++) { + ret = sys_set_int(IRLED_CONTROL_PATH, frequency_pattern[i]); + if (ret < 0) { + _E("Failed to transmit ir pattern"); + return ret; + } + } + return 0; +} + +static int ir_open(struct hw_info *info, + const char *id, struct hw_common **common) +{ + struct ir_device *ir_dev; + + if (!info || !common) + return -EINVAL; + + ir_dev = calloc(1, sizeof(struct ir_device)); + if (!ir_dev) + return -ENOMEM; + + ir_dev->common.info = info; + ir_dev->is_available = ir_is_available; + ir_dev->transmit = ir_transmit; + + *common = (struct hw_common *)ir_dev; + return 0; +} + +static int ir_close(struct hw_common *common) +{ + if (!common) + return -EINVAL; + + free(common); + return 0; +} + +HARDWARE_MODULE_STRUCTURE = { + .magic = HARDWARE_INFO_TAG, + .hal_version = HARDWARE_INFO_VERSION, + .device_version = IR_HARDWARE_DEVICE_VERSION, + .id = IR_HARDWARE_DEVICE_ID, + .name = "ir", + .open = ir_open, + .close = ir_close, +}; |