^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * written by: Kirk Reiser <kirk@braille.uwo.ca>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * this version considerably modified by David Borowski, david575@rogers.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 1998-99 Kirk Reiser.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2003 David Borowski.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * this code is specificly written as a driver for the speakup screenreview
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * package and is not a general device driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * This driver is for the Aicom Acent PC internal synthesizer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "spk_priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "serialio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "speakup.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "speakup_acnt.h" /* local header file for Accent values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define DRV_VERSION "2.10"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define PROCSPEECH '\r'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int synth_probe(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static void accent_release(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static const char *synth_immediate(struct spk_synth *synth, const char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static void do_catch_up(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static void synth_flush(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static int synth_port_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static int port_forced;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static unsigned int synth_portlist[] = { 0x2a8, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static struct var_t vars[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) { CAPS_START, .u.s = {"\033P8" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) { CAPS_STOP, .u.s = {"\033P5" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) { VOL, .u.n = {"\033A%d", 5, 0, 9, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) V_LAST_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * These attributes will appear in /sys/accessibility/speakup/acntpc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static struct kobj_attribute caps_start_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static struct kobj_attribute caps_stop_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static struct kobj_attribute pitch_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) __ATTR(pitch, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static struct kobj_attribute rate_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) __ATTR(rate, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static struct kobj_attribute tone_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) __ATTR(tone, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static struct kobj_attribute vol_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) __ATTR(vol, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static struct kobj_attribute delay_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static struct kobj_attribute direct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) __ATTR(direct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) static struct kobj_attribute full_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) __ATTR(full_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static struct kobj_attribute jiffy_delta_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static struct kobj_attribute trigger_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * Create a group of attributes so that we can create and destroy them all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static struct attribute *synth_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) &caps_start_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) &caps_stop_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) &pitch_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) &rate_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) &tone_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) &vol_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) &delay_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) &direct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) &full_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) &jiffy_delta_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) &trigger_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) NULL, /* need to NULL terminate the list of attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static struct spk_synth synth_acntpc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .name = "acntpc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .version = DRV_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .long_name = "Accent PC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .init = "\033=X \033Oi\033T2\033=M\033N1\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .procspeech = PROCSPEECH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .clear = SYNTH_CLEAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .delay = 500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .trigger = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .jiffies = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .full = 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .startup = SYNTH_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .checkval = SYNTH_CHECK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .vars = vars,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .io_ops = &spk_serial_io_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .probe = synth_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .release = accent_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .synth_immediate = synth_immediate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .catch_up = do_catch_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .flush = synth_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) .is_alive = spk_synth_is_alive_nop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) .synth_adjust = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .read_buff_add = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .get_index = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .indexing = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) .command = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .lowindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) .highindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) .currindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) .attributes = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .attrs = synth_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .name = "acntpc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static inline bool synth_writable(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return inb_p(synth_port_control) & SYNTH_WRITABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline bool synth_full(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return inb_p(speakup_info.port_tts + UART_RX) == 'F';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static const char *synth_immediate(struct spk_synth *synth, const char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) u_char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) while ((ch = *buf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int timeout = SPK_XMITR_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (ch == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ch = PROCSPEECH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (synth_full())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) while (synth_writable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (!--timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) udelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) outb_p(ch, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) buf++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static void do_catch_up(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) u_char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned long jiff_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int delay_time_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int full_time_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct var_t *delay_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct var_t *full_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct var_t *jiffy_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) jiffy_delta = spk_get_var(JIFFY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) delay_time = spk_get_var(DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) full_time = spk_get_var(FULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) jiffy_delta_val = jiffy_delta->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) jiff_max = jiffies + jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) while (!kthread_should_stop()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (speakup_info.flushing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) speakup_info.flushing = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) synth->flush(synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) synth_buffer_skip_nonlatin1();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (synth_buffer_empty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) set_current_state(TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) full_time_val = full_time->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (synth_full()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) schedule_timeout(msecs_to_jiffies(full_time_val));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) set_current_state(TASK_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) timeout = SPK_XMITR_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) while (synth_writable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (!--timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) udelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ch = synth_buffer_getc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (ch == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ch = PROCSPEECH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) outb_p(ch, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (time_after_eq(jiffies, jiff_max) && ch == SPACE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) timeout = SPK_XMITR_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) while (synth_writable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (!--timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) udelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) outb_p(PROCSPEECH, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) jiffy_delta_val = jiffy_delta->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) delay_time_val = delay_time->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) schedule_timeout(msecs_to_jiffies(delay_time_val));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) jiff_max = jiffies + jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) timeout = SPK_XMITR_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) while (synth_writable()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (!--timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) udelay(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) outb_p(PROCSPEECH, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static void synth_flush(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) outb_p(SYNTH_CLEAR, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static int synth_probe(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned int port_val = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) pr_info("Probing for %s.\n", synth->long_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (port_forced) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) speakup_info.port_tts = port_forced;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) pr_info("probe forced to %x by kernel command line\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) if (synth_request_region(speakup_info.port_tts - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) SYNTH_IO_EXTENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) pr_warn("sorry, port already reserved\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) port_val = inw(speakup_info.port_tts - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) synth_port_control = speakup_info.port_tts - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) for (i = 0; synth_portlist[i]; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) if (synth_request_region(synth_portlist[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) SYNTH_IO_EXTENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) pr_warn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ("request_region: failed with 0x%x, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) synth_portlist[i], SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) port_val = inw(synth_portlist[i]) & 0xfffc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (port_val == 0x53fc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /* 'S' and out&input bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) synth_port_control = synth_portlist[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) speakup_info.port_tts = synth_port_control + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) port_val &= 0xfffc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (port_val != 0x53fc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /* 'S' and out&input bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) pr_info("%s: not found\n", synth->long_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) synth_release_region(synth_port_control, SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) synth_port_control = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) synth_port_control, synth_port_control + SYNTH_IO_EXTENT - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) synth->version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) synth->alive = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) static void accent_release(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) spk_stop_serial_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (speakup_info.port_tts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) synth_release_region(speakup_info.port_tts - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) speakup_info.port_tts = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) module_param_hw_named(port, port_forced, int, ioport, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) module_param_named(start, synth_acntpc.startup, short, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) module_spk_synth(synth_acntpc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) MODULE_AUTHOR("David Borowski");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) MODULE_DESCRIPTION("Speakup support for Accent PC synthesizer");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) MODULE_VERSION(DRV_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)