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" |
| 31 | #define synth_full( ) ( !( inb( synth_port_tts + UART_MSR ) & UART_MSR_CTS ) ) |
| 32 | #define PROCSPEECH 0x0d |
| 33 | |
| 34 | static int synth_probe(struct spk_synth *synth); |
| 35 | |
| 36 | static struct var_t vars[] = { |
| 37 | { CAPS_START, .u.s = {"\x01+35p" }}, |
| 38 | { CAPS_STOP, .u.s = {"\x01-35p" }}, |
| 39 | { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL }}, |
| 40 | { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL }}, |
| 41 | { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL }}, |
| 42 | { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL }}, |
| 43 | { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL }}, |
| 44 | { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL }}, |
| 45 | { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL }}, |
| 46 | { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL }}, |
| 47 | V_LAST_VAR |
| 48 | }; |
| 49 | |
| 50 | /* |
| 51 | * These attributes will appear in /sys/accessibility/speakup/ltlk. |
| 52 | */ |
| 53 | static struct kobj_attribute caps_start_attribute = |
| 54 | __ATTR(caps_start, USER_RW, spk_var_show, spk_var_store); |
| 55 | static struct kobj_attribute caps_stop_attribute = |
| 56 | __ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store); |
| 57 | static struct kobj_attribute freq_attribute = |
| 58 | __ATTR(freq, USER_RW, spk_var_show, spk_var_store); |
| 59 | static struct kobj_attribute pitch_attribute = |
| 60 | __ATTR(pitch, USER_RW, spk_var_show, spk_var_store); |
| 61 | static struct kobj_attribute punct_attribute = |
| 62 | __ATTR(punct, USER_RW, spk_var_show, spk_var_store); |
| 63 | static struct kobj_attribute rate_attribute = |
| 64 | __ATTR(rate, USER_RW, spk_var_show, spk_var_store); |
| 65 | static struct kobj_attribute tone_attribute = |
| 66 | __ATTR(tone, USER_RW, spk_var_show, spk_var_store); |
| 67 | static struct kobj_attribute voice_attribute = |
| 68 | __ATTR(voice, USER_RW, spk_var_show, spk_var_store); |
| 69 | static struct kobj_attribute vol_attribute = |
| 70 | __ATTR(vol, USER_RW, spk_var_show, spk_var_store); |
| 71 | |
| 72 | static struct kobj_attribute delay_time_attribute = |
| 73 | __ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store); |
| 74 | static struct kobj_attribute direct_attribute = |
| 75 | __ATTR(direct, USER_RW, spk_var_show, spk_var_store); |
| 76 | static struct kobj_attribute full_time_attribute = |
| 77 | __ATTR(full_time, ROOT_W, spk_var_show, spk_var_store); |
| 78 | static struct kobj_attribute jiffy_delta_attribute = |
| 79 | __ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store); |
| 80 | static struct kobj_attribute trigger_time_attribute = |
| 81 | __ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store); |
| 82 | |
| 83 | /* |
| 84 | * Create a group of attributes so that we can create and destroy them all |
| 85 | * at once. |
| 86 | */ |
| 87 | static struct attribute *synth_attrs[] = { |
| 88 | &caps_start_attribute.attr, |
| 89 | &caps_stop_attribute.attr, |
| 90 | &freq_attribute.attr, |
| 91 | &pitch_attribute.attr, |
| 92 | &punct_attribute.attr, |
| 93 | &rate_attribute.attr, |
| 94 | &tone_attribute.attr, |
| 95 | &voice_attribute.attr, |
| 96 | &vol_attribute.attr, |
| 97 | &delay_time_attribute.attr, |
| 98 | &direct_attribute.attr, |
| 99 | &full_time_attribute.attr, |
| 100 | &jiffy_delta_attribute.attr, |
| 101 | &trigger_time_attribute.attr, |
| 102 | NULL, /* need to NULL terminate the list of attributes */ |
| 103 | }; |
| 104 | |
| 105 | static struct spk_synth synth_ltlk = { |
| 106 | .name = "ltlk", |
| 107 | .version = DRV_VERSION, |
| 108 | .long_name = "LiteTalk", |
| 109 | .init = "\01@\x01\x31y\n\0", |
| 110 | .procspeech = PROCSPEECH, |
| 111 | .clear = SYNTH_CLEAR, |
| 112 | .delay = 500, |
| 113 | .trigger = 50, |
| 114 | .jiffies = 50, |
| 115 | .full = 40000, |
| 116 | .startup = SYNTH_START, |
| 117 | .checkval = SYNTH_CHECK, |
| 118 | .vars = vars, |
| 119 | .probe = synth_probe, |
| 120 | .release = spk_serial_release, |
| 121 | .synth_immediate = spk_synth_immediate, |
| 122 | .catch_up = spk_do_catch_up, |
| 123 | .flush = spk_synth_flush, |
| 124 | .is_alive = spk_synth_is_alive_restart, |
| 125 | .synth_adjust = NULL, |
| 126 | .read_buff_add = NULL, |
| 127 | .get_index = spk_serial_in_nowait, |
| 128 | .indexing = { |
| 129 | .command = "\x01%di", |
| 130 | .lowindex = 1, |
| 131 | .highindex = 5, |
| 132 | .currindex = 1, |
| 133 | }, |
| 134 | .attributes = { |
| 135 | .attrs = synth_attrs, |
| 136 | .name = "ltlk", |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | /* interrogate the LiteTalk and print its settings */ |
| 141 | static void synth_interrogate(struct spk_synth *synth) |
| 142 | { |
| 143 | unsigned char *t, i; |
| 144 | unsigned char buf[50], rom_v[20]; |
| 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 | |
| 165 | failed = serial_synth_probe(synth); |
| 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 | |