speakup_txprt.c 3.9 KB

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