Bug 24503 - keyboard bell stopped working with xorg-server 1.7.0
Summary: keyboard bell stopped working with xorg-server 1.7.0
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: low minor
Assignee: Peter Hutterer
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-13 09:44 UTC by Rafał Mużyło
Modified: 2010-02-24 15:09 UTC (History)
8 users (show)

See Also:
i915 platform:
i915 features:


Attachments
testcase (183 bytes, text/plain)
2009-12-10 07:34 UTC, Rafał Mużyło
no flags Details
Rings the bell on an evdev kernel device. (1.28 KB, text/plain)
2010-01-08 22:17 UTC, Kusanagi Kouichi
no flags Details
0001-Implement-support-for-keyboard-bells.patch (3.68 KB, patch)
2010-01-11 20:25 UTC, Peter Hutterer
no flags Details | Splinter Review
0001-dix-try-to-ring-the-bell-even-if-the-current-device-.patch (1.60 KB, patch)
2010-02-14 22:40 UTC, Peter Hutterer
no flags Details | Splinter Review

Description Rafał Mużyło 2009-10-13 09:44:03 UTC
I suspect it may simply be a configuration problem,
but as it didn't need any special setting before,
I'm not sure where to look.

After I upgraded from xorg-server 1.6.3 to 1.7.0
for some reason keyboard bell stopped working,
meaning I can no longer hear it.

Driver used: xf86-input-evdev.
xkeyboard-config 1.6
Comment 1 Igor Durdanovic 2009-12-06 19:52:11 UTC
I have a similar problem, after upgrading from 1.5.3 (fedora 10) to 1.7.1 (fedora 12) the BELL (ascii 7, e.g. executing echo -e "\a") stopped working on /dev/pts/X.

However, if I attach to the same X session/display via VNC, the BELL works!?

Shouldn't it be reversed, the remote (VNC) should not be able to trigger local beep and the local should.
Comment 2 Rafał Mużyło 2009-12-10 07:34:25 UTC
Created attachment 31942 [details]
testcase

