patch-2.1.86 linux/drivers/sound/sound_timer.c

Next file: linux/drivers/sound/soundcard.c
Previous file: linux/drivers/sound/sound_calls.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.85/linux/drivers/sound/sound_timer.c linux/drivers/sound/sound_timer.c
@@ -29,20 +29,17 @@
 
 static struct sound_lowlev_timer *tmr = NULL;
 
-static unsigned long
-tmr2ticks(int tmr_value)
+static unsigned long tmr2ticks(int tmr_value)
 {
 	/*
 	 *    Convert timer ticks to MIDI ticks
 	 */
 
-	unsigned long   tmp;
-	unsigned long   scale;
+	unsigned long tmp;
+	unsigned long scale;
 
 	tmp = tmr_value * usecs_per_tmr;	/* Convert to usecs */
-
 	scale = (60 * 1000000) / (curr_tempo * curr_timebase);	/* usecs per MIDI tick */
-
 	return (tmp + (scale / 2)) / scale;
 }
 
@@ -53,7 +50,7 @@
 	usecs_per_tick = (60 * 1000000) / (curr_tempo * curr_timebase);
 
 	/*
-	   * Don't kill the system by setting too high timer rate
+	 * Don't kill the system by setting too high timer rate
 	 */
 	if (usecs_per_tick < 2000)
 		usecs_per_tick = 2000;
@@ -61,22 +58,19 @@
 	usecs_per_tmr = tmr->tmr_start(tmr->dev, usecs_per_tick);
 }
 
-void
-sound_timer_syncinterval(unsigned int new_usecs)
+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.
- */
+	/*
+	 *    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;
 }
 
-static void
-tmr_reset(void)
+static void tmr_reset(void)
 {
 	unsigned long   flags;
 
@@ -91,99 +85,89 @@
 	restore_flags(flags);
 }
 
-static int
-timer_open(int dev, int mode)
+static int timer_open(int dev, int mode)
 {
 	if (opened)
 		return -EBUSY;
-
 	tmr_reset();
 	curr_tempo = 60;
 	curr_timebase = 100;
 	opened = 1;
 	reprogram_timer();
-
 	return 0;
 }
 
-static void
-timer_close(int dev)
+static void timer_close(int dev)
 {
 	opened = tmr_running = 0;
 	tmr->tmr_disable(tmr->dev);
 }
 
-static int
-timer_event(int dev, unsigned char *event)
+static int timer_event(int dev, unsigned char *event)
 {
-	unsigned char   cmd = event[1];
-	unsigned long   parm = *(int *) &event[4];
+	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;
+	{
+		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;
 
-	  default:;
-	  }
+		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 unsigned long
-timer_get_time(int dev)
+static unsigned long timer_get_time(int dev)
 {
 	if (!opened)
 		return 0;
-
 	return curr_ticks;
 }
 
@@ -191,73 +175,80 @@
 {
 	int val;
 
-	switch (cmd) {
-	case SNDCTL_TMR_SOURCE:
-		return __put_user(TMR_INTERNAL, (int *)arg);
-
-	case SNDCTL_TMR_START:
-		tmr_reset();
-		tmr_running = 1;
-		return 0;
+	switch (cmd) 
+	{
+		case SNDCTL_TMR_SOURCE:
+			val = TMR_INTERNAL;
+			break;
+
+		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, (int *)arg))
-			return -EFAULT;
-		if (val) {
-			if (val < 1)
-				val = 1;
-			if (val > 1000)
-				val = 1000;
-			curr_timebase = val;
-		}
-		return __put_user(curr_timebase, (int *)arg);
-
-	case SNDCTL_TMR_TEMPO:
-		if (__get_user(val, (int *)arg))
-			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, (int *)arg);
-
-	case SNDCTL_SEQ_CTRLRATE:
-		if (__get_user(val, (int *)arg))
-			return -EFAULT;
-		if (val != 0)	/* Can't change */
-			return -EINVAL;
-		val = ((curr_tempo * curr_timebase) + 30) / 60;
-		return __put_user(val, (int *)arg);
+		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, (int *)arg))
+				return -EFAULT;
+			if (val) 
+			{
+				if (val < 1)
+					val = 1;
+				if (val > 1000)
+					val = 1000;
+				curr_timebase = val;
+			}
+			val = curr_timebase;
+			break;
+
+		case SNDCTL_TMR_TEMPO:
+			if (get_user(val, (int *)arg))
+				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();
+			}
+			val = curr_tempo;
+			break;
+
+		case SNDCTL_SEQ_CTRLRATE:
+			if (get_user(val, (int *)arg))
+				return -EFAULT;
+			if (val != 0)	/* Can't change */
+				return -EINVAL;
+			val = ((curr_tempo * curr_timebase) + 30) / 60;
+			break;
 		
-	case SNDCTL_SEQ_GETTIME:
-		return __put_user(curr_ticks, (int *)arg);
+		case SNDCTL_SEQ_GETTIME:
+			val = curr_ticks;
+			break;
 		
-	case SNDCTL_TMR_METRONOME:
-		/* NOP */
-		break;
+		case SNDCTL_TMR_METRONOME:
+			/* NOP */
+			break;
 		
-	default:;
+		default:
+			return -EINVAL;
 	}
-	return -EINVAL;
+	return put_user(val, (int *)arg);
 }
 
-static void
-timer_arm(int dev, long time)
+static void timer_arm(int dev, long time)
 {
 	if (time < 0)
 		time = curr_ticks + 1;
@@ -265,7 +256,6 @@
 		return;
 
 	next_event_time = prev_event_time = time;
-
 	return;
 }
 
@@ -282,8 +272,7 @@
 	timer_arm
 };
 
-void
-sound_timer_interrupt(void)
+void sound_timer_interrupt(void)
 {
 	if (!opened)
 		return;
@@ -297,26 +286,24 @@
 	curr_ticks = ticks_offs + tmr2ticks(tmr_ctr);
 
 	if (curr_ticks >= next_event_time)
-	  {
-		  next_event_time = (unsigned long) -1;
-		  sequencer_timer(0);
-	  }
+	{
+		next_event_time = (unsigned long) -1;
+		sequencer_timer(0);
+	}
 }
 
-void 
-sound_timer_init(struct sound_lowlev_timer *t, char *name)
+void  sound_timer_init(struct sound_lowlev_timer *t, char *name)
 {
-	int             n;
+	int n;
 
 	if (initialized)
-	  {
-		  if (t->priority <= tmr->priority)
-			  return;	/* There is already a similar or better timer */
-		  tmr = t;
-		  return;
-	  }
+	{
+		if (t->priority <= tmr->priority)
+			return;	/* There is already a similar or better timer */
+		tmr = t;
+		return;
+	}
 	initialized = 1;
-
 	tmr = t;
 
 	n = sound_alloc_timerdev();

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov