drivers/accessibility/speakup/buffers.c
Source file repositories/reference/linux-study-clean/drivers/accessibility/speakup/buffers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accessibility/speakup/buffers.c- Extension
.c- Size
- 2745 bytes
- Lines
- 125
- Domain
- Driver Families
- Bucket
- drivers/accessibility
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/console.hlinux/types.hlinux/wait.hspeakup.hspk_priv.h
Detected Declarations
function speakup_start_ttysfunction speakup_stop_ttysfunction synth_buffer_freefunction synth_buffer_emptyfunction synth_buffer_addfunction synth_buffer_getcfunction synth_buffer_peekfunction synth_buffer_skip_nonlatin1function synth_buffer_clearexport speakup_start_ttysexport synth_buffer_emptyexport synth_buffer_getcexport synth_buffer_peekexport synth_buffer_skip_nonlatin1export synth_buffer_clear
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/console.h>
#include <linux/types.h>
#include <linux/wait.h>
#include "speakup.h"
#include "spk_priv.h"
#define SYNTH_BUF_SIZE 8192 /* currently 8K bytes */
static u16 synth_buffer[SYNTH_BUF_SIZE]; /* guess what this is for! */
static u16 *buff_in = synth_buffer;
static u16 *buff_out = synth_buffer;
static u16 *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1;
/* These try to throttle applications by stopping the TTYs
* Note: we need to make sure that we will restart them eventually, which is
* usually not possible to do from the notifiers. TODO: it should be possible
* starting from linux 2.6.26.
*
* So we only stop when we know alive == 1 (else we discard the data anyway),
* and the alive synth will eventually call start_ttys from the thread context.
*/
void speakup_start_ttys(void)
{
int i;
for (i = 0; i < MAX_NR_CONSOLES; i++) {
if (speakup_console[i] && speakup_console[i]->tty_stopped)
continue;
if (vc_cons[i].d && vc_cons[i].d->port.tty)
start_tty(vc_cons[i].d->port.tty);
}
}
EXPORT_SYMBOL_GPL(speakup_start_ttys);
static void speakup_stop_ttys(void)
{
int i;
for (i = 0; i < MAX_NR_CONSOLES; i++)
if (vc_cons[i].d && vc_cons[i].d->port.tty)
stop_tty(vc_cons[i].d->port.tty);
}
static int synth_buffer_free(void)
{
int chars_free;
if (buff_in >= buff_out)
chars_free = SYNTH_BUF_SIZE - (buff_in - buff_out);
else
chars_free = buff_out - buff_in;
return chars_free;
}
int synth_buffer_empty(void)
{
return (buff_in == buff_out);
}
EXPORT_SYMBOL_GPL(synth_buffer_empty);
void synth_buffer_add(u16 ch)
{
if (!synth->alive) {
/* This makes sure that we won't stop TTYs if there is no synth
* to restart them
*/
return;
}
if (synth_buffer_free() <= 100) {
synth_start();
speakup_stop_ttys();
}
if (synth_buffer_free() <= 1)
return;
*buff_in++ = ch;
if (buff_in > buffer_end)
buff_in = synth_buffer;
/* We have written something to the speech synthesis, so we are not
* paused any more.
*/
spk_paused = false;
}
u16 synth_buffer_getc(void)
{
u16 ch;
if (buff_out == buff_in)
Annotation
- Immediate include surface: `linux/console.h`, `linux/types.h`, `linux/wait.h`, `speakup.h`, `spk_priv.h`.
- Detected declarations: `function speakup_start_ttys`, `function speakup_stop_ttys`, `function synth_buffer_free`, `function synth_buffer_empty`, `function synth_buffer_add`, `function synth_buffer_getc`, `function synth_buffer_peek`, `function synth_buffer_skip_nonlatin1`, `function synth_buffer_clear`, `export speakup_start_ttys`.
- Atlas domain: Driver Families / drivers/accessibility.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.