Merge "make it more generic : devman, device-node"
authorYoungJin Lee <yj0701.lee@tizendev.org>
Thu, 2 May 2013 06:19:46 +0000 (15:19 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 2 May 2013 06:19:46 +0000 (15:19 +0900)
14 files changed:
CMakeLists.txt
config/tizen.cfg
include/chg_env.h
include/chg_fb.h
include/chg_power.h
packaging/charging-animation.spec
packaging/charging-mode.service
run-chg-ani.in
src/chg_battery.c
src/chg_env.c
src/chg_fb.c
src/chg_main.c
src/chg_png.c
src/chg_power.c

index 3ab7db1..55f7e87 100755 (executable)
@@ -35,6 +35,10 @@ pkg_check_modules(pkgs REQUIRED
        libpng
        libdrm
        libkms
+       device-node
+       devman
+       dlog
+       deviced
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
@@ -55,7 +59,6 @@ ENDIF("${ARCH}" STREQUAL "arm")
 ADD_DEFINITIONS("-DSYS_LOG_DEBUG")
 ADD_DEFINITIONS("-DINTERFACE_FB")
 ADD_DEFINITIONS("-DINTERFACE_DRM")
-ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
 ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
index b89f00d..2eba8e8 100755 (executable)
@@ -1,19 +1,5 @@
-CHG_ENV_SUPPORT_FB=0
-CHG_ENV_SUPPORT_DRM=1
-
-CHG_ENV_DEV_FB=
-CHG_ENV_DEV_DRM_NAME=exynos
-
-CHG_ENV_LCD_BRIGHT=/sys/class/backlight/s6e8aa0-bl/brightness
-CHG_ENV_LCD_BR_DIMM_VAL=0
-CHG_ENV_LCD_BR_NORM_VAL=10
-
-CHG_ENV_LCD_BL_ONOFF=/sys/class/graphics/fb3/blank
-CHG_ENV_LCD_BL_ON_VAL=0
-CHG_ENV_LCD_BL_OFF_VAL=4
-CHG_ENV_LCD_BL_NORM_VAL=
-
-CHG_ENV_LCD_XRES=720
-CHG_ENV_LCD_YRES=1280
-
-CHG_ENV_KEY_EVENT=/dev/event1
+export CHG_ENV_DEV_FB=
+export CHG_ENV_DEV_DRM_NAME=exynos
+export CHG_ENV_LCD_BL_ON_VAL=0
+export CHG_ENV_LCD_BL_OFF_VAL=4
+export CHG_ENV_NO_SLEEP=0
\ No newline at end of file
index 50bf6de..e5b7aa5 100755 (executable)
@@ -22,65 +22,18 @@ limitations under the License.
 
 enum {
        EN_ENV_BATT_DUMMY = 0,
-       EN_ENV_BATT_CAP,
-       EN_ENV_BATT_VOL_NOW,
-       EN_ENV_BATT_CHG_NOW,
-       EN_ENV_BATT_TEMP,
-       EN_ENV_BATT_CHG_FULL,
-       EN_ENV_BATT_ONLINE,
-       EN_ENV_BATT_HEALTH,
-       EN_ENV_BATT_PRESENT,
-       EN_ENV_POWER_STATE,
-       EN_ENV_LCD_BRIGHT,
-       EN_ENV_LCD_BR_DIMM_VAL,
-       EN_ENV_LCD_BR_NORM_VAL,
-
-       EN_ENV_SUPPORT_FB,
-       EN_ENV_SUPPORT_DRM,
        EN_ENV_DEV_FB,
        EN_ENV_DEV_DRM_NAME,
-       EN_ENV_LCD_BL_ONOFF,
        EN_ENV_LCD_BL_ON_VAL,
        EN_ENV_LCD_BL_OFF_VAL,
-       EN_ENV_LCD_BL_NORM_VAL,
-       EN_ENV_LCD_XRES,
-       EN_ENV_LCD_YRES,
-       EN_ENV_KEY_EVENT,
        EN_ENV_NO_SLEEP,
-       EN_ENV_POWER_LOCK,
-       EN_ENV_POWER_UNLOCK,
        EN_ENV_MAX
 };
 
-
-#define CHG_ENV_BATT_CAP               "CHG_ENV_BATT_CAP"
-#define CHG_ENV_BATT_VOL_NOW           "CHG_ENV_BATT_VOL_NOW"
-#define CHG_ENV_BATT_CHG_NOW           "CHG_ENV_BATT_CHG_NOW"
-#define CHG_ENV_BATT_TEMP              "CHG_ENV_BATT_TEMP"
-#define CHG_ENV_BATT_CHG_FULL  "CHG_ENV_BATT_CHG_FULL"
-#define CHG_ENV_BATT_ONLINE            "CHG_ENV_BATT_ONLINE"
-#define CHG_ENV_BATT_HEALTH            "CHG_ENV_BATT_HEALTH"
-#define CHG_ENV_BATT_PRESENT           "CHG_ENV_BATT_PRESENT"
-#define CHG_ENV_POWER_STATE            "CHG_ENV_POWER_STATE"
-
-#define CHG_ENV_POWER_LOCK             "CHG_ENV_POWER_LOCK"
-#define CHG_ENV_POWER_UNLOCK           "CHG_ENV_POWER_UNLOCK"
-
-#define CHG_ENV_LCD_BRIGHT             "CHG_ENV_LCD_BRIGHT"
-#define CHG_ENV_LCD_BR_DIMM_VAL        "CHG_ENV_LCD_BR_DIMM_VAL"
-#define CHG_ENV_LCD_BR_NORM_VAL        "CHG_ENV_LCD_BR_NORM_VAL"
-
-#define CHG_ENV_SUPPORT_FB             "CHG_ENV_SUPPORT_FB"
-#define CHG_ENV_SUPPORT_DRM            "CHG_ENV_SUPPORT_DRM"
-#define CHG_ENV_DEV_FB                 "CHG_ENV_DEV_FB"
+#define CHG_ENV_DEV_FB                         "CHG_ENV_DEV_FB"
 #define CHG_ENV_DEV_DRM_NAME           "CHG_ENV_DEV_DRM_NAME"
-#define CHG_ENV_LCD_BL_ONOFF           "CHG_ENV_LCD_BL_ONOFF"
-#define CHG_ENV_LCD_BL_ON_VAL  "CHG_ENV_LCD_BL_ON_VAL"
-#define CHG_ENV_LCD_BL_OFF_VAL         "CHG_ENV_LCD_BL_OFF_VAL"
-#define CHG_ENV_LCD_BL_NORM_VAL        "CHG_ENV_LCD_BL_NORM_VAL"
-#define CHG_ENV_LCD_XRES               "CHG_ENV_LCD_XRES"
-#define CHG_ENV_LCD_YRES               "CHG_ENV_LCD_YRES"
-#define CHG_ENV_KEY_EVENT              "CHG_ENV_KEY_EVENT"
+#define CHG_ENV_LCD_BL_ON_VAL          "CHG_ENV_LCD_BL_ON_VAL"
+#define CHG_ENV_LCD_BL_OFF_VAL                 "CHG_ENV_LCD_BL_OFF_VAL"
 #define CHG_ENV_NO_SLEEP               "CHG_ENV_NO_SLEEP"
 
 extern char chg_env_str[EN_ENV_MAX][ENV_MAX_LEN];
index 227ea21..6a5070f 100755 (executable)
@@ -33,7 +33,7 @@ typedef struct _FbInfo {
        void* dev;
 } FbInfo;
 
-extern void set_chg_img_params(void);
+extern void set_chg_img_params(FbInfo fbi);
 extern int fb_open(FbInfo *fbi);
 extern void fb_close(FbInfo *fbi);
 extern int fb_pan_display( FbInfo *fbi );
index 87cd270..c84cd20 100755 (executable)
@@ -33,11 +33,6 @@ enum {
        SYS_POWER_ON,
        SYS_POWER_OFF
 };
-enum {
-       SYS_POWER_UNKOWN,
-       SYS_POWER_LOCK,
-       SYS_POWER_UNLOCK
-};
 
 extern int lcd_bl_on(FbInfo *fbi);
 extern int lcd_bl_off(FbInfo *fbi);
@@ -47,8 +42,6 @@ extern int lcd_br_dimm(void);
 extern int lcd_br_state(void);
 extern int sys_power_wakeup(FbInfo *fbi);
 extern int sys_power_sleep(FbInfo *fbi);
-extern int sys_power_lock();
-extern int sys_power_unlock();
 extern int sys_power_state(void);
 extern void sys_power_reboot(void);
 extern void sys_power_off(void);
index 8a98844..cd5a8c6 100755 (executable)
@@ -1,20 +1,22 @@
 Name:       charging-animation
 Summary:    charging-animation
 ExclusiveArch:  %{arm}
-Version:    0.0.7
+Version:    0.0.8
 Release:    0
 Group:      misc
 License:    Flora Software License
 Source0:    %{name}-%{version}.tar.gz
 Source100:  charging-mode.target
 Source101:  charging-mode.service
-Source102:  charging-animation.conf
 
 BuildRequires: cmake
-
 BuildRequires: pkgconfig(libpng)
 BuildRequires: pkgconfig(libdrm)
 BuildRequires: pkgconfig(libkms)
+BuildRequires: pkgconfig(device-node)
+BuildRequires: pkgconfig(devman)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(deviced)
 
 %description
 charging-animation
@@ -35,11 +37,6 @@ make %{?jobs:-j%jobs}
 cd cmake_tmp
 %make_install
 
-# temoprary HW configuration. it should be seperated.
-mkdir -p %{buildroot}/etc/sysconfig
-install -m 644 %{SOURCE102} %{buildroot}/etc/sysconfig/charging-animation
-
-
 # systemd related
 mkdir -p %{buildroot}%{_libdir}/systemd/system/
 install -m 0644 %{SOURCE100} %{buildroot}%{_libdir}/systemd/system/
index c074f6a..433991f 100644 (file)
@@ -3,10 +3,8 @@ Description=Charging Mode Service
 OnFailure=basic.target
 
 [Service]
-Type=simple
-EnvironmentFile=-/usr/share/charging-animation/config/common.cfg
-EnvironmentFile=-/etc/sysconfig/charging-animation
+Type=forking
 ExecStartPre=-/bin/bash -c '/bin/echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
-ExecStart=/usr/bin/charging-animation
+ExecStart=/bin/sh -c '/etc/rc.d/rc2.d/S01charging-animation'
 Restart=always
 RestartSec=5
index 4ccd869..338354b 100755 (executable)
@@ -15,11 +15,6 @@ do_charging_ani() {
                source @CFGDIR@/tizen.cfg
        fi
 
-       source @CFGDIR@/common.cfg
-
-       # export the platform specific variables
-       source /etc/sysconfig/charging-animation
-
        echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 
        INPUT_SEARCH_BASE=/sys/class/input
index ca20ecf..b20958a 100755 (executable)
@@ -16,54 +16,40 @@ limitations under the License.
 
 #include <stdlib.h>
 #include <string.h>
+#include <device-node.h>
+#include <devman.h>
 #include "chg_common.h"
 #include "chg_battery.h"
 #include "chg_env.h"
 #include "chg_misc.h"
 
+#define CHG_ENV_BATT_VOL_NOW   "/sys/class/power_supply/battery/voltage_now"
 
 /*-----------------------------------------------------------------------------
-  get_batt_health()
-
-  return value
-       0 : not good
-       1 : good
- ----------------------------------------------------------------------------*/
-static int get_batt_health(void)
-{
-       char buf[FILE_IO_BUF_SIZE];
-       int value = BATT_HEALTH_BAD;
-
-       if (read_from_file((const char*)chg_env_str[EN_ENV_BATT_HEALTH],
-               buf, FILE_IO_BUF_SIZE) > 0) {
-               if (strncmp(buf, "Good", 4) == 0)
-                       value = BATT_HEALTH_GOOD;
-       }
-       return value;
-}
-
-/*-----------------------------------------------------------------------------
-  is_ta_online()
+  is_batt_present()
  ----------------------------------------------------------------------------*/
 static int is_ta_online(void)
 {
-       int ret;
+       int ret = 0, value = 0;
 
-       ret = read_int_from_file(chg_env_str[EN_ENV_BATT_ONLINE]);
+       ret = device_get_property(DEVICE_TYPE_EXTCON, PROP_EXTCON_TA_ONLINE, &value);
 
-       return !!ret;
-}
+       DEBUG_MSG("[is_ta_online] %d\n", value);
 
+       return !!value;
+}
 /*-----------------------------------------------------------------------------
   is_batt_present()
  ----------------------------------------------------------------------------*/
 static int is_batt_present(void)
 {
-       int ret;
+       int ret = 0, value = 0;
 
-       ret = read_int_from_file(chg_env_str[EN_ENV_BATT_PRESENT]);
+       ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_PRESENT, &value);
 
-       return !!ret;
+       DEBUG_MSG("[is_batt_present] %d\n", value);
+
+       return !!value;
 }
 
 /*-----------------------------------------------------------------------------
@@ -71,21 +57,41 @@ static int is_batt_present(void)
  ----------------------------------------------------------------------------*/
 static int is_batt_healthy(void)
 {
-       int ret;
+       int ret = 0;
 
-       ret = (get_batt_health() == BATT_HEALTH_GOOD);
+       ret = (device_get_battery_health() == BATTERY_GOOD);
+
+       DEBUG_MSG("[is_batt_healthy] %d\n", ret);
 
        return ret;
 }
 
 /*-----------------------------------------------------------------------------
+  is_batt_chg_now()
+ ----------------------------------------------------------------------------*/
+int is_batt_chg_now(void)
+{
+       int ret = 0, value = 0;
+
+       ret = device_get_property(DEVICE_TYPE_POWER, PROP_POWER_CHARGE_NOW, &value);
+
+       DEBUG_MSG("[is_batt_chg_now] %d\n", value);
+
+       return value;
+}
+
+/*-----------------------------------------------------------------------------
   is_batt_chg_full()
  ----------------------------------------------------------------------------*/
 int is_batt_chg_full(void)
 {
-       int ret;
+       int ret = 0;
 
-       ret = read_int_from_file(chg_env_str[EN_ENV_BATT_CHG_FULL]);
+       ret = device_is_battery_full();
+
+       if (ret == -1)
+               ret = 0;
+       DEBUG_MSG("[is_batt_chg_full] %d\n", ret);
 
        return !!ret;
 }
@@ -105,14 +111,13 @@ int batt_chg_state()
 
        if (!is_ta_online() || !is_batt_present()) {
                val = BATT_STATE_DISCONNECT;
-       } else if (!is_batt_healthy()) {
+       } else if(!is_batt_healthy()) {
                val = BATT_STATE_ERROR;
        } else if (is_batt_chg_full()) {
                val = BATT_STATE_FULL;
        } else {
                val = BATT_STATE_CHARGING;
        }
-
        return val;
 }
 
