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 * specificly written as a driver for the speakup screenreview
19 * s not a general device driver.
20 */
21 #include "speakup.h"
22 #include "spk_priv.h"
23 #include "serialio.h"
24 #include "speakup_dtlk.h" /* local header file for LiteTalk values */
25
26 #define DRV_VERSION "2.11"
27 #define PROCSPEECH 0x0d
28
29 static int synth_probe(struct spk_synth *synth);
30
31 static struct var_t vars[] = {
32 { CAPS_START, .u.s = {"\x01+35p" } },
33 { CAPS_STOP, .u.s = {"\x01-35p" } },
34 { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },
35 { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },
36 { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
37 { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
38 { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },
39 { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
40 { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
41 { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
42 V_LAST_VAR
43 };
44
45 /*
46 * These attributes will appear in /sys/accessibility/speakup/ltlk.
47 */
48 static struct kobj_attribute caps_start_attribute =
49 __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
50 static struct kobj_attribute caps_stop_attribute =
51 __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
52 static struct kobj_attribute freq_attribute =
53 __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
54 static struct kobj_attribute pitch_attribute =
55 __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
56 static struct kobj_attribute punct_attribute =
57 __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
58 static struct kobj_attribute rate_attribute =
59 __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
60 static struct kobj_attribute tone_attribute =
61 __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
62 static struct kobj_attribute voice_attribute =
63 __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
64 static struct kobj_attribute vol_attribute =
65 __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
66
67 static struct kobj_attribute delay_time_attribute =
68 __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
69 static struct kobj_attribute direct_attribute =
70 __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
71 static struct kobj_attribute full_time_attribute =
72 __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
73 static struct kobj_attribute jiffy_delta_attribute =
74 __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
75 static struct kobj_attribute trigger_time_attribute =
76 __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
77
78 /*
79 * Create a group of attributes so that we can create and destroy them all
80 * at once.
81 */
82 static struct attribute *synth_attrs[] = {
83 &caps_start_attribute.attr,
84 &caps_stop_attribute.attr,
85 &freq_attribute.attr,
86 &pitch_attribute.attr,
87 &punct_attribute.attr,
88 &rate_attribute.attr,
89 &tone_attribute.attr,
90 &voice_attribute.attr,
91 &vol_attribute.attr,
92 &delay_time_attribute.attr,
93 &direct_attribute.attr,
94 &full_time_attribute.attr,
95 &jiffy_delta_attribute.attr,
96 &trigger_time_attribute.attr,
97 NULL, /* need to NULL terminate the list of attributes */
98 };
99
100 static struct spk_synth synth_ltlk = {
101 .name = "ltlk",
102 .version = DRV_VERSION,
103 .long_name = "LiteTalk",
104 .init = "\01@\x01\x31y\n\0",
105 .procspeech = PROCSPEECH,
106 .clear = SYNTH_CLEAR,
107 .delay = 500,
108 .trigger = 50,
109 .jiffies = 50,
110 .full = 40000,
111 .startup = SYNTH_START,
112 .checkval = SYNTH_CHECK,
113 .vars = vars,
114 .probe = synth_probe,
115 .release = spk_serial_release,
116 .synth_immediate = spk_synth_immediate,
117 .catch_up = spk_do_catch_up,
118 .flush = spk_synth_flush,
119 .is_alive = spk_synth_is_alive_restart,
120 .synth_adjust = NULL,
121 .read_buff_add = NULL,
122 .get_index = spk_serial_in_nowait,
123 .indexing = {
124 .command = "\x01%di",
125 .lowindex = 1,
126 .highindex = 5,
127 .currindex = 1,
128 },
129 .attributes = {
130 .attrs = synth_attrs,
131 .name = "ltlk",
132 },
133 };
134
135 /* interrogate the LiteTalk and print its settings */
synth_interrogate(struct spk_synth * synth)136 static void synth_interrogate(struct spk_synth *synth)
137 {
138 unsigned char *t, i;
139 unsigned char buf[50], rom_v[20];
140
141 spk_synth_immediate(synth, "\x18\x01?");
142 for (i = 0; i < 50; i++) {
143 buf[i] = spk_serial_in();
144 if (i > 2 && buf[i] == 0x7f)
145 break;
146 }
147 t = buf+2;
148 for (i = 0; *t != '\r'; t++) {
149 rom_v[i] = *t;
150 if (++i >= 19)
151 break;
152 }
153 rom_v[i] = 0;
154 pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
155 }
156
synth_probe(struct spk_synth * synth)157 static int synth_probe(struct spk_synth *synth)
158 {
159 int failed = 0;
160
161 failed = spk_serial_synth_probe(synth);
162 if (failed == 0)
163 synth_interrogate(synth);
164 synth->alive = !failed;
165 return failed;
166 }
167
168 module_param_named(ser, synth_ltlk.ser, int, S_IRUGO);
169 module_param_named(start, synth_ltlk.startup, short, S_IRUGO);
170
171 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
172 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
173
174 module_spk_synth(synth_ltlk);
175
176 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
177 MODULE_AUTHOR("David Borowski");
178 MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
179 MODULE_LICENSE("GPL");
180 MODULE_VERSION(DRV_VERSION);
181
182