Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
speakup_audptr.c
Go to the documentation of this file.
1 /*
2  * originally written by: Kirk Reiser <[email protected]>
3  * this version considerably modified by David Borowski, [email protected]
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  * 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
21  *
22  * specificly written as a driver for the speakup screenreview
23  * s not a general device driver.
24  */
25 #include "spk_priv.h"
26 #include "speakup.h"
27 #include "serialio.h"
28 
29 #define DRV_VERSION "2.11"
30 #define SYNTH_CLEAR 0x18 /* flush synth buffer */
31 #define PROCSPEECH '\r' /* start synth processing speech char */
32 
33 static int synth_probe(struct spk_synth *synth);
34 static void synth_flush(struct spk_synth *synth);
35 
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 } },
46 };
47 
48 /*
49  * These attributes will appear in /sys/accessibility/speakup/audptr.
50  */
51 static struct kobj_attribute caps_start_attribute =
53 static struct kobj_attribute caps_stop_attribute =
55 static struct kobj_attribute pitch_attribute =
57 static struct kobj_attribute punct_attribute =
59 static struct kobj_attribute rate_attribute =
61 static struct kobj_attribute tone_attribute =
63 static struct kobj_attribute vol_attribute =
65 
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 =
70 static struct kobj_attribute full_time_attribute =
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);
76 
77 /*
78  * Create a group of attributes so that we can create and destroy them all
79  * at once.
80  */
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 */
95 };
96 
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,
125  },
126  .attributes = {
127  .attrs = synth_attrs,
128  .name = "audptr",
129  },
130 };
131 
132 static void synth_flush(struct spk_synth *synth)
133 {
135  while (spk_serial_tx_busy()) {
136  if (!--timeout)
137  break;
138  udelay(1);
139  }
140  outb(SYNTH_CLEAR, speakup_info.port_tts);
142 }
143 
144 static void synth_version(struct spk_synth *synth)
145 {
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;
156  }
157  if (synth_id[0] == 'A')
158  pr_info("%s version: %s", synth->long_name, synth_id);
159 }
160 
161 static int synth_probe(struct spk_synth *synth)
162 {
163  int failed = 0;
164 
165  failed = serial_synth_probe(synth);
166  if (failed == 0)
167  synth_version(synth);
168  synth->alive = !failed;
169  return 0;
170 }
171 
172 module_param_named(ser, synth_audptr.ser, int, S_IRUGO);
173 module_param_named(start, synth_audptr.startup, short, S_IRUGO);
174 
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.");
177 
178 static int __init audptr_init(void)
179 {
180  return synth_add(&synth_audptr);
181 }
182 
183 static void __exit audptr_exit(void)
184 {
185  synth_remove(&synth_audptr);
186 }
187 
188 module_init(audptr_init);
189 module_exit(audptr_exit);
190 MODULE_AUTHOR("Kirk Reiser <[email protected]>");
191 MODULE_AUTHOR("David Borowski");
192 MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
193 MODULE_LICENSE("GPL");
195