Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / drivers / staging / speakup / speakup_audptr.c
blob94e509992c8b3e9e8bdd76fb7896e7f48afe9149
1 /*
2 * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
3 * this version considerably modified by David Borowski, david575@rogers.com
5 * Copyright (C) 1998-99 Kirk Reiser.
6 * Copyright (C) 2003 David Borowski.
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * specificly written as a driver for the speakup screenreview
23 * s not a general device driver.
25 #include "spk_priv.h"
26 #include "speakup.h"
27 #include "serialio.h"
29 #define DRV_VERSION "2.11"
30 #define SYNTH_CLEAR 0x18 /* flush synth buffer */
31 #define PROCSPEECH '\r' /* start synth processing speech char */
33 static int synth_probe(struct spk_synth *synth);
34 static void synth_flush(struct spk_synth *synth);
36 static struct var_t vars[] = {
37 { CAPS_START, .u.s = {"\x05[f99]" } },
38 { CAPS_STOP, .u.s = {"\x05[f80]" } },
39 { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } },
40 { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } },
41 { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } },
42 { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, 0 } },
43 { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } },
44 { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
45 V_LAST_VAR
49 * These attributes will appear in /sys/accessibility/speakup/audptr.
51 static struct kobj_attribute caps_start_attribute =
52 __ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
53 static struct kobj_attribute caps_stop_attribute =
54 __ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
55 static struct kobj_attribute pitch_attribute =
56 __ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
57 static struct kobj_attribute punct_attribute =
58 __ATTR(punct, USER_RW, spk_var_show, spk_var_store);
59 static struct kobj_attribute rate_attribute =
60 __ATTR(rate, USER_RW, spk_var_show, spk_var_store);
61 static struct kobj_attribute tone_attribute =
62 __ATTR(tone, USER_RW, spk_var_show, spk_var_store);
63 static struct kobj_attribute vol_attribute =
64 __ATTR(vol, USER_RW, spk_var_show, spk_var_store);
66 static struct kobj_attribute delay_time_attribute =
67 __ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
68 static struct kobj_attribute direct_attribute =
69 __ATTR(direct, USER_RW, spk_var_show, spk_var_store);
70 static struct kobj_attribute full_time_attribute =
71 __ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
72 static struct kobj_attribute jiffy_delta_attribute =
73 __ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
74 static struct kobj_attribute trigger_time_attribute =
75 __ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
78 * Create a group of attributes so that we can create and destroy them all
79 * at once.
81 static struct attribute *synth_attrs[] = {
82 &caps_start_attribute.attr,
83 &caps_stop_attribute.attr,
84 &pitch_attribute.attr,
85 &punct_attribute.attr,
86 &rate_attribute.attr,
87 &tone_attribute.attr,
88 &vol_attribute.attr,
89 &delay_time_attribute.attr,
90 &direct_attribute.attr,
91 &full_time_attribute.attr,
92 &jiffy_delta_attribute.attr,
93 &trigger_time_attribute.attr,
94 NULL, /* need to NULL terminate the list of attributes */
97 static struct spk_synth synth_audptr = {
98 .name = "audptr",
99 .version = DRV_VERSION,
100 .long_name = "Audapter",
101 .init = "\x05[D1]\x05[Ol]",
102 .procspeech = PROCSPEECH,
103 .clear = SYNTH_CLEAR,
104 .delay = 400,
105 .trigger = 50,
106 .jiffies = 30,
107 .full = 18000,
108 .startup = SYNTH_START,
109 .checkval = SYNTH_CHECK,
110 .vars = vars,
111 .probe = synth_probe,
112 .release = spk_serial_release,
113 .synth_immediate = spk_synth_immediate,
114 .catch_up = spk_do_catch_up,
115 .flush = synth_flush,
116 .is_alive = spk_synth_is_alive_restart,
117 .synth_adjust = NULL,
118 .read_buff_add = NULL,
119 .get_index = NULL,
120 .indexing = {
121 .command = NULL,
122 .lowindex = 0,
123 .highindex = 0,
124 .currindex = 0,
126 .attributes = {
127 .attrs = synth_attrs,
128 .name = "audptr",
132 static void synth_flush(struct spk_synth *synth)
134 int timeout = SPK_XMITR_TIMEOUT;
135 while (spk_serial_tx_busy()) {
136 if (!--timeout)
137 break;
138 udelay(1);
140 outb(SYNTH_CLEAR, speakup_info.port_tts);
141 spk_serial_out(PROCSPEECH);
144 static void synth_version(struct spk_synth *synth)
146 unsigned char test = 0;
147 char synth_id[40] = "";
148 spk_synth_immediate(synth, "\x05[Q]");
149 synth_id[test] = spk_serial_in();
150 if (synth_id[test] == 'A') {
151 do {
152 /* read version string from synth */
153 synth_id[++test] = spk_serial_in();
154 } while (synth_id[test] != '\n' && test < 32);
155 synth_id[++test] = 0x00;
157 if (synth_id[0] == 'A')
158 pr_info("%s version: %s", synth->long_name, synth_id);
161 static int synth_probe(struct spk_synth *synth)
163 int failed = 0;
165 failed = serial_synth_probe(synth);
166 if (failed == 0)
167 synth_version(synth);
168 synth->alive = !failed;
169 return 0;
172 module_param_named(ser, synth_audptr.ser, int, S_IRUGO);
173 module_param_named(start, synth_audptr.startup, short, S_IRUGO);
175 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
176 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
178 static int __init audptr_init(void)
180 return synth_add(&synth_audptr);
183 static void __exit audptr_exit(void)
185 synth_remove(&synth_audptr);
188 module_init(audptr_init);
189 module_exit(audptr_exit);
190 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
191 MODULE_AUTHOR("David Borowski");
192 MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
193 MODULE_LICENSE("GPL");
194 MODULE_VERSION(DRV_VERSION);