spk_types.h 5.9 KB

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