Merge tag 'asm-generic-4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd...
[deliverable/linux.git] / drivers / staging / speakup / speakup_audptr.c
CommitLineData
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 * specificly written as a driver for the speakup screenreview
19 * s not a general device driver.
20 */
21#include "spk_priv.h"
22#include "speakup.h"
23#include "serialio.h"
24
25#define DRV_VERSION "2.11"
26#define SYNTH_CLEAR 0x18 /* flush synth buffer */
27#define PROCSPEECH '\r' /* start synth processing speech char */
28
29static int synth_probe(struct spk_synth *synth);
30static void synth_flush(struct spk_synth *synth);
31
32static struct var_t vars[] = {
d1c07c41
CB
33 { CAPS_START, .u.s = {"\x05[f99]" } },
34 { CAPS_STOP, .u.s = {"\x05[f80]" } },
35 { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } },
36 { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } },
37 { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } },
ab06e0f2 38 { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } },
d1c07c41
CB
39 { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } },
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/audptr.
46 */
47static struct kobj_attribute caps_start_attribute =
d901aaa7 48 __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 49static struct kobj_attribute caps_stop_attribute =
d901aaa7 50 __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 51static struct kobj_attribute pitch_attribute =
d901aaa7 52 __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 53static struct kobj_attribute punct_attribute =
d901aaa7 54 __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 55static struct kobj_attribute rate_attribute =
d901aaa7 56 __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 57static struct kobj_attribute tone_attribute =
d901aaa7 58 __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 59static struct kobj_attribute vol_attribute =
d901aaa7 60 __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22
WH
61
62static struct kobj_attribute delay_time_attribute =
22c9bcad 63 __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 64static struct kobj_attribute direct_attribute =
d901aaa7 65 __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 66static struct kobj_attribute full_time_attribute =
22c9bcad 67 __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 68static struct kobj_attribute jiffy_delta_attribute =
22c9bcad 69 __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22 70static struct kobj_attribute trigger_time_attribute =
22c9bcad 71 __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
c6e3fd22
WH
72
73/*
74 * Create a group of attributes so that we can create and destroy them all
75 * at once.
76 */
77static struct attribute *synth_attrs[] = {
78 &caps_start_attribute.attr,
79 &caps_stop_attribute.attr,
80 &pitch_attribute.attr,
81 &punct_attribute.attr,
82 &rate_attribute.attr,
83 &tone_attribute.attr,
84 &vol_attribute.attr,
85 &delay_time_attribute.attr,
86 &direct_attribute.attr,
87 &full_time_attribute.attr,
88 &jiffy_delta_attribute.attr,
89 &trigger_time_attribute.attr,
90 NULL, /* need to NULL terminate the list of attributes */
91};
92
93static struct spk_synth synth_audptr = {
94 .name = "audptr",
95 .version = DRV_VERSION,
96 .long_name = "Audapter",
97 .init = "\x05[D1]\x05[Ol]",
98 .procspeech = PROCSPEECH,
99 .clear = SYNTH_CLEAR,
100 .delay = 400,
101 .trigger = 50,
102 .jiffies = 30,
103 .full = 18000,
104 .startup = SYNTH_START,
105 .checkval = SYNTH_CHECK,
106 .vars = vars,
107 .probe = synth_probe,
108 .release = spk_serial_release,
109 .synth_immediate = spk_synth_immediate,
110 .catch_up = spk_do_catch_up,
111 .flush = synth_flush,
112 .is_alive = spk_synth_is_alive_restart,
113 .synth_adjust = NULL,
114 .read_buff_add = NULL,
115 .get_index = NULL,
116 .indexing = {
117 .command = NULL,
118 .lowindex = 0,
119 .highindex = 0,
120 .currindex = 0,
121 },
122 .attributes = {
123 .attrs = synth_attrs,
124 .name = "audptr",
125 },
126};
127
128static void synth_flush(struct spk_synth *synth)
129{
130 int timeout = SPK_XMITR_TIMEOUT;
8e69a811 131
c6e3fd22
WH
132 while (spk_serial_tx_busy()) {
133 if (!--timeout)
134 break;
135 udelay(1);
136 }
137 outb(SYNTH_CLEAR, speakup_info.port_tts);
138 spk_serial_out(PROCSPEECH);
139}
140
141static void synth_version(struct spk_synth *synth)
142{
143 unsigned char test = 0;
144 char synth_id[40] = "";
8e69a811 145
c6e3fd22
WH
146 spk_synth_immediate(synth, "\x05[Q]");
147 synth_id[test] = spk_serial_in();
148 if (synth_id[test] == 'A') {
149 do {
150 /* read version string from synth */
151 synth_id[++test] = spk_serial_in();
152 } while (synth_id[test] != '\n' && test < 32);
153 synth_id[++test] = 0x00;
154 }
155 if (synth_id[0] == 'A')
156 pr_info("%s version: %s", synth->long_name, synth_id);
157}
158
159static int synth_probe(struct spk_synth *synth)
160{
b5186a9f 161 int failed;
c6e3fd22 162
ca2beaf8 163 failed = spk_serial_synth_probe(synth);
c6e3fd22
WH
164 if (failed == 0)
165 synth_version(synth);
166 synth->alive = !failed;
167 return 0;
168}
169
170module_param_named(ser, synth_audptr.ser, int, S_IRUGO);
171module_param_named(start, synth_audptr.startup, short, S_IRUGO);
172
173MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
174MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
175
ae89facc 176module_spk_synth(synth_audptr);
c6e3fd22 177
c6e3fd22
WH
178MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
179MODULE_AUTHOR("David Borowski");
180MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
181MODULE_LICENSE("GPL");
182MODULE_VERSION(DRV_VERSION);
183
This page took 0.495525 seconds and 5 git commands to generate.