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