speakup_ltlk.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * originally written by: Kirk Reiser <kirk@braille.uwo.ca>
  4. * this version considerably modified by David Borowski, david575@rogers.com
  5. *
  6. * Copyright (C) 1998-99 Kirk Reiser.
  7. * Copyright (C) 2003 David Borowski.
  8. *
  9. * specifically written as a driver for the speakup screenreview
  10. * s not a general device driver.
  11. */
  12. #include "speakup.h"
  13. #include "spk_priv.h"
  14. #include "speakup_dtlk.h" /* local header file for LiteTalk values */
  15. #define DRV_VERSION "2.11"
  16. #define PROCSPEECH 0x0d
  17. static int synth_probe(struct spk_synth *synth);
  18. enum default_vars_id {
  19. CAPS_START_ID = 0, CAPS_STOP_ID,
  20. RATE_ID, PITCH_ID,
  21. VOL_ID, TONE_ID, PUNCT_ID,
  22. VOICE_ID, FREQUENCY_ID,
  23. DIRECT_ID, V_LAST_VAR_ID,
  24. NB_ID
  25. };
  26. static struct var_t vars[NB_ID] = {
  27. [CAPS_START_ID] = { CAPS_START, .u.s = {"\x01+35p" } },
  28. [CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"\x01-35p" } },
  29. [RATE_ID] = { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } },
  30. [PITCH_ID] = { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } },
  31. [VOL_ID] = { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } },
  32. [TONE_ID] = { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } },
  33. [PUNCT_ID] = { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } },
  34. [VOICE_ID] = { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } },
  35. [FREQUENCY_ID] = { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } },
  36. [DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  37. V_LAST_VAR
  38. };
  39. /*
  40. * These attributes will appear in /sys/accessibility/speakup/ltlk.
  41. */
  42. static struct kobj_attribute caps_start_attribute =
  43. __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
  44. static struct kobj_attribute caps_stop_attribute =
  45. __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
  46. static struct kobj_attribute freq_attribute =
  47. __ATTR(freq, 0644, spk_var_show, spk_var_store);
  48. static struct kobj_attribute pitch_attribute =
  49. __ATTR(pitch, 0644, spk_var_show, spk_var_store);
  50. static struct kobj_attribute punct_attribute =
  51. __ATTR(punct, 0644, spk_var_show, spk_var_store);
  52. static struct kobj_attribute rate_attribute =
  53. __ATTR(rate, 0644, spk_var_show, spk_var_store);
  54. static struct kobj_attribute tone_attribute =
  55. __ATTR(tone, 0644, spk_var_show, spk_var_store);
  56. static struct kobj_attribute voice_attribute =
  57. __ATTR(voice, 0644, spk_var_show, spk_var_store);
  58. static struct kobj_attribute vol_attribute =
  59. __ATTR(vol, 0644, spk_var_show, spk_var_store);
  60. static struct kobj_attribute delay_time_attribute =
  61. __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
  62. static struct kobj_attribute direct_attribute =
  63. __ATTR(direct, 0644, spk_var_show, spk_var_store);
  64. static struct kobj_attribute full_time_attribute =
  65. __ATTR(full_time, 0644, spk_var_show, spk_var_store);
  66. static struct kobj_attribute jiffy_delta_attribute =
  67. __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
  68. static struct kobj_attribute trigger_time_attribute =
  69. __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
  70. /*
  71. * Create a group of attributes so that we can create and destroy them all
  72. * at once.
  73. */
  74. static struct attribute *synth_attrs[] = {
  75. &caps_start_attribute.attr,
  76. &caps_stop_attribute.attr,
  77. &freq_attribute.attr,
  78. &pitch_attribute.attr,
  79. &punct_attribute.attr,
  80. &rate_attribute.attr,
  81. &tone_attribute.attr,
  82. &voice_attribute.attr,
  83. &vol_attribute.attr,
  84. &delay_time_attribute.attr,
  85. &direct_attribute.attr,
  86. &full_time_attribute.attr,
  87. &jiffy_delta_attribute.attr,
  88. &trigger_time_attribute.attr,
  89. NULL, /* need to NULL terminate the list of attributes */
  90. };
  91. static struct spk_synth synth_ltlk = {
  92. .name = "ltlk",
  93. .version = DRV_VERSION,
  94. .long_name = "LiteTalk",
  95. .init = "\01@\x01\x31y\n\0",
  96. .procspeech = PROCSPEECH,
  97. .clear = SYNTH_CLEAR,
  98. .delay = 500,
  99. .trigger = 50,
  100. .jiffies = 50,
  101. .full = 40000,
  102. .dev_name = SYNTH_DEFAULT_DEV,
  103. .startup = SYNTH_START,
  104. .checkval = SYNTH_CHECK,
  105. .vars = vars,
  106. .io_ops = &spk_ttyio_ops,
  107. .probe = synth_probe,
  108. .release = spk_ttyio_release,
  109. .synth_immediate = spk_ttyio_synth_immediate,
  110. .catch_up = spk_do_catch_up,
  111. .flush = spk_synth_flush,
  112. .is_alive = spk_synth_is_alive_restart,
  113. .synth_adjust = NULL,
  114. .read_buff_add = NULL,
  115. .get_index = spk_synth_get_index,
  116. .indexing = {
  117. .command = "\x01%di",
  118. .lowindex = 1,
  119. .highindex = 5,
  120. .currindex = 1,
  121. },
  122. .attributes = {
  123. .attrs = synth_attrs,
  124. .name = "ltlk",
  125. },
  126. };
  127. /* interrogate the LiteTalk and print its settings */
  128. static void synth_interrogate(struct spk_synth *synth)
  129. {
  130. unsigned char *t, i;
  131. unsigned char buf[50], rom_v[20];
  132. synth->synth_immediate(synth, "\x18\x01?");
  133. for (i = 0; i < 50; i++) {
  134. buf[i] = synth->io_ops->synth_in(synth);
  135. if (i > 2 && buf[i] == 0x7f)
  136. break;
  137. }
  138. t = buf + 2;
  139. for (i = 0; *t != '\r'; t++) {
  140. rom_v[i] = *t;
  141. if (++i >= 19)
  142. break;
  143. }
  144. rom_v[i] = 0;
  145. pr_info("%s: ROM version: %s\n", synth->long_name, rom_v);
  146. }
  147. static int synth_probe(struct spk_synth *synth)
  148. {
  149. int failed = 0;
  150. failed = spk_ttyio_synth_probe(synth);
  151. if (failed == 0)
  152. synth_interrogate(synth);
  153. synth->alive = !failed;
  154. return failed;
  155. }
  156. module_param_named(ser, synth_ltlk.ser, int, 0444);
  157. module_param_named(dev, synth_ltlk.dev_name, charp, 0444);
  158. module_param_named(start, synth_ltlk.startup, short, 0444);
  159. module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);
  160. module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);
  161. module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);
  162. module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);
  163. module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);
  164. module_param_named(voice, vars[VOICE_ID].u.n.default_val, int, 0444);
  165. module_param_named(frequency, vars[FREQUENCY_ID].u.n.default_val, int, 0444);
  166. module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);
  167. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  168. MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
  169. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  170. MODULE_PARM_DESC(rate, "Set the rate variable on load.");
  171. MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");
  172. MODULE_PARM_DESC(vol, "Set the vol variable on load.");
  173. MODULE_PARM_DESC(tone, "Set the tone variable on load.");
  174. MODULE_PARM_DESC(punct, "Set the punct variable on load.");
  175. MODULE_PARM_DESC(voice, "Set the voice variable on load.");
  176. MODULE_PARM_DESC(frequency, "Set the frequency variable on load.");
  177. MODULE_PARM_DESC(direct, "Set the direct variable on load.");
  178. module_spk_synth(synth_ltlk);
  179. MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
  180. MODULE_AUTHOR("David Borowski");
  181. MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
  182. MODULE_LICENSE("GPL");
  183. MODULE_VERSION(DRV_VERSION);