merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:18:15 +0000 (01:18 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:18:15 +0000 (01:18 +0900)
CMakeLists.txt
packaging/power-manager.manifest
packaging/power-manager.spec
pm_battery.c
pm_core.c
pm_device_plugin.c [deleted file]
pm_device_plugin.h [deleted file]
pm_llinterface.c
pm_lsensor.c
pm_x_lcd_onoff.c
pmctrl.in

index c75267d..15b6336 100644 (file)
@@ -10,7 +10,6 @@ SET(SRCS
        pm_poll.c
        pm_core.c
        pm_lsensor.c
-       pm_device_plugin.c
        pm_key_filter.c
        pm_battery.c )
 
@@ -25,7 +24,7 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED vconf glib-2.0 sysman aul dlog heynoti devman_plugin sensor)
+pkg_check_modules(pkgs REQUIRED vconf glib-2.0 sysman aul dlog heynoti device-node sensor)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index e4d4971..54e7bce 100644 (file)
@@ -8,6 +8,8 @@
     <assign>
         <filesystem path="/etc/rc.d/init.d/pmctrl" label="_" exec_label="none" />
         <filesystem path="/etc/rc.d/rc3.d/S35power-manager" label="_" exec_label="none" />
+       <filesystem path="/usr/lib/systemd/system/power-manager.service" label="_" exec_label="none" />
+       <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/power-manager.service" label="_" exec_label="none" />
     </assign>
 </manifest>
 
index 0004a9c..a392536 100644 (file)
@@ -1,7 +1,7 @@
 Name:       power-manager
 Summary:    Power manager
 Version:    1.3.23
-Release:    8
+Release:    9
 Group:      framework/system
 License:    APLv2
 Source0:    %{name}-%{version}.tar.gz
@@ -16,7 +16,7 @@ BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(devman)
-BuildRequires:  pkgconfig(devman_plugin)
+BuildRequires:  pkgconfig(device-node)
 BuildRequires:  pkgconfig(heynoti)
 
 %description
@@ -61,6 +61,8 @@ vconftool set -t int memory/pm/battery_timetofull -1 -i
 vconftool set -t int memory/pm/battery_timetoempty -1 -i
 vconftool set -t int memory/pm/custom_brightness_status 0 -i -g 5000
 vconftool set -t bool memory/pm/brt_changed_lpm 0 -i
+vconftool set -t int memory/pm/current_brt 60 -i -g 5000
+
 
 heynotitool set system_wakeup
 heynotitool set pm_event
index a413774..4b69ff1 100644 (file)
@@ -21,7 +21,6 @@
 #include <stdlib.h>
 
 #include "pm_core.h"
-#include "pm_device_plugin.h"
 #include "pm_battery.h"
 
 #define CHARGING_STATE(x)      ((x) & CHRGR_FLAG)
index d53aa27..55b2352 100644 (file)
--- a/pm_core.c
+++ b/pm_core.c
@@ -40,8 +40,8 @@
 #include <sysman.h>
 #include <aul.h>
 #include <vconf-keys.h>
+#include <device-node.h>
 
-#include "pm_device_plugin.h"
 #include "pm_core.h"
 #include "pm_battery.h"
 
@@ -755,7 +755,7 @@ static int default_action(int timeout)
                        setitimer(ITIMER_REAL, &val, NULL);
 
                        /* sleep state : set system mode to SUSPEND */
-                       if (0 > plugin_intf->OEM_sys_get_power_wakeup_count(&wakeup_count)) 
+                       if (0 > device_get_property(DEVICE_TYPE_POWER, PROP_POWER_WAKEUP_COUNT, &wakeup_count))
                                LOGERR("wakeup count read error");
 
                        if (wakeup_count < 0) {
@@ -763,7 +763,7 @@ static int default_action(int timeout)
                                goto go_lcd_off;
                        }
 
