diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-03-10 11:56:27 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-14 12:57:45 +0100 |
commit | 65fa72d34360c571b058afeb0e64367d3eaf064b (patch) | |
tree | 6630e1337bb45da67d5398f52440c6cf84828fab /drivers/staging/speakup/spk_ttyio.c | |
parent | staging: comedi: adl_pci6208: remove redundant initialization of 'val' (diff) | |
download | linux-dev-65fa72d34360c571b058afeb0e64367d3eaf064b.tar.xz linux-dev-65fa72d34360c571b058afeb0e64367d3eaf064b.zip |
staging: speakup: Add unicode support to the speakup_dummy driver
This extends spk_io_ops with a synth_out_unicode which takes a u16 character
instead of just a byte, and extends spk_ttyio to implement it to emit
utf-8. spk_do_catch_up_unicode can then be introduced to benefit from
synth_out_unicode, and speakup_dummy made to use spk_do_catch_up_unicode instead
of spk_do_catch_up.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/speakup/spk_ttyio.c')
-rw-r--r-- | drivers/staging/speakup/spk_ttyio.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 311940205bee..ade03b03bcd3 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -110,6 +110,7 @@ static struct tty_ldisc_ops spk_ttyio_ldisc_ops = { }; static int spk_ttyio_out(struct spk_synth *in_synth, const char ch); +static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch); static void spk_ttyio_send_xchar(char ch); static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear); static unsigned char spk_ttyio_in(void); @@ -118,6 +119,7 @@ static void spk_ttyio_flush_buffer(void); struct spk_io_ops spk_ttyio_ops = { .synth_out = spk_ttyio_out, + .synth_out_unicode = spk_ttyio_out_unicode, .send_xchar = spk_ttyio_send_xchar, .tiocmset = spk_ttyio_tiocmset, .synth_in = spk_ttyio_in, @@ -221,6 +223,22 @@ static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) return 0; } +static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch) +{ + int ret; + if (ch < 0x80) + ret = spk_ttyio_out(in_synth, ch); + else if (ch < 0x800) { + ret = spk_ttyio_out(in_synth, 0xc0 | (ch >> 6)); + ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); + } else { + ret = spk_ttyio_out(in_synth, 0xe0 | (ch >> 12)); + ret &= spk_ttyio_out(in_synth, 0x80 | ((ch >> 6) & 0x3f)); + ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); + } + return ret; +} + static int check_tty(struct tty_struct *tty) { if (!tty) { |