mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 07:01:32 +00:00
Staging: add speakup to the staging directory
Speakup is a kernel based screen review package for the linux operating system. It allows blind users to interact with applications on the linux console by means of synthetic speech. The authors and maintainers of this code include the following: Kirk Reiser, Andy Berdan, John Covici, Brian and David Borowski, Christopher Brannon, Samuel Thibault and William Hubbs. Signed-off-by: William Hubbs <w.d.hubbs@gmail.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
e59fe083f6
commit
c6e3fd22cd
@ -173,5 +173,7 @@ source "drivers/staging/ft1000/Kconfig"
|
||||
|
||||
source "drivers/staging/intel_sst/Kconfig"
|
||||
|
||||
source "drivers/staging/speakup/Kconfig"
|
||||
|
||||
endif # !STAGING_EXCLUDE_BUILD
|
||||
endif # STAGING
|
||||
|
@ -67,3 +67,4 @@ obj-$(CONFIG_USB_ENESTORAGE) += keucr/
|
||||
obj-$(CONFIG_BCM_WIMAX) += bcm/
|
||||
obj-$(CONFIG_FT1000) += ft1000/
|
||||
obj-$(CONFIG_SND_INTEL_SST) += intel_sst/
|
||||
obj-$(CONFIG_SPEAKUP) += speakup/
|
||||
|
46
drivers/staging/speakup/DefaultKeyAssignments
Normal file
46
drivers/staging/speakup/DefaultKeyAssignments
Normal file
@ -0,0 +1,46 @@
|
||||
This file is intended to give you an overview of the default keys used
|
||||
by speakup for it's review functions. You may change them to be
|
||||
anything you want but that will take some familiarity with key
|
||||
mapping.
|
||||
|
||||
We have remapped the insert or zero key on the keypad to act as a
|
||||
shift key. Well, actually as an altgr key. So in the following list
|
||||
InsKeyPad-period means hold down the insert key like a shift key and
|
||||
hit the keypad period.
|
||||
|
||||
KeyPad-8 Say current Line
|
||||
InsKeyPad-8 say from top of screen to reading cursor.
|
||||
KeyPad-7 Say Previous Line (UP one line)
|
||||
KeyPad-9 Say Next Line (down one line)
|
||||
KeyPad-5 Say Current Word
|
||||
InsKeyPad-5 Spell Current Word
|
||||
KeyPad-4 Say Previous Word (left one word)
|
||||
InsKeyPad-4 say from left edge of line to reading cursor.
|
||||
KeyPad-6 Say Next Word (right one word)
|
||||
InsKeyPad-6 Say from reading cursor to right edge of line.
|
||||
KeyPad-2 Say Current Letter
|
||||
InsKeyPad-2 say current letter phonetically
|
||||
KeyPad-1 Say Previous Character (left one letter)
|
||||
KeyPad-3 Say Next Character (right one letter)
|
||||
KeyPad-plus Say Entire Screen
|
||||
InsKeyPad-plus Say from reading cursor line to bottom of screen.
|
||||
KeyPad-Minus Park reading cursor (toggle)
|
||||
InsKeyPad-minus Say character hex and decimal value.
|
||||
KeyPad-period Say Position (current line, position and console)
|
||||
InsKeyPad-period say colour attributes of current position.
|
||||
InsKeyPad-9 Move reading cursor to top of screen (insert pgup)
|
||||
InsKeyPad-3 Move reading cursor to bottom of screen (insert pgdn)
|
||||
InsKeyPad-7 Move reading cursor to left edge of screen (insert home)
|
||||
InsKeyPad-1 Move reading cursor to right edge of screen (insert end)
|
||||
ControlKeyPad-1 Move reading cursor to last character on current line.
|
||||
KeyPad-Enter Shut Up (until another key is hit) and sync reading cursor
|
||||
InsKeyPad-Enter Shut Up (until toggled back on).
|
||||
InsKeyPad-star n<x|y> go to line (y) or column (x). Where 'n' is any
|
||||
allowed value for the row or column for your current screen.
|
||||
KeyPad-/ Mark and Cut screen region.
|
||||
InsKeyPad-/ Paste screen region into any console.
|
||||
|
||||
Hitting any key while speakup is outputting speech will quiet the
|
||||
synth until it has caught up with what is being printed on the
|
||||
console.
|
||||
|
195
drivers/staging/speakup/Kconfig
Normal file
195
drivers/staging/speakup/Kconfig
Normal file
@ -0,0 +1,195 @@
|
||||
menu "Speakup console speech"
|
||||
|
||||
config SPEAKUP
|
||||
depends on VT
|
||||
tristate "Speakup core"
|
||||
---help---
|
||||
This is the Speakup screen reader. Think of it as a
|
||||
video console for blind people. If built in to the
|
||||
kernel, it can speak everything on the text console from
|
||||
boot up to shutdown. For more information on Speakup,
|
||||
point your browser at http://www.linux-speakup.org/.
|
||||
There is also a mailing list at the above url that you
|
||||
can subscribe to.
|
||||
|
||||
Supported synthesizers are accent sa, accent pc,
|
||||
appollo II., Auddapter, Braille 'n Speak, Dectalk
|
||||
external (old), Dectalk PC (full length isa board),
|
||||
Dectalk express, Doubletalk, Doubletalk LT or
|
||||
Litetalk, Keynote Gold internal PC, software
|
||||
synthesizers, Speakout, transport, and a dummy module
|
||||
that can be used with a plain text terminal.
|
||||
|
||||
Speakup can either be built in or compiled as a module
|
||||
by answering y or m. If you answer y here, then you
|
||||
must answer either y or m to at least one of the
|
||||
synthesizer drivers below. If you answer m here, then
|
||||
the synthesizer drivers below can only be built as
|
||||
modules.
|
||||
|
||||
These drivers are not standalone drivers, but must be
|
||||
used in conjunction with Speakup. Think of them as
|
||||
video cards for blind people.
|
||||
|
||||
|
||||
The Dectalk pc driver can only be built as a module, and
|
||||
requires software to be pre-loaded on to the card before
|
||||
the module can be loaded. See the decpc choice below
|
||||
for more details.
|
||||
|
||||
If you are not a blind person, or don't have access to
|
||||
one of the listed synthesizers, you should say n.
|
||||
|
||||
if SPEAKUP
|
||||
config SPEAKUP_SYNTH_ACNTSA
|
||||
tristate "Accent SA synthesizer support"
|
||||
---help---
|
||||
This is the Speakup driver for the Accent SA
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_ACNTPC
|
||||
tristate "Accent PC synthesizer support"
|
||||
---help---
|
||||
This is the Speakup driver for the accent pc
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_APOLLO
|
||||
tristate "Apollo II synthesizer support"
|
||||
---help---
|
||||
This is the Speakup driver for the Apollo II
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_AUDPTR
|
||||
tristate "Audapter synthesizer support"
|
||||
---help---
|
||||
This is the Speakup driver for the Audapter synthesizer.
|
||||
You can say y to build it into the kernel, or m to
|
||||
build it as a module. See the configuration help on the
|
||||
Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_BNS
|
||||
tristate "Braille 'n' Speak synthesizer support"
|
||||
---help---
|
||||
This is the Speakup driver for the Braille 'n' Speak
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_DECTLK
|
||||
tristate "DECtalk Express synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the DecTalk Express
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_DECEXT
|
||||
tristate "DECtalk External (old) synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the DecTalk External
|
||||
(old) synthesizer. You can say y to build it into the
|
||||
kernel, or m to build it as a module. See the
|
||||
configuration help on the Speakup choice above for more
|
||||
info.
|
||||
|
||||
config SPEAKUP_SYNTH_DECPC
|
||||
depends on m
|
||||
tristate "DECtalk PC (big ISA card) synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the DecTalk PC (full
|
||||
length ISA) synthesizer. You can say m to build it as
|
||||
a module. See the configuration help on the Speakup
|
||||
choice above for more info.
|
||||
|
||||
In order to use the DecTalk PC driver, you must download
|
||||
the dec_pc.tgz file from linux-speakup.org. It is in
|
||||
the pub/linux/goodies directory. The dec_pc.tgz file
|
||||
contains the software which must be pre-loaded on to the
|
||||
DecTalk PC board in order to use it with this driver.
|
||||
This driver must be built as a module, and can not be
|
||||
loaded until the file system is mounted and the DecTalk
|
||||
PC software has been pre-loaded on to the board.
|
||||
|
||||
See the README file in the dec_pc.tgz file for more
|
||||
details.
|
||||
|
||||
config SPEAKUP_SYNTH_DTLK
|
||||
tristate "DoubleTalk PC synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the internal DoubleTalk
|
||||
PC synthesizer. You can say y to build it into the
|
||||
kernel, or m to build it as a module. See the
|
||||
configuration help on the Speakup choice above for more
|
||||
info.
|
||||
|
||||
config SPEAKUP_SYNTH_KEYPC
|
||||
tristate "Keynote Gold PC synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the Keynote Gold
|
||||
PC synthesizer. You can say y to build it into the
|
||||
kernel, or m to build it as a module. See the
|
||||
configuration help on the Speakup choice above for more
|
||||
info.
|
||||
|
||||
config SPEAKUP_SYNTH_LTLK
|
||||
tristate "DoubleTalk LT/LiteTalk synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the LiteTalk/DoubleTalk
|
||||
LT synthesizer. You can say y to build it into the
|
||||
kernel, or m to build it as a module. See the
|
||||
configuration help on the Speakup choice above for more
|
||||
info.
|
||||
|
||||
config SPEAKUP_SYNTH_SOFT
|
||||
tristate "Userspace software synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the software synthesizer device node. It will
|
||||
register a device /dev/softsynth which midware programs
|
||||
and speech daemons may open and read to provide kernel
|
||||
output to software synths such as espeak, festival,
|
||||
flite and so forth. You can select 'y' or 'm' to have
|
||||
it built-in to the kernel or loaded as a module.
|
||||
|
||||
config SPEAKUP_SYNTH_SPKOUT
|
||||
tristate "Speak Out synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the Speakout synthesizer.
|
||||
You can say y to build it into the kernel, or m to
|
||||
build it as a module. See the configuration help on the
|
||||
Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_TXPRT
|
||||
tristate "Transport synthesizer support"
|
||||
---help---
|
||||
|
||||
This is the Speakup driver for the Transport
|
||||
synthesizer. You can say y to build it into the kernel,
|
||||
or m to build it as a module. See the configuration
|
||||
help on the Speakup choice above for more info.
|
||||
|
||||
config SPEAKUP_SYNTH_DUMMY
|
||||
tristate "Dummy synthesizer driver (for testing)"
|
||||
---help---
|
||||
|
||||
This is a dummy Speakup driver for plugging a mere serial
|
||||
terminal. This is handy if you want to test speakup but
|
||||
don't have the hardware. You can say y to build it into
|
||||
the kernel, or m to build it as a module. See the
|
||||
configuration help on the Speakup choice above for more info.
|
||||
|
||||
endif # SPEAKUP
|
||||
endmenu
|
30
drivers/staging/speakup/Makefile
Normal file
30
drivers/staging/speakup/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_ACNTSA) += speakup_acntsa.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_ACNTPC) += speakup_acntpc.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_APOLLO) += speakup_apollo.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_AUDPTR) += speakup_audptr.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_BNS) += speakup_bns.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_DECTLK) += speakup_dectlk.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_DECEXT) += speakup_decext.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_DECPC) += speakup_decpc.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_DTLK) += speakup_dtlk.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_KEYPC) += speakup_keypc.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_LTLK) += speakup_ltlk.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_SOFT) += speakup_soft.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_SPKOUT) += speakup_spkout.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_TXPRT) += speakup_txprt.o
|
||||
obj-$(CONFIG_SPEAKUP_SYNTH_DUMMY) += speakup_dummy.o
|
||||
|
||||
obj-$(CONFIG_SPEAKUP) += speakup.o
|
||||
speakup-objs := \
|
||||
buffers.o \
|
||||
devsynth.o \
|
||||
i18n.o \
|
||||
fakekey.o \
|
||||
main.o \
|
||||
keyhelp.o \
|
||||
kobjects.o \
|
||||
selection.o \
|
||||
serialio.o \
|
||||
synth.o \
|
||||
thread.o \
|
||||
varhandlers.o
|
47
drivers/staging/speakup/TODO
Normal file
47
drivers/staging/speakup/TODO
Normal file
@ -0,0 +1,47 @@
|
||||
Speakup project home: http://www.linux-speakup.org
|
||||
|
||||
Mailing List: speakup@braille.uwo.ca
|
||||
|
||||
Speakup is a kernel based screen review package for the linux operating
|
||||
system. It allows blind users to interact with applications on the
|
||||
linux console by means of synthetic speech.
|
||||
|
||||
Currently, speakup has several issues we know of.
|
||||
|
||||
The first issue has to do with the way speakup communicates with serial
|
||||
ports. Currently, we communicate directly with the hardware
|
||||
ports. This however conflicts with the standard serial port drivers,
|
||||
which poses various problems. This is also not working for modern hardware
|
||||
such as PCI-based serial ports. Also, there is not a way we can
|
||||
communicate with USB devices. The current serial port handling code is
|
||||
in serialio.c in this directory.
|
||||
|
||||
Some places are currently using in_atomic() because speakup functions
|
||||
are called in various contexts, and a couple of things can't happen
|
||||
in these cases. Pushing work to some worker thread would probably help,
|
||||
as was already done for the serial port driving part.
|
||||
|
||||
There is a duplication of the selection functions in selections.c. These
|
||||
functions should get exported from drivers/char/selection.c (clear_selection
|
||||
notably) and used from there instead.
|
||||
|
||||
The kobjects may have to move to a more proper place in /sys. The
|
||||
discussion on lkml resulted to putting speech synthesizers in the
|
||||
"speech" class, and the speakup screen reader itself into
|
||||
/sys/class/vtconsole/vtcon0/speakup, the nasty path being handled by
|
||||
userland tools.
|
||||
|
||||
Another issue seems to only happen on SMP systems. It seems
|
||||
that text in the output buffer gets garbled because a lock is not set.
|
||||
This bug happens regularly, but no one has been able to find a situation
|
||||
which produces it consistently.
|
||||
|
||||
Patches, suggestions, corrections, etc, are definitely welcome.
|
||||
|
||||
We prefer that you contact us on the mailing list; however, if you do
|
||||
not want to subscribe to a mailing list, send your email to all of the
|
||||
following:
|
||||
|
||||
w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@braille.uwo.ca and
|
||||
samuel.thibault@ens-lyon.org.
|
||||
|
108
drivers/staging/speakup/buffers.c
Normal file
108
drivers/staging/speakup/buffers.c
Normal file
@ -0,0 +1,108 @@
|
||||
#include <linux/console.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
|
||||
#define synthBufferSize 8192 /* currently 8K bytes */
|
||||
|
||||
static u_char synth_buffer[synthBufferSize]; /* guess what this is for! */
|
||||
static u_char *buff_in = synth_buffer;
|
||||
static u_char *buff_out = synth_buffer;
|
||||
static u_char *buffer_end = synth_buffer+synthBufferSize-1;
|
||||
|
||||
/* These try to throttle applications by stopping the TTYs
|
||||
* Note: we need to make sure that we will restart them eventually, which is
|
||||
* usually not possible to do from the notifiers. TODO: it should be possible
|
||||
* starting from linux 2.6.26.
|
||||
*
|
||||
* So we only stop when we know alive == 1 (else we discard the data anyway),
|
||||
* and the alive synth will eventually call start_ttys from the thread context.
|
||||
*/
|
||||
void speakup_start_ttys(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_NR_CONSOLES; i++) {
|
||||
if (speakup_console[i] && speakup_console[i]->tty_stopped)
|
||||
continue;
|
||||
if ((vc_cons[i].d != NULL) && (vc_cons[i].d->vc_tty != NULL))
|
||||
start_tty(vc_cons[i].d->vc_tty);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(speakup_start_ttys);
|
||||
|
||||
static void speakup_stop_ttys(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_NR_CONSOLES; i++)
|
||||
if ((vc_cons[i].d != NULL) && (vc_cons[i].d->vc_tty != NULL))
|
||||
stop_tty(vc_cons[i].d->vc_tty);
|
||||
return;
|
||||
}
|
||||
|
||||
static int synth_buffer_free(void)
|
||||
{
|
||||
int bytesFree;
|
||||
|
||||
if (buff_in >= buff_out)
|
||||
bytesFree = synthBufferSize - (buff_in - buff_out);
|
||||
else
|
||||
bytesFree = buff_out - buff_in;
|
||||
return bytesFree;
|
||||
}
|
||||
|
||||
int synth_buffer_empty(void)
|
||||
{
|
||||
return (buff_in == buff_out);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_buffer_empty);
|
||||
|
||||
void synth_buffer_add(char ch)
|
||||
{
|
||||
if (!synth->alive) {
|
||||
/* This makes sure that we won't stop TTYs if there is no synth
|
||||
* to restart them */
|
||||
return;
|
||||
}
|
||||
if (synth_buffer_free() <= 100) {
|
||||
synth_start();
|
||||
speakup_stop_ttys();
|
||||
}
|
||||
if (synth_buffer_free() <= 1)
|
||||
return;
|
||||
*buff_in++ = ch;
|
||||
if (buff_in > buffer_end)
|
||||
buff_in = synth_buffer;
|
||||
}
|
||||
|
||||
char synth_buffer_getc(void)
|
||||
{
|
||||
char ch;
|
||||
|
||||
if (buff_out == buff_in)
|
||||
return 0;
|
||||
ch = *buff_out++;
|
||||
if (buff_out > buffer_end)
|
||||
buff_out = synth_buffer;
|
||||
return ch;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_buffer_getc);
|
||||
|
||||
char synth_buffer_peek(void)
|
||||
{
|
||||
if (buff_out == buff_in)
|
||||
return 0;
|
||||
return *buff_out;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_buffer_peek);
|
||||
|
||||
void synth_buffer_clear(void)
|
||||
{
|
||||
buff_in = buff_out = synth_buffer;
|
||||
return;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_buffer_clear);
|
92
drivers/staging/speakup/devsynth.c
Normal file
92
drivers/staging/speakup/devsynth.c
Normal file
@ -0,0 +1,92 @@
|
||||
#include <linux/errno.h>
|
||||
#include <linux/miscdevice.h> /* for misc_register, and SYNTH_MINOR */
|
||||
#include <linux/types.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
|
||||
#ifndef SYNTH_MINOR
|
||||
#define SYNTH_MINOR 25
|
||||
#endif
|
||||
|
||||
static int misc_registered;
|
||||
static int dev_opened;
|
||||
|
||||
static ssize_t speakup_file_write(struct file *fp, const char *buffer,
|
||||
size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
size_t count = nbytes;
|
||||
const char *ptr = buffer;
|
||||
int bytes;
|
||||
unsigned long flags;
|
||||
u_char buf[256];
|
||||
if (synth == NULL)
|
||||
return -ENODEV;
|
||||
while (count > 0) {
|
||||
bytes = min_t(size_t, count, sizeof(buf));
|
||||
if (copy_from_user(buf, ptr, bytes))
|
||||
return -EFAULT;
|
||||
count -= bytes;
|
||||
ptr += bytes;
|
||||
spk_lock(flags);
|
||||
synth_write(buf, bytes);
|
||||
spk_unlock(flags);
|
||||
}
|
||||
return (ssize_t) nbytes;
|
||||
}
|
||||
|
||||
static ssize_t speakup_file_read(struct file *fp, char *buf, size_t nbytes, loff_t *ppos)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int speakup_file_open(struct inode *ip, struct file *fp)
|
||||
{
|
||||
if (synth == NULL)
|
||||
return -ENODEV;
|
||||
if (xchg(&dev_opened, 1))
|
||||
return -EBUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int speakup_file_release(struct inode *ip, struct file *fp)
|
||||
{
|
||||
dev_opened = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file_operations synth_fops = {
|
||||
.read = speakup_file_read,
|
||||
.write = speakup_file_write,
|
||||
.open = speakup_file_open,
|
||||
.release = speakup_file_release,
|
||||
};
|
||||
|
||||
static struct miscdevice synth_device = {
|
||||
.minor = SYNTH_MINOR,
|
||||
.name = "synth",
|
||||
.fops = &synth_fops,
|
||||
};
|
||||
|
||||
void speakup_register_devsynth(void)
|
||||
{
|
||||
if (misc_registered != 0)
|
||||
return;
|
||||
/* zero it so if register fails, deregister will not ref invalid ptrs */
|
||||
if (misc_register(&synth_device))
|
||||
pr_warn("Couldn't initialize miscdevice /dev/synth.\n");
|
||||
else {
|
||||
pr_info("initialized device: /dev/synth, node (MAJOR %d, MINOR %d)\n", MISC_MAJOR, SYNTH_MINOR);
|
||||
misc_registered = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void speakup_unregister_devsynth(void)
|
||||
{
|
||||
if (!misc_registered)
|
||||
return;
|
||||
pr_info("speakup: unregistering synth device /dev/synth\n");
|
||||
misc_deregister(&synth_device);
|
||||
misc_registered = 0;
|
||||
}
|
105
drivers/staging/speakup/fakekey.c
Normal file
105
drivers/staging/speakup/fakekey.c
Normal file
@ -0,0 +1,105 @@
|
||||
/* fakekey.c
|
||||
* Functions for simulating keypresses.
|
||||
*
|
||||
* Copyright (C) 2010 the Speakup Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <linux/types.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/preempt.h>
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "speakup.h"
|
||||
|
||||
#define PRESSED 1
|
||||
#define RELEASED 0
|
||||
|
||||
DEFINE_PER_CPU(bool, reporting_keystroke);
|
||||
|
||||
static struct input_dev *virt_keyboard;
|
||||
|
||||
int speakup_add_virtual_keyboard(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
virt_keyboard = input_allocate_device();
|
||||
|
||||
if (!virt_keyboard)
|
||||
return -ENOMEM;
|
||||
|
||||
virt_keyboard->name = "Speakup";
|
||||
virt_keyboard->id.bustype = BUS_VIRTUAL;
|
||||
virt_keyboard->phys = "speakup/input0";
|
||||
virt_keyboard->dev.parent = NULL;
|
||||
|
||||
__set_bit(EV_KEY, virt_keyboard->evbit);
|
||||
__set_bit(KEY_DOWN, virt_keyboard->keybit);
|
||||
|
||||
err = input_register_device(virt_keyboard);
|
||||
if (err) {
|
||||
input_free_device(virt_keyboard);
|
||||
virt_keyboard = NULL;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void speakup_remove_virtual_keyboard(void)
|
||||
{
|
||||
if (virt_keyboard != NULL) {
|
||||
input_unregister_device(virt_keyboard);
|
||||
input_free_device(virt_keyboard);
|
||||
virt_keyboard = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a simulated down-arrow to the application.
|
||||
*/
|
||||
void speakup_fake_down_arrow(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
/* disable keyboard interrupts */
|
||||
local_irq_save(flags);
|
||||
/* don't change CPU */
|
||||
preempt_disable();
|
||||
|
||||
__get_cpu_var(reporting_keystroke) = true;
|
||||
input_report_key(virt_keyboard, KEY_DOWN, PRESSED);
|
||||
input_report_key(virt_keyboard, KEY_DOWN, RELEASED);
|
||||
__get_cpu_var(reporting_keystroke) = false;
|
||||
|
||||
/* reenable preemption */
|
||||
preempt_enable();
|
||||
/* reenable keyboard interrupts */
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Are we handling a simulated keypress on the current CPU?
|
||||
* Returns a boolean.
|
||||
*/
|
||||
bool speakup_fake_key_pressed(void)
|
||||
{
|
||||
bool is_pressed;
|
||||
|
||||
is_pressed = get_cpu_var(reporting_keystroke);
|
||||
put_cpu_var(reporting_keystroke);
|
||||
|
||||
return is_pressed;
|
||||
}
|
622
drivers/staging/speakup/i18n.c
Normal file
622
drivers/staging/speakup/i18n.c
Normal file
@ -0,0 +1,622 @@
|
||||
/* Internationalization implementation. Includes definitions of English
|
||||
* string arrays, and the i18n pointer. */
|
||||
|
||||
#include <linux/slab.h> /* For kmalloc. */
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
|
||||
static char *speakup_msgs[MSG_LAST_INDEX];
|
||||
static char *speakup_default_msgs [MSG_LAST_INDEX] = {
|
||||
[MSG_BLANK] = "blank",
|
||||
[MSG_IAM_ALIVE] = "I'm aLive!",
|
||||
[MSG_YOU_KILLED_SPEAKUP] = "You killed speakup!",
|
||||
[MSG_HEY_THATS_BETTER] = "hey. That's better!",
|
||||
[MSG_YOU_TURNED_ME_OFF] = "You turned me off!",
|
||||
[MSG_PARKED] = "parked!",
|
||||
[MSG_UNPARKED] = "unparked!",
|
||||
[MSG_MARK] = "mark",
|
||||
[MSG_CUT] = "cut",
|
||||
[MSG_MARK_CLEARED] = "mark, cleared",
|
||||
[MSG_PASTE] = "paste",
|
||||
[MSG_BRIGHT] = "bright",
|
||||
[MSG_ON_BLINKING] = "on blinking",
|
||||
[MSG_OFF] = "off",
|
||||
[MSG_ON] = "on",
|
||||
[MSG_NO_WINDOW] = "no window",
|
||||
[MSG_CURSORING_OFF] = "cursoring off",
|
||||
[MSG_CURSORING_ON] = "cursoring on",
|
||||
[MSG_HIGHLIGHT_TRACKING] = "highlight tracking",
|
||||
[MSG_READ_WINDOW] = "read windo",
|
||||
[MSG_READ_ALL] = "read all",
|
||||
[MSG_EDIT_DONE] = "edit done",
|
||||
[MSG_WINDOW_ALREADY_SET] = "window already set, clear then reset",
|
||||
[MSG_END_BEFORE_START] = "error end before start",
|
||||
[MSG_WINDOW_CLEARED] = "window cleared",
|
||||
[MSG_WINDOW_SILENCED] = "window silenced",
|
||||
[MSG_WINDOW_SILENCE_DISABLED] = "window silence disabled",
|
||||
[MSG_ERROR] = "error",
|
||||
[MSG_GOTO_CANCELED] = "goto canceled",
|
||||
[MSG_GOTO] = "go to?",
|
||||
[MSG_LEAVING_HELP] = "leaving help",
|
||||
[MSG_IS_UNASSIGNED] = "is unassigned",
|
||||
[MSG_HELP_INFO] = "press space to leav help, cursor up or down to scroll, or a letter to go to commands in list",
|
||||
[MSG_EDGE_TOP] = "top,",
|
||||
[MSG_EDGE_BOTTOM] = "bottom,",
|
||||
[MSG_EDGE_LEFT] = "left,",
|
||||
[MSG_EDGE_RIGHT] = "right,",
|
||||
[MSG_NUMBER] = "number",
|
||||
[MSG_SPACE] = "space",
|
||||
[MSG_START] = "start",
|
||||
[MSG_END] = "end",
|
||||
[MSG_CTRL] = "control-",
|
||||
[MSG_DISJUNCTION] = "or",
|
||||
|
||||
/* Messages with embedded format specifiers. */
|
||||
[MSG_POS_INFO] = "line %ld, col %ld, t t y %d",
|
||||
[MSG_CHAR_INFO] = "hex %02x, decimal %d",
|
||||
[MSG_REPEAT_DESC] = "times %d .",
|
||||
[MSG_REPEAT_DESC2] = "repeated %d .",
|
||||
[MSG_WINDOW_LINE] = "window is line %d",
|
||||
[MSG_WINDOW_BOUNDARY] = "%s at line %d, column %d",
|
||||
[MSG_EDIT_PROMPT] = "edit %s, press space when done",
|
||||
[MSG_NO_COMMAND] = "no commands for %c",
|
||||
[MSG_KEYDESC] = "is %s",
|
||||
|
||||
/* Control keys. */
|
||||
/* Most of these duplicate the entries in state names. */
|
||||
[MSG_CTL_SHIFT] = "shift",
|
||||
[MSG_CTL_ALTGR] = "altgr",
|
||||
[MSG_CTL_CONTROL] = "control",
|
||||
[MSG_CTL_ALT] = "ault",
|
||||
[MSG_CTL_LSHIFT] = "l shift",
|
||||
[MSG_CTL_SPEAKUP] = "speakup",
|
||||
[MSG_CTL_LCONTROL] = "l control",
|
||||
[MSG_CTL_RCONTROL] = "r control",
|
||||
[MSG_CTL_CAPSSHIFT] = "caps shift",
|
||||
|
||||
/* Color names. */
|
||||
[MSG_COLOR_BLACK] = "black",
|
||||
[MSG_COLOR_BLUE] = "blue",
|
||||
[MSG_COLOR_GREEN] = "green",
|
||||
[MSG_COLOR_CYAN] = "cyan",
|
||||
[MSG_COLOR_RED] = "red",
|
||||
[MSG_COLOR_MAGENTA] = "magenta",
|
||||
[MSG_COLOR_YELLOW] = "yellow",
|
||||
[MSG_COLOR_WHITE] = "white",
|
||||
[MSG_COLOR_GREY] = "grey",
|
||||
|
||||
/* Names of key states. */
|
||||
[MSG_STATE_DOUBLE] = "double",
|
||||
[MSG_STATE_SPEAKUP] = "speakup",
|
||||
[MSG_STATE_ALT] = "alt",
|
||||
[MSG_STATE_CONTROL] = "ctrl",
|
||||
[MSG_STATE_ALTGR] = "altgr",
|
||||
[MSG_STATE_SHIFT] = "shift",
|
||||
|
||||
/* Key names. */
|
||||
[MSG_KEYNAME_ESC] = "escape",
|
||||
[MSG_KEYNAME_1] = "1",
|
||||
[MSG_KEYNAME_2] = "2",
|
||||
[MSG_KEYNAME_3] = "3",
|
||||
[MSG_KEYNAME_4] = "4",
|
||||
[MSG_KEYNAME_5] = "5",
|
||||
[MSG_KEYNAME_6] = "6",
|
||||
[MSG_KEYNAME_7] = "7",
|
||||
[MSG_KEYNAME_8] = "8",
|
||||
[MSG_KEYNAME_9] = "9",
|
||||
[MSG_KEYNAME_0] = "0",
|
||||
[MSG_KEYNAME_DASH] = "minus",
|
||||
[MSG_KEYNAME_EQUAL] = "equal",
|
||||
[MSG_KEYNAME_BS] = "back space",
|
||||
[MSG_KEYNAME_TAB] = "tab",
|
||||
[MSG_KEYNAME_Q] = "q",
|
||||
[MSG_KEYNAME_W] = "w",
|
||||
[MSG_KEYNAME_E] = "e",
|
||||
[MSG_KEYNAME_R] = "r",
|
||||
[MSG_KEYNAME_T] = "t",
|
||||
[MSG_KEYNAME_Y] = "y",
|
||||
[MSG_KEYNAME_U] = "u",
|
||||
[MSG_KEYNAME_I] = "i",
|
||||
[MSG_KEYNAME_O] = "o",
|
||||
[MSG_KEYNAME_P] = "p",
|
||||
[MSG_KEYNAME_LEFTBRACE] = "left brace",
|
||||
[MSG_KEYNAME_RIGHTBRACE] = "right brace",
|
||||
[MSG_KEYNAME_ENTER] = "enter",
|
||||
[MSG_KEYNAME_LEFTCTRL] = "left control",
|
||||
[MSG_KEYNAME_A] = "a",
|
||||
[MSG_KEYNAME_S] = "s",
|
||||
[MSG_KEYNAME_D] = "d",
|
||||
[MSG_KEYNAME_F] = "f",
|
||||
[MSG_KEYNAME_G] = "g",
|
||||
[MSG_KEYNAME_H] = "h",
|
||||
[MSG_KEYNAME_J] = "j",
|
||||
[MSG_KEYNAME_K] = "k",
|
||||
[MSG_KEYNAME_L] = "l",
|
||||
[MSG_KEYNAME_SEMICOLON] = "semicolon",
|
||||
[MSG_KEYNAME_SINGLEQUOTE] = "apostrophe",
|
||||
[MSG_KEYNAME_GRAVE] = "accent",
|
||||
[MSG_KEYNAME_LEFTSHFT] = "left shift",
|
||||
[MSG_KEYNAME_BACKSLASH] = "back slash",
|
||||
[MSG_KEYNAME_Z] = "z",
|
||||
[MSG_KEYNAME_X] = "x",
|
||||
[MSG_KEYNAME_C] = "c",
|
||||
[MSG_KEYNAME_V] = "v",
|
||||
[MSG_KEYNAME_B] = "b",
|
||||
[MSG_KEYNAME_N] = "n",
|
||||
[MSG_KEYNAME_M] = "m",
|
||||
[MSG_KEYNAME_COMMA] = "comma",
|
||||
[MSG_KEYNAME_DOT] = "dot",
|
||||
[MSG_KEYNAME_SLASH] = "slash",
|
||||
[MSG_KEYNAME_RIGHTSHFT] = "right shift",
|
||||
[MSG_KEYNAME_KPSTAR] = "keypad asterisk",
|
||||
[MSG_KEYNAME_LEFTALT] = "left alt",
|
||||
[MSG_KEYNAME_SPACE] = "space",
|
||||
[MSG_KEYNAME_CAPSLOCK] = "caps lock",
|
||||
[MSG_KEYNAME_F1] = "f1",
|
||||
[MSG_KEYNAME_F2] = "f2",
|
||||
[MSG_KEYNAME_F3] = "f3",
|
||||
[MSG_KEYNAME_F4] = "f4",
|
||||
[MSG_KEYNAME_F5] = "f5",
|
||||
[MSG_KEYNAME_F6] = "f6",
|
||||
[MSG_KEYNAME_F7] = "f7",
|
||||
[MSG_KEYNAME_F8] = "f8",
|
||||
[MSG_KEYNAME_F9] = "f9",
|
||||
[MSG_KEYNAME_F10] = "f10",
|
||||
[MSG_KEYNAME_NUMLOCK] = "num lock",
|
||||
[MSG_KEYNAME_SCROLLLOCK] = "scroll lock",
|
||||
[MSG_KEYNAME_KP7] = "keypad 7",
|
||||
[MSG_KEYNAME_KP8] = "keypad 8",
|
||||
[MSG_KEYNAME_KP9] = "keypad 9",
|
||||
[MSG_KEYNAME_KPMINUS] = "keypad minus",
|
||||
[MSG_KEYNAME_KP4] = "keypad 4",
|
||||
[MSG_KEYNAME_KP5] = "keypad 5",
|
||||
[MSG_KEYNAME_KP6] = "keypad 6",
|
||||
[MSG_KEYNAME_KPPLUS] = "keypad plus",
|
||||
[MSG_KEYNAME_KP1] = "keypad 1",
|
||||
[MSG_KEYNAME_KP2] = "keypad 2",
|
||||
[MSG_KEYNAME_KP3] = "keypad 3",
|
||||
[MSG_KEYNAME_KP0] = "keypad 0",
|
||||
[MSG_KEYNAME_KPDOT] = "keypad dot",
|
||||
[MSG_KEYNAME_103RD] = "103rd",
|
||||
[MSG_KEYNAME_F13] = "f13",
|
||||
[MSG_KEYNAME_102ND] = "102nd",
|
||||
[MSG_KEYNAME_F11] = "f11",
|
||||
[MSG_KEYNAME_F12] = "f12",
|
||||
[MSG_KEYNAME_F14] = "f14",
|
||||
[MSG_KEYNAME_F15] = "f15",
|
||||
[MSG_KEYNAME_F16] = "f16",
|
||||
[MSG_KEYNAME_F17] = "f17",
|
||||
[MSG_KEYNAME_F18] = "f18",
|
||||
[MSG_KEYNAME_F19] = "f19",
|
||||
[MSG_KEYNAME_F20] = "f20",
|
||||
[MSG_KEYNAME_KPENTER] = "keypad enter",
|
||||
[MSG_KEYNAME_RIGHTCTRL] = "right control",
|
||||
[MSG_KEYNAME_KPSLASH] = "keypad slash",
|
||||
[MSG_KEYNAME_SYSRQ] = "sysrq",
|
||||
[MSG_KEYNAME_RIGHTALT] = "right alt",
|
||||
[MSG_KEYNAME_LF] = "line feed",
|
||||
[MSG_KEYNAME_HOME] = "home",
|
||||
[MSG_KEYNAME_UP] = "up",
|
||||
[MSG_KEYNAME_PGUP] = "page up",
|
||||
[MSG_KEYNAME_LEFT] = "left",
|
||||
[MSG_KEYNAME_RIGHT] = "right",
|
||||
[MSG_KEYNAME_END] = "end",
|
||||
[MSG_KEYNAME_DOWN] = "down",
|
||||
[MSG_KEYNAME_PGDN] = "page down",
|
||||
[MSG_KEYNAME_INS] = "insert",
|
||||
[MSG_KEYNAME_DEL] = "delete",
|
||||
[MSG_KEYNAME_MACRO] = "macro",
|
||||
[MSG_KEYNAME_MUTE] = "mute",
|
||||
[MSG_KEYNAME_VOLDOWN] = "volume down",
|
||||
[MSG_KEYNAME_VOLUP] = "volume up",
|
||||
[MSG_KEYNAME_POWER] = "power",
|
||||
[MSG_KEYNAME_KPEQUAL] = "keypad equal",
|
||||
[MSG_KEYNAME_KPPLUSDASH] = "keypad plusminus",
|
||||
[MSG_KEYNAME_PAUSE] = "pause",
|
||||
[MSG_KEYNAME_F21] = "f21",
|
||||
[MSG_KEYNAME_F22] = "f22",
|
||||
[MSG_KEYNAME_F23] = "f23",
|
||||
[MSG_KEYNAME_F24] = "f24",
|
||||
[MSG_KEYNAME_KPCOMMA] = "keypad comma",
|
||||
[MSG_KEYNAME_LEFTMETA] = "left meta",
|
||||
[MSG_KEYNAME_RIGHTMETA] = "right meta",
|
||||
[MSG_KEYNAME_COMPOSE] = "compose",
|
||||
[MSG_KEYNAME_STOP] = "stop",
|
||||
[MSG_KEYNAME_AGAIN] = "again",
|
||||
[MSG_KEYNAME_PROPS] = "props",
|
||||
[MSG_KEYNAME_UNDO] = "undo",
|
||||
[MSG_KEYNAME_FRONT] = "front",
|
||||
[MSG_KEYNAME_COPY] = "copy",
|
||||
[MSG_KEYNAME_OPEN] = "open",
|
||||
[MSG_KEYNAME_PASTE] = "paste",
|
||||
[MSG_KEYNAME_FIND] = "find",
|
||||
[MSG_KEYNAME_CUT] = "cut",
|
||||
[MSG_KEYNAME_HELP] = "help",
|
||||
[MSG_KEYNAME_MENU] = "menu",
|
||||
[MSG_KEYNAME_CALC] = "calc",
|
||||
[MSG_KEYNAME_SETUP] = "setup",
|
||||
[MSG_KEYNAME_SLEEP] = "sleep",
|
||||
[MSG_KEYNAME_WAKEUP] = "wakeup",
|
||||
[MSG_KEYNAME_FILE] = "file",
|
||||
[MSG_KEYNAME_SENDFILE] = "send file",
|
||||
[MSG_KEYNAME_DELFILE] = "delete file",
|
||||
[MSG_KEYNAME_XFER] = "transfer",
|
||||
[MSG_KEYNAME_PROG1] = "prog1",
|
||||
[MSG_KEYNAME_PROG2] = "prog2",
|
||||
[MSG_KEYNAME_WWW] = "www",
|
||||
[MSG_KEYNAME_MSDOS] = "msdos",
|
||||
[MSG_KEYNAME_COFFEE] = "coffee",
|
||||
[MSG_KEYNAME_DIRECTION] = "direction",
|
||||
[MSG_KEYNAME_CYCLEWINDOWS] = "cycle windows",
|
||||
[MSG_KEYNAME_MAIL] = "mail",
|
||||
[MSG_KEYNAME_BOOKMARKS] = "bookmarks",
|
||||
[MSG_KEYNAME_COMPUTER] = "computer",
|
||||
[MSG_KEYNAME_BACK] = "back",
|
||||
[MSG_KEYNAME_FORWARD] = "forward",
|
||||
[MSG_KEYNAME_CLOSECD] = "close cd",
|
||||
[MSG_KEYNAME_EJECTCD] = "eject cd",
|
||||
[MSG_KEYNAME_EJECTCLOSE] = "eject close cd",
|
||||
[MSG_KEYNAME_NEXTSONG] = "next song",
|
||||
[MSG_KEYNAME_PLAYPAUSE] = "play pause",
|
||||
[MSG_KEYNAME_PREVSONG] = "previous song",
|
||||
[MSG_KEYNAME_STOPCD] = "stop cd",
|
||||
[MSG_KEYNAME_RECORD] = "record",
|
||||
[MSG_KEYNAME_REWIND] = "rewind",
|
||||
[MSG_KEYNAME_PHONE] = "phone",
|
||||
[MSG_KEYNAME_ISO] = "iso",
|
||||
[MSG_KEYNAME_CONFIG] = "config",
|
||||
[MSG_KEYNAME_HOMEPG] = "home page",
|
||||
[MSG_KEYNAME_REFRESH] = "refresh",
|
||||
[MSG_KEYNAME_EXIT] = "exit",
|
||||
[MSG_KEYNAME_MOVE] = "move",
|
||||
[MSG_KEYNAME_EDIT] = "edit",
|
||||
[MSG_KEYNAME_SCROLLUP] = "scroll up",
|
||||
[MSG_KEYNAME_SCROLLDN] = "scroll down",
|
||||
[MSG_KEYNAME_KPLEFTPAR] = "keypad left paren",
|
||||
[MSG_KEYNAME_KPRIGHTPAR] = "keypad right paren",
|
||||
|
||||
/* Function names. */
|
||||
[MSG_FUNCNAME_ATTRIB_BLEEP_DEC] = "attribute bleep decrement",
|
||||
[MSG_FUNCNAME_ATTRIB_BLEEP_INC] = "attribute bleep increment",
|
||||
[MSG_FUNCNAME_BLEEPS_DEC] = "bleeps decrement",
|
||||
[MSG_FUNCNAME_BLEEPS_INC] = "bleeps increment",
|
||||
[MSG_FUNCNAME_CHAR_FIRST] = "character, first",
|
||||
[MSG_FUNCNAME_CHAR_LAST] = "character, last",
|
||||
[MSG_FUNCNAME_CHAR_CURRENT] = "character, say current",
|
||||
[MSG_FUNCNAME_CHAR_HEX_AND_DEC] = "character, say hex and decimal",
|
||||
[MSG_FUNCNAME_CHAR_NEXT] = "character, say next",
|
||||
[MSG_FUNCNAME_CHAR_PHONETIC] = "character, say phonetic",
|
||||
[MSG_FUNCNAME_CHAR_PREVIOUS] = "character, say previous",
|
||||
[MSG_FUNCNAME_CURSOR_PARK] = "cursor park",
|
||||
[MSG_FUNCNAME_CUT] = "cut",
|
||||
[MSG_FUNCNAME_EDIT_DELIM] = "edit delimiters",
|
||||
[MSG_FUNCNAME_EDIT_EXNUM] = "edit exnum",
|
||||
[MSG_FUNCNAME_EDIT_MOST] = "edit most",
|
||||
[MSG_FUNCNAME_EDIT_REPEATS] = "edit repeats",
|
||||
[MSG_FUNCNAME_EDIT_SOME] = "edit some",
|
||||
[MSG_FUNCNAME_GOTO] = "go to",
|
||||
[MSG_FUNCNAME_GOTO_BOTTOM] = "go to bottom edge",
|
||||
[MSG_FUNCNAME_GOTO_LEFT] = "go to left edge",
|
||||
[MSG_FUNCNAME_GOTO_RIGHT] = "go to right edge",
|
||||
[MSG_FUNCNAME_GOTO_TOP] = "go to top edge",
|
||||
[MSG_FUNCNAME_HELP] = "help",
|
||||
[MSG_FUNCNAME_LINE_SAY_CURRENT] = "line, say current",
|
||||
[MSG_FUNCNAME_LINE_SAY_NEXT] = "line, say next",
|
||||
[MSG_FUNCNAME_LINE_SAY_PREVIOUS] = "line, say previous",
|
||||
[MSG_FUNCNAME_LINE_SAY_WITH_INDENT] = "line, say with indent",
|
||||
[MSG_FUNCNAME_PASTE] = "paste",
|
||||
[MSG_FUNCNAME_PITCH_DEC] = "pitch decrement",
|
||||
[MSG_FUNCNAME_PITCH_INC] = "pitch increment",
|
||||
[MSG_FUNCNAME_PUNC_DEC] = "punctuation decrement",
|
||||
[MSG_FUNCNAME_PUNC_INC] = "punctuation increment",
|
||||
[MSG_FUNCNAME_PUNC_LEVEL_DEC] = "punc level decrement",
|
||||
[MSG_FUNCNAME_PUNC_LEVEL_INC] = "punc level increment",
|
||||
[MSG_FUNCNAME_QUIET] = "quiet",
|
||||
[MSG_FUNCNAME_RATE_DEC] = "rate decrement",
|
||||
[MSG_FUNCNAME_RATE_INC] = "rate increment",
|
||||
[MSG_FUNCNAME_READING_PUNC_DEC] = "reading punctuation decrement",
|
||||
[MSG_FUNCNAME_READING_PUNC_INC] = "reading punctuation increment",
|
||||
[MSG_FUNCNAME_SAY_ATTRIBUTES] = "say attributes",
|
||||
[MSG_FUNCNAME_SAY_FROM_LEFT] = "say from left",
|
||||
[MSG_FUNCNAME_SAY_FROM_TOP] = "say from top",
|
||||
[MSG_FUNCNAME_SAY_POSITION] = "say position",
|
||||
[MSG_FUNCNAME_SAY_SCREEN] = "say screen",
|
||||
[MSG_FUNCNAME_SAY_TO_BOTTOM] = "say to bottom",
|
||||
[MSG_FUNCNAME_SAY_TO_RIGHT] = "say to right",
|
||||
[MSG_FUNCNAME_SPEAKUP] = "speakup",
|
||||
[MSG_FUNCNAME_SPEAKUP_LOCK] = "speakup lock",
|
||||
[MSG_FUNCNAME_SPEAKUP_OFF] = "speakup off",
|
||||
[MSG_FUNCNAME_SPEECH_KILL] = "speech kill",
|
||||
[MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement",
|
||||
[MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment",
|
||||
[MSG_FUNCNAME_SPELL_WORD] = "spell word",
|
||||
[MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phoneticly",
|
||||
[MSG_FUNCNAME_TONE_DEC] = "tone decrement",
|
||||
[MSG_FUNCNAME_TONE_INC] = "tone increment",
|
||||
[MSG_FUNCNAME_VOICE_DEC] = "voice decrement",
|
||||
[MSG_FUNCNAME_VOICE_INC] = "voice increment",
|
||||
[MSG_FUNCNAME_VOLUME_DEC] = "volume decrement",
|
||||
[MSG_FUNCNAME_VOLUME_INC] = "volume increment",
|
||||
[MSG_FUNCNAME_WINDOW_CLEAR] = "window, clear",
|
||||
[MSG_FUNCNAME_WINDOW_SAY] = "window, say",
|
||||
[MSG_FUNCNAME_WINDOW_SET] = "window, set",
|
||||
[MSG_FUNCNAME_WINDOW_SILENCE] = "window, silence",
|
||||
[MSG_FUNCNAME_WORD_SAY_CURRENT] = "word, say current",
|
||||
[MSG_FUNCNAME_WORD_SAY_NEXT] = "word, say next",
|
||||
[MSG_FUNCNAME_WORD_SAY_PREVIOUS] = "word, say previous",
|
||||
};
|
||||
|
||||
static struct msg_group_t all_groups [] = {
|
||||
{
|
||||
.name = "ctl_keys",
|
||||
.start = MSG_CTL_START,
|
||||
.end = MSG_CTL_END,
|
||||
},
|
||||
{
|
||||
.name = "colors",
|
||||
.start = MSG_COLORS_START,
|
||||
.end = MSG_COLORS_END,
|
||||
},
|
||||
{
|
||||
.name = "formatted",
|
||||
.start = MSG_FORMATTED_START,
|
||||
.end = MSG_FORMATTED_END,
|
||||
},
|
||||
{
|
||||
.name = "function_names",
|
||||
.start = MSG_FUNCNAMES_START,
|
||||
.end = MSG_FUNCNAMES_END,
|
||||
},
|
||||
{
|
||||
.name = "key_names",
|
||||
.start = MSG_KEYNAMES_START,
|
||||
.end = MSG_KEYNAMES_END,
|
||||
},
|
||||
{
|
||||
.name = "announcements",
|
||||
.start = MSG_ANNOUNCEMENTS_START,
|
||||
.end = MSG_ANNOUNCEMENTS_END,
|
||||
},
|
||||
{
|
||||
.name = "states",
|
||||
.start = MSG_STATES_START,
|
||||
.end = MSG_STATES_END,
|
||||
},
|
||||
};
|
||||
|
||||
static const int num_groups = sizeof(all_groups) / sizeof(struct msg_group_t);
|
||||
|
||||
char *msg_get(enum msg_index_t index)
|
||||
{
|
||||
char *ch;
|
||||
|
||||
ch = speakup_msgs[index];
|
||||
return ch;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: next_specifier
|
||||
* Finds the start of the next format specifier in the argument string.
|
||||
* Return value: pointer to start of format
|
||||
* specifier, or NULL if no specifier exists.
|
||||
*/
|
||||
static char *next_specifier(char *input)
|
||||
{
|
||||
int found = 0;
|
||||
char *next_percent = input;
|
||||
|
||||
while ((next_percent != NULL) && !found) {
|
||||
next_percent = strchr(next_percent, '%');
|
||||
if (next_percent != NULL) {
|
||||
while ((next_percent[0] == '%')
|
||||
&& (next_percent[1] == '%'))
|
||||
next_percent += 2; /* Advance over doubled percent signs. */
|
||||
if (*next_percent == '%')
|
||||
found = 1;
|
||||
else if (*next_percent == '\0')
|
||||
next_percent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return next_percent;
|
||||
}
|
||||
|
||||
/* Skip over 0 or more flags. */
|
||||
static char *skip_flags(char *input)
|
||||
{
|
||||
while ((*input != '\0') && strchr(" 0+-#", *input))
|
||||
input++;
|
||||
return input;
|
||||
}
|
||||
|
||||
/* Skip over width.precision, if it exists. */
|
||||
static char *skip_width(char *input)
|
||||
{
|
||||
while (isdigit(*input))
|
||||
input++;
|
||||
if (*input == '.') {
|
||||
input++;
|
||||
while (isdigit(*input))
|
||||
input++;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip past the end of the conversion part.
|
||||
* Note that this code only accepts a handful of conversion specifiers:
|
||||
* c d s x and ld. Not accidental; these are exactly the ones used in
|
||||
* the default group of formatted messages.
|
||||
*/
|
||||
static char *skip_conversion(char *input)
|
||||
{
|
||||
if ((input[0] == 'l') && (input[1] == 'd'))
|
||||
input += 2;
|
||||
else if ((*input != '\0') && strchr("cdsx", *input))
|
||||
input++;
|
||||
return input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: find_specifier_end
|
||||
* Return a pointer to the end of the format specifier.
|
||||
*/
|
||||
static char *find_specifier_end(char *input)
|
||||
{
|
||||
input++; /* Advance over %. */
|
||||
input = skip_flags(input);
|
||||
input = skip_width(input);
|
||||
input = skip_conversion(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: compare_specifiers
|
||||
* Compare the format specifiers pointed to by *input1 and *input2.
|
||||
* Return 1 if they are the same, 0 otherwise. Advance *input1 and *input2
|
||||
* so that they point to the character following the end of the specifier.
|
||||
*/
|
||||
static int compare_specifiers(char **input1, char **input2)
|
||||
{
|
||||
int same = 0;
|
||||
char *end1 = find_specifier_end(*input1);
|
||||
char *end2 = find_specifier_end(*input2);
|
||||
size_t length1 = end1 - *input1;
|
||||
size_t length2 = end2 - *input2;
|
||||
|
||||
if((length1 == length2) && !memcmp(*input1, *input2, length1))
|
||||
same = 1;
|
||||
|
||||
*input1 = end1;
|
||||
*input2 = end2;
|
||||
return same;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: fmt_validate
|
||||
* Check that two format strings contain the same number of format specifiers,
|
||||
* and that the order of specifiers is the same in both strings.
|
||||
* Return 1 if the condition holds, 0 if it doesn't.
|
||||
*/
|
||||
static int fmt_validate(char *template, char *user)
|
||||
{
|
||||
int valid = 1;
|
||||
int still_comparing = 1;
|
||||
char *template_ptr = template;
|
||||
char *user_ptr = user;
|
||||
|
||||
while (still_comparing && valid) {
|
||||
template_ptr = next_specifier(template_ptr);
|
||||
user_ptr = next_specifier(user_ptr);
|
||||
if (template_ptr && user_ptr) {
|
||||
/* Both have at least one more specifier. */
|
||||
valid = compare_specifiers(&template_ptr, &user_ptr);
|
||||
} else {
|
||||
/* No more format specifiers in one or both of the strings. */
|
||||
still_comparing = 0;
|
||||
if (template_ptr || user_ptr)
|
||||
valid = 0; /* One has more specifiers than the other. */
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: msg_set
|
||||
* Description: Add a user-supplied message to the user_messages array.
|
||||
* The message text is copied to a memory area allocated with kmalloc.
|
||||
* If the function fails, then user_messages is untouched.
|
||||
* Arguments:
|
||||
* - index: a message number, as found in i18n.h.
|
||||
* - text: text of message. Not NUL-terminated.
|
||||
* - length: number of bytes in text.
|
||||
* Failure conditions:
|
||||
* -EINVAL - Invalid format specifiers in formatted message or illegal index.
|
||||
* -ENOMEM - Unable to allocate memory.
|
||||
*/
|
||||
ssize_t msg_set(enum msg_index_t index, char *text, size_t length)
|
||||
{
|
||||
int rc = 0;
|
||||
char *newstr = NULL;
|
||||
unsigned long flags;
|
||||
|
||||
if ((index >= MSG_FIRST_INDEX) && (index < MSG_LAST_INDEX)) {
|
||||
newstr = kmalloc(length + 1, GFP_KERNEL);
|
||||
if (newstr) {
|
||||
memcpy(newstr, text, length);
|
||||
newstr[length] = '\0';
|
||||
if ((index >= MSG_FORMATTED_START && index <= MSG_FORMATTED_END)
|
||||
&& ! fmt_validate(speakup_default_msgs[index], newstr)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
spk_lock(flags);
|
||||
if (speakup_msgs[index] != speakup_default_msgs[index])
|
||||
kfree(speakup_msgs[index]);
|
||||
speakup_msgs[index] = newstr;
|
||||
spk_unlock(flags);
|
||||
} else {
|
||||
rc = -ENOMEM;
|
||||
}
|
||||
} else {
|
||||
rc = -EINVAL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a message group, given its name. Return a pointer to the structure
|
||||
* if found, or NULL otherwise.
|
||||
*/
|
||||
struct msg_group_t *find_msg_group(const char *group_name)
|
||||
{
|
||||
struct msg_group_t *group = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_groups; i++) {
|
||||
if (!strcmp(all_groups[i].name, group_name)) {
|
||||
group = &all_groups[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
void reset_msg_group(struct msg_group_t *group)
|
||||
{
|
||||
unsigned long flags;
|
||||
enum msg_index_t i;
|
||||
|
||||
spk_lock(flags);
|
||||
|
||||
for(i = group->start; i <= group->end; i++) {
|
||||
if (speakup_msgs[i] != speakup_default_msgs[i])
|
||||
kfree(speakup_msgs[i]);
|
||||
speakup_msgs[i] = speakup_default_msgs[i];
|
||||
}
|
||||
spk_unlock(flags);
|
||||
}
|
||||
|
||||
/* Called at initialization time, to establish default messages. */
|
||||
void initialize_msgs(void)
|
||||
{
|
||||
memcpy(speakup_msgs, speakup_default_msgs, sizeof(speakup_default_msgs));
|
||||
}
|
||||
|
||||
/* Free user-supplied strings when module is unloaded: */
|
||||
void free_user_msgs(void)
|
||||
{
|
||||
enum msg_index_t index;
|
||||
unsigned long flags;
|
||||
|
||||
spk_lock(flags);
|
||||
for(index = MSG_FIRST_INDEX; index < MSG_LAST_INDEX; index++) {
|
||||
if (speakup_msgs[index] != speakup_default_msgs[index]) {
|
||||
kfree(speakup_msgs[index]);
|
||||
speakup_msgs[index] = speakup_default_msgs[index];
|
||||
}
|
||||
}
|
||||
spk_unlock(flags);
|
||||
}
|
228
drivers/staging/speakup/i18n.h
Normal file
228
drivers/staging/speakup/i18n.h
Normal file
@ -0,0 +1,228 @@
|
||||
#ifndef I18N_H
|
||||
#define I18N_H
|
||||
/* Internationalization declarations */
|
||||
|
||||
enum msg_index_t {
|
||||
MSG_FIRST_INDEX ,
|
||||
MSG_ANNOUNCEMENTS_START = MSG_FIRST_INDEX,
|
||||
MSG_BLANK = MSG_ANNOUNCEMENTS_START,
|
||||
MSG_IAM_ALIVE,
|
||||
MSG_YOU_KILLED_SPEAKUP,
|
||||
MSG_HEY_THATS_BETTER,
|
||||
MSG_YOU_TURNED_ME_OFF,
|
||||
MSG_PARKED,
|
||||
MSG_UNPARKED,
|
||||
MSG_MARK,
|
||||
MSG_CUT,
|
||||
MSG_MARK_CLEARED,
|
||||
MSG_PASTE,
|
||||
MSG_BRIGHT,
|
||||
MSG_ON_BLINKING,
|
||||
MSG_STATUS_START,
|
||||
MSG_OFF = MSG_STATUS_START,
|
||||
MSG_ON,
|
||||
MSG_NO_WINDOW,
|
||||
MSG_CURSOR_MSGS_START,
|
||||
MSG_CURSORING_OFF = MSG_CURSOR_MSGS_START,
|
||||
MSG_CURSORING_ON,
|
||||
MSG_HIGHLIGHT_TRACKING,
|
||||
MSG_READ_WINDOW,
|
||||
MSG_READ_ALL,
|
||||
MSG_EDIT_DONE,
|
||||
MSG_WINDOW_ALREADY_SET,
|
||||
MSG_END_BEFORE_START,
|
||||
MSG_WINDOW_CLEARED,
|
||||
MSG_WINDOW_SILENCED,
|
||||
MSG_WINDOW_SILENCE_DISABLED,
|
||||
MSG_ERROR,
|
||||
MSG_GOTO_CANCELED,
|
||||
MSG_GOTO,
|
||||
MSG_LEAVING_HELP,
|
||||
MSG_IS_UNASSIGNED,
|
||||
MSG_HELP_INFO,
|
||||
MSG_EDGE_MSGS_START,
|
||||
MSG_EDGE_TOP = MSG_EDGE_MSGS_START,
|
||||
MSG_EDGE_BOTTOM,
|
||||
MSG_EDGE_LEFT,
|
||||
MSG_EDGE_RIGHT,
|
||||
MSG_NUMBER,
|
||||
MSG_SPACE,
|
||||
MSG_START, /* A little confusing, given our convention. */
|
||||
MSG_END, /* A little confusing, given our convention. */
|
||||
MSG_CTRL,
|
||||
|
||||
/* A message containing the single word "or". */
|
||||
MSG_DISJUNCTION,
|
||||
MSG_ANNOUNCEMENTS_END = MSG_DISJUNCTION,
|
||||
|
||||
/* Messages with format specifiers. */
|
||||
MSG_FORMATTED_START,
|
||||
MSG_POS_INFO = MSG_FORMATTED_START,
|
||||
MSG_CHAR_INFO,
|
||||
MSG_REPEAT_DESC,
|
||||
MSG_REPEAT_DESC2,
|
||||
MSG_WINDOW_LINE,
|
||||
MSG_WINDOW_BOUNDARY,
|
||||
MSG_EDIT_PROMPT,
|
||||
MSG_NO_COMMAND,
|
||||
MSG_KEYDESC,
|
||||
MSG_FORMATTED_END = MSG_KEYDESC,
|
||||
|
||||
/* Control keys. */
|
||||
MSG_CTL_START,
|
||||
MSG_CTL_SHIFT = MSG_CTL_START,
|
||||
MSG_CTL_ALTGR,
|
||||
MSG_CTL_CONTROL,
|
||||
MSG_CTL_ALT,
|
||||
MSG_CTL_LSHIFT,
|
||||
MSG_CTL_SPEAKUP,
|
||||
MSG_CTL_LCONTROL,
|
||||
MSG_CTL_RCONTROL,
|
||||
MSG_CTL_CAPSSHIFT,
|
||||
MSG_CTL_END = MSG_CTL_CAPSSHIFT,
|
||||
|
||||
/* Colors. */
|
||||
MSG_COLORS_START,
|
||||
MSG_COLOR_BLACK = MSG_COLORS_START,
|
||||
MSG_COLOR_BLUE,
|
||||
MSG_COLOR_GREEN,
|
||||
MSG_COLOR_CYAN,
|
||||
MSG_COLOR_RED,
|
||||
MSG_COLOR_MAGENTA,
|
||||
MSG_COLOR_YELLOW,
|
||||
MSG_COLOR_WHITE,
|
||||
MSG_COLOR_GREY,
|
||||
MSG_COLORS_END = MSG_COLOR_GREY,
|
||||
|
||||
MSG_STATES_START,
|
||||
MSG_STATE_DOUBLE = MSG_STATES_START,
|
||||
MSG_STATE_SPEAKUP,
|
||||
MSG_STATE_ALT,
|
||||
MSG_STATE_CONTROL,
|
||||
MSG_STATE_ALTGR,
|
||||
MSG_STATE_SHIFT,
|
||||
MSG_STATES_END = MSG_STATE_SHIFT,
|
||||
|
||||
MSG_KEYNAMES_START,
|
||||
MSG_KEYNAME_ESC = MSG_KEYNAMES_START,
|
||||
MSG_KEYNAME_1, MSG_KEYNAME_2, MSG_KEYNAME_3, MSG_KEYNAME_4,
|
||||
MSG_KEYNAME_5, MSG_KEYNAME_6, MSG_KEYNAME_7, MSG_KEYNAME_8, MSG_KEYNAME_9,
|
||||
MSG_KEYNAME_0, MSG_KEYNAME_DASH, MSG_KEYNAME_EQUAL, MSG_KEYNAME_BS,
|
||||
MSG_KEYNAME_TAB,
|
||||
MSG_KEYNAME_Q, MSG_KEYNAME_W, MSG_KEYNAME_E, MSG_KEYNAME_R, MSG_KEYNAME_T,
|
||||
MSG_KEYNAME_Y, MSG_KEYNAME_U, MSG_KEYNAME_I, MSG_KEYNAME_O, MSG_KEYNAME_P,
|
||||
MSG_KEYNAME_LEFTBRACE, MSG_KEYNAME_RIGHTBRACE, MSG_KEYNAME_ENTER,
|
||||
MSG_KEYNAME_LEFTCTRL, MSG_KEYNAME_A,
|
||||
MSG_KEYNAME_S, MSG_KEYNAME_D, MSG_KEYNAME_F, MSG_KEYNAME_G, MSG_KEYNAME_H,
|
||||
MSG_KEYNAME_J, MSG_KEYNAME_K, MSG_KEYNAME_L, MSG_KEYNAME_SEMICOLON,
|
||||
MSG_KEYNAME_SINGLEQUOTE, MSG_KEYNAME_GRAVE,
|
||||
MSG_KEYNAME_LEFTSHFT, MSG_KEYNAME_BACKSLASH, MSG_KEYNAME_Z, MSG_KEYNAME_X,
|
||||
MSG_KEYNAME_C, MSG_KEYNAME_V, MSG_KEYNAME_B, MSG_KEYNAME_N, MSG_KEYNAME_M,
|
||||
MSG_KEYNAME_COMMA, MSG_KEYNAME_DOT, MSG_KEYNAME_SLASH, MSG_KEYNAME_RIGHTSHFT,
|
||||
MSG_KEYNAME_KPSTAR,
|
||||
MSG_KEYNAME_LEFTALT, MSG_KEYNAME_SPACE, MSG_KEYNAME_CAPSLOCK,
|
||||
MSG_KEYNAME_F1, MSG_KEYNAME_F2,
|
||||
MSG_KEYNAME_F3, MSG_KEYNAME_F4, MSG_KEYNAME_F5, MSG_KEYNAME_F6,
|
||||
MSG_KEYNAME_F7,
|
||||
MSG_KEYNAME_F8, MSG_KEYNAME_F9, MSG_KEYNAME_F10, MSG_KEYNAME_NUMLOCK,
|
||||
MSG_KEYNAME_SCROLLLOCK,
|
||||
MSG_KEYNAME_KP7, MSG_KEYNAME_KP8, MSG_KEYNAME_KP9, MSG_KEYNAME_KPMINUS,
|
||||
MSG_KEYNAME_KP4,
|
||||
MSG_KEYNAME_KP5, MSG_KEYNAME_KP6, MSG_KEYNAME_KPPLUS, MSG_KEYNAME_KP1,
|
||||
MSG_KEYNAME_KP2,
|
||||
MSG_KEYNAME_KP3, MSG_KEYNAME_KP0, MSG_KEYNAME_KPDOT, MSG_KEYNAME_103RD,
|
||||
MSG_KEYNAME_F13,
|
||||
MSG_KEYNAME_102ND, MSG_KEYNAME_F11, MSG_KEYNAME_F12, MSG_KEYNAME_F14,
|
||||
MSG_KEYNAME_F15,
|
||||
MSG_KEYNAME_F16, MSG_KEYNAME_F17, MSG_KEYNAME_F18, MSG_KEYNAME_F19,
|
||||
MSG_KEYNAME_F20,
|
||||
MSG_KEYNAME_KPENTER, MSG_KEYNAME_RIGHTCTRL, MSG_KEYNAME_KPSLASH,
|
||||
MSG_KEYNAME_SYSRQ, MSG_KEYNAME_RIGHTALT,
|
||||
MSG_KEYNAME_LF, MSG_KEYNAME_HOME, MSG_KEYNAME_UP, MSG_KEYNAME_PGUP,
|
||||
MSG_KEYNAME_LEFT,
|
||||
MSG_KEYNAME_RIGHT, MSG_KEYNAME_END, MSG_KEYNAME_DOWN, MSG_KEYNAME_PGDN,
|
||||
MSG_KEYNAME_INS,
|
||||
MSG_KEYNAME_DEL, MSG_KEYNAME_MACRO, MSG_KEYNAME_MUTE,
|
||||
MSG_KEYNAME_VOLDOWN, MSG_KEYNAME_VOLUP,
|
||||
MSG_KEYNAME_POWER, MSG_KEYNAME_KPEQUAL, MSG_KEYNAME_KPPLUSDASH, MSG_KEYNAME_PAUSE, MSG_KEYNAME_F21,
|
||||
MSG_KEYNAME_F22, MSG_KEYNAME_F23, MSG_KEYNAME_F24, MSG_KEYNAME_KPCOMMA, MSG_KEYNAME_LEFTMETA,
|
||||
MSG_KEYNAME_RIGHTMETA, MSG_KEYNAME_COMPOSE, MSG_KEYNAME_STOP,
|
||||
MSG_KEYNAME_AGAIN, MSG_KEYNAME_PROPS,
|
||||
MSG_KEYNAME_UNDO, MSG_KEYNAME_FRONT, MSG_KEYNAME_COPY, MSG_KEYNAME_OPEN,
|
||||
MSG_KEYNAME_PASTE,
|
||||
MSG_KEYNAME_FIND, MSG_KEYNAME_CUT, MSG_KEYNAME_HELP, MSG_KEYNAME_MENU,
|
||||
MSG_KEYNAME_CALC,
|
||||
MSG_KEYNAME_SETUP, MSG_KEYNAME_SLEEP, MSG_KEYNAME_WAKEUP,
|
||||
MSG_KEYNAME_FILE, MSG_KEYNAME_SENDFILE,
|
||||
MSG_KEYNAME_DELFILE, MSG_KEYNAME_XFER, MSG_KEYNAME_PROG1,
|
||||
MSG_KEYNAME_PROG2, MSG_KEYNAME_WWW,
|
||||
MSG_KEYNAME_MSDOS, MSG_KEYNAME_COFFEE, MSG_KEYNAME_DIRECTION,
|
||||
MSG_KEYNAME_CYCLEWINDOWS, MSG_KEYNAME_MAIL,
|
||||
MSG_KEYNAME_BOOKMARKS, MSG_KEYNAME_COMPUTER, MSG_KEYNAME_BACK,
|
||||
MSG_KEYNAME_FORWARD, MSG_KEYNAME_CLOSECD,
|
||||
MSG_KEYNAME_EJECTCD, MSG_KEYNAME_EJECTCLOSE, MSG_KEYNAME_NEXTSONG,
|
||||
MSG_KEYNAME_PLAYPAUSE, MSG_KEYNAME_PREVSONG,
|
||||
MSG_KEYNAME_STOPCD, MSG_KEYNAME_RECORD, MSG_KEYNAME_REWIND,
|
||||
MSG_KEYNAME_PHONE, MSG_KEYNAME_ISO,
|
||||
MSG_KEYNAME_CONFIG, MSG_KEYNAME_HOMEPG, MSG_KEYNAME_REFRESH,
|
||||
MSG_KEYNAME_EXIT, MSG_KEYNAME_MOVE,
|
||||
MSG_KEYNAME_EDIT, MSG_KEYNAME_SCROLLUP, MSG_KEYNAME_SCROLLDN,
|
||||
MSG_KEYNAME_KPLEFTPAR, MSG_KEYNAME_KPRIGHTPAR,
|
||||
MSG_KEYNAMES_END = MSG_KEYNAME_KPRIGHTPAR,
|
||||
|
||||
MSG_FUNCNAMES_START,
|
||||
MSG_FUNCNAME_ATTRIB_BLEEP_DEC = MSG_FUNCNAMES_START,
|
||||
MSG_FUNCNAME_ATTRIB_BLEEP_INC,
|
||||
MSG_FUNCNAME_BLEEPS_DEC, MSG_FUNCNAME_BLEEPS_INC,
|
||||
MSG_FUNCNAME_CHAR_FIRST, MSG_FUNCNAME_CHAR_LAST,
|
||||
MSG_FUNCNAME_CHAR_CURRENT, MSG_FUNCNAME_CHAR_HEX_AND_DEC,
|
||||
MSG_FUNCNAME_CHAR_NEXT,
|
||||
MSG_FUNCNAME_CHAR_PHONETIC, MSG_FUNCNAME_CHAR_PREVIOUS,
|
||||
MSG_FUNCNAME_CURSOR_PARK, MSG_FUNCNAME_CUT,
|
||||
MSG_FUNCNAME_EDIT_DELIM, MSG_FUNCNAME_EDIT_EXNUM,
|
||||
MSG_FUNCNAME_EDIT_MOST, MSG_FUNCNAME_EDIT_REPEATS, MSG_FUNCNAME_EDIT_SOME,
|
||||
MSG_FUNCNAME_GOTO, MSG_FUNCNAME_GOTO_BOTTOM, MSG_FUNCNAME_GOTO_LEFT,
|
||||
MSG_FUNCNAME_GOTO_RIGHT, MSG_FUNCNAME_GOTO_TOP, MSG_FUNCNAME_HELP,
|
||||
MSG_FUNCNAME_LINE_SAY_CURRENT, MSG_FUNCNAME_LINE_SAY_NEXT,
|
||||
MSG_FUNCNAME_LINE_SAY_PREVIOUS, MSG_FUNCNAME_LINE_SAY_WITH_INDENT,
|
||||
MSG_FUNCNAME_PASTE, MSG_FUNCNAME_PITCH_DEC, MSG_FUNCNAME_PITCH_INC,
|
||||
MSG_FUNCNAME_PUNC_DEC, MSG_FUNCNAME_PUNC_INC,
|
||||
MSG_FUNCNAME_PUNC_LEVEL_DEC, MSG_FUNCNAME_PUNC_LEVEL_INC,
|
||||
MSG_FUNCNAME_QUIET,
|
||||
MSG_FUNCNAME_RATE_DEC, MSG_FUNCNAME_RATE_INC,
|
||||
MSG_FUNCNAME_READING_PUNC_DEC, MSG_FUNCNAME_READING_PUNC_INC,
|
||||
MSG_FUNCNAME_SAY_ATTRIBUTES,
|
||||
MSG_FUNCNAME_SAY_FROM_LEFT, MSG_FUNCNAME_SAY_FROM_TOP,
|
||||
MSG_FUNCNAME_SAY_POSITION, MSG_FUNCNAME_SAY_SCREEN,
|
||||
MSG_FUNCNAME_SAY_TO_BOTTOM, MSG_FUNCNAME_SAY_TO_RIGHT,
|
||||
MSG_FUNCNAME_SPEAKUP, MSG_FUNCNAME_SPEAKUP_LOCK,
|
||||
MSG_FUNCNAME_SPEAKUP_OFF, MSG_FUNCNAME_SPEECH_KILL,
|
||||
MSG_FUNCNAME_SPELL_DELAY_DEC, MSG_FUNCNAME_SPELL_DELAY_INC,
|
||||
MSG_FUNCNAME_SPELL_WORD, MSG_FUNCNAME_SPELL_WORD_PHONETICALLY,
|
||||
MSG_FUNCNAME_TONE_DEC, MSG_FUNCNAME_TONE_INC,
|
||||
MSG_FUNCNAME_VOICE_DEC, MSG_FUNCNAME_VOICE_INC,
|
||||
MSG_FUNCNAME_VOLUME_DEC, MSG_FUNCNAME_VOLUME_INC,
|
||||
MSG_FUNCNAME_WINDOW_CLEAR, MSG_FUNCNAME_WINDOW_SAY,
|
||||
MSG_FUNCNAME_WINDOW_SET, MSG_FUNCNAME_WINDOW_SILENCE,
|
||||
MSG_FUNCNAME_WORD_SAY_CURRENT, MSG_FUNCNAME_WORD_SAY_NEXT,
|
||||
MSG_FUNCNAME_WORD_SAY_PREVIOUS,
|
||||
MSG_FUNCNAMES_END = MSG_FUNCNAME_WORD_SAY_PREVIOUS,
|
||||
|
||||
/* all valid indices must be above this */
|
||||
MSG_LAST_INDEX
|
||||
};
|
||||
|
||||
struct msg_group_t {
|
||||
char *name;
|
||||
enum msg_index_t start;
|
||||
enum msg_index_t end;
|
||||
};
|
||||
|
||||
extern char *msg_get(enum msg_index_t index);
|
||||
extern ssize_t msg_set(enum msg_index_t index, char *text, size_t length);
|
||||
extern struct msg_group_t *find_msg_group(const char *group_name);
|
||||
extern void reset_msg_group(struct msg_group_t *group);
|
||||
extern void initialize_msgs(void);
|
||||
extern void free_user_msgs(void);
|
||||
|
||||
#endif
|
212
drivers/staging/speakup/keyhelp.c
Normal file
212
drivers/staging/speakup/keyhelp.c
Normal file
@ -0,0 +1,212 @@
|
||||
/* speakup_keyhelp.c
|
||||
help module for speakup
|
||||
|
||||
written by David Borowski.
|
||||
|
||||
Copyright (C) 2003 David Borowski.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <linux/keyboard.h>
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define MAXFUNCS 130
|
||||
#define MAXKEYS 256
|
||||
static const int num_key_names = MSG_KEYNAMES_END - MSG_KEYNAMES_START + 1;
|
||||
static u_short key_offsets[MAXFUNCS], key_data[MAXKEYS];
|
||||
static u_short masks[] = { 32, 16, 8, 4, 2, 1 };
|
||||
|
||||
static short letter_offsets[26] =
|
||||
{ -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1 };
|
||||
|
||||
static u_char funcvals[] = {
|
||||
ATTRIB_BLEEP_DEC, ATTRIB_BLEEP_INC, BLEEPS_DEC, BLEEPS_INC,
|
||||
SAY_FIRST_CHAR, SAY_LAST_CHAR, SAY_CHAR, SAY_CHAR_NUM,
|
||||
SAY_NEXT_CHAR, SAY_PHONETIC_CHAR, SAY_PREV_CHAR, SPEAKUP_PARKED,
|
||||
SPEAKUP_CUT, EDIT_DELIM, EDIT_EXNUM, EDIT_MOST,
|
||||
EDIT_REPEAT, EDIT_SOME, SPEAKUP_GOTO, BOTTOM_EDGE,
|
||||
LEFT_EDGE, RIGHT_EDGE, TOP_EDGE, SPEAKUP_HELP,
|
||||
SAY_LINE, SAY_NEXT_LINE, SAY_PREV_LINE, SAY_LINE_INDENT,
|
||||
SPEAKUP_PASTE, PITCH_DEC, PITCH_INC, PUNCT_DEC,
|
||||
PUNCT_INC, PUNC_LEVEL_DEC, PUNC_LEVEL_INC, SPEAKUP_QUIET,
|
||||
RATE_DEC, RATE_INC, READING_PUNC_DEC, READING_PUNC_INC,
|
||||
SAY_ATTRIBUTES, SAY_FROM_LEFT, SAY_FROM_TOP, SAY_POSITION,
|
||||
SAY_SCREEN, SAY_TO_BOTTOM, SAY_TO_RIGHT, SPK_KEY,
|
||||
SPK_LOCK, SPEAKUP_OFF, SPEECH_KILL, SPELL_DELAY_DEC,
|
||||
SPELL_DELAY_INC, SPELL_WORD, SPELL_PHONETIC, TONE_DEC,
|
||||
TONE_INC, VOICE_DEC, VOICE_INC, VOL_DEC,
|
||||
VOL_INC, CLEAR_WIN, SAY_WIN, SET_WIN,
|
||||
ENABLE_WIN, SAY_WORD, SAY_NEXT_WORD, SAY_PREV_WORD, 0
|
||||
};
|
||||
|
||||
static u_char *state_tbl;
|
||||
static int cur_item, nstates;
|
||||
|
||||
static void build_key_data(void)
|
||||
{
|
||||
u_char *kp, counters[MAXFUNCS], ch, ch1;
|
||||
u_short *p_key = key_data, key;
|
||||
int i, offset = 1;
|
||||
nstates = (int)(state_tbl[-1]);
|
||||
memset(counters, 0, sizeof(counters));
|
||||
memset(key_offsets, 0, sizeof(key_offsets));
|
||||
kp = state_tbl + nstates + 1;
|
||||
while (*kp++) {
|
||||
/* count occurrances of each function */
|
||||
for (i = 0; i < nstates; i++, kp++) {
|
||||
if (!*kp)
|
||||
continue;
|
||||
if ((state_tbl[i]&16) != 0 && *kp == SPK_KEY)
|
||||
continue;
|
||||
counters[*kp]++;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < MAXFUNCS; i++) {
|
||||
if (counters[i] == 0)
|
||||
continue;
|
||||
key_offsets[i] = offset;
|
||||
offset += (counters[i]+1);
|
||||
if (offset >= MAXKEYS)
|
||||
break;
|
||||
}
|
||||
/* leave counters set so high keycodes come first.
|
||||
this is done so num pad and other extended keys maps are spoken before
|
||||
the alpha with speakup type mapping. */
|
||||
kp = state_tbl + nstates + 1;
|
||||
while ((ch = *kp++)) {
|
||||
for (i = 0; i < nstates; i++) {
|
||||
ch1 = *kp++;
|
||||
if (!ch1)
|
||||
continue;
|
||||
if ((state_tbl[i]&16) != 0 && ch1 == SPK_KEY)
|
||||
continue;
|
||||
key = (state_tbl[i] << 8) + ch;
|
||||
counters[ch1]--;
|
||||
offset = key_offsets[ch1];
|
||||
if (!offset)
|
||||
continue;
|
||||
p_key = key_data + offset + counters[ch1];
|
||||
*p_key = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void say_key(int key)
|
||||
{
|
||||
int i, state = key >> 8;
|
||||
key &= 0xff;
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (state & masks[i])
|
||||
synth_printf(" %s", msg_get(MSG_STATES_START + i));
|
||||
}
|
||||
if ((key > 0) && (key <= num_key_names))
|
||||
synth_printf(" %s\n", msg_get(MSG_KEYNAMES_START + (key - 1)));
|
||||
}
|
||||
|
||||
static int help_init(void)
|
||||
{
|
||||
char start = SPACE;
|
||||
int i;
|
||||
int num_funcs = MSG_FUNCNAMES_END - MSG_FUNCNAMES_START + 1;
|
||||
state_tbl = our_keys[0]+SHIFT_TBL_SIZE+2;
|
||||
for (i = 0; i < num_funcs; i++) {
|
||||
char *cur_funcname = msg_get(MSG_FUNCNAMES_START + i);
|
||||
if (start == *cur_funcname)
|
||||
continue;
|
||||
start = *cur_funcname;
|
||||
letter_offsets[(start&31)-1] = i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
|
||||
{
|
||||
int i, n;
|
||||
char *name;
|
||||
u_char func, *kp;
|
||||
u_short *p_keys, val;
|
||||
if (letter_offsets[0] == -1)
|
||||
help_init();
|
||||
if (type == KT_LATIN) {
|
||||
if (ch == SPACE) {
|
||||
special_handler = NULL;
|
||||
synth_printf("%s\n", msg_get(MSG_LEAVING_HELP));
|
||||
return 1;
|
||||
}
|
||||
ch |= 32; /* lower case */
|
||||
if (ch < 'a' || ch > 'z')
|
||||
return -1;
|
||||
if (letter_offsets[ch-'a'] == -1) {
|
||||
synth_printf(msg_get(MSG_NO_COMMAND), ch);
|
||||
synth_printf("\n");
|
||||
return 1;
|
||||
}
|
||||
cur_item = letter_offsets[ch-'a'];
|
||||
} else if (type == KT_CUR) {
|
||||
if (ch == 0 && (cur_item + 1) <= MSG_FUNCNAMES_END)
|
||||
cur_item++;
|
||||
else if (ch == 3 && cur_item > 0)
|
||||
cur_item--;
|
||||
else
|
||||
return -1;
|
||||
} else if (type == KT_SPKUP && ch == SPEAKUP_HELP && !special_handler) {
|
||||
special_handler = handle_help;
|
||||
synth_printf("%s\n", msg_get(MSG_HELP_INFO));
|
||||
build_key_data(); /* rebuild each time in case new mapping */
|
||||
return 1;
|
||||
} else {
|
||||
name = NULL;
|
||||
if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
|
||||
synth_printf("%s\n", msg_get(MSG_KEYNAMES_START + key-1));
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; funcvals[i] != 0 && !name; i++) {
|
||||
if (ch == funcvals[i])
|
||||
name = msg_get(MSG_FUNCNAMES_START + i);
|
||||
}
|
||||
if (!name)
|
||||
return -1;
|
||||
kp = our_keys[key]+1;
|
||||
for (i = 0; i < nstates; i++) {
|
||||
if (ch == kp[i])
|
||||
break;
|
||||
}
|
||||
key += (state_tbl[i] << 8);
|
||||
say_key(key);
|
||||
synth_printf(msg_get(MSG_KEYDESC), name);
|
||||
synth_printf("\n");
|
||||
return 1;
|
||||
}
|
||||
name = msg_get(MSG_FUNCNAMES_START + cur_item);
|
||||
func = funcvals[cur_item];
|
||||
synth_printf("%s", name);
|
||||
if (key_offsets[func] == 0) {
|
||||
synth_printf(" %s\n", msg_get(MSG_IS_UNASSIGNED));
|
||||
return 1;
|
||||
}
|
||||
p_keys = key_data + key_offsets[func];
|
||||
for (n = 0; p_keys[n]; n++) {
|
||||
val = p_keys[n];
|
||||
if (n > 0)
|
||||
synth_printf("%s ", msg_get(MSG_DISJUNCTION));
|
||||
say_key(val);
|
||||
}
|
||||
return 1;
|
||||
}
|
1007
drivers/staging/speakup/kobjects.c
Normal file
1007
drivers/staging/speakup/kobjects.c
Normal file
File diff suppressed because it is too large
Load Diff
2304
drivers/staging/speakup/main.c
Normal file
2304
drivers/staging/speakup/main.c
Normal file
File diff suppressed because it is too large
Load Diff
155
drivers/staging/speakup/selection.c
Normal file
155
drivers/staging/speakup/selection.c
Normal file
@ -0,0 +1,155 @@
|
||||
#include <linux/slab.h> /* for kmalloc */
|
||||
#include <linux/consolemap.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/selection.h>
|
||||
|
||||
#include "speakup.h"
|
||||
|
||||
/* ------ cut and paste ----- */
|
||||
/* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
|
||||
#define ishardspace(c) ((c) == ' ')
|
||||
|
||||
unsigned short xs, ys, xe, ye; /* our region points */
|
||||
|
||||
/* Variables for selection control. */
|
||||
/* must not be disallocated */
|
||||
struct vc_data *spk_sel_cons;
|
||||
/* cleared by clear_selection */
|
||||
static int sel_start = -1;
|
||||
static int sel_end;
|
||||
static int sel_buffer_lth;
|
||||
static char *sel_buffer;
|
||||
|
||||
static unsigned char sel_pos(int n)
|
||||
{
|
||||
return inverse_translate(spk_sel_cons, screen_glyph(spk_sel_cons, n), 0);
|
||||
}
|
||||
|
||||
void speakup_clear_selection(void)
|
||||
{
|
||||
sel_start = -1;
|
||||
}
|
||||
|
||||
/* does screen address p correspond to character at LH/RH edge of screen? */
|
||||
static int atedge(const int p, int size_row)
|
||||
{
|
||||
return (!(p % size_row) || !((p + 2) % size_row));
|
||||
}
|
||||
|
||||
/* constrain v such that v <= u */
|
||||
static unsigned short limit(const unsigned short v, const unsigned short u)
|
||||
{
|
||||
return (v > u) ? u : v;
|
||||
}
|
||||
|
||||
int speakup_set_selection(struct tty_struct *tty)
|
||||
{
|
||||
int new_sel_start, new_sel_end;
|
||||
char *bp, *obp;
|
||||
int i, ps, pe;
|
||||
struct vc_data *vc = vc_cons[fg_console].d;
|
||||
|
||||
xs = limit(xs, vc->vc_cols - 1);
|
||||
ys = limit(ys, vc->vc_rows - 1);
|
||||
xe = limit(xe, vc->vc_cols - 1);
|
||||
ye = limit(ye, vc->vc_rows - 1);
|
||||
ps = ys * vc->vc_size_row + (xs << 1);
|
||||
pe = ye * vc->vc_size_row + (xe << 1);
|
||||
|
||||
if (ps > pe) {
|
||||
/* make sel_start <= sel_end */
|
||||
int tmp = ps;
|
||||
ps = pe;
|
||||
pe = tmp;
|
||||
}
|
||||
|
||||
if (spk_sel_cons != vc_cons[fg_console].d) {
|
||||
speakup_clear_selection();
|
||||
spk_sel_cons = vc_cons[fg_console].d;
|
||||
printk(KERN_WARNING
|
||||
"Selection: mark console not the same as cut\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
new_sel_start = ps;
|
||||
new_sel_end = pe;
|
||||
|
||||
/* select to end of line if on trailing space */
|
||||
if (new_sel_end > new_sel_start &&
|
||||
!atedge(new_sel_end, vc->vc_size_row) &&
|
||||
ishardspace(sel_pos(new_sel_end))) {
|
||||
for (pe = new_sel_end + 2; ; pe += 2)
|
||||
if (!ishardspace(sel_pos(pe)) ||
|
||||
atedge(pe, vc->vc_size_row))
|
||||
break;
|
||||
if (ishardspace(sel_pos(pe)))
|
||||
new_sel_end = pe;
|
||||
}
|
||||
if ((new_sel_start == sel_start) && (new_sel_end == sel_end))
|
||||
return 0; /* no action required */
|
||||
|
||||
sel_start = new_sel_start;
|
||||
sel_end = new_sel_end;
|
||||
/* Allocate a new buffer before freeing the old one ... */
|
||||
bp = kmalloc((sel_end-sel_start)/2+1, GFP_ATOMIC);
|
||||
if (!bp) {
|
||||
printk(KERN_WARNING "selection: kmalloc() failed\n");
|
||||
speakup_clear_selection();
|
||||
return -ENOMEM;
|
||||
}
|
||||
kfree(sel_buffer);
|
||||
sel_buffer = bp;
|
||||
|
||||
obp = bp;
|
||||
for (i = sel_start; i <= sel_end; i += 2) {
|
||||
*bp = sel_pos(i);
|
||||
if (!ishardspace(*bp++))
|
||||
obp = bp;
|
||||
if (!((i + 2) % vc->vc_size_row)) {
|
||||
/* strip trailing blanks from line and add newline,
|
||||
unless non-space at end of line. */
|
||||
if (obp != bp) {
|
||||
bp = obp;
|
||||
*bp++ = '\r';
|
||||
}
|
||||
obp = bp;
|
||||
}
|
||||
}
|
||||
sel_buffer_lth = bp - sel_buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO: move to some helper thread, probably. That'd fix having to check for
|
||||
* in_atomic(). */
|
||||
int speakup_paste_selection(struct tty_struct *tty)
|
||||
{
|
||||
struct vc_data *vc = (struct vc_data *) tty->driver_data;
|
||||
int pasted = 0, count;
|
||||
DECLARE_WAITQUEUE(wait, current);
|
||||
add_wait_queue(&vc->paste_wait, &wait);
|
||||
while (sel_buffer && sel_buffer_lth > pasted) {
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
if (test_bit(TTY_THROTTLED, &tty->flags)) {
|
||||
if (in_atomic())
|
||||
/* can't be performed in an interrupt handler, abort */
|
||||
break;
|
||||
schedule();
|
||||
continue;
|
||||
}
|
||||
count = sel_buffer_lth - pasted;
|
||||
count = min_t(int, count, tty->receive_room);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
|
||||
tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, 0, count);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
|
||||
tty->ldisc.ops->receive_buf(tty, sel_buffer + pasted, 0, count);
|
||||
#else
|
||||
tty->ldisc.receive_buf(tty, sel_buffer + pasted, 0, count);
|
||||
#endif
|
||||
pasted += count;
|
||||
}
|
||||
remove_wait_queue(&vc->paste_wait, &wait);
|
||||
current->state = TASK_RUNNING;
|
||||
return 0;
|
||||
}
|
||||
|
212
drivers/staging/speakup/serialio.c
Normal file
212
drivers/staging/speakup/serialio.c
Normal file
@ -0,0 +1,212 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/ioport.h>
|
||||
|
||||
#include "spk_types.h"
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
|
||||
static void start_serial_interrupt(int irq);
|
||||
|
||||
static struct serial_state rs_table[] = {
|
||||
SERIAL_PORT_DFNS
|
||||
};
|
||||
static struct serial_state *serstate;
|
||||
static int timeouts;
|
||||
|
||||
struct serial_state *spk_serial_init(int index)
|
||||
{
|
||||
int baud = 9600, quot = 0;
|
||||
unsigned int cval = 0;
|
||||
int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
|
||||
struct serial_state *ser = NULL;
|
||||
int err;
|
||||
|
||||
ser = rs_table + index;
|
||||
/* Divisor, bytesize and parity */
|
||||
quot = ser->baud_base / baud;
|
||||
cval = cflag & (CSIZE | CSTOPB);
|
||||
#if defined(__powerpc__) || defined(__alpha__)
|
||||
cval >>= 8;
|
||||
#else /* !__powerpc__ && !__alpha__ */
|
||||
cval >>= 4;
|
||||
#endif /* !__powerpc__ && !__alpha__ */
|
||||
if (cflag & PARENB)
|
||||
cval |= UART_LCR_PARITY;
|
||||
if (!(cflag & PARODD))
|
||||
cval |= UART_LCR_EPAR;
|
||||
if (synth_request_region(ser->port, 8)) {
|
||||
/* try to take it back. */
|
||||
printk("Ports not available, trying to steal them\n");
|
||||
__release_region(&ioport_resource, ser->port, 8);
|
||||
err = synth_request_region(ser->port, 8);
|
||||
if (err) {
|
||||
pr_warn("Unable to allocate port at %x, errno %i", ser->port, err);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable UART interrupts, set DTR and RTS high
|
||||
* and set speed. */
|
||||
outb(cval | UART_LCR_DLAB, ser->port + UART_LCR); /* set DLAB */
|
||||
outb(quot & 0xff, ser->port + UART_DLL); /* LS of divisor */
|
||||
outb(quot >> 8, ser->port + UART_DLM); /* MS of divisor */
|
||||
outb(cval, ser->port + UART_LCR); /* reset DLAB */
|
||||
|
||||
/* Turn off Interrupts */
|
||||
outb(0, ser->port + UART_IER);
|
||||
outb(UART_MCR_DTR | UART_MCR_RTS, ser->port + UART_MCR);
|
||||
|
||||
/* If we read 0xff from the LSR, there is no UART here. */
|
||||
if (inb(ser->port + UART_LSR) == 0xff) {
|
||||
synth_release_region(ser->port, 8);
|
||||
serstate = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mdelay(1);
|
||||
speakup_info.port_tts = ser->port;
|
||||
serstate = ser;
|
||||
|
||||
start_serial_interrupt(ser->irq);
|
||||
|
||||
return ser;
|
||||
}
|
||||
|
||||
static irqreturn_t synth_readbuf_handler(int irq, void *dev_id)
|
||||
{
|
||||
unsigned long flags;
|
||||
/*printk(KERN_ERR "in irq\n"); */
|
||||
/*pr_warn("in IRQ\n"); */
|
||||
int c;
|
||||
spk_lock(flags);
|
||||
while (inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR) {
|
||||
|
||||
c = inb_p(speakup_info.port_tts+UART_RX);
|
||||
synth->read_buff_add((u_char) c);
|
||||
/*printk(KERN_ERR "c = %d\n", c); */
|
||||
/*pr_warn("C = %d\n", c); */
|
||||
}
|
||||
spk_unlock(flags);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void start_serial_interrupt(int irq)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (synth->read_buff_add == NULL)
|
||||
return;
|
||||
|
||||
rv = request_irq(irq, synth_readbuf_handler, IRQF_SHARED,
|
||||
"serial", (void *) synth_readbuf_handler);
|
||||
|
||||
if (rv)
|
||||
printk(KERN_ERR "Unable to request Speakup serial I R Q\n");
|
||||
/* Set MCR */
|
||||
outb(UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2,
|
||||
speakup_info.port_tts + UART_MCR);
|
||||
/* Turn on Interrupts */
|
||||
outb(UART_IER_MSI|UART_IER_RLSI|UART_IER_RDI,
|
||||
speakup_info.port_tts + UART_IER);
|
||||
inb(speakup_info.port_tts+UART_LSR);
|
||||
inb(speakup_info.port_tts+UART_RX);
|
||||
inb(speakup_info.port_tts+UART_IIR);
|
||||
inb(speakup_info.port_tts+UART_MSR);
|
||||
outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */
|
||||
}
|
||||
|
||||
void stop_serial_interrupt(void)
|
||||
{
|
||||
if (speakup_info.port_tts == 0)
|
||||
return;
|
||||
|
||||
if (synth->read_buff_add == NULL)
|
||||
return;
|
||||
|
||||
/* Turn off interrupts */
|
||||
outb(0, speakup_info.port_tts+UART_IER);
|
||||
/* Free IRQ */
|
||||
free_irq(serstate->irq, (void *) synth_readbuf_handler);
|
||||
}
|
||||
|
||||
int wait_for_xmitr(void)
|
||||
{
|
||||
int tmout = SPK_XMITR_TIMEOUT;
|
||||
if ((synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) {
|
||||
pr_warn("%s: too many timeouts, deactivating speakup\n", synth->long_name);
|
||||
synth->alive = 0;
|
||||
/* No synth any more, so nobody will restart TTYs, and we thus
|
||||
* need to do it ourselves. Now that there is no synth we can
|
||||
* let application flood anyway */
|
||||
speakup_start_ttys();
|
||||
timeouts = 0;
|
||||
return 0;
|
||||
}
|
||||
while (spk_serial_tx_busy()) {
|
||||
if (--tmout == 0) {
|
||||
pr_warn("%s: timed out (tx busy)\n", synth->long_name);
|
||||
timeouts++;
|
||||
return 0;
|
||||
}
|
||||
udelay(1);
|
||||
}
|
||||
tmout = SPK_CTS_TIMEOUT;
|
||||
while (!((inb_p(speakup_info.port_tts + UART_MSR)) & UART_MSR_CTS)) {
|
||||
/* CTS */
|
||||
if (--tmout == 0) {
|
||||
// pr_warn("%s: timed out (cts)\n", synth->long_name);
|
||||
timeouts++;
|
||||
return 0;
|
||||
}
|
||||
udelay(1);
|
||||
}
|
||||
timeouts = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned char spk_serial_in(void)
|
||||
{
|
||||
int tmout = SPK_SERIAL_TIMEOUT;
|
||||
|
||||
while (!(inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)) {
|
||||
if (--tmout == 0) {
|
||||
pr_warn("time out while waiting for input.\n");
|
||||
return 0xff;
|
||||
}
|
||||
udelay(1);
|
||||
}
|
||||
return inb_p(speakup_info.port_tts + UART_RX);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_serial_in);
|
||||
|
||||
unsigned char spk_serial_in_nowait(void)
|
||||
{
|
||||
unsigned char lsr;
|
||||
|
||||
lsr = inb_p(speakup_info.port_tts + UART_LSR);
|
||||
if (!(lsr & UART_LSR_DR))
|
||||
return 0;
|
||||
return inb_p(speakup_info.port_tts + UART_RX);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_serial_in_nowait);
|
||||
|
||||
int spk_serial_out(const char ch)
|
||||
{
|
||||
if (synth->alive && wait_for_xmitr()) {
|
||||
outb_p(ch, speakup_info.port_tts);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_serial_out);
|
||||
|
||||
void spk_serial_release(void)
|
||||
{
|
||||
if (speakup_info.port_tts == 0)
|
||||
return;
|
||||
synth_release_region(speakup_info.port_tts, 8);
|
||||
speakup_info.port_tts = 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_serial_release);
|
||||
|
55
drivers/staging/speakup/serialio.h
Normal file
55
drivers/staging/speakup/serialio.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef _SPEAKUP_SERIAL_H
|
||||
#define _SPEAKUP_SERIAL_H
|
||||
|
||||
#include <linux/serial.h> /* for rs_table, serial constants &
|
||||
serial_uart_config */
|
||||
#include <linux/serial_reg.h> /* for more serial constants */
|
||||
#include <linux/serialP.h> /* for struct serial_state */
|
||||
#ifndef __sparc__
|
||||
#include <asm/serial.h>
|
||||
#endif
|
||||
|
||||
/* countdown values for serial timeouts in us */
|
||||
#define SPK_SERIAL_TIMEOUT 100000
|
||||
/* countdown values transmitter/dsr timeouts in us */
|
||||
#define SPK_XMITR_TIMEOUT 100000
|
||||
/* countdown values cts timeouts in us */
|
||||
#define SPK_CTS_TIMEOUT 100000
|
||||
/* check ttyS0 ... ttyS3 */
|
||||
#define SPK_LO_TTY 0
|
||||
#define SPK_HI_TTY 3
|
||||
/* # of timeouts permitted before disable */
|
||||
#define NUM_DISABLE_TIMEOUTS 3
|
||||
/* buffer timeout in ms */
|
||||
#define SPK_TIMEOUT 100
|
||||
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
|
||||
|
||||
#define spk_serial_tx_busy() ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY)
|
||||
|
||||
/* 2.6.22 doesn't have them any more, hardcode it for now (these values should
|
||||
* be fine for 99% cases) */
|
||||
#ifndef BASE_BAUD
|
||||
#define BASE_BAUD (1843200 / 16)
|
||||
#endif
|
||||
#ifndef STD_COM_FLAGS
|
||||
#ifdef CONFIG_SERIAL_DETECT_IRQ
|
||||
#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
|
||||
#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
|
||||
#else
|
||||
#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
|
||||
#define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SERIAL_PORT_DFNS
|
||||
#define SERIAL_PORT_DFNS \
|
||||
/* UART CLK PORT IRQ FLAGS */ \
|
||||
{ 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
|
||||
{ 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
|
||||
{ 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
|
||||
{ 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
|
||||
#endif
|
||||
#ifndef IRQF_SHARED
|
||||
#define IRQF_SHARED SA_SHIRQ
|
||||
#endif
|
||||
|
||||
#endif
|
127
drivers/staging/speakup/speakup.h
Normal file
127
drivers/staging/speakup/speakup.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef _SPEAKUP_H
|
||||
#define _SPEAKUP_H
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "spk_types.h"
|
||||
#include "i18n.h"
|
||||
|
||||
#define SPEAKUP_VERSION "3.1.6"
|
||||
#define KEY_MAP_VER 119
|
||||
#define SHIFT_TBL_SIZE 64
|
||||
#define MAX_DESC_LEN 72
|
||||
|
||||
/* proc permissions */
|
||||
#define USER_R (S_IFREG|S_IRUGO)
|
||||
#define USER_W (S_IFREG|S_IWUGO)
|
||||
#define USER_RW (S_IFREG|S_IRUGO|S_IWUGO)
|
||||
#define ROOT_W (S_IFREG|S_IRUGO|S_IWUSR)
|
||||
|
||||
#define TOGGLE_0 .u.n = {NULL, 0, 0, 1, 0, 0, NULL }
|
||||
#define TOGGLE_1 .u.n = {NULL, 1, 0, 1, 0, 0, NULL }
|
||||
#define MAXVARLEN 15
|
||||
|
||||
#define SYNTH_OK 0x0001
|
||||
#define B_ALPHA 0x0002
|
||||
#define ALPHA 0x0003
|
||||
#define B_CAP 0x0004
|
||||
#define A_CAP 0x0007
|
||||
#define B_NUM 0x0008
|
||||
#define NUM 0x0009
|
||||
#define ALPHANUM (B_ALPHA|B_NUM)
|
||||
#define SOME 0x0010
|
||||
#define MOST 0x0020
|
||||
#define PUNC 0x0040
|
||||
#define A_PUNC 0x0041
|
||||
#define B_WDLM 0x0080
|
||||
#define WDLM 0x0081
|
||||
#define B_EXNUM 0x0100
|
||||
#define CH_RPT 0x0200
|
||||
#define B_CTL 0x0400
|
||||
#define A_CTL (B_CTL+SYNTH_OK)
|
||||
#define B_SYM 0x0800
|
||||
#define B_CAPSYM (B_CAP|B_SYM)
|
||||
|
||||
#define IS_WDLM(x) (spk_chartab[((u_char)x)]&B_WDLM)
|
||||
#define IS_CHAR(x, type) (spk_chartab[((u_char)x)]&type)
|
||||
#define IS_TYPE(x, type) ((spk_chartab[((u_char)x)]&type) == type)
|
||||
|
||||
#define SET_DEFAULT -4
|
||||
#define E_RANGE -3
|
||||
#define E_TOOLONG -2
|
||||
#define E_UNDEF -1
|
||||
|
||||
extern int speakup_thread(void *data);
|
||||
extern void reset_default_chars(void);
|
||||
extern void reset_default_chartab(void);
|
||||
extern void synth_start(void);
|
||||
extern int set_key_info(const u_char *key_info, u_char *k_buffer);
|
||||
extern char *strlwr(char *s);
|
||||
extern char *speakup_s2i(char *start, int *dest);
|
||||
extern char *s2uchar(char *start, char *dest);
|
||||
extern char *xlate(char *s);
|
||||
extern int speakup_kobj_init(void);
|
||||
extern void speakup_kobj_exit(void);
|
||||
extern int chartab_get_value(char *keyword);
|
||||
extern void speakup_register_var(struct var_t *var);
|
||||
extern void speakup_unregister_var(enum var_id_t var_id);
|
||||
extern struct st_var_header *get_var_header(enum var_id_t var_id);
|
||||
extern struct st_var_header *var_header_by_name(const char *name);
|
||||
extern struct punc_var_t *get_punc_var(enum var_id_t var_id);
|
||||
extern int set_num_var(int val, struct st_var_header *var, int how);
|
||||
extern int set_string_var(const char *page, struct st_var_header *var, int len);
|
||||
extern int set_mask_bits(const char *input, const int which, const int how);
|
||||
extern special_func special_handler;
|
||||
extern int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key);
|
||||
extern int synth_init(char *name);
|
||||
extern void synth_release(void);
|
||||
|
||||
extern void do_flush(void);
|
||||
extern void speakup_start_ttys(void);
|
||||
extern void synth_buffer_add(char ch);
|
||||
extern void synth_buffer_clear(void);
|
||||
extern void speakup_clear_selection(void);
|
||||
extern int speakup_set_selection(struct tty_struct *tty);
|
||||
extern int speakup_paste_selection(struct tty_struct *tty);
|
||||
extern void speakup_register_devsynth(void);
|
||||
extern void speakup_unregister_devsynth(void);
|
||||
extern void synth_write(const char *buf, size_t count);
|
||||
extern int synth_supports_indexing(void);
|
||||
|
||||
extern struct vc_data *spk_sel_cons;
|
||||
extern unsigned short xs, ys, xe, ye; /* our region points */
|
||||
|
||||
extern wait_queue_head_t speakup_event;
|
||||
extern struct kobject *speakup_kobj;
|
||||
extern struct task_struct *speakup_task;
|
||||
extern const u_char key_defaults[];
|
||||
|
||||
/* Protect speakup synthesizer list */
|
||||
extern struct mutex spk_mutex;
|
||||
extern struct st_spk_t *speakup_console[];
|
||||
extern struct spk_synth *synth;
|
||||
extern char pitch_buff[];
|
||||
extern u_char *our_keys[];
|
||||
extern short punc_masks[];
|
||||
extern char str_caps_start[], str_caps_stop[];
|
||||
extern const struct st_bits_data punc_info[];
|
||||
extern u_char key_buf[600];
|
||||
extern char *characters[];
|
||||
extern char *default_chars[];
|
||||
extern u_short spk_chartab[];
|
||||
extern int no_intr, say_ctrl, say_word_ctl, punc_level;
|
||||
extern int reading_punc, attrib_bleep, bleeps;
|
||||
extern int bleep_time, bell_pos;
|
||||
extern int spell_delay, key_echo;
|
||||
extern short punc_mask;
|
||||
extern short pitch_shift, synth_flags;
|
||||
extern int quiet_boot;
|
||||
extern char *synth_name;
|
||||
extern struct bleep unprocessed_sound;
|
||||
|
||||
/* Prototypes from fakekey.c. */
|
||||
int speakup_add_virtual_keyboard(void);
|
||||
void speakup_remove_virtual_keyboard(void);
|
||||
void speakup_fake_down_arrow(void);
|
||||
bool speakup_fake_key_pressed(void);
|
||||
|
||||
#endif
|
16
drivers/staging/speakup/speakup_acnt.h
Normal file
16
drivers/staging/speakup/speakup_acnt.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* speakup_acntpc.h - header file for speakups Accent-PC driver. */
|
||||
|
||||
#define SYNTH_IO_EXTENT 0x02
|
||||
|
||||
#define SYNTH_CLEAR 0x18 /* stops speech */
|
||||
|
||||
/* Port Status Flags */
|
||||
#define SYNTH_READABLE 0x01 /* mask for bit which is nonzero if a
|
||||
byte can be read from the data port */
|
||||
#define SYNTH_WRITABLE 0x02 /* mask for RDY bit, which when set to
|
||||
1, indicates the data port is ready
|
||||
to accept a byte of data. */
|
||||
#define SYNTH_QUIET 'S' /* synth is not speaking */
|
||||
#define SYNTH_FULL 'F' /* synth is full. */
|
||||
#define SYNTH_ALMOST_EMPTY 'M' /* synth has les than 2 seconds of text left */
|
||||
#define SYNTH_SPEAKING 's' /* synth is speaking and has a fare way to go */
|
327
drivers/staging/speakup/speakup_acntpc.c
Normal file
327
drivers/staging/speakup/speakup_acntpc.c
Normal file
@ -0,0 +1,327 @@
|
||||
/*
|
||||
* written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* this code is specificly written as a driver for the speakup screenreview
|
||||
* package and is not a general device driver.
|
||||
* This driver is for the Aicom Acent PC internal synthesizer.
|
||||
*/
|
||||
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
#include "speakup.h"
|
||||
#include "speakup_acnt.h" /* local header file for Accent values */
|
||||
|
||||
#define DRV_VERSION "2.10"
|
||||
#define synth_readable() (inb_p(synth_port_control) & SYNTH_READABLE)
|
||||
#define synth_writable() (inb_p(synth_port_control) & SYNTH_WRITABLE)
|
||||
#define synth_full() (inb_p(speakup_info.port_tts + UART_RX) == 'F')
|
||||
#define PROCSPEECH '\r'
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
static void accent_release(void);
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf);
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static int synth_port_control;
|
||||
static int port_forced;
|
||||
static unsigned int synth_portlist[] = { 0x2a8, 0 };
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\033P8" }},
|
||||
{ CAPS_STOP, .u.s = {"\033P5" }},
|
||||
{ RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" }},
|
||||
{ PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\033A%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/acntpc.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_acntpc = {
|
||||
.name = "acntpc",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Accent PC",
|
||||
.init = "\033=X \033Oi\033T2\033=M\033N1\n",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 1000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = accent_release,
|
||||
.synth_immediate = synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_nop,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "acntpc",
|
||||
},
|
||||
};
|
||||
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf)
|
||||
{
|
||||
u_char ch;
|
||||
while ((ch = *buf)) {
|
||||
int timeout = SPK_XMITR_TIMEOUT;
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
if (synth_full())
|
||||
return buf;
|
||||
while (synth_writable()) {
|
||||
if (!--timeout)
|
||||
return buf;
|
||||
udelay(1);
|
||||
}
|
||||
outb_p(ch, speakup_info.port_tts);
|
||||
buf++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
int timeout;
|
||||
int delay_time_val;
|
||||
int jiffy_delta_val;
|
||||
int full_time_val;
|
||||
struct var_t *delay_time;
|
||||
struct var_t *full_time;
|
||||
struct var_t *jiffy_delta;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
full_time = get_var(FULL);
|
||||
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
full_time_val = full_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (synth_full()) {
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
timeout = SPK_XMITR_TIMEOUT;
|
||||
while (synth_writable()) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
spk_lock(flags);
|
||||
ch = synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
outb_p(ch, speakup_info.port_tts);
|
||||
if (jiffies >= jiff_max && ch == SPACE) {
|
||||
timeout = SPK_XMITR_TIMEOUT;
|
||||
while (synth_writable()) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
outb_p(PROCSPEECH, speakup_info.port_tts);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies+jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
timeout = SPK_XMITR_TIMEOUT;
|
||||
while (synth_writable()) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
outb_p(PROCSPEECH, speakup_info.port_tts);
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
outb_p(SYNTH_CLEAR, speakup_info.port_tts);
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
unsigned int port_val = 0;
|
||||
int i = 0;
|
||||
pr_info("Probing for %s.\n", synth->long_name);
|
||||
if (port_forced) {
|
||||
speakup_info.port_tts = port_forced;
|
||||
pr_info("probe forced to %x by kernel command line\n",
|
||||
speakup_info.port_tts);
|
||||
if (synth_request_region(speakup_info.port_tts-1,
|
||||
SYNTH_IO_EXTENT)) {
|
||||
pr_warn("sorry, port already reserved\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
port_val = inw(speakup_info.port_tts-1);
|
||||
synth_port_control = speakup_info.port_tts-1;
|
||||
} else {
|
||||
for (i = 0; synth_portlist[i]; i++) {
|
||||
if (synth_request_region(synth_portlist[i],
|
||||
SYNTH_IO_EXTENT)) {
|
||||
pr_warn("request_region: failed with 0x%x, %d\n",
|
||||
synth_portlist[i], SYNTH_IO_EXTENT);
|
||||
continue;
|
||||
}
|
||||
port_val = inw(synth_portlist[i]) & 0xfffc;
|
||||
if (port_val == 0x53fc) {
|
||||
/* 'S' and out&input bits */
|
||||
synth_port_control = synth_portlist[i];
|
||||
speakup_info.port_tts = synth_port_control+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
port_val &= 0xfffc;
|
||||
if (port_val != 0x53fc) {
|
||||
/* 'S' and out&input bits */
|
||||
pr_info("%s: not found\n", synth->long_name);
|
||||
synth_release_region(synth_port_control, SYNTH_IO_EXTENT);
|
||||
synth_port_control = 0;
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name,
|
||||
synth_port_control, synth_port_control+SYNTH_IO_EXTENT-1,
|
||||
synth->version);
|
||||
synth->alive = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void accent_release(void)
|
||||
{
|
||||
if (speakup_info.port_tts)
|
||||
synth_release_region(speakup_info.port_tts-1, SYNTH_IO_EXTENT);
|
||||
speakup_info.port_tts = 0;
|
||||
}
|
||||
|
||||
module_param_named(port, port_forced, int, S_IRUGO);
|
||||
module_param_named(start, synth_acntpc.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init acntpc_init(void)
|
||||
{
|
||||
return synth_add(&synth_acntpc);
|
||||
}
|
||||
|
||||
static void __exit acntpc_exit(void)
|
||||
{
|
||||
synth_remove(&synth_acntpc);
|
||||
}
|
||||
|
||||
module_init(acntpc_init);
|
||||
module_exit(acntpc_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Accent PC synthesizer");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
164
drivers/staging/speakup/speakup_acntsa.c
Normal file
164
drivers/staging/speakup/speakup_acntsa.c
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* this code is specificly written as a driver for the speakup screenreview
|
||||
* package and is not a general device driver.
|
||||
*/
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
#include "speakup_acnt.h" /* local header file for Accent values */
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define synth_full() (inb_p(speakup_info.port_tts + UART_RX) == 'F')
|
||||
#define PROCSPEECH '\r'
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\033P8" }},
|
||||
{ CAPS_STOP, .u.s = {"\033P5" }},
|
||||
{ RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" }},
|
||||
{ PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\033A%d", 9, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/acntsa.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_acntsa = {
|
||||
.name = "acntsa",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Accent-SA",
|
||||
.init = "\033T2\033=M\033Oi\033N1\n",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 400,
|
||||
.trigger = 50,
|
||||
.jiffies = 30,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "acntsa",
|
||||
},
|
||||
};
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
int failed;
|
||||
|
||||
failed = serial_synth_probe(synth);
|
||||
if (failed == 0) {
|
||||
spk_synth_immediate(synth, "\033=R\r");
|
||||
mdelay(100);
|
||||
}
|
||||
synth->alive = !failed;
|
||||
return failed;
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_acntsa.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_acntsa.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init acntsa_init(void)
|
||||
{
|
||||
return synth_add(&synth_acntsa);
|
||||
}
|
||||
|
||||
static void __exit acntsa_exit(void)
|
||||
{
|
||||
synth_remove(&synth_acntsa);
|
||||
}
|
||||
|
||||
module_init(acntsa_init);
|
||||
module_exit(acntsa_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
225
drivers/staging/speakup/speakup_apollo.c
Normal file
225
drivers/staging/speakup/speakup_apollo.c
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* this code is specificly written as a driver for the speakup screenreview
|
||||
* package and is not a general device driver.
|
||||
*/
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.21"
|
||||
#define SYNTH_CLEAR 0x18
|
||||
#define PROCSPEECH '\r'
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"cap, " }},
|
||||
{ CAPS_STOP, .u.s = {"" }},
|
||||
{ RATE, .u.n = {"@W%d", 6, 1, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"@F%x", 10, 0, 15, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"@A%x", 10, 0, 15, 0, 0, NULL }},
|
||||
{ VOICE, .u.n = {"@V%d", 1, 1, 6, 0, 0, NULL }},
|
||||
{ LANG, .u.n = {"@=%d,", 1, 1, 4, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/apollo.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute lang_attribute =
|
||||
__ATTR(lang, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&lang_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_apollo = {
|
||||
.name = "apollo",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Apollo",
|
||||
.init = "@R3@D0@K1\r",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "apollo",
|
||||
},
|
||||
};
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
struct var_t *full_time;
|
||||
int full_time_val = 0;
|
||||
int delay_time_val = 0;
|
||||
int jiffy_delta_val = 0;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
full_time = get_var(FULL);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
full_time_val = full_time->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
ch = synth_buffer_peek();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
full_time_val = full_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (!spk_serial_out(ch)) {
|
||||
outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR);
|
||||
outb(UART_MCR_DTR | UART_MCR_RTS,
|
||||
speakup_info.port_tts + UART_MCR);
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
continue;
|
||||
}
|
||||
if ((jiffies >= jiff_max) && (ch == SPACE)) {
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
full_time_val = full_time->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (spk_serial_out(synth->procspeech))
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
else
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
}
|
||||
spk_serial_out(PROCSPEECH);
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_apollo.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_apollo.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init apollo_init(void)
|
||||
{
|
||||
return synth_add(&synth_apollo);
|
||||
}
|
||||
|
||||
static void __exit apollo_exit(void)
|
||||
{
|
||||
synth_remove(&synth_apollo);
|
||||
}
|
||||
|
||||
module_init(apollo_init);
|
||||
module_exit(apollo_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
195
drivers/staging/speakup/speakup_audptr.c
Normal file
195
drivers/staging/speakup/speakup_audptr.c
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
#include "serialio.h"
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define SYNTH_CLEAR 0x18 /* flush synth buffer */
|
||||
#define PROCSPEECH '\r' /* start synth processing speech char */
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x05[f99]" }},
|
||||
{ CAPS_STOP, .u.s = {"\x05[f80]" }},
|
||||
{ RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL }},
|
||||
{ PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, 0 }},
|
||||
{ PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/audptr.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_audptr = {
|
||||
.name = "audptr",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Audapter",
|
||||
.init = "\x05[D1]\x05[Ol]",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 400,
|
||||
.trigger = 50,
|
||||
.jiffies = 30,
|
||||
.full = 18000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "audptr",
|
||||
},
|
||||
};
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
int timeout = SPK_XMITR_TIMEOUT;
|
||||
while (spk_serial_tx_busy()) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
outb(SYNTH_CLEAR, speakup_info.port_tts);
|
||||
spk_serial_out(PROCSPEECH);
|
||||
}
|
||||
|
||||
static void synth_version(struct spk_synth *synth)
|
||||
{
|
||||
unsigned char test = 0;
|
||||
char synth_id[40] = "";
|
||||
spk_synth_immediate(synth, "\x05[Q]");
|
||||
synth_id[test] = spk_serial_in();
|
||||
if (synth_id[test] == 'A') {
|
||||
do {
|
||||
/* read version string from synth */
|
||||
synth_id[++test] = spk_serial_in();
|
||||
} while (synth_id[test] != '\n' && test < 32);
|
||||
synth_id[++test] = 0x00;
|
||||
}
|
||||
if (synth_id[0] == 'A')
|
||||
pr_info("%s version: %s", synth->long_name, synth_id);
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
int failed = 0;
|
||||
|
||||
failed = serial_synth_probe(synth);
|
||||
if (failed == 0)
|
||||
synth_version(synth);
|
||||
synth->alive = !failed;
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_audptr.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_audptr.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init audptr_init(void)
|
||||
{
|
||||
return synth_add(&synth_audptr);
|
||||
}
|
||||
|
||||
static void __exit audptr_exit(void)
|
||||
{
|
||||
synth_remove(&synth_audptr);
|
||||
}
|
||||
|
||||
module_init(audptr_init);
|
||||
module_exit(audptr_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
147
drivers/staging/speakup/speakup_bns.c
Normal file
147
drivers/staging/speakup/speakup_bns.c
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* this code is specificly written as a driver for the speakup screenreview
|
||||
* package and is not a general device driver.
|
||||
*/
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define SYNTH_CLEAR 0x18
|
||||
#define PROCSPEECH '\r'
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x05\x31\x32P" }},
|
||||
{ CAPS_STOP, .u.s = {"\x05\x38P" }},
|
||||
{ RATE, .u.n = {"\x05%dE", 8, 1, 16, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x05%dP", 8, 0, 16, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x05%dV", 8, 0, 16, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x05%dT", 8, 0, 16, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/bns.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_bns = {
|
||||
.name = "bns",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Braille 'N Speak",
|
||||
.init = "\x05Z\x05\x43",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "bns",
|
||||
},
|
||||
};
|
||||
|
||||
module_param_named(ser, synth_bns.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_bns.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init bns_init(void)
|
||||
{
|
||||
return synth_add(&synth_bns);
|
||||
}
|
||||
|
||||
static void __exit bns_exit(void)
|
||||
{
|
||||
synth_remove(&synth_bns);
|
||||
}
|
||||
|
||||
module_init(bns_init);
|
||||
module_exit(bns_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Braille 'n Speak synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
242
drivers/staging/speakup/speakup_decext.c
Normal file
242
drivers/staging/speakup/speakup_decext.c
Normal file
@ -0,0 +1,242 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.14"
|
||||
#define SYNTH_CLEAR 0x03
|
||||
#define PROCSPEECH 0x0b
|
||||
static unsigned char last_char;
|
||||
#define get_last_char() ((inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)? \
|
||||
(last_char = inb_p(speakup_info.port_tts + UART_RX)) : last_char)
|
||||
#define synth_full() (get_last_char() == 0x13)
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static int in_escape;
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"[:dv ap 222]" }},
|
||||
{ CAPS_STOP, .u.s = {"[:dv ap 100]" }},
|
||||
{ RATE, .u.n = {"[:ra %d]", 7, 0, 9, 150, 25, NULL }},
|
||||
{ PITCH, .u.n = {"[:dv ap %d]", 100, 0, 100, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"[:dv gv %d]", 13, 0, 16, 0, 5, NULL }},
|
||||
{ PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" }},
|
||||
{ VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/decext.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_decext = {
|
||||
.name = "decext",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Dectalk External",
|
||||
.init = "[:pe -380]",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.flags = SF_DEC,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "decext",
|
||||
},
|
||||
};
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
static u_char last = '\0';
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
int jiffy_delta_val = 0;
|
||||
int delay_time_val = 0;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
ch = synth_buffer_peek();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = 0x0D;
|
||||
if (synth_full() || !spk_serial_out(ch)) {
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '[')
|
||||
in_escape = 1;
|
||||
else if (ch == ']')
|
||||
in_escape = 0;
|
||||
else if (ch <= SPACE) {
|
||||
if (!in_escape && strchr(",.!?;:", last))
|
||||
spk_serial_out(PROCSPEECH);
|
||||
if (jiffies >= jiff_max) {
|
||||
if ( ! in_escape )
|
||||
spk_serial_out(PROCSPEECH);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
last = ch;
|
||||
}
|
||||
if (!in_escape)
|
||||
spk_serial_out(PROCSPEECH);
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
in_escape = 0;
|
||||
spk_synth_immediate(synth, "\033P;10z\033\\");
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_decext.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_decext.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init decext_init(void)
|
||||
{
|
||||
return synth_add(&synth_decext);
|
||||
}
|
||||
|
||||
static void __exit decext_exit(void)
|
||||
{
|
||||
synth_remove(&synth_decext);
|
||||
}
|
||||
|
||||
module_init(decext_init);
|
||||
module_exit(decext_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for DECtalk External synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
503
drivers/staging/speakup/speakup_decpc.c
Normal file
503
drivers/staging/speakup/speakup_decpc.c
Normal file
@ -0,0 +1,503 @@
|
||||
/*
|
||||
* This is the DECtalk PC speakup driver
|
||||
*
|
||||
* Some constants from DEC's DOS driver:
|
||||
* Copyright (c) by Digital Equipment Corp.
|
||||
*
|
||||
* 386BSD DECtalk PC driver:
|
||||
* Copyright (c) 1996 Brian Buhrow <buhrow@lothlorien.nfbcal.org>
|
||||
*
|
||||
* Linux DECtalk PC driver:
|
||||
* Copyright (c) 1997 Nicolas Pitre <nico@cam.org>
|
||||
*
|
||||
* speakup DECtalk PC Internal driver:
|
||||
* Copyright (c) 2003 David Borowski <david575@golden.net>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define MODULE_init 0x0dec /* module in boot code */
|
||||
#define MODULE_self_test 0x8800 /* module in self-test */
|
||||
#define MODULE_reset 0xffff /* reinit the whole module */
|
||||
|
||||
#define MODE_mask 0xf000 /* mode bits in high nibble */
|
||||
#define MODE_null 0x0000
|
||||
#define MODE_test 0x2000 /* in testing mode */
|
||||
#define MODE_status 0x8000
|
||||
#define STAT_int 0x0001 /* running in interrupt mode */
|
||||
#define STAT_tr_char 0x0002 /* character data to transmit */
|
||||
#define STAT_rr_char 0x0004 /* ready to receive char data */
|
||||
#define STAT_cmd_ready 0x0008 /* ready to accept commands */
|
||||
#define STAT_dma_ready 0x0010 /* dma command ready */
|
||||
#define STAT_digitized 0x0020 /* spc in digitized mode */
|
||||
#define STAT_new_index 0x0040 /* new last index ready */
|
||||
#define STAT_new_status 0x0080 /* new status posted */
|
||||
#define STAT_dma_state 0x0100 /* dma state toggle */
|
||||
#define STAT_index_valid 0x0200 /* indexs are valid */
|
||||
#define STAT_flushing 0x0400 /* flush in progress */
|
||||
#define STAT_self_test 0x0800 /* module in self test */
|
||||
#define MODE_ready 0xc000 /* module ready for next phase */
|
||||
#define READY_boot 0x0000
|
||||
#define READY_kernel 0x0001
|
||||
#define MODE_error 0xf000
|
||||
|
||||
#define CMD_mask 0xf000 /* mask for command nibble */
|
||||
#define CMD_null 0x0000 /* post status */
|
||||
#define CMD_control 0x1000 /* hard control command */
|
||||
#define CTRL_mask 0x0F00 /* mask off control nibble */
|
||||
#define CTRL_data 0x00FF /* madk to get data byte */
|
||||
#define CTRL_null 0x0000 /* null control */
|
||||
#define CTRL_vol_up 0x0100 /* increase volume */
|
||||
#define CTRL_vol_down 0x0200 /* decrease volume */
|
||||
#define CTRL_vol_set 0x0300 /* set volume */
|
||||
#define CTRL_pause 0x0400 /* pause spc */
|
||||
#define CTRL_resume 0x0500 /* resume spc clock */
|
||||
#define CTRL_resume_spc 0x0001 /* resume spc soft pause */
|
||||
#define CTRL_flush 0x0600 /* flush all buffers */
|
||||
#define CTRL_int_enable 0x0700 /* enable status change ints */
|
||||
#define CTRL_buff_free 0x0800 /* buffer remain count */
|
||||
#define CTRL_buff_used 0x0900 /* buffer in use */
|
||||
#define CTRL_speech 0x0a00 /* immediate speech change */
|
||||
#define CTRL_SP_voice 0x0001 /* voice change */
|
||||
#define CTRL_SP_rate 0x0002 /* rate change */
|
||||
#define CTRL_SP_comma 0x0003 /* comma pause change */
|
||||
#define CTRL_SP_period 0x0004 /* period pause change */
|
||||
#define CTRL_SP_rate_delta 0x0005 /* delta rate change */
|
||||
#define CTRL_SP_get_param 0x0006 /* return the desired parameter */
|
||||
#define CTRL_last_index 0x0b00 /* get last index spoken */
|
||||
#define CTRL_io_priority 0x0c00 /* change i/o priority */
|
||||
#define CTRL_free_mem 0x0d00 /* get free paragraphs on module */
|
||||
#define CTRL_get_lang 0x0e00 /* return bit mask of loaded
|
||||
* languages */
|
||||
#define CMD_test 0x2000 /* self-test request */
|
||||
#define TEST_mask 0x0F00 /* isolate test field */
|
||||
#define TEST_null 0x0000 /* no test requested */
|
||||
#define TEST_isa_int 0x0100 /* assert isa irq */
|
||||
#define TEST_echo 0x0200 /* make data in == data out */
|
||||
#define TEST_seg 0x0300 /* set peek/poke segment */
|
||||
#define TEST_off 0x0400 /* set peek/poke offset */
|
||||
#define TEST_peek 0x0500 /* data out == *peek */
|
||||
#define TEST_poke 0x0600 /* *peek == data in */
|
||||
#define TEST_sub_code 0x00FF /* user defined test sub codes */
|
||||
#define CMD_id 0x3000 /* return software id */
|
||||
#define ID_null 0x0000 /* null id */
|
||||
#define ID_kernel 0x0100 /* kernel code executing */
|
||||
#define ID_boot 0x0200 /* boot code executing */
|
||||
#define CMD_dma 0x4000 /* force a dma start */
|
||||
#define CMD_reset 0x5000 /* reset module status */
|
||||
#define CMD_sync 0x6000 /* kernel sync command */
|
||||
#define CMD_char_in 0x7000 /* single character send */
|
||||
#define CMD_char_out 0x8000 /* single character get */
|
||||
#define CHAR_count_1 0x0100 /* one char in cmd_low */
|
||||
#define CHAR_count_2 0x0200 /* the second in data_low */
|
||||
#define CHAR_count_3 0x0300 /* the third in data_high */
|
||||
#define CMD_spc_mode 0x9000 /* change spc mode */
|
||||
#define CMD_spc_to_text 0x0100 /* set to text mode */
|
||||
#define CMD_spc_to_digit 0x0200 /* set to digital mode */
|
||||
#define CMD_spc_rate 0x0400 /* change spc data rate */
|
||||
#define CMD_error 0xf000 /* severe error */
|
||||
|
||||
enum { PRIMARY_DIC = 0, USER_DIC, COMMAND_DIC, ABBREV_DIC };
|
||||
|
||||
#define DMA_single_in 0x01
|
||||
#define DMA_single_out 0x02
|
||||
#define DMA_buff_in 0x03
|
||||
#define DMA_buff_out 0x04
|
||||
#define DMA_control 0x05
|
||||
#define DT_MEM_ALLOC 0x03
|
||||
#define DT_SET_DIC 0x04
|
||||
#define DT_START_TASK 0x05
|
||||
#define DT_LOAD_MEM 0x06
|
||||
#define DT_READ_MEM 0x07
|
||||
#define DT_DIGITAL_IN 0x08
|
||||
#define DMA_sync 0x06
|
||||
#define DMA_sync_char 0x07
|
||||
|
||||
#define DRV_VERSION "2.12"
|
||||
#define PROCSPEECH 0x0b
|
||||
#define SYNTH_IO_EXTENT 8
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
static void dtpc_release(void);
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf);
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static int synth_portlist[] = { 0x340, 0x350, 0x240, 0x250, 0 };
|
||||
static int in_escape, is_flushing;
|
||||
static int dt_stat, dma_state;
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"[:dv ap 200]" }},
|
||||
{ CAPS_STOP, .u.s = {"[:dv ap 100]" }},
|
||||
{ RATE, .u.n = {"[:ra %d]", 9, 0, 18, 150, 25, NULL }},
|
||||
{ PITCH, .u.n = {"[:dv ap %d]", 80, 0, 100, 20, 0, NULL }},
|
||||
{ VOL, .u.n = {"[:vo se %d]", 5, 0, 9, 5, 10, NULL }},
|
||||
{ PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" }},
|
||||
{ VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/decpc.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_dec_pc = {
|
||||
.name = "decpc",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Dectalk PC",
|
||||
.init = "[:pe -380]",
|
||||
.procspeech = PROCSPEECH,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 1000,
|
||||
.flags = SF_DEC,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = dtpc_release,
|
||||
.synth_immediate = synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_nop,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "decpc",
|
||||
},
|
||||
};
|
||||
|
||||
static int dt_getstatus(void)
|
||||
{
|
||||
dt_stat = inb_p(speakup_info.port_tts) |
|
||||
(inb_p(speakup_info.port_tts + 1) << 8);
|
||||
return dt_stat;
|
||||
}
|
||||
|
||||
static void dt_sendcmd(u_int cmd)
|
||||
{
|
||||
outb_p(cmd & 0xFF, speakup_info.port_tts);
|
||||
outb_p((cmd >> 8) & 0xFF, speakup_info.port_tts+1);
|
||||
}
|
||||
|
||||
static int dt_waitbit(int bit)
|
||||
{
|
||||
int timeout = 100;
|
||||
while (--timeout > 0) {
|
||||
if ((dt_getstatus() & bit) == bit)
|
||||
return 1;
|
||||
udelay(50);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dt_wait_dma(void)
|
||||
{
|
||||
int timeout = 100, state = dma_state;
|
||||
if (!dt_waitbit(STAT_dma_ready))
|
||||
return 0;
|
||||
while (--timeout > 0) {
|
||||
if ((dt_getstatus()&STAT_dma_state) == state)
|
||||
return 1;
|
||||
udelay(50);
|
||||
}
|
||||
dma_state = dt_getstatus() & STAT_dma_state;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dt_ctrl(u_int cmd)
|
||||
{
|
||||
int timeout = 10;
|
||||
if (!dt_waitbit(STAT_cmd_ready))
|
||||
return -1;
|
||||
outb_p(0, speakup_info.port_tts+2);
|
||||
outb_p(0, speakup_info.port_tts+3);
|
||||
dt_getstatus();
|
||||
dt_sendcmd(CMD_control|cmd);
|
||||
outb_p(0, speakup_info.port_tts+6);
|
||||
while (dt_getstatus() & STAT_cmd_ready) {
|
||||
udelay(20);
|
||||
if (--timeout == 0)
|
||||
break;
|
||||
}
|
||||
dt_sendcmd(CMD_null);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
int timeout = 10;
|
||||
if (is_flushing)
|
||||
return;
|
||||
is_flushing = 4;
|
||||
in_escape = 0;
|
||||
while (dt_ctrl(CTRL_flush)) {
|
||||
if (--timeout == 0)
|
||||
break;
|
||||
udelay(50);
|
||||
}
|
||||
for (timeout = 0; timeout < 10; timeout++) {
|
||||
if (dt_waitbit(STAT_dma_ready))
|
||||
break;
|
||||
udelay(50);
|
||||
}
|
||||
outb_p(DMA_sync, speakup_info.port_tts+4);
|
||||
outb_p(0, speakup_info.port_tts+4);
|
||||
udelay(100);
|
||||
for (timeout = 0; timeout < 10; timeout++) {
|
||||
if (!(dt_getstatus() & STAT_flushing))
|
||||
break;
|
||||
udelay(50);
|
||||
}
|
||||
dma_state = dt_getstatus() & STAT_dma_state;
|
||||
dma_state ^= STAT_dma_state;
|
||||
is_flushing = 0;
|
||||
}
|
||||
|
||||
static int dt_sendchar(char ch)
|
||||
{
|
||||
if (!dt_wait_dma())
|
||||
return -1;
|
||||
if (!(dt_stat & STAT_rr_char))
|
||||
return -2;
|
||||
outb_p(DMA_single_in, speakup_info.port_tts+4);
|
||||
outb_p(ch, speakup_info.port_tts+4);
|
||||
dma_state ^= STAT_dma_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int testkernel(void)
|
||||
{
|
||||
int status = 0;
|
||||
if (dt_getstatus() == 0xffff) {
|
||||
status = -1;
|
||||
goto oops;
|
||||
}
|
||||
dt_sendcmd(CMD_sync);
|
||||
if (!dt_waitbit(STAT_cmd_ready))
|
||||
status = -2;
|
||||
else if (dt_stat&0x8000)
|
||||
return 0;
|
||||
else if (dt_stat == 0x0dec)
|
||||
pr_warn("dec_pc at 0x%x, software not loaded\n",
|
||||
speakup_info.port_tts);
|
||||
status = -3;
|
||||
oops: synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT);
|
||||
speakup_info.port_tts = 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
static u_char last = '\0';
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
int jiffy_delta_val;
|
||||
int delay_time_val;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
ch = synth_buffer_peek();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = 0x0D;
|
||||
if (dt_sendchar(ch)) {
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '[')
|
||||
in_escape = 1;
|
||||
else if (ch == ']')
|
||||
in_escape = 0;
|
||||
else if (ch <= SPACE) {
|
||||
if (!in_escape && strchr(",.!?;:", last))
|
||||
dt_sendchar(PROCSPEECH);
|
||||
if (jiffies >= jiff_max) {
|
||||
if (!in_escape)
|
||||
dt_sendchar(PROCSPEECH);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
last = ch;
|
||||
ch = 0;
|
||||
}
|
||||
if (!in_escape)
|
||||
dt_sendchar(PROCSPEECH);
|
||||
}
|
||||
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf)
|
||||
{
|
||||
u_char ch;
|
||||
while ((ch = *buf)) {
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
if (dt_sendchar(ch))
|
||||
return buf;
|
||||
buf++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
int i = 0, failed = 0;
|
||||
pr_info("Probing for %s.\n", synth->long_name);
|
||||
for (i = 0; synth_portlist[i]; i++) {
|
||||
if (synth_request_region(synth_portlist[i], SYNTH_IO_EXTENT)) {
|
||||
pr_warn("request_region: failed with 0x%x, %d\n",
|
||||
synth_portlist[i], SYNTH_IO_EXTENT);
|
||||
continue;
|
||||
}
|
||||
speakup_info.port_tts = synth_portlist[i];
|
||||
failed = testkernel();
|
||||
if (failed == 0)
|
||||
break;
|
||||
}
|
||||
if (failed) {
|
||||
pr_info("%s: not found\n", synth->long_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_info("%s: %03x-%03x, Driver Version %s,\n", synth->long_name,
|
||||
speakup_info.port_tts, speakup_info.port_tts + 7,
|
||||
synth->version);
|
||||
synth->alive = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dtpc_release(void)
|
||||
{
|
||||
if (speakup_info.port_tts)
|
||||
synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT);
|
||||
speakup_info.port_tts = 0;
|
||||
}
|
||||
|
||||
module_param_named(start, synth_dec_pc.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init decpc_init(void)
|
||||
{
|
||||
return synth_add(&synth_dec_pc);
|
||||
}
|
||||
|
||||
static void __exit decpc_exit(void)
|
||||
{
|
||||
synth_remove(&synth_dec_pc);
|
||||
}
|
||||
|
||||
module_init(decpc_init);
|
||||
module_exit(decpc_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for DECtalk PC synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
315
drivers/staging/speakup/speakup_dectlk.c
Normal file
315
drivers/staging/speakup/speakup_dectlk.c
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
|
||||
#define DRV_VERSION "2.20"
|
||||
#define SYNTH_CLEAR 0x03
|
||||
#define PROCSPEECH 0x0b
|
||||
static volatile int xoff;
|
||||
#define synth_full() (xoff)
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
static void read_buff_add(u_char c);
|
||||
static unsigned char get_index(void);
|
||||
|
||||
static int in_escape;
|
||||
static int is_flushing;
|
||||
|
||||
static spinlock_t flush_lock;
|
||||
static DECLARE_WAIT_QUEUE_HEAD(flush);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"[:dv ap 160] " }},
|
||||
{ CAPS_STOP, .u.s = {"[:dv ap 100 ] " }},
|
||||
{ RATE, .u.n = {"[:ra %d] ", 180, 75, 650, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"[:dv ap %d] ", 122, 50, 350, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"[:dv g5 %d] ", 86, 60, 86, 0, 0, NULL }},
|
||||
{ PUNCT, .u.n = {"[:pu %c] ", 0, 0, 2, 0, 0, "nsa" }},
|
||||
{ VOICE, .u.n = {"[:n%c] ", 0, 0, 9, 0, 0, "phfdburwkv" }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/dectlk.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static int ap_defaults[] = {122, 89, 155, 110, 208, 240, 200, 106, 306};
|
||||
static int g5_defaults[] = {86, 81, 86, 84, 81, 80, 83, 83, 73};
|
||||
|
||||
static struct spk_synth synth_dectlk = {
|
||||
.name = "dectlk",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Dectalk Express",
|
||||
.init = "[:error sp :name paul :rate 180 :tsr off] ",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.default_pitch = ap_defaults,
|
||||
.default_vol = g5_defaults,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = read_buff_add,
|
||||
.get_index = get_index,
|
||||
.indexing = {
|
||||
.command = "[:in re %d ] ",
|
||||
.lowindex = 1,
|
||||
.highindex = 8,
|
||||
.currindex = 1,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "dectlk",
|
||||
},
|
||||
};
|
||||
|
||||
static int is_indnum(u_char *ch)
|
||||
{
|
||||
if ((*ch >= '0') && (*ch <= '9')) {
|
||||
*ch = *ch - '0';
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u_char lastind = 0;
|
||||
|
||||
static unsigned char get_index(void)
|
||||
{
|
||||
u_char rv;
|
||||
rv = lastind;
|
||||
lastind = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void read_buff_add(u_char c)
|
||||
{
|
||||
static int ind = -1;
|
||||
|
||||
if (c == 0x01) {
|
||||
unsigned long flags;
|
||||
spin_lock_irqsave(&flush_lock, flags);
|
||||
is_flushing = 0;
|
||||
wake_up_interruptible(&flush);
|
||||
spin_unlock_irqrestore(&flush_lock, flags);
|
||||
} else if (c == 0x13) {
|
||||
xoff = 1;
|
||||
} else if (c == 0x11) {
|
||||
xoff = 0;
|
||||
} else if (is_indnum(&c)) {
|
||||
if (ind == -1)
|
||||
ind = c;
|
||||
else
|
||||
ind = ind * 10 + c;
|
||||
} else if ((c > 31) && (c < 127)) {
|
||||
if (ind != -1)
|
||||
lastind = (u_char)ind;
|
||||
ind = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
static u_char ch = 0;
|
||||
static u_char last = '\0';
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
unsigned long timeout = msecs_to_jiffies(4000);
|
||||
DEFINE_WAIT(wait);
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
int jiffy_delta_val;
|
||||
int delay_time_val;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
/* if no ctl-a in 4, send data anyway */
|
||||
spin_lock_irqsave(&flush_lock, flags);
|
||||
while (is_flushing && timeout) {
|
||||
prepare_to_wait(&flush, &wait, TASK_INTERRUPTIBLE);
|
||||
spin_unlock_irqrestore(&flush_lock, flags);
|
||||
timeout = schedule_timeout(timeout);
|
||||
spin_lock_irqsave(&flush_lock, flags);
|
||||
}
|
||||
finish_wait(&flush, &wait);
|
||||
is_flushing = 0;
|
||||
spin_unlock_irqrestore(&flush_lock, flags);
|
||||
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
ch = synth_buffer_peek();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = 0x0D;
|
||||
if (synth_full() || !spk_serial_out(ch)) {
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '[')
|
||||
in_escape = 1;
|
||||
else if (ch == ']')
|
||||
in_escape = 0;
|
||||
else if (ch <= SPACE) {
|
||||
if (!in_escape && strchr(",.!?;:", last))
|
||||
spk_serial_out(PROCSPEECH);
|
||||
if (jiffies >= jiff_max) {
|
||||
if ( ! in_escape )
|
||||
spk_serial_out(PROCSPEECH);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
last = ch;
|
||||
}
|
||||
if (!in_escape)
|
||||
spk_serial_out(PROCSPEECH);
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
if (in_escape) {
|
||||
/* if in command output ']' so we don't get an error */
|
||||
spk_serial_out(']');
|
||||
}
|
||||
in_escape = 0;
|
||||
is_flushing = 1;
|
||||
spk_serial_out(SYNTH_CLEAR);
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_dectlk.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_dectlk.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init dectlk_init(void)
|
||||
{
|
||||
return synth_add(&synth_dectlk);
|
||||
}
|
||||
|
||||
static void __exit dectlk_exit(void)
|
||||
{
|
||||
synth_remove(&synth_dectlk);
|
||||
}
|
||||
|
||||
module_init(dectlk_init);
|
||||
module_exit(dectlk_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for DECtalk Express synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
386
drivers/staging/speakup/speakup_dtlk.c
Normal file
386
drivers/staging/speakup/speakup_dtlk.c
Normal file
@ -0,0 +1,386 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* package it's not a general device driver.
|
||||
* This driver is for the RC Systems DoubleTalk PC internal synthesizer.
|
||||
*/
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
#include "speakup_dtlk.h" /* local header file for DoubleTalk values */
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.10"
|
||||
#define PROCSPEECH 0x00
|
||||
#define synth_readable() ((synth_status = inb_p(speakup_info.port_tts + UART_RX)) & TTS_READABLE)
|
||||
#define synth_writable() ((synth_status = inb_p(speakup_info.port_tts + UART_RX)) & TTS_WRITABLE)
|
||||
#define synth_full() ((synth_status = inb_p(speakup_info.port_tts + UART_RX)) & TTS_ALMOST_FULL)
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
static void dtlk_release(void);
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf);
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static int synth_lpc;
|
||||
static int port_forced;
|
||||
static unsigned int synth_portlist[] =
|
||||
{ 0x25e, 0x29e, 0x2de, 0x31e, 0x35e, 0x39e, 0 };
|
||||
static u_char synth_status;
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x01+35p" }},
|
||||
{ CAPS_STOP, .u.s = {"\x01-35p" }},
|
||||
{ RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL }},
|
||||
{ PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL }},
|
||||
{ VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL }},
|
||||
{ FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/dtlk.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute freq_attribute =
|
||||
__ATTR(freq, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&freq_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_dtlk = {
|
||||
.name = "dtlk",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "DoubleTalk PC",
|
||||
.init = "\x01@\x01\x31y",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 30,
|
||||
.jiffies = 50,
|
||||
.full = 1000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = dtlk_release,
|
||||
.synth_immediate = synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_nop,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = spk_serial_in_nowait,
|
||||
.indexing = {
|
||||
.command = "\x01%di",
|
||||
.lowindex = 1,
|
||||
.highindex = 5,
|
||||
.currindex = 1,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "dtlk",
|
||||
},
|
||||
};
|
||||
|
||||
static void spk_out(const char ch)
|
||||
{
|
||||
int timeout = SPK_XMITR_TIMEOUT;
|
||||
while (synth_writable() == 0) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
outb_p(ch, speakup_info.port_tts);
|
||||
timeout = SPK_XMITR_TIMEOUT;
|
||||
while (synth_writable() != 0) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
int jiffy_delta_val;
|
||||
int delay_time_val;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (synth_full()) {
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
ch = synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
spk_out(ch);
|
||||
if ((jiffies >= jiff_max) && (ch == SPACE)) {
|
||||
spk_out(PROCSPEECH);
|
||||
spk_lock(flags);
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
spk_out(PROCSPEECH);
|
||||
}
|
||||
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf)
|
||||
{
|
||||
u_char ch;
|
||||
while ((ch = (u_char)*buf)) {
|
||||
if (synth_full())
|
||||
return buf;
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
spk_out(ch);
|
||||
buf++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
outb_p(SYNTH_CLEAR, speakup_info.port_tts);
|
||||
while (synth_writable() != 0)
|
||||
cpu_relax();
|
||||
}
|
||||
|
||||
static char synth_read_tts(void)
|
||||
{
|
||||
u_char ch;
|
||||
while (synth_readable() == 0)
|
||||
cpu_relax();
|
||||
ch = synth_status & 0x7f;
|
||||
outb_p(ch, speakup_info.port_tts);
|
||||
while (synth_readable() != 0)
|
||||
cpu_relax();
|
||||
return (char) ch;
|
||||
}
|
||||
|
||||
/* interrogate the DoubleTalk PC and return its settings */
|
||||
static struct synth_settings *synth_interrogate(struct spk_synth *synth)
|
||||
{
|
||||
u_char *t;
|
||||
static char buf[sizeof(struct synth_settings) + 1];
|
||||
int total, i;
|
||||
static struct synth_settings status;
|
||||
synth_immediate(synth, "\x18\x01?");
|
||||
for (total = 0, i = 0; i < 50; i++) {
|
||||
buf[total] = synth_read_tts();
|
||||
if (total > 2 && buf[total] == 0x7f)
|
||||
break;
|
||||
if (total < sizeof(struct synth_settings))
|
||||
total++;
|
||||
}
|
||||
t = buf;
|
||||
/* serial number is little endian */
|
||||
status.serial_number = t[0] + t[1]*256;
|
||||
t += 2;
|
||||
for (i = 0; *t != '\r'; t++) {
|
||||
status.rom_version[i] = *t;
|
||||
if (i < sizeof(status.rom_version)-1)
|
||||
i++;
|
||||
}
|
||||
status.rom_version[i] = 0;
|
||||
t++;
|
||||
status.mode = *t++;
|
||||
status.punc_level = *t++;
|
||||
status.formant_freq = *t++;
|
||||
status.pitch = *t++;
|
||||
status.speed = *t++;
|
||||
status.volume = *t++;
|
||||
status.tone = *t++;
|
||||
status.expression = *t++;
|
||||
status.ext_dict_loaded = *t++;
|
||||
status.ext_dict_status = *t++;
|
||||
status.free_ram = *t++;
|
||||
status.articulation = *t++;
|
||||
status.reverb = *t++;
|
||||
status.eob = *t++;
|
||||
return &status;
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
unsigned int port_val = 0;
|
||||
int i = 0;
|
||||
struct synth_settings *sp;
|
||||
pr_info("Probing for DoubleTalk.\n");
|
||||
if (port_forced) {
|
||||
speakup_info.port_tts = port_forced;
|
||||
pr_info("probe forced to %x by kernel command line\n",
|
||||
speakup_info.port_tts);
|
||||
if ((port_forced & 0xf) != 0xf)
|
||||
pr_info("warning: port base should probably end with f\n");
|
||||
if (synth_request_region(speakup_info.port_tts-1,
|
||||
SYNTH_IO_EXTENT)) {
|
||||
pr_warn("sorry, port already reserved\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
port_val = inw(speakup_info.port_tts-1);
|
||||
synth_lpc = speakup_info.port_tts-1;
|
||||
} else {
|
||||
for (i = 0; synth_portlist[i]; i++) {
|
||||
if (synth_request_region(synth_portlist[i],
|
||||
SYNTH_IO_EXTENT))
|
||||
continue;
|
||||
port_val = inw(synth_portlist[i]) & 0xfbff;
|
||||
if (port_val == 0x107f) {
|
||||
synth_lpc = synth_portlist[i];
|
||||
speakup_info.port_tts = synth_lpc+1;
|
||||
break;
|
||||
}
|
||||
synth_release_region(synth_portlist[i],
|
||||
SYNTH_IO_EXTENT);
|
||||
}
|
||||
}
|
||||
port_val &= 0xfbff;
|
||||
if (port_val != 0x107f) {
|
||||
pr_info("DoubleTalk PC: not found\n");
|
||||
synth_release_region(synth_lpc, SYNTH_IO_EXTENT);
|
||||
return -ENODEV;
|
||||
}
|
||||
while (inw_p(synth_lpc) != 0x147f)
|
||||
cpu_relax(); /* wait until it's ready */
|
||||
sp = synth_interrogate(synth);
|
||||
pr_info("%s: %03x-%03x, ROM ver %s, s/n %u, driver: %s\n",
|
||||
synth->long_name, synth_lpc, synth_lpc+SYNTH_IO_EXTENT - 1,
|
||||
sp->rom_version, sp->serial_number, synth->version);
|
||||
synth->alive = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dtlk_release(void)
|
||||
{
|
||||
if (speakup_info.port_tts)
|
||||
synth_release_region(speakup_info.port_tts-1, SYNTH_IO_EXTENT);
|
||||
speakup_info.port_tts = 0;
|
||||
}
|
||||
|
||||
module_param_named(port, port_forced, int, S_IRUGO);
|
||||
module_param_named(start, synth_dtlk.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init dtlk_init(void)
|
||||
{
|
||||
return synth_add(&synth_dtlk);
|
||||
}
|
||||
|
||||
static void __exit dtlk_exit(void)
|
||||
{
|
||||
synth_remove(&synth_dtlk);
|
||||
}
|
||||
|
||||
module_init(dtlk_init);
|
||||
module_exit(dtlk_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for DoubleTalk PC synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
54
drivers/staging/speakup/speakup_dtlk.h
Normal file
54
drivers/staging/speakup/speakup_dtlk.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* speakup_dtlk.h - header file for speakups DoubleTalk driver. */
|
||||
|
||||
#define SYNTH_IO_EXTENT 0x02
|
||||
#define SYNTH_CLEAR 0x18 /* stops speech */
|
||||
/* TTS Port Status Flags */
|
||||
#define TTS_READABLE 0x80 /* mask for bit which is nonzero if a
|
||||
byte can be read from the TTS port */
|
||||
#define TTS_SPEAKING 0x40 /* mask for SYNC bit, which is nonzero
|
||||
while DoubleTalk is producing
|
||||
output with TTS, PCM or CVSD
|
||||
synthesizers or tone generators
|
||||
(that is, all but LPC) */
|
||||
#define TTS_SPEAKING2 0x20 /* mask for SYNC2 bit,
|
||||
which falls to zero up to 0.4 sec
|
||||
before speech stops */
|
||||
#define TTS_WRITABLE 0x10 /* mask for RDY bit, which when set to
|
||||
1, indicates the TTS port is ready
|
||||
to accept a byte of data. The RDY
|
||||
bit goes zero 2-3 usec after
|
||||
writing, and goes 1 again 180-190
|
||||
usec later. */
|
||||
#define TTS_ALMOST_FULL 0x08 /* mask for AF bit: When set to 1,
|
||||
indicates that less than 300 bytes
|
||||
are available in the TTS input
|
||||
buffer. AF is always 0 in the PCM,
|
||||
TGN and CVSD modes. */
|
||||
#define TTS_ALMOST_EMPTY 0x04 /* mask for AE bit: When set to 1,
|
||||
indicates that less than 300 bytes
|
||||
are remaining in DoubleTalk's input
|
||||
(TTS or PCM) buffer. AE is always 1
|
||||
in the TGN and CVSD modes. */
|
||||
|
||||
/* data returned by Interrogate command */
|
||||
struct synth_settings {
|
||||
u_short serial_number; /* 0-7Fh:0-7Fh */
|
||||
u_char rom_version[24]; /* null terminated string */
|
||||
u_char mode; /* 0=Character; 1=Phoneme; 2=Text */
|
||||
u_char punc_level; /* nB; 0-7 */
|
||||
u_char formant_freq; /* nF; 0-9 */
|
||||
u_char pitch; /* nP; 0-99 */
|
||||
u_char speed; /* nS; 0-9 */
|
||||
u_char volume; /* nV; 0-9 */
|
||||
u_char tone; /* nX; 0-2 */
|
||||
u_char expression; /* nE; 0-9 */
|
||||
u_char ext_dict_loaded; /* 1=exception dictionary loaded */
|
||||
u_char ext_dict_status; /* 1=exception dictionary enabled */
|
||||
u_char free_ram; /* # pages (truncated) remaining for
|
||||
* text buffer */
|
||||
u_char articulation; /* nA; 0-9 */
|
||||
u_char reverb; /* nR; 0-9 */
|
||||
u_char eob; /* 7Fh value indicating end of
|
||||
* parameter block */
|
||||
u_char has_indexing; /* nonzero if indexing is implemented */
|
||||
};
|
148
drivers/staging/speakup/speakup_dummy.c
Normal file
148
drivers/staging/speakup/speakup_dummy.c
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
* eventually modified by Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
* Copyright (C) 2007 Samuel Thibault.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define PROCSPEECH '\n'
|
||||
#define DRV_VERSION "2.11"
|
||||
#define SYNTH_CLEAR '!'
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"CAPS_START\n" }},
|
||||
{ CAPS_STOP, .u.s = {"CAPS_STOP\n" }},
|
||||
{ RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/dummy.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_dummy = {
|
||||
.name = "dummy",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Dummy",
|
||||
.init = "Speakup\n",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "dummy",
|
||||
},
|
||||
};
|
||||
|
||||
module_param_named(ser, synth_dummy.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_dummy.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init dummy_init(void)
|
||||
{
|
||||
return synth_add(&synth_dummy);
|
||||
}
|
||||
|
||||
static void __exit dummy_exit(void)
|
||||
{
|
||||
synth_remove(&synth_dummy);
|
||||
}
|
||||
|
||||
module_init(dummy_init);
|
||||
module_exit(dummy_exit);
|
||||
MODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>");
|
||||
MODULE_DESCRIPTION("Speakup support for text console");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
327
drivers/staging/speakup/speakup_keypc.c
Normal file
327
drivers/staging/speakup/speakup_keypc.c
Normal file
@ -0,0 +1,327 @@
|
||||
/*
|
||||
* written by David Borowski
|
||||
*
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* package it's not a general device driver.
|
||||
* This driver is for the Keynote Gold internal synthesizer.
|
||||
*/
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/serial_reg.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.10"
|
||||
#define SYNTH_IO_EXTENT 0x04
|
||||
#define SWAIT udelay(70)
|
||||
#define synth_writable() (inb_p(synth_port + UART_RX) & 0x10)
|
||||
#define synth_readable() (inb_p(synth_port + UART_RX) & 0x10)
|
||||
#define synth_full() ((inb_p(synth_port + UART_RX) & 0x80) == 0)
|
||||
#define PROCSPEECH 0x1f
|
||||
#define SYNTH_CLEAR 0x03
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
static void keynote_release(void);
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf);
|
||||
static void do_catch_up(struct spk_synth *synth);
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static int synth_port;
|
||||
static int port_forced;
|
||||
static unsigned int synth_portlist[] = { 0x2a8, 0 };
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"[f130]" }},
|
||||
{ CAPS_STOP, .u.s = {"[f90]" }},
|
||||
{ RATE, .u.n = {"\04%c ", 8, 0, 10, 81, -8, NULL }},
|
||||
{ PITCH, .u.n = {"[f%d]", 5, 0, 9, 40, 10, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/keypc.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_keypc = {
|
||||
.name = "keypc",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Keynote PC",
|
||||
.init = "[t][n7,1][n8,0]",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 1000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = keynote_release,
|
||||
.synth_immediate = synth_immediate,
|
||||
.catch_up = do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_nop,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "keypc",
|
||||
},
|
||||
};
|
||||
|
||||
static char *oops(void)
|
||||
{
|
||||
int s1, s2, s3, s4;
|
||||
s1 = inb_p(synth_port);
|
||||
s2 = inb_p(synth_port+1);
|
||||
s3 = inb_p(synth_port+2);
|
||||
s4 = inb_p(synth_port+3);
|
||||
pr_warn("synth timeout %d %d %d %d\n", s1, s2, s3, s4);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *synth_immediate(struct spk_synth *synth, const char *buf)
|
||||
{
|
||||
u_char ch;
|
||||
int timeout;
|
||||
while ((ch = *buf)) {
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
if (synth_full())
|
||||
return buf;
|
||||
timeout = 1000;
|
||||
while (synth_writable())
|
||||
if (--timeout <= 0)
|
||||
return oops();
|
||||
outb_p(ch, synth_port);
|
||||
udelay(70);
|
||||
buf++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
int timeout;
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *jiffy_delta;
|
||||
struct var_t *delay_time;
|
||||
struct var_t *full_time;
|
||||
int delay_time_val;
|
||||
int full_time_val;
|
||||
int jiffy_delta_val;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
delay_time = get_var(DELAY);
|
||||
full_time = get_var(FULL);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
full_time_val = full_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (synth_full()) {
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
continue;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
timeout = 1000;
|
||||
while (synth_writable())
|
||||
if (--timeout <= 0)
|
||||
break;
|
||||
if (timeout <= 0) {
|
||||
oops();
|
||||
break;
|
||||
}
|
||||
spk_lock(flags);
|
||||
ch = synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = PROCSPEECH;
|
||||
outb_p(ch, synth_port);
|
||||
SWAIT;
|
||||
if ((jiffies >= jiff_max) && (ch == SPACE)) {
|
||||
timeout = 1000;
|
||||
while (synth_writable())
|
||||
if (--timeout <= 0)
|
||||
break;
|
||||
if (timeout <= 0) {
|
||||
oops();
|
||||
break;
|
||||
}
|
||||
outb_p(PROCSPEECH, synth_port);
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
jiff_max = jiffies+jiffy_delta_val;
|
||||
}
|
||||
}
|
||||
timeout = 1000;
|
||||
while (synth_writable())
|
||||
if (--timeout <= 0)
|
||||
break;
|
||||
if (timeout <= 0)
|
||||
oops();
|
||||
else
|
||||
outb_p(PROCSPEECH, synth_port);
|
||||
}
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
outb_p(SYNTH_CLEAR, synth_port);
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
unsigned int port_val = 0;
|
||||
int i = 0;
|
||||
pr_info("Probing for %s.\n", synth->long_name);
|
||||
if (port_forced) {
|
||||
synth_port = port_forced;
|
||||
pr_info("probe forced to %x by kernel command line\n",
|
||||
synth_port);
|
||||
if (synth_request_region(synth_port-1, SYNTH_IO_EXTENT)) {
|
||||
pr_warn("sorry, port already reserved\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
port_val = inb(synth_port);
|
||||
} else {
|
||||
for (i = 0; synth_portlist[i]; i++) {
|
||||
if (synth_request_region(synth_portlist[i],
|
||||
SYNTH_IO_EXTENT)) {
|
||||
pr_warn("request_region: failed with 0x%x, %d\n",
|
||||
synth_portlist[i], SYNTH_IO_EXTENT);
|
||||
continue;
|
||||
}
|
||||
port_val = inb(synth_portlist[i]);
|
||||
if (port_val == 0x80) {
|
||||
synth_port = synth_portlist[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (port_val != 0x80) {
|
||||
pr_info("%s: not found\n", synth->long_name);
|
||||
synth_release_region(synth_port, SYNTH_IO_EXTENT);
|
||||
synth_port = 0;
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name,
|
||||
synth_port, synth_port+SYNTH_IO_EXTENT-1,
|
||||
synth->version);
|
||||
synth->alive = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void keynote_release(void)
|
||||
{
|
||||
if (synth_port)
|
||||
synth_release_region(synth_port, SYNTH_IO_EXTENT);
|
||||
synth_port = 0;
|
||||
}
|
||||
|
||||
module_param_named(port, port_forced, int, S_IRUGO);
|
||||
module_param_named(start, synth_keypc.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init keypc_init(void)
|
||||
{
|
||||
return synth_add(&synth_keypc);
|
||||
}
|
||||
|
||||
static void __exit keypc_exit(void)
|
||||
{
|
||||
synth_remove(&synth_keypc);
|
||||
}
|
||||
|
||||
module_init(keypc_init);
|
||||
module_exit(keypc_exit);
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Keynote Gold PC synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
195
drivers/staging/speakup/speakup_ltlk.c
Normal file
195
drivers/staging/speakup/speakup_ltlk.c
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
#include "serialio.h"
|
||||
#include "speakup_dtlk.h" /* local header file for LiteTalk values */
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define synth_full( ) ( !( inb( synth_port_tts + UART_MSR ) & UART_MSR_CTS ) )
|
||||
#define PROCSPEECH 0x0d
|
||||
|
||||
static int synth_probe(struct spk_synth *synth);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x01+35p" }},
|
||||
{ CAPS_STOP, .u.s = {"\x01-35p" }},
|
||||
{ RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL }},
|
||||
{ PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL }},
|
||||
{ VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL }},
|
||||
{ FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/ltlk.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute freq_attribute =
|
||||
__ATTR(freq, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&freq_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_ltlk = {
|
||||
.name = "ltlk",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "LiteTalk",
|
||||
.init = "\01@\x01\x31y\n\0",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = spk_serial_in_nowait,
|
||||
.indexing = {
|
||||
.command = "\x01%di",
|
||||
.lowindex = 1,
|
||||
.highindex = 5,
|
||||
.currindex = 1,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "ltlk",
|
||||
},
|
||||
};
|
||||
|
||||
/* interrogate the LiteTalk and print its settings */
|
||||
static void synth_interrogate(struct spk_synth *synth)
|
||||
{
|
||||
unsigned char *t, i;
|
||||
unsigned char buf[50], rom_v[20];
|
||||
spk_synth_immediate(synth, "\x18\x01?");
|
||||
for (i = 0; i < 50; i++) {
|
||||
buf[i] = spk_serial_in();
|
||||
if (i > 2 && buf[i] == 0x7f)
|
||||
break;
|
||||
}
|
||||
t = buf+2;
|
||||
for (i = 0; *t != '\r'; t++) {
|
||||
rom_v[i] = *t;
|
||||
if (++i >= 19)
|
||||
break;
|
||||
}
|
||||
rom_v[i] = 0;
|
||||
pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
|
||||
}
|
||||
|
||||
static int synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
int failed = 0;
|
||||
|
||||
failed = serial_synth_probe(synth);
|
||||
if (failed == 0)
|
||||
synth_interrogate(synth);
|
||||
synth->alive = !failed;
|
||||
return failed;
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_ltlk.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_ltlk.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init ltlk_init(void)
|
||||
{
|
||||
return synth_add(&synth_ltlk);
|
||||
}
|
||||
|
||||
static void __exit ltlk_exit(void)
|
||||
{
|
||||
synth_remove(&synth_ltlk);
|
||||
}
|
||||
|
||||
module_init(ltlk_init);
|
||||
module_exit(ltlk_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
366
drivers/staging/speakup/speakup_soft.c
Normal file
366
drivers/staging/speakup/speakup_soft.c
Normal file
@ -0,0 +1,366 @@
|
||||
/* speakup_soft.c - speakup driver to register and make available
|
||||
* a user space device for software synthesizers. written by: Kirk
|
||||
* Reiser <kirk@braille.uwo.ca>
|
||||
*
|
||||
* Copyright (C) 2003 Kirk Reiser.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* this code is specificly written as a driver for the speakup screenreview
|
||||
* package and is not a general device driver. */
|
||||
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/miscdevice.h> /* for misc_register, and SYNTH_MINOR */
|
||||
#include <linux/poll.h> /* for poll_wait() */
|
||||
#include <linux/sched.h> /* schedule(), signal_pending(), TASK_INTERRUPTIBLE */
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.6"
|
||||
#define SOFTSYNTH_MINOR 26 /* might as well give it one more than /dev/synth */
|
||||
#define PROCSPEECH 0x0d
|
||||
#define CLEAR_SYNTH 0x18
|
||||
|
||||
static int softsynth_probe(struct spk_synth *synth);
|
||||
static void softsynth_release(void);
|
||||
static int softsynth_is_alive(struct spk_synth *synth);
|
||||
static unsigned char get_index(void);
|
||||
|
||||
static struct miscdevice synth_device;
|
||||
static int initialized = 0;
|
||||
static int misc_registered;
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x01+3p" }},
|
||||
{ CAPS_STOP, .u.s = {"\x01-3p" }},
|
||||
{ RATE, .u.n = {"\x01%ds", 5, 0, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x01%dp", 5, 0, 9, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL }},
|
||||
{ PUNCT, .u.n = {"\x01%db", 0, 0, 2, 0, 0, NULL }},
|
||||
{ VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL }},
|
||||
{ FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/soft.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute freq_attribute =
|
||||
__ATTR(freq, USER_RW, spk_var_show, spk_var_store);
|
||||
//static struct kobj_attribute lang_attribute =
|
||||
// __ATTR(lang, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute voice_attribute =
|
||||
__ATTR(voice, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&freq_attribute.attr,
|
||||
// &lang_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&voice_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_soft = {
|
||||
.name = "soft",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "software synth",
|
||||
.init = "\01@\x01\x31y\n",
|
||||
.procspeech = PROCSPEECH,
|
||||
.delay = 0,
|
||||
.trigger = 0,
|
||||
.jiffies = 0,
|
||||
.full = 0,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = softsynth_probe,
|
||||
.release = softsynth_release,
|
||||
.synth_immediate = NULL,
|
||||
.catch_up = NULL,
|
||||
.flush = NULL,
|
||||
.is_alive = softsynth_is_alive,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = get_index,
|
||||
.indexing = {
|
||||
.command = "\x01%di",
|
||||
.lowindex = 1,
|
||||
.highindex = 5,
|
||||
.currindex = 1,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "soft",
|
||||
},
|
||||
};
|
||||
|
||||
static char *get_initstring(void)
|
||||
{
|
||||
static char buf[40];
|
||||
char *cp;
|
||||
struct var_t *var;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
cp = buf;
|
||||
var = synth_soft.vars;
|
||||
while (var->var_id != MAXVARS) {
|
||||
if (var->var_id != CAPS_START && var->var_id != CAPS_STOP
|
||||
&& var->var_id != DIRECT)
|
||||
cp = cp + sprintf(cp, var->u.n.synth_fmt, var->u.n.value);
|
||||
var++;
|
||||
}
|
||||
cp = cp + sprintf(cp, "\n");
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int softsynth_open(struct inode *inode, struct file *fp)
|
||||
{
|
||||
unsigned long flags;
|
||||
/*if ((fp->f_flags & O_ACCMODE) != O_RDONLY) */
|
||||
/* return -EPERM; */
|
||||
spk_lock(flags);
|
||||
if (synth_soft.alive) {
|
||||
spk_unlock(flags);
|
||||
return -EBUSY;
|
||||
}
|
||||
synth_soft.alive = 1;
|
||||
spk_unlock(flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int softsynth_close(struct inode *inode, struct file *fp)
|
||||
{
|
||||
unsigned long flags;
|
||||
spk_lock(flags);
|
||||
synth_soft.alive = 0;
|
||||
initialized = 0;
|
||||
spk_unlock(flags);
|
||||
/* Make sure we let applications go before leaving */
|
||||
speakup_start_ttys();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t softsynth_read(struct file *fp, char *buf, size_t count,
|
||||
loff_t *pos)
|
||||
{
|
||||
int chars_sent = 0;
|
||||
char *cp;
|
||||
char *init;
|
||||
char ch;
|
||||
int empty;
|
||||
unsigned long flags;
|
||||
DEFINE_WAIT(wait);
|
||||
|
||||
spk_lock(flags);
|
||||
while (1) {
|
||||
prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
|
||||
if (!synth_buffer_empty() || speakup_info.flushing)
|
||||
break;
|
||||
spk_unlock(flags);
|
||||
if (fp->f_flags & O_NONBLOCK) {
|
||||
finish_wait(&speakup_event, &wait);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (signal_pending(current)) {
|
||||
finish_wait(&speakup_event, &wait);
|
||||
return -ERESTARTSYS;
|
||||
}
|
||||
schedule();
|
||||
spk_lock(flags);
|
||||
}
|
||||
finish_wait(&speakup_event, &wait);
|
||||
|
||||
cp = buf;
|
||||
init = get_initstring();
|
||||
while (chars_sent < count) {
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
ch = '\x18';
|
||||
} else if (synth_buffer_empty()) {
|
||||
break;
|
||||
} else if (! initialized) {
|
||||
if (*init) {
|
||||
ch = *init;
|
||||
init++;
|
||||
} else {
|
||||
initialized = 1;
|
||||
}
|
||||
} else {
|
||||
ch = synth_buffer_getc();
|
||||
}
|
||||
spk_unlock(flags);
|
||||
if (copy_to_user(cp, &ch, 1))
|
||||
return -EFAULT;
|
||||
spk_lock(flags);
|
||||
chars_sent++;
|
||||
cp++;
|
||||
}
|
||||
*pos += chars_sent;
|
||||
empty = synth_buffer_empty();
|
||||
spk_unlock(flags);
|
||||
if (empty) {
|
||||
speakup_start_ttys();
|
||||
*pos = 0;
|
||||
}
|
||||
return chars_sent;
|
||||
}
|
||||
|
||||
static int last_index = 0;
|
||||
|
||||
static ssize_t softsynth_write(struct file *fp, const char *buf, size_t count,
|
||||
loff_t *pos)
|
||||
{
|
||||
char indbuf[5];
|
||||
if (count >= sizeof(indbuf))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(indbuf, buf, count))
|
||||
return -EFAULT;
|
||||
indbuf[4] = 0;
|
||||
|
||||
last_index = simple_strtoul(indbuf, NULL, 0);
|
||||
return count;
|
||||
}
|
||||
|
||||
static unsigned int softsynth_poll(struct file *fp,
|
||||
struct poll_table_struct *wait)
|
||||
{
|
||||
unsigned long flags;
|
||||
int ret = 0;
|
||||
poll_wait(fp, &speakup_event, wait);
|
||||
|
||||
spk_lock(flags);
|
||||
if (! synth_buffer_empty() || speakup_info.flushing)
|
||||
ret = POLLIN | POLLRDNORM;
|
||||
spk_unlock(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned char get_index(void)
|
||||
{
|
||||
int rv;
|
||||
rv = last_index;
|
||||
last_index = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static struct file_operations softsynth_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.poll = softsynth_poll,
|
||||
.read = softsynth_read,
|
||||
.write = softsynth_write,
|
||||
.open = softsynth_open,
|
||||
.release = softsynth_close,
|
||||
};
|
||||
|
||||
|
||||
static int softsynth_probe(struct spk_synth *synth)
|
||||
{
|
||||
|
||||
if (misc_registered != 0)
|
||||
return 0;
|
||||
memset(&synth_device, 0, sizeof(synth_device));
|
||||
synth_device.minor = SOFTSYNTH_MINOR;
|
||||
synth_device.name = "softsynth";
|
||||
synth_device.fops = &softsynth_fops;
|
||||
if (misc_register(&synth_device)) {
|
||||
pr_warn("Couldn't initialize miscdevice /dev/softsynth.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
misc_registered = 1;
|
||||
pr_info("initialized device: /dev/softsynth, node (MAJOR 10, MINOR 26)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void softsynth_release(void)
|
||||
{
|
||||
misc_deregister(&synth_device);
|
||||
misc_registered = 0;
|
||||
pr_info("unregistered /dev/softsynth\n");
|
||||
}
|
||||
|
||||
static int softsynth_is_alive(struct spk_synth *synth)
|
||||
{
|
||||
if (synth_soft.alive)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_param_named(start, synth_soft.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
|
||||
static int __init soft_init(void)
|
||||
{
|
||||
return synth_add(&synth_soft);
|
||||
}
|
||||
|
||||
static void __exit soft_exit(void)
|
||||
{
|
||||
synth_remove(&synth_soft);
|
||||
}
|
||||
|
||||
module_init(soft_init);
|
||||
module_exit(soft_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_DESCRIPTION("Speakup userspace software synthesizer support");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
165
drivers/staging/speakup/speakup_spkout.c
Normal file
165
drivers/staging/speakup/speakup_spkout.c
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
#include "serialio.h"
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define SYNTH_CLEAR 0x18
|
||||
#define PROCSPEECH '\r'
|
||||
|
||||
static void synth_flush(struct spk_synth *synth);
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x05P+" }},
|
||||
{ CAPS_STOP, .u.s = {"\x05P-" }},
|
||||
{ RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL }},
|
||||
{ PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/spkout.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute punct_attribute =
|
||||
__ATTR(punct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&punct_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_spkout = {
|
||||
.name = "spkout",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Speakout",
|
||||
.init = "\005W1\005I2\005C3",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = spk_serial_in_nowait,
|
||||
.indexing = {
|
||||
.command = "\x05[%c",
|
||||
.lowindex = 1,
|
||||
.highindex = 5,
|
||||
.currindex = 1,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "spkout",
|
||||
},
|
||||
};
|
||||
|
||||
static void synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
int timeout = SPK_XMITR_TIMEOUT;
|
||||
while (spk_serial_tx_busy()) {
|
||||
if (!--timeout)
|
||||
break;
|
||||
udelay(1);
|
||||
}
|
||||
outb(SYNTH_CLEAR, speakup_info.port_tts);
|
||||
}
|
||||
|
||||
module_param_named(ser, synth_spkout.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_spkout.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init spkout_init(void)
|
||||
{
|
||||
return synth_add(&synth_spkout);
|
||||
}
|
||||
|
||||
static void __exit spkout_exit(void)
|
||||
{
|
||||
synth_remove(&synth_spkout);
|
||||
}
|
||||
|
||||
module_init(spkout_init);
|
||||
module_exit(spkout_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
147
drivers/staging/speakup/speakup_txprt.c
Normal file
147
drivers/staging/speakup/speakup_txprt.c
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* originally written by: Kirk Reiser <kirk@braille.uwo.ca>
|
||||
* this version considerably modified by David Borowski, david575@rogers.com
|
||||
*
|
||||
* Copyright (C) 1998-99 Kirk Reiser.
|
||||
* Copyright (C) 2003 David Borowski.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* specificly written as a driver for the speakup screenreview
|
||||
* s not a general device driver.
|
||||
*/
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
#define DRV_VERSION "2.11"
|
||||
#define SYNTH_CLEAR 0x18
|
||||
#define PROCSPEECH '\r' /* process speech char */
|
||||
|
||||
static struct var_t vars[] = {
|
||||
{ CAPS_START, .u.s = {"\x05P8" }},
|
||||
{ CAPS_STOP, .u.s = {"\x05P5" }},
|
||||
{ RATE, .u.n = {"\x05R%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ PITCH, .u.n = {"\x05P%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ VOL, .u.n = {"\x05V%d", 5, 0, 9, 0, 0, NULL }},
|
||||
{ TONE, .u.n = {"\x05T%c", 12, 0, 25, 61, 0, NULL }},
|
||||
{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/*
|
||||
* These attributes will appear in /sys/accessibility/speakup/txprt.
|
||||
*/
|
||||
static struct kobj_attribute caps_start_attribute =
|
||||
__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute caps_stop_attribute =
|
||||
__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute pitch_attribute =
|
||||
__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute rate_attribute =
|
||||
__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute tone_attribute =
|
||||
__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute vol_attribute =
|
||||
__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
|
||||
|
||||
static struct kobj_attribute delay_time_attribute =
|
||||
__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute direct_attribute =
|
||||
__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute full_time_attribute =
|
||||
__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute jiffy_delta_attribute =
|
||||
__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
|
||||
static struct kobj_attribute trigger_time_attribute =
|
||||
__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
|
||||
|
||||
/*
|
||||
* Create a group of attributes so that we can create and destroy them all
|
||||
* at once.
|
||||
*/
|
||||
static struct attribute *synth_attrs[] = {
|
||||
&caps_start_attribute.attr,
|
||||
&caps_stop_attribute.attr,
|
||||
&pitch_attribute.attr,
|
||||
&rate_attribute.attr,
|
||||
&tone_attribute.attr,
|
||||
&vol_attribute.attr,
|
||||
&delay_time_attribute.attr,
|
||||
&direct_attribute.attr,
|
||||
&full_time_attribute.attr,
|
||||
&jiffy_delta_attribute.attr,
|
||||
&trigger_time_attribute.attr,
|
||||
NULL, /* need to NULL terminate the list of attributes */
|
||||
};
|
||||
|
||||
static struct spk_synth synth_txprt = {
|
||||
.name = "txprt",
|
||||
.version = DRV_VERSION,
|
||||
.long_name = "Transport",
|
||||
.init = "\x05N1",
|
||||
.procspeech = PROCSPEECH,
|
||||
.clear = SYNTH_CLEAR,
|
||||
.delay = 500,
|
||||
.trigger = 50,
|
||||
.jiffies = 50,
|
||||
.full = 40000,
|
||||
.startup = SYNTH_START,
|
||||
.checkval = SYNTH_CHECK,
|
||||
.vars = vars,
|
||||
.probe = serial_synth_probe,
|
||||
.release = spk_serial_release,
|
||||
.synth_immediate = spk_synth_immediate,
|
||||
.catch_up = spk_do_catch_up,
|
||||
.flush = spk_synth_flush,
|
||||
.is_alive = spk_synth_is_alive_restart,
|
||||
.synth_adjust = NULL,
|
||||
.read_buff_add = NULL,
|
||||
.get_index = NULL,
|
||||
.indexing = {
|
||||
.command = NULL,
|
||||
.lowindex = 0,
|
||||
.highindex = 0,
|
||||
.currindex = 0,
|
||||
},
|
||||
.attributes = {
|
||||
.attrs = synth_attrs,
|
||||
.name = "txprt",
|
||||
},
|
||||
};
|
||||
|
||||
module_param_named(ser, synth_txprt.ser, int, S_IRUGO);
|
||||
module_param_named(start, synth_txprt.startup, short, S_IRUGO);
|
||||
|
||||
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
|
||||
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
|
||||
|
||||
static int __init txprt_init(void)
|
||||
{
|
||||
return synth_add(&synth_txprt);
|
||||
}
|
||||
|
||||
static void __exit txprt_exit(void)
|
||||
{
|
||||
synth_remove(&synth_txprt);
|
||||
}
|
||||
|
||||
module_init(txprt_init);
|
||||
module_exit(txprt_exit);
|
||||
MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
|
||||
MODULE_AUTHOR("David Borowski");
|
||||
MODULE_DESCRIPTION("Speakup support for Transport synthesizers");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_VERSION);
|
||||
|
65
drivers/staging/speakup/speakupmap.h
Normal file
65
drivers/staging/speakup/speakupmap.h
Normal file
@ -0,0 +1,65 @@
|
||||
119, 62, 6,
|
||||
0, 16, 20, 17, 32, 48, 0,
|
||||
2, 0, 78, 0, 0, 0, 0,
|
||||
3, 0, 79, 0, 0, 0, 0,
|
||||
4, 0, 76, 0, 0, 0, 0,
|
||||
5, 0, 77, 0, 0, 0, 0,
|
||||
6, 0, 74, 0, 0, 0, 0,
|
||||
7, 0, 75, 0, 0, 0, 0,
|
||||
9, 0, 5, 46, 0, 0, 0,
|
||||
10, 0, 4, 0, 0, 0, 0,
|
||||
11, 0, 0, 1, 0, 0, 0,
|
||||
12, 0, 27, 0, 33, 0, 0,
|
||||
19, 0, 47, 0, 0, 0, 0,
|
||||
21, 0, 29, 17, 0, 0, 0,
|
||||
22, 0, 15, 0, 0, 0, 0,
|
||||
23, 0, 14, 0, 0, 0, 28,
|
||||
24, 0, 16, 0, 0, 0, 0,
|
||||
25, 0, 30, 18, 0, 0, 0,
|
||||
28, 0, 3, 26, 0, 0, 0,
|
||||
35, 0, 31, 0, 0, 0, 0,
|
||||
36, 0, 12, 0, 0, 0, 0,
|
||||
37, 0, 11, 0, 0, 0, 22,
|
||||
38, 0, 13, 0, 0, 0, 0,
|
||||
39, 0, 32, 7, 0, 0, 0,
|
||||
40, 0, 23, 0, 0, 0, 0,
|
||||
44, 0, 44, 0, 0, 0, 0,
|
||||
49, 0, 24, 0, 0, 0, 0,
|
||||
50, 0, 9, 19, 6, 0, 0,
|
||||
51, 0, 8, 0, 0, 0, 36,
|
||||
52, 0, 10, 20, 0, 0, 0,
|
||||
53, 0, 25, 0, 0, 0, 0,
|
||||
55, 46, 1, 0, 0, 0, 0,
|
||||
58, 128, 128, 0, 0, 0, 0,
|
||||
59, 0, 45, 0, 0, 0, 0,
|
||||
60, 0, 40, 0, 0, 0, 0,
|
||||
61, 0, 41, 0, 0, 0, 0,
|
||||
62, 0, 42, 0, 0, 0, 0,
|
||||
63, 0, 34, 0, 0, 0, 0,
|
||||
64, 0, 35, 0, 0, 0, 0,
|
||||
65, 0, 37, 0, 0, 0, 0,
|
||||
66, 0, 38, 0, 0, 0, 0,
|
||||
67, 0, 66, 0, 39, 0, 0,
|
||||
68, 0, 67, 0, 0, 0, 0,
|
||||
71, 15, 19, 0, 0, 0, 0,
|
||||
72, 14, 29, 0, 0, 28, 0,
|
||||
73, 16, 17, 0, 0, 0, 0,
|
||||
74, 27, 33, 0, 0, 0, 0,
|
||||
75, 12, 31, 0, 0, 0, 0,
|
||||
76, 11, 21, 0, 0, 22, 0,
|
||||
77, 13, 32, 0, 0, 0, 0,
|
||||
78, 23, 43, 0, 0, 0, 0,
|
||||
79, 9, 20, 0, 0, 0, 0,
|
||||
80, 8, 30, 0, 0, 36, 0,
|
||||
81, 10, 18, 0, 0, 0, 0,
|
||||
82, 128, 128, 0, 0, 0, 0,
|
||||
83, 24, 25, 0, 0, 0, 0,
|
||||
87, 0, 68, 0, 0, 0, 0,
|
||||
88, 0, 69, 0, 0, 0, 0,
|
||||
96, 3, 26, 0, 0, 0, 0,
|
||||
98, 4, 5, 0, 0, 0, 0,
|
||||
99, 2, 0, 0, 0, 0, 0,
|
||||
104, 0, 6, 0, 0, 0, 0,
|
||||
109, 0, 7, 0, 0, 0, 0,
|
||||
125, 128, 128, 0, 0, 0, 0,
|
||||
0, 119
|
93
drivers/staging/speakup/speakupmap.map
Normal file
93
drivers/staging/speakup/speakupmap.map
Normal file
@ -0,0 +1,93 @@
|
||||
spk key_f9 = punc_level_dec
|
||||
spk key_f10 = punc_level_inc
|
||||
spk key_f11 = reading_punc_dec
|
||||
spk key_f12 = reading_punc_inc
|
||||
spk key_1 = vol_dec
|
||||
spk key_2 = vol_inc
|
||||
spk key_3 = pitch_dec
|
||||
spk key_4 = pitch_inc
|
||||
spk key_5 = rate_dec
|
||||
spk key_6 = rate_inc
|
||||
key_kpasterisk = toggle_cursoring
|
||||
ctrl spk key_8 = toggle_cursoring
|
||||
spk key_kpasterisk = speakup_goto
|
||||
spk key_f1 = speakup_help
|
||||
spk key_f2 = set_win
|
||||
spk key_f3 = clear_win
|
||||
spk key_f4 = enable_win
|
||||
spk key_f5 = edit_some
|
||||
spk key_f6 = edit_most
|
||||
spk key_f7 = edit_delim
|
||||
spk key_f8 = edit_repeat
|
||||
shift spk key_f9 = edit_exnum
|
||||
key_kp7 = say_prev_line
|
||||
spk key_kp7 = left_edge
|
||||
key_kp8 = say_line
|
||||
double key_kp8 = say_line_indent
|
||||
spk key_kp8 = say_from_top
|
||||
key_kp9 = say_next_line
|
||||
spk key_kp9 = top_edge
|
||||
key_kpminus = speakup_parked
|
||||
spk key_kpminus = say_char_num
|
||||
key_kp4 = say_prev_word
|
||||
spk key_kp4 = say_from_left
|
||||
key_kp5 = say_word
|
||||
double key_kp5 = spell_word
|
||||
spk key_kp5 = spell_phonetic
|
||||
key_kp6 = say_next_word
|
||||
spk key_kp6 = say_to_right
|
||||
key_kpplus = say_screen
|
||||
spk key_kpplus = say_win
|
||||
key_kp1 = say_prev_char
|
||||
spk key_kp1 = right_edge
|
||||
key_kp2 = say_char
|
||||
spk key_kp2 = say_to_bottom
|
||||
double key_kp2 = say_phonetic_char
|
||||
key_kp3 = say_next_char
|
||||
spk key_kp3 = bottom_edge
|
||||
key_kp0 = spk_key
|
||||
key_kpdot = say_position
|
||||
spk key_kpdot = say_attributes
|
||||
key_kpenter = speakup_quiet
|
||||
spk key_kpenter = speakup_off
|
||||
key_sysrq = speech_kill
|
||||
key_kpslash = speakup_cut
|
||||
spk key_kpslash = speakup_paste
|
||||
spk key_pageup = say_first_char
|
||||
spk key_pagedown = say_last_char
|
||||
key_capslock = spk_key
|
||||
spk key_z = spk_lock
|
||||
key_leftmeta = spk_key
|
||||
ctrl spk key_0 = speakup_goto
|
||||
spk key_u = say_prev_line
|
||||
spk key_i = say_line
|
||||
double spk key_i = say_line_indent
|
||||
spk key_o = say_next_line
|
||||
spk key_minus = speakup_parked
|
||||
shift spk key_minus = say_char_num
|
||||
spk key_j = say_prev_word
|
||||
spk key_k = say_word
|
||||
double spk key_k = spell_word
|
||||
spk key_l = say_next_word
|
||||
spk key_m = say_prev_char
|
||||
spk key_comma = say_char
|
||||
double spk key_comma = say_phonetic_char
|
||||
spk key_dot = say_next_char
|
||||
spk key_n = say_position
|
||||
ctrl spk key_m = left_edge
|
||||
ctrl spk key_y = top_edge
|
||||
ctrl spk key_dot = right_edge
|
||||
ctrl spk key_p = bottom_edge
|
||||
spk key_apostrophe = say_screen
|
||||
spk key_h = say_from_left
|
||||
spk key_y = say_from_top
|
||||
spk key_semicolon = say_to_right
|
||||
spk key_p = say_to_bottom
|
||||
spk key_slash = say_attributes
|
||||
spk key_enter = speakup_quiet
|
||||
ctrl spk key_enter = speakup_off
|
||||
spk key_9 = speakup_cut
|
||||
spk key_8 = speakup_paste
|
||||
shift spk key_m = say_first_char
|
||||
ctrl spk key_semicolon = say_last_char
|
||||
spk key_r = read_all_doc
|
93
drivers/staging/speakup/spk_priv.h
Normal file
93
drivers/staging/speakup/spk_priv.h
Normal file
@ -0,0 +1,93 @@
|
||||
/* spk_priv.h
|
||||
review functions for the speakup screen review package.
|
||||
originally written by: Kirk Reiser and Andy Berdan.
|
||||
|
||||
extensively modified by David Borowski.
|
||||
|
||||
Copyright (C) 1998 Kirk Reiser.
|
||||
Copyright (C) 2003 David Borowski.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef _SPEAKUP_PRIVATE_H
|
||||
#define _SPEAKUP_PRIVATE_H
|
||||
|
||||
#include "spk_types.h"
|
||||
#include "spk_priv_keyinfo.h"
|
||||
|
||||
#ifndef pr_warn
|
||||
#define pr_warn(fmt, arg...) printk(KERN_WARNING fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#define V_LAST_VAR { MAXVARS }
|
||||
#define SPACE 0x20
|
||||
#define SYNTH_CHECK 20030716 /* today's date ought to do for check value */
|
||||
/* synth flags, for odd synths */
|
||||
#define SF_DEC 1 /* to fiddle puncs in alpha strings so it doesn't spell */
|
||||
#ifdef MODULE
|
||||
#define SYNTH_START 1
|
||||
#else
|
||||
#define SYNTH_START 0
|
||||
#endif
|
||||
|
||||
#define KT_SPKUP 15
|
||||
|
||||
extern struct serial_state *spk_serial_init(int index);
|
||||
extern void stop_serial_interrupt(void);
|
||||
extern int wait_for_xmitr(void);
|
||||
extern unsigned char spk_serial_in(void);
|
||||
extern unsigned char spk_serial_in_nowait(void);
|
||||
extern int spk_serial_out(const char ch);
|
||||
extern void spk_serial_release(void);
|
||||
|
||||
extern char synth_buffer_getc(void);
|
||||
extern char synth_buffer_peek(void);
|
||||
extern int synth_buffer_empty(void);
|
||||
extern struct var_t *get_var(enum var_id_t var_id);
|
||||
extern ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf);
|
||||
extern ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
const char *buf, size_t count);
|
||||
|
||||
extern int serial_synth_probe(struct spk_synth *synth);
|
||||
extern const char *spk_synth_immediate(struct spk_synth *synth, const char *buff);
|
||||
extern void spk_do_catch_up(struct spk_synth *synth);
|
||||
extern void spk_synth_flush(struct spk_synth *synth);
|
||||
extern int spk_synth_is_alive_nop(struct spk_synth *synth);
|
||||
extern int spk_synth_is_alive_restart(struct spk_synth *synth);
|
||||
extern void synth_printf(const char *buf, ...);
|
||||
extern int synth_request_region(u_long, u_long);
|
||||
extern int synth_release_region(u_long, u_long);
|
||||
extern int synth_add(struct spk_synth *in_synth);
|
||||
extern void synth_remove(struct spk_synth *in_synth);
|
||||
|
||||
extern struct speakup_info_t speakup_info;
|
||||
|
||||
extern struct var_t synth_time_vars[];
|
||||
|
||||
/* Protect the whole speakup machinery, must be taken at each kernel->speakup
|
||||
* transition and released at all corresponding speakup->kernel transitions
|
||||
* (flags must be the same variable between lock/trylock and unlock).
|
||||
*
|
||||
* The progression thread only interferes with the speakup machinery through
|
||||
* the synth buffer, and so only needs to take the lock while tinkering with
|
||||
* it.
|
||||
*/
|
||||
/* Speakup needs to disable the keyboard IRQ, hence _irqsave/restore */
|
||||
#define spk_lock(flags) spin_lock_irqsave(&speakup_info.spinlock, flags)
|
||||
#define spk_trylock(flags) spin_trylock_irqsave(&speakup_info.spinlock, flags)
|
||||
#define spk_unlock(flags) spin_unlock_irqrestore(&speakup_info.spinlock, flags)
|
||||
|
||||
#endif
|
110
drivers/staging/speakup/spk_priv_keyinfo.h
Normal file
110
drivers/staging/speakup/spk_priv_keyinfo.h
Normal file
@ -0,0 +1,110 @@
|
||||
/* spk_priv.h
|
||||
review functions for the speakup screen review package.
|
||||
originally written by: Kirk Reiser and Andy Berdan.
|
||||
|
||||
extensively modified by David Borowski.
|
||||
|
||||
Copyright (C) 1998 Kirk Reiser.
|
||||
Copyright (C) 2003 David Borowski.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _SPEAKUP_KEYINFO_H
|
||||
#define _SPEAKUP_KEYINFO_H
|
||||
|
||||
#define FIRST_SYNTH_VAR RATE
|
||||
/* 0 is reserved for no remap */
|
||||
#define SPEAKUP_GOTO 0x01
|
||||
#define SPEECH_KILL 0x02
|
||||
#define SPEAKUP_QUIET 0x03
|
||||
#define SPEAKUP_CUT 0x04
|
||||
#define SPEAKUP_PASTE 0x05
|
||||
#define SAY_FIRST_CHAR 0x06
|
||||
#define SAY_LAST_CHAR 0x07
|
||||
#define SAY_CHAR 0x08
|
||||
#define SAY_PREV_CHAR 0x09
|
||||
#define SAY_NEXT_CHAR 0x0a
|
||||
#define SAY_WORD 0x0b
|
||||
#define SAY_PREV_WORD 0x0c
|
||||
#define SAY_NEXT_WORD 0x0d
|
||||
#define SAY_LINE 0x0e
|
||||
#define SAY_PREV_LINE 0x0f
|
||||
#define SAY_NEXT_LINE 0x10
|
||||
#define TOP_EDGE 0x11
|
||||
#define BOTTOM_EDGE 0x12
|
||||
#define LEFT_EDGE 0x13
|
||||
#define RIGHT_EDGE 0x14
|
||||
#define SPELL_PHONETIC 0x15
|
||||
#define SPELL_WORD 0x16
|
||||
#define SAY_SCREEN 0x17
|
||||
#define SAY_POSITION 0x18
|
||||
#define SAY_ATTRIBUTES 0x19
|
||||
#define SPEAKUP_OFF 0x1a
|
||||
#define SPEAKUP_PARKED 0x1b
|
||||
#define SAY_LINE_INDENT 0x1c
|
||||
#define SAY_FROM_TOP 0x1d
|
||||
#define SAY_TO_BOTTOM 0x1e
|
||||
#define SAY_FROM_LEFT 0x1f
|
||||
#define SAY_TO_RIGHT 0x20
|
||||
#define SAY_CHAR_NUM 0x21
|
||||
#define EDIT_SOME 0x22
|
||||
#define EDIT_MOST 0x23
|
||||
#define SAY_PHONETIC_CHAR 0x24
|
||||
#define EDIT_DELIM 0x25
|
||||
#define EDIT_REPEAT 0x26
|
||||
#define EDIT_EXNUM 0x27
|
||||
#define SET_WIN 0x28
|
||||
#define CLEAR_WIN 0x29
|
||||
#define ENABLE_WIN 0x2a
|
||||
#define SAY_WIN 0x2b
|
||||
#define SPK_LOCK 0x2c
|
||||
#define SPEAKUP_HELP 0x2d
|
||||
#define TOGGLE_CURSORING 0x2e
|
||||
#define READ_ALL_DOC 0x2f
|
||||
#define SPKUP_MAX_FUNC 0x30 /* one greater than the last func handler */
|
||||
|
||||
#define SPK_KEY 0x80
|
||||
#define FIRST_EDIT_BITS 0x22
|
||||
|
||||
#define FIRST_SET_VAR SPELL_DELAY
|
||||
#define VAR_START 0x40 /* increase if adding more than 0x3f functions */
|
||||
|
||||
/* keys for setting variables, must be ordered same as the enum for var_ids */
|
||||
/* with dec being even and inc being 1 greater */
|
||||
#define SPELL_DELAY_DEC VAR_START+0
|
||||
#define SPELL_DELAY_INC SPELL_DELAY_DEC+1
|
||||
#define PUNC_LEVEL_DEC SPELL_DELAY_DEC+2
|
||||
#define PUNC_LEVEL_INC PUNC_LEVEL_DEC+1
|
||||
#define READING_PUNC_DEC PUNC_LEVEL_DEC+2
|
||||
#define READING_PUNC_INC READING_PUNC_DEC+1
|
||||
#define ATTRIB_BLEEP_DEC READING_PUNC_DEC+2
|
||||
#define ATTRIB_BLEEP_INC ATTRIB_BLEEP_DEC+1
|
||||
#define BLEEPS_DEC ATTRIB_BLEEP_DEC+2
|
||||
#define BLEEPS_INC BLEEPS_DEC+1
|
||||
#define RATE_DEC BLEEPS_DEC+2
|
||||
#define RATE_INC RATE_DEC+1
|
||||
#define PITCH_DEC RATE_DEC+2
|
||||
#define PITCH_INC PITCH_DEC+1
|
||||
#define VOL_DEC PITCH_DEC+2
|
||||
#define VOL_INC VOL_DEC+1
|
||||
#define TONE_DEC VOL_DEC+2
|
||||
#define TONE_INC TONE_DEC+1
|
||||
#define PUNCT_DEC TONE_DEC+2
|
||||
#define PUNCT_INC PUNCT_DEC+1
|
||||
#define VOICE_DEC PUNCT_DEC+2
|
||||
#define VOICE_INC VOICE_DEC+1
|
||||
|
||||
#endif
|
193
drivers/staging/speakup/spk_types.h
Normal file
193
drivers/staging/speakup/spk_types.h
Normal file
@ -0,0 +1,193 @@
|
||||
#ifndef SPEAKUP_TYPES_H
|
||||
#define SPEAKUP_TYPES_H
|
||||
|
||||
/*
|
||||
* This file includes all of the typedefs and structs used in speakup.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/wait.h> /* for wait_queue */
|
||||
#include <linux/init.h> /* for __init */
|
||||
#include <linux/module.h>
|
||||
#include <linux/vt_kern.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/io.h> /* for inb_p, outb_p, inb, outb, etc... */
|
||||
|
||||
enum var_type_t {
|
||||
VAR_NUM = 0,
|
||||
VAR_TIME,
|
||||
VAR_STRING,
|
||||
VAR_PROC
|
||||
};
|
||||
|
||||
enum {
|
||||
E_DEFAULT = 0,
|
||||
E_SET,
|
||||
E_INC,
|
||||
E_DEC,
|
||||
E_NEW_DEFAULT,
|
||||
};
|
||||
|
||||
enum var_id_t {
|
||||
VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT,
|
||||
KEYMAP, CHARS,
|
||||
PUNC_SOME, PUNC_MOST, PUNC_ALL,
|
||||
DELIM, REPEATS, EXNUMBER,
|
||||
DELAY, TRIGGER, JIFFY, FULL, /* all timers must be together */
|
||||
BLEEP_TIME, CURSOR_TIME, BELL_POS,
|
||||
SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
|
||||
SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
|
||||
ATTRIB_BLEEP, BLEEPS,
|
||||
RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, DIRECT,
|
||||
CAPS_START, CAPS_STOP, CHARTAB,
|
||||
MAXVARS
|
||||
};
|
||||
|
||||
typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch,
|
||||
u_short key);
|
||||
|
||||
#define COLOR_BUFFER_SIZE 160
|
||||
|
||||
struct spk_highlight_color_track{
|
||||
/* Count of each background color */
|
||||
unsigned int bgcount[8];
|
||||
/* Buffer for characters drawn with each background color */
|
||||
char highbuf[8][COLOR_BUFFER_SIZE];
|
||||
/* Current index into highbuf */
|
||||
unsigned int highsize[8];
|
||||
/* Reading Position for each color */
|
||||
u_long rpos[8], rx[8], ry[8];
|
||||
/* Real Cursor Y Position */
|
||||
ulong cy;
|
||||
};
|
||||
|
||||
struct st_spk_t {
|
||||
u_long reading_x, cursor_x;
|
||||
u_long reading_y, cursor_y;
|
||||
u_long reading_pos, cursor_pos;
|
||||
u_long go_x, go_pos;
|
||||
u_long w_top, w_bottom, w_left, w_right;
|
||||
u_char w_start, w_enabled;
|
||||
u_char reading_attr, old_attr;
|
||||
char parked, shut_up;
|
||||
struct spk_highlight_color_track ht;
|
||||
int tty_stopped;
|
||||
};
|
||||
|
||||
/* now some defines to make these easier to use. */
|
||||
#define spk_shut_up speakup_console[vc->vc_num]->shut_up
|
||||
#define spk_killed (speakup_console[vc->vc_num]->shut_up & 0x40)
|
||||
#define spk_x speakup_console[vc->vc_num]->reading_x
|
||||
#define spk_cx speakup_console[vc->vc_num]->cursor_x
|
||||
#define spk_y speakup_console[vc->vc_num]->reading_y
|
||||
#define spk_cy speakup_console[vc->vc_num]->cursor_y
|
||||
#define spk_pos (speakup_console[vc->vc_num]->reading_pos)
|
||||
#define spk_cp speakup_console[vc->vc_num]->cursor_pos
|
||||
#define goto_pos (speakup_console[vc->vc_num]->go_pos)
|
||||
#define goto_x (speakup_console[vc->vc_num]->go_x)
|
||||
#define win_top (speakup_console[vc->vc_num]->w_top)
|
||||
#define win_bottom (speakup_console[vc->vc_num]->w_bottom)
|
||||
#define win_left (speakup_console[vc->vc_num]->w_left)
|
||||
#define win_right (speakup_console[vc->vc_num]->w_right)
|
||||
#define win_start (speakup_console[vc->vc_num]->w_start)
|
||||
#define win_enabled (speakup_console[vc->vc_num]->w_enabled)
|
||||
#define spk_attr speakup_console[vc->vc_num]->reading_attr
|
||||
#define spk_old_attr speakup_console[vc->vc_num]->old_attr
|
||||
#define spk_parked speakup_console[vc->vc_num]->parked
|
||||
|
||||
struct st_var_header {
|
||||
char *name;
|
||||
enum var_id_t var_id;
|
||||
enum var_type_t var_type;
|
||||
void *p_val; /* ptr to programs variable to store value */
|
||||
void *data; /* ptr to the vars data */
|
||||
};
|
||||
|
||||
struct num_var_t {
|
||||
char *synth_fmt;
|
||||
int default_val;
|
||||
int low;
|
||||
int high;
|
||||
short offset, multiplier; /* for fiddling rates etc. */
|
||||
char *out_str; /* if synth needs char representation of number */
|
||||
int value; /* current value */
|
||||
};
|
||||
|
||||
struct punc_var_t {
|
||||
enum var_id_t var_id;
|
||||
short value;
|
||||
};
|
||||
|
||||
struct string_var_t {
|
||||
char *default_val;
|
||||
};
|
||||
|
||||
struct var_t {
|
||||
enum var_id_t var_id;
|
||||
union {
|
||||
struct num_var_t n;
|
||||
struct string_var_t s;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct st_bits_data { /* punc, repeats, word delim bits */
|
||||
char *name;
|
||||
char *value;
|
||||
short mask;
|
||||
};
|
||||
|
||||
struct synth_indexing {
|
||||
char *command;
|
||||
unsigned char lowindex;
|
||||
unsigned char highindex;
|
||||
unsigned char currindex;
|
||||
};
|
||||
|
||||
struct spk_synth {
|
||||
const char *name;
|
||||
const char *version;
|
||||
const char *long_name;
|
||||
const char *init;
|
||||
char procspeech;
|
||||
char clear;
|
||||
int delay;
|
||||
int trigger;
|
||||
int jiffies;
|
||||
int full;
|
||||
int ser;
|
||||
short flags;
|
||||
short startup;
|
||||
const int checkval; /* for validating a proper synth module */
|
||||
struct var_t *vars;
|
||||
int *default_pitch;
|
||||
int *default_vol;
|
||||
int (*probe)(struct spk_synth *synth);
|
||||
void (*release)(void);
|
||||
const char *(*synth_immediate)(struct spk_synth *synth, const char *buff);
|
||||
void (*catch_up)(struct spk_synth *synth);
|
||||
void (*flush)(struct spk_synth *synth);
|
||||
int (*is_alive)(struct spk_synth *synth);
|
||||
int (*synth_adjust)(struct st_var_header *var);
|
||||
void (*read_buff_add)(u_char);
|
||||
unsigned char (*get_index)(void);
|
||||
struct synth_indexing indexing;
|
||||
int alive;
|
||||
struct attribute_group attributes;
|
||||
};
|
||||
|
||||
struct speakup_info_t {
|
||||
spinlock_t spinlock;
|
||||
int port_tts;
|
||||
int flushing;
|
||||
};
|
||||
|
||||
struct bleep {
|
||||
short freq;
|
||||
unsigned long jiffies;
|
||||
int active;
|
||||
};
|
||||
#endif
|
1575
drivers/staging/speakup/spkguide.txt
Normal file
1575
drivers/staging/speakup/spkguide.txt
Normal file
File diff suppressed because it is too large
Load Diff
458
drivers/staging/speakup/synth.c
Normal file
458
drivers/staging/speakup/synth.c
Normal file
@ -0,0 +1,458 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/ctype.h> /* for isdigit() and friends */
|
||||
#include <linux/fs.h>
|
||||
#include <linux/mm.h> /* for verify_area */
|
||||
#include <linux/errno.h> /* for -EBUSY */
|
||||
#include <linux/ioport.h> /* for check_region, request_region */
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/delay.h> /* for loops_per_sec */
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/uaccess.h> /* for copy_from_user */
|
||||
#include <linux/sched.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
#include "serialio.h"
|
||||
|
||||
#define MAXSYNTHS 16 /* Max number of synths in array. */
|
||||
static struct spk_synth *synths[MAXSYNTHS];
|
||||
struct spk_synth *synth = NULL;
|
||||
char pitch_buff[32] = "";
|
||||
static int module_status;
|
||||
int quiet_boot;
|
||||
|
||||
struct speakup_info_t speakup_info = {
|
||||
.spinlock = SPIN_LOCK_UNLOCKED,
|
||||
.flushing = 0,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(speakup_info);
|
||||
|
||||
static int do_synth_init(struct spk_synth *in_synth);
|
||||
|
||||
int serial_synth_probe(struct spk_synth *synth)
|
||||
{
|
||||
struct serial_state *ser;
|
||||
int failed = 0;
|
||||
|
||||
if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) {
|
||||
ser = spk_serial_init(synth->ser);
|
||||
if (ser == NULL) {
|
||||
failed = -1;
|
||||
} else {
|
||||
outb_p(0, ser->port);
|
||||
mdelay(1);
|
||||
outb_p('\r', ser->port);
|
||||
}
|
||||
} else {
|
||||
failed = -1;
|
||||
pr_warn("ttyS%i is an invalid port\n", synth->ser);
|
||||
}
|
||||
if (failed) {
|
||||
pr_info("%s: not found\n", synth->long_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
pr_info("%s: ttyS%i, Driver Version %s\n",
|
||||
synth->long_name, synth->ser, synth->version);
|
||||
synth->alive = 1;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(serial_synth_probe);
|
||||
|
||||
/* Main loop of the progression thread: keep eating from the buffer
|
||||
* and push to the serial port, waiting as needed
|
||||
*
|
||||
* For devices that have a "full" notification mecanism, the driver can
|
||||
* adapt the loop the way they prefer.
|
||||
*/
|
||||
void spk_do_catch_up(struct spk_synth *synth)
|
||||
{
|
||||
u_char ch;
|
||||
unsigned long flags;
|
||||
unsigned long jiff_max;
|
||||
struct var_t *delay_time;
|
||||
struct var_t *full_time;
|
||||
struct var_t *jiffy_delta;
|
||||
int jiffy_delta_val;
|
||||
int delay_time_val;
|
||||
int full_time_val;
|
||||
|
||||
jiffy_delta = get_var(JIFFY);
|
||||
full_time = get_var(FULL);
|
||||
delay_time = get_var(DELAY);
|
||||
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
spk_unlock(flags);
|
||||
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
while (!kthread_should_stop()) {
|
||||
spk_lock(flags);
|
||||
if (speakup_info.flushing) {
|
||||
speakup_info.flushing = 0;
|
||||
spk_unlock(flags);
|
||||
synth->flush(synth);
|
||||
continue;
|
||||
}
|
||||
if (synth_buffer_empty()) {
|
||||
spk_unlock(flags);
|
||||
break;
|
||||
}
|
||||
ch = synth_buffer_peek();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
full_time_val = full_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (ch == '\n')
|
||||
ch = synth->procspeech;
|
||||
if (!spk_serial_out(ch)) {
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
continue;
|
||||
}
|
||||
if ((jiffies >= jiff_max) && (ch == SPACE)) {
|
||||
spk_lock(flags);
|
||||
jiffy_delta_val = jiffy_delta->u.n.value;
|
||||
delay_time_val = delay_time->u.n.value;
|
||||
full_time_val = full_time->u.n.value;
|
||||
spk_unlock(flags);
|
||||
if (spk_serial_out(synth->procspeech))
|
||||
schedule_timeout(msecs_to_jiffies(delay_time_val));
|
||||
else
|
||||
schedule_timeout(msecs_to_jiffies(full_time_val));
|
||||
jiff_max = jiffies + jiffy_delta_val;
|
||||
}
|
||||
set_current_state(TASK_RUNNING);
|
||||
spk_lock(flags);
|
||||
synth_buffer_getc();
|
||||
spk_unlock(flags);
|
||||
}
|
||||
spk_serial_out(synth->procspeech);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_do_catch_up);
|
||||
|
||||
const char *spk_synth_immediate(struct spk_synth *synth, const char *buff)
|
||||
{
|
||||
u_char ch;
|
||||
while ((ch = *buff)) {
|
||||
if (ch == '\n')
|
||||
ch = synth->procspeech;
|
||||
if (wait_for_xmitr())
|
||||
outb(ch, speakup_info.port_tts);
|
||||
else
|
||||
return buff;
|
||||
buff++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_synth_immediate);
|
||||
|
||||
void spk_synth_flush(struct spk_synth *synth)
|
||||
{
|
||||
spk_serial_out(synth->clear);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_synth_flush);
|
||||
|
||||
int spk_synth_is_alive_nop(struct spk_synth *synth)
|
||||
{
|
||||
synth->alive = 1;
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_synth_is_alive_nop);
|
||||
|
||||
int spk_synth_is_alive_restart(struct spk_synth *synth)
|
||||
{
|
||||
if (synth->alive)
|
||||
return 1;
|
||||
if (!synth->alive && wait_for_xmitr() > 0) {
|
||||
/* restart */
|
||||
synth->alive = 1;
|
||||
synth_printf("%s", synth->init);
|
||||
return 2; /* reenabled */
|
||||
}
|
||||
pr_warn("%s: can't restart synth\n", synth->long_name);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spk_synth_is_alive_restart);
|
||||
|
||||
static void thread_wake_up(u_long data)
|
||||
{
|
||||
wake_up_interruptible_all(&speakup_event);
|
||||
}
|
||||
|
||||
static DEFINE_TIMER(thread_timer, thread_wake_up, 0, 0);
|
||||
|
||||
void synth_start(void)
|
||||
{
|
||||
struct var_t *trigger_time;
|
||||
|
||||
if (!synth->alive) {
|
||||
synth_buffer_clear();
|
||||
return;
|
||||
}
|
||||
trigger_time = get_var(TRIGGER);
|
||||
if (!timer_pending(&thread_timer))
|
||||
mod_timer(&thread_timer, jiffies + msecs_to_jiffies(trigger_time->u.n.value));
|
||||
}
|
||||
|
||||
void do_flush(void)
|
||||
{
|
||||
speakup_info.flushing = 1;
|
||||
synth_buffer_clear();
|
||||
if (synth->alive) {
|
||||
if (pitch_shift) {
|
||||
synth_printf("%s", pitch_buff);
|
||||
pitch_shift = 0;
|
||||
}
|
||||
}
|
||||
wake_up_interruptible_all(&speakup_event);
|
||||
wake_up_process(speakup_task);
|
||||
}
|
||||
|
||||
void synth_write(const char *buf, size_t count)
|
||||
{
|
||||
while (count--)
|
||||
synth_buffer_add(*buf++);
|
||||
synth_start();
|
||||
}
|
||||
|
||||
void synth_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
unsigned char buf[160], *p;
|
||||
int r;
|
||||
|
||||
va_start(args, fmt);
|
||||
r = vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
if (r > sizeof(buf) - 1)
|
||||
r = sizeof(buf) - 1;
|
||||
|
||||
p = buf;
|
||||
while (r--)
|
||||
synth_buffer_add(*p++);
|
||||
synth_start();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_printf);
|
||||
|
||||
static int index_count = 0;
|
||||
static int sentence_count = 0;
|
||||
|
||||
void reset_index_count(int sc)
|
||||
{
|
||||
static int first = 1;
|
||||
if (first)
|
||||
first = 0;
|
||||
else
|
||||
synth->get_index();
|
||||
index_count = 0;
|
||||
sentence_count = sc;
|
||||
}
|
||||
|
||||
int synth_supports_indexing(void)
|
||||
{
|
||||
if (synth->get_index != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void synth_insert_next_index(int sent_num)
|
||||
{
|
||||
int out;
|
||||
if (synth->alive) {
|
||||
if (sent_num == 0) {
|
||||
synth->indexing.currindex++;
|
||||
index_count++;
|
||||
if (synth->indexing.currindex >
|
||||
synth->indexing.highindex)
|
||||
synth->indexing.currindex =
|
||||
synth->indexing.lowindex;
|
||||
}
|
||||
|
||||
out = synth->indexing.currindex * 10 + sent_num;
|
||||
synth_printf(synth->indexing.command, out, out);
|
||||
}
|
||||
}
|
||||
|
||||
void get_index_count(int *linecount, int *sentcount)
|
||||
{
|
||||
int ind = synth->get_index();
|
||||
if (ind) {
|
||||
sentence_count = ind % 10;
|
||||
|
||||
if ((ind / 10) <= synth->indexing.currindex)
|
||||
index_count = synth->indexing.currindex-(ind/10);
|
||||
else
|
||||
index_count = synth->indexing.currindex-synth->indexing.lowindex
|
||||
+ synth->indexing.highindex-(ind/10)+1;
|
||||
|
||||
}
|
||||
*sentcount = sentence_count;
|
||||
*linecount = index_count;
|
||||
}
|
||||
|
||||
static struct resource synth_res;
|
||||
|
||||
int synth_request_region(unsigned long start, unsigned long n)
|
||||
{
|
||||
struct resource *parent = &ioport_resource;
|
||||
memset(&synth_res, 0, sizeof(synth_res));
|
||||
synth_res.name = synth->name;
|
||||
synth_res.start = start;
|
||||
synth_res.end = start + n - 1;
|
||||
synth_res.flags = IORESOURCE_BUSY;
|
||||
return request_resource(parent, &synth_res);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_request_region);
|
||||
|
||||
int synth_release_region(unsigned long start, unsigned long n)
|
||||
{
|
||||
return release_resource(&synth_res);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_release_region);
|
||||
|
||||
struct var_t synth_time_vars[] = {
|
||||
{ DELAY, .u.n = {NULL, 100, 100, 2000, 0, 0, NULL }},
|
||||
{ TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL }},
|
||||
{ JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL }},
|
||||
{ FULL, .u.n = {NULL, 400, 200, 60000, 0, 0, NULL }},
|
||||
V_LAST_VAR
|
||||
};
|
||||
|
||||
/* called by: speakup_init() */
|
||||
int synth_init(char *synth_name)
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
struct spk_synth *synth = NULL;
|
||||
|
||||
if (synth_name == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(synth_name, "none") == 0) {
|
||||
mutex_lock(&spk_mutex);
|
||||
synth_release();
|
||||
mutex_unlock(&spk_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mutex_lock(&spk_mutex);
|
||||
/* First, check if we already have it loaded. */
|
||||
for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
|
||||
if (strcmp(synths[i]->name, synth_name) == 0)
|
||||
synth = synths[i];
|
||||
|
||||
/* If we got one, initialize it now. */
|
||||
if (synth)
|
||||
ret = do_synth_init(synth);
|
||||
else
|
||||
ret = -ENODEV;
|
||||
mutex_unlock(&spk_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* called by: synth_add() */
|
||||
static int do_synth_init(struct spk_synth *in_synth)
|
||||
{
|
||||
struct var_t *var;
|
||||
|
||||
synth_release();
|
||||
if (in_synth->checkval != SYNTH_CHECK)
|
||||
return -EINVAL;
|
||||
synth = in_synth;
|
||||
synth->alive = 0;
|
||||
pr_warn("synth probe\n");
|
||||
if (synth->probe(synth) < 0) {
|
||||
pr_warn("%s: device probe failed\n", in_synth->name);
|
||||
synth = NULL;
|
||||
return -ENODEV;
|
||||
}
|
||||
synth_time_vars[0].u.n.value =
|
||||
synth_time_vars[0].u.n.default_val = synth->delay;
|
||||
synth_time_vars[1].u.n.value =
|
||||
synth_time_vars[1].u.n.default_val = synth->trigger;
|
||||
synth_time_vars[2].u.n.value =
|
||||
synth_time_vars[2].u.n.default_val = synth->jiffies;
|
||||
synth_time_vars[3].u.n.value =
|
||||
synth_time_vars[3].u.n.default_val = synth->full;
|
||||
synth_printf("%s", synth->init);
|
||||
for (var = synth->vars; (var->var_id >= 0) && (var->var_id < MAXVARS); var++)
|
||||
speakup_register_var(var);
|
||||
if (!quiet_boot)
|
||||
synth_printf("%s found\n", synth->long_name);
|
||||
if (synth->attributes.name
|
||||
&& sysfs_create_group(speakup_kobj, &(synth->attributes)) < 0)
|
||||
return -ENOMEM;
|
||||
synth_flags = synth->flags;
|
||||
wake_up_interruptible_all(&speakup_event);
|
||||
if (speakup_task)
|
||||
wake_up_process(speakup_task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void synth_release(void)
|
||||
{
|
||||
struct var_t *var;
|
||||
unsigned long flags;
|
||||
|
||||
if (synth == NULL)
|
||||
return;
|
||||
spk_lock(flags);
|
||||
pr_info("releasing synth %s\n", synth->name);
|
||||
synth->alive = 0;
|
||||
del_timer(&thread_timer);
|
||||
spk_unlock(flags);
|
||||
if (synth->attributes.name)
|
||||
sysfs_remove_group(speakup_kobj, &(synth->attributes));
|
||||
for (var = synth->vars; var->var_id != MAXVARS; var++)
|
||||
speakup_unregister_var(var->var_id);
|
||||
stop_serial_interrupt();
|
||||
synth->release();
|
||||
synth = NULL;
|
||||
}
|
||||
|
||||
/* called by: all_driver_init() */
|
||||
int synth_add(struct spk_synth *in_synth)
|
||||
{
|
||||
int i;
|
||||
int status = 0;
|
||||
mutex_lock(&spk_mutex);
|
||||
for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
|
||||
/* synth_remove() is responsible for rotating the array down */
|
||||
if (in_synth == synths[i]) {
|
||||
mutex_unlock(&spk_mutex);
|
||||
return 0;
|
||||
}
|
||||
if (i == MAXSYNTHS) {
|
||||
pr_warn("Error: attempting to add a synth past end of array\n");
|
||||
mutex_unlock(&spk_mutex);
|
||||
return -1;
|
||||
}
|
||||
synths[i++] = in_synth;
|
||||
synths[i] = NULL;
|
||||
if (in_synth->startup)
|
||||
status = do_synth_init(in_synth);
|
||||
mutex_unlock(&spk_mutex);
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_add);
|
||||
|
||||
void synth_remove(struct spk_synth *in_synth)
|
||||
{
|
||||
int i;
|
||||
mutex_lock(&spk_mutex);
|
||||
if (synth == in_synth)
|
||||
synth_release();
|
||||
for (i = 0; synths[i] != NULL; i++) {
|
||||
if (in_synth == synths[i])
|
||||
break;
|
||||
}
|
||||
for ( ; synths[i] != NULL; i++) /* compress table */
|
||||
synths[i] = synths[i+1];
|
||||
module_status = 0;
|
||||
mutex_unlock(&spk_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(synth_remove);
|
||||
|
||||
short punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
|
58
drivers/staging/speakup/thread.c
Normal file
58
drivers/staging/speakup/thread.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include "spk_types.h"
|
||||
#include "speakup.h"
|
||||
#include "spk_priv.h"
|
||||
|
||||
DECLARE_WAIT_QUEUE_HEAD(speakup_event);
|
||||
EXPORT_SYMBOL_GPL(speakup_event);
|
||||
|
||||
int speakup_thread(void *data)
|
||||
{
|
||||
unsigned long flags;
|
||||
int should_break;
|
||||
struct bleep our_sound;
|
||||
|
||||
our_sound.active = 0;
|
||||
our_sound.freq = 0;
|
||||
our_sound.jiffies = 0;
|
||||
|
||||
mutex_lock(&spk_mutex);
|
||||
while (1) {
|
||||
DEFINE_WAIT(wait);
|
||||
while(1) {
|
||||
spk_lock(flags);
|
||||
our_sound = unprocessed_sound;
|
||||
unprocessed_sound.active = 0;
|
||||
prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
|
||||
should_break = kthread_should_stop() ||
|
||||
our_sound.active ||
|
||||
(synth && synth->catch_up && synth->alive &&
|
||||
(speakup_info.flushing ||
|
||||
!synth_buffer_empty()));
|
||||
spk_unlock(flags);
|
||||
if (should_break)
|
||||
break;
|
||||
mutex_unlock(&spk_mutex);
|
||||
schedule();
|
||||
mutex_lock(&spk_mutex);
|
||||
}
|
||||
finish_wait(&speakup_event, &wait);
|
||||
if (kthread_should_stop())
|
||||
break;
|
||||
|
||||
if (our_sound.active) {
|
||||
kd_mksound(our_sound.freq, our_sound.jiffies);
|
||||
}
|
||||
if (synth && synth->catch_up && synth->alive) {
|
||||
/* It is up to the callee to take the lock, so that it
|
||||
* can sleep whenever it likes */
|
||||
synth->catch_up(synth);
|
||||
}
|
||||
|
||||
speakup_start_ttys();
|
||||
}
|
||||
mutex_unlock(&spk_mutex);
|
||||
return 0;
|
||||
}
|
403
drivers/staging/speakup/varhandlers.c
Normal file
403
drivers/staging/speakup/varhandlers.c
Normal file
@ -0,0 +1,403 @@
|
||||
#include <linux/ctype.h>
|
||||
#include "spk_types.h"
|
||||
#include "spk_priv.h"
|
||||
#include "speakup.h"
|
||||
|
||||
static struct st_var_header var_headers[] = {
|
||||
{ "version", VERSION, VAR_PROC, NULL, NULL },
|
||||
{ "synth_name", SYNTH, VAR_PROC, NULL, NULL },
|
||||
{ "keymap", KEYMAP, VAR_PROC, NULL, NULL },
|
||||
{ "silent", SILENT, VAR_PROC, NULL, NULL },
|
||||
{ "punc_some", PUNC_SOME, VAR_PROC, NULL, NULL },
|
||||
{ "punc_most", PUNC_MOST, VAR_PROC, NULL, NULL },
|
||||
{ "punc_all", PUNC_ALL, VAR_PROC, NULL, NULL },
|
||||
{ "delimiters", DELIM, VAR_PROC, NULL, NULL },
|
||||
{ "repeats", REPEATS, VAR_PROC, NULL, NULL },
|
||||
{ "ex_num", EXNUMBER, VAR_PROC, NULL, NULL },
|
||||
{ "characters", CHARS, VAR_PROC, NULL, NULL },
|
||||
{ "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL },
|
||||
{ "caps_start", CAPS_START, VAR_STRING, str_caps_start, NULL },
|
||||
{ "caps_stop", CAPS_STOP, VAR_STRING, str_caps_stop, NULL },
|
||||
{ "delay_time", DELAY, VAR_TIME, NULL, NULL },
|
||||
{ "trigger_time", TRIGGER, VAR_TIME, NULL, NULL },
|
||||
{ "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL },
|
||||
{ "full_time", FULL, VAR_TIME, NULL, NULL },
|
||||
{ "spell_delay", SPELL_DELAY, VAR_NUM, &spell_delay, NULL },
|
||||
{ "bleeps", BLEEPS, VAR_NUM, &bleeps, NULL },
|
||||
{ "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &attrib_bleep, NULL },
|
||||
{ "bleep_time", BLEEP_TIME, VAR_TIME, &bleep_time, NULL },
|
||||
{ "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL },
|
||||
{ "punc_level", PUNC_LEVEL, VAR_NUM, &punc_level, NULL },
|
||||
{ "reading_punc", READING_PUNC, VAR_NUM, &reading_punc, NULL },
|
||||
{ "say_control", SAY_CONTROL, VAR_NUM, &say_ctrl, NULL },
|
||||
{ "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &say_word_ctl, NULL },
|
||||
{ "no_interrupt", NO_INTERRUPT, VAR_NUM, &no_intr, NULL },
|
||||
{ "key_echo", KEY_ECHO, VAR_NUM, &key_echo, NULL },
|
||||
{ "bell_pos", BELL_POS, VAR_NUM, &bell_pos, NULL },
|
||||
{ "rate", RATE, VAR_NUM, NULL, NULL },
|
||||
{ "pitch", PITCH, VAR_NUM, NULL, NULL },
|
||||
{ "vol", VOL, VAR_NUM, NULL, NULL },
|
||||
{ "tone", TONE, VAR_NUM, NULL, NULL },
|
||||
{ "punct", PUNCT, VAR_NUM, NULL, NULL },
|
||||
{ "voice", VOICE, VAR_NUM, NULL, NULL },
|
||||
{ "freq", FREQUENCY, VAR_NUM, NULL, NULL },
|
||||
{ "lang", LANG, VAR_NUM, NULL, NULL },
|
||||
{ "chartab", CHARTAB, VAR_PROC, NULL, NULL },
|
||||
{ "direct", DIRECT, VAR_NUM, NULL, NULL },
|
||||
};
|
||||
|
||||
static struct st_var_header *var_ptrs[MAXVARS] = { 0, 0, 0 };
|
||||
|
||||
static struct punc_var_t punc_vars[] = {
|
||||
{ PUNC_SOME, 1 },
|
||||
{ PUNC_MOST, 2 },
|
||||
{ PUNC_ALL, 3 },
|
||||
{ DELIM, 4 },
|
||||
{ REPEATS, 5 },
|
||||
{ EXNUMBER, 6 },
|
||||
{ -1, -1 },
|
||||
};
|
||||
|
||||
int chartab_get_value(char *keyword)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
if (!strcmp(keyword, "ALPHA"))
|
||||
value = ALPHA;
|
||||
else if (!strcmp(keyword, "B_CTL"))
|
||||
value = B_CTL;
|
||||
else if (!strcmp(keyword, "WDLM"))
|
||||
value = WDLM;
|
||||
else if (!strcmp(keyword, "A_PUNC"))
|
||||
value = A_PUNC;
|
||||
else if (!strcmp(keyword, "PUNC"))
|
||||
value = PUNC;
|
||||
else if (!strcmp(keyword, "NUM"))
|
||||
value = NUM;
|
||||
else if (!strcmp(keyword, "A_CAP"))
|
||||
value = A_CAP;
|
||||
else if (!strcmp(keyword, "B_CAPSYM"))
|
||||
value = B_CAPSYM;
|
||||
else if (!strcmp(keyword, "B_SYM"))
|
||||
value = B_SYM;
|
||||
return value;
|
||||
}
|
||||
|
||||
void speakup_register_var(struct var_t *var)
|
||||
{
|
||||
static char nothing[2] = "\0";
|
||||
int i;
|
||||
struct st_var_header *p_header;
|
||||
|
||||
BUG_ON(!var || var->var_id < 0 || var->var_id >= MAXVARS);
|
||||
if (var_ptrs[0] == NULL) {
|
||||
for (i = 0; i < MAXVARS; i++) {
|
||||
p_header = &var_headers[i];
|
||||
var_ptrs[p_header->var_id] = p_header;
|
||||
p_header->data = NULL;
|
||||
}
|
||||
}
|
||||
p_header = var_ptrs[var->var_id];
|
||||
if (p_header->data != NULL)
|
||||
return;
|
||||
p_header->data = var;
|
||||
switch (p_header->var_type) {
|
||||
case VAR_STRING:
|
||||
set_string_var(nothing, p_header, 0);
|
||||
break;
|
||||
case VAR_NUM:
|
||||
case VAR_TIME:
|
||||
set_num_var(0, p_header, E_DEFAULT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void speakup_unregister_var(enum var_id_t var_id)
|
||||
{
|
||||
struct st_var_header *p_header;
|
||||
BUG_ON(var_id < 0 || var_id >= MAXVARS);
|
||||
p_header = var_ptrs[var_id];
|
||||
p_header->data = NULL;
|
||||
}
|
||||
|
||||
struct st_var_header *get_var_header(enum var_id_t var_id)
|
||||
{
|
||||
struct st_var_header *p_header;
|
||||
if (var_id < 0 || var_id >= MAXVARS)
|
||||
return NULL;
|
||||
p_header = var_ptrs[var_id];
|
||||
if (p_header->data == NULL)
|
||||
return NULL;
|
||||
return p_header;
|
||||
}
|
||||
|
||||
struct st_var_header *var_header_by_name(const char *name)
|
||||
{
|
||||
int i;
|
||||
struct st_var_header *where = NULL;
|
||||
|
||||
if (name != NULL) {
|
||||
i = 0;
|
||||
while ((i < MAXVARS) && (where == NULL)) {
|
||||
if (strcmp(name, var_ptrs[i]->name) == 0)
|
||||
where = var_ptrs[i];
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return where;
|
||||
}
|
||||
|
||||
struct var_t *get_var(enum var_id_t var_id)
|
||||
{
|
||||
BUG_ON(var_id < 0 || var_id >= MAXVARS);
|
||||
BUG_ON(! var_ptrs[var_id]);
|
||||
return (var_ptrs[var_id]->data);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(get_var);
|
||||
|
||||
struct punc_var_t *get_punc_var(enum var_id_t var_id)
|
||||
{
|
||||
struct punc_var_t *rv = NULL;
|
||||
struct punc_var_t *where;
|
||||
|
||||
where = punc_vars;
|
||||
while ((where->var_id != -1) && (rv == NULL)) {
|
||||
if (where->var_id == var_id)
|
||||
rv = where;
|
||||
else
|
||||
where++;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* handlers for setting vars */
|
||||
int set_num_var(int input, struct st_var_header *var, int how)
|
||||
{
|
||||
int val;
|
||||
short ret = 0;
|
||||
int *p_val = var->p_val;
|
||||
int l;
|
||||
char buf[32];
|
||||
char *cp;
|
||||
struct var_t *var_data = var->data;
|
||||
if (var_data == NULL)
|
||||
return E_UNDEF;
|
||||
|
||||
if (how == E_NEW_DEFAULT) {
|
||||
if (input < var_data->u.n.low || input > var_data->u.n.high)
|
||||
ret = E_RANGE;
|
||||
else
|
||||
var_data->u.n.default_val = input;
|
||||
return ret;
|
||||
}
|
||||
if (how == E_DEFAULT) {
|
||||
val = var_data->u.n.default_val;
|
||||
ret = SET_DEFAULT;
|
||||
} else {
|
||||
if (how == E_SET)
|
||||
val = input;
|
||||
else
|
||||
val = var_data->u.n.value;
|
||||
if (how == E_INC)
|
||||
val += input;
|
||||
else if (how == E_DEC)
|
||||
val -= input;
|
||||
if (val < var_data->u.n.low || val > var_data->u.n.high)
|
||||
return E_RANGE;
|
||||
}
|
||||
var_data->u.n.value = val;
|
||||
if (var->var_type == VAR_TIME && p_val != NULL) {
|
||||
*p_val = msecs_to_jiffies(val);
|
||||
return ret;
|
||||
}
|
||||
if (p_val != NULL)
|
||||
*p_val = val;
|
||||
if (var->var_id == PUNC_LEVEL) {
|
||||
punc_mask = punc_masks[val];
|
||||
return ret;
|
||||
}
|
||||
if (var_data->u.n.multiplier != 0)
|
||||
val *= var_data->u.n.multiplier;
|
||||
val += var_data->u.n.offset;
|
||||
if (var->var_id < FIRST_SYNTH_VAR || synth == NULL)
|
||||
return ret;
|
||||
if (synth->synth_adjust != NULL) {
|
||||
int status = synth->synth_adjust(var);
|
||||
return (status != 0) ? status : ret;
|
||||
}
|
||||
if (!var_data->u.n.synth_fmt)
|
||||
return ret;
|
||||
if (var->var_id == PITCH)
|
||||
cp = pitch_buff;
|
||||
else
|
||||
cp = buf;
|
||||
if (!var_data->u.n.out_str)
|
||||
l = sprintf(cp, var_data->u.n.synth_fmt, (int)val);
|
||||
else
|
||||
l = sprintf(cp, var_data->u.n.synth_fmt, var_data->u.n.out_str[val]);
|
||||
synth_printf("%s", cp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_string_var(const char *page, struct st_var_header *var, int len)
|
||||
{
|
||||
int ret = 0;
|
||||
struct var_t *var_data = var->data;
|
||||
if (var_data == NULL)
|
||||
return E_UNDEF;
|
||||
if (len > MAXVARLEN)
|
||||
return -E_TOOLONG;
|
||||
if (!len) {
|
||||
if (!var_data->u.s.default_val)
|
||||
return 0;
|
||||
ret = SET_DEFAULT;
|
||||
if (!var->p_val)
|
||||
var->p_val = var_data->u.s.default_val;
|
||||
if (var->p_val != var_data->u.s.default_val)
|
||||
strcpy((char *)var->p_val, var_data->u.s.default_val);
|
||||
} else if (var->p_val)
|
||||
strcpy((char *)var->p_val, page);
|
||||
else
|
||||
return -E_TOOLONG;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* set_mask_bits sets or clears the punc/delim/repeat bits,
|
||||
* if input is null uses the defaults.
|
||||
* values for how: 0 clears bits of chars supplied,
|
||||
* 1 clears allk, 2 sets bits for chars */
|
||||
int set_mask_bits(const char *input, const int which, const int how)
|
||||
{
|
||||
u_char *cp;
|
||||
short mask = punc_info[which].mask;
|
||||
if (how&1) {
|
||||
for (cp = (u_char *)punc_info[3].value; *cp; cp++)
|
||||
spk_chartab[*cp] &= ~mask;
|
||||
}
|
||||
cp = (u_char *)input;
|
||||
if (cp == 0)
|
||||
cp = punc_info[which].value;
|
||||
else {
|
||||
for ( ; *cp; cp++) {
|
||||
if (*cp < SPACE)
|
||||
break;
|
||||
if (mask < PUNC) {
|
||||
if (!(spk_chartab[*cp]&PUNC))
|
||||
break;
|
||||
} else if (spk_chartab[*cp]&B_NUM)
|
||||
break;
|
||||
}
|
||||
if (*cp)
|
||||
return -EINVAL;
|
||||
cp = (u_char *)input;
|
||||
}
|
||||
if (how&2) {
|
||||
for ( ; *cp; cp++)
|
||||
if (*cp > SPACE)
|
||||
spk_chartab[*cp] |= mask;
|
||||
} else {
|
||||
for ( ; *cp; cp++)
|
||||
if (*cp > SPACE)
|
||||
spk_chartab[*cp] &= ~mask;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *strlwr(char *s)
|
||||
{
|
||||
char *p;
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
for (p = s; *p; p++)
|
||||
*p = tolower(*p);
|
||||
return s;
|
||||
}
|
||||
|
||||
char *speakup_s2i(char *start, int *dest)
|
||||
{
|
||||
int val;
|
||||
char ch = *start;
|
||||
if (ch == '-' || ch == '+')
|
||||
start++;
|
||||
if (*start < '0' || *start > '9')
|
||||
return start;
|
||||
val = (*start) - '0';
|
||||
start++;
|
||||
while (*start >= '0' && *start <= '9') {
|
||||
val *= 10;
|
||||
val += (*start) - '0';
|
||||
start++;
|
||||
}
|
||||
if (ch == '-')
|
||||
*dest = -val;
|
||||
else
|
||||
*dest = val;
|
||||
return start;
|
||||
}
|
||||
|
||||
char *s2uchar(char *start, char *dest)
|
||||
{
|
||||
int val = 0;
|
||||
while (*start && *start <= SPACE)
|
||||
start++;
|
||||
while (*start >= '0' && *start <= '9') {
|
||||
val *= 10;
|
||||
val += (*start) - '0';
|
||||
start++;
|
||||
}
|
||||
if (*start == ',')
|
||||
start++;
|
||||
*dest = (u_char)val;
|
||||
return start;
|
||||
}
|
||||
|
||||
char *xlate(char *s)
|
||||
{
|
||||
static const char finds[] = "nrtvafe";
|
||||
static const char subs[] = "\n\r\t\013\001\014\033";
|
||||
static const char hx[] = "0123456789abcdefABCDEF";
|
||||
char *p = s, *p1, *p2, c;
|
||||
int num;
|
||||
while ((p = strchr(p, '\\'))) {
|
||||
p1 = p+1;
|
||||
p2 = strchr(finds, *p1);
|
||||
if (p2) {
|
||||
*p++ = subs[p2-finds];
|
||||
p1++;
|
||||
} else if (*p1 >= '0' && *p1 <= '7') {
|
||||
num = (*p1++)&7;
|
||||
while (num < 256 && *p1 >= '0' && *p1 <= '7') {
|
||||
num <<= 3;
|
||||
num = (*p1++)&7;
|
||||
}
|
||||
*p++ = num;
|
||||
} else if (*p1 == 'x' &&
|
||||
strchr(hx, p1[1]) && strchr(hx, p1[2])) {
|
||||
p1++;
|
||||
c = *p1++;
|
||||
if (c > '9')
|
||||
c = (c - '7') & 0x0f;
|
||||
else
|
||||
c -= '0';
|
||||
num = c << 4;
|
||||
c = *p1++;
|
||||
if (c > '9')
|
||||
c = (c-'7')&0x0f;
|
||||
else
|
||||
c -= '0';
|
||||
num += c;
|
||||
*p++ = num;
|
||||
} else
|
||||
*p++ = *p1++;
|
||||
p2 = p;
|
||||
while (*p1)
|
||||
*p2++ = *p1++;
|
||||
*p2 = '\0';
|
||||
}
|
||||
return s;
|
||||
}
|
Loading…
Reference in New Issue
Block a user