21 static volatile int opened, tmr_running;
22 static volatile time_t tmr_offs, tmr_ctr;
23 static volatile unsigned long ticks_offs;
24 static volatile int curr_tempo, curr_timebase;
25 static volatile unsigned long curr_ticks;
26 static volatile unsigned long next_event_time;
27 static unsigned long prev_event_time;
29 static void poll_def_tmr(
unsigned long dummy);
34 tmr2ticks(
int tmr_value)
45 tmp = tmr_value * (1000000 /
HZ);
46 scale = (60 * 1000000) / (curr_tempo * curr_timebase);
47 return (tmp + scale / 2) / scale;
51 poll_def_tmr(
unsigned long dummy)
58 def_tmr.expires = (1) + jiffies;
66 curr_ticks = ticks_offs + tmr2ticks(tmr_ctr);
68 if (curr_ticks >= next_event_time)
70 next_event_time = (
unsigned long) -1;
87 next_event_time = (
unsigned long) -1;
90 spin_unlock_irqrestore(&
lock,flags);
104 def_tmr.expires = (1) + jiffies;
112 def_tmr_close(
int dev)
114 opened = tmr_running = 0;
119 def_tmr_event(
int dev,
unsigned char *
event)
121 unsigned char cmd =
event[1];
122 unsigned long parm = *(
int *) &event[4];
127 parm += prev_event_time;
133 if (parm <= curr_ticks)
137 next_event_time = prev_event_time =
time;
164 ticks_offs += tmr2ticks(tmr_ctr);
181 def_tmr_get_time(
int dev)
190 static int def_tmr_ioctl(
int dev,
unsigned int cmd,
void __user *
arg)
233 ticks_offs += tmr2ticks(tmr_ctr);
245 val = ((curr_tempo * curr_timebase) + 30) / 60;
261 def_tmr_arm(
int dev,
long time)
264 time = curr_ticks + 1;
265 else if (time <= curr_ticks)
268 next_event_time = prev_event_time =
time;
276 .info = {
"System clock", 0},
279 .open = def_tmr_open,
280 .close = def_tmr_close,
281 .event = def_tmr_event,
282 .get_time = def_tmr_get_time,
283 .ioctl = def_tmr_ioctl,
284 .arm_timer = def_tmr_arm