William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1 | /* |
| 2 | * originally written by: Kirk Reiser <kirk@braille.uwo.ca> |
| 3 | * this version considerably modified by David Borowski, david575@rogers.com |
| 4 | * |
| 5 | * Copyright (C) 1998-99 Kirk Reiser. |
| 6 | * Copyright (C) 2003 David Borowski. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | * specificly written as a driver for the speakup screenreview |
| 23 | * s not a general device driver. |
| 24 | */ |
| 25 | #include "speakup.h" |
| 26 | #include "spk_priv.h" |
| 27 | #include "serialio.h" |
| 28 | #include "speakup_dtlk.h" /* local header file for LiteTalk values */ |
| 29 | |
| 30 | #define DRV_VERSION "2.11" |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 31 | #define PROCSPEECH 0x0d |
| 32 | |
| 33 | static int synth_probe(struct spk_synth *synth); |
| 34 | |
| 35 | static struct var_t vars[] = { |
Christopher Brannon | e66c3d8 | 2010-10-14 19:23:56 -0500 | [diff] [blame] | 36 | { CAPS_START, .u.s = {"\x01+35p" } }, |
| 37 | { CAPS_STOP, .u.s = {"\x01-35p" } }, |
| 38 | { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } }, |
| 39 | { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } }, |
| 40 | { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, |
| 41 | { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, |
| 42 | { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } }, |
| 43 | { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, |
| 44 | { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, |
| 45 | { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 46 | V_LAST_VAR |
| 47 | }; |
| 48 | |
| 49 | /* |
| 50 | * These attributes will appear in /sys/accessibility/speakup/ltlk. |
| 51 | */ |
| 52 | static struct kobj_attribute caps_start_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 53 | __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 54 | static struct kobj_attribute caps_stop_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 55 | __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 56 | static struct kobj_attribute freq_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 57 | __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 58 | static struct kobj_attribute pitch_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 59 | __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 60 | static struct kobj_attribute punct_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 61 | __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 62 | static struct kobj_attribute rate_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 63 | __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 64 | static struct kobj_attribute tone_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 65 | __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 66 | static struct kobj_attribute voice_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 67 | __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 68 | static struct kobj_attribute vol_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 69 | __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 70 | |
| 71 | static struct kobj_attribute delay_time_attribute = |
Rusty Russell | 22c9bca | 2014-04-01 13:30:05 +1030 | [diff] [blame] | 72 | __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 73 | static struct kobj_attribute direct_attribute = |
Rusty Russell | d901aaa | 2014-04-24 13:57:49 +0930 | [diff] [blame] | 74 | __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 75 | static struct kobj_attribute full_time_attribute = |
Rusty Russell | 22c9bca | 2014-04-01 13:30:05 +1030 | [diff] [blame] | 76 | __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 77 | static struct kobj_attribute jiffy_delta_attribute = |
Rusty Russell | 22c9bca | 2014-04-01 13:30:05 +1030 | [diff] [blame] | 78 | __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 79 | static struct kobj_attribute trigger_time_attribute = |
Rusty Russell | 22c9bca | 2014-04-01 13:30:05 +1030 | [diff] [blame] | 80 | __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * Create a group of attributes so that we can create and destroy them all |
| 84 | * at once. |
| 85 | */ |
| 86 | static struct attribute *synth_attrs[] = { |
| 87 | &caps_start_attribute.attr, |
| 88 | &caps_stop_attribute.attr, |
| 89 | &freq_attribute.attr, |
| 90 | &pitch_attribute.attr, |
| 91 | &punct_attribute.attr, |
| 92 | &rate_attribute.attr, |
| 93 | &tone_attribute.attr, |
| 94 | &voice_attribute.attr, |
| 95 | &vol_attribute.attr, |
| 96 | &delay_time_attribute.attr, |
| 97 | &direct_attribute.attr, |
| 98 | &full_time_attribute.attr, |
| 99 | &jiffy_delta_attribute.attr, |
| 100 | &trigger_time_attribute.attr, |
| 101 | NULL, /* need to NULL terminate the list of attributes */ |
| 102 | }; |
| 103 | |
| 104 | static struct spk_synth synth_ltlk = { |
| 105 | .name = "ltlk", |
| 106 | .version = DRV_VERSION, |
| 107 | .long_name = "LiteTalk", |
| 108 | .init = "\01@\x01\x31y\n\0", |
| 109 | .procspeech = PROCSPEECH, |
| 110 | .clear = SYNTH_CLEAR, |
| 111 | .delay = 500, |
| 112 | .trigger = 50, |
| 113 | .jiffies = 50, |
| 114 | .full = 40000, |
| 115 | .startup = SYNTH_START, |
| 116 | .checkval = SYNTH_CHECK, |
| 117 | .vars = vars, |
| 118 | .probe = synth_probe, |
| 119 | .release = spk_serial_release, |
| 120 | .synth_immediate = spk_synth_immediate, |
| 121 | .catch_up = spk_do_catch_up, |
| 122 | .flush = spk_synth_flush, |
| 123 | .is_alive = spk_synth_is_alive_restart, |
| 124 | .synth_adjust = NULL, |
| 125 | .read_buff_add = NULL, |
| 126 | .get_index = spk_serial_in_nowait, |
| 127 | .indexing = { |
| 128 | .command = "\x01%di", |
| 129 | .lowindex = 1, |
| 130 | .highindex = 5, |
| 131 | .currindex = 1, |
| 132 | }, |
| 133 | .attributes = { |
| 134 | .attrs = synth_attrs, |
| 135 | .name = "ltlk", |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | /* interrogate the LiteTalk and print its settings */ |
| 140 | static void synth_interrogate(struct spk_synth *synth) |
| 141 | { |
| 142 | unsigned char *t, i; |
| 143 | unsigned char buf[50], rom_v[20]; |
Domagoj Trsan | 8e69a81 | 2014-09-09 20:04:34 +0200 | [diff] [blame] | 144 | |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 145 | spk_synth_immediate(synth, "\x18\x01?"); |
| 146 | for (i = 0; i < 50; i++) { |
| 147 | buf[i] = spk_serial_in(); |
| 148 | if (i > 2 && buf[i] == 0x7f) |
| 149 | break; |
| 150 | } |
| 151 | t = buf+2; |
| 152 | for (i = 0; *t != '\r'; t++) { |
| 153 | rom_v[i] = *t; |
| 154 | if (++i >= 19) |
| 155 | break; |
| 156 | } |
| 157 | rom_v[i] = 0; |
| 158 | pr_info("%s: ROM version: %s\n", synth->long_name, rom_v); |
| 159 | } |
| 160 | |
| 161 | static int synth_probe(struct spk_synth *synth) |
| 162 | { |
| 163 | int failed = 0; |
| 164 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 165 | failed = spk_serial_synth_probe(synth); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 166 | if (failed == 0) |
| 167 | synth_interrogate(synth); |
| 168 | synth->alive = !failed; |
| 169 | return failed; |
| 170 | } |
| 171 | |
| 172 | module_param_named(ser, synth_ltlk.ser, int, S_IRUGO); |
| 173 | module_param_named(start, synth_ltlk.startup, short, S_IRUGO); |
| 174 | |
| 175 | MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); |
| 176 | MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); |
| 177 | |
| 178 | static int __init ltlk_init(void) |
| 179 | { |
| 180 | return synth_add(&synth_ltlk); |
| 181 | } |
| 182 | |
| 183 | static void __exit ltlk_exit(void) |
| 184 | { |
| 185 | synth_remove(&synth_ltlk); |
| 186 | } |
| 187 | |
| 188 | module_init(ltlk_init); |
| 189 | module_exit(ltlk_exit); |
| 190 | MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>"); |
| 191 | MODULE_AUTHOR("David Borowski"); |
| 192 | MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers"); |
| 193 | MODULE_LICENSE("GPL"); |
| 194 | MODULE_VERSION(DRV_VERSION); |
| 195 | |