yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * °æ±¾ËùÓÐ (C)ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾ |
| 3 | * Ä£¿éÃû £ºMMI |
| 4 | * ÎļþÃû £ºmmi_ctrl.c |
| 5 | * Îļþ±êʶ £º |
| 6 | * Ïà¹ØÎļþ £º |
| 7 | * ʵÏÖ¹¦ÄÜ £ºMMIÊ¡µç´¦Àí |
| 8 | * ×÷Õß £º |
| 9 | * °æ±¾ £ºV1.0 |
| 10 | * Íê³ÉÈÕÆÚ £º2014-6-20 |
| 11 | * ÆäËü˵Ã÷ £º |
| 12 | * |
| 13 | ******************************************************************************/ |
| 14 | |
| 15 | /***************************************************************************** |
| 16 | Í·Îļþ |
| 17 | ******************************************************************************/ |
| 18 | #include "mmi_common.h" |
| 19 | #include "mmi_lcd.h" |
| 20 | |
| 21 | /***************************************************************************** |
| 22 | È«¾Ö±äÁ¿¶¨Òå |
| 23 | ******************************************************************************/ |
| 24 | //lcd/ledµÄ¹¤×÷ģʽ£¬ÓÃÀ´¾ö¶¨ÁÁÃðÆÁ/µÆ¡¢Ê¡µçµÈ |
| 25 | static E_zMmi_Work_Mode g_mmi_lcd_mode = MMI_ACTIVE_MODE; |
| 26 | static E_zMmi_Work_Mode g_mmi_led_mode = MMI_ACTIVE_MODE; |
| 27 | SINT32 g_mmi_softtimer_flag = 0;//ÓÃÀ´²âÊÔsofttimer»Øµ÷ÊÇ·ñÖ´ÐеÄdebug±äÁ¿ |
| 28 | |
| 29 | /***************************************************************************** |
| 30 | ÒýÓñäÁ¿ |
| 31 | ******************************************************************************/ |
| 32 | extern pthread_mutex_t g_mmi_lcdmode_mutex; |
| 33 | extern pthread_mutex_t g_mmi_ledmode_mutex; |
| 34 | extern E_zMmiShowMode g_showMode; |
| 35 | extern UINT32 g_led_sleep_mode; |
| 36 | extern UINT32 g_led_standby_mode; |
| 37 | |
| 38 | |
| 39 | /***************************************************************************** |
| 40 | º¯Êý˵Ã÷:×¢²áÃðÆÁÃðµÆ¿ØÖÆÄ£¿é |
| 41 | ******************************************************************************/ |
| 42 | SINT32 mmi_get_ctrlinfo(UINT32 ctrlinfo) |
| 43 | { |
| 44 | if (ctrlinfo != 0) { |
| 45 | T_zMMICtrlInfo * pCtrlInfo = (T_zMMICtrlInfo *)ctrlinfo; |
| 46 | pCtrlInfo->lcdmode = mmi_get_lcd_mode(); |
| 47 | pCtrlInfo->ledmode = mmi_get_led_mode(); |
| 48 | } |
| 49 | return MMI_SUCCESS; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | SINT32 mmi_RegisterCtrlTaskInfoItem() |
| 54 | { |
| 55 | T_zMMITaskInfoItem ctrlInfoItem = {0}; |
| 56 | ctrlInfoItem.task = MMI_TASK_CTRL; |
| 57 | ctrlInfoItem.taskinfo = (VOID*)malloc(sizeof(T_zMMICtrlInfo)); |
| 58 | ctrlInfoItem.get_taskinfo_fun = mmi_get_ctrlinfo; |
| 59 | ctrlInfoItem.get_ledinfo_fun = mmi_getLedCtrlInfo; |
| 60 | #ifndef DISABLE_LCD |
| 61 | ctrlInfoItem.get_lcdinfo_fun = mmi_getLcdCtrlInfo; |
| 62 | #endif |
| 63 | ctrlInfoItem.ledinfo = (VOID*)malloc(sizeof(T_zMmi_Led_Info)); |
| 64 | //ctrlInfoItem.show_mode = 2; |
| 65 | mmi_register_taskinfo_item(&ctrlInfoItem); |
| 66 | return MMI_SUCCESS; |
| 67 | } |
| 68 | |
| 69 | /********************************************************************************** |
| 70 | º¯Êý×÷ÓÃ:´ý»úʱÎÞ°´¼ü¹Ø±³¹â,Ïȱ䰵 5Ãë |
| 71 | ***********************************************************************************/ |
| 72 | static VOID * mmi_idle_halfbright_timer_cb(VOID *arg) |
| 73 | { |
| 74 | slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_idle_halfbright_timer_cb !!\n"); |
| 75 | mmi_set_lcd_mode(MMI_BACKLIGHT_OFF_MODE); |
| 76 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 77 | return NULL; |
| 78 | } |
| 79 | |
| 80 | static VOID mmi_idle_halfbright_timer_start(VOID) |
| 81 | { |
| 82 | int ret = -1; |
| 83 | slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_idle_halfbright_timer_start !!\n"); |
| 84 | #if MMI_SOFTTIMER_DEBUG |
| 85 | g_mmi_softtimer_flag = 5; |
| 86 | #endif |
| 87 | ret = CreateSoftTimer(SET_BACKLIGHT_HALFBRIGHT_TIMER, TIMER_FLAG_ONCE, SET_BACKLIGHT_HALFBRIGHT_TIME, &mmi_idle_halfbright_timer_cb, NULL); |
| 88 | if (ret != 0) { |
| 89 | slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_idle_halfbright_timer_start FAILED !!"); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | static VOID mmi_idle_halfbright_timer_stop(VOID) |
| 94 | { |
| 95 | |
| 96 | DeleteSoftTimer(SET_BACKLIGHT_HALFBRIGHT_TIMER); |
| 97 | } |
| 98 | |
| 99 | SINT32 zMMI_Handle_Msg_BacklightOff(VOID *data) |
| 100 | { |
| 101 | //mmi_idle_halfbright_timer_start(); |
| 102 | mmi_set_lcd_mode(MMI_BACKLIGHT_OFF_MODE); |
| 103 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 104 | return 0; |
| 105 | } |
| 106 | /********************************************************************************** |
| 107 | º¯Êý×÷ÓÃ:MMI´ý»úʱ¶¨Ê±Æ÷µÄ»Øµ÷º¯Êý |
| 108 | ***********************************************************************************/ |
| 109 | static VOID * mmi_idle_timer_cb(VOID *arg) |
| 110 | { |
| 111 | slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_idle_timer_cb !!\n"); |
| 112 | if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) { |
| 113 | if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_CHARGE_MODE || mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE) { |
| 114 | mmi_set_lcd_mode(MMI_FAKE_POWEROFF_MODE); |
| 115 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 116 | } else { |
| 117 | mmi_set_lcd_mode(MMI_BACKLIGHT_HALFBRIGHT_MODE); |
| 118 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 119 | //mmi_send_message(MODULE_ID_MMI, (USHORT)MSG_CMD_MMISTART_BACKLIGHTOFF_TIMER, 0, NULL); |
| 120 | ipc_send_message(MODULE_ID_MMI, MODULE_ID_MMI, MSG_CMD_MMISTART_BACKLIGHTOFF_TIMER, 0, NULL, 0); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | if (g_led_sleep_mode) { |
| 125 | if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) { |
| 126 | E_zMmi_Work_Mode led_mode = mmi_get_led_mode(); |
| 127 | if (led_mode == MMI_FAKE_POWEROFF_MODE || led_mode == MMI_IDLE_STANDBY_LEDOFF_MODE) { |
| 128 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 129 | return NULL; |
| 130 | } |
| 131 | if (led_mode == MMI_FAKE_POWEROFF_CHARGE_MODE) { |
| 132 | return NULL; |
| 133 | } |
| 134 | if (mmi_get_charge_state() == STATE_CHARGING || mmi_get_charge_state() == STATE_FULL) { |
| 135 | mmi_set_led_mode(MMI_IDLE_CHG_LEDOFF_MODE); |
| 136 | } else if (g_led_standby_mode && mmi_get_wifi_state() == FALSE) { |
| 137 | mmi_set_led_mode(MMI_IDLE_STANDBY_LEDOFF_MODE); |
| 138 | } else { |
| 139 | mmi_set_led_mode(MMI_IDLE_LEDOFF_MODE); |
| 140 | } |
| 141 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 142 | } |
| 143 | } |
| 144 | return NULL; |
| 145 | } |
| 146 | |
| 147 | /********************************************************************************** |
| 148 | º¯Êý×÷ÓÃ:´ý»úʱÎÞ°´¼ü¹Ø±³¹â¶¨Ê±Æ÷£¬Ê±¼ä20Ã룬һ´ÎÐÔ¶¨Ê±Æ÷ |
| 149 | ***********************************************************************************/ |
| 150 | static VOID mmi_idle_timer_create(VOID) |
| 151 | { |
| 152 | int ret = -1; |
| 153 | ret = CreateSoftTimer(SET_MMI_IDLE_TIMER, TIMER_FLAG_ONCE, SET_MMI_IDLE_TIME, &mmi_idle_timer_cb, NULL); |
| 154 | if (ret != 0) { |
| 155 | slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_idle_timer_create FAILED !!"); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /********************************************************************************** |
| 160 | º¯Êý×÷ÓÃ:STOP ´ý»úʱÎÞ°´¼üÃðµÆ¶¨Ê±Æ÷ |
| 161 | ***********************************************************************************/ |
| 162 | VOID mmi_idle_timer_stop(VOID) |
| 163 | { |
| 164 | |
| 165 | DeleteSoftTimer(SET_MMI_IDLE_TIMER); |
| 166 | } |
| 167 | |
| 168 | /********************************************************************************** |
| 169 | º¯Êý×÷ÓÃ:MMI¿ìËٹػúʱ¶¨Ê±Æ÷µÄ»Øµ÷º¯Êý |
| 170 | ***********************************************************************************/ |
| 171 | static VOID * mmi_fast_poweron_idle_timer_cb(VOID *arg) |
| 172 | { |
| 173 | slog(MMI_PRINT, SLOG_DEBUG, "ZTE_MMI mmi_fast_poweron_idle_timer_cb !!\n"); |
| 174 | if (mmi_get_lcd_mode() == MMI_FAKE_POWEROFF_MODE && (mmi_get_charge_state() == STATE_DISCHARGE)) { |
| 175 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 176 | } |
| 177 | return NULL; |
| 178 | } |
| 179 | |
| 180 | /********************************************************************************** |
| 181 | º¯Êý×÷ÓÃ:¿ìËٹػúʱ¶Ì°´¼ü½øÈë˯Ãß¶¨Ê±Æ÷£¬Ê±¼ä4Ã룬һ´ÎÐÔ¶¨Ê±Æ÷ |
| 182 | ***********************************************************************************/ |
| 183 | static VOID mmi_fast_poweron_idle_timer_create(VOID) |
| 184 | { |
| 185 | int ret = -1; |
| 186 | ret = CreateSoftTimer(SET_MMI_FAST_POWERON_IDLE_TIMER, TIMER_FLAG_ONCE, SET_MMI_FAST_POWERON_IDLE_TIME, &mmi_fast_poweron_idle_timer_cb, NULL); |
| 187 | if (ret != 0) { |
| 188 | slog(MMI_PRINT, SLOG_ERR, "ZTE_MMI mmi_fast_poweron_idle_timer_create FAILED\n"); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | /********************************************************************************** |
| 193 | º¯Êý×÷ÓÃ:KILL¿ìËٹػúʱʡµç¶¨Ê±Æ÷ |
| 194 | ***********************************************************************************/ |
| 195 | VOID mmi_fast_poweron_idle_timer_stop(VOID) |
| 196 | { |
| 197 | |
| 198 | DeleteSoftTimer(SET_MMI_FAST_POWERON_IDLE_TIMER); |
| 199 | } |
| 200 | |
| 201 | /********************************************************************************** |
| 202 | º¯Êý×÷ÓÃ:ÉèÖÃ/»ñÈ¡µ±Ç°LCDģʽ |
| 203 | ***********************************************************************************/ |
| 204 | E_zMmi_Work_Mode mmi_get_lcd_mode(VOID) |
| 205 | { |
| 206 | E_zMmi_Work_Mode tmpMode = MMI_ACTIVE_MODE; |
| 207 | mmi_getMutex(&g_mmi_lcdmode_mutex); |
| 208 | tmpMode = g_mmi_lcd_mode; |
| 209 | mmi_putMutex(&g_mmi_lcdmode_mutex); |
| 210 | return tmpMode; |
| 211 | } |
| 212 | |
| 213 | VOID mmi_set_lcd_mode(E_zMmi_Work_Mode tmpMode) |
| 214 | { |
| 215 | mmi_getMutex(&g_mmi_lcdmode_mutex); |
| 216 | g_mmi_lcd_mode = tmpMode; |
| 217 | mmi_putMutex(&g_mmi_lcdmode_mutex); |
| 218 | } |
| 219 | |
| 220 | /********************************************************************************** |
| 221 | º¯Êý×÷ÓÃ:ÉèÖÃ/»ñÈ¡µ±Ç°LEDģʽ |
| 222 | ***********************************************************************************/ |
| 223 | E_zMmi_Work_Mode mmi_get_led_mode(VOID) |
| 224 | { |
| 225 | E_zMmi_Work_Mode tmpMode = MMI_ACTIVE_MODE; |
| 226 | mmi_getMutex(&g_mmi_ledmode_mutex); |
| 227 | tmpMode = g_mmi_led_mode; |
| 228 | mmi_putMutex(&g_mmi_ledmode_mutex); |
| 229 | return tmpMode; |
| 230 | } |
| 231 | |
| 232 | VOID mmi_set_led_mode(E_zMmi_Work_Mode tmpMode) |
| 233 | { |
| 234 | mmi_getMutex(&g_mmi_ledmode_mutex); |
| 235 | g_mmi_led_mode = tmpMode; |
| 236 | mmi_putMutex(&g_mmi_ledmode_mutex); |
| 237 | } |
| 238 | |
| 239 | /********************************************************************************** |
| 240 | º¯Êý×÷ÓÃ:½«MMIÉèΪæµ״̬ |
| 241 | ***********************************************************************************/ |
| 242 | VOID mmi_set_mode_active(VOID) |
| 243 | { |
| 244 | if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) { |
| 245 | E_zMmi_Work_Mode lcd_mode = mmi_get_lcd_mode(); |
| 246 | if (lcd_mode == MMI_BACKLIGHT_OFF_MODE || lcd_mode == MMI_BACKLIGHT_HALFBRIGHT_MODE) { |
| 247 | mmi_set_lcd_mode(MMI_ACTIVE_MODE); |
| 248 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 249 | } |
| 250 | } |
| 251 | if (g_showMode == MMI_MODE_LED || g_showMode == MMI_MODE_ALL) { |
| 252 | E_zMmi_Work_Mode led_mode = mmi_get_led_mode(); |
| 253 | if (led_mode == MMI_IDLE_LEDOFF_MODE || led_mode == MMI_IDLE_STANDBY_LEDOFF_MODE || led_mode == MMI_IDLE_CHG_LEDOFF_MODE) { |
| 254 | mmi_set_led_mode(MMI_ACTIVE_MODE); |
| 255 | mmi_set_update_flag(MMI_TASK_CTRL); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /********************************************************************************** |
| 261 | º¯Êý×÷ÓÃ:MMIÊ¡µçʱµÄÏà¹Ø¶¨Ê±Æ÷reset£¬°´¼üºÍUSB²å°Îʱµ÷Óà |
| 262 | ***********************************************************************************/ |
| 263 | VOID mmi_reset_idle_timer(VOID) |
| 264 | { |
| 265 | if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) { |
| 266 | mmi_idle_halfbright_timer_stop(); |
| 267 | } |
| 268 | mmi_idle_timer_stop(); |
| 269 | mmi_idle_timer_create(); |
| 270 | } |
| 271 | |
| 272 | /********************************************************************************** |
| 273 | º¯Êý×÷ÓÃ:¿ìËٹػúʱÈôÓа´¼ü²Ù×÷£¬MMIÊ¡µçʱµÄÏà¹Ø¶¨Ê±Æ÷reset£¬°´¼üʱµ÷Óà |
| 274 | ***********************************************************************************/ |
| 275 | VOID mmi_reset_fast_poweron_idle_timer(VOID) |
| 276 | { |
| 277 | mmi_fast_poweron_idle_timer_stop(); |
| 278 | mmi_fast_poweron_idle_timer_create(); |
| 279 | } |
| 280 | |
| 281 | /********************************************************************************** |
| 282 | º¯Êý×÷ÓÃ:MMIÊ¡µçʱµÄÏà¹Ø¶¨Ê±Æ÷KILL£¬ ¹Ø»úºÍÖØÆôʱµ÷Óà |
| 283 | ***********************************************************************************/ |
| 284 | VOID mmi_kill_idle_timer(VOID) |
| 285 | { |
| 286 | if (g_showMode == MMI_MODE_LCD || g_showMode == MMI_MODE_ALL) { |
| 287 | mmi_idle_halfbright_timer_stop(); |
| 288 | } |
| 289 | mmi_idle_timer_stop(); |
| 290 | mmi_fast_poweron_idle_timer_stop(); |
| 291 | } |
| 292 | |
| 293 | /********************************************************************************** |
| 294 | º¯Êý×÷ÓÃ:³õʼ»¯MMIÊ¡µç¹ÜÀí |
| 295 | ***********************************************************************************/ |
| 296 | VOID mmi_init_idle_control(VOID) |
| 297 | { |
| 298 | mmi_idle_timer_create(); |
| 299 | } |
| 300 | |