linux/drivers/accessibility/speakup/main.c

// SPDX-License-Identifier: GPL-2.0+
/* speakup.c
 * review functions for the speakup screen review package.
 * originally written by: Kirk Reiser and Andy Berdan.
 *
 * extensively modified by David Borowski.
 *
 ** Copyright (C) 1998  Kirk Reiser.
 *  Copyright (C) 2003  David Borowski.
 */

#include <linux/kernel.h>
#include <linux/vt.h>
#include <linux/tty.h>
#include <linux/mm.h>		/* __get_free_page() and friends */
#include <linux/vt_kern.h>
#include <linux/ctype.h>
#include <linux/selection.h>
#include <linux/unistd.h>
#include <linux/jiffies.h>
#include <linux/kthread.h>
#include <linux/keyboard.h>	/* for KT_SHIFT */
#include <linux/kbd_kern.h>	/* for vc_kbd_* and friends */
#include <linux/input.h>
#include <linux/kmod.h>

/* speakup_*_selection */
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/consolemap.h>

#include <linux/spinlock.h>
#include <linux/notifier.h>

#include <linux/uaccess.h>	/* copy_from|to|user() and others */

#include "spk_priv.h"
#include "speakup.h"

#define MAX_DELAY
#define MINECHOCHAR

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_VERSION();

char *synth_name;
module_param_named(synth, synth_name, charp, 0444);
module_param_named(quiet, spk_quiet_boot, bool, 0444);

MODULE_PARM_DESC();
MODULE_PARM_DESC();

special_func spk_special_handler;

short spk_pitch_shift, synth_flags;
static u16 buf[256];
int spk_attrib_bleep, spk_bleeps, spk_bleep_time =;
int spk_no_intr, spk_spell_delay;
int spk_key_echo, spk_say_word_ctl;
int spk_say_ctrl, spk_bell_pos;
short spk_punc_mask;
int spk_punc_level, spk_reading_punc;
int spk_cur_phonetic;
char spk_str_caps_start[MAXVARLEN + 1] =;
char spk_str_caps_stop[MAXVARLEN + 1] =;
char spk_str_pause[MAXVARLEN + 1] =;
bool spk_paused;
const struct st_bits_data spk_punc_info[] =;

static char mark_cut_flag;
#define MAX_KEY
static u_char *spk_shift_table;
u_char *spk_our_keys[MAX_KEY];
u_char spk_key_buf[600];
const u_char spk_key_defaults[] =;

/* cursor track modes, must be ordered same as cursor_msgs in enum msg_index_t */
enum cursor_track {};

/* Speakup Cursor Track Variables */
static enum cursor_track cursor_track =, prev_cursor_track =;

static struct tty_struct *tty;

static void spkup_write(const u16 *in_buf, int count);

static char *phonetic[] =;

/* array of 256 char pointers (one for each character description)
 * initialized to default_chars and user selectable via
 * /proc/speakup/characters
 */
char *spk_characters[256];

char *spk_default_chars[256] =;

/* array of 256 u_short (one for each character)
 * initialized to default_chartab and user selectable via
 * /sys/module/speakup/parameters/chartab
 */
u_short spk_chartab[256];

static u_short default_chartab[256] =;

struct task_struct *speakup_task;
struct bleep spk_unprocessed_sound;
static int spk_keydown;
static u16 spk_lastkey;
static u_char spk_close_press, keymap_flags;
static u_char last_keycode, this_speakup_key;
static u_long last_spk_jiffy;

struct st_spk_t *speakup_console[MAX_NR_CONSOLES];

DEFINE_MUTEX();

static int keyboard_notifier_call(struct notifier_block *,
				  unsigned long code, void *param);

static struct notifier_block keyboard_notifier_block =;

static int vt_notifier_call(struct notifier_block *,
			    unsigned long code, void *param);

static struct notifier_block vt_notifier_block =;

static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
{}

static void speakup_date(struct vc_data *vc)
{}

static void bleep(u_short val)
{}

static void speakup_shut_up(struct vc_data *vc)
{}

static void speech_kill(struct vc_data *vc)
{}

