speakup_dummy.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. * eventually modified by Samuel Thibault <samuel.thibault@ens-lyon.org>
  6. *
  7. * Copyright (C) 1998-99 Kirk Reiser.
  8. * Copyright (C) 2003 David Borowski.
  9. * Copyright (C) 2007 Samuel Thibault.
  10. *
  11. * specifically written as a driver for the speakup screenreview
  12. * s not a general device driver.
  13. */
  14. #include "spk_priv.h"
  15. #include "speakup.h"
  16. #define PROCSPEECH '\n'
  17. #define DRV_VERSION "2.11"
  18. #define SYNTH_CLEAR '!'
  19. enum default_vars_id {
  20. CAPS_START_ID = 0, CAPS_STOP_ID,
  21. PAUSE_ID,
  22. RATE_ID, PITCH_ID, INFLECTION_ID,
  23. VOL_ID, TONE_ID, PUNCT_ID,
  24. DIRECT_ID, V_LAST_VAR_ID,
  25. NB_ID
  26. };
  27. static struct var_t vars[NB_ID] = {
  28. [CAPS_START_ID] = { CAPS_START, .u.s = {"CAPS_START\n" } },
  29. [CAPS_STOP_ID] = { CAPS_STOP, .u.s = {"CAPS_STOP\n" } },
  30. [PAUSE_ID] = { PAUSE, .u.s = {"PAUSE\n"} },
  31. [RATE_ID] = { RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } },
  32. [PITCH_ID] = { PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } },
  33. [INFLECTION_ID] = { INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
  34. [VOL_ID] = { VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
  35. [TONE_ID] = { TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
  36. [PUNCT_ID] = { PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
  37. [DIRECT_ID] = { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  38. V_LAST_VAR
  39. };
  40. /*
  41. * These attributes will appear in /sys/accessibility/speakup/dummy.
  42. */
  43. static struct kobj_attribute caps_start_attribute =
  44. __ATTR(caps_start, 0644, spk_var_show, spk_var_store);
  45. static struct kobj_attribute caps_stop_attribute =
  46. __ATTR(caps_stop, 0644, spk_var_show, spk_var_store);
  47. static struct kobj_attribute pitch_attribute =
  48. __ATTR(pitch, 0644, spk_var_show, spk_var_store);
  49. static struct kobj_attribute inflection_attribute =
  50. __ATTR(inflection, 0644, spk_var_show, spk_var_store);
  51. static struct kobj_attribute punct_attribute =
  52. __ATTR(punct, 0644, spk_var_show, spk_var_store);
  53. static struct kobj_attribute rate_attribute =
  54. __ATTR(rate, 0644, spk_var_show, spk_var_store);
  55. static struct kobj_attribute tone_attribute =
  56. __ATTR(tone, 0644, spk_var_show, spk_var_store);
  57. static struct kobj_attribute vol_attribute =
  58. __ATTR(vol, 0644, spk_var_show, spk_var_store);
  59. static struct kobj_attribute delay_time_attribute =
  60. __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
  61. static struct kobj_attribute direct_attribute =
  62. __ATTR(direct, 0644, spk_var_show, spk_var_store);
  63. static struct kobj_attribute full_time_attribute =
  64. __ATTR(full_time, 0644, spk_var_show, spk_var_store);
  65. static struct kobj_attribute jiffy_delta_attribute =
  66. __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
  67. static struct kobj_attribute trigger_time_attribute =
  68. __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
  69. /*
  70. * Create a group of attributes so that we can create and destroy them all
  71. * at once.
  72. */
  73. static struct attribute *synth_attrs[] = {
  74. &caps_start_attribute.attr,
  75. &caps_stop_attribute.attr,
  76. &pitch_attribute.attr,
  77. &inflection_attribute.attr,
  78. &punct_attribute.attr,
  79. &rate_attribute.attr,
  80. &tone_attribute.attr,
  81. &vol_attribute.attr,
  82. &delay_time_attribute.attr,
  83. &direct_attribute.attr,
  84. &full_time_attribute.attr,
  85. &jiffy_delta_attribute.attr,
  86. &trigger_time_attribute.attr,
  87. NULL, /* need to NULL terminate the list of attributes */
  88. };
  89. static void read_buff_add(u_char c)
  90. {
  91. pr_info("speakup_dummy: got character %02x\n", c);
  92. }
  93. static struct spk_synth synth_dummy = {
  94. .name = "dummy",
  95. .version = DRV_VERSION,
  96. .long_name = "Dummy",
  97. .init = "Speakup\n",
  98. .procspeech = PROCSPEECH,
  99. .clear = SYNTH_CLEAR,
  100. .delay = 500,
  101. .trigger = 50,
  102. .jiffies = 50,
  103. .full = 40000,
  104. .dev_name = SYNTH_DEFAULT_DEV,
  105. .startup = SYNTH_START,
  106. .checkval = SYNTH_CHECK,
  107. .vars = vars,
  108. .io_ops = &spk_ttyio_ops,
  109. .probe = spk_ttyio_synth_probe,
  110. .release = spk_ttyio_release,
  111. .synth_immediate = spk_ttyio_synth_immediate,
  112. .catch_up = spk_do_catch_up_unicode,
  113. .flush = spk_synth_flush,
  114. .is_alive = spk_synth_is_alive_restart,
  115. .synth_adjust = NULL,
  116. .read_buff_add = read_buff_add,
  117. .get_index = NULL,
  118. .indexing = {
  119. .command = NULL,
  120. .lowindex = 0,
  121. .highindex = 0,
  122. .currindex = 0,
  123. },
  124. .attributes = {
  125. .attrs = synth_attrs,
  126. .name = "dummy",
  127. },
  128. };
  129. module_param_named(ser, synth_dummy.ser, int, 0444);
  130. module_param_named(dev, synth_dummy.dev_name, charp, 0444);
  131. module_param_named(start, synth_dummy.startup, short, 0444);
  132. module_param_named(rate, vars[RATE_ID].u.n.default_val, int, 0444);
  133. module_param_named(pitch, vars[PITCH_ID].u.n.default_val, int, 0444);
  134. module_param_named(inflection, vars[INFLECTION_ID].u.n.default_val, int, 0444);
  135. module_param_named(vol, vars[VOL_ID].u.n.default_val, int, 0444);
  136. module_param_named(tone, vars[TONE_ID].u.n.default_val, int, 0444);
  137. module_param_named(punct, vars[PUNCT_ID].u.n.default_val, int, 0444);
  138. module_param_named(direct, vars[DIRECT_ID].u.n.default_val, int, 0444);
  139. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  140. MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
  141. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  142. MODULE_PARM_DESC(rate, "Set the rate variable on load.");
  143. MODULE_PARM_DESC(pitch, "Set the pitch variable on load.");
  144. MODULE_PARM_DESC(inflection, "Set the inflection variable on load.");
  145. MODULE_PARM_DESC(vol, "Set the vol variable on load.");
  146. MODULE_PARM_DESC(tone, "Set the tone variable on load.");
  147. MODULE_PARM_DESC(punct, "Set the punct variable on load.");
  148. MODULE_PARM_DESC(direct, "Set the direct variable on load.");
  149. module_spk_synth(synth_dummy);
  150. MODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>");
  151. MODULE_DESCRIPTION("Speakup support for text console");
  152. MODULE_LICENSE("GPL");
  153. MODULE_VERSION(DRV_VERSION);