Commit 2c4e9671 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Dmitry Torokhov

Input: use PIT_TICK_RATE in vt beep ioctl

The KIOCSOUND and KDMKTONE ioctls are based on the CLOCK_TICK_RATE,
which is architecture and sometimes configuration specific.

In practice, most user applications assume that it is actually defined
as the i8253 PIT base clock of 1193182 Hz, which is true on some
architectures but not on others.

This patch makes the vt code use the PIT frequency on all
architectures, which is much more well-defined.  It will change the
behavior of user applications sending the beep ioctl on all
architectures that define CLOCK_TICK_RATE different from
PIT_TICK_RATE.

The original breakage was introduced in commit bcc8ca09 "Adapt
drivers/char/vt_ioctl.c to non-x86".  Hopefully, reverting this change
will make the frequency correct in more cases than it will make it
incorrect.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAlan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent d9f66c1a
...@@ -533,11 +533,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -533,11 +533,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
case KIOCSOUND: case KIOCSOUND:
if (!perm) if (!perm)
goto eperm; goto eperm;
/* FIXME: This is an old broken API but we need to keep it /*
supported and somehow separate the historic advertised * The use of PIT_TICK_RATE is historic, it used to be
tick rate from any real one */ * the platform-dependent CLOCK_TICK_RATE between 2.6.12
* and 2.6.36, which was a minor but unfortunate ABI
* change.
*/
if (arg) if (arg)
arg = CLOCK_TICK_RATE / arg; arg = PIT_TICK_RATE / arg;
kd_mksound(arg, 0); kd_mksound(arg, 0);
break; break;
...@@ -553,11 +556,8 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -553,11 +556,8 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
*/ */
ticks = HZ * ((arg >> 16) & 0xffff) / 1000; ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
count = ticks ? (arg & 0xffff) : 0; count = ticks ? (arg & 0xffff) : 0;
/* FIXME: This is an old broken API but we need to keep it
supported and somehow separate the historic advertised
tick rate from any real one */
if (count) if (count)
count = CLOCK_TICK_RATE / count; count = PIT_TICK_RATE / count;
kd_mksound(count, ticks); kd_mksound(count, ticks);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment