diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-03-04 15:01:55 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-09 17:28:20 +0100 |
commit | 89fc2ae80bb1eeca1d967723c1918c0b156508a0 (patch) | |
tree | c7024e665fd9ecb22c86cdf031b48516565ff019 /drivers/staging/speakup/buffers.c | |
parent | 981b7ae9ad9b3a9ccb83a7be6cfc57a05f61185f (diff) |
speakup: extend synth buffer to 16bit unicode characters
This extends the synth buffer slots to 16bit, so as to hold 16bit
unicode characters.
synth_buffer_getc and synth_buffer_peek now return 16bit characters.
Speech synthesizers which do not support characters beyond latin1 can
use the synth_buffer_skip_nonlatin1() helper to skip the non-latin1
characters before getting or peeking. All synthesizers are made to use
it for now.
This makes synth_buffer_add take a 16bit character. For simplicity for
now, synth_printf is left to using latin1 formats and strings.
synth_putwc, synth_putwc_s, synth_putws and synth_putws_s helpers are
however added to put 16bit characters and strings.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Chris Brannon <chris@the-brannons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/speakup/buffers.c')
-rw-r--r-- | drivers/staging/speakup/buffers.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c index 723d5df44221..f459e4004bfa 100644 --- a/drivers/staging/speakup/buffers.c +++ b/drivers/staging/speakup/buffers.c @@ -7,10 +7,10 @@ #define SYNTH_BUF_SIZE 8192 /* currently 8K bytes */ -static u_char synth_buffer[SYNTH_BUF_SIZE]; /* 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 + SYNTH_BUF_SIZE - 1; +static u16 synth_buffer[SYNTH_BUF_SIZE]; /* guess what this is for! */ +static u16 *buff_in = synth_buffer; +static u16 *buff_out = synth_buffer; +static u16 *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1; /* These try to throttle applications by stopping the TTYs * Note: we need to make sure that we will restart them eventually, which is @@ -44,13 +44,13 @@ static void speakup_stop_ttys(void) static int synth_buffer_free(void) { - int bytes_free; + int chars_free; if (buff_in >= buff_out) - bytes_free = SYNTH_BUF_SIZE - (buff_in - buff_out); + chars_free = SYNTH_BUF_SIZE - (buff_in - buff_out); else - bytes_free = buff_out - buff_in; - return bytes_free; + chars_free = buff_out - buff_in; + return chars_free; } int synth_buffer_empty(void) @@ -59,7 +59,7 @@ int synth_buffer_empty(void) } EXPORT_SYMBOL_GPL(synth_buffer_empty); -void synth_buffer_add(char ch) +void synth_buffer_add(u16 ch) { if (!synth->alive) { /* This makes sure that we won't stop TTYs if there is no synth @@ -78,9 +78,9 @@ void synth_buffer_add(char ch) buff_in = synth_buffer; } -char synth_buffer_getc(void) +u16 synth_buffer_getc(void) { - char ch; + u16 ch; if (buff_out == buff_in) return 0; @@ -91,7 +91,7 @@ char synth_buffer_getc(void) } EXPORT_SYMBOL_GPL(synth_buffer_getc); -char synth_buffer_peek(void) +u16 synth_buffer_peek(void) { if (buff_out == buff_in) return 0; @@ -99,6 +99,18 @@ char synth_buffer_peek(void) } EXPORT_SYMBOL_GPL(synth_buffer_peek); +void synth_buffer_skip_nonlatin1(void) +{ + while (buff_out != buff_in) { + if (*buff_out < 0x100) + return; + buff_out++; + if (buff_out > buffer_end) + buff_out = synth_buffer; + } +} +EXPORT_SYMBOL_GPL(synth_buffer_skip_nonlatin1); + void synth_buffer_clear(void) { buff_in = synth_buffer; |