Source: charging-animation
Section: devel
Priority: extra
-Maintainer: YoungJin Lee <yj0701.lee@samsung.com>
+Maintainer: YongChul Park <yc1216.park@samsung.com>
Uploaders: YoungJin Lee <yj0701.lee@samsung.com>, Dongil Park <dongil01.park@samsung.com>
Build-Depends: debhelper (>= 5), libpng-dev, libdrm-dev
Standards-Version: 0.1.0
#include <sys/types.h>
-extern int read_from_file(const char *path, char *buf, size_t size);
+extern int read_from_file(const char *path, char *buf, int size);
extern int write_to_file(const char *path, const char *buf);
extern int read_int_from_file(char *path);
+extern int system_cmd_wait(const char *command);
+extern int system_cmd_nowait(const char *command);
#endif /* __CHG_MISC_H__ */
Name: charging-animation
Summary: charging-animation
ExclusiveArch: %{arm}
-Version: 0.0.2
+Version: 0.0.3
Release: 1
Group: misc
License: Flora Software License
# export the platform specific variables
source /etc/sysconfig/charging-animation
- if [ "${CHG_ENV_SUPPORT_DRM}" = "1" ]; then
- /sbin/udevd --daemon
- /sbin/udevadm trigger --subsystem-match=drm
+ echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
+
+ INPUT_SEARCH_BASE=/sys/class/input
+ CANDIDATE=`ls ${INPUT_SEARCH_BASE} | grep input`
+
+ FOUND=
+ for f in ${CANDIDATE}
+ do
+ DEV_NAME=`cat ${INPUT_SEARCH_BASE}/${f}/name`
+ if [ "${DEV_NAME}" = "gpio-keys" ]; then
+ FOUND=${f}
+ break
+ fi
+ done
+ if [ "X${FOUND}" = "X" ]; then
+ echo "[error] cannot find key input event node"
fi
+ FOUND_NUM=${FOUND##input}
+ KEY_EVENT=/dev/input/event${FOUND_NUM}
- echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
- /usr/bin/charging-animation &
+ /usr/bin/charging-animation $KEY_EVENT &
}
limitations under the License.
*/
+#define _GNU_SOURCE
+#define __USE_GNU
#include <string.h>
#include <unistd.h>
#include "chg_common.h"
/* add drm framebuffer */
if(drmModeAddFB(drmdi->fd, drmdi->bo_width, drmdi->bo_height,
- 32, 32, drmdi->bo_stride, drmdi->bo_handle, &drmdi->fb_id)) {
+ 24, 32, drmdi->bo_stride, drmdi->bo_handle, &drmdi->fb_id)) {
LOGD("[create_framebuffer] Cannot add drm fb\n");
return -1;
}
(unsigned char *)mmap(0, fbdi->fb_buf_size,
PROT_READ | PROT_WRITE, MAP_SHARED,
fbdi->fb_fd, 0);
- if ((int)fbdi->fb_buf == -1) {
+ if ((void*)fbdi->fb_buf == (void*)-1) {
close(fbdi->fb_fd);
LOGD("Error: failed to map framebuffer device to memory.\n");
return -1;
limitations under the License.
*/
+#define _GNU_SOURCE
+#define __USE_GNU
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "chg_battery.h"
#include "chg_env.h"
-
-#define LCD_DIMM_COUNT 5
-#define LCD_OFF_COUNT 15
-
-
#define KEY_VAL_PRESS 1
#define KEY_VAL_RELEASE 0
#define KEY_CODE_POWER 116
+#define EVT_LOOP_DURATION 1000
+
+#define LCD_DIMM_TIME 10000
+#define LCD_OFF_TIME 30000
+#define LCD_DIMM_COUNT (LCD_DIMM_TIME/EVT_LOOP_DURATION)
+#define LCD_OFF_COUNT (LCD_OFF_TIME/EVT_LOOP_DURATION)
+
+#define KEY_INPUT_PATH "/dev/input/event7"
+
FbInfo fbi;
/*-----------------------------------------------------------------------------
static int key_release_time = 0;
char* key_dev_node;
- LOGD("[main] event_monitor_process() started. \n");
-
- key_dev_node = chg_env_str[EN_ENV_KEY_EVENT];
+ LOGD("[main] event_monitor_process() started. %s\n", arg);
- if ((fd = open(key_dev_node, O_RDWR)) < 0) {
- LOGD("%s: open error, fd = %d\n", key_dev_node, fd);
+ if ((fd = open(arg, O_RDWR)) < 0) {
+ LOGD("%s: open error, fd = %d\n", arg, fd);
return -1;
}
while (1) {
- ret = poll(&pollevents, 1, 2000);
+ ret = poll(&pollevents, 1, EVT_LOOP_DURATION);
if (ret < 0)
LOGD("poll error\n");
}
if (sys_power_cnt > 0xFFFE)
- sys_power_cnt = 16;
+ sys_power_cnt = LCD_OFF_COUNT;
sys_power_cnt++;
gettimeofday(&tv, NULL);
key_release_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
- if ((key_release_time - key_push_time) > 3000) {
+ if ((key_release_time - key_push_time) > 2000) {
sys_power_reboot();
break;
}
int main(int argc, char *argv[])
{
int child_stack[4096];
+ char key_path[256];
+
+ if (argc > 1)
+ strncpy(key_path, argv[1], 255);
+ else
+ strncpy(key_path, KEY_INPUT_PATH, 255);
chg_env_str_load();
return -1;
}
+ LOGD("charging-animation main function called.");
+
sys_power_wakeup(&fbi);
lcd_bl_on(&fbi);
lcd_br_normal();
if (clone(event_monitor_process, (void *)(child_stack + 4095),
- CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, NULL) < 0) {
+ CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, key_path) < 0) {
LOGD("[main] cannot creat thread ... \n");
goto main_exit;
}
*/
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include "chg_common.h"
/*-----------------------------------------------------------------------------
read_from_file()
----------------------------------------------------------------------------*/
-int read_from_file(const char *path, char *buf, size_t size)
+int read_from_file(const char *path, char *buf, int size)
{
int fd;
- size_t count;
+ int count;
if (!path)
return -1;
return -1;
}
- count = read(fd, buf, size);
+ count = (int)read(fd, buf, size);
if (count > 0) {
count = (count < size) ? count : size - 1;
while (count > 0 && buf[count - 1] == '\n')
int write_to_file(const char *path, const char *buf)
{
int fd;
- size_t count;
+ ssize_t count;
if (!path)
return -1;
close(fd);
if (count < 0) {
LOGD("[write_to_file] %s write error", path);
- return count;
+ return (int)count;
}
return 0;
return value;
}
+/*-----------------------------------------------------------------------------
+ system_cmd_wait()
+ ----------------------------------------------------------------------------*/
+int system_cmd_wait(const char *command)
+{
+
+ int pid = 0;
+ int status = 0;
+ char* const environ[2] = {"DISPLAY=:0", NULL };
+
+ if (command == NULL)
+ return -1;
+
+ pid = fork();
+
+ if (pid == -1)
+ return -1;
+
+ if (pid == 0) {
+ char *argv[4];
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char*)command;
+ argv[3] = 0;
+ execve("/bin/sh", argv, environ);
+ exit(127);
+ }
+
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR)
+ return -1;
+ } else {
+ return status;
+ }
+ } while(1);
+}
+
+/*-----------------------------------------------------------------------------
+ system_cmd_nowait()
+ ----------------------------------------------------------------------------*/
+int system_cmd_nowait(const char *command)
+{
+
+ int pid = 0;
+ char* const environ[2] = {"DISPLAY=:0", NULL };
+
+ if (command == NULL)
+ return -1;
+
+ pid = fork();
+
+ if (pid == -1)
+ return -1;
+
+ if (pid == 0) {
+ char *argv[4];
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char*)command;
+ argv[3] = 0;
+ execve("/bin/sh", argv, environ);
+ exit(127);
+ } else if (pid < 0) {
+ LOGD("execve fail : '%s'", command);
+ return -1;
+ }
+
+ return 0;
+}
+
+
return -1;
}
- fread(header, 1, 8, fp);
+ (void)fread(header, 1, 8, fp);
if (png_sig_cmp((png_bytep)header, 0, 8)) {
fclose(fp);
LOGD("[read_png_file] File %s is not recognized"
----------------------------------------------------------------------------*/
void sys_power_reboot(void)
{
+ LOGD("sys_power_reboot() is called.\n");
reboot(RB_AUTOBOOT);
}
----------------------------------------------------------------------------*/
void sys_power_off(void)
{
+ LOGD("sys_power_off() is called.\n");
reboot(RB_POWER_OFF);
}