diff options
author | jy910.yun <jy910.yun@samsung.com> | 2013-02-26 16:06:47 +0900 |
---|---|---|
committer | jy910.yun <jy910.yun@samsung.com> | 2013-02-26 16:07:44 +0900 |
commit | f440d7952681e9bf4540f795cc709c9010c7024d (patch) | |
tree | 216eda99728aba84d4820fcfb194e054a6dd32dd /devices | |
parent | cdefbf11af164d3f3a7fbfebb7dfa8ff76e2b436 (diff) | |
download | libdevice-node-f440d7952681e9bf4540f795cc709c9010c7024d.tar.gz libdevice-node-f440d7952681e9bf4540f795cc709c9010c7024d.tar.bz2 libdevice-node-f440d7952681e9bf4540f795cc709c9010c7024d.zip |
Create new Library to control OAL APIssubmit/trunk/20130226.073610
separate some code about OAL from devman
This module is a Library to control OAL APIs only used by system f/w
Change-Id: I8ea27904950f402922d4df315c02881c70fb65ac
Diffstat (limited to 'devices')
-rw-r--r-- | devices/CMakeLists.txt | 10 | ||||
-rw-r--r-- | devices/cpu.c | 65 | ||||
-rw-r--r-- | devices/display.c | 143 | ||||
-rw-r--r-- | devices/extcon.c | 96 | ||||
-rw-r--r-- | devices/led.c | 59 | ||||
-rw-r--r-- | devices/memory.c | 61 | ||||
-rw-r--r-- | devices/power.c | 73 | ||||
-rw-r--r-- | devices/process.c | 59 | ||||
-rw-r--r-- | devices/vibrator.c | 63 |
9 files changed, 629 insertions, 0 deletions
diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt new file mode 100644 index 0000000..967849e --- /dev/null +++ b/devices/CMakeLists.txt @@ -0,0 +1,10 @@ +SET(TARGET_SRCS + devices/cpu.c + devices/display.c + devices/extcon.c + devices/led.c + devices/memory.c + devices/power.c + devices/process.c + devices/vibrator.c +) diff --git a/devices/cpu.c b/devices/cpu.c new file mode 100644 index 0000000..fb710d1 --- /dev/null +++ b/devices/cpu.c @@ -0,0 +1,65 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int cpu_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_CPU_CPUINFO_MAX_FREQ: + return PLUGIN_GET(cpufreq_cpuinfo_max_freq)(val); + case PROP_CPU_CPUINFO_MIN_FREQ: + return PLUGIN_GET(cpufreq_cpuinfo_min_freq)(val); + case PROP_CPU_SCALING_MAX_FREQ: + return PLUGIN_GET(cpufreq_scaling_max_freq)(val); + case PROP_CPU_SCALING_MIN_FREQ: + return PLUGIN_GET(cpufreq_scaling_min_freq)(val); + } + + return -1; +} + +static int cpu_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_CPU_SCALING_MAX_FREQ: + return PLUGIN_SET(cpufreq_scaling_max_freq)(val); + case PROP_CPU_SCALING_MIN_FREQ: + return PLUGIN_SET(cpufreq_scaling_min_freq)(val); + } + + return -1; +} + +static const struct device cpu = { + .name = "cpu", + .set_prop = cpu_set_prop, + .get_prop = cpu_get_prop, + .type = DEVICE_TYPE_CPU, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(cpu.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(cpu.type)); +} diff --git a/devices/display.c b/devices/display.c new file mode 100644 index 0000000..f4355ff --- /dev/null +++ b/devices/display.c @@ -0,0 +1,143 @@ +/* + * device-node + * Copyright (c) 2012 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 <vconf.h> +#include "device-internal.h" + +#define PROPERTY_MASK 0x0F +#define PROPERTY_PROP(val) ((val) & PROPERTY_MASK) +#define PROPERTY_INDEX(val) ((val) >> 4) + +static int display_get_prop(int __prop, int *val) +{ + int prop = PROPERTY_PROP(__prop); + int index = PROPERTY_INDEX(__prop); + int ps_stat; + int ps_disp_stat; + int disp_cnt; + int r; + + r = PLUGIN_GET(display_count)(&disp_cnt); + if (r < 0) { + DEVERR("Get display count failed"); + return -1; + } + + if (index >= disp_cnt) { + DEVERR("Invalid Argument: index(%d) > max(%d)", index, disp_cnt); + return -1; + } + + switch (prop) { + case PROP_DISPLAY_DISPLAY_COUNT: + *val = disp_cnt; + return 0; + case PROP_DISPLAY_BRIGHTNESS: + /* check power saving */ + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &ps_stat); + if (ps_stat == 1) + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &ps_disp_stat); + if (ps_disp_stat != 1) + ps_disp_stat = 0; + return PLUGIN_GET(backlight_brightness)(index, val, ps_disp_stat); + case PROP_DISPLAY_ACL_CONTROL: + return PLUGIN_GET(backlight_acl_control)(index, val); + case PROP_DISPLAY_ONOFF: + return PLUGIN_GET(lcd_power)(index, val); + case PROP_DISPLAY_BRIGHTNESS_BY_LUX: + return PLUGIN_GET(backlight_brightness_by_lux)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_MODE: + return PLUGIN_GET(image_enhance_mode)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_SCENARIO: + return PLUGIN_GET(image_enhance_scenario)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_TONE: + return PLUGIN_GET(image_enhance_tone)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_OUTDOOR: + return PLUGIN_GET(image_enhance_outdoor)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_INFO: + return PLUGIN_SYS(image_enhance_info)(val); + } + + return -1; +} + +static int display_set_prop(int __prop, int val) +{ + int prop = PROPERTY_PROP(__prop); + int index = PROPERTY_INDEX(__prop); + int ps_stat; + int ps_disp_stat; + int disp_cnt; + int r; + + r = PLUGIN_GET(display_count)(&disp_cnt); + if (r < 0) { + DEVERR("Get display count failed"); + return -1; + } + + if (index >= disp_cnt) { + DEVERR("Invalid Argument: index(%d) > max(%d)", index, disp_cnt); + return -1; + } + + switch (prop) { + case PROP_DISPLAY_BRIGHTNESS: + /* check power saving */ + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &ps_stat); + if (ps_stat == 1) + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &ps_disp_stat); + if (ps_disp_stat != 1) + ps_disp_stat = 0; + return PLUGIN_SET(backlight_brightness)(index, val, ps_disp_stat); + case PROP_DISPLAY_ACL_CONTROL: + return PLUGIN_SET(backlight_acl_control)(index, val); + case PROP_DISPLAY_ONOFF: + return PLUGIN_SET(lcd_power)(index, val); + case PROP_DISPLAY_FRAME_RATE: + return PLUGIN_SET(display_frame_rate)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_MODE: + return PLUGIN_SET(image_enhance_mode)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_SCENARIO: + return PLUGIN_SET(image_enhance_scenario)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_TONE: + return PLUGIN_SET(image_enhance_tone)(val); + case PROP_DISPLAY_IMAGE_ENHANCE_OUTDOOR: + return PLUGIN_SET(image_enhance_outdoor)(val); + } + + return -1; +} + +static const struct device display = { + .name = "display", + .set_prop = display_set_prop, + .get_prop = display_get_prop, + .type = DEVICE_TYPE_DISPLAY, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(display.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(display.type)); +} diff --git a/devices/extcon.c b/devices/extcon.c new file mode 100644 index 0000000..42a41d1 --- /dev/null +++ b/devices/extcon.c @@ -0,0 +1,96 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int extcon_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_EXTCON_TA_ONLINE: + return PLUGIN_GET(jack_charger_online)(val); + case PROP_EXTCON_EARJACK_ONLINE: + return PLUGIN_GET(jack_earjack_online)(val); + case PROP_EXTCON_EARKEY_ONLINE: + return PLUGIN_GET(jack_earkey_online)(val); + case PROP_EXTCON_HDMI_ONLINE: + return PLUGIN_GET(jack_hdmi_online)(val); + case PROP_EXTCON_USB_ONLINE: + return PLUGIN_GET(jack_usb_online)(val); + case PROP_EXTCON_CRADLE_ONLINE: + return PLUGIN_GET(jack_cradle_online)(val); + case PROP_EXTCON_TVOUT_ONLINE: + return PLUGIN_GET(jack_tvout_online)(val); + case PROP_EXTCON_KEYBOARD_ONLINE: + return PLUGIN_GET(jack_keyboard_online)(val); + case PROP_EXTCON_HDMI_SUPPORT: + return PLUGIN_GET(hdmi_support)(val); + case PROP_EXTCON_UART_PATH: + return PLUGIN_GET(uart_path)(val); + case PROP_EXTCON_USB_PATH: + return PLUGIN_GET(usb_path)(val); + } + + return -1; +} + +static int extcon_set_prop(int prop, int val) +{ + int r; + + switch (prop) { + case PROP_EXTCON_UART_PATH: + r = PLUGIN_SET(uart_path)(val); + if (r == 0) { + if (val == PATH_CP) + system("/usr/bin/save_blenv uartpath CP"); + else + system("/usr/bin/save_blenv uartpath AP"); + } + return r; + case PROP_EXTCON_USB_PATH: + r = PLUGIN_SET(usb_path)(val); + if (r == 0) { + if (val == PATH_CP) + system("/usr/bin/save_blenv usbpath CP"); + else + system("/usr/bin/save_blenv usbpath AP"); + } + return r; + } + + return -1; +} + + +static const struct device extcon = { + .name = "extcon", + .set_prop = extcon_set_prop, + .get_prop = extcon_get_prop, + .type = DEVICE_TYPE_EXTCON, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(extcon.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(extcon.type)); +} diff --git a/devices/led.c b/devices/led.c new file mode 100644 index 0000000..925b306 --- /dev/null +++ b/devices/led.c @@ -0,0 +1,59 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int led_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_LED_MAX_BRIGHTNESS: + return PLUGIN_GET(leds_torch_max_brightness)(val); + case PROP_LED_BRIGHTNESS: + return PLUGIN_GET(leds_torch_brightness)(val); + } + + return -1; +} + +static int led_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_LED_BRIGHTNESS: + return PLUGIN_SET(leds_torch_brightness)(val); + } + + return -1; +} + +static const struct device led = { + .name = "led", + .set_prop = led_set_prop, + .get_prop = led_get_prop, + .type = DEVICE_TYPE_LED, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(led.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(led.type)); +} diff --git a/devices/memory.c b/devices/memory.c new file mode 100644 index 0000000..eb60465 --- /dev/null +++ b/devices/memory.c @@ -0,0 +1,61 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int memory_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_MEMORY_NODE: + return PLUGIN_GET(memnotify_node)((char*)val); + case PROP_MEMORY_VICTIM_TASK: + return PLUGIN_GET(memnotify_victim_task)(val); + } + + return -1; +} + +static int memory_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_MEMORY_THRESHOLD_LV1: + return PLUGIN_SET(memnotify_threshold_lv1)(val); + case PROP_MEMORY_THRESHOLD_LV2: + return PLUGIN_SET(memnotify_threshold_lv2)(val); + } + + return -1; +} + +static const struct device memory = { + .name = "memory", + .set_prop = memory_set_prop, + .get_prop = memory_get_prop, + .type = DEVICE_TYPE_MEMORY, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(memory.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(memory.type)); +} diff --git a/devices/power.c b/devices/power.c new file mode 100644 index 0000000..c57943a --- /dev/null +++ b/devices/power.c @@ -0,0 +1,73 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int power_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_POWER_CAPACITY: + return PLUGIN_GET(battery_capacity)(val); + case PROP_POWER_CAPACITY_RAW: + return PLUGIN_GET(battery_capacity_raw)(val); + case PROP_POWER_CHARGE_FULL: + return PLUGIN_GET(battery_charge_full)(val); + case PROP_POWER_CHARGE_NOW: + return PLUGIN_GET(battery_charge_now)(val); + case PROP_POWER_WAKEUP_COUNT: + return PLUGIN_GET(power_wakeup_count)(val); + case PROP_POWER_PRESENT: + return PLUGIN_GET(battery_present)(val); + case PROP_POWER_HEALTH: + return PLUGIN_GET(battery_health)(val); + case PROP_POWER_INSUSPEND_CHARGING_SUPPORT: + return PLUGIN_GET(battery_support_insuspend_charging)(val); + } + + return -1; +} + +static int power_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_POWER_STATE: + return PLUGIN_SET(power_state)(val); + case PROP_POWER_WAKEUP_COUNT: + return PLUGIN_SET(power_wakeup_count)(val); + } + + return -1; +} + +static const struct device power = { + .name = "power", + .set_prop = power_set_prop, + .get_prop = power_get_prop, + .type = DEVICE_TYPE_POWER, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(power.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(power.type)); +} diff --git a/devices/process.c b/devices/process.c new file mode 100644 index 0000000..94ee4c9 --- /dev/null +++ b/devices/process.c @@ -0,0 +1,59 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int process_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_PROCESS_NODE: + return PLUGIN_GET(process_monitor_node)((char*)val); + } + + return -1; +} + +static int process_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_PROCESS_MP_PNP: + return PLUGIN_SET(process_monitor_mp_pnp)(val); + case PROP_PROCESS_MP_VIP: + return PLUGIN_SET(process_monitor_mp_vip)(val); + } + + return -1; +} + +static const struct device process = { + .name = "process", + .set_prop = process_set_prop, + .get_prop = process_get_prop, + .type = DEVICE_TYPE_PROCESS, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(process.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(process.type)); +} diff --git a/devices/vibrator.c b/devices/vibrator.c new file mode 100644 index 0000000..80d8e3e --- /dev/null +++ b/devices/vibrator.c @@ -0,0 +1,63 @@ +/* + * device-node + * Copyright (c) 2012 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 "device-internal.h" + +static int vibrator_get_prop(int prop, int *val) +{ + switch (prop) { + case PROP_VIBRATOR_LEVEL: + return PLUGIN_GET(haptic_vibetones_level)(val); + case PROP_VIBRATOR_LEVEL_MAX: + return PLUGIN_GET(haptic_vibetones_level_max)(val); + } + + return -1; +} + +static int vibrator_set_prop(int prop, int val) +{ + switch (prop) { + case PROP_VIBRATOR_ENABLE: + return PLUGIN_SET(haptic_vibetones_enable)(val); + case PROP_VIBRATOR_LEVEL: + return PLUGIN_SET(haptic_vibetones_level)(val); + case PROP_VIBRATOR_ONESHOT: + return PLUGIN_SET(haptic_vibetones_oneshot)(val); + } + + return -1; +} + +static const struct device vibrator = { + .name = "vibrator", + .set_prop = vibrator_set_prop, + .get_prop = vibrator_get_prop, + .type = DEVICE_TYPE_VIBRATOR, +}; + +static void __CONSTRUCTOR__ module_init(void) +{ + add_device(&(vibrator.type)); +} + +static void __DESTRUCTOR__ module_fini(void) +{ + remove_device(&(vibrator.type)); +} |