2 Copyright 2012-2013 Samsung Electronics Co., Ltd
4 Licensed under the Flora License, Version 1.1 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://floralicense.org/license/
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
18 #include <sys/reboot.h>
20 #include <sys/ioctl.h>
21 #include <device-node.h>
24 #include "chg_common.h"
25 #include "chg_power.h"
30 static int s_lcd_bl_state = LCD_BL_ON;
31 static int s_lcd_br_state = LCD_BR_NORMAL;
32 static int s_sys_power_state = SYS_POWER_ON;
34 /*-----------------------------------------------------------------------------
36 ----------------------------------------------------------------------------*/
37 static int fb_lcd_bl_on(st_fbdi *s_fbdi)
39 DEBUG_MSG("fb_lcd_bl_on() is called.\n");
40 ioctl(s_fbdi->fb_fd, FBIOBLANK, FB_BLANK_UNBLANK);
44 /*-----------------------------------------------------------------------------
46 ----------------------------------------------------------------------------*/
47 static int fb_lcd_bl_off(st_fbdi *s_fbdi)
49 DEBUG_MSG("fb_lcd_bl_off() is called.\n");
50 ioctl(s_fbdi->fb_fd, FBIOBLANK, FB_BLANK_POWERDOWN);
53 /*-----------------------------------------------------------------------------
55 ----------------------------------------------------------------------------*/
56 int lcd_bl_on(FbInfo *fbi)
58 DEBUG_MSG("lcd_bl_on() is called.\n");
59 if (s_lcd_bl_state == LCD_BL_ON)
62 if (fbi->type == FB_DEV_FB) {
63 if (fb_lcd_bl_on((st_fbdi*)fbi->dev) < 0)
65 } else if (fbi->type == FB_DEV_DRM) {
66 if (drmd_lcd_on((st_drmdi*)fbi->dev) < 0)
71 s_lcd_bl_state = LCD_BL_ON;
75 /*-----------------------------------------------------------------------------
77 ----------------------------------------------------------------------------*/
78 int lcd_bl_off(FbInfo *fbi)
80 DEBUG_MSG("lcd_bl_off() is called.\n");
81 if (s_lcd_bl_state == LCD_BL_OFF)
84 if (fbi->type == FB_DEV_FB) {
85 if (fb_lcd_bl_off((st_fbdi*)fbi->dev) < 0)
87 } else if (fbi->type == FB_DEV_DRM) {
88 if (drmd_lcd_off((st_drmdi*)fbi->dev) < 0)
93 s_lcd_bl_state = LCD_BL_OFF;
97 /*-----------------------------------------------------------------------------
99 ----------------------------------------------------------------------------*/
100 int lcd_bl_state(void)
102 return s_lcd_bl_state;
106 /*-----------------------------------------------------------------------------
108 ----------------------------------------------------------------------------*/
109 int lcd_br_normal(void)
112 int brightness_max = 0;
114 brightness_max = device_get_max_brt(DEV_MAIN_DISPLAY);
115 ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_BRIGHTNESS,(int)(brightness_max*0.6));
117 DEBUG_MSG("lcd_br_normal() is called. ret : %d \n",ret);
119 s_lcd_br_state = LCD_BR_NORMAL;
123 /*-----------------------------------------------------------------------------
125 ----------------------------------------------------------------------------*/
126 int lcd_br_dimm(void)
130 ret = device_set_property(DEVICE_TYPE_DISPLAY,PROP_DISPLAY_BRIGHTNESS, 0);
132 DEBUG_MSG("lcd_br_dimm() is called. ret : %d \n",ret);
134 s_lcd_br_state = LCD_BR_DIMM;
138 /*-----------------------------------------------------------------------------
140 ----------------------------------------------------------------------------*/
141 int lcd_br_state(void)
143 return s_lcd_br_state;
146 /*-----------------------------------------------------------------------------
148 ----------------------------------------------------------------------------*/
149 int sys_power_wakeup(FbInfo *fbi)
151 DEBUG_MSG("sys_power_wakeup() is called.\n");
153 s_sys_power_state = SYS_POWER_ON;
159 /*-----------------------------------------------------------------------------
161 ----------------------------------------------------------------------------*/
162 int sys_power_sleep(FbInfo *fbi)
164 DEBUG_MSG("sys_power_sleep() is called.env :%s\n",
165 chg_env_str[EN_ENV_NO_SLEEP]);
167 s_sys_power_state = SYS_POWER_OFF;
171 if (0 == (strcmp(chg_env_str[EN_ENV_NO_SLEEP], "1"))) {
172 DEBUG_MSG("nosleep...\n");
176 system_cmd_nowait("echo mem > /sys/power/state");
181 /*-----------------------------------------------------------------------------
183 ----------------------------------------------------------------------------*/
184 int sys_power_state(void)
186 return s_sys_power_state;
189 /*-----------------------------------------------------------------------------
191 ----------------------------------------------------------------------------*/
192 void sys_power_reboot(void)
194 DEBUG_MSG("sys_power_reboot() is called.\n");
198 /*-----------------------------------------------------------------------------
200 ----------------------------------------------------------------------------*/
201 void sys_power_off(void)
203 DEBUG_MSG("sys_power_off() is called.\n");
204 reboot(RB_POWER_OFF);