cregit-Linux how code gets into the kernel

Release 4.18 drivers/staging/speakup/buffers.c

// 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); } }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs6891.89%150.00%
Greg Kroah-Hartman68.11%150.00%
Total74100.00%2100.00%

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); }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs5289.66%150.00%
Greg Kroah-Hartman610.34%150.00%
Total58100.00%2100.00%


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; }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs3286.49%133.33%
Samuel Thibault410.81%133.33%
Lijo Antony12.70%133.33%
Total37100.00%3100.00%


int synth_buffer_empty(void) { return (buff_in == buff_out); }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs14100.00%1100.00%
Total14100.00%1100.00%

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; }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs5688.89%116.67%
Samuel Thibault69.52%466.67%
Aleksei Fedotov11.59%116.67%
Total63100.00%6100.00%


u16 synth_buffer_getc(void) { u16 ch; if (buff_out == buff_in) return 0; ch = *buff_out++; if (buff_out > buffer_end) buff_out = synth_buffer; return ch; }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs3694.74%150.00%
Samuel Thibault25.26%150.00%
Total38100.00%2100.00%

EXPORT_SYMBOL_GPL(synth_buffer_getc);
u16 synth_buffer_peek(void) { if (buff_out == buff_in) return 0; return *buff_out; }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs1995.00%150.00%
Samuel Thibault15.00%150.00%
Total20100.00%2100.00%

EXPORT_SYMBOL_GPL(synth_buffer_peek);
void synth_buffer_skip_nonlatin1(void) { while (buff_out != buff_in) { if (*buff_out < 0x100) return; buff_out++; if (buff_out > buffer_end) buff_out = synth_buffer; } }

Contributors

PersonTokensPropCommitsCommitProp
Samuel Thibault36100.00%1100.00%
Total36100.00%1100.00%

EXPORT_SYMBOL_GPL(synth_buffer_skip_nonlatin1);
void synth_buffer_clear(void) { buff_in = synth_buffer; buff_out = synth_buffer; }

Contributors

PersonTokensPropCommitsCommitProp
William Hubbs1386.67%150.00%
Burcin Akalin213.33%150.00%
Total15100.00%2100.00%

EXPORT_SYMBOL_GPL(synth_buffer_clear);

Overall Contributors

PersonTokensPropCommitsCommitProp
William Hubbs36282.27%110.00%
Samuel Thibault5813.18%440.00%
Greg Kroah-Hartman132.95%220.00%
Lijo Antony40.91%110.00%
Burcin Akalin20.45%110.00%
Aleksei Fedotov10.23%110.00%
Total440100.00%10100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.