@@ -124,7 +129,7 @@ int batt_chg_level()
        int bat_soc;
        int bat_bar = 0;
 
-       bat_soc = read_int_from_file(chg_env_str[EN_ENV_BATT_CAP]);
+       bat_soc = device_get_battery_pct();
 
        bat_bar = bat_soc / 10;
        bat_bar = bat_bar * 10;
@@ -143,15 +148,10 @@ void show_batt_info(void)
 {
        int bat_soc;
        int bat_vol;
-       int bat_chg_now;
 
-       bat_soc = read_int_from_file(chg_env_str[EN_ENV_BATT_CAP]);
-       bat_vol = read_int_from_file(chg_env_str[EN_ENV_BATT_VOL_NOW]);
-       bat_chg_now = read_int_from_file(chg_env_str[EN_ENV_BATT_CHG_NOW]);
+       bat_soc = device_get_battery_pct();
+       bat_vol = read_int_from_file(CHG_ENV_BATT_VOL_NOW);
 
        DEBUG_MSG("[capacity] %d\n", bat_soc);
        DEBUG_MSG("[voltage_now] %d\n", bat_vol);
-       DEBUG_MSG("[charge_now] %d\n", bat_chg_now);
-}
-
-
+}
\ No newline at end of file
index 58c555e..c19e85b 100755 (executable)
@@ -39,57 +39,14 @@ void get_env(char *name, char *buf, int size)
 
 void chg_env_str_load(void)
 {
-       get_env(CHG_ENV_BATT_CAP,
-               chg_env_str[EN_ENV_BATT_CAP], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_VOL_NOW,
-               chg_env_str[EN_ENV_BATT_VOL_NOW], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_CHG_NOW,
-               chg_env_str[EN_ENV_BATT_CHG_NOW], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_TEMP,
-               chg_env_str[EN_ENV_BATT_TEMP], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_CHG_FULL,
-               chg_env_str[EN_ENV_BATT_CHG_FULL], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_ONLINE,
-               chg_env_str[EN_ENV_BATT_ONLINE], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_HEALTH,
-               chg_env_str[EN_ENV_BATT_HEALTH], ENV_MAX_LEN);
-       get_env(CHG_ENV_BATT_PRESENT,
-               chg_env_str[EN_ENV_BATT_PRESENT], ENV_MAX_LEN);
-       get_env(CHG_ENV_POWER_STATE,
-               chg_env_str[EN_ENV_POWER_STATE], ENV_MAX_LEN);
-       get_env(CHG_ENV_POWER_LOCK,
-               chg_env_str[EN_ENV_POWER_LOCK], ENV_MAX_LEN);
-       get_env(CHG_ENV_POWER_UNLOCK,
-               chg_env_str[EN_ENV_POWER_UNLOCK], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_BRIGHT,
-               chg_env_str[EN_ENV_LCD_BRIGHT], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_BR_DIMM_VAL,
-               chg_env_str[EN_ENV_LCD_BR_DIMM_VAL], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_BR_NORM_VAL,
-               chg_env_str[EN_ENV_LCD_BR_NORM_VAL], ENV_MAX_LEN);
-
-       get_env(CHG_ENV_SUPPORT_FB,
-               chg_env_str[EN_ENV_SUPPORT_FB], ENV_MAX_LEN);
-       get_env(CHG_ENV_SUPPORT_DRM,
-               chg_env_str[EN_ENV_SUPPORT_DRM], ENV_MAX_LEN);
        get_env(CHG_ENV_DEV_FB,
                chg_env_str[EN_ENV_DEV_FB], ENV_MAX_LEN);
        get_env(CHG_ENV_DEV_DRM_NAME,
                chg_env_str[EN_ENV_DEV_DRM_NAME], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_BL_ONOFF,
-               chg_env_str[EN_ENV_LCD_BL_ONOFF], ENV_MAX_LEN);
        get_env(CHG_ENV_LCD_BL_ON_VAL,
                chg_env_str[EN_ENV_LCD_BL_ON_VAL], ENV_MAX_LEN);
        get_env(CHG_ENV_LCD_BL_OFF_VAL,
                chg_env_str[EN_ENV_LCD_BL_OFF_VAL], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_BL_NORM_VAL,
-               chg_env_str[EN_ENV_LCD_BL_NORM_VAL], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_XRES,
-               chg_env_str[EN_ENV_LCD_XRES], ENV_MAX_LEN);
-       get_env(CHG_ENV_LCD_YRES,
-               chg_env_str[EN_ENV_LCD_YRES], ENV_MAX_LEN);
-       get_env(CHG_ENV_KEY_EVENT,
-               chg_env_str[EN_ENV_KEY_EVENT], ENV_MAX_LEN);
        get_env(CHG_ENV_NO_SLEEP,
                chg_env_str[EN_ENV_NO_SLEEP], ENV_MAX_LEN);
 }
