Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/accessibility/speakup/speakup_acntsa.c
26282 views
1
// SPDX-License-Identifier: GPL-2.0+
2
/*
3
* originally written by: Kirk Reiser <[email protected]>
4
* this version considerably modified by David Borowski, [email protected]
5
*
6
* Copyright (C) 1998-99 Kirk Reiser.
7
* Copyright (C) 2003 David Borowski.
8
*
9
* this code is specifically written as a driver for the speakup screenreview
10
* package and is not a general device driver.
11
*/
12
13
#include "spk_priv.h"
14
#include "speakup.h"
15
#include "speakup_acnt.h" /* local header file for Accent values */
16
17
#define DRV_VERSION "2.11"
18
#define PROCSPEECH '\r'
19
20
static int synth_probe(struct spk_synth *synth);
21
22
23
enum default_vars_id {
24
CAPS_START_ID = 0, CAPS_STOP_ID,
25
RATE_ID, PITCH_ID,
26
VOL_ID, TONE_ID,
27
DIRECT_ID, V_LAST_VAR_ID,
28
NB_ID
29
};
30
31
32
static struct var_t vars[NB_ID] = {
33
[CAPS_START_ID] = { CAPS_START, .u.s = {"\033P8" } },
34
[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\033P5" } },
35
[RATE_ID] = { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } },
36
[PITCH_ID] = { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } },
37
[VOL_ID] = { VOL, .u.n = {"\033A%d", 9, 0, 9, 0, 0, NULL } },
38
[TONE_ID] = { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } },
39
[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
40
V_LAST_VAR
41
};
42
43
/*
44
* These attributes will appear in /sys/accessibility/speakup/acntsa.
45
*/
46
static struct kobj_attribute caps_start_attribute =
47
__ATTR(caps_start, 0644, spk_var_show, spk_var_store);
48
static struct kobj_attribute caps_stop_attribute =
49
__ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
50
static struct kobj_attribute pitch_attribute =
51
__ATTR(pitch, 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
&rate_attribute.attr,
79
&tone_attribute.attr,
80
&vol_attribute.attr,
81
&delay_time_attribute.attr,
82
&direct_attribute.attr,
83
&full_time_attribute.attr,
84
&jiffy_delta_attribute.attr,
85
&trigger_time_attribute.attr,
86
NULL, /* need to NULL terminate the list of attributes */
87
};
88
89
static struct spk_synth synth_acntsa = {
90
.name = "acntsa",
91
.version = DRV_VERSION,
92
.long_name = "Accent-SA",
93
.init = "\033T2\033=M\033Oi\033N1\n",
94
.procspeech = PROCSPEECH,
95
.clear = SYNTH_CLEAR,
96
.delay = 400,
97
.trigger = 50,
98
.jiffies = 30,
99
.full = 40000,
100
.dev_name = SYNTH_DEFAULT_DEV,
101
.startup = SYNTH_START,
102
.checkval = SYNTH_CHECK,
103
.vars = vars,
104
.io_ops = &spk_ttyio_ops,
105
.probe = synth_probe,
106
.release = spk_ttyio_release,
107
.synth_immediate = spk_ttyio_synth_immediate,
108
.catch_up = spk_do_catch_up,
109
.flush = spk_synth_flush,
110
.is_alive = spk_synth_is_alive_restart,
111
.synth_adjust = NULL,
112
.read_buff_add = NULL,
113
.get_index = NULL,
114
.indexing = {
115
.command = NULL,
116
.lowindex = 0,
117
.highindex = 0,
118
.currindex = 0,
119
},
120
.attributes = {
121
.attrs = synth_attrs,
122
.name = "acntsa",
123
},
124
};
125
126
static int synth_probe(struct spk_synth *synth)
127
{
128
int failed;
129
130
failed = spk_ttyio_synth_probe(synth);
131
if (failed == 0) {
132
synth->synth_immediate(synth, "\033=R\r");
133
mdelay(100);
134
}
135
synth->alive = !failed;
136
return failed;
137
}
138
139
module_param_named(ser, synth_acntsa.ser, int, 0444);
140
module_param_named(dev, synth_acntsa.dev_name, charp, 0444);
141
module_param_named(start, synth_acntsa.startup, short, 0444);
142
module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);
143
module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);
144
module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);
145
module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);
146
module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);
147
148
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
149
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
150
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
151
MODULE_PARM_DESC(rate, "Set the rate variable on load.");
152
MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");
153
MODULE_PARM_DESC(vol, "Set the vol variable on load.");
154
MODULE_PARM_DESC(tone, "Set the tone variable on load.");
155
MODULE_PARM_DESC(direct, "Set the direct variable on load.");
156
157
158
module_spk_synth(synth_acntsa);
159
160
MODULE_AUTHOR("Kirk Reiser <[email protected]>");
161
MODULE_AUTHOR("David Borowski");
162
MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer");
163
MODULE_LICENSE("GPL");
164
MODULE_VERSION(DRV_VERSION);
165
166
167