Add patch to change autobrightness interval by dbus. 19/14919/2
authorsh.pi <sh.pi@samsung.com>
Wed, 8 May 2013 05:45:54 +0000 (14:45 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Thu, 16 Jan 2014 10:38:45 +0000 (11:38 +0100)
default value is 2 seconds.
but the value can be changed for reducing power consumption.

Change-Id: I68807eecf14ee4673fb23839ad27b9f9428331fb
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
src/display/display-dbus.c
src/display/lsensor.c

index 9f98795..6384897 100644 (file)
@@ -301,6 +301,43 @@ error:
        return reply;
 }
 
+static DBusMessage *e_dbus_getautobrightnessinterval_cb(E_DBus_Object *obj, DBusMessage *msg)
+{
+       DBusMessageIter iter;
+       DBusMessage *reply;
+       int val;
+
+       val = get_autobrightness_interval();
+       _I("get autobrightness interval %d", val);
+
+       reply = dbus_message_new_method_return(msg);
+       dbus_message_iter_init_append(reply, &iter);
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &val);
+       return reply;
+}
+
+static DBusMessage *e_dbus_setautobrightnessinterval_cb(E_DBus_Object *obj, DBusMessage *msg)
+{
+       DBusMessageIter iter;
+       DBusMessage *reply;
+       int rate, ret;
+
+       dbus_message_iter_init(msg, &iter);
+       dbus_message_iter_get_basic(&iter, &rate);
+
+       ret = set_autobrightness_interval(rate);
+       if (ret)
+               _E("fail to set autobrightness interval %d, %d", rate, ret);
+       else
+               _I("set autobrightness interval %d", rate);
+
+       reply = dbus_message_new_method_return(msg);
+       dbus_message_iter_init_append(reply, &iter);
+       dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret);
+
+       return reply;
+}
+
 static struct edbus_method {
        const char *member;
        const char *signature;
@@ -315,6 +352,8 @@ static struct edbus_method {
        { "getbrightness",   NULL,   "i", e_dbus_getbrightness_cb },
        { "setbrightness",    "i",   "i", e_dbus_setbrightness_cb },
        { "setframerate",     "i",   "i", e_dbus_setframerate_cb },
+       { "getautobrightnessinterval",  NULL,   "i", e_dbus_getautobrightnessinterval_cb },
+       { "setautobrightnessinterval",   "i",   "i", e_dbus_setautobrightnessinterval_cb },
        /* Add methods here */
 };
 
index fbfb8e5..075080d 100644 (file)
@@ -32,6 +32,7 @@
 #include "core.h"
 #include "device-node.h"
 
+#define MAX_SAMPLING_INTERVAL  10      /* 10 sec */
 #define SAMPLING_INTERVAL      2       /* 2 sec */
 #define MAX_FAULT              5
 
@@ -41,6 +42,7 @@ static Ecore_Timer *alc_timeout_id = 0;
 static int sf_handle = -1;
 static int fault_count = 0;
 static int power_saving_display_stat = 0;
+static int sampling_interval = SAMPLING_INTERVAL;
 
 static bool alc_handler(void* data)
 {
@@ -99,7 +101,7 @@ static int alc_action(int timeout)
        /* sampling timer add */
        if (alc_timeout_id == 0 && !(pm_status_flag & PWRSV_FLAG))
                alc_timeout_id =
-                   ecore_timer_add(SAMPLING_INTERVAL,
+                   ecore_timer_add(sampling_interval,
                            (Ecore_Task_Cb)alc_handler, NULL);
 
        if (_default_action != NULL)
@@ -188,7 +190,7 @@ static int set_alc_function(keynode_t *key_nodes, void *data)
                        _default_action = states[S_NORMAL].action;
                states[S_NORMAL].action = alc_action;
                alc_timeout_id =
-                   ecore_timer_add(SAMPLING_INTERVAL,
+                   ecore_timer_add(sampling_interval,
                            (Ecore_Task_Cb)alc_handler, NULL);
        } else if (onoff == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
                _I("auto brightness paused!");
@@ -232,7 +234,7 @@ static bool check_sfsvc(void* data)
                        _default_action = states[S_NORMAL].action;
                states[S_NORMAL].action = alc_action;
                alc_timeout_id =
-                   ecore_timer_add(SAMPLING_INTERVAL,
+                   ecore_timer_add(sampling_interval,
                            (Ecore_Task_Cb)alc_handler, NULL);
                if (alc_timeout_id > 0)
                        return EINA_FALSE;
@@ -251,7 +253,7 @@ static int prepare_lsensor(void *data)
        vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &alc_conf);
 
        if (alc_conf == SETTING_BRIGHTNESS_AUTOMATIC_ON)
-               ecore_timer_add(SAMPLING_INTERVAL, (Ecore_Task_Cb)check_sfsvc, NULL);
+               ecore_timer_add(sampling_interval, (Ecore_Task_Cb)check_sfsvc, NULL);
 
        /* add auto_brt_setting change handler */
        vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
@@ -269,6 +271,24 @@ void set_power_saving_display_stat(int stat)
        power_saving_display_stat = stat;
 }
 
+int get_autobrightness_interval(void)
+{
+       return sampling_interval;
+}
+
+int set_autobrightness_interval(int val)
+{
+       if (val <= 0 || val > MAX_SAMPLING_INTERVAL)
+               return -EINVAL;
+
+       sampling_interval = val;
+
+       if (alc_timeout_id > 0)
+               ecore_timer_interval_set(alc_timeout_id, val);
+
+       return 0;
+}
+
 static void __attribute__ ((constructor)) pm_lsensor_init(void)
 {
        _default_action = NULL;