^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) * this code is specificly written as a driver for the speakup screenreview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * package and is 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define PROCSPEECH '\r'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static struct var_t vars[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) { CAPS_START, .u.s = {"\x05\x31\x32P" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) { CAPS_STOP, .u.s = {"\x05\x38P" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) { RATE, .u.n = {"\x05%dE", 8, 1, 16, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) { PITCH, .u.n = {"\x05%dP", 8, 0, 16, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) { VOL, .u.n = {"\x05%dV", 8, 0, 16, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) { TONE, .u.n = {"\x05%dT", 8, 0, 16, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) V_LAST_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * These attributes will appear in /sys/accessibility/speakup/bns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static struct kobj_attribute caps_start_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static struct kobj_attribute caps_stop_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static struct kobj_attribute pitch_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) __ATTR(pitch, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static struct kobj_attribute rate_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __ATTR(rate, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct kobj_attribute tone_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __ATTR(tone, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static struct kobj_attribute vol_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) __ATTR(vol, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static struct kobj_attribute delay_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static struct kobj_attribute direct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) __ATTR(direct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static struct kobj_attribute full_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __ATTR(full_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static struct kobj_attribute jiffy_delta_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static struct kobj_attribute trigger_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Create a group of attributes so that we can create and destroy them all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static struct attribute *synth_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) &caps_start_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) &caps_stop_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) &pitch_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) &rate_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) &tone_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) &vol_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) &delay_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) &direct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) &full_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) &jiffy_delta_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) &trigger_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) NULL, /* need to NULL terminate the list of attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static struct spk_synth synth_bns = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .name = "bns",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .version = DRV_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .long_name = "Braille 'N Speak",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .init = "\x05Z\x05\x43",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .procspeech = PROCSPEECH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .clear = SYNTH_CLEAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) .delay = 500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .trigger = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .jiffies = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .full = 40000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .dev_name = SYNTH_DEFAULT_DEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .startup = SYNTH_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .checkval = SYNTH_CHECK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .vars = vars,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .io_ops = &spk_ttyio_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .probe = spk_ttyio_synth_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .release = spk_ttyio_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .synth_immediate = spk_ttyio_synth_immediate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .catch_up = spk_do_catch_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .flush = spk_synth_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .is_alive = spk_synth_is_alive_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .synth_adjust = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .read_buff_add = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .get_index = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .indexing = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .command = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .lowindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .highindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .currindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .attributes = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .attrs = synth_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .name = "bns",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) module_param_named(ser, synth_bns.ser, int, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) module_param_named(dev, synth_bns.dev_name, charp, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) module_param_named(start, synth_bns.startup, short, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) module_spk_synth(synth_bns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) MODULE_AUTHOR("David Borowski");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) MODULE_DESCRIPTION("Speakup support for Braille 'n Speak synthesizers");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) MODULE_VERSION(DRV_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)