Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca693dcd authored by Okash Khawaja's avatar Okash Khawaja Committed by Greg Kroah-Hartman
Browse files

staging: speakup: make input functionality swappable



This moves functions which take input from external synth, into struct
spk_io_ops. The calling code then uses serial implementation of those methods
through spk_io_ops. That way we can add a parallel TTY-based implementation and
simply replace serial with TTY. That is what the next patch in this series does.

speakup_decext.c has get_last_char function which reads the most recent
available character from the synth. This patch changes that by defining
read_buff_add callback method of spk_syth and letting that update the last_char
global character read from the synth. read_buff_add is called from ISR, so
there is a possibility for last_char to be stale. Therefore it is marked as
volatile. It also pulls a repeated get_index implementation into synth.c, to
be used as a utility function.

Signed-off-by: default avatarOkash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2a3e1437
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -28,11 +28,15 @@ static int timeouts;
static int spk_serial_out(struct spk_synth *in_synth, const char ch);
static void spk_serial_send_xchar(char ch);
static void spk_serial_tiocmset(unsigned int set, unsigned int clear);
static unsigned char spk_serial_in(void);
static unsigned char spk_serial_in_nowait(void);

struct spk_io_ops spk_serial_io_ops = {
	.synth_out = spk_serial_out,
	.send_xchar = spk_serial_send_xchar,
	.tiocmset = spk_serial_tiocmset,
	.synth_in = spk_serial_in,
	.synth_in_nowait = spk_serial_in_nowait,
};
EXPORT_SYMBOL_GPL(spk_serial_io_ops);

@@ -240,7 +244,7 @@ int spk_wait_for_xmitr(struct spk_synth *in_synth)
	return 1;
}

unsigned char spk_serial_in(void)
static unsigned char spk_serial_in(void)
{
	int tmout = SPK_SERIAL_TIMEOUT;

@@ -253,9 +257,8 @@ unsigned char spk_serial_in(void)
	}
	return inb_p(speakup_info.port_tts + UART_RX);
}
EXPORT_SYMBOL_GPL(spk_serial_in);

unsigned char spk_serial_in_nowait(void)
static unsigned char spk_serial_in_nowait(void)
{
	unsigned char lsr;

@@ -264,7 +267,6 @@ unsigned char spk_serial_in_nowait(void)
		return 0;
	return inb_p(speakup_info.port_tts + UART_RX);
}
EXPORT_SYMBOL_GPL(spk_serial_in_nowait);

static int spk_serial_out(struct spk_synth *in_synth, const char ch)
{
+2 −2
Original line number Diff line number Diff line
@@ -138,11 +138,11 @@ static void synth_version(struct spk_synth *synth)
	char synth_id[40] = "";

	synth->synth_immediate(synth, "\x05[Q]");
	synth_id[test] = spk_serial_in();
	synth_id[test] = synth->io_ops->synth_in();
	if (synth_id[test] == 'A') {
		do {
			/* read version string from synth */
			synth_id[++test] = spk_serial_in();
			synth_id[++test] = synth->io_ops->synth_in();
		} while (synth_id[test] != '\n' && test < 32);
		synth_id[++test] = 0x00;
	}
+5 −9
Original line number Diff line number Diff line
@@ -30,20 +30,16 @@
#define DRV_VERSION "2.14"
#define SYNTH_CLEAR 0x03
#define PROCSPEECH 0x0b
static unsigned char last_char;
static volatile unsigned char last_char;

static inline u_char get_last_char(void)
static void read_buff_add(u_char ch)
{
	u_char avail = inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR;

	if (avail)
		last_char = inb_p(speakup_info.port_tts + UART_RX);
	return last_char;
	last_char = ch;
}

static inline bool synth_full(void)
{
	return get_last_char() == 0x13;
	return last_char == 0x13;
}

static void do_catch_up(struct spk_synth *synth);
@@ -135,7 +131,7 @@ static struct spk_synth synth_decext = {
	.flush = synth_flush,
	.is_alive = spk_synth_is_alive_restart,
	.synth_adjust = NULL,
	.read_buff_add = NULL,
	.read_buff_add = read_buff_add,
	.get_index = NULL,
	.indexing = {
		.command = NULL,
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ static inline int synth_full(void)
static void do_catch_up(struct spk_synth *synth);
static void synth_flush(struct spk_synth *synth);
static void read_buff_add(u_char c);
static unsigned char get_index(void);
static unsigned char get_index(struct spk_synth *synth);

static int in_escape;
static int is_flushing;
@@ -163,7 +163,7 @@ static int is_indnum(u_char *ch)

static u_char lastind;

static unsigned char get_index(void)
static unsigned char get_index(struct spk_synth *synth)
{
	u_char rv;

+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ static struct spk_synth synth_dtlk = {
	.is_alive = spk_synth_is_alive_nop,
	.synth_adjust = NULL,
	.read_buff_add = NULL,
	.get_index = spk_serial_in_nowait,
	.get_index = spk_synth_get_index,
	.indexing = {
		.command = "\x01%di",
		.lowindex = 1,
Loading