Commit | Line | Data |
---|---|---|
c6e3fd22 WH |
1 | /* |
2 | * originally written by: Kirk Reiser <kirk@braille.uwo.ca> | |
3 | * this version considerably modified by David Borowski, david575@rogers.com | |
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 | * this code is specificly written as a driver for the speakup screenreview |
19 | * package and is not a general device driver. | |
20 | */ | |
21 | #include <linux/jiffies.h> | |
22 | #include <linux/sched.h> | |
23 | #include <linux/timer.h> | |
24 | #include <linux/kthread.h> | |
25 | ||
26 | #include "spk_priv.h" | |
27 | #include "serialio.h" | |
28 | #include "speakup.h" | |
29 | ||
30 | #define DRV_VERSION "2.21" | |
31 | #define SYNTH_CLEAR 0x18 | |
32 | #define PROCSPEECH '\r' | |
33 | ||
34 | static void do_catch_up(struct spk_synth *synth); | |
35 | ||
36 | static struct var_t vars[] = { | |
f4931441 CB |
37 | { CAPS_START, .u.s = {"cap, " } }, |
38 | { CAPS_STOP, .u.s = {"" } }, | |
39 | { RATE, .u.n = {"@W%d", 6, 1, 9, 0, 0, NULL } }, | |
40 | { PITCH, .u.n = {"@F%x", 10, 0, 15, 0, 0, NULL } }, | |
41 | { VOL, .u.n = {"@A%x", 10, 0, 15, 0, 0, NULL } }, | |
42 | { VOICE, .u.n = {"@V%d", 1, 1, 6, 0, 0, NULL } }, | |
43 | { LANG, .u.n = {"@=%d,", 1, 1, 4, 0, 0, NULL } }, | |
44 | { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, | |
c6e3fd22 WH |
45 | V_LAST_VAR |
46 | }; | |
47 | ||
48 | /* | |
49 | * These attributes will appear in /sys/accessibility/speakup/apollo. | |
50 | */ | |
51 | static struct kobj_attribute caps_start_attribute = | |
d901aaa7 | 52 | __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 53 | static struct kobj_attribute caps_stop_attribute = |
d901aaa7 | 54 | __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 55 | static struct kobj_attribute lang_attribute = |
d901aaa7 | 56 | __ATTR(lang, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 57 | static struct kobj_attribute pitch_attribute = |
d901aaa7 | 58 | __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 59 | static struct kobj_attribute rate_attribute = |
d901aaa7 | 60 | __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 61 | static struct kobj_attribute voice_attribute = |
d901aaa7 | 62 | __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 63 | static struct kobj_attribute vol_attribute = |
d901aaa7 | 64 | __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 WH |
65 | |
66 | static struct kobj_attribute delay_time_attribute = | |
22c9bcad | 67 | __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 68 | static struct kobj_attribute direct_attribute = |
d901aaa7 | 69 | __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 70 | static struct kobj_attribute full_time_attribute = |
22c9bcad | 71 | __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 72 | static struct kobj_attribute jiffy_delta_attribute = |
22c9bcad | 73 | __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); |
c6e3fd22 | 74 | static struct kobj_attribute trigger_time_attribute = |
22c9bcad | 75 | __ATTR(trigger_time, S_IWUSR|S_IRUGO, 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 | */ | |
81 | static struct attribute *synth_attrs[] = { | |
82 | &caps_start_attribute.attr, | |
83 | &caps_stop_attribute.attr, | |
84 | &lang_attribute.attr, | |
85 | &pitch_attribute.attr, | |
86 | &rate_attribute.attr, | |
87 | &voice_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_apollo = { | |
98 | .name = "apollo", | |
99 | .version = DRV_VERSION, | |
100 | .long_name = "Apollo", | |
101 | .init = "@R3@D0@K1\r", | |
102 | .procspeech = PROCSPEECH, | |
103 | .clear = SYNTH_CLEAR, | |
104 | .delay = 500, | |
105 | .trigger = 50, | |
106 | .jiffies = 50, | |
107 | .full = 40000, | |
108 | .startup = SYNTH_START, | |
109 | .checkval = SYNTH_CHECK, | |
110 | .vars = vars, | |
ca2beaf8 | 111 | .probe = spk_serial_synth_probe, |
c6e3fd22 WH |
112 | .release = spk_serial_release, |
113 | .synth_immediate = spk_synth_immediate, | |
114 | .catch_up = do_catch_up, | |
115 | .flush = spk_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 = "apollo", | |
129 | }, | |
130 | }; | |
131 | ||
132 | static void do_catch_up(struct spk_synth *synth) | |
133 | { | |
134 | u_char ch; | |
135 | unsigned long flags; | |
136 | unsigned long jiff_max; | |
137 | struct var_t *jiffy_delta; | |
138 | struct var_t *delay_time; | |
139 | struct var_t *full_time; | |
140 | int full_time_val = 0; | |
141 | int delay_time_val = 0; | |
142 | int jiffy_delta_val = 0; | |
143 | ||
ca2beaf8 ST |
144 | jiffy_delta = spk_get_var(JIFFY); |
145 | delay_time = spk_get_var(DELAY); | |
146 | full_time = spk_get_var(FULL); | |
6ca4dbe3 | 147 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
c6e3fd22 | 148 | jiffy_delta_val = jiffy_delta->u.n.value; |
6ca4dbe3 | 149 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
150 | jiff_max = jiffies + jiffy_delta_val; |
151 | ||
152 | while (!kthread_should_stop()) { | |
6ca4dbe3 | 153 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
154 | jiffy_delta_val = jiffy_delta->u.n.value; |
155 | full_time_val = full_time->u.n.value; | |
156 | delay_time_val = delay_time->u.n.value; | |
157 | if (speakup_info.flushing) { | |
158 | speakup_info.flushing = 0; | |
6ca4dbe3 | 159 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
160 | synth->flush(synth); |
161 | continue; | |
162 | } | |
163 | if (synth_buffer_empty()) { | |
6ca4dbe3 | 164 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
165 | break; |
166 | } | |
167 | ch = synth_buffer_peek(); | |
168 | set_current_state(TASK_INTERRUPTIBLE); | |
169 | full_time_val = full_time->u.n.value; | |
6ca4dbe3 | 170 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
171 | if (!spk_serial_out(ch)) { |
172 | outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR); | |
173 | outb(UART_MCR_DTR | UART_MCR_RTS, | |
174 | speakup_info.port_tts + UART_MCR); | |
175 | schedule_timeout(msecs_to_jiffies(full_time_val)); | |
176 | continue; | |
177 | } | |
c45a9a9b | 178 | if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { |
6ca4dbe3 | 179 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
180 | jiffy_delta_val = jiffy_delta->u.n.value; |
181 | full_time_val = full_time->u.n.value; | |
182 | delay_time_val = delay_time->u.n.value; | |
6ca4dbe3 | 183 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 | 184 | if (spk_serial_out(synth->procspeech)) |
f4931441 CB |
185 | schedule_timeout(msecs_to_jiffies |
186 | (delay_time_val)); | |
c6e3fd22 | 187 | else |
f4931441 CB |
188 | schedule_timeout(msecs_to_jiffies |
189 | (full_time_val)); | |
c6e3fd22 WH |
190 | jiff_max = jiffies + jiffy_delta_val; |
191 | } | |
192 | set_current_state(TASK_RUNNING); | |
6ca4dbe3 | 193 | spin_lock_irqsave(&speakup_info.spinlock, flags); |
c6e3fd22 | 194 | synth_buffer_getc(); |
6ca4dbe3 | 195 | spin_unlock_irqrestore(&speakup_info.spinlock, flags); |
c6e3fd22 WH |
196 | } |
197 | spk_serial_out(PROCSPEECH); | |
198 | } | |
199 | ||
200 | module_param_named(ser, synth_apollo.ser, int, S_IRUGO); | |
201 | module_param_named(start, synth_apollo.startup, short, S_IRUGO); | |
202 | ||
203 | MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); | |
204 | MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); | |
205 | ||
ae89facc | 206 | module_spk_synth(synth_apollo); |
c6e3fd22 | 207 | |
c6e3fd22 WH |
208 | MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>"); |
209 | MODULE_AUTHOR("David Borowski"); | |
210 | MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer"); | |
211 | MODULE_LICENSE("GPL"); | |
212 | MODULE_VERSION(DRV_VERSION); | |
213 |