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