speakup_acntsa.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. * this code is specifically written as a driver for the speakup screenreview
  10. * package and is not a general device driver.
  11. */
  12. #include "spk_priv.h"
  13. #include "speakup.h"
  14. #include "speakup_acnt.h" /* local header file for Accent values */
  15. #define DRV_VERSION "2.11"
  16. #define PROCSPEECH '\r'
  17. static int synth_probe(struct spk_synth *synth);
  18. static struct var_t vars[] = {
  19. { CAPS_START, .u.s = {"\033P8" } },
  20. { CAPS_STOP, .u.s = {"\033P5" } },
  21. { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } },
  22. { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } },
  23. { VOL, .u.n = {"\033A%d", 9, 0, 9, 0, 0, NULL } },
  24. { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } },
  25. { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  26. V_LAST_VAR
  27. };
  28. /*
  29. * These attributes will appear in /sys/accessibility/speakup/acntsa.
  30. */
  31. static struct kobj_attribute caps_start_attribute =
  32. __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
  33. static struct kobj_attribute caps_stop_attribute =
  34. __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
  35. static struct kobj_attribute pitch_attribute =
  36. __ATTR(pitch, 0644, spk_var_show, spk_var_store);
  37. static struct kobj_attribute rate_attribute =
  38. __ATTR(rate, 0644, spk_var_show, spk_var_store);
  39. static struct kobj_attribute tone_attribute =
  40. __ATTR(tone, 0644, spk_var_show, spk_var_store);
  41. static struct kobj_attribute vol_attribute =
  42. __ATTR(vol, 0644, spk_var_show, spk_var_store);
  43. static struct kobj_attribute delay_time_attribute =
  44. __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
  45. static struct kobj_attribute direct_attribute =
  46. __ATTR(direct, 0644, spk_var_show, spk_var_store);
  47. static struct kobj_attribute full_time_attribute =
  48. __ATTR(full_time, 0644, spk_var_show, spk_var_store);
  49. static struct kobj_attribute jiffy_delta_attribute =
  50. __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
  51. static struct kobj_attribute trigger_time_attribute =
  52. __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
  53. /*
  54. * Create a group of attributes so that we can create and destroy them all
  55. * at once.
  56. */
  57. static struct attribute *synth_attrs[] = {
  58. &caps_start_attribute.attr,
  59. &caps_stop_attribute.attr,
  60. &pitch_attribute.attr,
  61. &rate_attribute.attr,
  62. &tone_attribute.attr,
  63. &vol_attribute.attr,
  64. &delay_time_attribute.attr,
  65. &direct_attribute.attr,
  66. &full_time_attribute.attr,
  67. &jiffy_delta_attribute.attr,
  68. &trigger_time_attribute.attr,
  69. NULL, /* need to NULL terminate the list of attributes */
  70. };
  71. static struct spk_synth synth_acntsa = {
  72. .name = "acntsa",
  73. .version = DRV_VERSION,
  74. .long_name = "Accent-SA",
  75. .init = "\033T2\033=M\033Oi\033N1\n",
  76. .procspeech = PROCSPEECH,
  77. .clear = SYNTH_CLEAR,
  78. .delay = 400,
  79. .trigger = 50,
  80. .jiffies = 30,
  81. .full = 40000,
  82. .dev_name = SYNTH_DEFAULT_DEV,
  83. .startup = SYNTH_START,
  84. .checkval = SYNTH_CHECK,
  85. .vars = vars,
  86. .io_ops = &spk_ttyio_ops,
  87. .probe = synth_probe,
  88. .release = spk_ttyio_release,
  89. .synth_immediate = spk_ttyio_synth_immediate,
  90. .catch_up = spk_do_catch_up,
  91. .flush = spk_synth_flush,
  92. .is_alive = spk_synth_is_alive_restart,
  93. .synth_adjust = NULL,
  94. .read_buff_add = NULL,
  95. .get_index = NULL,
  96. .indexing = {
  97. .command = NULL,
  98. .lowindex = 0,
  99. .highindex = 0,
  100. .currindex = 0,
  101. },
  102. .attributes = {
  103. .attrs = synth_attrs,
  104. .name = "acntsa",
  105. },
  106. };
  107. static int synth_probe(struct spk_synth *synth)
  108. {
  109. int failed;
  110. failed = spk_ttyio_synth_probe(synth);
  111. if (failed == 0) {
  112. synth->synth_immediate(synth, "\033=R\r");
  113. mdelay(100);
  114. }
  115. synth->alive = !failed;
  116. return failed;
  117. }
  118. module_param_named(ser, synth_acntsa.ser, int, 0444);
  119. module_param_named(dev, synth_acntsa.dev_name, charp, 0444);
  120. module_param_named(start, synth_acntsa.startup, short, 0444);
  121. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  122. MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
  123. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  124. module_spk_synth(synth_acntsa);
  125. MODULE_AUTHOR("Kirk Reiser <[email protected]>");
  126. MODULE_AUTHOR("David Borowski");
  127. MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer");
  128. MODULE_LICENSE("GPL");
  129. MODULE_VERSION(DRV_VERSION);