speakup_ltlk.c 5.2 KB

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