SET(CMAKE_VERBOSE_MAKEFILE ON)
-SET(PKG_MODULES
- dlog)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
-
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(DEST_DIR ${LIB_INSTALL_DIR}/pass)
-ADD_SUBDIRECTORY(src/cpu)
-ADD_SUBDIRECTORY(src/bus)
-ADD_SUBDIRECTORY(src/gpu)
-
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass.conf DESTINATION /etc/pass)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-resource0.conf DESTINATION /etc/pass)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-resource1.conf DESTINATION /etc/pass)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(pass-hal-devel)
%description
PASS hal for TM2
%files
%manifest %{name}.manifest
-%{_libdir}/pass/*.so
/usr/lib/tmpfiles.d/pass-hal.conf
%config %{_sysconfdir}/pass/pass.conf
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bus C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
- ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
+++ /dev/null
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 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 <errno.h>
-#include <limits.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../shared/sysfs.h"
-
-/* TODO: Version! */
-#define HAL_VERSION MAKE_2B_CODE_4(VER_MAJOR,VER_MINOR,VER_REVISION,VER_RELEASE)
-#define DEV_VERSION_BUS MAKE_2B_CODE_2(1,0)
-
-#define DEVFREQ_BUS_PATH_PREFIX "/sys/class/devfreq/"
-#define DEVFREQ_BUS_CURR_GOVERNOR_PATH_SUFFIX "/governor"
-#define DEVFREQ_BUS_CURR_FREQ_PATH_SUFFIX "/cur_freq"
-#define DEVFREQ_BUS_MIN_FREQ_PATH_SUFFIX "/min_freq"
-#define DEVFREQ_BUS_MAX_FREQ_PATH_SUFFIX "/max_freq"
-
-static int tm2_dvfs_get_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_read_str(path, governor, BUFF_MAX);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_set_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_write_str(path, governor);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_curr_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_CURR_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_get_min_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_min_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_max_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_max_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_BUS_PATH_PREFIX,
- res_name,
- DEVFREQ_BUS_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
- return 0;
-}
-
-
-static struct pass_resource_dvfs_ops tm2_bus_dvfs_ops = {
- .get_curr_governor = tm2_dvfs_get_curr_governor,
- .set_curr_governor = tm2_dvfs_set_curr_governor,
- .get_avail_governor = NULL,
- .get_curr_freq = tm2_dvfs_get_curr_freq,
- .get_min_freq = tm2_dvfs_get_min_freq,
- .set_min_freq = tm2_dvfs_set_min_freq,
- .get_max_freq = tm2_dvfs_get_max_freq,
- .set_max_freq = tm2_dvfs_set_max_freq,
- .get_up_threshold = NULL,
- .set_up_threshold = NULL,
- .get_load_table = NULL,
-};
-
-static int tm2_bus_open(char *res_name, struct pass_resource_info *info,
- struct pass_resource_common **common)
-{
- struct pass_resource_bus *bus_res;
-
- if (!info)
- return -EINVAL;
-
- /* TODO: Possibility of a memory leak */
- bus_res = calloc(1, sizeof(struct pass_resource_bus));
- if (!bus_res)
- return -ENOMEM;
-
- bus_res->common.info = info;
- bus_res->dvfs = tm2_bus_dvfs_ops;
-
- *common = (struct pass_resource_common *) bus_res;
-
- return 0;
-}
-
-static int tm2_bus_close(char *res_name, struct pass_resource_common *common)
-{
- if (!common)
- return -EINVAL;
-
- free(common);
-
- return 0;
-}
-
-HAL_MODULE_STRUCTURE = {
- .magic = HAL_INFO_TAG,
- .hal_version = HAL_VERSION,
- .device_version = DEV_VERSION_BUS,
- .id = PASS_RESOURCE_BUS_ID,
- .name = PASS_RESOURCE_BUS_NAME,
- .open = tm2_bus_open,
- .close = tm2_bus_close,
-};
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(cpu C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
- ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
+++ /dev/null
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 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 <errno.h>
-#include <limits.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../shared/sysfs.h"
-
-/* TODO: Version! */
-#define HAL_VERSION MAKE_2B_CODE_4(VER_MAJOR,VER_MINOR,VER_REVISION,VER_RELEASE)
-#define DEV_VERSION_CPU MAKE_2B_CODE_2(1,0)
-
-#define CPUFREQ_PATH_PREFIX "/sys/devices/system/cpu/"
-#define CPUFREQ_CURR_GOVERNOR_PATH_SUFFIX "/cpufreq/scaling_governor"
-#define CPUFREQ_AVAIL_GOVERNOR_PATH_SUFFIX "/cpufreq/scaling_available_governors"
-
-/*
- * The cpuinfo_cur_freq indicates the actual operating CPU freqeuncy
- * and scaling_cur_freq is the CPU frequency set by the CPUFREQ policy.
- */
-#define CPUFREQ_CURR_FREQ_PATH_SUFFIX "/cpufreq/cpuinfo_cur_freq"
-#define CPUFREQ_MIN_FREQ_PATH_SUFFIX "/cpufreq/scaling_min_freq"
-#define CPUFREQ_MAX_FREQ_PATH_SUFFIX "/cpufreq/scaling_max_freq"
-#define CPUFREQ_UP_THRESHOLD_PATH_SUFFIX "/cpufreq/ondemand/up_threshold"
-
-#define LOADTABLE_PATH_PREFIX "/sys/kernel/debug/cpufreq/"
-#define LOADTABLE_PATH_SUFFIX "/load_table"
-
-#define CPU_ONLINE_PATH_PREFIX "/sys/devices/system/cpu/cpu"
-#define CPU_ONLINE_PATH_SUFFIX "/online"
-#define CPU_ONLINE_STATE_ON 1
-#define CPU_ONLINE_STATE_OFF 0
-
-#define TMU_PATH_PREFIX "/sys/class/thermal/"
-#define TMU_TEMP_PATH_SUFFIX "/temp"
-#define TMU_POLICY_PATH_SUFFIX "/policy"
-
-static int tm2_dvfs_get_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_read_str(path, governor, BUFF_MAX);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_set_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_write_str(path, governor);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_curr_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_CURR_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_get_min_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_min_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_max_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_max_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
- return 0;
-}
-
-static int tm2_dvfs_get_up_threshold(char *res_name)
-{
- char path[PATH_MAX];
- int val, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_UP_THRESHOLD_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &val);
- if (ret < 0)
- return ret;
-
- return val;
-}
-
-static int tm2_dvfs_set_up_threshold(char *res_name, int up_threshold)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (up_threshold < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- CPUFREQ_PATH_PREFIX,
- res_name,
- CPUFREQ_UP_THRESHOLD_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, up_threshold);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_load_table(char *res_name, void *pass_cpu_load_table)
-{
- return 0;
-}
-
-static struct pass_resource_dvfs_ops tm2_cpu_dvfs_ops = {
- .get_curr_governor = tm2_dvfs_get_curr_governor,
- .set_curr_governor = tm2_dvfs_set_curr_governor,
- .get_avail_governor = NULL,
- .get_curr_freq = tm2_dvfs_get_curr_freq,
- .get_min_freq = tm2_dvfs_get_min_freq,
- .set_min_freq = tm2_dvfs_set_min_freq,
- .get_max_freq = tm2_dvfs_get_max_freq,
- .set_max_freq = tm2_dvfs_set_max_freq,
- .get_up_threshold = tm2_dvfs_get_up_threshold,
- .set_up_threshold = tm2_dvfs_set_up_threshold,
- .get_load_table = tm2_dvfs_get_load_table,
-};
-
-static int tm2_hotplug_get_online_state(char *res_name, int cpu)
-{
- char path[PATH_MAX];
- int ret, online;
-
- if ((!res_name))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%d%s",
- CPU_ONLINE_PATH_PREFIX,
- cpu,
- CPU_ONLINE_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &online);
- if (ret < 0)
- return ret;
-
- return online;
-}
-
-static int tm2_hotplug_set_online_state(char *res_name, int cpu, int on)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name))
- return -EINVAL;
- if ((on != CPU_ONLINE_STATE_ON) && (on != CPU_ONLINE_STATE_OFF))
- return -EINVAL;
-
- /*
- * NOTE: Exynos SoC series cannot turn off the CPU0
- * because of h/w design. To prevent the critical problem,
- * if someone try to turn off the CPU0, just return without any
- * opertaion.
- */
- if (on == 0 && cpu == 0) {
- _E("cannot turn off the CPU0");
- return 0;
- }
-
- snprintf(path, PATH_MAX, "%s%d%s",
- CPU_ONLINE_PATH_PREFIX,
- cpu,
- CPU_ONLINE_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, on);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static struct pass_resource_hotplug_ops tm2_cpu_hotplus_ops = {
- .get_online_state = tm2_hotplug_get_online_state,
- .set_online_state = tm2_hotplug_set_online_state,
- .get_online_min_num = NULL,
- .set_online_min_num = NULL,
- .get_online_max_num = NULL,
- .set_online_max_num = NULL,
-};
-
-static int tm2_tmu_get_temp(char *res_thermal_name)
-{
- char path[PATH_MAX];
- int temp, ret;
-
- if (!res_thermal_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- TMU_PATH_PREFIX,
- res_thermal_name,
- TMU_TEMP_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &temp);
- if (ret < 0)
- return ret;
-
- return temp;
-}
-
-static int tm2_tmu_get_policy(char *res_thermal_name, char *policy)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_thermal_name) || (!policy))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- TMU_PATH_PREFIX,
- res_thermal_name,
- TMU_POLICY_PATH_SUFFIX);
-
- ret = sysfs_read_str(path, policy, BUFF_MAX);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static struct pass_resource_tmu_ops tm2_cpu_tmu_ops = {
- .get_temp = tm2_tmu_get_temp,
- .get_policy = tm2_tmu_get_policy,
-};
-
-static int tm2_cpu_open(char *res_name, struct pass_resource_info *info,
- struct pass_resource_common **common)
-{
- struct pass_resource_cpu *cpu_res;
-
- if (!info)
- return -EINVAL;
-
- /* TODO: Possibility of a memory leak */
- cpu_res = calloc(1, sizeof(struct pass_resource_cpu));
- if (!cpu_res)
- return -ENOMEM;
-
- cpu_res->common.info = info;
- cpu_res->dvfs = tm2_cpu_dvfs_ops;
- cpu_res->hotplug = tm2_cpu_hotplus_ops;
- cpu_res->tmu = tm2_cpu_tmu_ops;
-
- *common = (struct pass_resource_common *) cpu_res;
-
- return 0;
-}
-
-static int tm2_cpu_close(char *res_name, struct pass_resource_common *common)
-{
- if (!common)
- return -EINVAL;
-
- free(common);
-
- return 0;
-}
-
-HAL_MODULE_STRUCTURE = {
- .magic = HAL_INFO_TAG,
- .hal_version = HAL_VERSION,
- .device_version = DEV_VERSION_CPU,
- .id = PASS_RESOURCE_CPU_ID,
- .name = PASS_RESOURCE_CPU_NAME,
- .open = tm2_cpu_open,
- .close = tm2_cpu_close,
-};
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(gpu C)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
-
-#HAL version
-string(REPLACE "." ";" HAL_VERSION_LIST ${HAL_VERSION})
-list(GET HAL_VERSION_LIST 0 HAL_VERSION_MAJOR)
-list(GET HAL_VERSION_LIST 1 HAL_VERSION_MINOR)
-list(GET HAL_VERSION_LIST 2 HAL_VERSION_REVISION)
-list(GET HAL_VERSION_LIST 3 HAL_VERSION_RELEASE)
-add_definitions(-DVER_MAJOR=${HAL_VERSION_MAJOR} -DVER_MINOR=${HAL_VERSION_MINOR})
-add_definitions(-DVER_REVISION=${HAL_VERSION_REVISION} -DVER_RELEASE=${HAL_VERSION_RELEASE})
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(SRCS ${PROJECT_NAME}.c
- ../shared/sysfs.c)
-
-ADD_LIBRARY(${PROJECT_NAME} MODULE ${SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${DEST_DIR} COMPONENT RuntimeLibraries)
+++ /dev/null
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 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 <errno.h>
-#include <limits.h>
-#include <pass/hal.h>
-#include <pass/hal-log.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../shared/sysfs.h"
-
-/* TODO: Version! */
-#define HAL_VERSION MAKE_2B_CODE_4(VER_MAJOR,VER_MINOR,VER_REVISION,VER_RELEASE)
-#define DEV_VERSION_GPU MAKE_2B_CODE_2(1,0)
-
-#define DEVFREQ_GPU_PATH_PREFIX "/sys/class/devfreq/"
-#define DEVFREQ_GPU_CURR_GOVERNOR_PATH_SUFFIX "/governor"
-#define DEVFREQ_GPU_CURR_FREQ_PATH_SUFFIX "/cur_freq"
-#define DEVFREQ_GPU_MIN_FREQ_PATH_SUFFIX "/min_freq"
-#define DEVFREQ_GPU_MAX_FREQ_PATH_SUFFIX "/max_freq"
-
-#define TMU_PATH_PREFIX "/sys/class/thermal/"
-#define TMU_TEMP_PATH_SUFFIX "/temp"
-#define TMU_POLICY_PATH_SUFFIX "/policy"
-
-static int tm2_dvfs_get_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_read_str(path, governor, BUFF_MAX);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_set_curr_governor(char *res_name, char *governor)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (!governor))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_CURR_GOVERNOR_PATH_SUFFIX);
-
- ret = sysfs_write_str(path, governor);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_curr_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_CURR_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_get_min_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_min_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_MIN_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static int tm2_dvfs_get_max_freq(char *res_name)
-{
- char path[PATH_MAX];
- int freq, ret;
-
- if (!res_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &freq);
- if (ret < 0)
- return ret;
-
- return freq;
-}
-
-static int tm2_dvfs_set_max_freq(char *res_name, int freq)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_name) || (freq < 0))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- DEVFREQ_GPU_PATH_PREFIX,
- res_name,
- DEVFREQ_GPU_MAX_FREQ_PATH_SUFFIX);
-
- ret = sysfs_write_int(path, freq);
- if (ret < 0)
- return ret;
- return 0;
-}
-
-
-static struct pass_resource_dvfs_ops tm2_gpu_dvfs_ops = {
- .get_curr_governor = tm2_dvfs_get_curr_governor,
- .set_curr_governor = tm2_dvfs_set_curr_governor,
- .get_avail_governor = NULL,
- .get_curr_freq = tm2_dvfs_get_curr_freq,
- .get_min_freq = tm2_dvfs_get_min_freq,
- .set_min_freq = tm2_dvfs_set_min_freq,
- .get_max_freq = tm2_dvfs_get_max_freq,
- .set_max_freq = tm2_dvfs_set_max_freq,
- .get_up_threshold = NULL,
- .set_up_threshold = NULL,
- .get_load_table = NULL,
-};
-
-static int tm2_tmu_get_temp(char *res_thermal_name)
-{
- char path[PATH_MAX];
- int temp;
- int ret;
-
- if (!res_thermal_name)
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- TMU_PATH_PREFIX,
- res_thermal_name,
- TMU_TEMP_PATH_SUFFIX);
-
- ret = sysfs_read_int(path, &temp);
- if (ret < 0)
- return ret;
-
- return temp;
-}
-
-static int tm2_tmu_get_policy(char *res_thermal_name, char *policy)
-{
- char path[PATH_MAX];
- int ret;
-
- if ((!res_thermal_name) || (!policy))
- return -EINVAL;
-
- snprintf(path, PATH_MAX, "%s%s%s",
- TMU_PATH_PREFIX,
- res_thermal_name,
- TMU_POLICY_PATH_SUFFIX);
-
- ret = sysfs_read_str(path, policy, BUFF_MAX);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-static struct pass_resource_tmu_ops tm2_gpu_tmu_ops = {
- .get_temp = tm2_tmu_get_temp,
- .get_policy = tm2_tmu_get_policy,
-};
-
-static int tm2_gpu_open(char *res_name, struct pass_resource_info *info,
- struct pass_resource_common **common)
-{
- struct pass_resource_gpu *gpu_res;
-
- if (!info)
- return -EINVAL;
-
- /* TODO: Possibility of a memory leak */
- gpu_res = calloc(1, sizeof(struct pass_resource_gpu));
- if (!gpu_res)
- return -ENOMEM;
-
- gpu_res->common.info = info;
- gpu_res->dvfs = tm2_gpu_dvfs_ops;
- gpu_res->tmu = tm2_gpu_tmu_ops;
-
- *common = (struct pass_resource_common *) gpu_res;
-
- return 0;
-}
-
-static int tm2_gpu_close(char *res_name, struct pass_resource_common *common)
-{
- if (!common)
- return -EINVAL;
-
- free(common);
-
- return 0;
-}
-
-HAL_MODULE_STRUCTURE = {
- .magic = HAL_INFO_TAG,
- .hal_version = HAL_VERSION,
- .device_version = DEV_VERSION_GPU,
- .id = PASS_RESOURCE_GPU_ID,
- .name = PASS_RESOURCE_GPU_NAME,
- .open = tm2_gpu_open,
- .close = tm2_gpu_close,
-};
+++ /dev/null
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2017 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 <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "sysfs.h"
-
-static int sysfs_read_buf(char *path, char *buf, int len)
-{
- int r, fd;
-
- if ((!path) || (!buf) || (len < 0))
- return -EINVAL;
-
- fd = open(path, O_RDONLY);
- if (fd == -1)
- return -ENOENT;
-
- r = read(fd, buf, len + 1);
- close(fd);
-
- if ((r < 0) || (r > len))
- return -EIO;
-
- buf[r] = '\0';
-
- return 0;
-}
-
-static int sysfs_write_buf(char *path, char *buf)
-{
- int w, fd;
-
- if ((!path) || (!buf))
- return -EINVAL;
-
- fd = open(path, O_WRONLY);
- if (fd == -1)
- return -ENOENT;
-
- w = write(fd, buf, strlen(buf));
- close(fd);
-
- if (w < 0)
- return -EIO;
-
- return 0;
-}
-
-int sysfs_read_int(char *path, int *val)
-{
- char buf[MAX_BUF_SIZE];
- int r;
-
- if ((!path) || (!val))
- return -EINVAL;
-
- r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
- if (r < 0)
- return r;
-
- *val = atoi(buf);
- return 0;
-}
-
-int sysfs_read_str(char *path, char *str, int len)
-{
- int r;
-
- if ((!path) || (!str) || (len <= 0))
- return -EINVAL;
-
- r = sysfs_read_buf(path, str, len);
- if (r < 0)
- return r;
-
- return 0;
-}
-
-int sysfs_write_int(char *path, int val)
-{
- char buf[MAX_BUF_SIZE];
- int w;
-
- if (!path)
- return -EINVAL;
-
- snprintf(buf, MAX_BUF_SIZE, "%d", val);
- w = sysfs_write_buf(path, buf);
- if (w < 0)
- return w;
-
- return 0;
-}
-
-int sysfs_write_str(char *path, char *str)
-{
- int w;
-
- if ((!path) || (!str))
- return -EINVAL;
-
- w = sysfs_write_buf(path, str);
- if (w < 0)
- return w;
-
- return 0;
-}
+++ /dev/null
-#define MAX_BUF_SIZE 255
-
-int sysfs_read_int(char *path, int *val);
-int sysfs_read_str(char *path, char *str, int len);
-int sysfs_write_int(char *path, int val);
-int sysfs_write_str(char *path, char *str);