Skip to contentSkip to conversation

drivers/accessibility: audio feedback as characters are generated

PATCH New Karl Dahlke 1 participant 1 message Dec 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/accessibility: audio feedback as characters are generated

From: Karl Dahlke <[email protected]>

This module generates soft clicks as printable characters are sent to the foreground tty.
These sounds simulate an old fashion teletype running at 2400 baud. This serves as valuable feedback for a blind user,
even if speech or braille is not working.
And there are many reasons why speech or brail might not function. With clicks alone, it is possible to log in and issue some commands in an attempt to get speech working again.
Also, these clicks throttle the output, so that screen after screen does not fly by before the blind user can hit control S
and find out what is happening.
A separate sequence of tones indicates a printk message, like an audible alarm. These sounds can be turned on and off by a master switch at runtime.

---

This module depends on the additional kd sounds that are in the patch I submitted earlier with subject
[PATCH] drivers/input/misc: new PC speaker sounds, clicks and notes In fact this patch will not build without the kd patch.
I kept them separate however because they are logically different. The kd patch is a general enhancement to the pc speaker sounds
of the kernel, which anyone can use for any purpose, even games. This is specifically an accessibility module that happens to use those sounds.

This code passes checkpatch.pl, and has been exercised (in some form) for years, going back to the 2.2 kernel series.
Thank you for your review and consideration.

Documentation/accessibility/ttyclicks.txt +160 -0
diff -uprN a/Documentation/accessibility/ttyclicks.txt b/Documentation/accessibility/ttyclicks.txt
@@ -0,0 +1,160 @@
+
+The tty clicks module
+			---------------------
+			Karl Dahlke
+			[email protected]
+
+When this module is installed, soft clicks accompany
+the nonspace characters that are sent to the console,
+while a longer swoop indicates a newline character.
+These sounds simulate an old fashion teletype (how many of you are old enough
+to remember those) running at 2400 baud.
+Why would you want such a thing?
+You probably wouldn't, but a blind person might.
+
+I can tell, by clicks alone, when the computer responds to a command,
+and I can discern the quantity and format of that response,
+without any speech or braille.
+In addition, the output is throttled, and does not fly by the screen
+in a flash, faster than I could possibly hit control S.
+
+It is important that this be a separate, stand alone kernel module
+that does not depend on anything else.
+If the adapter isn't running,
+if the synthesizer isn't working, if the braille display isn't working,
+if we're talking to the wrong serial port, if the sound card isn't working,
+if the sound card is not properly initialized,
+if the sound module is not loaded, if the wrong sound module is loaded,
+if an essential daemon is not running - at least I have my clicks.
+I can tell, to some degree, what the computer is doing.
+If it gets to a login prompt, I know what that sounds like.
+I can log in and listen for the single click of the $ prompt,
+which tells me I have a shell.
+Then I can issue some basic commands,
+trying to load modules and start the adapter.
+All this I do without speech.
+I need these clicks to be present whenever the kernel is running.
+To this end, ttyclicks is a self-contained module
+that is loaded first in the boot sequence,
+quite apart from any adapters.
+I can turn off the clicks at run time if I wish,
+but if the synthesizer ever fails me, for any reason,
+I have the clicks to fall back on.
+
+As you can see from the above paragraph,
+I don't want to run these clicks through anybody's sound card.
+There are too many points of failure along that path.
+Instead, I use the in-built toggle speaker at port 0x61.
+Not all machines have this speaker, but most do,
+and I wouldn't buy a computer that didn't.
+
+Other programs, outside of the linux kernel, can also take advantage of
+this legacy speaker.
+Grub, for instance, beeps when it brings up the menu,
+provided I put a control G in the title.
+This tells me that I have ten seconds to cursor up and down
+and select a target, if I want something other than the default.
+Beyound this, it tells me that the machine has gotten to grub successfully,
+and is not stuck in bios for some bizarre reason.
+It is difficult to overstate the importance of this little in-built speaker
+for the blind user.
+
+This module might not click and chirp if you are in X.
+It responds to text characters that pass through the standard tty,
+and probably doesn't do anything in graphics mode.
+Even the terminal emulator, running under a desktop, still runs through X,
+and probably won't work with ttyclicks.
+You really need to be at run level 3.
+See /etc/inittab for the run level.
+This module is for command line users,
+or users who will stay in command mode long enough to make sure their
+software is properly launched and speaking.
+
+Module parameters:
+
+As always, you can run modinfo ttyclicks.ko to review these parameters.
+
+enabled = 1 or 0
+
+If 1, then sounds are enabled as soon as the module is loaded.
+If 0, then sounds are not enabled.
+These sounds can be turned on or off at run time by the exported symbol
+	bool ttyclicks_on;
+Thus other modules can turn sounds on or off.
+In particular, any adapter that includes a lodable module
+has access to this master switch.
+
+fgtty = 1 or 0
+
+This parameter enables the clicks that accompany the display of characters
+from  the foreground tty.
+The corresponding exported symbol is
+	bool ttyclicks_tty;
+
+kmsg = 1 or 0
+
+Printk messages do not pass through the tty,
+and do not generate the aforementioned clicks.
+However, if this switch is enabled,
+each printk message generates a distinctive sequence of tones.
+This is like an alarm,
+telling the user that he needs to read the message on the screen.
+The corresponding exported symbol is
+	bool ttyclicks_kmsg;
+
+cursormotion = 0 or 1
+
+Many screen programs generate ansi escape sequences that position the cursor
+and set character attributes such as underline etc.
+This is not true output, and does not generate clicks by default.
+However, you can set this parameter to 1 if you want these characters
+to generate clicks.
+
+Exported functions.
+These are all subject to the master switch ttyclicks_on.
+
+void ttyclicks_click(void);
+
+Generate a 0.6 millisecond pulse.
+
+void ttyclicks_cr(void);
+
+Generate a quick frequency swoop from 2900 to 3600 hz.
+This sound is associated with the newline character at the console,
+but you can use this function to generate the same sound whenever you wish.
+
+void ttyclicks_notes(const short *notelist);
+
+Play a series of notes in the background.
+Each note is defined by two shorts, a frequency and a duration.
+The frequency is in hurtz, and the duration is in hundredths of a second.
+A frequency of -1 is a rest.
+A frequency of 0 terminates the array.
+The queue can only hold 64 notes, so don't try to play an entire sonata.
+
+void ttyclicks_steps(int freq1, int freq2, int step, int duration)
+
+Play a series of notes, of the specified duration, moving from
+frequency freq1 to frequency freq2 in a geometric progression of step%.
+This is a customizable chromatic scale.
+The traditional scale, based on half tones, and starting at middle C,
+has an approximate step of 6%, and looks like this.
+ttyclicks_mksteps(260, 530, 6, 150);
+Use a negative step for a descending scale.
+
+void ttyclicks_bell(void);
+
+This function generates an 1800 hz tone for a tenth of a second.
+this is associated with the control G bell.
+The traditional bell is 1000 hz, but I wanted a slightly higher tone.
+As long as this module is loaded, it swallows control G, and sounds the bell,
+rather then passing it through to the console and letting the console
+ring the bell.  This allows the master switch, ttyclicks_on,
+to enable or disable the control G bell along with all the other sounds.
+You can turn off all the sounds in one go, if they are bothering your roommate.
+
+This module is integral to many command line adapters,
+as a complement to speech or braille.  Beyond this,
+it can prove invaluable if the adapter is not working for any reason.
+I have relied on this form of audio feedback, in some form or another,
+for over 30 years.
drivers/accessibility/Kconfig +15 -0
diff -uprN a/drivers/accessibility/Kconfig b/drivers/accessibility/Kconfig
@@ -30,4 +30,19 @@ config A11Y_BRAILLE_CONSOLE
 
 	  If unsure, say N.
 
