• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef SPEAKUP_TYPES_H
3 #define SPEAKUP_TYPES_H
4 
5 /* This file includes all of the typedefs and structs used in speakup. */
6 
7 #include <linux/types.h>
8 #include <linux/fs.h>
9 #include <linux/errno.h>
10 #include <linux/delay.h>
11 #include <linux/wait.h>		/* for wait_queue */
12 #include <linux/init.h>		/* for __init */
13 #include <linux/module.h>
14 #include <linux/vt_kern.h>
15 #include <linux/spinlock.h>
16 #include <linux/mutex.h>
17 #include <linux/io.h>		/* for inb_p, outb_p, inb, outb, etc... */
18 #include <linux/device.h>
19 
20 enum var_type_t {
21 	VAR_NUM = 0,
22 	VAR_TIME,
23 	VAR_STRING,
24 	VAR_PROC
25 };
26 
27 enum {
28 	E_DEFAULT = 0,
29 	E_SET,
30 	E_INC,
31 	E_DEC,
32 	E_NEW_DEFAULT,
33 };
34 
35 /*
36  * Note: add new members at the end, speakupmap.h depends on the values of the
37  * enum starting from SPELL_DELAY (see inc_dec_var)
38  */
39 enum var_id_t {
40 	VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT,
41 	KEYMAP, CHARS,
42 	PUNC_SOME, PUNC_MOST, PUNC_ALL,
43 	DELIM, REPEATS, EXNUMBER,
44 	DELAY, TRIGGER, JIFFY, FULL, /* all timers must be together */
45 	BLEEP_TIME, CURSOR_TIME, BELL_POS,
46 	SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
47 	SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
48 	ATTRIB_BLEEP, BLEEPS,
49 	RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
50 	DIRECT, PAUSE,
51 	CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
52 	MAXVARS
53 };
54 
55 typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch,
56 		u_short key);
57 
58 #define COLOR_BUFFER_SIZE 160
59 
60 struct spk_highlight_color_track {
61 	/* Count of each background color */
62 	unsigned int bgcount[8];
63 	/* Buffer for characters drawn with each background color */
64 	u16 highbuf[8][COLOR_BUFFER_SIZE];
65 	/* Current index into highbuf */
66 	unsigned int highsize[8];
67 	/* Reading Position for each color */
68 	u_long rpos[8], rx[8], ry[8];
69 	/* Real Cursor Y Position */
70 	ulong cy;
71 };
72 
73 struct st_spk_t {
74 	u_long reading_x, cursor_x;
75 	u_long reading_y, cursor_y;
76 	u_long reading_pos, cursor_pos;
77 	u_long go_x, go_pos;
78 	u_long w_top, w_bottom, w_left, w_right;
79 	u_char w_start, w_enabled;
80 	u_char reading_attr, old_attr;
81 	char parked, shut_up;
82 	struct spk_highlight_color_track ht;
83 	int tty_stopped;
84 };
85 
86 /* now some defines to make these easier to use. */
87 #define spk_shut_up (speakup_console[vc->vc_num]->shut_up)
88 #define spk_killed (speakup_console[vc->vc_num]->shut_up & 0x40)
89 #define spk_x (speakup_console[vc->vc_num]->reading_x)
90 #define spk_cx (speakup_console[vc->vc_num]->cursor_x)
91 #define spk_y (speakup_console[vc->vc_num]->reading_y)
92 #define spk_cy (speakup_console[vc->vc_num]->cursor_y)
93 #define spk_pos (speakup_console[vc->vc_num]->reading_pos)
94 #define spk_cp (speakup_console[vc->vc_num]->cursor_pos)
95 #define goto_pos (speakup_console[vc->vc_num]->go_pos)
96 #define goto_x (speakup_console[vc->vc_num]->go_x)
97 #define win_top (speakup_console[vc->vc_num]->w_top)
98 #define win_bottom (speakup_console[vc->vc_num]->w_bottom)
99 #define win_left (speakup_console[vc->vc_num]->w_left)
100 #define win_right (speakup_console[vc->vc_num]->w_right)
101 #define win_start (speakup_console[vc->vc_num]->w_start)
102 #define win_enabled (speakup_console[vc->vc_num]->w_enabled)
103 #define spk_attr (speakup_console[vc->vc_num]->reading_attr)
104 #define spk_old_attr (speakup_console[vc->vc_num]->old_attr)
105 #define spk_parked (speakup_console[vc->vc_num]->parked)
106 
107 struct st_var_header {
108 	char *name;
109 	enum var_id_t var_id;
110 	enum var_type_t var_type;
111 	void *p_val; /* ptr to programs variable to store value */
112 	void *data;  /* ptr to the vars data */
113 };
114 
115 struct num_var_t {
116 	char *synth_fmt;
117 	int default_val;
118 	int low;
119 	int high;
120 	short offset, multiplier; /* for fiddling rates etc. */
121 	char *out_str;  /* if synth needs char representation of number */
122 	int value;	/* current value */
123 };
124 
125 struct punc_var_t {
126 	enum var_id_t var_id;
127 	short value;
128 };
129 
130 struct string_var_t {
131 	char *default_val;
132 };
133 
134 struct var_t {
135 	enum var_id_t var_id;
136 	union {
137 		struct num_var_t n;
138 		struct string_var_t s;
139 	} u;
140 };
141 
142 struct st_bits_data { /* punc, repeats, word delim bits */
143 	char *name;
144 	char *value;
145 	short mask;
146 };
147 
148 struct synth_indexing {
149 	char *command;
150 	unsigned char lowindex;
151 	unsigned char highindex;
152 	unsigned char currindex;
153 };
154 
155 struct spk_synth;
156 
157 struct spk_io_ops {
158 	int (*synth_out)(struct spk_synth *synth, const char ch);
159 	int (*synth_out_unicode)(struct spk_synth *synth, u16 ch);
160 	void (*send_xchar)(struct spk_synth *synth, char ch);
161 	void (*tiocmset)(struct spk_synth *synth, unsigned int set, unsigned int clear);
162 	unsigned char (*synth_in)(struct spk_synth *synth);
163 	unsigned char (*synth_in_nowait)(struct spk_synth *synth);
164 	void (*flush_buffer)(struct spk_synth *synth);
165 	int (*wait_for_xmitr)(struct spk_synth *synth);
166 };
167 
168 struct spk_synth {
169 	struct list_head node;
170 
171 	const char *name;
172 	const char *version;
173 	const char *long_name;
174 	const char *init;
175 	char procspeech;
176 	char clear;
177 	int delay;
178 	int trigger;
179 	int jiffies;
180 	int full;
181 	int flush_time;
182 	int ser;
183 	char *dev_name;
184 	short flags;
185 	short startup;
186 	const int checkval; /* for validating a proper synth module */
187 	struct var_t *vars;
188 	int *default_pitch;
189 	int *default_vol;
190 	struct spk_io_ops *io_ops;
191 	int (*probe)(struct spk_synth *synth);
192 	void (*release)(struct spk_synth *synth);
193 	const char *(*synth_immediate)(struct spk_synth *synth,
194 				       const char *buff);
195 	void (*catch_up)(struct spk_synth *synth);
196 	void (*flush)(struct spk_synth *synth);
197 	int (*is_alive)(struct spk_synth *synth);
198 	int (*synth_adjust)(struct st_var_header *var);
199 	void (*read_buff_add)(u_char c);
200 	unsigned char (*get_index)(struct spk_synth *synth);
201 	struct synth_indexing indexing;
202 	int alive;
203 	struct attribute_group attributes;
204 
205 	void *dev;
206 };
207 
208 /*
209  * module_spk_synth() - Helper macro for registering a speakup driver
210  * @__spk_synth: spk_synth struct
211  * Helper macro for speakup drivers which do not do anything special in module
212  * init/exit. This eliminates a lot of boilerplate. Each module may only
213  * use this macro once, and calling it replaces module_init() and module_exit()
214  */
215 #define module_spk_synth(__spk_synth) \
216 	module_driver(__spk_synth, synth_add, synth_remove)
217 
218 struct speakup_info_t {
219 	spinlock_t spinlock;
220 	int port_tts;
221 	int flushing;
222 };
223 
224 struct bleep {
225 	short freq;
226 	unsigned long jiffies;
227 	int active;
228 };
229 #endif
230