1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kthread.h>
3 #include <linux/wait.h>
9 DECLARE_WAIT_QUEUE_HEAD(speakup_event
);
10 EXPORT_SYMBOL_GPL(speakup_event
);
12 int speakup_thread(void *data
)
16 struct bleep our_sound
;
20 our_sound
.jiffies
= 0;
22 mutex_lock(&spk_mutex
);
27 spin_lock_irqsave(&speakup_info
.spinlock
, flags
);
28 our_sound
= spk_unprocessed_sound
;
29 spk_unprocessed_sound
.active
= 0;
30 prepare_to_wait(&speakup_event
, &wait
,
32 should_break
= kthread_should_stop() ||
34 (synth
&& synth
->catch_up
&& synth
->alive
&&
35 (speakup_info
.flushing
||
36 !synth_buffer_empty()));
37 spin_unlock_irqrestore(&speakup_info
.spinlock
, flags
);
40 mutex_unlock(&spk_mutex
);
42 mutex_lock(&spk_mutex
);
44 finish_wait(&speakup_event
, &wait
);
45 if (kthread_should_stop())
49 kd_mksound(our_sound
.freq
, our_sound
.jiffies
);
50 if (synth
&& synth
->catch_up
&& synth
->alive
) {
52 * It is up to the callee to take the lock, so that it
53 * can sleep whenever it likes
55 synth
->catch_up(synth
);
60 mutex_unlock(&spk_mutex
);