2 * This file is part of samsung-ril.
4 * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
5 * Copyright (C) 2011-2012 Paul Kocialkowski <contact@paulk.fr>
7 * samsung-ril is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * samsung-ril is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with samsung-ril. If not, see <http://www.gnu.org/licenses/>.
22 #define LOG_TAG "RIL-PWR"
23 #include <utils/Log.h>
25 #include "samsung-ril.h"
29 * Out: RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED
30 * Modem lets us know it's powered on. Though, it's still in LPM and should
31 * be considered as OFF. Send this to update RILJ radio state (OFF)
33 void ipc_pwr_phone_pwr_up(void)
35 ril_data.state.radio_state = RADIO_STATE_OFF;
36 ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM;
38 ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
42 * In: IPC_PWR_PHONE_STATE
43 * Noti from the modem giving current power mode (LPM or NORMAL)
44 * LPM = Low Power Mode (airplane mode for instance)
46 * Out: RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED
47 * Update radio state according to modem power state
49 void ipc_pwr_phone_state(struct ipc_message_info *info)
51 uint8_t state = *((uint8_t *) info->data);
55 case IPC_PWR_R(IPC_PWR_PHONE_STATE_LPM):
56 LOGD("Got power to LPM");
58 if (ril_data.state.power_state == IPC_PWR_PHONE_STATE_NORMAL &&
59 ril_data.tokens.radio_power != (RIL_Token) 0x00) {
60 ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0);
61 ril_data.tokens.radio_power = (RIL_Token) 0x00;
64 ril_data.state.radio_state = RADIO_STATE_OFF;
65 ril_data.state.power_state = IPC_PWR_PHONE_STATE_LPM;
66 ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
68 case IPC_PWR_R(IPC_PWR_PHONE_STATE_NORMAL):
69 LOGD("Got power to NORMAL");
71 if (ril_data.state.power_state == IPC_PWR_PHONE_STATE_LPM &&
72 ril_data.tokens.radio_power != (RIL_Token) 0x00) {
73 ril_request_complete(ril_data.tokens.radio_power, RIL_E_SUCCESS, NULL, 0);
74 ril_data.tokens.radio_power = (RIL_Token) 0x00;
77 ril_data.state.radio_state = RADIO_STATE_SIM_NOT_READY;
78 ril_data.state.power_state = IPC_PWR_PHONE_STATE_NORMAL;
79 ril_request_unsolicited(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0);
87 * In: RIL_REQUEST_RADIO_POWER
88 * Request ON or OFF radio power mode
90 * Out: IPC_PWR_PHONE_STATE
91 * Order the modem to get in required power mode
93 void ril_request_radio_power(RIL_Token t, void *data, size_t datalen)
95 int power_state = *((int *)data);
96 unsigned short power_data;
98 LOGD("requested power_state is %d", power_state);
100 if (power_state > 0) {
101 LOGD("Request power to NORMAL");
102 power_data = IPC_PWR_PHONE_STATE_NORMAL;
104 ipc_gen_phone_res_expect_to_abort(ril_request_get_id(t), IPC_PWR_PHONE_STATE);
105 ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), ril_request_get_id(t));
107 ril_data.tokens.radio_power = t;
109 LOGD("Request power to LPM");
110 power_data = IPC_PWR_PHONE_STATE_LPM;
112 ipc_gen_phone_res_expect_to_abort(ril_request_get_id(t), IPC_PWR_PHONE_STATE);
113 ipc_fmt_send(IPC_PWR_PHONE_STATE, IPC_TYPE_EXEC, (void *) &power_data, sizeof(power_data), ril_request_get_id(t));
115 ril_data.tokens.radio_power = t;