Path: blob/master/drivers/accessibility/speakup/speakup_audptr.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 0x18 /* flush synth buffer */16#define PROCSPEECH '\r' /* start synth processing speech char */1718static int synth_probe(struct spk_synth *synth);19static void synth_flush(struct spk_synth *synth);202122enum 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};2930static struct var_t vars[NB_ID] = {31[CAPS_START_ID] = { CAPS_START, .u.s = {"\x05[f99]" } },32[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x05[f80]" } },33[RATE_ID] = { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } },34[PITCH_ID] = { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } },35[VOL_ID] = { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } },36[TONE_ID] = { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } },37[PUNCT_ID] = { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } },38[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },39V_LAST_VAR40};4142/*43* These attributes will appear in /sys/accessibility/speakup/audptr.44*/45static 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_audptr = {92.name = "audptr",93.version = DRV_VERSION,94.long_name = "Audapter",95.init = "\x05[D1]\x05[Ol]",96.procspeech = PROCSPEECH,97.clear = SYNTH_CLEAR,98.delay = 400,99.trigger = 50,100.jiffies = 30,101.full = 18000,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 = 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 = NULL,116.indexing = {117.command = NULL,118.lowindex = 0,119.highindex = 0,120.currindex = 0,121},122.attributes = {123.attrs = synth_attrs,124.name = "audptr",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);132synth->io_ops->synth_out(synth, PROCSPEECH);133}134135static void synth_version(struct spk_synth *synth)136{137unsigned i;138char synth_id[33];139140synth->synth_immediate(synth, "\x05[Q]");141synth_id[0] = synth->io_ops->synth_in(synth);142if (synth_id[0] != 'A')143return;144145for (i = 1; i < sizeof(synth_id) - 1; i++) {146/* read version string from synth */147synth_id[i] = synth->io_ops->synth_in(synth);148if (synth_id[i] == '\n')149break;150}151synth_id[i] = '\0';152pr_info("%s version: %s", synth->long_name, synth_id);153}154155static int synth_probe(struct spk_synth *synth)156{157int failed;158159failed = spk_ttyio_synth_probe(synth);160if (failed == 0)161synth_version(synth);162synth->alive = !failed;163return 0;164}165166module_param_named(ser, synth_audptr.ser, int, 0444);167module_param_named(dev, synth_audptr.dev_name, charp, 0444);168module_param_named(start, synth_audptr.startup, short, 0444);169module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);170module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);171module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);172module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);173module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);174module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);175176177178MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");179MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");180MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");181MODULE_PARM_DESC(rate, "Set the rate variable on load.");182MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");183MODULE_PARM_DESC(vol, "Set the vol variable on load.");184MODULE_PARM_DESC(tone, "Set the tone variable on load.");185MODULE_PARM_DESC(punct, "Set the punct variable on load.");186MODULE_PARM_DESC(direct, "Set the direct variable on load.");187188189module_spk_synth(synth_audptr);190191MODULE_AUTHOR("Kirk Reiser <[email protected]>");192MODULE_AUTHOR("David Borowski");193MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");194MODULE_LICENSE("GPL");195MODULE_VERSION(DRV_VERSION);196197198199