Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  * This is the DECtalk PC speakup driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Some constants from DEC's DOS driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *      Copyright (c) by Digital Equipment Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * 386BSD DECtalk PC driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *      Copyright (c) 1996 Brian Buhrow <buhrow@lothlorien.nfbcal.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Linux DECtalk PC driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *      Copyright (c) 1997 Nicolas Pitre <nico@cam.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * speakup DECtalk PC Internal driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *      Copyright (c) 2003 David Borowski <david575@golden.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "spk_priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "speakup.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define	MODULE_init		0x0dec	/* module in boot code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define	MODULE_self_test	0x8800	/* module in self-test */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define	MODULE_reset		0xffff	/* reinit the whole module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define	MODE_mask		0xf000	/* mode bits in high nibble */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define	MODE_null		0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define	MODE_test		0x2000	/* in testing mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define	MODE_status		0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define	STAT_int		0x0001	/* running in interrupt mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define	STAT_tr_char		0x0002	/* character data to transmit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define	STAT_rr_char		0x0004	/* ready to receive char data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define	STAT_cmd_ready		0x0008	/* ready to accept commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define	STAT_dma_ready		0x0010	/* dma command ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define	STAT_digitized		0x0020	/* spc in digitized mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define	STAT_new_index		0x0040	/* new last index ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define	STAT_new_status		0x0080	/* new status posted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define	STAT_dma_state		0x0100	/* dma state toggle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define	STAT_index_valid	0x0200	/* indexs are valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define	STAT_flushing		0x0400	/* flush in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define	STAT_self_test		0x0800	/* module in self test */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define	MODE_ready		0xc000	/* module ready for next phase */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define	READY_boot		0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define	READY_kernel		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define	MODE_error		0xf000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define	CMD_mask		0xf000	/* mask for command nibble */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define	CMD_null		0x0000	/* post status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define	CMD_control		0x1000	/* hard control command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define	CTRL_mask		0x0F00	/* mask off control nibble */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define	CTRL_data		0x00FF	/* mask to get data byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define	CTRL_null		0x0000	/* null control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define	CTRL_vol_up		0x0100	/* increase volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define	CTRL_vol_down		0x0200	/* decrease volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define	CTRL_vol_set		0x0300	/* set volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define	CTRL_pause		0x0400	/* pause spc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define	CTRL_resume		0x0500	/* resume spc clock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define	CTRL_resume_spc		0x0001	/* resume spc soft pause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define	CTRL_flush		0x0600	/* flush all buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define	CTRL_int_enable		0x0700	/* enable status change ints */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define	CTRL_buff_free		0x0800	/* buffer remain count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define	CTRL_buff_used		0x0900	/* buffer in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define	CTRL_speech		0x0a00	/* immediate speech change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define	CTRL_SP_voice		0x0001	/* voice change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define	CTRL_SP_rate		0x0002	/* rate change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define	CTRL_SP_comma		0x0003	/* comma pause change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define	CTRL_SP_period		0x0004	/* period pause change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define	CTRL_SP_rate_delta	0x0005	/* delta rate change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define	CTRL_SP_get_param	0x0006	/* return the desired parameter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define	CTRL_last_index		0x0b00	/* get last index spoken */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define	CTRL_io_priority	0x0c00	/* change i/o priority */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #define	CTRL_free_mem		0x0d00	/* get free paragraphs on module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define	CTRL_get_lang		0x0e00	/* return bitmask of loaded languages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define	CMD_test		0x2000	/* self-test request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define	TEST_mask		0x0F00	/* isolate test field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define	TEST_null		0x0000	/* no test requested */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define	TEST_isa_int		0x0100	/* assert isa irq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define	TEST_echo		0x0200	/* make data in == data out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define	TEST_seg		0x0300	/* set peek/poke segment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define	TEST_off		0x0400	/* set peek/poke offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) #define	TEST_peek		0x0500	/* data out == *peek */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define	TEST_poke		0x0600	/* *peek == data in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #define	TEST_sub_code		0x00FF	/* user defined test sub codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define	CMD_id			0x3000	/* return software id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define	ID_null			0x0000	/* null id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define	ID_kernel		0x0100	/* kernel code executing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define	ID_boot			0x0200	/* boot code executing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #define	CMD_dma			0x4000	/* force a dma start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define	CMD_reset		0x5000	/* reset module status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #define	CMD_sync		0x6000	/* kernel sync command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define	CMD_char_in		0x7000	/* single character send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define	CMD_char_out		0x8000	/* single character get */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #define	CHAR_count_1		0x0100	/* one char in cmd_low */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define	CHAR_count_2		0x0200	/* the second in data_low */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define	CHAR_count_3		0x0300	/* the third in data_high */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define	CMD_spc_mode		0x9000	/* change spc mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define	CMD_spc_to_text		0x0100	/* set to text mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define	CMD_spc_to_digit	0x0200	/* set to digital mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define	CMD_spc_rate		0x0400	/* change spc data rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define	CMD_error		0xf000	/* severe error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) enum {	PRIMARY_DIC	= 0, USER_DIC, COMMAND_DIC, ABBREV_DIC };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define	DMA_single_in		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define	DMA_single_out		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define	DMA_buff_in		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define	DMA_buff_out		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define	DMA_control		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define	DT_MEM_ALLOC		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define	DT_SET_DIC		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define	DT_START_TASK		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define	DT_LOAD_MEM		0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define	DT_READ_MEM		0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define	DT_DIGITAL_IN		0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define	DMA_sync		0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define	DMA_sync_char		0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define DRV_VERSION "2.12"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define PROCSPEECH 0x0b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define SYNTH_IO_EXTENT 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int synth_probe(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static void dtpc_release(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static const char *synth_immediate(struct spk_synth *synth, const char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void do_catch_up(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void synth_flush(struct spk_synth *synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static int synth_portlist[] = { 0x340, 0x350, 0x240, 0x250, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static int in_escape, is_flushing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static int dt_stat, dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static struct var_t vars[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	{ CAPS_START, .u.s = {"[:dv ap 200]" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	{ CAPS_STOP, .u.s = {"[:dv ap 100]" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	{ RATE, .u.n = {"[:ra %d]", 9, 0, 18, 150, 25, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	{ PITCH, .u.n = {"[:dv ap %d]", 80, 0, 100, 20, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{ INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{ VOL, .u.n = {"[:vo se %d]", 5, 0, 9, 5, 10, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	{ PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	{ VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	V_LAST_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * These attributes will appear in /sys/accessibility/speakup/decpc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static struct kobj_attribute caps_start_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	__ATTR(caps_start, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static struct kobj_attribute caps_stop_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	__ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static struct kobj_attribute pitch_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	__ATTR(pitch, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static struct kobj_attribute inflection_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	__ATTR(inflection, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static struct kobj_attribute punct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	__ATTR(punct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static struct kobj_attribute rate_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	__ATTR(rate, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static struct kobj_attribute voice_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	__ATTR(voice, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static struct kobj_attribute vol_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	__ATTR(vol, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static struct kobj_attribute delay_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	__ATTR(delay_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static struct kobj_attribute direct_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	__ATTR(direct, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static struct kobj_attribute full_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	__ATTR(full_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static struct kobj_attribute jiffy_delta_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	__ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static struct kobj_attribute trigger_time_attribute =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	__ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * Create a group of attributes so that we can create and destroy them all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static struct attribute *synth_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	&caps_start_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	&caps_stop_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	&pitch_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	&inflection_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	&punct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	&rate_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	&voice_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	&vol_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	&delay_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	&direct_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	&full_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	&jiffy_delta_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	&trigger_time_attribute.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	NULL,	/* need to NULL terminate the list of attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static struct spk_synth synth_dec_pc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	.name = "decpc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	.version = DRV_VERSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	.long_name = "Dectalk PC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	.init = "[:pe -380]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	.procspeech = PROCSPEECH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	.delay = 500,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	.trigger = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	.jiffies = 50,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	.full = 1000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.flags = SF_DEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.startup = SYNTH_START,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.checkval = SYNTH_CHECK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.vars = vars,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.io_ops = &spk_serial_io_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.probe = synth_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.release = dtpc_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.synth_immediate = synth_immediate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.catch_up = do_catch_up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.flush = synth_flush,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	.is_alive = spk_synth_is_alive_nop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	.synth_adjust = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	.read_buff_add = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	.get_index = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	.indexing = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		.command = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		.lowindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		.highindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		.currindex = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	.attributes = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		.attrs = synth_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		.name = "decpc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static int dt_getstatus(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	dt_stat = inb_p(speakup_info.port_tts) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		 (inb_p(speakup_info.port_tts + 1) << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return dt_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void dt_sendcmd(u_int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	outb_p(cmd & 0xFF, speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	outb_p((cmd >> 8) & 0xFF, speakup_info.port_tts + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static int dt_waitbit(int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	int timeout = 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	while (--timeout > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		if ((dt_getstatus() & bit) == bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		udelay(50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static int dt_wait_dma(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	int timeout = 100, state = dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (!dt_waitbit(STAT_dma_ready))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	while (--timeout > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		if ((dt_getstatus() & STAT_dma_state) == state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		udelay(50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	dma_state = dt_getstatus() & STAT_dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static int dt_ctrl(u_int cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	int timeout = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	if (!dt_waitbit(STAT_cmd_ready))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	outb_p(0, speakup_info.port_tts + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	outb_p(0, speakup_info.port_tts + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	dt_getstatus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	dt_sendcmd(CMD_control | cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	outb_p(0, speakup_info.port_tts + 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	while (dt_getstatus() & STAT_cmd_ready) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		udelay(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		if (--timeout == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	dt_sendcmd(CMD_null);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static void synth_flush(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	int timeout = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (is_flushing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	is_flushing = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	in_escape = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	while (dt_ctrl(CTRL_flush)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		if (--timeout == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		udelay(50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	for (timeout = 0; timeout < 10; timeout++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		if (dt_waitbit(STAT_dma_ready))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		udelay(50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	outb_p(DMA_sync, speakup_info.port_tts + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	outb_p(0, speakup_info.port_tts + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	udelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	for (timeout = 0; timeout < 10; timeout++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		if (!(dt_getstatus() & STAT_flushing))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		udelay(50);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	dma_state = dt_getstatus() & STAT_dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	dma_state ^= STAT_dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	is_flushing = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static int dt_sendchar(char ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	if (!dt_wait_dma())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	if (!(dt_stat & STAT_rr_char))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	outb_p(DMA_single_in, speakup_info.port_tts + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	outb_p(ch, speakup_info.port_tts + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	dma_state ^= STAT_dma_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static int testkernel(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	if (dt_getstatus() == 0xffff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		status = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		goto oops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	dt_sendcmd(CMD_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	if (!dt_waitbit(STAT_cmd_ready))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		status = -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	else if (dt_stat & 0x8000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	else if (dt_stat == 0x0dec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		pr_warn("dec_pc at 0x%x, software not loaded\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			speakup_info.port_tts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	status = -3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) oops:	synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	speakup_info.port_tts = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static void do_catch_up(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	u_char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	static u_char last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	unsigned long jiff_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	struct var_t *jiffy_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	struct var_t *delay_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	int jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	int delay_time_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	jiffy_delta = spk_get_var(JIFFY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	delay_time = spk_get_var(DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	jiffy_delta_val = jiffy_delta->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	jiff_max = jiffies + jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	while (!kthread_should_stop()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		if (speakup_info.flushing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			speakup_info.flushing = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			synth->flush(synth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		synth_buffer_skip_nonlatin1();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		if (synth_buffer_empty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		ch = synth_buffer_peek();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		set_current_state(TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		delay_time_val = delay_time->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		if (ch == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			ch = 0x0D;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		if (dt_sendchar(ch)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 			schedule_timeout(msecs_to_jiffies(delay_time_val));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		set_current_state(TASK_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		spin_lock_irqsave(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		synth_buffer_getc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		if (ch == '[') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 			in_escape = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		} else if (ch == ']') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			in_escape = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		} else if (ch <= SPACE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 			if (!in_escape && strchr(",.!?;:", last))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 				dt_sendchar(PROCSPEECH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			if (time_after_eq(jiffies, jiff_max)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 				if (!in_escape)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 					dt_sendchar(PROCSPEECH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 				spin_lock_irqsave(&speakup_info.spinlock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 						  flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 				jiffy_delta_val = jiffy_delta->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 				delay_time_val = delay_time->u.n.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 				spin_unlock_irqrestore(&speakup_info.spinlock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 						       flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 				schedule_timeout(msecs_to_jiffies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 						 (delay_time_val));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 				jiff_max = jiffies + jiffy_delta_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		last = ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		ch = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	if (!in_escape)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		dt_sendchar(PROCSPEECH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) static const char *synth_immediate(struct spk_synth *synth, const char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	u_char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	while ((ch = *buf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		if (ch == '\n')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 			ch = PROCSPEECH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		if (dt_sendchar(ch))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 			return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		buf++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static int synth_probe(struct spk_synth *synth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	int i = 0, failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	pr_info("Probing for %s.\n", synth->long_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	for (i = 0; synth_portlist[i]; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		if (synth_request_region(synth_portlist[i], SYNTH_IO_EXTENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			pr_warn("request_region: failed with 0x%x, %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 				synth_portlist[i], SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		speakup_info.port_tts = synth_portlist[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		failed = testkernel();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		if (failed == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	if (failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		pr_info("%s: not found\n", synth->long_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	pr_info("%s: %03x-%03x, Driver Version %s,\n", synth->long_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		speakup_info.port_tts, speakup_info.port_tts + 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		synth->version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	synth->alive = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static void dtpc_release(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	spk_stop_serial_interrupt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	if (speakup_info.port_tts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	speakup_info.port_tts = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) module_param_named(start, synth_dec_pc.startup, short, 0444);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) module_spk_synth(synth_dec_pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) MODULE_AUTHOR("David Borowski");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) MODULE_DESCRIPTION("Speakup support for DECtalk PC synthesizers");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) MODULE_VERSION(DRV_VERSION);