static void speakup_off(struct vc_data *vc)
{}

static void speakup_parked(struct vc_data *vc)
{}

static void speakup_cut(struct vc_data *vc)
{}

static void speakup_paste(struct vc_data *vc)
{}

static void say_attributes(struct vc_data *vc)
{}

/* must be ordered same as edge_msgs in enum msg_index_t */
enum edge {};

static void announce_edge(struct vc_data *vc, enum edge msg_id)
{}

static void speak_char(u16 ch)
{}

static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs)
{}

static void say_char(struct vc_data *vc)
{}

static void say_phonetic_char(struct vc_data *vc)
{}

static void say_prev_char(struct vc_data *vc)
{}

static void say_next_char(struct vc_data *vc)
{}

/* get_word - will first check to see if the character under the
 * reading cursor is a space and if spk_say_word_ctl is true it will
 * return the word space.  If spk_say_word_ctl is not set it will check to
 * see if there is a word starting on the next position to the right
 * and return that word if it exists.  If it does not exist it will
 * move left to the beginning of any previous word on the line or the
 * beginning off the line whichever comes first..
 */

static u_long get_word(struct vc_data *vc)
{}

static void say_word(struct vc_data *vc)
{}

static void say_prev_word(struct vc_data *vc)
{}

static void say_next_word(struct vc_data *vc)
{}

static void spell_word(struct vc_data *vc)
{}

static int get_line(struct vc_data *vc)
{}

static void say_line(struct vc_data *vc)
{}

static void say_prev_line(struct vc_data *vc)
{}

static void say_next_line(struct vc_data *vc)
{}

static int say_from_to(struct vc_data *vc, u_long from, u_long to,
		       int read_punc)
{}

static void say_line_from_to(struct vc_data *vc, u_long from, u_long to,
			     int read_punc)
{}

/* Sentence Reading Commands */

static int currsentence;
static int numsentences[2];
static u16 *sentbufend[2];
static u16 *sentmarks[2][10];
static int currbuf;
static int bn;
static u16 sentbuf[2][256];

static int say_sentence_num(int num, int prev)
{}

static int get_sentence_buf(struct vc_data *vc, int read_punc)
{}

static void say_screen_from_to(struct vc_data *vc, u_long from, u_long to)
{}

static void say_screen(struct vc_data *vc)
{}

static void speakup_win_say(struct vc_data *vc)
{}

static void top_edge(struct vc_data *vc)
{}

static void bottom_edge(struct vc_data *vc)
{}

static void left_edge(struct vc_data *vc)
{}

static void right_edge(struct vc_data *vc)
{}

static void say_first_char(struct vc_data *vc)
{}

static void say_last_char(struct vc_data *vc)
{}

static void say_position(struct vc_data *vc)
{}

/* Added by brianb */
static void say_char_num(struct vc_data *vc)
{}

/* these are stub functions to keep keyboard.c happy. */

static void say_from_top(struct vc_data *vc)
{}

static void say_to_bottom(struct vc_data *vc)
{}

static void say_from_left(struct vc_data *vc)
{}

static void say_to_right(struct vc_data *vc)
{}

/* end of stub functions. */

static void spkup_write(const u16 *in_buf, int count)
{}

static const int NUM_CTL_LABELS =;

static void read_all_doc(struct vc_data *vc);
static void cursor_done(struct timer_list *unused);
static DEFINE_TIMER(cursor_timer, cursor_done);

static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag)
{}

static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag)
{}

int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
{}

enum spk_vars_id {};

static struct var_t spk_vars[NB_ID] =;

static void toggle_cursoring(struct vc_data *vc)
{}

void spk_reset_default_chars(void)
{}

void spk_reset_default_chartab(void)
{}

static const struct st_bits_data *pb_edit;

static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key)
{}

/* Allocation concurrency is protected by the console semaphore */
static int speakup_allocate(struct vc_data *vc, gfp_t gfp_flags)
{}

static void speakup_deallocate(struct vc_data *vc)
{}

enum read_all_command {};

static u_char is_cursor;
static u_long old_cursor_pos, old_cursor_x, old_cursor_y;
static int cursor_con;

