2 * Copyright (C) 2009 Sony Computer Entertainment Inc.
3 * Copyright 2009 Sony Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #if defined(HAVE_CONFIG_H)
32 * ui_timer_init - Initialize the timer for use.
33 * @seconds: The final timeout value in seconds.
36 void ui_timer_init(struct ui_timer *timer, unsigned int seconds)
38 pb_log("%s: %u\n", __func__, seconds);
39 assert(!timer->disabled);
40 timer->timeout = seconds;
44 * ui_timer_next - Calculate the next timer interval.
47 static unsigned int ui_timer_next(unsigned int seconds)
63 next = next ? next : 5;
68 next = next ? next : 10;
71 pb_log("%s: %u = %u\n", __func__, seconds, next);
76 * ui_timer_kick - Kickstart the next timer interval.
79 void ui_timer_kick(struct ui_timer *timer)
86 if (timer->update_display)
87 timer->update_display(timer, timer->timeout);
89 next = ui_timer_next(timer->timeout);
90 timer->timeout -= next;
97 pb_log("%s: timed out\n", __func__);
99 ui_timer_disable(timer);
100 timer->handle_timeout(timer);
104 * ui_timer_disable - Stop and disable the timer.
107 void ui_timer_disable(struct ui_timer *timer)
112 pb_log("%s\n", __func__);
114 timer->timeout = UINT_MAX;
124 void ui_timer_sigalrm(struct ui_timer *timer)
130 * ui_timer_process_sig - Process a timer signal
133 void ui_timer_process_sig(struct ui_timer *timer)
135 while (timer->signaled) {
137 ui_timer_kick(timer);