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