-                       if (0 > plugin_intf->OEM_sys_set_power_wakeup_count(wakeup_count)) {
+                       if (0 > device_set_property(DEVICE_TYPE_POWER, PROP_POWER_WAKEUP_COUNT, wakeup_count)) {
                                LOGERR("wakeup count write error");
                                goto go_lcd_off;
                        }
@@ -1024,7 +1024,7 @@ static int update_setting(int key_idx, int val)
                        vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
                if (power_saving_display_stat != 1)
                        power_saving_display_stat = 0;
-               plugin_intf->OEM_sys_set_display_frame_rate(power_saving_display_stat);
+               device_set_property(DEVICE_TYPE_DISPLAY, PROP_DISPLAY_FRAME_RATE, power_saving_display_stat);
                backlight_restore();
                break;
        case SETTING_POWER_SAVING_DISPLAY:
@@ -1034,7 +1034,7 @@ static int update_setting(int key_idx, int val)
                                power_saving_display_stat = 1;
                        else
                                power_saving_display_stat = 0;
-                       plugin_intf->OEM_sys_set_display_frame_rate(power_saving_display_stat);
+                       device_set_property(DEVICE_TYPE_DISPLAY, PROP_DISPLAY_FRAME_RATE, power_saving_display_stat);
                        backlight_restore();
                }
                break;
@@ -1218,29 +1218,30 @@ static void input_cb(void* data)
        return ;
 }
 