+config TTYCLICKS
+	tristate "tty clicks"
+	---help---
+	Generate clicks, using the pc speaker, as characters are sent
+	to the foreground console.  The sound is similar to an old style
+	teletype running at 2400 baud.
+	This provides audio feedback to a blind user,
+	even if speech or braille is not available.
+	It also throttles the output, so that screen after screen of text
+	does not fly by before the blind user has a chance to hit control s
+	and find out what is happening.
+	See Documentation/accessibility/ttyclicks.txt for more details.
+
+	  If unsure, say N.
+
 endif # ACCESSIBILITY
drivers/accessibility/Makefile +2 -0
diff -uprN a/drivers/accessibility/Makefile b/drivers/accessibility/Makefile
@@ -1 +1,3 @@
 obj-y				+= braille/
+
+obj-$(CONFIG_TTYCLICKS) += ttyclicks.o
drivers/accessibility/ttyclicks.c +409 -0

409 lines not on this page · raw message

include/linux/ttyclicks.h +17 -0
diff -uprN a/include/linux/ttyclicks.h b/include/linux/ttyclicks.h
@@ -0,0 +1,17 @@
+#ifndef _LINUX_TTYCLICKS_H
+#define _LINUX_TTYCLICKS_H
+
+/* External prototypes for ttyclicks.c */
+/* See Documentation/accessibility/ttyclicks.txt for documentation. */
+
+extern bool ttyclicks_on;	/* speaker sounds activated */
+extern bool ttyclicks_tty;	/* speaker sounds from tty */
+extern bool ttyclicks_kmsg;	/* speaker sounds from kernel message */
+
+void ttyclicks_click(void);
+void ttyclicks_cr(void);
+void ttyclicks_bell(void);
+void ttyclicks_notes(const short *notelist);
+void ttyclicks_steps(int start, int end, int step, int duration);
+
+#endif