speakup_dummy.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. * eventually modified by Samuel Thibault <[email protected]>
  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. static struct var_t vars[] = {
  20. { CAPS_START, .u.s = {"CAPS_START\n" } },
  21. { CAPS_STOP, .u.s = {"CAPS_STOP\n" } },
  22. { PAUSE, .u.s = {"PAUSE\n"} },
  23. { RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } },
  24. { PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } },
  25. { INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } },
  26. { VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } },
  27. { TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } },
  28. { PUNCT, .u.n = {"PUNCT %d\n", 0, 0, 3, 0, 0, NULL } },
  29. { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } },
  30. V_LAST_VAR
  31. };
  32. /*
  33. * These attributes will appear in /sys/accessibility/speakup/dummy.
  34. */
  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 inflection_attribute =
  42. __ATTR(inflection, 0644, spk_var_show, spk_var_store);
  43. static struct kobj_attribute punct_attribute =
  44. __ATTR(punct, 0644, spk_var_show, spk_var_store);
  45. static struct kobj_attribute rate_attribute =
  46. __ATTR(rate, 0644, spk_var_show, spk_var_store);
  47. static struct kobj_attribute tone_attribute =
  48. __ATTR(tone, 0644, spk_var_show, spk_var_store);
  49. static struct kobj_attribute vol_attribute =
  50. __ATTR(vol, 0644, spk_var_show, spk_var_store);
  51. static struct kobj_attribute delay_time_attribute =
  52. __ATTR(delay_time, 0644, spk_var_show, spk_var_store);
  53. static struct kobj_attribute direct_attribute =
  54. __ATTR(direct, 0644, spk_var_show, spk_var_store);
  55. static struct kobj_attribute full_time_attribute =
  56. __ATTR(full_time, 0644, spk_var_show, spk_var_store);
  57. static struct kobj_attribute jiffy_delta_attribute =
  58. __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
  59. static struct kobj_attribute trigger_time_attribute =
  60. __ATTR(trigger_time, 0644, spk_var_show, spk_var_store);
  61. /*
  62. * Create a group of attributes so that we can create and destroy them all
  63. * at once.
  64. */
  65. static struct attribute *synth_attrs[] = {
  66. &caps_start_attribute.attr,
  67. &caps_stop_attribute.attr,
  68. &pitch_attribute.attr,
  69. &inflection_attribute.attr,
  70. &punct_attribute.attr,
  71. &rate_attribute.attr,
  72. &tone_attribute.attr,
  73. &vol_attribute.attr,
  74. &delay_time_attribute.attr,
  75. &direct_attribute.attr,
  76. &full_time_attribute.attr,
  77. &jiffy_delta_attribute.attr,
  78. &trigger_time_attribute.attr,
  79. NULL, /* need to NULL terminate the list of attributes */
  80. };
  81. static void read_buff_add(u_char c)
  82. {
  83. pr_info("speakup_dummy: got character %02x\n", c);
  84. }
  85. static struct spk_synth synth_dummy = {
  86. .name = "dummy",
  87. .version = DRV_VERSION,
  88. .long_name = "Dummy",
  89. .init = "Speakup\n",
  90. .procspeech = PROCSPEECH,
  91. .clear = SYNTH_CLEAR,
  92. .delay = 500,
  93. .trigger = 50,
  94. .jiffies = 50,
  95. .full = 40000,
  96. .dev_name = SYNTH_DEFAULT_DEV,
  97. .startup = SYNTH_START,
  98. .checkval = SYNTH_CHECK,
  99. .vars = vars,
  100. .io_ops = &spk_ttyio_ops,
  101. .probe = spk_ttyio_synth_probe,
  102. .release = spk_ttyio_release,
  103. .synth_immediate = spk_ttyio_synth_immediate,
  104. .catch_up = spk_do_catch_up_unicode,
  105. .flush = spk_synth_flush,
  106. .is_alive = spk_synth_is_alive_restart,
  107. .synth_adjust = NULL,
  108. .read_buff_add = read_buff_add,
  109. .get_index = NULL,
  110. .indexing = {
  111. .command = NULL,
  112. .lowindex = 0,
  113. .highindex = 0,
  114. .currindex = 0,
  115. },
  116. .attributes = {
  117. .attrs = synth_attrs,
  118. .name = "dummy",
  119. },
  120. };
  121. module_param_named(ser, synth_dummy.ser, int, 0444);
  122. module_param_named(dev, synth_dummy.dev_name, charp, 0444);
  123. module_param_named(start, synth_dummy.startup, short, 0444);
  124. MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
  125. MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer.");
  126. MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
  127. module_spk_synth(synth_dummy);
  128. MODULE_AUTHOR("Samuel Thibault <[email protected]>");
  129. MODULE_DESCRIPTION("Speakup support for text console");
  130. MODULE_LICENSE("GPL");
  131. MODULE_VERSION(DRV_VERSION);