2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <sys/types.h>
22 #include "devman_define_node_path.h"
23 #include "device_manager_siop.h"
24 #include "device_manager_io.h"
27 #if defined (DEVMGR_LOG)
28 #define LOG_TAG "DEVICE_PLUGIN"
29 #include <dlog/dlog.h>
30 #define devmgr_log(fmt, args...) SLOGD(fmt, ##args)
32 #define devmgr_log(fmt, args...)
35 /*===================================================
37 Last updated on 2013.5.15
38 ====================================================*/
39 const device_siop_table siop_table[SIOP_SCENARIO_MAX][SIOP_LEVEL_MAX] =
41 {/*********** LCD ON *****************************/
42 /* ITEM : cpu_freq cpu_core charging BL lcd_freq */
43 /* UNIT : MHz #core mA cd Hz */
44 /* level 0 */{RELEASE, IGNORE, IGNORE, 100, IGNORE},
45 /* level 1 */{RELEASE, IGNORE, IGNORE, 100, IGNORE},
46 /* level 2 */{RELEASE, IGNORE, IGNORE, 69, IGNORE},
47 /* level 3 */{1497600, IGNORE, IGNORE, 63, IGNORE},
48 /* level 4 */{1267200, IGNORE, IGNORE, 55, IGNORE},
49 /* level 5 */{1036800, IGNORE, IGNORE, 55, IGNORE},
50 /* level 6 */{1036800, IGNORE, IGNORE, 55, IGNORE},
51 /* level 7 */{1036800, IGNORE, IGNORE, 55, IGNORE},
54 {/*********** LCD OFF ****************************/
55 /* ITEM : cpu_freq cpu_core charging BL lcd_freq */
56 /* UNIT : MHz #core mA cd Hz */
57 /* level 0 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
58 /* level 1 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
59 /* level 2 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
60 /* level 3 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
61 /* level 4 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
62 /* level 5 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
63 /* level 6 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
64 /* level 7 */{IGNORE, IGNORE, IGNORE, IGNORE, IGNORE},
81 enum display_type etype; /* FIXME:!! Main LCD or Sub LCD node */
82 char bl_name[MAX_NAME+1]; /* backlight name */
83 char lcd_name[MAX_NAME+1]; /* lcd name */
86 extern struct display_info disp_info[DISP_MAX];
88 int OEM_sys_get_battery_siop_active(int *value)
91 int siop_activated, siop_level;
93 ret = sys_get_int(BATTERY_SIOP_ACTIVATE_PATH, &siop_activated);
98 ret = sys_get_int(BATTERY_SIOP_LEVEL_PATH, &siop_level);
103 if (siop_activated == 0)
112 int OEM_sys_set_battery_siop_active(int value)
115 int siop_activated, siop_level;
124 ret = sys_set_int(BATTERY_SIOP_ACTIVATE_PATH, siop_activated);
129 ret = sys_set_int(BATTERY_SIOP_LEVEL_PATH, siop_level);
137 static int sys_set_battery_siop_control(int level, int charge_current)
140 int siop_activated=0;
143 if (charge_current>=0)
146 ret = sys_set_int(BATTERY_SIOP_ACTIVATE_PATH, siop_activated);
151 if(siop_activated == 1) {
152 ret = sys_set_int(BATTERY_SIOP_LEVEL_PATH, level);
157 snprintf(buf, sizeof(buf), "%d %d", level, charge_current);
159 ret = sys_set_str(BATTERY_SIOP_LEVEL_CURRENT_PATH, buf);
168 int OEM_sys_get_backlight_overheating_control(int index, int *value)
171 char path[MAX_NAME+1];
173 if (index >= DISP_MAX) {
174 devmgr_log("supports %d display node", DISP_MAX);
178 snprintf(path, MAX_NAME, MDNIE_BACKLIGHT_OVERHEATING_PATH);
179 if(!sys_check_node((char *)path)) {
180 ret = sys_get_int(path, value);
182 snprintf(path, MAX_NAME, BACKLIGHT_OVERHEATING_PATH, disp_info[index].bl_name);
183 ret = sys_get_int(path, value);
189 extern int current_brightness;
190 extern int set_backlight_brightness(int index, int value);
192 int OEM_sys_set_backlight_overheating_control(int index, int value)
195 char path[MAX_NAME+1];
197 if (index >= DISP_MAX) {
198 devmgr_log("supports %d display node", DISP_MAX);
202 if ((current_brightness != -1) && (value > current_brightness)) {
203 value = current_brightness;
206 ret = set_backlight_brightness(index, value);
209 devmgr_log("Can't set backlight brightness");
216 int current_level=-1, current_mode=-1;
217 device_siop_table current_table = {RELEASE, RELEASE, RELEASE, 100, 60};
219 int OEM_sys_set_siop_control(int level, int mode)
221 device_siop_table new_table;
223 memcpy(&new_table, &siop_table[mode][level], sizeof(device_siop_table));
225 devmgr_log("level %d, mode %d",level, mode);
226 devmgr_log("current_siop {%d, %d, %d, %d, %d}",current_table.cpu_freq, current_table.cpu_max_core,\
227 current_table.battery_charing, current_table.backlight, current_table.lcd_freq);
228 devmgr_log("new_siop {%d, %d, %d, %d, %d}",new_table.cpu_freq, new_table.cpu_max_core,\
229 new_table.battery_charing, new_table.backlight, new_table.lcd_freq);
231 if((current_level==level) && (current_mode==mode))
235 if((new_table.cpu_freq != IGNORE) && (new_table.cpu_freq != current_table.cpu_freq)) {
236 devmgr_log("CPU max clock %d",new_table.cpu_freq);
237 sys_set_int(CPUFREQ_POWER_MAX_FREQ_PATH, new_table.cpu_freq);
238 current_table.cpu_freq = new_table.cpu_freq;
240 if((new_table.cpu_max_core != IGNORE) && (new_table.cpu_max_core != current_table.cpu_max_core)) {
241 devmgr_log("CPU max core num %d",new_table.cpu_max_core);
242 sys_set_int(CPU_ENABLE_MAX_NUMBER_PATH, new_table.cpu_max_core);
243 current_table.cpu_max_core = new_table.cpu_max_core;
246 /* Battery charging */
247 //OEM_sys_set_battery_siop_active(siop_table[level].battery_charing);
248 if((new_table.battery_charing != IGNORE) && (new_table.battery_charing != current_table.battery_charing)) {
249 devmgr_log("battery_charing current %d",new_table.battery_charing);
250 sys_set_battery_siop_control(level, new_table.battery_charing);
251 current_table.battery_charing = new_table.battery_charing;
255 if((new_table.backlight != IGNORE) && (new_table.backlight != current_table.backlight)) {
256 devmgr_log("backlight %d",new_table.backlight);
257 OEM_sys_set_backlight_overheating_control(DISP_MAIN, new_table.backlight);
258 current_table.backlight = new_table.backlight;
261 if((new_table.lcd_freq != IGNORE) && (new_table.lcd_freq != current_table.lcd_freq)) {
262 devmgr_log("lcd_freq %d",new_table.lcd_freq);
263 sys_set_int(DISPLAY_FRAME_RATE_PATH, new_table.lcd_freq);
264 current_table.lcd_freq = new_table.lcd_freq;