patch-1.3.62 linux/drivers/char/vt.c

Next file: linux/drivers/char/vt_kern.h
Previous file: linux/drivers/char/serial.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.61/linux/drivers/char/vt.c linux/drivers/char/vt.c
@@ -155,10 +155,16 @@
 }
 
 void
-kd_mksound(unsigned int count, unsigned int ticks)
+_kd_mksound(unsigned int hz, unsigned int ticks)
 {
-	static struct timer_list sound_timer = { NULL, NULL, 0, 0, kd_nosound };
+	static struct timer_list sound_timer = { NULL, NULL, 0, 0,
+						 kd_nosound };
 
+	unsigned int count = 0;
+
+	if (hz > 20 && hz < 32767)
+		count = 1193180 / hz;
+	
 	cli();
 	del_timer(&sound_timer);
 	if (count) {
@@ -180,6 +186,8 @@
 	return;
 }
 
+void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
+	
 /*
  * We handle the console-specific ioctl's here.  We allow the
  * capability to modify any console, not just the fg_console. 
@@ -211,22 +219,22 @@
 	case KIOCSOUND:
 		if (!perm)
 			return -EPERM;
-		kd_mksound((unsigned int)arg, 0);
+		kd_mksound(1193180 / (unsigned int) arg, 0);
 		return 0;
 
 	case KDMKTONE:
 		if (!perm)
 			return -EPERM;
 	{
-		unsigned int ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
-
+		unsigned int ticks, count;
+		
 		/*
 		 * Generate the tone for the appropriate number of ticks.
 		 * If the time is zero, turn off sound ourselves.
 		 */
-		kd_mksound(arg & 0xffff, ticks);
-		if (ticks == 0)
-			kd_nosound(0);
+		ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
+		count = ticks ? (1193180 / (arg & 0xffff)) : 0;
+		kd_mksound(count, ticks);
 		return 0;
 	}
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this