Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef SPEAKUP_TYPES_H
0003 #define SPEAKUP_TYPES_H
0004 
0005 /* This file includes all of the typedefs and structs used in speakup. */
0006 
0007 #include <linux/types.h>
0008 #include <linux/fs.h>
0009 #include <linux/errno.h>
0010 #include <linux/delay.h>
0011 #include <linux/wait.h>     /* for wait_queue */
0012 #include <linux/init.h>     /* for __init */
0013 #include <linux/module.h>
0014 #include <linux/vt_kern.h>
0015 #include <linux/spinlock.h>
0016 #include <linux/mutex.h>
0017 #include <linux/io.h>       /* for inb_p, outb_p, inb, outb, etc... */
0018 #include <linux/device.h>
0019 
0020 enum var_type_t {
0021     VAR_NUM = 0,
0022     VAR_TIME,
0023     VAR_STRING,
0024     VAR_PROC
0025 };
0026 
0027 enum {
0028     E_DEFAULT = 0,
0029     E_SET,
0030     E_INC,
0031     E_DEC,
0032     E_NEW_DEFAULT,
0033 };
0034 
0035 /*
0036  * Note: add new members at the end, speakupmap.h depends on the values of the
0037  * enum starting from SPELL_DELAY (see inc_dec_var)
0038  */
0039 enum var_id_t {
0040     VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT,
0041     KEYMAP, CHARS,
0042     PUNC_SOME, PUNC_MOST, PUNC_ALL,
0043     DELIM, REPEATS, EXNUMBER,
0044     DELAY, TRIGGER, JIFFY, FULL, /* all timers must be together */
0045     BLEEP_TIME, CURSOR_TIME, BELL_POS,
0046     SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO,
0047     SPELL_DELAY, PUNC_LEVEL, READING_PUNC,
0048     ATTRIB_BLEEP, BLEEPS,
0049     RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
0050     DIRECT, PAUSE,
0051     CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
0052     MAXVARS
0053 };
0054 
0055 typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch,
0056         u_short key);
0057 
0058 #define COLOR_BUFFER_SIZE 160
0059 
0060 struct spk_highlight_color_track {
0061     /* Count of each background color */
0062     unsigned int bgcount[8];
0063     /* Buffer for characters drawn with each background color */
0064     u16 highbuf[8][COLOR_BUFFER_SIZE];
0065     /* Current index into highbuf */
0066     unsigned int highsize[8];
0067     /* Reading Position for each color */
0068     u_long rpos[8], rx[8], ry[8];
0069     /* Real Cursor Y Position */
0070     ulong cy;
0071 };
0072 
0073 struct st_spk_t {
0074     u_long reading_x, cursor_x;
0075     u_long reading_y, cursor_y;
0076     u_long reading_pos, cursor_pos;
0077     u_long go_x, go_pos;
0078     u_long w_top, w_bottom, w_left, w_right;
0079     u_char w_start, w_enabled;
0080     u_char reading_attr, old_attr;
0081     char parked, shut_up;
0082     struct spk_highlight_color_track ht;
0083     int tty_stopped;
0084 };
0085 
0086 /* now some defines to make these easier to use. */
0087 #define spk_shut_up (speakup_console[vc->vc_num]->shut_up)
0088 #define spk_killed (speakup_console[vc->vc_num]->shut_up & 0x40)
0089 #define spk_x (speakup_console[vc->vc_num]->reading_x)
0090 #define spk_cx (speakup_console[vc->vc_num]->cursor_x)
0091 #define spk_y (speakup_console[vc->vc_num]->reading_y)
0092 #define spk_cy (speakup_console[vc->vc_num]->cursor_y)
0093 #define spk_pos (speakup_console[vc->vc_num]->reading_pos)
0094 #define spk_cp (speakup_console[vc->vc_num]->cursor_pos)
0095 #define goto_pos (speakup_console[vc->vc_num]->go_pos)
0096 #define goto_x (speakup_console[vc->vc_num]->go_x)
0097 #define win_top (speakup_console[vc->vc_num]->w_top)
0098 #define win_bottom (speakup_console[vc->vc_num]->w_bottom)
0099 #define win_left (speakup_console[vc->vc_num]->w_left)
0100 #define win_right (speakup_console[vc->vc_num]->w_right)
0101 #define win_start (speakup_console[vc->vc_num]->w_start)
0102 #define win_enabled (speakup_console[vc->vc_num]->w_enabled)
0103 #define spk_attr (speakup_console[vc->vc_num]->reading_attr)
0104 #define spk_old_attr (speakup_console[vc->vc_num]->old_attr)
0105 #define spk_parked (speakup_console[vc->vc_num]->parked)
0106 
0107 struct st_var_header {
0108     char *name;
0109     enum var_id_t var_id;
0110     enum var_type_t var_type;
0111     void *p_val; /* ptr to programs variable to store value */
0112     void *data;  /* ptr to the vars data */
0113 };
0114 
0115 struct num_var_t {
0116     char *synth_fmt;
0117     int default_val;
0118     int low;
0119     int high;
0120     short offset, multiplier; /* for fiddling rates etc. */
0121     char *out_str;  /* if synth needs char representation of number */
0122     int value;  /* current value */
0123 };
0124 
0125 struct punc_var_t {
0126     enum var_id_t var_id;
0127     short value;
0128 };
0129 
0130 struct string_var_t {
0131     char *default_val;
0132 };
0133 
0134 struct var_t {
0135     enum var_id_t var_id;
0136     union {
0137         struct num_var_t n;
0138         struct string_var_t s;
0139     } u;
0140 };
0141 
0142 struct st_bits_data { /* punc, repeats, word delim bits */
0143     char *name;
0144     char *value;
0145     short mask;
0146 };
0147 
0148 struct synth_indexing {
0149     char *command;
0150     unsigned char lowindex;
0151     unsigned char highindex;
0152     unsigned char currindex;
0153 };
0154 
0155 struct spk_synth;
0156 
0157 struct spk_io_ops {
0158     int (*synth_out)(struct spk_synth *synth, const char ch);
0159     int (*synth_out_unicode)(struct spk_synth *synth, u16 ch);
0160     void (*send_xchar)(struct spk_synth *synth, char ch);
0161     void (*tiocmset)(struct spk_synth *synth, unsigned int set, unsigned int clear);
0162     unsigned char (*synth_in)(struct spk_synth *synth);
0163     unsigned char (*synth_in_nowait)(struct spk_synth *synth);
0164     void (*flush_buffer)(struct spk_synth *synth);
0165     int (*wait_for_xmitr)(struct spk_synth *synth);
0166 };
0167 
0168 struct spk_synth {
0169     struct list_head node;
0170 
0171     const char *name;
0172     const char *version;
0173     const char *long_name;
0174     const char *init;
0175     char procspeech;
0176     char clear;
0177     int delay;
0178     int trigger;
0179     int jiffies;
0180     int full;
0181     int flush_time;
0182     int ser;
0183     char *dev_name;
0184     short flags;
0185     short startup;
0186     const int checkval; /* for validating a proper synth module */
0187     struct var_t *vars;
0188     int *default_pitch;
0189     int *default_vol;
0190     struct spk_io_ops *io_ops;
0191     int (*probe)(struct spk_synth *synth);
0192     void (*release)(struct spk_synth *synth);
0193     const char *(*synth_immediate)(struct spk_synth *synth,
0194                        const char *buff);
0195     void (*catch_up)(struct spk_synth *synth);
0196     void (*flush)(struct spk_synth *synth);
0197     int (*is_alive)(struct spk_synth *synth);
0198     int (*synth_adjust)(struct st_var_header *var);
0199     void (*read_buff_add)(u_char c);
0200     unsigned char (*get_index)(struct spk_synth *synth);
0201     struct synth_indexing indexing;
0202     int alive;
0203     struct attribute_group attributes;
0204 
0205     void *dev;
0206 };
0207 
0208 /*
0209  * module_spk_synth() - Helper macro for registering a speakup driver
0210  * @__spk_synth: spk_synth struct
0211  * Helper macro for speakup drivers which do not do anything special in module
0212  * init/exit. This eliminates a lot of boilerplate. Each module may only
0213  * use this macro once, and calling it replaces module_init() and module_exit()
0214  */
0215 #define module_spk_synth(__spk_synth) \
0216     module_driver(__spk_synth, synth_add, synth_remove)
0217 
0218 struct speakup_info_t {
0219     spinlock_t spinlock;
0220     int port_tts;
0221     int flushing;
0222 };
0223 
0224 struct bleep {
0225     short freq;
0226     unsigned long jiffies;
0227     int active;
0228 };
0229 #endif