This test program is enough to trigger the problem:
for some reason XBell doesn't work.
However, XkbBell does.
Comment 3 Igor Durdanovic 2009-12-10 07:53:29 UTC
Rafał, can you vnc to the display from the outside and check if the XBell() suddenly works? I find it weird that it works under vnc on my side.
Comment 4 Leonid Isaev 2009-12-15 14:50:41 UTC
Well, my bell works in GViM/Firefox, but not in xterm. However, the bell parameters can not be changed with xset. Also, xkbbell -force does produce a beep.
I use ArchLinux with xorg-server 1.7.3.
Comment 5 Rafał Mużyło 2009-12-15 18:58:09 UTC
(In reply to comment #4)
> Also, xkbbell -force does produce a
> beep.
I already said that - xkbbell uses XkbBell,
while i.e. rxvt-unicode (probably xterm too) uses XBell.
Comment 6 Peter Hutterer 2009-12-15 21:58:27 UTC
are you using the kbd driver or evdev only?
evdev doesn't seem to set up the BellProc so I'm not sure how that test program could work (didn't work on my evdev-only box). The difference between XBell and XkbBell makes sense, that's fixable though.
Comment 7 Rafał Mużyło 2009-12-16 05:48:51 UTC
I'm using evdev only.

Well, that could explain the difference with vnc
- IIRC, it's lacking a certain X extension,
so it can't use evdev properly and falls back to the old driver.
Comment 8 Alan Coopersmith 2009-12-16 08:08:11 UTC
(In reply to comment #7)
> I'm using evdev only.
> 
> Well, that could explain the difference with vnc
> - IIRC, it's lacking a certain X extension,
> so it can't use evdev properly and falls back to the old driver.

Xvnc doesn't use any keyboard driver since it doesn't talk to the local
keyboard.   It's keyboard input all comes over the RFB protocol from 
the vncviewer client.

Comment 9 Peter Hutterer 2009-12-16 15:55:10 UTC
I've had a play at trying to add keyboard bell support to evdev but failed. The code, though similar to what the ioctl does in the keyboard driver doesn't seem to make a sound. Any help there would be appreciated (especially a test program that rings the bell on an evdev kernel device).

Meanwhile, reducing priority a bit, without your help I won't be able to spend much time on this.
Comment 10 Rafał Mużyło 2009-12-17 03:06:56 UTC
So, why does XkbBell still work ?
Is that implemented in the server ?
Comment 11 Peter Hutterer 2009-12-17 03:23:31 UTC
On Thu, Dec 17, 2009 at 03:06:57AM -0800, bugzilla-daemon@freedesktop.org wrote:
> --- Comment #10 from Rafał Mużyło <galtgendo@o2.pl>  2009-12-17 03:06:56 PST ---
> So, why does XkbBell still work ?
> Is that implemented in the server ?

tbh, I don't know but when I ran the test program neither triggered the bell
(probably some local setting, I've never had a need for the keyboard bell)
Comment 12 Rafał Mużyło 2009-12-17 05:13:23 UTC
In that case, 'xset q' reports:
bell percent:  50    bell pitch:  400    bell duration:  100
Not sure if it matters, but for the moment can't think about
a different setting.

Do you have pc speaker among your kernel input devices ?
If you don't, perhaps that's a reason for the missing bell
in XkbBell case.
Comment 13 Peter Hutterer 2009-12-17 22:11:43 UTC
i ran modprobe pcspkr and managed to make the terminal beep somehow, but not
the test program.
Comment 14 Rafał Mużyło 2009-12-18 01:57:26 UTC
Just so we're on the same page
- that test program doesn't beep with XBell,
but if you switch comments, it does with XkbBell.
Comment 15 Peter Hutterer 2009-12-18 02:10:00 UTC
well, that's the theory. in practice, neither is ringing anything :)
Comment 16 Alan Coopersmith 2009-12-18 07:21:28 UTC
Note that some desktops will intercept XkbBell() calls to play sounds
themselves (I've seen this in GNOME 2.28 with gnome sound themes for
instance).
Comment 17 Rafał Mużyło 2009-12-18 12:17:04 UTC
Perhaps it's a matter of a mainboard/soundcard.
All I've got is intel8x0 - it needs nothing but pcspkr (INPUT_PCSPKR).
For HDA there's a SND_HDA_INPUT_BEEP_MODE kernel setting,
that *may* affect this problem (OK, so I'm grasping at straws).
Comment 18 Leonid Isaev 2009-12-18 13:00:14 UTC
(In reply to comment #17)
> Perhaps it's a matter of a mainboard/soundcard.
> All I've got is intel8x0 - it needs nothing but pcspkr (INPUT_PCSPKR).
> For HDA there's a SND_HDA_INPUT_BEEP_MODE kernel setting,
> that *may* affect this problem (OK, so I'm grasping at straws).
> 

Are you sure it's SND_HDA_INPUT_BEEP_MODE? Because I have only CONFIG_SND_HDA_INPUT_BEEP=y in /proc/config.gz. Anyway, disabling it does nothing on my IHC5 intel card.
Also, I don't understand why xset does not work?

(In reply to comment #5)
>I already said that - xkbbell uses XkbBell,
>while i.e. rxvt-unicode (probably xterm too) uses XBell.

I was just confirming ;)
Comment 19 Kusanagi Kouichi 2010-01-08 22:17:15 UTC
Created attachment 32540 [details]
Rings the bell on an evdev kernel device.

(In reply to comment #9)
> I've had a play at trying to add keyboard bell support to evdev but failed. The
> code, though similar to what the ioctl does in the keyboard driver doesn't seem
> to make a sound. Any help there would be appreciated (especially a test program
> that rings the bell on an evdev kernel device).
> 
> Meanwhile, reducing priority a bit, without your help I won't be able to spend
> much time on this.

I hope this helps you.
Comment 20 Rafał Mużyło 2010-01-09 04:54:10 UTC
For me, this code works only on pcspkr, not keyboard.
But if the settings are the same as 'xset q' reports (f=400),
sound is correct (root only, as root owns those devices).
Comment 21 Rafał Mużyło 2010-01-10 12:24:11 UTC
To add to confusion: even in X, "printf '\a' > /dev/tty0"
does generate a beep.
Comment 22 Peter Hutterer 2010-01-11 20:25:32 UTC
Created attachment 32581 [details] [review]
0001-Implement-support-for-keyboard-bells.patch

something like this should work then. note that this patch is completely untested, it only compiles.
we should also set a timer for when the duration exceeds certain values, but that's a bit more complicated and I'd rather check back first whether this approach works.
Comment 23 Rafał Mużyło 2010-01-12 11:57:27 UTC
Well, the bell's there (at least with xorg-server default settings).
Comment 24 Kusanagi Kouichi 2010-01-12 20:56:42 UTC
If EvdevBellProc is passed to InitKeyboardDeviceStruct, bell rings.
However, it seems that EvdevBellProc is not called.
Even if EvdevBellProc is empty, bell rings.
Comment 25 Rafał Mużyło 2010-01-13 11:33:17 UTC
I think it may somehow be related to
ProcBell in dix/devices returning Success
without actually doing anything if BellProc is NULL

Do you want to say even a BellProc like
'static foo(int percent, DeviceIntPtr dev, pointer ctrl, int class) {}' works ?
Comment 26 Peter Hutterer 2010-01-13 15:15:44 UTC
> I think it may somehow be related to
> ProcBell in dix/devices returning Success
> without actually doing anything if BellProc is NULL
> 
> Do you want to say even a BellProc like
> 'static foo(int percent, DeviceIntPtr dev, pointer ctrl, int class) {}' works ?

The protocol only allows for a BadValue error in case the value range is
outside [-100,100]. There is nothing in the protocol to accommodate for a
nonexisting bell, so we must return Success in this case.
Comment 27 Rafał Mużyło 2010-01-29 17:54:27 UTC
Anyway, just as comment 24 says, an empty EvdevBellProc
is enough to make bell work.
Comment 28 Peter Hutterer 2010-01-31 23:38:49 UTC
> --- Comment #27 from Rafał Mużyło <galtgendo@o2.pl>  2010-01-29 17:54:27 PST ---
> Anyway, just as comment 24 says, an empty EvdevBellProc
> is enough to make bell work.

heh. funny. care to submit a patch?
Comment 29 Rafał Mużyło 2010-02-01 05:45:52 UTC
(In reply to comment #28)
> 
> heh. funny. care to submit a patch?
> 

Not sure, what did you meant by that.
I simply tried your patch with an empty EvdevBellProc
(perhaps it can be simplified even a bit more, can't really tell).
AFAICT, if that function is not NULL, default server bell is called,
that simply writes \07 to console fd - that's enough for me.
Comment 30 Peter Hutterer 2010-02-02 22:35:56 UTC
On Mon, Feb 01, 2010 at 05:45:53AM -0800, bugzilla-daemon@freedesktop.org wrote:
> Not sure, what did you meant by that.
> I simply tried your patch with an empty EvdevBellProc
> (perhaps it can be simplified even a bit more, can't really tell).

That's enough then, if that works for you submit this as a patch please. I
don't have a lot of time to test and since you already got it working on
your box, that's enough for me.
Comment 31 Rafał Mużyło 2010-02-12 08:49:34 UTC
(In reply to comment #30)
> On Mon, Feb 01, 2010 at 05:45:53AM -0800, bugzilla-daemon@freedesktop.org
> wrote:
> 
> That's enough then, if that works for you submit this as a patch please. I
> don't have a lot of time to test and since you already got it working on
> your box, that's enough for me.
> 

But aren't you one of the people with write access to evdev git ?

After all, it's your patch, with just a one block removed
(and I'm still not sure if more trimming can be done
- I know very little about xorg-server internals).
Comment 32 Peter Hutterer 2010-02-14 22:34:24 UTC
Alright, I think I found why.

The core keyboard is set up with a bell proc initially but that gets overwritten once you hit a key. The idea here is that the device copies the bell proc into the master device so if a client rings the bell it rings it on the last device used.

If that device doesn't have a bell proc, the function exits early. If that device does have a bell proc, then that function is called (noop in this case) but the function is also called for all other devices that are attached to this device. One of these devices is the XTEST keyboard that has the bell proc set and eventually calls through to xf86OSRingBell which I guess is what produces the sound.

That also explains why XkbBell works but XBell doesn't - XkbBell always loops through all devices.

Comment 33 Peter Hutterer 2010-02-14 22:40:30 UTC
Created attachment 33303 [details] [review]
0001-dix-try-to-ring-the-bell-even-if-the-current-device-.patch

x server patch to replicate the XKB behaviour.
Comment 34 Peter Hutterer 2010-02-17 17:26:38 UTC
ping? any testing successes so far?
Comment 35 Rafał Mużyło 2010-02-18 04:21:51 UTC
Sorry, I thought it's a patch that already went
into master.

Yes, this solution works too.

On a not really related note:
how far you, people, still care about 32bit ?
Cause warnings like "warning: cast from pointer to integer of different size"
(xorg-server 1.7.5) start to make me worried.
Perhaps those particular ones are harmless, but still
give a bit sloppy feeling.
Comment 36 Peter Hutterer 2010-02-18 14:02:59 UTC
> Yes, this solution works too.

thanks for testing!

> On a not really related note:
> how far you, people, still care about 32bit ?
> Cause warnings like "warning: cast from pointer to integer of different size"
> (xorg-server 1.7.5) start to make me worried.
> Perhaps those particular ones are harmless, but still
> give a bit sloppy feeling.

where is this? I'm on 32 bit most of the time, so usually I try to catch
those but some slip through. These warnings should be fixed but please send
me a private email on this (or to xorg-devel) to avoid flooding the
bugreport with unrelated info.
Comment 37 Peter Hutterer 2010-02-24 15:09:42 UTC
Fixed, thanks to all for your help with this bug.

commit 758f6971750ed507e64eee817d720a77181439f2
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Feb 15 16:32:16 2010 +1000

    dix: try to ring the bell even if the current device doesn't have one. (#24503)


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.