1 // SPDX-License-Identifier: GPL-2.0+
3 * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
4 * this version considerably modified by David Borowski, david575@rogers.com
6 * Copyright (C) 1998-99 Kirk Reiser.
7 * Copyright (C) 2003 David Borowski.
9 * specifically written as a driver for the speakup screenreview
10 * s not a general device driver.
15 #define DRV_VERSION "2.11"
16 #define SYNTH_CLEAR 0x18
17 #define PROCSPEECH '\r'
19 static void synth_flush(struct spk_synth
*synth
);
23 enum default_vars_id
{
24 CAPS_START_ID
= 0, CAPS_STOP_ID
,
26 VOL_ID
, TONE_ID
, PUNCT_ID
,
27 DIRECT_ID
, V_LAST_VAR_ID
,
32 static struct var_t vars
[NB_ID
] = {
33 [CAPS_START_ID
] = { CAPS_START
, .u
.s
= {"\x05P+" } },
34 [CAPS_STOP_ID
] = { CAPS_STOP
, .u
.s
= {"\x05P-" } },
35 [RATE_ID
] = { RATE
, .u
.n
= {"\x05R%d", 7, 0, 9, 0, 0, NULL
} },
36 [PITCH_ID
] = { PITCH
, .u
.n
= {"\x05P%d", 3, 0, 9, 0, 0, NULL
} },
37 [VOL_ID
] = { VOL
, .u
.n
= {"\x05V%d", 9, 0, 9, 0, 0, NULL
} },
38 [TONE_ID
] = { TONE
, .u
.n
= {"\x05T%c", 8, 0, 25, 65, 0, NULL
} },
39 [PUNCT_ID
] = { PUNCT
, .u
.n
= {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } },
40 [DIRECT_ID
] = { DIRECT
, .u
.n
= {NULL
, 0, 0, 1, 0, 0, NULL
} },
44 /* These attributes will appear in /sys/accessibility/speakup/spkout. */
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 punct_attribute
=
53 __ATTR(punct
, 0644, spk_var_show
, spk_var_store
);
54 static struct kobj_attribute rate_attribute
=
55 __ATTR(rate
, 0644, spk_var_show
, spk_var_store
);
56 static struct kobj_attribute tone_attribute
=
57 __ATTR(tone
, 0644, spk_var_show
, spk_var_store
);
58 static struct kobj_attribute vol_attribute
=
59 __ATTR(vol
, 0644, spk_var_show
, spk_var_store
);
61 static struct kobj_attribute delay_time_attribute
=
62 __ATTR(delay_time
, 0644, spk_var_show
, spk_var_store
);
63 static struct kobj_attribute direct_attribute
=
64 __ATTR(direct
, 0644, spk_var_show
, spk_var_store
);
65 static struct kobj_attribute full_time_attribute
=
66 __ATTR(full_time
, 0644, spk_var_show
, spk_var_store
);
67 static struct kobj_attribute jiffy_delta_attribute
=
68 __ATTR(jiffy_delta
, 0644, spk_var_show
, spk_var_store
);
69 static struct kobj_attribute trigger_time_attribute
=
70 __ATTR(trigger_time
, 0644, spk_var_show
, spk_var_store
);
73 * Create a group of attributes so that we can create and destroy them all
76 static struct attribute
*synth_attrs
[] = {
77 &caps_start_attribute
.attr
,
78 &caps_stop_attribute
.attr
,
79 &pitch_attribute
.attr
,
80 &punct_attribute
.attr
,
84 &delay_time_attribute
.attr
,
85 &direct_attribute
.attr
,
86 &full_time_attribute
.attr
,
87 &jiffy_delta_attribute
.attr
,
88 &trigger_time_attribute
.attr
,
89 NULL
, /* need to NULL terminate the list of attributes */
92 static struct spk_synth synth_spkout
= {
94 .version
= DRV_VERSION
,
95 .long_name
= "Speakout",
96 .init
= "\005W1\005I2\005C3",
97 .procspeech
= PROCSPEECH
,
103 .dev_name
= SYNTH_DEFAULT_DEV
,
104 .startup
= SYNTH_START
,
105 .checkval
= SYNTH_CHECK
,
107 .io_ops
= &spk_ttyio_ops
,
108 .probe
= spk_ttyio_synth_probe
,
109 .release
= spk_ttyio_release
,
110 .synth_immediate
= spk_ttyio_synth_immediate
,
111 .catch_up
= spk_do_catch_up
,
112 .flush
= synth_flush
,
113 .is_alive
= spk_synth_is_alive_restart
,
114 .synth_adjust
= NULL
,
115 .read_buff_add
= NULL
,
116 .get_index
= spk_synth_get_index
,
118 .command
= "\x05[%c",
124 .attrs
= synth_attrs
,
129 static void synth_flush(struct spk_synth
*synth
)
131 synth
->io_ops
->flush_buffer(synth
);
132 synth
->io_ops
->send_xchar(synth
, SYNTH_CLEAR
);
135 module_param_named(ser
, synth_spkout
.ser
, int, 0444);
136 module_param_named(dev
, synth_spkout
.dev_name
, charp
, 0444);
137 module_param_named(start
, synth_spkout
.startup
, short, 0444);
138 module_param_named(rate
, vars
[RATE_ID
].u
.n
.default_val
, int, 0444);
139 module_param_named(vol
, vars
[PITCH_ID
].u
.n
.default_val
, int, 0444);
140 module_param_named(tone
, vars
[TONE_ID
].u
.n
.default_val
, int, 0444);
141 module_param_named(punct
, vars
[PUNCT_ID
].u
.n
.default_val
, int, 0444);
142 module_param_named(direct
, vars
[DIRECT_ID
].u
.n
.default_val
, int, 0444);
146 MODULE_PARM_DESC(ser
, "Set the serial port for the synthesizer (0-based).");
147 MODULE_PARM_DESC(dev
, "Set the device e.g. ttyUSB0, for the synthesizer.");
148 MODULE_PARM_DESC(start
, "Start the synthesizer once it is loaded.");
149 MODULE_PARM_DESC(rate
, "Set the rate variable on load.");
150 MODULE_PARM_DESC(vol
, "Set the vol variable on load.");
151 MODULE_PARM_DESC(tone
, "Set the tone variable on load.");
152 MODULE_PARM_DESC(punct
, "Set the punct variable on load.");
153 MODULE_PARM_DESC(direct
, "Set the direct variable on load.");
157 module_spk_synth(synth_spkout
);
159 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
160 MODULE_AUTHOR("David Borowski");
161 MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");
162 MODULE_LICENSE("GPL");
163 MODULE_VERSION(DRV_VERSION
);