summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjihye kim <jihye1128.kim@samsung.com>2013-02-28 15:10:02 +0900
committerjihye kim <jihye1128.kim@samsung.com>2013-02-28 15:10:02 +0900
commitcc5e516c638be6a48a76218e1c092f67e60f16f0 (patch)
treee18020b7a109dab2bbf63dad64de17f2237f0aa9
parentd9a22dc4dc1942e186c10b4416125179ca44e85d (diff)
downloaddevice-manager-plugin-emul-cc5e516c638be6a48a76218e1c092f67e60f16f0.tar.gz
device-manager-plugin-emul-cc5e516c638be6a48a76218e1c092f67e60f16f0.tar.bz2
device-manager-plugin-emul-cc5e516c638be6a48a76218e1c092f67e60f16f0.zip
add api (sync with exynos)
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/devman_define_node_path.h14
-rw-r--r--include/devman_plugin_intf.h21
-rw-r--r--packaging/device-manager-plugin-maru.spec3
-rw-r--r--src/device_manager_io.c13
-rw-r--r--src/device_manager_plugin_maru.c217
6 files changed, 206 insertions, 64 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d8f540..bbdd52c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,4 +30,4 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
diff --git a/include/devman_define_node_path.h b/include/devman_define_node_path.h
index 4c35275..57142d9 100644
--- a/include/devman_define_node_path.h
+++ b/include/devman_define_node_path.h
@@ -25,11 +25,18 @@
#define LCD_PATH "/sys/class/lcd/"
#define LCD_ACL_CONTROL_PATH LCD_PATH"%s/acl_control"
#define LCD_POWER_PATH LCD_PATH"%s/lcd_power"
+#define IMAGE_ENHANCE_PATH "/sys/class/extension/mdnie/%s"
+#define IMAGE_ENHANCE_PATH_INFO "/sys/class/extension/mdnie"
//#define DISPLAY_FRAME_RATE_PATH "/sys/devices/platform/maru-display/devfreq/maru-display/max_freq"
-#define UART_PATH "/sys/devices/platform/uart-select/path"
-#define USB_PATH "/sys/devices/platform/usb-switch/path"
+//#define UART_PATH "/sys/devices/platform/uart-select/path"
+//#define USB_PATH "/sys/devices/platform/usb-switch/path"
+
+#define UART_PATH "/sys/devices/virtual/sec/switch/uart_sel"
+#define USB_PATH "/sys/devices/virtual/sec/switch/usb_sel"
+#define UART_PATH_TRATS "/sys/devices/platform/uart-select/path"
+#define USB_PATH_TRATS "/sys/devices/platform/usb-select/path"
#define HAPTIC_VIBETONES_LEVEL_PATH "/sys/class/haptic/vibetones/level"
#define HAPTIC_VIBETONES_LEVEL_MAX_PATH "/sys/class/haptic/vibetones/level_max"
@@ -37,6 +44,7 @@
#define HAPTIC_VIBETONES_ONESHOT_PATH "/sys/class/haptic/vibetones/oneshot"
#define BATTERY_CAPACITY_PATH "/sys/class/power_supply/battery/capacity"
+#define BATTERY_CAPACITY_RAW_PATH "/sys/class/power_supply/battery/capacity_raw"
#define BATTERY_CHARGE_FULL_PATH "/sys/class/power_supply/battery/charge_full"
#define BATTERY_CHARGE_NOW_PATH "/sys/class/power_supply/battery/charge_now"
#define BATTERY_PRESENT_PATH "/sys/class/power_supply/battery/present"
@@ -53,6 +61,8 @@
#define LEDS_TORCH_MAX_BRIGHTNESS_PATH "/sys/class/leds/leds-torch/max_brightness"
#define LEDS_TORCH_BRIGHTNESS_PATH "/sys/class/leds/leds-torch/brightness"
+//#define LEDS_TORCH_MAX_BRIGHTNESS_PATH "/sys/class/camera/flash/max_brightness"
+//#define LEDS_TORCH_BRIGHTNESS_PATH "/sys/class/camera/flash/rear_flash"
#define POWER_STATE_PATH "/sys/power/state"
#define POWER_WAKEUP_COUNT_PATH "/sys/power/wakeup_count"
diff --git a/include/devman_plugin_intf.h b/include/devman_plugin_intf.h
index 332355e..f973719 100644
--- a/include/devman_plugin_intf.h
+++ b/include/devman_plugin_intf.h
@@ -51,17 +51,26 @@ enum {
enum {
POWER_STATE_SUSPEND = 0,
+ POWER_STATE_PRE_SUSPEND,
+ POWER_STATE_POST_RESUME,
};
+enum {
+ LUX_DECREMENT,
+ LUX_NOCHANGE,
+ LUX_INCREMENT,
+};
+
+
typedef struct {
int (*OEM_sys_get_display_count) (int *value);
- int (*OEM_sys_get_backlight_min_brightness) (int index, int *value);
+ int (*OEM_sys_get_backlight_min_brightness) (int index, int *value);
int (*OEM_sys_get_backlight_max_brightness) (int index, int *value);
int (*OEM_sys_get_backlight_brightness) (int index, int *value, int power_saving);
int (*OEM_sys_set_backlight_brightness) (int index, int value, int power_saving);
- int (*OEM_sys_set_backlight_dimming) (int index, int value);
+ int (*OEM_sys_set_backlight_dimming) (int index, int value);
int (*OEM_sys_get_backlight_acl_control) (int index, int *value);
int (*OEM_sys_set_backlight_acl_control) (int index, int value);
@@ -90,6 +99,12 @@ typedef struct {
int (*OEM_sys_get_usb_path) (int *value);
int (*OEM_sys_set_usb_path) (int value);
+ int (*OEM_sys_get_haptic_motor_level_max) (int *value);
+ int (*OEM_sys_get_haptic_motor_level) (int *value);
+ int (*OEM_sys_set_haptic_motor_level) (int value);
+ int (*OEM_sys_set_haptic_motor_enable) (int value);
+ int (*OEM_sys_set_haptic_motor_oneshot) (int value);
+
int (*OEM_sys_get_haptic_vibetones_level_max) (int *value);
int (*OEM_sys_get_haptic_vibetones_level) (int *value);
int (*OEM_sys_set_haptic_vibetones_level) (int value);
@@ -142,6 +157,8 @@ typedef struct {
int (*OEM_sys_set_cpufreq_scaling_max_freq) (int value);
int (*OEM_sys_get_cpufreq_scaling_min_freq) (int *value);
int (*OEM_sys_set_cpufreq_scaling_min_freq) (int value);
+
+ int (*OEM_sys_get_backlight_brightness_by_lux) (int lux, int status);
} OEM_sys_devman_plugin_interface;
const OEM_sys_devman_plugin_interface *OEM_sys_get_devman_plugin_interface();
diff --git a/packaging/device-manager-plugin-maru.spec b/packaging/device-manager-plugin-maru.spec
index 89453dc..a0ea737 100644
--- a/packaging/device-manager-plugin-maru.spec
+++ b/packaging/device-manager-plugin-maru.spec
@@ -1,6 +1,6 @@
Name: device-manager-plugin-maru
Summary: device-manager-plugin-maru
-Version: 0.0.13
+Version: 0.0.14
Release: 1
Group: TO_BE/FILLED_IN
License: TO_BE/FILLED_IN
@@ -9,7 +9,6 @@ Source1001: packaging/device-manager-plugin-maru.manifest
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
-BuildRequires: pkgconfig(devman_plugin)
%description
device-manager-plugin-maru.
diff --git a/src/device_manager_io.c b/src/device_manager_io.c
index a9a49dd..9c619ef 100644
--- a/src/device_manager_io.c
+++ b/src/device_manager_io.c
@@ -34,6 +34,19 @@
#define SUCCESS 0
#define FAIL 1
+int sys_check_node(char *path)
+{
+ int fd = -1;
+
+ fd = open(path, O_RDONLY);
+
+ if (fd == -1)
+ return -1;
+
+ close(fd);
+ return 0;
+}
+
int sys_get_node(char *path, char *node)
{
if (0 >= snprintf(node, strlen(path) + 1, "%s", path))
diff --git a/src/device_manager_plugin_maru.c b/src/device_manager_plugin_maru.c
index 8d72f0f..a5f8d74 100644
--- a/src/device_manager_plugin_maru.c
+++ b/src/device_manager_plugin_maru.c
@@ -101,6 +101,12 @@ enum display_type
DISP_MAX
};
+enum lux_status {
+ decrement,
+ no_change,
+ increment,
+};
+
struct display_info
{
enum display_type etype; /* FIXME:!! Main LCD or Sub LCD node */
@@ -115,6 +121,62 @@ struct display_info
int lcd_index;
struct display_info disp_info[DISP_MAX];
+int OEM_sys_get_backlight_brightness_by_lux(unsigned int lux, enum lux_status status)
+{
+ static int brightness = -1;
+
+ if (status == no_change) {
+ if (brightness == -1)
+ status = increment;
+ else
+ return brightness;
+ }
+ if (status == decrement) {
+ switch (lux) {
+ case 10000 ... 0xffffffff:
+ brightness = 100;
+ break;
+ case 1000 ... 9999:
+ brightness = 80;
+ break;
+ case 75 ... 999:
+ brightness = 60;
+ break;
+ case 7 ... 74:
+ brightness = 40;
+ break;
+ case 0 ... 6:
+ brightness = 1;
+ break;
+ default:
+ return -1;
+ }
+ } else if (status == increment) {
+ switch (lux) {
+ case 15001 ... 0xffffffff:
+ brightness = 100;
+ break;
+ case 1501 ... 15000:
+ brightness = 80;
+ break;
+ case 151 ... 1500:
+ brightness = 60;
+ break;
+ case 16 ... 150:
+ brightness = 40;
+ break;
+ case 0 ... 15:
+ brightness = 1;
+ break;
+ default:
+ return -1;
+ }
+ } else
+ return -1;
+
+ return brightness;
+}
+
static int OEM_sys_display_info(struct display_info *disp_info)
{
struct dirent *dent;
@@ -205,6 +267,23 @@ int OEM_sys_get_backlight_max_brightness(int index, int *value)
return ret;
}
+int OEM_sys_get_backlight_min_brightness(int index, int *value)
+{
+ int ret = -1;
+ char path[MAX_NAME+1];
+
+ if (index >= DISP_MAX) {
+ devmgr_log("supports %d display node", DISP_MAX);
+ return ret;
+ }
+
+ snprintf(path, MAX_NAME, BACKLIGHT_MIN_BRIGHTNESS_PATH, disp_info[index].bl_name);
+ ret = sys_get_int(path, value);
+ devmgr_log("path[%s]value[%d]", path, *value);
+
+ return ret;
+}
+
int OEM_sys_get_backlight_brightness(int index, int *value, int power_saving)
{
int ret = -1;
@@ -242,6 +321,28 @@ int OEM_sys_get_backlight_brightness(int index, int *value, int power_saving)
return ret;
}
+int OEM_sys_set_backlight_dimming(int index, int value)
+{
+ /*
+ int ret = -1;
+ char path[MAX_NAME+1];
+
+ if (index >= DISP_MAX) {
+ devmgr_log("supports %d display node", DISP_MAX);
+ return ret;
+ }
+
+ snprintf(path, MAX_NAME, BACKLIGHT_DIMMING_PATH, disp_info[index].lcd_name);
+ devmgr_log("path[%s]value[%d]", path, value);
+ ret = sys_set_int(path, value);
+ return ret;
+ */
+
+ // TODO : value is only 1
+ return OEM_sys_set_backlight_brightness(index, 1, 0/*power_saving*/);
+
+}
+
int OEM_sys_set_backlight_brightness(int index, int value, int power_saving)
{
int ret = -1;
@@ -348,45 +449,6 @@ int OEM_sys_set_lcd_power(int index, int value)
return ret;
}
-int OEM_sys_get_backlight_min_brightness(int index, int *value)
-{
- int ret = -1;
- char path[MAX_NAME+1];
-
- if (index >= DISP_MAX) {
- devmgr_log("supports %d display node", DISP_MAX);
- return ret;
- }
-
- snprintf(path, MAX_NAME, BACKLIGHT_MIN_BRIGHTNESS_PATH, disp_info[index].bl_name);
- ret = sys_get_int(path, value);
- devmgr_log("path[%s]value[%d]", path, *value);
-
- return ret;
-}
-
-int OEM_sys_set_backlight_dimming(int index, int value)
-{
- /*
- int ret = -1;
- char path[MAX_NAME+1];
-
- if (index >= DISP_MAX) {
- devmgr_log("supports %d display node", DISP_MAX);
- return ret;
- }
-
- snprintf(path, MAX_NAME, BACKLIGHT_DIMMING_PATH, disp_info[index].lcd_name);
- devmgr_log("path[%s]value[%d]", path, value);
- ret = sys_set_int(path, value);
- return ret;
- */
-
- // TODO : value is only 1
- return OEM_sys_set_backlight_brightness(index, 1, 0/*power_saving*/);
-
-}
-
/* image_enhance */
int OEM_sys_get_image_enhance_save(void *image_enhance)
{
@@ -460,6 +522,11 @@ int OEM_sys_set_image_enhance_tune(int value)
return ret;
}
+int OEM_sys_image_enhance_info(int *value)
+{
+ return 0;
+}
+
int OEM_sys_set_display_frame_rate(int value)
{
/*
@@ -484,6 +551,11 @@ GENERATE_ACCESSORS_INT_R(battery_charge_full, BATTERY_CHARGE_FULL_PATH)
GENERATE_ACCESSORS_INT_R(battery_charge_now, BATTERY_CHARGE_NOW_PATH)
GENERATE_ACCESSORS_INT_R(battery_present, BATTERY_PRESENT_PATH)
+int OEM_sys_get_battery_capacity_raw(int *value)
+{
+ return 0;
+}
+
static char *health_text[] = {
"Unknown", "Good", "Overheat", "Dead", "Over voltage",
"Unspecified failure", "Cold",
@@ -524,12 +596,46 @@ int OEM_sys_get_battery_support_insuspend_charging(int *value)
return 0;
}
+static char uart_node_path[MAX_NAME];
+static char usb_node_path[MAX_NAME];
+
+/* find uart/usb node path */
+static int OEM_sys_muic_node_path_info()
+{
+ int err = -1;
+
+ err = sys_check_node(UART_PATH);
+ if (!err)
+ sys_get_node(UART_PATH, uart_node_path);
+ else {
+ err = sys_check_node(UART_PATH_TRATS);
+ if (err) {
+ devmgr_log("uart path node not found");
+ return -1;
+ }
+ sys_get_node(UART_PATH_TRATS, uart_node_path);
+ }
+
+ err = sys_check_node(USB_PATH);
+ if (!err)
+ sys_get_node(USB_PATH, usb_node_path);
+ else {
+ err = sys_check_node(USB_PATH_TRATS);
+ if (err) {
+ devmgr_log("usb path node not found");
+ return -1;
+ }
+ sys_get_node(USB_PATH_TRATS, usb_node_path);
+ }
+ return 0;
+}
+
int OEM_sys_get_uart_path(int *value)
{
char buf[BUFF_MAX] = {0};
int ret = 0;
- ret = sys_get_str(UART_PATH, buf);
+ ret = sys_get_str(uart_node_path, buf);
if (ret != 0) {
return -1;
}
@@ -549,9 +655,9 @@ int OEM_sys_set_uart_path(int value)
{
switch (value) {
case PATH_CP:
- return sys_set_str(UART_PATH, "CP");
+ return sys_set_str(uart_node_path, "CP");
case PATH_AP:
- return sys_set_str(UART_PATH, "AP");
+ return sys_set_str(uart_node_path, "AP");
}
return -1;
@@ -563,15 +669,15 @@ int OEM_sys_get_usb_path(int *value)
char buf[BUFF_MAX] = {0};
int ret = 0;
- ret = sys_get_str(USB_PATH, buf);
+ ret = sys_get_str(usb_node_path, buf);
if (ret != 0) {
return -1;
}
- if (strncmp(buf, "AP", 2) == 0) {
+ if (strncmp(buf, "PDA", 3) == 0) {
*value = PATH_AP;
return 0;
- } else if (strncmp(buf, "CP", 2) == 0) {
+ } else if (strncmp(buf, "MODEM", 5) == 0) {
*value = PATH_CP;
return 0;
}
@@ -583,24 +689,14 @@ int OEM_sys_set_usb_path(int value)
{
switch (value) {
case PATH_CP:
- return sys_set_str(USB_PATH, "CP");
+ return sys_set_str(usb_node_path, "MODEM");
case PATH_AP:
- return sys_set_str(USB_PATH, "AP");
+ return sys_set_str(usb_node_path, "PDA");
}
return -1;
}
-int OEM_sys_get_battery_capacity_raw(int *value)
-{
- return 0;
-}
-
-int OEM_sys_image_enhance_info(int *value)
-{
- return 0;
-}
-
GENERATE_ACCESSORS_INT_R(jack_charger_online, JACK_CHARGER_ONLINE_PATH)
GENERATE_ACCESSORS_INT_R(jack_earjack_online, JACK_EARJACK_ONLINE_PATH)
GENERATE_ACCESSORS_INT_R(jack_earkey_online, JACK_EARKEY_ONLINE_PATH)
@@ -632,6 +728,10 @@ int OEM_sys_set_power_state(int value)
switch (value) {
case POWER_STATE_SUSPEND:
return sys_set_str(POWER_STATE_PATH, "mem");
+ case POWER_STATE_PRE_SUSPEND:
+ return sys_set_str(POWER_STATE_PATH, "pre_suspend");
+ case POWER_STATE_POST_RESUME:
+ return sys_set_str(POWER_STATE_PATH, "post_resume");
}
return -1;
@@ -973,6 +1073,9 @@ EXPORT_API const OEM_sys_devman_plugin_interface *OEM_sys_get_devman_plugin_inte
devman_plugin_interface_emul.OEM_sys_get_cpufreq_scaling_min_freq = &OEM_sys_get_cpufreq_scaling_min_freq;
devman_plugin_interface_emul.OEM_sys_set_cpufreq_scaling_min_freq = &OEM_sys_set_cpufreq_scaling_min_freq;
+ devman_plugin_interface_emul.OEM_sys_get_backlight_brightness_by_lux = &OEM_sys_get_backlight_brightness_by_lux;
OEM_sys_display_info(disp_info);
+ OEM_sys_muic_node_path_info();
+
return &devman_plugin_interface_emul;
}