linux/drivers/staging/speakup/speakup_audptr.c
<<
>>
Prefs
   1/*
   2 * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
   3 * this version considerably modified by David Borowski, david575@rogers.com
   4 *
   5 * Copyright (C) 1998-99  Kirk Reiser.
   6 * Copyright (C) 2003 David Borowski.
   7 *
   8 * This program is free software; you can redistribute it and/or modify
   9 * it under the terms of the GNU General Public License as published by
  10 * the Free Software Foundation; either version 2 of the License, or
  11 * (at your option) any later version.
  12 *
  13 * This program is distributed in the hope that it will be useful,
  14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16 * GNU General Public License for more details.
  17 *
  18 * You should have received a copy of the GNU General Public License
  19 * along with this program; if not, write to the Free Software
  20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21 *
  22 * specificly written as a driver for the speakup screenreview
  23 * s not a general device driver.
  24 */
  25#include "spk_priv.h"
  26#include "speakup.h"
  27#include "serialio.h"
  28
  29#define DRV_VERSION "2.11"
  30#define SYNTH_CLEAR 0x18 /* flush synth buffer */
  31#define PROCSPEECH '\r' /* start synth processing speech char */
  32
  33static int synth_probe(struct spk_synth *synth);
  34static void synth_flush(struct spk_synth *synth);
  35
  36static struct var_t vars[] = {
  37        { CAPS_START, .u.s = {"\x05[f99]" } },
  38        { CAPS_STOP, .u.s = {"\x05[f80]" } },
  39        { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } },
  40        { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } },
  41        { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } },
  42        { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } },
  43        { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } },
  44        { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  45        V_LAST_VAR
  46};
  47
  48/*
  49 * These attributes will appear in /sys/accessibility/speakup/audptr.
  50 */
  51static struct kobj_attribute caps_start_attribute =
  52        __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  53static struct kobj_attribute caps_stop_attribute =
  54        __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  55static struct kobj_attribute pitch_attribute =
  56        __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  57static struct kobj_attribute punct_attribute =
  58        __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  59static struct kobj_attribute rate_attribute =
  60        __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  61static struct kobj_attribute tone_attribute =
  62        __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  63static struct kobj_attribute vol_attribute =
  64        __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  65
  66static struct kobj_attribute delay_time_attribute =
  67        __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  68static struct kobj_attribute direct_attribute =
  69        __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  70static struct kobj_attribute full_time_attribute =
  71        __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  72static struct kobj_attribute jiffy_delta_attribute =
  73        __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  74static struct kobj_attribute trigger_time_attribute =
  75        __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  76
  77/*
  78 * Create a group of attributes so that we can create and destroy them all
  79 * at once.
  80 */
  81static struct attribute *synth_attrs[] = {
  82        &caps_start_attribute.attr,
  83        &caps_stop_attribute.attr,
  84        &pitch_attribute.attr,
  85        &punct_attribute.attr,
  86        &rate_attribute.attr,
  87        &tone_attribute.attr,
  88        &vol_attribute.attr,
  89        &delay_time_attribute.attr,
  90        &direct_attribute.attr,
  91        &full_time_attribute.attr,
  92        &jiffy_delta_attribute.attr,
  93        &trigger_time_attribute.attr,
  94        NULL,   /* need to NULL terminate the list of attributes */
  95};
  96
  97static struct spk_synth synth_audptr = {
  98        .name = "audptr",
  99        .version = DRV_VERSION,
 100        .long_name = "Audapter",
 101        .init = "\x05[D1]\x05[Ol]",
 102        .procspeech = PROCSPEECH,
 103        .clear = SYNTH_CLEAR,
 104        .delay = 400,
 105        .trigger = 50,
 106        .jiffies = 30,
 107        .full = 18000,
 108        .startup = SYNTH_START,
 109        .checkval = SYNTH_CHECK,
 110        .vars = vars,
 111        .probe = synth_probe,
 112        .release = spk_serial_release,
 113        .synth_immediate = spk_synth_immediate,
 114        .catch_up = spk_do_catch_up,
 115        .flush = synth_flush,
 116        .is_alive = spk_synth_is_alive_restart,
 117        .synth_adjust = NULL,
 118        .read_buff_add = NULL,
 119        .get_index = NULL,
 120        .indexing = {
 121                .command = NULL,
 122                .lowindex = 0,
 123                .highindex = 0,
 124                .currindex = 0,
 125        },
 126        .attributes = {
 127                .attrs = synth_attrs,
 128                .name = "audptr",
 129        },
 130};
 131
 132static void synth_flush(struct spk_synth *synth)
 133{
 134        int timeout = SPK_XMITR_TIMEOUT;
 135        while (spk_serial_tx_busy()) {
 136                if (!--timeout)
 137                        break;
 138                udelay(1);
 139        }
 140        outb(SYNTH_CLEAR, speakup_info.port_tts);
 141        spk_serial_out(PROCSPEECH);
 142}
 143
 144static void synth_version(struct spk_synth *synth)
 145{
 146        unsigned char test = 0;
 147        char synth_id[40] = "";
 148        spk_synth_immediate(synth, "\x05[Q]");
 149        synth_id[test] = spk_serial_in();
 150        if (synth_id[test] == 'A') {
 151                do {
 152                        /* read version string from synth */
 153                        synth_id[++test] = spk_serial_in();
 154                } while (synth_id[test] != '\n' && test < 32);
 155                synth_id[++test] = 0x00;
 156        }
 157        if (synth_id[0] == 'A')
 158                pr_info("%s version: %s", synth->long_name, synth_id);
 159}
 160
 161static int synth_probe(struct spk_synth *synth)
 162{
 163        int failed = 0;
 164
 165        failed = spk_serial_synth_probe(synth);
 166        if (failed == 0)
 167                synth_version(synth);
 168        synth->alive = !failed;
 169        return 0;
 170}
 171
 172module_param_named(ser, synth_audptr.ser, int, S_IRUGO);
 173module_param_named(start, synth_audptr.startup, short, S_IRUGO);
 174
 175MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 176MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 177
 178static int __init audptr_init(void)
 179{
 180        return synth_add(&synth_audptr);
 181}
 182
 183static void __exit audptr_exit(void)
 184{
 185        synth_remove(&synth_audptr);
 186}
 187
 188module_init(audptr_init);
 189module_exit(audptr_exit);
 190MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 191MODULE_AUTHOR("David Borowski");
 192MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
 193MODULE_LICENSE("GPL");
 194MODULE_VERSION(DRV_VERSION);
 195
 196