static int timer_event(int dev, unsigned char *event) { unsigned char cmd = event[1]; unsigned long parm = *(int *) &event[4]; switch (cmd) { case TMR_WAIT_REL: parm += prev_event_time; case TMR_WAIT_ABS: if (parm > 0) { long time; if (parm <= curr_ticks) /* It's the time */ return TIMER_NOT_ARMED; time = parm; next_event_time = prev_event_time = time; return TIMER_ARMED; } break; case TMR_START: tmr_reset(); tmr_running = 1; reprogram_timer(); break; case TMR_STOP: tmr_running = 0; break; case TMR_CONTINUE: tmr_running = 1; reprogram_timer(); break; case TMR_TEMPO: if (parm) { if (parm < 8) parm = 8; if (parm > 250) parm = 250; tmr_offs = tmr_ctr; ticks_offs += tmr2ticks(tmr_ctr); tmr_ctr = 0; curr_tempo = parm; reprogram_timer(); } break; case TMR_ECHO: seq_copy_to_input(event, 8); break; default:; } return TIMER_NOT_ARMED; }
static void poll_def_tmr(unsigned long dummy) { if (opened) { { def_tmr.expires = (1) + jiffies; add_timer(&def_tmr); }; if (tmr_running) { spin_lock(&lock); tmr_ctr++; curr_ticks = ticks_offs + tmr2ticks(tmr_ctr); if (curr_ticks >= next_event_time) { next_event_time = (unsigned long) -1; sequencer_timer(0); } spin_unlock(&lock); } } }
void sound_timer_syncinterval(unsigned int new_usecs) { /* * This routine is called by the hardware level if * the clock frequency has changed for some reason. */ tmr_offs = tmr_ctr; ticks_offs += tmr2ticks(tmr_ctr); tmr_ctr = 0; usecs_per_tmr = new_usecs; }
void sound_timer_interrupt (void) { if (!opened) return; tmr->tmr_restart (tmr->dev); if (!tmr_running) return; tmr_ctr++; curr_ticks = ticks_offs + tmr2ticks (tmr_ctr); if (curr_ticks >= next_event_time) { next_event_time = (unsigned long) -1; sequencer_timer (0); } }
static void poll_def_tmr (unsigned long dummy) { if (opened) { ACTIVATE_TIMER (def_tmr, poll_def_tmr, 1); if (tmr_running) { tmr_ctr++; curr_ticks = ticks_offs + tmr2ticks (tmr_ctr); if (curr_ticks >= next_event_time) { next_event_time = 0xffffffff; sequencer_timer (); } } } }
void sound_timer_interrupt(void) { unsigned long flags; if (!opened) return; tmr->tmr_restart(tmr->dev); if (!tmr_running) return; spin_lock_irqsave(&lock,flags); tmr_ctr++; curr_ticks = ticks_offs + tmr2ticks(tmr_ctr); if (curr_ticks >= next_event_time) { next_event_time = (unsigned long) -1; sequencer_timer(0); } spin_unlock_irqrestore(&lock,flags); }
/* same as sound_timer.c:timer_ioctl!? */ static int def_tmr_ioctl(int dev, unsigned int cmd, void __user *arg) { int __user *p = arg; int val; switch (cmd) { case SNDCTL_TMR_SOURCE: return __put_user(TMR_INTERNAL, p); case SNDCTL_TMR_START: tmr_reset(); tmr_running = 1; return 0; case SNDCTL_TMR_STOP: tmr_running = 0; return 0; case SNDCTL_TMR_CONTINUE: tmr_running = 1; return 0; case SNDCTL_TMR_TIMEBASE: if (__get_user(val, p)) return -EFAULT; if (val) { if (val < 1) val = 1; if (val > 1000) val = 1000; curr_timebase = val; } return __put_user(curr_timebase, p); case SNDCTL_TMR_TEMPO: if (__get_user(val, p)) return -EFAULT; if (val) { if (val < 8) val = 8; if (val > 250) val = 250; tmr_offs = tmr_ctr; ticks_offs += tmr2ticks(tmr_ctr); tmr_ctr = 0; curr_tempo = val; reprogram_timer(); } return __put_user(curr_tempo, p); case SNDCTL_SEQ_CTRLRATE: if (__get_user(val, p)) return -EFAULT; if (val != 0) /* Can't change */ return -EINVAL; val = ((curr_tempo * curr_timebase) + 30) / 60; return __put_user(val, p); case SNDCTL_SEQ_GETTIME: return __put_user(curr_ticks, p); case SNDCTL_TMR_METRONOME: /* NOP */ break; default:; } return -EINVAL; }
static int timer_ioctl (int dev, unsigned int cmd, caddr_t arg) { switch (cmd) { case SNDCTL_TMR_SOURCE: return snd_ioctl_return ((int *) arg, TMR_INTERNAL); break; case SNDCTL_TMR_START: tmr_reset (); tmr_running = 1; return 0; break; case SNDCTL_TMR_STOP: tmr_running = 0; return 0; break; case SNDCTL_TMR_CONTINUE: tmr_running = 1; return 0; break; case SNDCTL_TMR_TIMEBASE: { int val = get_fs_long ((long *) arg); if (val) { if (val < 1) val = 1; if (val > 1000) val = 1000; curr_timebase = val; } return snd_ioctl_return ((int *) arg, curr_timebase); } break; case SNDCTL_TMR_TEMPO: { int val = get_fs_long ((long *) arg); if (val) { if (val < 8) val = 8; if (val > 250) val = 250; tmr_offs = tmr_ctr; ticks_offs += tmr2ticks (tmr_ctr); tmr_ctr = 0; curr_tempo = val; reprogram_timer (); } return snd_ioctl_return ((int *) arg, curr_tempo); } break; case SNDCTL_SEQ_CTRLRATE: if (get_fs_long ((long *) arg) != 0) /* Can't change */ return -(EINVAL); return snd_ioctl_return ((int *) arg, ((curr_tempo * curr_timebase) + 30) / 60); break; case SNDCTL_TMR_METRONOME: /* NOP */ break; default:; } return -(EINVAL); }
static int def_tmr_ioctl (int dev, unsigned int cmd, unsigned int arg) { switch (cmd) { case SNDCTL_TMR_SOURCE: return IOCTL_OUT (arg, TMR_INTERNAL); break; case SNDCTL_TMR_START: tmr_reset (); tmr_running = 1; return 0; break; case SNDCTL_TMR_STOP: tmr_running = 0; return 0; break; case SNDCTL_TMR_CONTINUE: tmr_running = 1; return 0; break; case SNDCTL_TMR_TIMEBASE: { int val = IOCTL_IN (arg); if (val) { if (val < 1) val = 1; if (val > 1000) val = 1000; curr_timebase = val; } return IOCTL_OUT (arg, curr_timebase); } break; case SNDCTL_TMR_TEMPO: { int val = IOCTL_IN (arg); if (val) { if (val < 8) val = 8; if (val > 250) val = 250; tmr_offs = tmr_ctr; ticks_offs += tmr2ticks (tmr_ctr); tmr_ctr = 0; curr_tempo = val; } return IOCTL_OUT (arg, curr_tempo); } break; case SNDCTL_SEQ_CTRLRATE: if (IOCTL_IN (arg) != 0) /* Can't change */ return RET_ERROR (EINVAL); return IOCTL_OUT (arg, ((curr_tempo * curr_timebase) + 30) / 60); break; case SNDCTL_TMR_METRONOME: /* NOP */ break; default:; } return RET_ERROR (EINVAL); }