Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/accessibility/speakup/speakup_ltlk.c
26282 views
1
// SPDX-License-Identifier: GPL-2.0+
2
/*
3
* originally written by: Kirk Reiser <[email protected]>
4
* this version considerably modified by David Borowski, [email protected]
5
*
6
* Copyright (C) 1998-99 Kirk Reiser.
7
* Copyright (C) 2003 David Borowski.
8
*
9
* specifically written as a driver for the speakup screenreview
10
* s not a general device driver.
11
*/
12
#include "speakup.h"
13
#include "spk_priv.h"
14
#include "speakup_dtlk.h" /* local header file for LiteTalk values */
15
16
#define DRV_VERSION "2.11"
17
#define PROCSPEECH 0x0d
18
19
static int synth_probe(struct spk_synth *synth);
20
21
22
enum default_vars_id {
23
CAPS_START_ID = 0, CAPS_STOP_ID,
24
RATE_ID, PITCH_ID,
25
VOL_ID, TONE_ID, PUNCT_ID,
26
VOICE_ID, FREQUENCY_ID,
27
DIRECT_ID, V_LAST_VAR_ID,
28
NB_ID
29
};
30
31
32
static struct var_t vars[NB_ID] = {
33
[CAPS_START_ID] = { CAPS_START, .u.s = {"\x01+35p" } },
34
[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x01-35p" } },
35
[RATE_ID] = { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },
36
[PITCH_ID] = { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },
37
[VOL_ID] = { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
38
[TONE_ID] = { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
39
[PUNCT_ID] = { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },
40
[VOICE_ID] = { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
41
[FREQUENCY_ID] = { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
42
[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
43
V_LAST_VAR
44
};
45
46
/*
47
* These attributes will appear in /sys/accessibility/speakup/ltlk.
48
*/
49
static struct kobj_attribute caps_start_attribute =
50
__ATTR(caps_start, 0644, spk_var_show, spk_var_store);
51
static struct kobj_attribute caps_stop_attribute =
52
__ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
53
static struct kobj_attribute freq_attribute =
54
__ATTR(freq, 0644, spk_var_show, spk_var_store);
55
static struct kobj_attribute pitch_attribute =
56
__ATTR(pitch, 0644, spk_var_show, spk_var_store);
57
static struct kobj_attribute punct_attribute =
58
__ATTR(punct, 0644, spk_var_show, spk_var_store);
59
static struct kobj_attribute rate_attribute =
60
__ATTR(rate, 0644, spk_var_show, spk_var_store);
61
static struct kobj_attribute tone_attribute =
62
__ATTR(tone, 0644, spk_var_show, spk_var_store);
63
static struct kobj_attribute voice_attribute =
64
__ATTR(voice, 0644, spk_var_show, spk_var_store);
65
static struct kobj_attribute vol_attribute =
66
__ATTR(vol, 0644, spk_var_show, spk_var_store);
67
68
static struct kobj_attribute delay_time_attribute =
69
__ATTR(delay_time, 0644, spk_var_show, spk_var_store);
70
static struct kobj_attribute direct_attribute =
71
__ATTR(direct, 0644, spk_var_show, spk_var_store);
72
static struct kobj_attribute full_time_attribute =
73
__ATTR(full_time, 0644, spk_var_show, spk_var_store);
74
static struct kobj_attribute jiffy_delta_attribute =
75
__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
76
static struct kobj_attribute trigger_time_attribute =
77
__ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
78
79
/*
80
* Create a group of attributes so that we can create and destroy them all
81
* at once.
82
*/
83
static struct attribute *synth_attrs[] = {
84
&caps_start_attribute.attr,
85
&caps_stop_attribute.attr,
86
&freq_attribute.attr,
87
&pitch_attribute.attr,
88
&punct_attribute.attr,
89
&rate_attribute.attr,
90
&tone_attribute.attr,
91
&voice_attribute.attr,
92
&vol_attribute.attr,
93
&delay_time_attribute.attr,
94
&direct_attribute.attr,
95
&full_time_attribute.attr,
96
&jiffy_delta_attribute.attr,
97
&trigger_time_attribute.attr,
98
NULL, /* need to NULL terminate the list of attributes */
99
};
100
101
static struct spk_synth synth_ltlk = {
102
.name = "ltlk",
103
.version = DRV_VERSION,
104
.long_name = "LiteTalk",
105
.init = "\01@\x01\x31y\n\0",
106
.procspeech = PROCSPEECH,
107
.clear = SYNTH_CLEAR,
108
.delay = 500,
109
.trigger = 50,
110
.jiffies = 50,
111
.full = 40000,
112
.dev_name = SYNTH_DEFAULT_DEV,
113
.startup = SYNTH_START,
114
.checkval = SYNTH_CHECK,
115
.vars = vars,
116
.io_ops = &spk_ttyio_ops,
117
.probe = synth_probe,
118
.release = spk_ttyio_release,
119
.synth_immediate = spk_ttyio_synth_immediate,
120
.catch_up = spk_do_catch_up,
121
.flush = spk_synth_flush,
122
.is_alive = spk_synth_is_alive_restart,
123
.synth_adjust = NULL,
124
.read_buff_add = NULL,
125
.get_index = spk_synth_get_index,
126
.indexing = {
127
.command = "\x01%di",
128
.lowindex = 1,
129
.highindex = 5,
130
.currindex = 1,
131
},
132
.attributes = {
133
.attrs = synth_attrs,
134
.name = "ltlk",
135
},
136
};
137
138
/* interrogate the LiteTalk and print its settings */
139
static void synth_interrogate(struct spk_synth *synth)
140
{
141
unsigned char *t, i;
142
unsigned char buf[50], rom_v[20];
143
144
synth->synth_immediate(synth, "\x18\x01?");
145
for (i = 0; i < 50; i++) {
146
buf[i] = synth->io_ops->synth_in(synth);
147
if (i > 2 && buf[i] == 0x7f)
148
break;
149
}
150
t = buf + 2;
151
for (i = 0; *t != '\r'; t++) {
152
rom_v[i] = *t;
153
if (++i >= 19)
154
break;
155
}
156
rom_v[i] = 0;
157
pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
158
}
159
160
static int synth_probe(struct spk_synth *synth)
161
{
162
int failed = 0;
163
164
failed = spk_ttyio_synth_probe(synth);
165
if (failed == 0)
166
synth_interrogate(synth);
167
synth->alive = !failed;
168
return failed;
169
}
170
171
module_param_named(ser, synth_ltlk.ser, int, 0444);
172
module_param_named(dev, synth_ltlk.dev_name, charp, 0444);
173
module_param_named(start, synth_ltlk.startup, short, 0444);
174
module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);
175
module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);
176
module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);
177
module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);
178
module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);
179
module_param_named(voice, vars[VOICE_ID].u.n.default_val, int, 0444);
180
module_param_named(frequency, vars[FREQUENCY_ID].u.n.default_val, int, 0444);
181
module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);
182
183
184
185
186
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
187
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
188
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
189
MODULE_PARM_DESC(rate, "Set the rate variable on load.");
190
MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");
191
MODULE_PARM_DESC(vol, "Set the vol variable on load.");
192
MODULE_PARM_DESC(tone, "Set the tone variable on load.");
193
MODULE_PARM_DESC(punct, "Set the punct variable on load.");
194
MODULE_PARM_DESC(voice, "Set the voice variable on load.");
195
MODULE_PARM_DESC(frequency, "Set the frequency variable on load.");
196
MODULE_PARM_DESC(direct, "Set the direct variable on load.");
197
198
199
module_spk_synth(synth_ltlk);
200
201
MODULE_AUTHOR("Kirk Reiser <[email protected]>");
202
MODULE_AUTHOR("David Borowski");
203
MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
204
MODULE_LICENSE("GPL");
205
MODULE_VERSION(DRV_VERSION);
206
207
208