Linux-libre 4.14.82-gnu
[librecmc/linux-libre.git] / drivers / staging / speakup / speakup_spkout.c
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  *
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
24 #define DRV_VERSION "2.11"
25 #define SYNTH_CLEAR 0x18
26 #define PROCSPEECH '\r'
27
28 static void synth_flush(struct spk_synth *synth);
29
30 static struct var_t vars[] = {
31         { CAPS_START, .u.s = {"\x05P+" } },
32         { CAPS_STOP, .u.s = {"\x05P-" } },
33         { RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL } },
34         { PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL } },
35         { VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL } },
36         { TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL } },
37         { PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } },
38         { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
39         V_LAST_VAR
40 };
41
42 /* These attributes will appear in /sys/accessibility/speakup/spkout. */
43
44 static struct kobj_attribute caps_start_attribute =
45         __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
46 static struct kobj_attribute caps_stop_attribute =
47         __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
48 static struct kobj_attribute pitch_attribute =
49         __ATTR(pitch, 0644, spk_var_show, spk_var_store);
50 static struct kobj_attribute punct_attribute =
51         __ATTR(punct, 0644, spk_var_show, spk_var_store);
52 static struct kobj_attribute rate_attribute =
53         __ATTR(rate, 0644, spk_var_show, spk_var_store);
54 static struct kobj_attribute tone_attribute =
55         __ATTR(tone, 0644, spk_var_show, spk_var_store);
56 static struct kobj_attribute vol_attribute =
57         __ATTR(vol, 0644, spk_var_show, spk_var_store);
58
59 static struct kobj_attribute delay_time_attribute =
60         __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
61 static struct kobj_attribute direct_attribute =
62         __ATTR(direct, 0644, spk_var_show, spk_var_store);
63 static struct kobj_attribute full_time_attribute =
64         __ATTR(full_time, 0644, spk_var_show, spk_var_store);
65 static struct kobj_attribute jiffy_delta_attribute =
66         __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
67 static struct kobj_attribute trigger_time_attribute =
68         __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
69
70 /*
71  * Create a group of attributes so that we can create and destroy them all
72  * at once.
73  */
74 static struct attribute *synth_attrs[] = {
75         &caps_start_attribute.attr,
76         &caps_stop_attribute.attr,
77         &pitch_attribute.attr,
78         &punct_attribute.attr,
79         &rate_attribute.attr,
80         &tone_attribute.attr,
81         &vol_attribute.attr,
82         &delay_time_attribute.attr,
83         &direct_attribute.attr,
84         &full_time_attribute.attr,
85         &jiffy_delta_attribute.attr,
86         &trigger_time_attribute.attr,
87         NULL,   /* need to NULL terminate the list of attributes */
88 };
89
90 static struct spk_synth synth_spkout = {
91         .name = "spkout",
92         .version = DRV_VERSION,
93         .long_name = "Speakout",
94         .init = "\005W1\005I2\005C3",
95         .procspeech = PROCSPEECH,
96         .clear = SYNTH_CLEAR,
97         .delay = 500,
98         .trigger = 50,
99         .jiffies = 50,
100         .full = 40000,
101         .dev_name = SYNTH_DEFAULT_DEV,
102         .startup = SYNTH_START,
103         .checkval = SYNTH_CHECK,
104         .vars = vars,
105         .io_ops = &spk_ttyio_ops,
106         .probe = spk_ttyio_synth_probe,
107         .release = spk_ttyio_release,
108         .synth_immediate = spk_ttyio_synth_immediate,
109         .catch_up = spk_do_catch_up,
110         .flush = synth_flush,
111         .is_alive = spk_synth_is_alive_restart,
112         .synth_adjust = NULL,
113         .read_buff_add = NULL,
114         .get_index = spk_synth_get_index,
115         .indexing = {
116                 .command = "\x05[%c",
117                 .lowindex = 1,
118                 .highindex = 5,
119                 .currindex = 1,
120         },
121         .attributes = {
122                 .attrs = synth_attrs,
123                 .name = "spkout",
124         },
125 };
126
127 static void synth_flush(struct spk_synth *synth)
128 {
129         synth->io_ops->flush_buffer();
130         synth->io_ops->send_xchar(SYNTH_CLEAR);
131 }
132
133 module_param_named(ser, synth_spkout.ser, int, 0444);
134 module_param_named(dev, synth_spkout.dev_name, charp, S_IRUGO);
135 module_param_named(start, synth_spkout.startup, short, 0444);
136
137 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
138 MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
139 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
140
141 module_spk_synth(synth_spkout);
142
143 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
144 MODULE_AUTHOR("David Borowski");
145 MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");
146 MODULE_LICENSE("GPL");
147 MODULE_VERSION(DRV_VERSION);
148