index 9810c87..2f5f839 100755 (executable)
@@ -39,11 +39,11 @@ limitations under the License.
 #define CHG_IMG_DIR_720x1280           "/720x1280/"
 
 enum {
-       E_LCD_RES_480x800,
-       E_LCD_RES_320x480,
-       E_LCD_RES_1024x600,
-       E_LCD_RES_720x1280,
-       E_LCD_RES_1280x800,
+       E_LCD_RES_480x800 = (unsigned int) ((480 << 16) + 800),
+       E_LCD_RES_320x480 = (unsigned int) ((320 << 16) + 480),
+       E_LCD_RES_1024x600 = (unsigned int) ((1024 << 16) + 600),
+       E_LCD_RES_720x1280 = (unsigned int) ((720 << 16) + 1280),
+       E_LCD_RES_1280x800 = (unsigned int) ((1280 << 16) + 800),
        E_LCD_RES_MAX
 };
 
@@ -69,47 +69,14 @@ st_fbdi s_fbdi;
 st_drmdi s_drmdi;
 
 /*-----------------------------------------------------------------------------
-  get_lcd_resolution()
- ----------------------------------------------------------------------------*/
-static int get_lcd_resolution(void)
-{
-       int ret_lcd_res = E_LCD_RES_480x800;
-       int xres = 0;
-       int yres = 0;
-
-       if (strlen(chg_env_str[EN_ENV_LCD_XRES]) > 0)
-               xres = atoi(chg_env_str[EN_ENV_LCD_XRES]);
-       if (strlen(chg_env_str[EN_ENV_LCD_YRES]) > 0)
-               yres = atoi(chg_env_str[EN_ENV_LCD_YRES]);
-
-       if ((xres == 320) && (yres == 480)) {
-               DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_320x480 \n");
-               ret_lcd_res = E_LCD_RES_320x480;
-       } else if ((xres == 1024) && (yres == 600)) {
-               DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_1024x600 \n");
-               ret_lcd_res = E_LCD_RES_1024x600;
-       } else if ((xres == 720) && (yres == 1280)) {
-               DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_720x1280 \n");
-               ret_lcd_res = E_LCD_RES_720x1280;
-       } else if ((xres == 1280) && (yres == 800)) {
-               DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_1280x800 \n");
-               ret_lcd_res = E_LCD_RES_1280x800;
-       } else {
-               DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_480x800 \n");
-       }
-
-
-       return ret_lcd_res;
-}
-
-/*-----------------------------------------------------------------------------
   set_chg_img_params()
  ----------------------------------------------------------------------------*/