-static int set_noti(int noti_fd)
+static int set_noti(int *noti_fd)
 {
        int fd;
        char buf[PATH_MAX];
 
-       noti_fd = heynoti_init();
-       if (noti_fd < 0) {
+       fd = heynoti_init();
+       if (fd < 0) {
                LOGERR("heynoti_init error");
                return -1;
        }
 
-       if (heynoti_subscribe(noti_fd, PM_EVENT_NOTI_NAME, input_cb, PM_EVENT_NOTI_PATH) < 0) {
+       if (heynoti_subscribe(fd, PM_EVENT_NOTI_NAME, input_cb, PM_EVENT_NOTI_PATH) < 0) {
                LOGERR("input file change noti add failed(%s). %s", buf, strerror(errno));
                return -1;
        } else {
                LOGERR("input file change noti add ok");
        }
 
-       if (heynoti_attach_handler(noti_fd) < 0) {
+       if (heynoti_attach_handler(fd) < 0) {
                LOGERR("heynoti_attach_handler error");
                return -1;
        }
 
+       *noti_fd = fd;
        return 0;
 }
 
@@ -1269,26 +1270,23 @@ void start_main(unsigned int flags)
 {
        int ret, i;
 
-       if (0 > _pm_devman_plugin_init()) {
-               LOGERR("Device Manager Plugin initialize failed");
-               exit (-1);
-       }
-
        LOGINFO("Start power manager daemon");
 
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
        signal(SIGHUP, sig_hup);
        signal(SIGCHLD, SIG_IGN);
        signal(SIGUSR1, sig_usr);
-       signal(SIGUSR2, sig_quit);
        signal(SIGALRM, sig_break_block);
 
        mainloop = g_main_loop_new(NULL, FALSE);
        power_saving_func = default_saving_mode;
 
        /* noti init for new input device like bt mouse */
-       int noti_fd;
+       int noti_fd = -1;
        indev_list=NULL;
-       set_noti(noti_fd);
+       set_noti(&noti_fd);
 
        for (i = INIT_SETTING; i < INIT_END; i++) {
                switch (i) {
diff --git a/pm_device_plugin.c b/pm_device_plugin.c
deleted file mode 100644 (file)
index 00663d6..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * power-manager
- * 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 <dlfcn.h>
-#include <unistd.h>
-
-#include "util.h"
-#include "pm_device_plugin.h"
-
-static void *dlopen_handle;
-
-int _pm_devman_plugin_init()
-{
-       char *error;
-
-       dlopen_handle = dlopen(DEVMAN_PLUGIN_PATH, RTLD_NOW);
-       if (!dlopen_handle) {
-               LOGERR("dlopen() failed");
-               return -1;
-       }
-
-       const OEM_sys_devman_plugin_interface *(*get_devman_plugin_interface) ();
-       get_devman_plugin_interface = dlsym(dlopen_handle, "OEM_sys_get_devman_plugin_interface");
-       if ((error = dlerror()) != NULL) {
-               LOGERR("dlsym() failed: %s", error);
-               dlclose(dlopen_handle);
-               return -1;
-       }
-
-       plugin_intf = get_devman_plugin_interface();
-       if (!plugin_intf) {
-               LOGERR("get_devman_plugin_interface() failed");
-               dlclose(dlopen_handle);
-               return -1;
-       }
-
-       return 0;
-}
-
-
-int _pm_devman_plugin_fini()
-{
-       if (dlopen_handle) {
-               dlclose(dlopen_handle);
-       }
-
-       return 0;
-}
-
-
diff --git a/pm_device_plugin.h b/pm_device_plugin.h
deleted file mode 100644 (file)
index 1cf1b8e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * power-manager
- * 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.
-*/
-
-
-#ifndef __PM_DEVICE_PLUGIN_H__
-#define __PM_DEVICE_PLUGIN_H__
-
-#include "devman_plugin_intf.h"
-
-#define DEVMAN_PLUGIN_PATH      "/usr/lib/libslp_devman_plugin.so"
-
-int _pm_devman_plugin_init(void);
-int _pm_devman_plugin_fini(void);
-
-const OEM_sys_devman_plugin_interface *plugin_intf;
-
-#endif  /* __PM_DEVICE_PLUGIN_H__ */
index df4ffdc..23c16e3 100644 (file)
 #include <string.h>
 #include <unistd.h>
 #include <limits.h>
+#include <device-node.h>
+#include <vconf.h>
 
 #include "pm_llinterface.h"
-#include "pm_device_plugin.h"
 #include "util.h"
 #include "pm_conf.h"
-#include "vconf.h"
 #include "pm_core.h"
 
+#define DISP_INDEX_BIT                      4
+#define COMBINE_DISP_CMD(cmd, prop, index)  (cmd = (prop | (index << DISP_INDEX_BIT)))
+
 typedef struct _PMSys PMSys;
 struct _PMSys {
        int def_brt;
@@ -69,20 +72,17 @@ static void _update_curbrt(PMSys *p)
 
 static int _bl_onoff(PMSys *p, int onoff)
 {
-       return plugin_intf->OEM_sys_set_lcd_power(DEFAULT_DISPLAY, onoff);
+       int cmd;
+       COMBINE_DISP_CMD(cmd, PROP_DISPLAY_ONOFF, DEFAULT_DISPLAY);
+       return device_set_property(DEVICE_TYPE_DISPLAY, cmd, onoff);
 }
 
 static int _bl_brt(PMSys *p, int brightness)
 {
-       int power_saving_stat = -1;
-       int power_saving_display_stat = -1;
-       vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
-       if (power_saving_stat == 1)
-               vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
-       if (power_saving_display_stat != 1)
-               power_saving_display_stat = 0;
-       int ret = plugin_intf->OEM_sys_set_backlight_brightness(DEFAULT_DISPLAY, brightness, power_saving_display_stat);
-LOGERR("set brightness %d,%d(saving %d) %d", DEFAULT_DISPLAY, brightness, power_saving_display_stat, ret);
+       int cmd;
+       COMBINE_DISP_CMD(cmd, PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
+       int ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, brightness);
+       LOGERR("set brightness %d,%d %d", DEFAULT_DISPLAY, brightness, ret);
        return ret;
 }
 
@@ -90,7 +90,7 @@ static int _sys_power_state(PMSys *p, int state)
 {
        if (state < POWER_STATE_SUSPEND || state > POWER_STATE_POST_RESUME)
                return 0;
-       return plugin_intf->OEM_sys_set_power_state(state);
+       return device_set_property(DEVICE_TYPE_POWER, PROP_POWER_STATE, state);
 }
 
 static int _sys_get_battery_capacity(PMSys *p)
@@ -98,8 +98,7 @@ static int _sys_get_battery_capacity(PMSys *p)
        int value = 0;
        int ret = -1;
 
-       ret = plugin_intf->OEM_sys_get_battery_capacity(&value);
-
+       ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY, &value);
        if(ret < 0)
                return -1;
 
@@ -114,8 +113,7 @@ static int _sys_get_battery_capacity_raw(PMSys *p)
        int value = 0;
        int ret = -1;
 
-       ret = plugin_intf->OEM_sys_get_battery_capacity_raw(&value);
-
+       ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CAPACITY_RAW, &value);
        if(ret < 0)
                return -1;
 
@@ -130,8 +128,7 @@ static int _sys_get_battery_charge_full(PMSys *p)
        int value = 0;
        int ret = -1;
 
-       ret = plugin_intf->OEM_sys_get_battery_charge_full(&value);
-
+       ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CHARGE_FULL, &value);
        if(ret < 0)
                return -1;
 
index 71d6ddb..646bc14 100644 (file)
 #include <glib.h>
 #include <vconf.h>
 #include <sensor.h>
+#include <device-node.h>
 
 #include "pm_core.h"
-#include "pm_device_plugin.h"
 
 #define SAMPLING_INTERVAL      1       /* 1 sec */
 #define MAX_FAULT                      5
 
+#define DISP_INDEX_BIT                      4
+#define COMBINE_DISP_CMD(cmd, prop, index)  (cmd = (prop | (index << DISP_INDEX_BIT)))
+
 static int (*prev_init_extention) (void *data);
 static int (*_default_action) (int);
 static int alc_timeout_id = 0;
@@ -59,18 +62,14 @@ static gboolean alc_handler(gpointer data)
                                fault_count++;
                        } else {
                                int tmp_value;
-                               int power_saving_stat = -1;
-                               int power_saving_display_stat = -1;
-                               vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
-                               if (power_saving_stat == 1)
-                                       vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
-                               if (power_saving_display_stat != 1)
-                                       power_saving_display_stat = 0;
+                               int cmd;
                                value = PM_MAX_BRIGHTNESS * (int)light_data.values[0] / 10;
-                               plugin_intf->OEM_sys_get_backlight_brightness(DEFAULT_DISPLAY, &tmp_value, power_saving_display_stat);
+                               COMBINE_DISP_CMD(cmd, PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
+                               device_get_property(DEVICE_TYPE_DISPLAY, cmd, &tmp_value);
                                if (tmp_value != value) {
                                        set_default_brt(value);
                                        backlight_restore();
+                                       vconf_set_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, value);
                                }
                                LOGINFO("load light data : %d, brightness : %d", (int)light_data.values[0], value);
                        }
index 01200ae..e308231 100644 (file)
@@ -23,8 +23,6 @@
 #include <sys/wait.h>
 #include <errno.h>
 
-#include "pm_device_plugin.h"
-
 #define CMD_ON         "on"
 #define CMD_OFF                "off"
 
index e6d8b5d..72dda7d 100644 (file)
--- a/pmctrl.in
+++ b/pmctrl.in
@@ -55,12 +55,12 @@ case "$1" in
                ;;
        stop)
                if [ -e /var/run/power-manager.pid ] ; then
-                       kill -USR2 `cat /var/run/power-manager.pid`
+                       kill `cat /var/run/power-manager.pid`
                fi
                ;;
        restart)
                if [ -e /var/run/power-manager.pid ] ; then
-                       kill -USR2 `cat /var/run/power-manager.pid`
+                       kill `cat /var/run/power-manager.pid`
                        # sleep 1 second to wait PID file get removed
                        sleep 1
                fi