x86/PCI: use host bridge _CRS info on ASUS M2V-MX SE
[linux-btrfs-devel.git] / drivers / staging / speakup / speakup_apollo.c
blob00d5cedd00ab929354bddd8b03765afd077095c5
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 * this code is specificly written as a driver for the speakup screenreview
23 * package and is not a general device driver.
25 #include <linux/jiffies.h>
26 #include <linux/sched.h>
27 #include <linux/timer.h>
28 #include <linux/kthread.h>
30 #include "spk_priv.h"
31 #include "serialio.h"
32 #include "speakup.h"
34 #define DRV_VERSION "2.21"
35 #define SYNTH_CLEAR 0x18
36 #define PROCSPEECH '\r'
38 static void do_catch_up(struct spk_synth *synth);
40 static struct var_t vars[] = {
41 { CAPS_START, .u.s = {"cap, " } },
42 { CAPS_STOP, .u.s = {"" } },
43 { RATE, .u.n = {"@W%d", 6, 1, 9, 0, 0, NULL } },
44 { PITCH, .u.n = {"@F%x", 10, 0, 15, 0, 0, NULL } },
45 { VOL, .u.n = {"@A%x", 10, 0, 15, 0, 0, NULL } },
46 { VOICE, .u.n = {"@V%d", 1, 1, 6, 0, 0, NULL } },
47 { LANG, .u.n = {"@=%d,", 1, 1, 4, 0, 0, NULL } },
48 { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
49 V_LAST_VAR
53 * These attributes will appear in /sys/accessibility/speakup/apollo.
55 static struct kobj_attribute caps_start_attribute =
56 __ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
57 static struct kobj_attribute caps_stop_attribute =
58 __ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
59 static struct kobj_attribute lang_attribute =
60 __ATTR(lang, USER_RW, spk_var_show, spk_var_store);
61 static struct kobj_attribute pitch_attribute =
62 __ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
63 static struct kobj_attribute rate_attribute =
64 __ATTR(rate, USER_RW, spk_var_show, spk_var_store);
65 static struct kobj_attribute voice_attribute =
66 __ATTR(voice, USER_RW, spk_var_show, spk_var_store);
67 static struct kobj_attribute vol_attribute =
68 __ATTR(vol, USER_RW, spk_var_show, spk_var_store);
70 static struct kobj_attribute delay_time_attribute =
71 __ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
72 static struct kobj_attribute direct_attribute =
73 __ATTR(direct, USER_RW, spk_var_show, spk_var_store);
74 static struct kobj_attribute full_time_attribute =
75 __ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
76 static struct kobj_attribute jiffy_delta_attribute =
77 __ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
78 static struct kobj_attribute trigger_time_attribute =
79 __ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
82 * Create a group of attributes so that we can create and destroy them all
83 * at once.
85 static struct attribute *synth_attrs[] = {
86 &caps_start_attribute.attr,
87 &caps_stop_attribute.attr,
88 &lang_attribute.attr,
89 &pitch_attribute.attr,
90 &rate_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 */
101 static struct spk_synth synth_apollo = {
102 .name = "apollo",
103 .version = DRV_VERSION,
104 .long_name = "Apollo",
105 .init = "@R3@D0@K1\r",
106 .procspeech = PROCSPEECH,
107 .clear = SYNTH_CLEAR,
108 .delay = 500,
109 .trigger = 50,
110 .jiffies = 50,
111 .full = 40000,
112 .startup = SYNTH_START,
113 .checkval = SYNTH_CHECK,
114 .vars = vars,
115 .probe = serial_synth_probe,
116 .release = spk_serial_release,
117 .synth_immediate = spk_synth_immediate,
118 .catch_up = 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,
123 .get_index = NULL,
124 .indexing = {
125 .command = NULL,
126 .lowindex = 0,
127 .highindex = 0,
128 .currindex = 0,
130 .attributes = {
131 .attrs = synth_attrs,
132 .name = "apollo",
136 static void do_catch_up(struct spk_synth *synth)
138 u_char ch;
139 unsigned long flags;
140 unsigned long jiff_max;
141 struct var_t *jiffy_delta;
142 struct var_t *delay_time;
143 struct var_t *full_time;
144 int full_time_val = 0;
145 int delay_time_val = 0;
146 int jiffy_delta_val = 0;
148 jiffy_delta = get_var(JIFFY);
149 delay_time = get_var(DELAY);
150 full_time = get_var(FULL);
151 spk_lock(flags);
152 jiffy_delta_val = jiffy_delta->u.n.value;
153 spk_unlock(flags);
154 jiff_max = jiffies + jiffy_delta_val;
156 while (!kthread_should_stop()) {
157 spk_lock(flags);
158 jiffy_delta_val = jiffy_delta->u.n.value;
159 full_time_val = full_time->u.n.value;
160 delay_time_val = delay_time->u.n.value;
161 if (speakup_info.flushing) {
162 speakup_info.flushing = 0;
163 spk_unlock(flags);
164 synth->flush(synth);
165 continue;
167 if (synth_buffer_empty()) {
168 spk_unlock(flags);
169 break;
171 ch = synth_buffer_peek();
172 set_current_state(TASK_INTERRUPTIBLE);
173 full_time_val = full_time->u.n.value;
174 spk_unlock(flags);
175 if (!spk_serial_out(ch)) {
176 outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR);
177 outb(UART_MCR_DTR | UART_MCR_RTS,
178 speakup_info.port_tts + UART_MCR);
179 schedule_timeout(msecs_to_jiffies(full_time_val));
180 continue;
182 if ((jiffies >= jiff_max) && (ch == SPACE)) {
183 spk_lock(flags);
184 jiffy_delta_val = jiffy_delta->u.n.value;
185 full_time_val = full_time->u.n.value;
186 delay_time_val = delay_time->u.n.value;
187 spk_unlock(flags);
188 if (spk_serial_out(synth->procspeech))
189 schedule_timeout(msecs_to_jiffies
190 (delay_time_val));
191 else
192 schedule_timeout(msecs_to_jiffies
193 (full_time_val));
194 jiff_max = jiffies + jiffy_delta_val;
196 set_current_state(TASK_RUNNING);
197 spk_lock(flags);
198 synth_buffer_getc();
199 spk_unlock(flags);
201 spk_serial_out(PROCSPEECH);
204 module_param_named(ser, synth_apollo.ser, int, S_IRUGO);
205 module_param_named(start, synth_apollo.startup, short, S_IRUGO);
207 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
208 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
210 static int __init apollo_init(void)
212 return synth_add(&synth_apollo);
215 static void __exit apollo_exit(void)
217 synth_remove(&synth_apollo);
220 module_init(apollo_init);
221 module_exit(apollo_exit);
222 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
223 MODULE_AUTHOR("David Borowski");
224 MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer");
225 MODULE_LICENSE("GPL");
226 MODULE_VERSION(DRV_VERSION);