speakup_txprt.c 4.8 KB

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