speakup_spkout.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 "spk_priv.h"
  13. #include "speakup.h"
  14. #define DRV_VERSION "2.11"
  15. #define SYNTH_CLEAR 0x18
  16. #define PROCSPEECH '\r'
  17. static void synth_flush(struct spk_synth *synth);
  18. static struct var_t vars[] = {
  19. { CAPS_START, .u.s = {"\x05P+" } },
  20. { CAPS_STOP, .u.s = {"\x05P-" } },
  21. { RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL } },
  22. { PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL } },
  23. { VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL } },
  24. { TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL } },
  25. { PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } },
  26. { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  27. V_LAST_VAR
  28. };
  29. /* These attributes will appear in /sys/accessibility/speakup/spkout. */
  30. static struct kobj_attribute caps_start_attribute =
  31. __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
  32. static struct kobj_attribute caps_stop_attribute =
  33. __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
  34. static struct kobj_attribute pitch_attribute =
  35. __ATTR(pitch, 0644, spk_var_show, spk_var_store);
  36. static struct kobj_attribute punct_attribute =
  37. __ATTR(punct, 0644, spk_var_show, spk_var_store);
  38. static struct kobj_attribute rate_attribute =
  39. __ATTR(rate, 0644, spk_var_show, spk_var_store);
  40. static struct kobj_attribute tone_attribute =
  41. __ATTR(tone, 0644, spk_var_show, spk_var_store);
  42. static struct kobj_attribute vol_attribute =
  43. __ATTR(vol, 0644, spk_var_show, spk_var_store);
  44. static struct kobj_attribute delay_time_attribute =
  45. __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
  46. static struct kobj_attribute direct_attribute =
  47. __ATTR(direct, 0644, spk_var_show, spk_var_store);
  48. static struct kobj_attribute full_time_attribute =
  49. __ATTR(full_time, 0644, spk_var_show, spk_var_store);
  50. static struct kobj_attribute jiffy_delta_attribute =
  51. __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
  52. static struct kobj_attribute trigger_time_attribute =
  53. __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
  54. /*
  55. * Create a group of attributes so that we can create and destroy them all
  56. * at once.
  57. */
  58. static struct attribute *synth_attrs[] = {
  59. &caps_start_attribute.attr,
  60. &caps_stop_attribute.attr,
  61. &pitch_attribute.attr,
  62. &punct_attribute.attr,
  63. &rate_attribute.attr,
  64. &tone_attribute.attr,
  65. &vol_attribute.attr,
  66. &delay_time_attribute.attr,
  67. &direct_attribute.attr,
  68. &full_time_attribute.attr,
  69. &jiffy_delta_attribute.attr,
  70. &trigger_time_attribute.attr,
  71. NULL, /* need to NULL terminate the list of attributes */
  72. };
  73. static struct spk_synth synth_spkout = {
  74. .name = "spkout",
  75. .version = DRV_VERSION,
  76. .long_name = "Speakout",
  77. .init = "\005W1\005I2\005C3",
  78. .procspeech = PROCSPEECH,
  79. .clear = SYNTH_CLEAR,
  80. .delay = 500,
  81. .trigger = 50,
  82. .jiffies = 50,
  83. .full = 40000,
  84. .dev_name = SYNTH_DEFAULT_DEV,
  85. .startup = SYNTH_START,
  86. .checkval = SYNTH_CHECK,
  87. .vars = vars,
  88. .io_ops = &spk_ttyio_ops,
  89. .probe = spk_ttyio_synth_probe,
  90. .release = spk_ttyio_release,
  91. .synth_immediate = spk_ttyio_synth_immediate,
  92. .catch_up = spk_do_catch_up,
  93. .flush = synth_flush,
  94. .is_alive = spk_synth_is_alive_restart,
  95. .synth_adjust = NULL,
  96. .read_buff_add = NULL,
  97. .get_index = spk_synth_get_index,
  98. .indexing = {
  99. .command = "\x05[%c",
  100. .lowindex = 1,
  101. .highindex = 5,
  102. .currindex = 1,
  103. },
  104. .attributes = {
  105. .attrs = synth_attrs,
  106. .name = "spkout",
  107. },
  108. };
  109. static void synth_flush(struct spk_synth *synth)
  110. {
  111. synth->io_ops->flush_buffer(synth);
  112. synth->io_ops->send_xchar(synth, SYNTH_CLEAR);
  113. }
  114. module_param_named(ser, synth_spkout.ser, int, 0444);
  115. module_param_named(dev, synth_spkout.dev_name, charp, 0444);
  116. module_param_named(start, synth_spkout.startup, short, 0444);
  117. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  118. MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
  119. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  120. module_spk_synth(synth_spkout);
  121. MODULE_AUTHOR("Kirk Reiser <[email protected]>");
  122. MODULE_AUTHOR("David Borowski");
  123. MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");
  124. MODULE_LICENSE("GPL");
  125. MODULE_VERSION(DRV_VERSION);