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