-void set_chg_img_params(void)
+void set_chg_img_params(FbInfo fbi)
 {
-       int lcd_res;
+       unsigned int lcd_res;
 
-       lcd_res = get_lcd_resolution();
+       lcd_res = (unsigned int)((fbi.w << 16) + fbi.h);
+       DEBUG_MSG("screen width(%d), height(%d)\n", fbi.w, fbi.h);
 
        /* charging images are different with models */
        switch (lcd_res) {
@@ -134,11 +101,11 @@ void set_chg_img_params(void)
        case E_LCD_RES_720x1280:
                snprintf(str_chg_img_dir, sizeof(str_chg_img_dir)-1, "%s%s", CHG_IMG_BASE, CHG_IMG_DIR_720x1280);
                s_normal_img_x = 266;
-               s_normal_img_y = 468;
+               s_normal_img_y = 358;
                s_progress_img_x = 270;
-               s_progress_img_y = 914;
-               s_err_img_x = 266;
-               s_err_img_y = 468;
+               s_progress_img_y = 804;
+               s_err_img_x = 264;
+               s_err_img_y = 357;
                break;
        case E_LCD_RES_1280x800:
                snprintf(str_chg_img_dir, sizeof(str_chg_img_dir)-1, "%s%s", CHG_IMG_BASE, CHG_IMG_DIR_480x800);
@@ -167,18 +134,13 @@ void set_chg_img_params(void)
  ----------------------------------------------------------------------------*/
 int fb_open(FbInfo *fbi)
 {
-       int support_fb;
-       int support_drm;
 
-       support_fb = atoi(chg_env_str[EN_ENV_SUPPORT_FB]);
-       support_drm = atoi(chg_env_str[EN_ENV_SUPPORT_DRM]);
-
-       if ((support_fb == 1) && (support_drm == 0)) {
-               DEBUG_MSG("[fb_open] fb device is detected. \n");
-               fbi->type = FB_DEV_FB;
-       } else if ((support_fb == 0) && (support_drm == 1)) {
+       if (!drmd_open(&s_drmdi) ) {
                DEBUG_MSG("[fb_open] drm device is detected. \n");
                fbi->type = FB_DEV_DRM;
+       } else if (!fbd_open(&s_fbdi)) {
+               DEBUG_MSG("[fb_open] fb device is detected. \n");
+               fbi->type = FB_DEV_FB;
        } else {
                DEBUG_MSG("[fb_open] No graphic device is specified. \n");
                return -1;
@@ -186,9 +148,6 @@ int fb_open(FbInfo *fbi)
 
        switch (fbi->type) {
        case FB_DEV_FB:
-               if (fbd_open(&s_fbdi) <0)
-                       return -1;
-
                fbi->buf = s_fbdi.fb_buf;
                fbi->w = s_fbdi.vi.xres;
                fbi->h = s_fbdi.vi.yres;
@@ -196,9 +155,6 @@ int fb_open(FbInfo *fbi)
                fbi->dev = (void*)&s_fbdi;
                break;
        case FB_DEV_DRM:
-               if (drmd_open(&s_drmdi) <0)
-                       return -1;
-
                fbi->buf = s_drmdi.fb_buf;
                fbi->buf2 = s_drmdi.fb_buf2;
                fbi->current_fb_id = s_drmdi.fb_id[0];
@@ -372,17 +328,6 @@ void fb_draw_img_normal_charging(FbInfo *fbi)
 
 #ifdef INTERFACE_DRM
        if (fbi->type == FB_DEV_DRM) {
-               if (sys_power_state() == SYS_POWER_OFF) {
-                       DEBUG_MSG("fb_draw_img_normal_charging - power off ..\n");
-                       if (fbi->current_fb_id == s_drmdi.fb_id[0])
-                               fbi->current_fb_id = s_drmdi.fb_id[1];
-                       else
-                               fbi->current_fb_id = s_drmdi.fb_id[0];
-                       return;
-               }
-               else
-                       DEBUG_MSG("no check..\n");
-
                DEBUG_MSG("[fb_draw_img_normal_charging] current_fb_id :%d\n",\
                        fbi->current_fb_id);
                drmModePageFlip(s_drmdi.fd, s_drmdi.crtc->crtc_id,\
@@ -423,17 +368,6 @@ void fb_draw_img_full_charging(FbInfo *fbi)
 
 #ifdef INTERFACE_DRM
        if (fbi->type == FB_DEV_DRM) {
-               if (sys_power_state() == SYS_POWER_OFF) {
-                       DEBUG_MSG("fb_draw_img_full_charging - power off ..\n");
-                       if (fbi->current_fb_id == s_drmdi.fb_id[0])
-                               fbi->current_fb_id = s_drmdi.fb_id[1];
-                       else
-                               fbi->current_fb_id = s_drmdi.fb_id[0];
-                       return;
-               }
-               else
-                       DEBUG_MSG("no check..\n");
-
                DEBUG_MSG("[fb_draw_img_full_charging] current_fb_id :%d\n",\
                        fbi->current_fb_id);
                drmModePageFlip(s_drmdi.fd, s_drmdi.crtc->crtc_id,\
@@ -530,17 +464,6 @@ void fb_draw_img_batt_err_temp(FbInfo *fbi)
 
 #ifdef INTERFACE_DRM
        if (fbi->type == FB_DEV_DRM) {
-               if (sys_power_state() == SYS_POWER_OFF) {
-                       DEBUG_MSG("fb_draw_img_batt_err_temp - power off ..\n");
-                       if (fbi->current_fb_id == s_drmdi.fb_id[0])
-                               fbi->current_fb_id = s_drmdi.fb_id[1];
-                       else
-                               fbi->current_fb_id = s_drmdi.fb_id[0];
-                       return;
-               }
-               else
-                       DEBUG_MSG("no check..\n");
-
                DEBUG_MSG("[fb_draw_img_batt_err_temp]new_fb_id : %d\n",\
                        fbi->current_fb_id);
                drmModePageFlip(s_drmdi.fd, s_drmdi.crtc->crtc_id,\
@@ -609,17 +532,6 @@ void fb_draw_img_batt_err_charging(FbInfo *fbi)
 
 #ifdef INTERFACE_DRM
        if (fbi->type == FB_DEV_DRM) {
-               if (sys_power_state() == SYS_POWER_OFF) {
-                       DEBUG_MSG("fb_draw_img_batt_err_charging - power off ..\n");
-                       if (fbi->current_fb_id == s_drmdi.fb_id[0])
-                               fbi->current_fb_id = s_drmdi.fb_id[1];
-                       else
-                               fbi->current_fb_id = s_drmdi.fb_id[0];
-                       return;
-               }
-               else
-                       DEBUG_MSG("no check..\n");
-
                DEBUG_MSG("[fb_draw_img_batt_err_charging]new_fb_id : %d\n",\
                        fbi->current_fb_id);
                drmModePageFlip(s_drmdi.fd, s_drmdi.crtc->crtc_id,\
index f56d71c..08ceedf 100755 (executable)
@@ -49,6 +49,8 @@ limitations under the License.
 
 FbInfo fbi;
 
+static int charging_error_lcd_dimming = 0;
+
 /*-----------------------------------------------------------------------------
   event_monitor_process()
  ----------------------------------------------------------------------------*/
@@ -63,6 +65,7 @@ int event_monitor_process(void *arg)
        struct timeval tv;
        static int key_push_time = 0;
        static int key_release_time = 0;
+       static int mode = 0;
 
        DEBUG_MSG("[main] event_monitor_process() started. %s\n", (char *)arg);
 
@@ -86,36 +89,45 @@ int event_monitor_process(void *arg)
                        if (lcd_on_flag == 1) {
                                lcd_on_flag++;
                        } else {
-                               sys_power_wakeup(&fbi);
-
                                if (lcd_br_state() == LCD_BR_DIMM) {
                                        lcd_br_normal();
                                }
-
-                               sys_power_cnt = LCD_DIMM_COUNT;
+                               sys_power_wakeup(&fbi);
+                               sys_power_cnt = LCD_DIMM_COUNT-5;
                                lcd_on_flag = 0;
                        }
                }
 
-               if (!batt_full_charged) {
+               /* check battery state */
+               if (!batt_full_charged) {/* battery status normal -> full */
                        if (is_batt_chg_full()) {
                                DEBUG_MSG("battery fully charged\n");
                                lcd_on_flag = 1;
                                batt_full_charged = 1;
                        }
+               } else { /* already battery level was full */
+                       DEBUG_MSG("full battery..\n");
+                       mode = batt_chg_state();
+                       if (BATT_STATE_DISCONNECT == mode) {
+                               DEBUG_MSG("TA or USB disconnected !!\n");
+                       }
                }
 
+               /* lcd dimming */
                if (sys_power_cnt == LCD_DIMM_COUNT) {
                        if (lcd_br_dimm() < 0)
                                sys_power_cnt = 0;
                }
 
+               /* power sleep */
                if (sys_power_cnt >= LCD_OFF_COUNT
                    && sys_power_state()!= SYS_POWER_OFF) {
+                       /* BATT_STATE_ERROR */
+                       if (charging_error_lcd_dimming ==1) {
+                               sys_power_cnt = LCD_DIMM_COUNT;
+                               continue;
+                       }
                        sys_power_sleep(&fbi);
-                       /* cpu sleep mode unlock */
-                       sys_power_unlock();
-
                }
 
                if (sys_power_cnt > 0xFFFE)
@@ -136,6 +148,7 @@ int event_monitor_process(void *arg)
                        }
                }
 
+               /* detect key event */
                if (pollevents.revents & POLLIN) {
                        readcount = read(pollevents.fd, &event, sizeof(event));
                        if (readcount != sizeof(event)) {
@@ -152,9 +165,8 @@ int event_monitor_process(void *arg)
                                                    tv.tv_sec * 1000 +
                                                    tv.tv_usec / 1000;
                                        }
-
-                                       sys_power_wakeup(&fbi);
                                        lcd_br_normal();
+                                       sys_power_wakeup(&fbi);
                                        sys_power_cnt = 0;
                                }
 
@@ -188,13 +200,19 @@ int charging_animation_process(void)
        int b_disp_status = 0;
        DEBUG_MSG("[main] charging_animation_process() started. \n");
 
-       set_chg_img_params();
+       set_chg_img_params(fbi);
 
        /* main loop for checking battery status
           and draw apropriate charging images   */
        while (1) {
                charging_mode = batt_chg_state();
                show_batt_info();
+
+               if (charging_mode == BATT_STATE_ERROR)
+                       charging_error_lcd_dimming = 1;
+               else
+                       charging_error_lcd_dimming = 0;
+
                switch (charging_mode) {
                case BATT_STATE_CHARGING:       /* Normal Charging */
                        fb_draw_img_normal_charging(&fbi);
@@ -211,13 +229,11 @@ int charging_animation_process(void)
                        batt_err_temp_cnt++;
                        break;
                case BATT_STATE_DISCONNECT:     /* TA disconnected */
-                       sys_power_lock();
-                       if (lcd_bl_state() == LCD_BL_OFF) {
+                       if (lcd_br_state() == LCD_BR_DIMM)
+                               lcd_br_normal();
+                       if (lcd_bl_state() == LCD_BL_OFF)
                                lcd_bl_on(&fbi);
-                               if (lcd_br_state() == LCD_BR_DIMM)
-                                       lcd_br_normal();
-                               sleep(1);
-                       }
+                       sleep(1);
                        fb_draw_img_batt_err_plug(&fbi);
                        sleep(1);
                        sys_power_off();
@@ -259,14 +275,10 @@ int main(int argc, char *argv[])
 
        DEBUG_MSG("charging-animation main function called.");
 
-       sys_power_wakeup(&fbi);
-       /* cpu wake up sequnce start */
-       /* sys_power_lock(); --> mem > /sys/power/state */
-       system_cmd_nowait("echo mem > /sys/power/state");
-       /* cpu wake up sequnce end */
-
        lcd_br_normal();
 
+       sys_power_wakeup(&fbi);
+
        if (clone(event_monitor_process, (void *)(child_stack + 4095),
                  CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, key_path) < 0) {
                DEBUG_MSG("[main] cannot creat thread ... \n");
index 21c4836..6850282 100755 (executable)
@@ -117,7 +117,7 @@ int read_png_file(char *file_name)
  ----------------------------------------------------------------------------*/
 void draw_png_img_xy(FbInfo *fbi, int x1, int y1)
 {
-       unsigned int *fb_buf_cur;
+       unsigned int *fb_buf_cur = NULL;
        int bpp;
        int x, y;
 
index e37f57b..199e56a 100755 (executable)
@@ -16,6 +16,10 @@ limitations under the License.
 
 #include <string.h>
 #include <sys/reboot.h>
+#include <stdlib.h>
+#include <device-node.h>
+#include <devman.h>
+
 #include "chg_common.h"
 #include "chg_power.h"
 #include "chg_misc.h"
@@ -25,70 +29,20 @@ limitations under the License.
 static int s_lcd_bl_state = LCD_BL_ON;
 static int s_lcd_br_state = LCD_BR_NORMAL;
 static int s_sys_power_state = SYS_POWER_ON;
-static int s_sys_power_lock = SYS_POWER_UNKOWN;
 
 /*-----------------------------------------------------------------------------
-  fb_lcd_bl_on()
- ----------------------------------------------------------------------------*/
-static int fb_lcd_bl_on(void)
-{
-       int ret;
-
-       if (strlen(chg_env_str[EN_ENV_LCD_BL_NORM_VAL]) > 0) {
-               ret = write_to_file(
-                       (const char*)chg_env_str[EN_ENV_LCD_BL_ONOFF],
-                       (const char*)chg_env_str[EN_ENV_LCD_BL_NORM_VAL]);
-               if (ret < 0)
-                       return -1;
-       }
-
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_LCD_BL_ONOFF],
-               (const char*)chg_env_str[EN_ENV_LCD_BL_ON_VAL]);
-       if (ret < 0)
-               return -1;
-
-       return 0;
-}
-
-/*-----------------------------------------------------------------------------
-  fb_lcd_bl_off()
- ----------------------------------------------------------------------------*/
-static int fb_lcd_bl_off(void)
-{
-       int ret;
-
-       if (strlen(chg_env_str[EN_ENV_LCD_BL_NORM_VAL]) > 0) {
-               ret = write_to_file(
-                       (const char*)chg_env_str[EN_ENV_LCD_BL_ONOFF],
-                       (const char*)chg_env_str[EN_ENV_LCD_BL_NORM_VAL]);
-               if (ret < 0)
-                       return -1;
-       }
-
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_LCD_BL_ONOFF],
-               (const char*)chg_env_str[EN_ENV_LCD_BL_OFF_VAL]);
-       if (ret < 0)
-               return -1;
-
-       return 0;
-}
-/*-----------------------------------------------------------------------------
   lcd_bl_on()
  ----------------------------------------------------------------------------*/
 int lcd_bl_on(FbInfo *fbi)
 {
-       DEBUG_MSG("lcd_bl_on() is called.\n");
+       int ret = 0;
+
        if (s_lcd_bl_state == LCD_BL_ON)
                return 0;
 
-       if (fbi->type == FB_DEV_FB) {
-               if (fb_lcd_bl_on() < 0)
-                       return -1;
-       } else if (fbi->type == FB_DEV_DRM) {
-               if (drmd_lcd_on((st_drmdi*)fbi->dev) < 0)
-                       return -1;
-       } else
-               return -1;
+       ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_ONOFF, atoi(chg_env_str[EN_ENV_LCD_BL_ON_VAL]));
+
+       DEBUG_MSG("lcd_bl_on() is called. ret : %d \n",ret);
 
        s_lcd_bl_state = LCD_BL_ON;
        return 0;
@@ -99,18 +53,14 @@ int lcd_bl_on(FbInfo *fbi)
  ----------------------------------------------------------------------------*/
 int lcd_bl_off(FbInfo *fbi)
 {
-       DEBUG_MSG("lcd_bl_off() is called.\n");
+       int ret = 0;
+
        if (s_lcd_bl_state == LCD_BL_OFF)
                return 0;
 
-       if (fbi->type == FB_DEV_FB) {
-               if (fb_lcd_bl_off() < 0)
-                       return -1;
-       } else if (fbi->type == FB_DEV_DRM) {
-               if (drmd_lcd_off((st_drmdi*)fbi->dev) < 0)
-                       return -1;
-       } else
-               return -1;
+       ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_ONOFF, atoi(chg_env_str[EN_ENV_LCD_BL_OFF_VAL]));
+
+       DEBUG_MSG("lcd_bl_off() is called. ret : %d \n",ret);
 
        s_lcd_bl_state = LCD_BL_OFF;
        return 0;
@@ -130,13 +80,13 @@ int lcd_bl_state(void)
  ----------------------------------------------------------------------------*/
 int lcd_br_normal(void)
 {
-       int ret;
+       int ret = 0;
+       int brightness_max = 0;
 
-       DEBUG_MSG("lcd_br_normal() is called.\n");
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_LCD_BRIGHT],
-               (const char*)chg_env_str[EN_ENV_LCD_BR_NORM_VAL]);
-       if (ret < 0)
-               return -1;
+       brightness_max = device_get_max_brt(DEV_MAIN_DISPLAY);
+       ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_BRIGHTNESS,(int)(brightness_max*0.6));
+
+       DEBUG_MSG("lcd_br_normal() is called. ret : %d \n",ret);
 
        s_lcd_br_state = LCD_BR_NORMAL;
        return 0;
@@ -147,13 +97,11 @@ int lcd_br_normal(void)
  ----------------------------------------------------------------------------*/
 int lcd_br_dimm(void)
 {
-       int ret;
+       int ret = 0;
+
+       ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_BRIGHTNESS,1);
 
-       DEBUG_MSG("lcd_br_dimm() is called.\n");
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_LCD_BRIGHT],
-               (const char*)chg_env_str[EN_ENV_LCD_BR_DIMM_VAL]);
-       if (ret < 0)
-               return -1;
+       DEBUG_MSG("lcd_br_dimm() is called. ret : %d \n",ret);
 
        s_lcd_br_state = LCD_BR_DIMM;
        return 0;
@@ -173,48 +121,13 @@ int lcd_br_state(void)
 int sys_power_wakeup(FbInfo *fbi)
 {
        DEBUG_MSG("sys_power_wakeup() is called.\n");
-       sys_power_lock();
+
        s_sys_power_state = SYS_POWER_ON;
        lcd_bl_on(fbi);
 
        return 0;
 }
-
-/*-----------------------------------------------------------------------------
-  sys_power_lock()
- ----------------------------------------------------------------------------*/
-int sys_power_lock()
-{
-       int ret = 0;
-
-       DEBUG_MSG("sys_power_lock() is called.\n");
-
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_POWER_LOCK],
-                       "mainlock");
-       if (ret < 0)
-               return -1;
-       s_sys_power_lock = SYS_POWER_LOCK;
-       return 0;
-}
-
- /*-----------------------------------------------------------------------------
-  sys_power_unlock()
- ----------------------------------------------------------------------------*/
-int sys_power_unlock()
-{
-       int ret = 0;
-
-       DEBUG_MSG("sys_power_unlock() is called.\n");
-
-       ret = write_to_file((const char*)chg_env_str[EN_ENV_POWER_UNLOCK],
-                       "mainlock");
-
-       if (ret < 0)
-               return -1;
-       s_sys_power_lock = SYS_POWER_UNLOCK;
-       return 0;
-}
-
 /*-----------------------------------------------------------------------------
   sys_power_sleep()
  ----------------------------------------------------------------------------*/
@@ -260,4 +173,3 @@ void sys_power_off(void)
        reboot(RB_POWER_OFF);
 }
 
-