Path: blob/master/drivers/accessibility/speakup/speakup_spkout.c
26282 views
// SPDX-License-Identifier: GPL-2.0+1/*2* originally written by: Kirk Reiser <[email protected]>3* this version considerably modified by David Borowski, [email protected]4*5* Copyright (C) 1998-99 Kirk Reiser.6* Copyright (C) 2003 David Borowski.7*8* specifically written as a driver for the speakup screenreview9* s not a general device driver.10*/11#include "spk_priv.h"12#include "speakup.h"1314#define DRV_VERSION "2.11"15#define SYNTH_CLEAR 0x1816#define PROCSPEECH '\r'1718static void synth_flush(struct spk_synth *synth);19202122enum default_vars_id {23CAPS_START_ID = 0, CAPS_STOP_ID,24RATE_ID, PITCH_ID,25VOL_ID, TONE_ID, PUNCT_ID,26DIRECT_ID, V_LAST_VAR_ID,27NB_ID28};293031static struct var_t vars[NB_ID] = {32[CAPS_START_ID] = { CAPS_START, .u.s = {"\x05P+" } },33[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x05P-" } },34[RATE_ID] = { RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL } },35[PITCH_ID] = { PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL } },36[VOL_ID] = { VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL } },37[TONE_ID] = { TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL } },38[PUNCT_ID] = { PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } },39[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },40V_LAST_VAR41};4243/* These attributes will appear in /sys/accessibility/speakup/spkout. */4445static struct kobj_attribute caps_start_attribute =46__ATTR(caps_start, 0644, spk_var_show, spk_var_store);47static struct kobj_attribute caps_stop_attribute =48__ATTR(caps_stop, 0644, spk_var_show, spk_var_store);49static struct kobj_attribute pitch_attribute =50__ATTR(pitch, 0644, spk_var_show, spk_var_store);51static struct kobj_attribute punct_attribute =52__ATTR(punct, 0644, spk_var_show, spk_var_store);53static struct kobj_attribute rate_attribute =54__ATTR(rate, 0644, spk_var_show, spk_var_store);55static struct kobj_attribute tone_attribute =56__ATTR(tone, 0644, spk_var_show, spk_var_store);57static struct kobj_attribute vol_attribute =58__ATTR(vol, 0644, spk_var_show, spk_var_store);5960static struct kobj_attribute delay_time_attribute =61__ATTR(delay_time, 0644, spk_var_show, spk_var_store);62static struct kobj_attribute direct_attribute =63__ATTR(direct, 0644, spk_var_show, spk_var_store);64static struct kobj_attribute full_time_attribute =65__ATTR(full_time, 0644, spk_var_show, spk_var_store);66static struct kobj_attribute jiffy_delta_attribute =67__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);68static struct kobj_attribute trigger_time_attribute =69__ATTR(trigger_time, 0644, spk_var_show, spk_var_store);7071/*72* Create a group of attributes so that we can create and destroy them all73* at once.74*/75static struct attribute *synth_attrs[] = {76&caps_start_attribute.attr,77&caps_stop_attribute.attr,78&pitch_attribute.attr,79&punct_attribute.attr,80&rate_attribute.attr,81&tone_attribute.attr,82&vol_attribute.attr,83&delay_time_attribute.attr,84&direct_attribute.attr,85&full_time_attribute.attr,86&jiffy_delta_attribute.attr,87&trigger_time_attribute.attr,88NULL, /* need to NULL terminate the list of attributes */89};9091static struct spk_synth synth_spkout = {92.name = "spkout",93.version = DRV_VERSION,94.long_name = "Speakout",95.init = "\005W1\005I2\005C3",96.procspeech = PROCSPEECH,97.clear = SYNTH_CLEAR,98.delay = 500,99.trigger = 50,100.jiffies = 50,101.full = 40000,102.dev_name = SYNTH_DEFAULT_DEV,103.startup = SYNTH_START,104.checkval = SYNTH_CHECK,105.vars = vars,106.io_ops = &spk_ttyio_ops,107.probe = spk_ttyio_synth_probe,108.release = spk_ttyio_release,109.synth_immediate = spk_ttyio_synth_immediate,110.catch_up = spk_do_catch_up,111.flush = synth_flush,112.is_alive = spk_synth_is_alive_restart,113.synth_adjust = NULL,114.read_buff_add = NULL,115.get_index = spk_synth_get_index,116.indexing = {117.command = "\x05[%c",118.lowindex = 1,119.highindex = 5,120.currindex = 1,121},122.attributes = {123.attrs = synth_attrs,124.name = "spkout",125},126};127128static void synth_flush(struct spk_synth *synth)129{130synth->io_ops->flush_buffer(synth);131synth->io_ops->send_xchar(synth, SYNTH_CLEAR);132}133134module_param_named(ser, synth_spkout.ser, int, 0444);135module_param_named(dev, synth_spkout.dev_name, charp, 0444);136module_param_named(start, synth_spkout.startup, short, 0444);137module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);138module_param_named(vol, vars[PITCH_ID].u.n.default_val, int, 0444);139module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);140module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);141module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);142143144145MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");146MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");147MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");148MODULE_PARM_DESC(rate, "Set the rate variable on load.");149MODULE_PARM_DESC(vol, "Set the vol variable on load.");150MODULE_PARM_DESC(tone, "Set the tone variable on load.");151MODULE_PARM_DESC(punct, "Set the punct variable on load.");152MODULE_PARM_DESC(direct, "Set the direct variable on load.");153154155156module_spk_synth(synth_spkout);157158MODULE_AUTHOR("Kirk Reiser <[email protected]>");159MODULE_AUTHOR("David Borowski");160MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");161MODULE_LICENSE("GPL");162MODULE_VERSION(DRV_VERSION);163164165166