static void reset_highlight_buffers(struct vc_data *);

static enum read_all_command read_all_key;

static int in_keyboard_notifier;

static void start_read_all_timer(struct vc_data *vc, enum read_all_command command);

static void kbd_fakekey2(struct vc_data *vc, enum read_all_command command)
{}

static void read_all_doc(struct vc_data *vc)
{}

static void stop_read_all(struct vc_data *vc)
{}

static void start_read_all_timer(struct vc_data *vc, enum read_all_command command)
{}

static void handle_cursor_read_all(struct vc_data *vc, enum read_all_command command)
{}

static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
{}

static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
{}

static void update_color_buffer(struct vc_data *vc, const u16 *ic, int len)
{}

static void reset_highlight_buffers(struct vc_data *vc)
{}

static int count_highlight_color(struct vc_data *vc)
{}

static int get_highlight_color(struct vc_data *vc)
{}

static int speak_highlight(struct vc_data *vc)
{}

static void cursor_done(struct timer_list *unused)
{}

/* called by: vt_notifier_call() */
static void speakup_bs(struct vc_data *vc)
{}

/* called by: vt_notifier_call() */
static void speakup_con_write(struct vc_data *vc, u16 *str, int len)
{}

static void speakup_con_update(struct vc_data *vc)
{}

static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag)
{}

static int inc_dec_var(u_char value)
{}

static void speakup_win_set(struct vc_data *vc)
{}

static void speakup_win_clear(struct vc_data *vc)
{}

static void speakup_win_enable(struct vc_data *vc)
{}

static void speakup_bits(struct vc_data *vc)
{}

static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key)
{}

static void speakup_goto(struct vc_data *vc)
{}

static void speakup_help(struct vc_data *vc)
{}

static void do_nothing(struct vc_data *vc)
{}

static u_char key_speakup, spk_key_locked;

static void speakup_lock(struct vc_data *vc)
{}

spkup_hand;
static spkup_hand spkup_handler[] =;

static void do_spkup(struct vc_data *vc, u_char value)
{}

static const char *pad_chars =;

static int
speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
	    int up_flag)
{}

static int keyboard_notifier_call(struct notifier_block *nb,
				  unsigned long code, void *_param)
{}

static int vt_notifier_call(struct notifier_block *nb,
			    unsigned long code, void *_param)
{}

/* called by: module_exit() */
static void __exit speakup_exit(void)
{}

/* call by: module_init() */
static int __init speakup_init(void)
{}

module_param_named(bell_pos, spk_vars[BELL_POS_ID].u.n.default_val, int, 0444);
module_param_named(spell_delay, spk_vars[SPELL_DELAY_ID].u.n.default_val, int, 0444);
module_param_named(attrib_bleep, spk_vars[ATTRIB_BLEEP_ID].u.n.default_val, int, 0444);
module_param_named(bleeps, spk_vars[BLEEPS_ID].u.n.default_val, int, 0444);
module_param_named(bleep_time, spk_vars[BLEEP_TIME_ID].u.n.default_val, int, 0444);
module_param_named(punc_level, spk_vars[PUNC_LEVEL_ID].u.n.default_val, int, 0444);
module_param_named(reading_punc, spk_vars[READING_PUNC_ID].u.n.default_val, int, 0444);
module_param_named(cursor_time, spk_vars[CURSOR_TIME_ID].u.n.default_val, int, 0444);
module_param_named(say_control, spk_vars[SAY_CONTROL_ID].u.n.default_val, int, 0444);
module_param_named(say_word_ctl, spk_vars[SAY_WORD_CTL_ID].u.n.default_val, int, 0444);
module_param_named(no_interrupt, spk_vars[NO_INTERRUPT_ID].u.n.default_val, int, 0444);
module_param_named(key_echo, spk_vars[KEY_ECHO_ID].u.n.default_val, int, 0444);
module_param_named(cur_phonetic, spk_vars[CUR_PHONETIC_ID].u.n.default_val, int, 0444);

MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();

module_init();
module_exit(speakup_exit);