speakup_ltlk.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
  3. * this version considerably modified by David Borowski, david575@rogers.com
  4. *
  5. * Copyright (C) 1998-99 Kirk Reiser.
  6. * Copyright (C) 2003 David Borowski.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * specificly written as a driver for the speakup screenreview
  23. * s not a general device driver.
  24. */
  25. #include "speakup.h"
  26. #include "spk_priv.h"
  27. #include "serialio.h"
  28. #include "speakup_dtlk.h" /* local header file for LiteTalk values */
  29. #define DRV_VERSION "2.11"
  30. #define PROCSPEECH 0x0d
  31. static int synth_probe(struct spk_synth *synth);
  32. static struct var_t vars[] = {
  33. { CAPS_START, .u.s = {"\x01+35p" } },
  34. { CAPS_STOP, .u.s = {"\x01-35p" } },
  35. { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },
  36. { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },
  37. { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
  38. { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
  39. { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },
  40. { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
  41. { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
  42. { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  43. V_LAST_VAR
  44. };
  45. /*
  46. * These attributes will appear in /sys/accessibility/speakup/ltlk.
  47. */
  48. static struct kobj_attribute caps_start_attribute =
  49. __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  50. static struct kobj_attribute caps_stop_attribute =
  51. __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  52. static struct kobj_attribute freq_attribute =
  53. __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  54. static struct kobj_attribute pitch_attribute =
  55. __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  56. static struct kobj_attribute punct_attribute =
  57. __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  58. static struct kobj_attribute rate_attribute =
  59. __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  60. static struct kobj_attribute tone_attribute =
  61. __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  62. static struct kobj_attribute voice_attribute =
  63. __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  64. static struct kobj_attribute vol_attribute =
  65. __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  66. static struct kobj_attribute delay_time_attribute =
  67. __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  68. static struct kobj_attribute direct_attribute =
  69. __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  70. static struct kobj_attribute full_time_attribute =
  71. __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  72. static struct kobj_attribute jiffy_delta_attribute =
  73. __ATTR(jiffy_delta, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  74. static struct kobj_attribute trigger_time_attribute =
  75. __ATTR(trigger_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store);
  76. /*
  77. * Create a group of attributes so that we can create and destroy them all
  78. * at once.
  79. */
  80. static struct attribute *synth_attrs[] = {
  81. &caps_start_attribute.attr,
  82. &caps_stop_attribute.attr,
  83. &freq_attribute.attr,
  84. &pitch_attribute.attr,
  85. &punct_attribute.attr,
  86. &rate_attribute.attr,
  87. &tone_attribute.attr,
  88. &voice_attribute.attr,
  89. &vol_attribute.attr,
  90. &delay_time_attribute.attr,
  91. &direct_attribute.attr,
  92. &full_time_attribute.attr,
  93. &jiffy_delta_attribute.attr,
  94. &trigger_time_attribute.attr,
  95. NULL, /* need to NULL terminate the list of attributes */
  96. };
  97. static struct spk_synth synth_ltlk = {
  98. .name = "ltlk",
  99. .version = DRV_VERSION,
  100. .long_name = "LiteTalk",
  101. .init = "\01@\x01\x31y\n\0",
  102. .procspeech = PROCSPEECH,
  103. .clear = SYNTH_CLEAR,
  104. .delay = 500,
  105. .trigger = 50,
  106. .jiffies = 50,
  107. .full = 40000,
  108. .startup = SYNTH_START,
  109. .checkval = SYNTH_CHECK,
  110. .vars = vars,
  111. .probe = synth_probe,
  112. .release = spk_serial_release,
  113. .synth_immediate = spk_synth_immediate,
  114. .catch_up = spk_do_catch_up,
  115. .flush = spk_synth_flush,
  116. .is_alive = spk_synth_is_alive_restart,
  117. .synth_adjust = NULL,
  118. .read_buff_add = NULL,
  119. .get_index = spk_serial_in_nowait,
  120. .indexing = {
  121. .command = "\x01%di",
  122. .lowindex = 1,
  123. .highindex = 5,
  124. .currindex = 1,
  125. },
  126. .attributes = {
  127. .attrs = synth_attrs,
  128. .name = "ltlk",
  129. },
  130. };
  131. /* interrogate the LiteTalk and print its settings */
  132. static void synth_interrogate(struct spk_synth *synth)
  133. {
  134. unsigned char *t, i;
  135. unsigned char buf[50], rom_v[20];
  136. spk_synth_immediate(synth, "\x18\x01?");
  137. for (i = 0; i < 50; i++) {
  138. buf[i] = spk_serial_in();
  139. if (i > 2 && buf[i] == 0x7f)
  140. break;
  141. }
  142. t = buf+2;
  143. for (i = 0; *t != '\r'; t++) {
  144. rom_v[i] = *t;
  145. if (++i >= 19)
  146. break;
  147. }
  148. rom_v[i] = 0;
  149. pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
  150. }
  151. static int synth_probe(struct spk_synth *synth)
  152. {
  153. int failed = 0;
  154. failed = spk_serial_synth_probe(synth);
  155. if (failed == 0)
  156. synth_interrogate(synth);
  157. synth->alive = !failed;
  158. return failed;
  159. }
  160. module_param_named(ser, synth_ltlk.ser, int, S_IRUGO);
  161. module_param_named(start, synth_ltlk.startup, short, S_IRUGO);
  162. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  163. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  164. module_spk_synth(synth_ltlk);
  165. MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
  166. MODULE_AUTHOR("David Borowski");
  167. MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
  168. MODULE_LICENSE("GPL");
  169. MODULE_VERSION(DRV_VERSION);