diff options
author | taeyoung <ty317.kim@samsung.com> | 2015-11-12 13:42:35 +0900 |
---|---|---|
committer | taeyoung <ty317.kim@samsung.com> | 2015-11-12 13:51:07 +0900 |
commit | eaa2f9fe64398865ab6eb889469c1f824dc0c472 (patch) | |
tree | 3335fb7a0347108b206e5257f5e3259e0bf80b59 | |
parent | 8d6110e0432fd49faad07cbc50143ce6a7ff00ce (diff) | |
download | device-tm1-eaa2f9fe64398865ab6eb889469c1f824dc0c472.tar.gz device-tm1-eaa2f9fe64398865ab6eb889469c1f824dc0c472.tar.bz2 device-tm1-eaa2f9fe64398865ab6eb889469c1f824dc0c472.zip |
HAL: change HAL module to use hwcommon library
- Previous implementation is from Tizen 2.4, and it was not
use the new HAL structure.
- To support New HAL of Tizen 3.0, it uses hwcommon library
which defines the interfaces between kernel and platform.
Change-Id: I8340dbbdd7516a206ecc311dd91c1ab617dcfe63
Signed-off-by: taeyoung <ty317.kim@samsung.com>
-rw-r--r-- | CMakeLists.txt | 47 | ||||
-rw-r--r-- | LICENSE (renamed from apache-2.0.txt) | 0 | ||||
-rw-r--r-- | hw/display/CMakeLists.txt | 19 | ||||
-rw-r--r-- | hw/display/display.c | 48 | ||||
-rw-r--r-- | hw/led/CMakeLists.txt | 16 | ||||
-rw-r--r-- | hw/led/led.c | 49 | ||||
-rw-r--r-- | hw/shared.c | 129 | ||||
-rw-r--r-- | hw/shared.h | 43 | ||||
-rw-r--r-- | packaging/device-manager-plugin-sc7727.spec | 53 | ||||
-rw-r--r-- | packaging/device-manager-plugin-sc7730.manifest (renamed from device-manager-plugin-sc7727.manifest) | 10 | ||||
-rw-r--r-- | packaging/device-manager-plugin-sc7730.spec | 40 |
11 files changed, 352 insertions, 102 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4597b43..2495541 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(slp_devman_plugin C) - -SET(SRCS - src/device_manager_io.c - src/device_manager_TRM.c - src/device_manager_siop.c - src/device_manager_plugin_sc7727.c) - -SET(DUMP_FILES - dump/dump_power.sh) - -SET(SRC_TEST - src/test_devices.c - src/device_manager_io.c - src/device_manager_siop.c) - -IF("${CMAKE_BUILD_TYPE}" STREQUAL "") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") -MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") -SET(CMAKE_C_FLAGS_RELEASE "-O2") - -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED devman_plugin) - -FOREACH(flag ${pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) - -ADD_EXECUTABLE(sys_oal_test ${SRC_TEST}) -TARGET_LINK_LIBRARIES(sys_oal_test ${pkgs_LDFLAGS}) +PROJECT(device-manager-sc7730 C) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries) -INSTALL(PROGRAMS ${DUMP_FILES} DESTINATION /opt/etc/dump.d/module.d) -INSTALL(TARGETS sys_oal_test DESTINATION bin) +ADD_SUBDIRECTORY(hw/display) +ADD_SUBDIRECTORY(hw/led) diff --git a/hw/display/CMakeLists.txt b/hw/display/CMakeLists.txt new file mode 100644 index 0000000..ebccfbe --- /dev/null +++ b/hw/display/CMakeLists.txt @@ -0,0 +1,19 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(display C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(display_pkgs REQUIRED hwcommon dlog) + +FOREACH(flag ${display_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 display.c ../shared.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${display_pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries) diff --git a/hw/display/display.c b/hw/display/display.c new file mode 100644 index 0000000..e144804 --- /dev/null +++ b/hw/display/display.c @@ -0,0 +1,48 @@ +/* + * device-node + * + * Copyright (c) 2015 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 <stdlib.h> +#include <string.h> +#include <errno.h> +#include <linux/limits.h> + +#include <hw/display.h> +#include "../shared.h" + +static int display_open(struct hw_info *info, + const char *id, struct hw_common **common) +{ + return 0; +} + +static int display_close(struct hw_common *common) +{ + return 0; +} + +HARDWARE_MODULE_STRUCTURE = { + .magic = HARDWARE_INFO_TAG, + .hal_version = HARDWARE_INFO_VERSION, + .device_version = DISPLAY_HARDWARE_DEVICE_VERSION, + .id = DISPLAY_HARDWARE_DEVICE_ID, + .name = "Display", + .open = display_open, + .close = display_close, +}; diff --git a/hw/led/CMakeLists.txt b/hw/led/CMakeLists.txt new file mode 100644 index 0000000..017ddc6 --- /dev/null +++ b/hw/led/CMakeLists.txt @@ -0,0 +1,16 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(led 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 led.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/led/led.c b/hw/led/led.c new file mode 100644 index 0000000..a2df95a --- /dev/null +++ b/hw/led/led.c @@ -0,0 +1,49 @@ +/* + * device-node + * + * Copyright (c) 2015 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 <stdlib.h> +#include <string.h> +#include <errno.h> +#include <linux/limits.h> + +#include <hw/led.h> +#include "../shared.h" + +static int led_open(struct hw_info *info, + const char *id, struct hw_common **common) +{ + return 0; +} + +static int led_close(struct hw_common *common) +{ + return 0; +} + +HARDWARE_MODULE_STRUCTURE = { + .magic = HARDWARE_INFO_TAG, + .hal_version = HARDWARE_INFO_VERSION, + .device_version = LED_HARDWARE_DEVICE_VERSION, + .id = LED_HARDWARE_DEVICE_ID, + .name = "Default LED", + .author = "Jiyoung Yun <jy910.yun@samsung.com>", + .open = led_open, + .close = led_close, +}; diff --git a/hw/shared.c b/hw/shared.c new file mode 100644 index 0000000..b6401c1 --- /dev/null +++ b/hw/shared.c @@ -0,0 +1,129 @@ +/* + * device-node + * + * Copyright (c) 2015 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 <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +#define BUF_MAX 255 + +static int sys_read_buf(char *file, char *buf, int len) +{ + int fd, r; + + if (!file || !buf || len < 0) + return -EINVAL; + + fd = open(file, O_RDONLY); + if (fd == -1) + return -ENOENT; + + r = read(fd, buf, len); + close(fd); + if ((r >= 0) && (r < len)) + buf[r] = '\0'; + else + return -EIO; + + return 0; +} + +static int sys_write_buf(char *file, char *buf) +{ + int fd, r; + + if (!file || !buf) + return -EINVAL; + + fd = open(file, O_WRONLY); + if (fd == -1) + return -EPERM; + + r = write(fd, buf, strlen(buf)); + close(fd); + if (r < 0) + return -EIO; + + return 0; +} + +int sys_get_int(char *fname, int *val) +{ + char buf[BUF_MAX]; + int r; + + if (!fname || !val) + return -EINVAL; + + r = sys_read_buf(fname, buf, sizeof(buf)); + if (r < 0) + return r; + + *val = atoi(buf); + return 0; +} + +int sys_get_str(char *fname, char *str, int len) +{ + int r; + + if (!fname || !str || len < 0) + return -EINVAL; + + r = sys_read_buf(fname, str, len); + if (r < 0) + return r; + + return 0; +} + +int sys_set_int(char *fname, int val) +{ + char buf[BUF_MAX]; + int r; + + if (!fname) + return -EINVAL; + + snprintf(buf, sizeof(buf), "%d", val); + r = sys_write_buf(fname, buf); + if (r < 0) + return r; + + return 0; +} + +int sys_set_str(char *fname, char *val) +{ + int r; + + if (!fname || !val) + return -EINVAL; + + r = sys_write_buf(fname, val); + if (r < 0) + return r; + + return 0; +} diff --git a/hw/shared.h b/hw/shared.h new file mode 100644 index 0000000..da51ca4 --- /dev/null +++ b/hw/shared.h @@ -0,0 +1,43 @@ +/* + * libdevice-node + * + * Copyright (c) 2015 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. + */ + + +#ifndef __HW_DEFAULT_SHARED_H__ +#define __HW_DEFAULT_SHARED_H__ + +#define FEATURE_HARDWARE_DLOG +#ifdef FEATURE_HARDWARE_DLOG +#define LOG_TAG "HARDWARE" +#include <dlog.h> +#define _I(fmt, args...) SLOGI(fmt, ##args) +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) +#else +#define _I(x, ...) do { } while (0) +#define _D(x, ...) do { } while (0) +#define _E(x, ...) do { } while (0) +#endif + +#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) + +int sys_get_int(char *fname, int *val); +int sys_get_str(char *fname, char *str, int len); +int sys_set_int(char *fname, int val); +int sys_set_str(char *fname, char *val); + +#endif diff --git a/packaging/device-manager-plugin-sc7727.spec b/packaging/device-manager-plugin-sc7727.spec deleted file mode 100644 index 15a5abc..0000000 --- a/packaging/device-manager-plugin-sc7727.spec +++ /dev/null @@ -1,53 +0,0 @@ -#sbs-git:slp/pkgs/d/device-manager-plugin-sc7727 device-manager-plugin-sc7727 0.0.1 5bf2e95e0bb15c43ff928f7375e1978b0accb0f8 -Name: device-manager-plugin-sc7730 -Summary: Device manager plugin sc7730 -Version: 0.0.03 -Release: 0 -Group: TO_BE/FILLED_IN -License: Apache-2.0 -Source0: %{name}-%{version}.tar.gz -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig -BuildRequires: cmake -BuildRequires: pkgconfig(devman_plugin) -BuildRequires: pkgconfig(dlog) - -%if "%{tizen_target_name}" != "Z300H" -ExcludeArch: %{arm} -%endif - -%description -Device manager plugin sc7730 - - -%prep -%setup -q - -%build -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} - -make %{?jobs:-j%jobs} - -%install -rm -rf %{buildroot} -mkdir -p %{buildroot}/usr/share/license -cp -a apache-2.0.txt %{buildroot}/usr/share/license/%{name} -mkdir -p %{buildroot}/usr/lib/udev/rules.d -cp -a 61-tizen-video-device.rules %{buildroot}/usr/lib/udev/rules.d - -%make_install - -%post -/sbin/ldconfig -mkdir -p /lib/firmware/modem - -%postun -/sbin/ldconfig - -%files -%manifest device-manager-plugin-sc7727.manifest -/usr/share/license/device-manager-plugin-sc7730 -/usr/lib/libslp_devman_plugin.so -/usr/lib/udev/rules.d/61-tizen-video-device.rules -/opt/etc/dump.d/module.d/ -%exclude /usr/bin/sys_oal_test diff --git a/device-manager-plugin-sc7727.manifest b/packaging/device-manager-plugin-sc7730.manifest index af9b883..97e8c31 100644 --- a/device-manager-plugin-sc7727.manifest +++ b/packaging/device-manager-plugin-sc7730.manifest @@ -1,5 +1,5 @@ -<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
+<manifest> + <request> + <domain name="_"/> + </request> +</manifest> diff --git a/packaging/device-manager-plugin-sc7730.spec b/packaging/device-manager-plugin-sc7730.spec new file mode 100644 index 0000000..953da39 --- /dev/null +++ b/packaging/device-manager-plugin-sc7730.spec @@ -0,0 +1,40 @@ +Name: device-manager-plugin-sc7730 +Summary: Device manager plugin sc7730 +Version: 0.0.1 +Release: 0 +Group: System/Hardware Adaptation +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(hwcommon) + +%description +Device manager plugin sc7730 + + +%prep +%setup -q +cp %{SOURCE1} . + +%build +%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} + +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%{_libdir}/hw/*.so +%manifest %{name}.manifest +%license LICENSE |