| 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 |
* specifically written as a driver for the speakup screenreview |
| 10 |
* s not a general device driver. |
| 11 |
*/ |
| 12 |
#include "spk_priv.h" |
| 13 |
#include "speakup.h" |
| 14 |
|
| 15 |
#define DRV_VERSION "2.11" |
| 16 |
#define SYNTH_CLEAR 0x18 |
| 17 |
#define PROCSPEECH '\r' /* process speech char */ |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
enum default_vars_id { |
| 23 |
CAPS_START_ID = 0, CAPS_STOP_ID, |
| 24 |
RATE_ID, PITCH_ID, |
| 25 |
VOL_ID, TONE_ID, |
| 26 |
DIRECT_ID, V_LAST_VAR_ID, |
| 27 |
NB_ID |
| 28 |
}; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
static struct var_t vars[NB_ID] = { |
| 35 |
[CAPS_START_ID] = { CAPS_START, .u.s = {"\x05P8" } }, |
| 36 |
[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x05P5" } }, |
| 37 |
[RATE_ID] = { RATE, .u.n = {"\x05R%d", 5, 0, 9, 0, 0, NULL } }, |
| 38 |
[PITCH_ID] = { PITCH, .u.n = {"\x05P%d", 5, 0, 9, 0, 0, NULL } }, |
| 39 |
[VOL_ID] = { VOL, .u.n = {"\x05V%d", 5, 0, 9, 0, 0, NULL } }, |
| 40 |
[TONE_ID] = { TONE, .u.n = {"\x05T%c", 12, 0, 25, 61, 0, NULL } }, |
| 41 |
[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, |
| 42 |
V_LAST_VAR |
| 43 |
}; |
| 44 |
|
| 45 |
/* These attributes will appear in /sys/accessibility/speakup/txprt. */ |
| 46 |
|
| 47 |
static struct kobj_attribute caps_start_attribute = |
| 48 |
__ATTR(caps_start, 0644, spk_var_show, spk_var_store); |
| 49 |
static struct kobj_attribute caps_stop_attribute = |
| 50 |
__ATTR(caps_stop, 0644, spk_var_show, spk_var_store); |
| 51 |
static struct kobj_attribute pitch_attribute = |
| 52 |
__ATTR(pitch, 0644, spk_var_show, spk_var_store); |
| 53 |
static struct kobj_attribute rate_attribute = |
| 54 |
__ATTR(rate, 0644, spk_var_show, spk_var_store); |
| 55 |
static struct kobj_attribute tone_attribute = |
| 56 |
__ATTR(tone, 0644, spk_var_show, spk_var_store); |
| 57 |
static struct kobj_attribute vol_attribute = |
| 58 |
__ATTR(vol, 0644, spk_var_show, spk_var_store); |
| 59 |
|
| 60 |
static struct kobj_attribute delay_time_attribute = |
| 61 |
__ATTR(delay_time, 0644, spk_var_show, spk_var_store); |
| 62 |
static struct kobj_attribute direct_attribute = |
| 63 |
__ATTR(direct, 0644, spk_var_show, spk_var_store); |
| 64 |
static struct kobj_attribute full_time_attribute = |
| 65 |
__ATTR(full_time, 0644, spk_var_show, spk_var_store); |
| 66 |
static struct kobj_attribute jiffy_delta_attribute = |
| 67 |
__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); |
| 68 |
static struct kobj_attribute trigger_time_attribute = |
| 69 |
__ATTR(trigger_time, 0644, spk_var_show, spk_var_store); |
| 70 |
|
| 71 |
/* |
| 72 |
* Create a group of attributes so that we can create and destroy them all |
| 73 |
* at once. |
| 74 |
*/ |
| 75 |
static struct attribute *synth_attrs[] = { |
| 76 |
&caps_start_attribute.attr, |
| 77 |
&caps_stop_attribute.attr, |
| 78 |
&pitch_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_txprt = { |
| 91 |
.name = "txprt", |
| 92 |
.version = DRV_VERSION, |
| 93 |
.long_name = "Transport", |
| 94 |
.init = "\x05N1", |
| 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 = spk_synth_flush, |
| 111 |
.is_alive = spk_synth_is_alive_restart, |
| 112 |
.synth_adjust = NULL, |
| 113 |
.read_buff_add = NULL, |
| 114 |
.get_index = NULL, |
| 115 |
.indexing = { |
| 116 |
.command = NULL, |
| 117 |
.lowindex = 0, |
| 118 |
.highindex = 0, |
| 119 |
.currindex = 0, |
| 120 |
}, |
| 121 |
.attributes = { |
| 122 |
.attrs = synth_attrs, |
| 123 |
.name = "txprt", |
| 124 |
}, |
| 125 |
}; |
| 126 |
|
| 127 |
module_param_named(ser, synth_txprt.ser, int, 0444); |
| 128 |
module_param_named(dev, synth_txprt.dev_name, charp, 0444); |
| 129 |
module_param_named(start, synth_txprt.startup, short, 0444); |
| 130 |
module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444); |
| 131 |
module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444); |
| 132 |
module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444); |
| 133 |
module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444); |
| 134 |
module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); |
| 139 |
MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); |
| 140 |
MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); |
| 141 |
MODULE_PARM_DESC(rate, "Set the rate variable on load."); |
| 142 |
MODULE_PARM_DESC(pitch, "Set the pitch variable on load."); |
| 143 |
MODULE_PARM_DESC(vol, "Set the vol variable on load."); |
| 144 |
MODULE_PARM_DESC(tone, "Set the tone variable on load."); |
| 145 |
MODULE_PARM_DESC(direct, "Set the direct variable on load."); |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
module_spk_synth(synth_txprt); |
| 150 |
|
| 151 |
MODULE_AUTHOR("Kirk Reiser <[email protected]>"); |
| 152 |
MODULE_AUTHOR("David Borowski"); |
| 153 |
MODULE_DESCRIPTION("Speakup support for Transport synthesizers"); |
| 154 |
MODULE_LICENSE("GPL"); |
| 155 |
MODULE_VERSION(DRV_VERSION); |
| 156 |
|