]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
speakup: Make dectlk flush timeout configurable
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 28 Jan 2021 18:01:16 +0000 (19:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Feb 2021 16:05:48 +0000 (17:05 +0100)
In case the serial port or cable got faulty, we may not be getting
acknowledgements any more. The driver then currently waits for 4s to
avoid jamming the device. This makes this delay configurable.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20210128180116.1848120-3-samuel.thibault@ens-lyon.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/stable/sysfs-driver-speakup
drivers/accessibility/speakup/speakup_dectlk.c
drivers/accessibility/speakup/spk_types.h
drivers/accessibility/speakup/synth.c
drivers/accessibility/speakup/varhandlers.c

index 47f5c8a9843a2751f5b141fdab14ef0431e94356..dc2a6ba1674b87f903553431b493010b0effed29 100644 (file)
@@ -312,6 +312,13 @@ Contact:   speakup@linux-speakup.org
 Description:   Gets or sets the frequency of the speech synthesizer. Range is
                0-9.
 
+What:          /sys/accessibility/speakup/<synth-name>/flush_time
+KernelVersion: 5.12
+Contact:       speakup@linux-speakup.org
+Description:   Gets or sets the timeout to wait for the synthesizer flush to
+               complete. This can be used when the cable gets faulty and flush
+               notifications are getting lost.
+
 What:          /sys/accessibility/speakup/<synth-name>/full_time
 KernelVersion: 2.6
 Contact:       speakup@linux-speakup.org
index d75de36e96c353dce58e18bcd46b11ea5293413f..580ec796816bcf0eefdc66e23329ee10f173f19f 100644 (file)
@@ -78,6 +78,8 @@ static struct kobj_attribute direct_attribute =
        __ATTR(direct, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute full_time_attribute =
        __ATTR(full_time, 0644, spk_var_show, spk_var_store);
+static struct kobj_attribute flush_time_attribute =
+       __ATTR(flush_time, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute jiffy_delta_attribute =
        __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute trigger_time_attribute =
@@ -99,6 +101,7 @@ static struct attribute *synth_attrs[] = {
        &delay_time_attribute.attr,
        &direct_attribute.attr,
        &full_time_attribute.attr,
+       &flush_time_attribute.attr,
        &jiffy_delta_attribute.attr,
        &trigger_time_attribute.attr,
        NULL,   /* need to NULL terminate the list of attributes */
@@ -118,6 +121,7 @@ static struct spk_synth synth_dectlk = {
        .trigger = 50,
        .jiffies = 50,
        .full = 40000,
+       .flush_time = 4000,
        .dev_name = SYNTH_DEFAULT_DEV,
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
@@ -200,18 +204,23 @@ static void do_catch_up(struct spk_synth *synth)
        static u_char last = '\0';
        unsigned long flags;
        unsigned long jiff_max;
-       unsigned long timeout = msecs_to_jiffies(4000);
+       unsigned long timeout;
        DEFINE_WAIT(wait);
        struct var_t *jiffy_delta;
        struct var_t *delay_time;
+       struct var_t *flush_time;
        int jiffy_delta_val;
        int delay_time_val;
+       int timeout_val;
 
        jiffy_delta = spk_get_var(JIFFY);
        delay_time = spk_get_var(DELAY);
+       flush_time = spk_get_var(FLUSH);
        spin_lock_irqsave(&speakup_info.spinlock, flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
+       timeout_val = flush_time->u.n.value;
        spin_unlock_irqrestore(&speakup_info.spinlock, flags);
+       timeout = msecs_to_jiffies(timeout_val);
        jiff_max = jiffies + jiffy_delta_val;
 
        while (!kthread_should_stop()) {
index 7789f5dca62a757fe911f40b221259447877c951..6a96ad94bc3f84255c6b14fb96db35ee1f017688 100644 (file)
@@ -48,7 +48,7 @@ enum var_id_t {
        ATTRIB_BLEEP, BLEEPS,
        RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
        DIRECT, PAUSE,
-       CAPS_START, CAPS_STOP, CHARTAB, INFLECTION,
+       CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
        MAXVARS
 };
 
@@ -178,6 +178,7 @@ struct spk_synth {
        int trigger;
        int jiffies;
        int full;
+       int flush_time;
        int ser;
        char *dev_name;
        short flags;
index 6c14b682da13d335aa764eea53aff36231a5fd13..2b8699673bace5571ea623d55409a6d8bdf03225 100644 (file)
@@ -348,6 +348,7 @@ struct var_t synth_time_vars[] = {
        { TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL } },
        { JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL } },
        { FULL, .u.n = {NULL, 400, 200, 60000, 0, 0, NULL } },
+       { FLUSH, .u.n = {NULL, 4000, 100, 4000, 0, 0, NULL } },
        V_LAST_VAR
 };
 
@@ -408,6 +409,8 @@ static int do_synth_init(struct spk_synth *in_synth)
                synth_time_vars[2].u.n.default_val = synth->jiffies;
        synth_time_vars[3].u.n.value =
                synth_time_vars[3].u.n.default_val = synth->full;
+       synth_time_vars[4].u.n.value =
+               synth_time_vars[4].u.n.default_val = synth->flush_time;
        synth_printf("%s", synth->init);
        for (var = synth->vars;
                (var->var_id >= 0) && (var->var_id < MAXVARS); var++)
index d7f6bec7ff06f6439e12b2d818a12cc91143bae9..067c0da97dcbf16cea24f32cdd069ffb7f27af65 100644 (file)
@@ -23,6 +23,7 @@ static struct st_var_header var_headers[] = {
        { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL },
        { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL },
        { "full_time", FULL, VAR_TIME, NULL, NULL },
+       { "flush_time", FLUSH, VAR_TIME, NULL, NULL },
        { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL },
        { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL },
        { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL },