^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * this version considerably modified by David Borowski, david575@rogers.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 1998-99 Kirk Reiser.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2003 David Borowski.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * specificly written as a driver for the speakup screenreview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * s not a general device driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "spk_priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "speakup.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define DRV_VERSION "2.11"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define SYNTH_CLEAR 0x18 /* flush synth buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define PROCSPEECH '\r' /* start synth processing speech char */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static int synth_probe(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static void synth_flush(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static struct var_t vars[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) { CAPS_START, .u.s = {"\x05[f99]" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) { CAPS_STOP, .u.s = {"\x05[f80]" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) V_LAST_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * These attributes will appear in /sys/accessibility/speakup/audptr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static struct kobj_attribute caps_start_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static struct kobj_attribute caps_stop_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct kobj_attribute pitch_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __ATTR(pitch, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static struct kobj_attribute punct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) __ATTR(punct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static struct kobj_attribute rate_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __ATTR(rate, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static struct kobj_attribute tone_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __ATTR(tone, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static struct kobj_attribute vol_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __ATTR(vol, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static struct kobj_attribute delay_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static struct kobj_attribute direct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) __ATTR(direct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static struct kobj_attribute full_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __ATTR(full_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static struct kobj_attribute jiffy_delta_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static struct kobj_attribute trigger_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Create a group of attributes so that we can create and destroy them all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static struct attribute *synth_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) &caps_start_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) &caps_stop_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) &pitch_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) &punct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) &rate_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) &tone_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) &vol_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) &delay_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) &direct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) &full_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) &jiffy_delta_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) &trigger_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) NULL, /* need to NULL terminate the list of attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static struct spk_synth synth_audptr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .name = "audptr",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .version = DRV_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .long_name = "Audapter",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .init = "\x05[D1]\x05[Ol]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .procspeech = PROCSPEECH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .clear = SYNTH_CLEAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .delay = 400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .trigger = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .jiffies = 30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .full = 18000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .dev_name = SYNTH_DEFAULT_DEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .startup = SYNTH_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .checkval = SYNTH_CHECK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .vars = vars,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .io_ops = &spk_ttyio_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .probe = synth_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .release = spk_ttyio_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .synth_immediate = spk_ttyio_synth_immediate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .catch_up = spk_do_catch_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .flush = synth_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .is_alive = spk_synth_is_alive_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .synth_adjust = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .read_buff_add = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .get_index = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .indexing = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .command = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .lowindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .highindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .currindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) .attributes = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) .attrs = synth_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .name = "audptr",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void synth_flush(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) synth->io_ops->flush_buffer();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) synth->io_ops->send_xchar(SYNTH_CLEAR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) synth->io_ops->synth_out(synth, PROCSPEECH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void synth_version(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned char test = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) char synth_id[40] = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) synth->synth_immediate(synth, "\x05[Q]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) synth_id[test] = synth->io_ops->synth_in();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (synth_id[test] == 'A') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* read version string from synth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) synth_id[++test] = synth->io_ops->synth_in();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) } while (synth_id[test] != '\n' && test < 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) synth_id[++test] = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (synth_id[0] == 'A')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) pr_info("%s version: %s", synth->long_name, synth_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static int synth_probe(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) failed = spk_ttyio_synth_probe(synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (failed == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) synth_version(synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) synth->alive = !failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) module_param_named(ser, synth_audptr.ser, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) module_param_named(dev, synth_audptr.dev_name, charp, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) module_param_named(start, synth_audptr.startup, short, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) module_spk_synth(synth_audptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) MODULE_AUTHOR("David Borowski");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) MODULE_VERSION(DRV_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)