Path: blob/master/drivers/accessibility/speakup/speakup_ltlk.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 "speakup.h"12#include "spk_priv.h"13#include "speakup_dtlk.h" /* local header file for LiteTalk values */1415#define DRV_VERSION "2.11"16#define PROCSPEECH 0x0d1718static int synth_probe(struct spk_synth *synth);192021enum default_vars_id {22CAPS_START_ID = 0, CAPS_STOP_ID,23RATE_ID, PITCH_ID,24VOL_ID, TONE_ID, PUNCT_ID,25VOICE_ID, FREQUENCY_ID,26DIRECT_ID, V_LAST_VAR_ID,27NB_ID28};293031static struct var_t vars[NB_ID] = {32[CAPS_START_ID] = { CAPS_START, .u.s = {"\x01+35p" } },33[CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x01-35p" } },34[RATE_ID] = { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },35[PITCH_ID] = { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },36[VOL_ID] = { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },37[TONE_ID] = { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },38[PUNCT_ID] = { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },39[VOICE_ID] = { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },40[FREQUENCY_ID] = { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },41[DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },42V_LAST_VAR43};4445/*46* These attributes will appear in /sys/accessibility/speakup/ltlk.47*/48static struct kobj_attribute caps_start_attribute =49__ATTR(caps_start, 0644, spk_var_show, spk_var_store);50static struct kobj_attribute caps_stop_attribute =51__ATTR(caps_stop, 0644, spk_var_show, spk_var_store);52static struct kobj_attribute freq_attribute =53__ATTR(freq, 0644, spk_var_show, spk_var_store);54static struct kobj_attribute pitch_attribute =55__ATTR(pitch, 0644, spk_var_show, spk_var_store);56static struct kobj_attribute punct_attribute =57__ATTR(punct, 0644, spk_var_show, spk_var_store);58static struct kobj_attribute rate_attribute =59__ATTR(rate, 0644, spk_var_show, spk_var_store);60static struct kobj_attribute tone_attribute =61__ATTR(tone, 0644, spk_var_show, spk_var_store);62static struct kobj_attribute voice_attribute =63__ATTR(voice, 0644, spk_var_show, spk_var_store);64static struct kobj_attribute vol_attribute =65__ATTR(vol, 0644, spk_var_show, spk_var_store);6667static struct kobj_attribute delay_time_attribute =68__ATTR(delay_time, 0644, spk_var_show, spk_var_store);69static struct kobj_attribute direct_attribute =70__ATTR(direct, 0644, spk_var_show, spk_var_store);71static struct kobj_attribute full_time_attribute =72__ATTR(full_time, 0644, spk_var_show, spk_var_store);73static struct kobj_attribute jiffy_delta_attribute =74__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);75static struct kobj_attribute trigger_time_attribute =76__ATTR(trigger_time, 0644, spk_var_show, spk_var_store);7778/*79* Create a group of attributes so that we can create and destroy them all80* at once.81*/82static struct attribute *synth_attrs[] = {83&caps_start_attribute.attr,84&caps_stop_attribute.attr,85&freq_attribute.attr,86&pitch_attribute.attr,87&punct_attribute.attr,88&rate_attribute.attr,89&tone_attribute.attr,90&voice_attribute.attr,91&vol_attribute.attr,92&delay_time_attribute.attr,93&direct_attribute.attr,94&full_time_attribute.attr,95&jiffy_delta_attribute.attr,96&trigger_time_attribute.attr,97NULL, /* need to NULL terminate the list of attributes */98};99100static struct spk_synth synth_ltlk = {101.name = "ltlk",102.version = DRV_VERSION,103.long_name = "LiteTalk",104.init = "\01@\x01\x31y\n\0",105.procspeech = PROCSPEECH,106.clear = SYNTH_CLEAR,107.delay = 500,108.trigger = 50,109.jiffies = 50,110.full = 40000,111.dev_name = SYNTH_DEFAULT_DEV,112.startup = SYNTH_START,113.checkval = SYNTH_CHECK,114.vars = vars,115.io_ops = &spk_ttyio_ops,116.probe = synth_probe,117.release = spk_ttyio_release,118.synth_immediate = spk_ttyio_synth_immediate,119.catch_up = spk_do_catch_up,120.flush = spk_synth_flush,121.is_alive = spk_synth_is_alive_restart,122.synth_adjust = NULL,123.read_buff_add = NULL,124.get_index = spk_synth_get_index,125.indexing = {126.command = "\x01%di",127.lowindex = 1,128.highindex = 5,129.currindex = 1,130},131.attributes = {132.attrs = synth_attrs,133.name = "ltlk",134},135};136137/* interrogate the LiteTalk and print its settings */138static void synth_interrogate(struct spk_synth *synth)139{140unsigned char *t, i;141unsigned char buf[50], rom_v[20];142143synth->synth_immediate(synth, "\x18\x01?");144for (i = 0; i < 50; i++) {145buf[i] = synth->io_ops->synth_in(synth);146if (i > 2 && buf[i] == 0x7f)147break;148}149t = buf + 2;150for (i = 0; *t != '\r'; t++) {151rom_v[i] = *t;152if (++i >= 19)153break;154}155rom_v[i] = 0;156pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);157}158159static int synth_probe(struct spk_synth *synth)160{161int failed = 0;162163failed = spk_ttyio_synth_probe(synth);164if (failed == 0)165synth_interrogate(synth);166synth->alive = !failed;167return failed;168}169170module_param_named(ser, synth_ltlk.ser, int, 0444);171module_param_named(dev, synth_ltlk.dev_name, charp, 0444);172module_param_named(start, synth_ltlk.startup, short, 0444);173module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);174module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);175module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);176module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);177module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);178module_param_named(voice, vars[VOICE_ID].u.n.default_val, int, 0444);179module_param_named(frequency, vars[FREQUENCY_ID].u.n.default_val, int, 0444);180module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);181182183184185MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");186MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");187MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");188MODULE_PARM_DESC(rate, "Set the rate variable on load.");189MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");190MODULE_PARM_DESC(vol, "Set the vol variable on load.");191MODULE_PARM_DESC(tone, "Set the tone variable on load.");192MODULE_PARM_DESC(punct, "Set the punct variable on load.");193MODULE_PARM_DESC(voice, "Set the voice variable on load.");194MODULE_PARM_DESC(frequency, "Set the frequency variable on load.");195MODULE_PARM_DESC(direct, "Set the direct variable on load.");196197198module_spk_synth(synth_ltlk);199200MODULE_AUTHOR("Kirk Reiser <[email protected]>");201MODULE_AUTHOR("David Borowski");202MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");203MODULE_LICENSE("GPL");204MODULE_VERSION(DRV_VERSION);205206207208