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