1c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs/*
2c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
3c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * this version considerably modified by David Borowski, david575@rogers.com
4c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * eventually modified by Samuel Thibault <samuel.thibault@ens-lyon.org>
5c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs *
6c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * Copyright (C) 1998-99  Kirk Reiser.
7c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * Copyright (C) 2003 David Borowski.
8c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * Copyright (C) 2007 Samuel Thibault.
9c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs *
10c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * This program is free software; you can redistribute it and/or modify
11c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * it under the terms of the GNU General Public License as published by
12c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * the Free Software Foundation; either version 2 of the License, or
13c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * (at your option) any later version.
14c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs *
15c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * This program is distributed in the hope that it will be useful,
16c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * but WITHOUT ANY WARRANTY; without even the implied warranty of
17c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * GNU General Public License for more details.
19c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs *
20c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * You should have received a copy of the GNU General Public License
21c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * along with this program; if not, write to the Free Software
22c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs *
24c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * specificly written as a driver for the speakup screenreview
25c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * s not a general device driver.
26c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs */
27c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs#include "spk_priv.h"
28c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs#include "speakup.h"
29c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
30c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs#define PROCSPEECH '\n'
31c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs#define DRV_VERSION "2.11"
32c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs#define SYNTH_CLEAR '!'
33c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
34c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct var_t vars[] = {
359d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ CAPS_START, .u.s = {"CAPS_START\n" } },
369d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ CAPS_STOP, .u.s = {"CAPS_STOP\n" } },
379d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } },
389d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } },
399d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
409d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
419d096afa060935f1ecf04ef2d7534e0b0d94ac9dChristopher Brannon	{ DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
42c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	V_LAST_VAR
43c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs};
44c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
45c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs/*
46c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * These attributes will appear in /sys/accessibility/speakup/dummy.
47c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs */
48c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute caps_start_attribute =
49c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(caps_start, USER_RW, spk_var_show, spk_var_store);
50c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute caps_stop_attribute =
51c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(caps_stop, USER_RW, spk_var_show, spk_var_store);
52c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute pitch_attribute =
53c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(pitch, USER_RW, spk_var_show, spk_var_store);
54c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute rate_attribute =
55c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(rate, USER_RW, spk_var_show, spk_var_store);
56c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute tone_attribute =
57c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(tone, USER_RW, spk_var_show, spk_var_store);
58c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute vol_attribute =
59c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(vol, USER_RW, spk_var_show, spk_var_store);
60c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
61c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute delay_time_attribute =
62c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(delay_time, ROOT_W, spk_var_show, spk_var_store);
63c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute direct_attribute =
64c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(direct, USER_RW, spk_var_show, spk_var_store);
65c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute full_time_attribute =
66c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(full_time, ROOT_W, spk_var_show, spk_var_store);
67c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute jiffy_delta_attribute =
68c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(jiffy_delta, ROOT_W, spk_var_show, spk_var_store);
69c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct kobj_attribute trigger_time_attribute =
70c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	__ATTR(trigger_time, ROOT_W, spk_var_show, spk_var_store);
71c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
72c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs/*
73c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * Create a group of attributes so that we can create and destroy them all
74c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs * at once.
75c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs */
76c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct attribute *synth_attrs[] = {
77c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&caps_start_attribute.attr,
78c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&caps_stop_attribute.attr,
79c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&pitch_attribute.attr,
80c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&rate_attribute.attr,
81c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&tone_attribute.attr,
82c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&vol_attribute.attr,
83c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&delay_time_attribute.attr,
84c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&direct_attribute.attr,
85c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&full_time_attribute.attr,
86c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&jiffy_delta_attribute.attr,
87c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	&trigger_time_attribute.attr,
88c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	NULL,	/* need to NULL terminate the list of attributes */
89c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs};
90c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
91c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic struct spk_synth synth_dummy = {
92c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.name = "dummy",
93c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.version = DRV_VERSION,
94c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.long_name = "Dummy",
95c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.init = "Speakup\n",
96c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.procspeech = PROCSPEECH,
97c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.clear = SYNTH_CLEAR,
98c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.delay = 500,
99c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.trigger = 50,
100c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.jiffies = 50,
101c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.full = 40000,
102c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.startup = SYNTH_START,
103c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.checkval = SYNTH_CHECK,
104c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.vars = vars,
105c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.probe = serial_synth_probe,
106c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.release = spk_serial_release,
107c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.synth_immediate = spk_synth_immediate,
108c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.catch_up = spk_do_catch_up,
109c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.flush = spk_synth_flush,
110c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.is_alive = spk_synth_is_alive_restart,
111c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.synth_adjust = NULL,
112c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.read_buff_add = NULL,
113c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.get_index = NULL,
114c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.indexing = {
115c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.command = NULL,
116c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.lowindex = 0,
117c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.highindex = 0,
118c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.currindex = 0,
119c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	},
120c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	.attributes = {
121c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.attrs = synth_attrs,
122c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs		.name = "dummy",
123c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	},
124c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs};
125c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
126c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsmodule_param_named(ser, synth_dummy.ser, int, S_IRUGO);
127c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsmodule_param_named(start, synth_dummy.startup, short, S_IRUGO);
128c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
129c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
130c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
131c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
132c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic int __init dummy_init(void)
133c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs{
134c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	return synth_add(&synth_dummy);
135c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs}
136c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
137c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsstatic void __exit dummy_exit(void)
138c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs{
139c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs	synth_remove(&synth_dummy);
140c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs}
141c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
142c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsmodule_init(dummy_init);
143c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbsmodule_exit(dummy_exit);
144c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>");
145c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_DESCRIPTION("Speakup support for text console");
146c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_LICENSE("GPL");
147c6e3fd22cd538365bfeb82997d5b89562e077d42William HubbsMODULE_VERSION(DRV_VERSION);
148c6e3fd22cd538365bfeb82997d5b89562e077d42William Hubbs
149