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