forked from rubenslte/android_kernel_samsung_msm8226
kernel: alarm: add dedicated alarm type for poweroff alarm
Now we use type of RTC_WAKEUP for the poweroff alarm. Actually lots of other applications also use this type. But these applications never expect the device will power on after it has been shut down. So we need to add dedicated alarm type for the Deskclock or similar applications. CRs-fixed: 529674 Change-Id: I9b7911906446daa1aeb5835478c9837f8ef797f2 Signed-off-by: Figo Wang <figow@codeaurora.org>
This commit is contained in:
@@ -98,7 +98,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
wake_unlock(&alarm_wake_lock);
|
||||
}
|
||||
alarm_enabled &= ~alarm_type_mask;
|
||||
if (alarm_type == ANDROID_ALARM_RTC_WAKEUP)
|
||||
if (alarm_type == ANDROID_ALARM_RTC_POWEROFF_WAKEUP)
|
||||
set_power_on_alarm(0);
|
||||
spin_unlock_irqrestore(&alarm_slock, flags);
|
||||
break;
|
||||
@@ -127,7 +127,7 @@ from_old_alarm_set:
|
||||
alarm_start_range(&alarms[alarm_type],
|
||||
timespec_to_ktime(new_alarm_time),
|
||||
timespec_to_ktime(new_alarm_time));
|
||||
if ((alarm_type == ANDROID_ALARM_RTC_WAKEUP) &&
|
||||
if ((alarm_type == ANDROID_ALARM_RTC_POWEROFF_WAKEUP) &&
|
||||
(ANDROID_ALARM_BASE_CMD(cmd) ==
|
||||
ANDROID_ALARM_SET(0)))
|
||||
set_power_on_alarm(new_alarm_time.tv_sec);
|
||||
@@ -171,6 +171,7 @@ from_old_alarm_set:
|
||||
switch (alarm_type) {
|
||||
case ANDROID_ALARM_RTC_WAKEUP:
|
||||
case ANDROID_ALARM_RTC:
|
||||
case ANDROID_ALARM_RTC_POWEROFF_WAKEUP:
|
||||
getnstimeofday(&tmp_time);
|
||||
break;
|
||||
case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP:
|
||||
|
||||
+16
-1
@@ -81,7 +81,8 @@ static void update_timer_locked(struct alarm_queue *base, bool head_removed)
|
||||
{
|
||||
struct alarm *alarm;
|
||||
bool is_wakeup = base == &alarms[ANDROID_ALARM_RTC_WAKEUP] ||
|
||||
base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
|
||||
base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP] ||
|
||||
base == &alarms[ANDROID_ALARM_RTC_POWEROFF_WAKEUP];
|
||||
|
||||
if (base->stopped) {
|
||||
pr_alarm(FLOW, "changed alarm while setting the wall time\n");
|
||||
@@ -423,15 +424,25 @@ static int alarm_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
hrtimer_cancel(&alarms[ANDROID_ALARM_RTC_WAKEUP].timer);
|
||||
hrtimer_cancel(&alarms[
|
||||
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].timer);
|
||||
hrtimer_cancel(&alarms[
|
||||
ANDROID_ALARM_RTC_POWEROFF_WAKEUP].timer);
|
||||
|
||||
tmp_queue = &alarms[ANDROID_ALARM_RTC_WAKEUP];
|
||||
if (tmp_queue->first)
|
||||
wakeup_queue = tmp_queue;
|
||||
|
||||
tmp_queue = &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
|
||||
if (tmp_queue->first && (!wakeup_queue ||
|
||||
hrtimer_get_expires(&tmp_queue->timer).tv64 <
|
||||
hrtimer_get_expires(&wakeup_queue->timer).tv64))
|
||||
wakeup_queue = tmp_queue;
|
||||
|
||||
tmp_queue = &alarms[ANDROID_ALARM_RTC_POWEROFF_WAKEUP];
|
||||
if (tmp_queue->first && (!wakeup_queue ||
|
||||
hrtimer_get_expires(&tmp_queue->timer).tv64 <
|
||||
hrtimer_get_expires(&wakeup_queue->timer).tv64))
|
||||
wakeup_queue = tmp_queue;
|
||||
|
||||
if (wakeup_queue) {
|
||||
rtc_read_time(alarm_rtc_dev, &rtc_current_rtc_time);
|
||||
getnstimeofday(&wall_time);
|
||||
@@ -466,6 +477,8 @@ static int alarm_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
false);
|
||||
update_timer_locked(&alarms[
|
||||
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP], false);
|
||||
update_timer_locked(&alarms[
|
||||
ANDROID_ALARM_RTC_POWEROFF_WAKEUP], false);
|
||||
err = -EBUSY;
|
||||
spin_unlock_irqrestore(&alarm_slock, flags);
|
||||
}
|
||||
@@ -489,6 +502,8 @@ static int alarm_resume(struct platform_device *pdev)
|
||||
update_timer_locked(&alarms[ANDROID_ALARM_RTC_WAKEUP], false);
|
||||
update_timer_locked(&alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP],
|
||||
false);
|
||||
update_timer_locked(&alarms[ANDROID_ALARM_RTC_POWEROFF_WAKEUP],
|
||||
false);
|
||||
spin_unlock_irqrestore(&alarm_slock, flags);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -25,6 +25,7 @@ enum android_alarm_type {
|
||||
ANDROID_ALARM_RTC,
|
||||
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
|
||||
ANDROID_ALARM_ELAPSED_REALTIME,
|
||||
ANDROID_ALARM_RTC_POWEROFF_WAKEUP,
|
||||
ANDROID_ALARM_SYSTEMTIME,
|
||||
|
||||
ANDROID_ALARM_TYPE_COUNT,
|
||||
@@ -86,6 +87,7 @@ enum android_alarm_return_flags {
|
||||
1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
|
||||
ANDROID_ALARM_ELAPSED_REALTIME_MASK =
|
||||
1U << ANDROID_ALARM_ELAPSED_REALTIME,
|
||||
ANDROID_ALARM_RTC_POWEROFF_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_POWEROFF_WAKEUP,
|
||||
ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME,
|
||||
ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user