Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
0004  * this version considerably modified by David Borowski, david575@rogers.com
0005  *
0006  * Copyright (C) 1998-99  Kirk Reiser.
0007  * Copyright (C) 2003 David Borowski.
0008  *
0009  * specifically written as a driver for the speakup screenreview
0010  * s not a general device driver.
0011  */
0012 #include "speakup.h"
0013 #include "spk_priv.h"
0014 #include "speakup_dtlk.h" /* local header file for LiteTalk values */
0015 
0016 #define DRV_VERSION "2.11"
0017 #define PROCSPEECH 0x0d
0018 
0019 static int synth_probe(struct spk_synth *synth);
0020 
0021 static struct var_t vars[] = {
0022     { CAPS_START, .u.s = {"\x01+35p" } },
0023     { CAPS_STOP, .u.s = {"\x01-35p" } },
0024     { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },
0025     { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },
0026     { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
0027     { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
0028     { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },
0029     { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
0030     { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
0031     { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
0032     V_LAST_VAR
0033 };
0034 
0035 /*
0036  * These attributes will appear in /sys/accessibility/speakup/ltlk.
0037  */
0038 static struct kobj_attribute caps_start_attribute =
0039     __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
0040 static struct kobj_attribute caps_stop_attribute =
0041     __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
0042 static struct kobj_attribute freq_attribute =
0043     __ATTR(freq, 0644, spk_var_show, spk_var_store);
0044 static struct kobj_attribute pitch_attribute =
0045     __ATTR(pitch, 0644, spk_var_show, spk_var_store);
0046 static struct kobj_attribute punct_attribute =
0047     __ATTR(punct, 0644, spk_var_show, spk_var_store);
0048 static struct kobj_attribute rate_attribute =
0049     __ATTR(rate, 0644, spk_var_show, spk_var_store);
0050 static struct kobj_attribute tone_attribute =
0051     __ATTR(tone, 0644, spk_var_show, spk_var_store);
0052 static struct kobj_attribute voice_attribute =
0053     __ATTR(voice, 0644, spk_var_show, spk_var_store);
0054 static struct kobj_attribute vol_attribute =
0055     __ATTR(vol, 0644, spk_var_show, spk_var_store);
0056 
0057 static struct kobj_attribute delay_time_attribute =
0058     __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
0059 static struct kobj_attribute direct_attribute =
0060     __ATTR(direct, 0644, spk_var_show, spk_var_store);
0061 static struct kobj_attribute full_time_attribute =
0062     __ATTR(full_time, 0644, spk_var_show, spk_var_store);
0063 static struct kobj_attribute jiffy_delta_attribute =
0064     __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
0065 static struct kobj_attribute trigger_time_attribute =
0066     __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
0067 
0068 /*
0069  * Create a group of attributes so that we can create and destroy them all
0070  * at once.
0071  */
0072 static struct attribute *synth_attrs[] = {
0073     &caps_start_attribute.attr,
0074     &caps_stop_attribute.attr,
0075     &freq_attribute.attr,
0076     &pitch_attribute.attr,
0077     &punct_attribute.attr,
0078     &rate_attribute.attr,
0079     &tone_attribute.attr,
0080     &voice_attribute.attr,
0081     &vol_attribute.attr,
0082     &delay_time_attribute.attr,
0083     &direct_attribute.attr,
0084     &full_time_attribute.attr,
0085     &jiffy_delta_attribute.attr,
0086     &trigger_time_attribute.attr,
0087     NULL,   /* need to NULL terminate the list of attributes */
0088 };
0089 
0090 static struct spk_synth synth_ltlk = {
0091     .name = "ltlk",
0092     .version = DRV_VERSION,
0093     .long_name = "LiteTalk",
0094     .init = "\01@\x01\x31y\n\0",
0095     .procspeech = PROCSPEECH,
0096     .clear = SYNTH_CLEAR,
0097     .delay = 500,
0098     .trigger = 50,
0099     .jiffies = 50,
0100     .full = 40000,
0101     .dev_name = SYNTH_DEFAULT_DEV,
0102     .startup = SYNTH_START,
0103     .checkval = SYNTH_CHECK,
0104     .vars = vars,
0105     .io_ops = &spk_ttyio_ops,
0106     .probe = synth_probe,
0107     .release = spk_ttyio_release,
0108     .synth_immediate = spk_ttyio_synth_immediate,
0109     .catch_up = spk_do_catch_up,
0110     .flush = spk_synth_flush,
0111     .is_alive = spk_synth_is_alive_restart,
0112     .synth_adjust = NULL,
0113     .read_buff_add = NULL,
0114     .get_index = spk_synth_get_index,
0115     .indexing = {
0116         .command = "\x01%di",
0117         .lowindex = 1,
0118         .highindex = 5,
0119         .currindex = 1,
0120     },
0121     .attributes = {
0122         .attrs = synth_attrs,
0123         .name = "ltlk",
0124     },
0125 };
0126 
0127 /* interrogate the LiteTalk and print its settings */
0128 static void synth_interrogate(struct spk_synth *synth)
0129 {
0130     unsigned char *t, i;
0131     unsigned char buf[50], rom_v[20];
0132 
0133     synth->synth_immediate(synth, "\x18\x01?");
0134     for (i = 0; i < 50; i++) {
0135         buf[i] = synth->io_ops->synth_in(synth);
0136         if (i > 2 && buf[i] == 0x7f)
0137             break;
0138     }
0139     t = buf + 2;
0140     for (i = 0; *t != '\r'; t++) {
0141         rom_v[i] = *t;
0142         if (++i >= 19)
0143             break;
0144     }
0145     rom_v[i] = 0;
0146     pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
0147 }
0148 
0149 static int synth_probe(struct spk_synth *synth)
0150 {
0151     int failed = 0;
0152 
0153     failed = spk_ttyio_synth_probe(synth);
0154     if (failed == 0)
0155         synth_interrogate(synth);
0156     synth->alive = !failed;
0157     return failed;
0158 }
0159 
0160 module_param_named(ser, synth_ltlk.ser, int, 0444);
0161 module_param_named(dev, synth_ltlk.dev_name, charp, 0444);
0162 module_param_named(start, synth_ltlk.startup, short, 0444);
0163 
0164 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
0165 MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
0166 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
0167 
0168 module_spk_synth(synth_ltlk);
0169 
0170 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
0171 MODULE_AUTHOR("David Borowski");
0172 MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
0173 MODULE_LICENSE("GPL");
0174 MODULE_VERSION(DRV_VERSION);
0175