Version 1.0, May, 2012
-http://www.tizenopensource.org/license
+http://floralicense.org/license/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#ifndef __CHG_COMMON_H__
#define __CHG_COMMON_H__
-
#include <stdio.h>
+#include <errno.h>
+
+#define DEBUG_MSG printf
+#if 0
+#define CHG_LOG_TAG "CHG_ANI"
+#include <dlog.h>
+#include <time.h>
+#include <sys/time.h>
+#include <libgen.h>
+#include <stdio.h>
+#include <errno.h>
-#define LOGD printf
-#define FILE_IO_BUF_SIZE 128
+#define DEBUG_MSG(format,args...) \
+do {\
+ LOG(LOG_DEBUG, CHG_LOG_TAG, "[%s:%d] "format"", __func__, __LINE__, ##args);\
+}while(0)
+#endif
+#define FILE_IO_BUF_SIZE 128
#endif /* __CHG_COMMON_H__ */
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
drmModeCrtcPtr crtc;
/*framebuffer*/
- unsigned int fb_id;
- struct kms_bo *bo;
+ unsigned int fb_id[2];
+ struct kms_bo *bo[2];
unsigned char *fb_buf;
+ unsigned char *fb_buf2;
unsigned int bo_stride;
unsigned int bo_handle;
unsigned int bo_width, bo_height;
} st_drmdi;
+enum {
+ FRAME_BUFFER1 = 0,
+ FRAME_BUFFER2
+};
+extern st_drmdi s_drmdi;
+extern drmEventContext evctx;
extern int drmd_open(st_drmdi *drmdi);
extern void drmd_close(st_drmdi *drmdi);
extern int drmd_lcd_on(st_drmdi *drmdi);
extern int drmd_lcd_off(st_drmdi *drmdi);
+extern void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void * data);
#endif /* __CHG_DRMD_H__ */
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
};
typedef struct _FbInfo {
- unsigned char *buf;
+ unsigned char *buf, *buf2;
+ unsigned int current_fb_id;
int w;
int h;
int sz;
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#include "chg_fb.h"
+#include "chg_drmd.h"
extern int png_img_width;
extern int png_img_height;
-extern int png_img_width_batt_normal;
-extern int png_img_height_batt_normal;
+/* clear screen based on img size */
+//extern int png_img_width_batt_normal;
+//extern int png_img_height_batt_normal;
extern int read_png_file(char *file_name);
extern void draw_png_img_xy(FbInfo *fbi, int x1, int y1);
extern void release_png_res(void);
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Name: charging-animation
Summary: charging-animation
ExclusiveArch: %{arm}
-Version: 0.0.5
+Version: 0.0.6
Release: 1
Group: misc
License: Flora Software License
charging_boot=`grep charger_detect_boot /proc/cmdline`
if [ "z$charging_boot" != "z" ]; then
- do_charging_ani
+
# for logs
mount -a
- syslogd -O /opt/var/log/messages-chrg
+ syslogd -b 5 -O /opt/var/log/messages-chrg
klogd
+
+ do_charging_ani
+
fi
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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]);
- LOGD("[capacity] %d\n", bat_soc);
- LOGD("[voltage_now] %d\n", bat_vol);
- LOGD("[charge_now] %d\n", bat_chg_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);
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#include "chg_drmd.h"
#include "chg_env.h"
+drmEventContext evctx;
/*-----------------------------------------------------------------------------
find_connector()
----------------------------------------------------------------------------*/
for(i=0; i<res_mode->count_connectors; i++) {
connector = drmModeGetConnector(fd, res_mode->connectors[i]);
if(connector == NULL) {
- LOGD("[find_connector] connector is NULL)\n");
+ DEBUG_MSG("[find_connector] connector is NULL)\n");
continue;
}
if(connector->connector_type == type)
}
if(!connector) {
- LOGD("[find_connector] Cannot find connector:%d\n", type);
+ DEBUG_MSG("[find_connector] Cannot find connector:%d\n", type);
return -1;
}
if(connector->connection != DRM_MODE_CONNECTED) {
- LOGD("[find_connector] connector is not connected (%d)\n",
+ DEBUG_MSG("[find_connector] connector is not connected (%d)\n",
(int)connector->connection);
return -1;
}
/* find default encoder */
encoder = drmModeGetEncoder(fd, connector->encoder_id);
if(!encoder) {
- LOGD("[find_connector] Cannot get encoder:%d\n", type);
+ DEBUG_MSG("[find_connector] Cannot get encoder:%d\n", type);
return -1;
}
/* find default crtc */
crtc = drmModeGetCrtc(fd, encoder->crtc_id);
if(!crtc) {
- LOGD("[find_connector] Cannot get CRTC\n");
+ DEBUG_MSG("[find_connector] Cannot get CRTC\n");
return -1;
}
/*-----------------------------------------------------------------------------
create_framebuffer()
----------------------------------------------------------------------------*/
-static int create_framebuffer(st_drmdi *drmdi)
+static int create_framebuffer(st_drmdi *drmdi,int i)
{
unsigned int attrs[]={
KMS_WIDTH, 0,
attrs[1] = drmdi->connector->modes[0].hdisplay;
attrs[3] = drmdi->connector->modes[0].vdisplay;
- if(kms_bo_create(drmdi->kms, attrs, &drmdi->bo)) {
- LOGD("[create_framebuffer] Cannot create kms bo\n");
+ if(kms_bo_create(drmdi->kms, attrs, &drmdi->bo[i])) {
+ DEBUG_MSG("[create_framebuffer] Cannot create kms bo\n");
return -1;
}
drmdi->bo_width = drmdi->connector->modes[0].hdisplay;
drmdi->bo_height = drmdi->connector->modes[0].vdisplay;
- kms_bo_get_prop(drmdi->bo, KMS_PITCH, &drmdi->bo_stride);
- kms_bo_get_prop(drmdi->bo, KMS_HANDLE, &drmdi->bo_handle);
+ kms_bo_get_prop(drmdi->bo[i], KMS_PITCH, &drmdi->bo_stride);
+ kms_bo_get_prop(drmdi->bo[i], KMS_HANDLE, &drmdi->bo_handle);
/* add drm framebuffer */
if(drmModeAddFB(drmdi->fd, drmdi->bo_width, drmdi->bo_height,
- 24, 32, drmdi->bo_stride, drmdi->bo_handle, &drmdi->fb_id)) {
- LOGD("[create_framebuffer] Cannot add drm fb\n");
+ 24, 32, drmdi->bo_stride, drmdi->bo_handle, &drmdi->fb_id[i])) {
+ DEBUG_MSG("[create_framebuffer] Cannot add drm fb\n");
return -1;
}
{
if(drmModeSetCrtc(drmdi->fd
, drmdi->crtc->crtc_id
- , drmdi->fb_id
+ , drmdi->fb_id[0]
, 0, 0
, &drmdi->connector->connector_id, 1
, drmdi->connector->modes)) {
- LOGD("[set_drm_mode] Cannot set drm mode\n");
+ DEBUG_MSG("[set_drm_mode] Cannot set drm mode\n");
return -1;
}
----------------------------------------------------------------------------*/
static void free_drm_res(st_drmdi *drmdi)
{
+ int i = 0;
if(drmdi->connector)
drmModeFreeConnector(drmdi->connector);
if(drmdi->res_mode)
drmModeFreeResources(drmdi->res_mode);
- if(drmdi->fb_id)
- drmModeRmFB(drmdi->fd, drmdi->fb_id);
- if(drmdi->bo)
- kms_bo_destroy(&drmdi->bo);
+ for( i = 0 ;i <FRAME_BUFFER2 ; i++) {
+ if(drmdi->fb_id[i])
+ drmModeRmFB(drmdi->fd, drmdi->fb_id[i]);
+ if(drmdi->bo[i])
+ kms_bo_destroy(&drmdi->bo[i]);
+ }
if(drmdi->kms)
kms_destroy(&drmdi->kms);
drmClose(drmdi->fd);
}
+void page_flip_handler(int fd, unsigned int frame,
+ unsigned int sec, unsigned int usec, void *data)
+{
+// DEBUG_MSG("page_flip_handler~\n");
+ return;
+}
+
/*-----------------------------------------------------------------------------
drmd_open()
----------------------------------------------------------------------------*/
int drmd_open(st_drmdi *drmdi)
{
drm_magic_t magic;
- void *ptr;
+ void *ptr, *ptr2;
int ret;
if (drmdi == NULL) {
- LOGD("[drmd_open] drmdi is NULL\n");
+ DEBUG_MSG("[drmd_open] drmdi is NULL\n");
return -1;
}
drmdi->fd = drmOpen(chg_env_str[EN_ENV_DEV_DRM_NAME], NULL);
if(drmdi->fd<0) {
- LOGD("[drmd_open] Cannot open drm:%s\n",
+ DEBUG_MSG("[drmd_open] Cannot open drm:%s\n",
chg_env_str[EN_ENV_DEV_DRM_NAME]);
return -1;
}
+ else {
+ DEBUG_MSG("[drmd_open] drmdi->fd : %d ",drmdi->fd);
+ }
drmdi->driver_name = drmGetDeviceNameFromFd(drmdi->fd);
- LOGD("[drmd_open] Init DRM(name:%s, fd:%d)...OK\n",
+ DEBUG_MSG("[drmd_open] Init DRM(name:%s, fd:%d)...OK\n",
drmdi->driver_name, drmdi->fd);
/* Auth DRM */
if(drmGetMagic(drmdi->fd, &magic)) {
- LOGD("[drmd_open] Cannot get magic\n");
+ DEBUG_MSG("[drmd_open] Cannot get magic\n");
goto drm_err_exit;
}
if(drmAuthMagic(drmdi->fd, magic)) {
- LOGD("[drmd_open] Cannot auth magic\n");
+ DEBUG_MSG("[drmd_open] Cannot auth magic\n");
goto drm_err_exit;
}
/* Create KMS */
if(kms_create(drmdi->fd, &drmdi->kms)) {
- LOGD("[drmd_open] Cannot create kms\n");
+ DEBUG_MSG("[drmd_open] Cannot create kms\n");
goto drm_err_exit;
}
/* Get drmmode resource */
drmdi->res_mode = drmModeGetResources(drmdi->fd);
if(!drmdi->res_mode) {
- LOGD("[drmd_open] Cannot get drmmode resources\n");
+ DEBUG_MSG("[drmd_open] Cannot get drmmode resources\n");
goto drm_err_exit;
}
ret = find_connector(drmdi, DRM_MODE_CONNECTOR_LVDS);
if(ret < 0) {
- LOGD("[drmd_open] Cannot get default(LVDS) connector\n");
+ DEBUG_MSG("[drmd_open] Cannot get default(LVDS) connector\n");
goto drm_err_exit;
}
/* Create framebuffer */
- ret = create_framebuffer(drmdi);
+ ret = create_framebuffer(drmdi, FRAME_BUFFER1);
if(ret < 0) {
- LOGD("[drmd_open] Cannot create frame buffer\n");
+ DEBUG_MSG("[drmd_open] Cannot create frame buffer\n");
goto drm_err_exit;
}
- if (kms_bo_map(drmdi->bo, &ptr)) {
- LOGD("[drmd_open] kms_bo_map() failed. \n");
+ if (kms_bo_map(drmdi->bo[FRAME_BUFFER1], &ptr)) {
+ DEBUG_MSG("[drmd_open] kms_bo_map() failed. \n");
goto drm_err_exit;
}
drmdi->fb_buf = ptr;
drmdi->dpms_mode = DPMSModeOn;
memset(ptr, 0x00, drmdi->bo_stride * drmdi->bo_height);
+ kms_bo_unmap(drmdi->bo[FRAME_BUFFER1]);
/* Set mode */
ret = set_drm_mode(drmdi);
if(ret < 0) {
- LOGD("[drmd_open] Cannot set drm mode\n");
+ DEBUG_MSG("[drmd_open] Cannot set drm mode\n");
+ goto drm_err_exit;
+ }
+
+ /* Create framebuffer 2 */
+ ret = create_framebuffer(drmdi, FRAME_BUFFER2);
+ if(ret < 0) {
+ DEBUG_MSG("[drmd_open] Cannot create frame buffer\n");
goto drm_err_exit;
}
+ if (kms_bo_map(drmdi->bo[FRAME_BUFFER2], &ptr2)) {
+ DEBUG_MSG("[drmd_open] kms_bo_map() failed. \n");
+ goto drm_err_exit;
+ }
+
+ drmdi->fb_buf2 = ptr2;
+ memset(ptr2, 0x00, drmdi->bo_stride * drmdi->bo_height);
+ kms_bo_unmap(drmdi->bo[FRAME_BUFFER2]);
+
+
+ ret = drmModePageFlip(drmdi->fd, drmdi->crtc->crtc_id, drmdi->fb_id[0],
+ DRM_MODE_PAGE_FLIP_EVENT, drmdi);
+ if (ret) {
+ DEBUG_MSG("failed to page flip: %s\n", strerror(errno));
+ return -1;
+ }
+
+ memset(&evctx, 0, sizeof evctx);
+ evctx.version = DRM_EVENT_CONTEXT_VERSION;
+ evctx.vblank_handler = NULL;
+ evctx.page_flip_handler = page_flip_handler;
+
+ {
+ struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 };
+ fd_set fds;
+
+
+ FD_ZERO(&fds);
+ FD_SET(0, &fds);
+ FD_SET(drmdi->fd, &fds);
+ ret = select(drmdi->fd + 1, &fds, NULL, NULL, &timeout);
+
+ if (ret <= 0) {
+ DEBUG_MSG("select timed out or error (ret %d)\n",
+ ret);
+ } else if (FD_ISSET(0, &fds)) {
+ // break;
+ DEBUG_MSG("drmHandleEvent.. \n");
+ }
+
+ drmHandleEvent(drmdi->fd, &evctx);
+ }
+
return 0;
drm_err_exit:
+ DEBUG_MSG("drm_err_exit\n");
free_drm_res(drmdi);
return -1;
}
----------------------------------------------------------------------------*/
void drmd_close(st_drmdi *drmdi)
{
- kms_bo_unmap(drmdi->bo);
+ int i;
+ for( i = 0 ;i <FRAME_BUFFER2 ; i++) {
+ kms_bo_unmap(drmdi->bo[i]);
+ }
free_drm_res(drmdi);
}
drmModeConnectorPtr connector;
if (drmdi == NULL) {
- LOGD("[drmd_set_dpms_mode] drmdi is NULL\n");
+ DEBUG_MSG("[drmd_set_dpms_mode] drmdi is NULL\n");
return -1;
}
connector = drmdi->connector;
if (dpms_mode == DPMSModeStandby || dpms_mode == DPMSModeSuspend) {
- LOGD("[drmd_set_dpms_mode] dmps_mode %s is not supported.\n",
+ DEBUG_MSG("[drmd_set_dpms_mode] dmps_mode %s is not supported.\n",
(dpms_mode == DPMSModeStandby)?
"DPMSModeStandby":"DPMSModeSuspend");
return -1;
ret = drmd_set_dpms_mode(drmdi, DPMSModeOn);
if (ret < 0) {
- LOGD("[drmd_lcd_on] drmd_set_dpms_mode() fail.\n");
+ DEBUG_MSG("[drmd_lcd_on] drmd_set_dpms_mode() fail.\n");
return -1;
}
ret = drmd_set_dpms_mode(drmdi, DPMSModeOff);
if (ret < 0) {
- LOGD("[drmd_lcd_off] drmd_set_dpms_mode() fail.\n");
+ DEBUG_MSG("[drmd_lcd_off] drmd_set_dpms_mode() fail.\n");
return -1;
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
snprintf(buf, size, "%s", ret);
}
- LOGD("[gen_env] %s ---> %s\n", name, buf);
+ DEBUG_MSG("[gen_env] %s ---> %s\n", name, buf);
}
void chg_env_str_load(void)
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
yres = atoi(chg_env_str[EN_ENV_LCD_YRES]);
if ((xres == 320) && (yres == 480)) {
- LOGD("[get_lcd_resolution] E_LCD_RES_320x480 \n");
+ DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_320x480 \n");
ret_lcd_res = E_LCD_RES_320x480;
} else if ((xres == 1024) && (yres == 600)) {
- LOGD("[get_lcd_resolution] E_LCD_RES_1024x600 \n");
+ DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_1024x600 \n");
ret_lcd_res = E_LCD_RES_1024x600;
} else if ((xres == 720) && (yres == 1280)) {
- LOGD("[get_lcd_resolution] E_LCD_RES_720x1280 \n");
+ DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_720x1280 \n");
ret_lcd_res = E_LCD_RES_720x1280;
} else if ((xres == 1280) && (yres == 800)) {
- LOGD("[get_lcd_resolution] E_LCD_RES_1280x800 \n");
+ DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_1280x800 \n");
ret_lcd_res = E_LCD_RES_1280x800;
} else {
- LOGD("[get_lcd_resolution] E_LCD_RES_480x800 \n");
+ DEBUG_MSG("[get_lcd_resolution] E_LCD_RES_480x800 \n");
}
support_drm = atoi(chg_env_str[EN_ENV_SUPPORT_DRM]);
if ((support_fb == 1) && (support_drm == 0)) {
- LOGD("[fb_open] fb device is detected. \n");
+ DEBUG_MSG("[fb_open] fb device is detected. \n");
fbi->type = FB_DEV_FB;
} else if ((support_fb == 0) && (support_drm == 1)) {
- LOGD("[fb_open] drm device is detected. \n");
+ DEBUG_MSG("[fb_open] drm device is detected. \n");
fbi->type = FB_DEV_DRM;
} else {
- LOGD("[fb_open] No graphic device is specified. \n");
+ DEBUG_MSG("[fb_open] No graphic device is specified. \n");
return -1;
}
return -1;
fbi->buf = s_drmdi.fb_buf;
+ fbi->buf2 = s_drmdi.fb_buf2;
+ fbi->current_fb_id = s_drmdi.fb_id[0];
fbi->w = s_drmdi.bo_width;
fbi->h = s_drmdi.bo_height;
fbi->sz = s_drmdi.bo_stride * s_drmdi.bo_height;
----------------------------------------------------------------------------*/
void fb_clear_screen(FbInfo *fbi, unsigned int color)
{
- unsigned int *fb_buf_cur = (unsigned int *)fbi->buf;
+ unsigned int *fb_buf_cur;
int loop_count = fbi->w * fbi->h;
+ if (fbi->current_fb_id == s_drmdi.fb_id[0])
+ fb_buf_cur = (unsigned int *)fbi->buf;
+ else
+ fb_buf_cur = (unsigned int *)fbi->buf2;
+
while (loop_count--)
*(fb_buf_cur++) = color;
}
void fb_fill_rect(FbInfo *fbi, int x1, int y1, int x2, int y2,
unsigned int color)
{
- unsigned int *fb_buf_cur = (unsigned int *)fbi->buf;
+ unsigned int *fb_buf_cur;
unsigned int *fb_line_buf;
int screen_width = fbi->w;
int draw_width = x2 - x1 + 1;
int width_cnt;
int height_cnt;
+ if (fbi->current_fb_id == s_drmdi.fb_id[0])
+ fb_buf_cur = (unsigned int *)fbi->buf;
+ else
+ fb_buf_cur = (unsigned int *)fbi->buf2;
+
fb_buf_cur += (x1 + y1 * screen_width);
fb_line_buf = fb_buf_cur;
width_cnt = draw_width;
static int batt_bar = 5;
char chg_img_filename[MAX_IMG_FILE_PATH];
- if (progress_cnt == 0) {
- batt_bar = batt_chg_level();
+ 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];
+
+ /* fill full screen with black color */
+ fb_clear_screen(fbi, 0x00000000);
- /* draw charging image based on batt_bar */
- sprintf(chg_img_filename, "%s%s_%d.png",
- str_chg_img_dir, CHG_IMG_NORMAL_PREFIX, batt_bar);
+ batt_bar = batt_chg_level();
- if (read_png_file(chg_img_filename) < 0) {
- return;
- }
+ /* draw charging image based on batt_bar */
+ sprintf(chg_img_filename, "%s%s_%d.png",
+ str_chg_img_dir, CHG_IMG_NORMAL_PREFIX, batt_bar);
- draw_png_img_xy(fbi, s_normal_img_x, s_normal_img_y);
- release_png_res();
+ if (read_png_file(chg_img_filename) < 0) {
+ return;
}
+ draw_png_img_xy(fbi, s_normal_img_x, s_normal_img_y);
+ release_png_res();
+
+
/* draw charging image based on progress_cnt */
sprintf(chg_img_filename, "%s%s_%02d.png",
str_chg_img_dir, CHG_IMG_PROGRESS_PREFIX, progress_cnt + 1);
progress_cnt = 0;
}
+ 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, fbi->current_fb_id,\
+ DRM_MODE_PAGE_FLIP_EVENT, NULL);
+ drmHandleEvent(s_drmdi.fd, &evctx);
}
/*-----------------------------------------------------------------------------
{
char chg_img_filename[MAX_IMG_FILE_PATH];
+
+ 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];
+
+ /* fill full screen with black color */
+ fb_clear_screen(fbi, 0x00000000);
+
/* draw charging image based on batt_bar & progress_cnt */
sprintf(chg_img_filename, "%s%s_100.png",
str_chg_img_dir, CHG_IMG_NORMAL_PREFIX);
draw_png_img_xy(fbi, s_normal_img_x, s_normal_img_y);
release_png_res();
+ 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, fbi->current_fb_id,\
+ DRM_MODE_PAGE_FLIP_EVENT, NULL);
+ drmHandleEvent(s_drmdi.fd, &evctx);
+
}
/*-----------------------------------------------------------------------------
{
char chg_img_filename[MAX_IMG_FILE_PATH];
+ 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];
+
+ /* fill full screen with black color */
+ fb_clear_screen(fbi, 0x00000000);
+
/* draw charging image based on batt_bar & progress_cnt */
sprintf(chg_img_filename, "%s%s.png",
str_chg_img_dir, CHG_IMG_DISCONNECT);
return;
}
- fb_clear_screen(fbi, 0x00000000);
draw_png_img_xy(fbi, s_err_img_x, s_err_img_y);
release_png_res();
+ DEBUG_MSG("[fb_draw_img_batt_err_plug]new_fb_id : %d\n",\
+ fbi->current_fb_id);
+ drmModePageFlip(s_drmdi.fd, s_drmdi.crtc->crtc_id, fbi->current_fb_id,\
+ DRM_MODE_PAGE_FLIP_EVENT, NULL);
+ drmHandleEvent(s_drmdi.fd, &evctx);
}
/*-----------------------------------------------------------------------------
{
char chg_img_filename[MAX_IMG_FILE_PATH];
+ 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];
+
+ /* fill full screen with black color */
+ fb_clear_screen(fbi, 0x00000000);
+
/* draw charging image based on batt_bar & progress_cnt */
sprintf(chg_img_filename, "%s%s.png",
str_chg_img_dir, CHG_IMG_TEMP_ERROR);
/* clear screen based on normal_img & progress_img */
- fb_fill_rect(fbi, s_normal_img_x, s_normal_img_y,\
+ /* fb_fill_rect(fbi, s_normal_img_x, s_normal_img_y,\
s_normal_img_x + png_img_width_batt_normal,\
s_normal_img_y + png_img_height_batt_normal,\
0x00000000);
fb_fill_rect(fbi, s_progress_img_x, s_progress_img_y,\
s_progress_img_x + png_img_width,\
- s_progress_img_y + png_img_height, 0x00000000);
-
+ s_progress_img_y + png_img_height, 0x00000000);*/
if (read_png_file(chg_img_filename) < 0) {
return;
}
draw_png_img_xy(fbi, s_err_img_x, s_err_img_y);
release_png_res();
+ 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, fbi->current_fb_id,\
+ DRM_MODE_PAGE_FLIP_EVENT, NULL);
+ drmHandleEvent(s_drmdi.fd, &evctx);
+
}
/*-----------------------------------------------------------------------------
static int batt_bar = 5;
char chg_img_filename[MAX_IMG_FILE_PATH];
+ 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];
+
+ /* fill full screen with black color */
+ fb_clear_screen(fbi, 0x00000000);
+
batt_bar = batt_chg_level();
/* draw charging image based on batt_bar */
str_chg_img_dir, CHG_IMG_NORMAL_PREFIX, batt_bar);
/* clear screen based on err_img */
- fb_fill_rect(fbi, s_err_img_x, s_err_img_y,\
+ /* fb_fill_rect(fbi, s_err_img_x, s_err_img_y,\
s_err_img_x + png_img_width,\
- s_err_img_y + png_img_height, 0x00000000);
+ s_err_img_y + png_img_height, 0x00000000);*/
if (read_png_file(chg_img_filename) < 0) {
return;
draw_png_img_xy(fbi, s_normal_img_x, s_normal_img_y);
release_png_res();
- png_img_width_batt_normal = png_img_width;
- png_img_height_batt_normal = png_img_height;
+// png_img_width_batt_normal = png_img_width;
+// png_img_height_batt_normal = png_img_height;
/* draw charging image based on progress_cnt */
sprintf(chg_img_filename, "%s%s_%02d.png",
progress_cnt = 0;
}
+ 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, fbi->current_fb_id,\
+ DRM_MODE_PAGE_FLIP_EVENT, NULL);
+ drmHandleEvent(s_drmdi.fd, &evctx);
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
{
fbdi->fb_fd = open(chg_env_str[EN_ENV_DEV_FB], O_RDWR);
if (!fbdi->fb_fd) {
- LOGD("Error: cannot open framebuffer device.\n");
+ DEBUG_MSG("Error: cannot open framebuffer device.\n");
return -1;
}
/* Get fixed screen information */
if (ioctl(fbdi->fb_fd, FBIOGET_FSCREENINFO, &fbdi->fi)) {
close(fbdi->fb_fd);
- LOGD("Error reading fixed information.\n");
+ DEBUG_MSG("Error reading fixed information.\n");
return -1;
}
/* Get variable screen information */
if (ioctl(fbdi->fb_fd, FBIOGET_VSCREENINFO, &fbdi->vi)) {
close(fbdi->fb_fd);
- LOGD("Error reading fixed information.\n");
+ DEBUG_MSG("Error reading fixed information.\n");
return -1;
}
fbdi->fb_fd, 0);
if ((void*)fbdi->fb_buf == (void*)-1) {
close(fbdi->fb_fd);
- LOGD("Error: failed to map framebuffer device to memory.\n");
+ DEBUG_MSG("Error: failed to map framebuffer device to memory.\n");
return -1;
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#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"
+#define KEY_INPUT_PATH "/dev/input/event1"
FbInfo fbi;
struct timeval tv;
static int key_push_time = 0;
static int key_release_time = 0;
- char* key_dev_node;
- LOGD("[main] event_monitor_process() started. %s\n", (char *)arg);
+ DEBUG_MSG("[main] event_monitor_process() started. %s\n", (char *)arg);
if ((fd = open(arg, O_RDWR)) < 0) {
- LOGD("%s: open error, fd = %d\n", (char *)arg, fd);
+ DEBUG_MSG("%s: open error, fd = %d\n", (char *)arg, fd);
return -1;
}
ret = poll(&pollevents, 1, EVT_LOOP_DURATION);
if (ret < 0)
- LOGD("poll error\n");
+ DEBUG_MSG("poll error\n");
if (lcd_on_flag) {
if (lcd_on_flag == 1) {
if (!batt_full_charged) {
if (is_batt_chg_full()) {
- LOGD("battery fully charged\n");
+ DEBUG_MSG("battery fully charged\n");
lcd_on_flag = 1;
batt_full_charged = 1;
}
sys_power_cnt++;
- LOGD("poll event : %d\n", ret);
+ DEBUG_MSG("poll event : %d, fd : %d sys_power_cnt : %d, arg : %s\n" \
+ , ret, pollevents.fd, sys_power_cnt, (char *) arg);
if (key_push_time) {
gettimeofday(&tv, NULL);
if (pollevents.revents & POLLIN) {
readcount = read(pollevents.fd, &event, sizeof(event));
if (readcount != sizeof(event)) {
- LOGD("key read error\n");
+ DEBUG_MSG("key read error\n");
continue;
}
- LOGD("key events happen\n");
+ DEBUG_MSG("key events happen\n");
if (event.type == EV_KEY) {
if (event.value == KEY_VAL_PRESS) {
if (event.code == KEY_CODE_POWER) {
sys_power_cnt = 0;
}
- LOGD("keycod: 0x%x, value: %d\n",
+ DEBUG_MSG("keycod: 0x%x, value: %d\n",
event.code, event.value);
if (event.value == KEY_VAL_RELEASE
}
} else if (event.type == EV_SYN) {
- LOGD("syn keycod: 0x%x, value: %d\n",
+ DEBUG_MSG("syn keycod: 0x%x, value: %d\n",
event.code, event.value);
}
int charging_mode = 0;
int batt_err_temp_cnt = 0;
- LOGD("[main] charging_animation_process() started. \n");
+ DEBUG_MSG("[main] charging_animation_process() started. \n");
set_chg_img_params();
- /* fill full screen with black color */
- fb_clear_screen(&fbi, 0x00000000);
-
/* main loop for checking battery status
and draw apropriate charging images */
while (1) {
chg_env_str_load();
if (fb_open(&fbi) < 0) {
- LOGD("[main] fb_open() failed. \n");
+ DEBUG_MSG("[main] fb_open() failed. \n");
return -1;
}
- LOGD("charging-animation main function called.");
+ DEBUG_MSG("charging-animation main function called.");
sys_power_wakeup(&fbi);
lcd_bl_on(&fbi);
if (clone(event_monitor_process, (void *)(child_stack + 4095),
CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, key_path) < 0) {
- LOGD("[main] cannot creat thread ... \n");
+ DEBUG_MSG("[main] cannot creat thread ... \n");
goto main_exit;
}
charging_animation_process();
main_exit:
- LOGD("[main] terminate %s \n", argv[0]);
+ DEBUG_MSG("[main] terminate \n");
lcd_br_dimm();
lcd_bl_off(&fbi);
sys_power_sleep(&fbi);
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
-#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include "chg_common.h"
fd = open(path, O_RDONLY, 0);
if (fd == -1) {
- LOGD("[read_from_file] Could not open '%s'", path);
+ DEBUG_MSG("[read_from_file] Could not open '%s'", path);
return -1;
}
fd = open(path, O_WRONLY);
if (fd == -1) {
- LOGD("[write_to_file] Could not open '%s'", path);
+ DEBUG_MSG("[write_to_file] Could not open '%s'", path);
return -1;
}
count = write(fd, buf, strlen(buf));
close(fd);
if (count < 0) {
- LOGD("[write_to_file] %s write error", path);
+ DEBUG_MSG("[write_to_file] %s write error", path);
return (int)count;
}
execve("/bin/sh", argv, environ);
exit(127);
} else if (pid < 0) {
- LOGD("execve fail : '%s'", command);
+ DEBUG_MSG("execve fail : '%s'", command);
return -1;
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
int png_img_width;
int png_img_height;
-int png_img_width_batt_normal;
-int png_img_height_batt_normal;
+/* clear screen based on img size */
+//int png_img_width_batt_normal;
+//int png_img_height_batt_normal;
png_byte color_type;
png_byte bit_depth;
/* open file and test for it being a png */
FILE *fp = fopen(file_name, "rb");
if (!fp) {
- LOGD("[read_png_file] File %s could not be opened"
+ DEBUG_MSG("[read_png_file] File %s could not be opened"
" for reading \n", file_name);
return -1;
}
(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"
+ DEBUG_MSG("[read_png_file] File %s is not recognized"
" as a PNG file \n", file_name);
return -1;
}
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
fclose(fp);
- LOGD("[read_png_file] png_create_read_struct failed \n");
+ DEBUG_MSG("[read_png_file] png_create_read_struct failed \n");
return -1;
}
if (!info_ptr) {
png_destroy_read_struct(&png_ptr, NULL, NULL);
fclose(fp);
- LOGD("[read_png_file] png_create_info_struct failed \n");
+ DEBUG_MSG("[read_png_file] png_create_info_struct failed \n");
return -1;
}
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
- LOGD("[read_png_file] Error during init_io \n");
+ DEBUG_MSG("[read_png_file] Error during init_io \n");
return -1;
}
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
- LOGD("[read_png_file] Error during read_image \n");
+ DEBUG_MSG("[read_png_file] Error during read_image \n");
return -1;
}
----------------------------------------------------------------------------*/
void draw_png_img_xy(FbInfo *fbi, int x1, int y1)
{
- unsigned int *fb_buf_cur = (unsigned int *)fbi->buf;
+ unsigned int *fb_buf_cur;
int bpp;
int x, y;
+ if (fbi->current_fb_id == s_drmdi.fb_id[0])
+ fb_buf_cur = (unsigned int *)fbi->buf;
+ else
+ fb_buf_cur = (unsigned int *)fbi->buf2;
+
/* check out range */
if ((x1 + png_img_width > fbi->w) ||
(y1 + png_img_height > fbi->h)) {
- LOGD("[draw_png_img_xy] "
- "output range exceeds frame buffer range \n");
+ DEBUG_MSG("[draw_png_img_xy] output range exceeds frame buffer range \n");
return;
}
else if (color_type == PNG_COLOR_TYPE_RGBA)
bpp = 4;
else {
- LOGD("[draw_png_img_xy] "
- "png type does not match RGB or RGBA \n");
+ DEBUG_MSG("[draw_png_img_xy] png type does not match RGB or RGBA \n");
return;
}
/*
-Copyright 2012, 2013 Samsung Electronics Co., Ltd
+Copyright 2012-2013 Samsung Electronics Co., Ltd
Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ http://floralicense.org/license/
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
----------------------------------------------------------------------------*/
int lcd_bl_on(FbInfo *fbi)
{
- LOGD("lcd_bl_on() is called.\n");
+ DEBUG_MSG("lcd_bl_on() is called.\n");
if (s_lcd_bl_state == LCD_BL_ON)
return 0;
----------------------------------------------------------------------------*/
int lcd_bl_off(FbInfo *fbi)
{
- LOGD("lcd_bl_off() is called.\n");
+ DEBUG_MSG("lcd_bl_off() is called.\n");
if (s_lcd_bl_state == LCD_BL_OFF)
return 0;
{
int ret;
- LOGD("lcd_br_normal() is called.\n");
+ 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)
{
int ret;
- LOGD("lcd_br_dimm() is called.\n");
+ 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)
----------------------------------------------------------------------------*/
int sys_power_wakeup(FbInfo *fbi)
{
- LOGD("sys_power_wakeup() is called.\n");
+ DEBUG_MSG("sys_power_wakeup() is called.\n");
lcd_bl_on(fbi);
s_sys_power_state = SYS_POWER_ON;
return 0;
----------------------------------------------------------------------------*/
int sys_power_sleep(FbInfo *fbi)
{
- LOGD("sys_power_sleep() is called.\n");
+ DEBUG_MSG("sys_power_sleep() is called.\n");
lcd_bl_off(fbi);
s_sys_power_state = SYS_POWER_OFF;
+// system_cmd_nowait("echo mem > /sys/power/state");
return 0;
}
----------------------------------------------------------------------------*/
void sys_power_reboot(void)
{
- LOGD("sys_power_reboot() is called.\n");
+ DEBUG_MSG("sys_power_reboot() is called.\n");
reboot(RB_AUTOBOOT);
}
----------------------------------------------------------------------------*/
void sys_power_off(void)
{
- LOGD("sys_power_off() is called.\n");
+ DEBUG_MSG("sys_power_off() is called.\n");
reboot(RB_POWER_OFF);
}