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

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

staging: speakup: add spk_io_ops struct to spk_synth



This patch adds spk_io_ops struct which contain those methods whose job is to
communicate with synth device. Currently, all comms with external synth
device use raw serial i/o. The idea is to group all methods which do the
actual communication with external device into this new struct. Then migrating
a serial-based synth over to an alternative to raw serial i/o will mean
swapping serial spk_io_ops instance with the io_ops instance of the new
method, making the migration simpler.

At the moment, this struct only contains one method, synth_out but more will
be added in future when migrating synths which require input functionality.
Also at the moment, synth_out method has one implementation which uses
serial i/o. Plan is to add an alternative.

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 9176d156
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -24,6 +24,12 @@ static const struct old_serial_port rs_table[] = {
static const struct old_serial_port *serstate;
static int timeouts;

static int spk_serial_out(struct spk_synth *in_synth, const char ch);
struct spk_io_ops spk_serial_io_ops = {
	.synth_out = spk_serial_out,
};
EXPORT_SYMBOL_GPL(spk_serial_io_ops);

const struct old_serial_port *spk_serial_init(int index)
{
	int baud = 9600, quot = 0;
@@ -214,7 +220,6 @@ int spk_serial_out(struct spk_synth *in_synth, const char ch)
	}
	return 0;
}
EXPORT_SYMBOL_GPL(spk_serial_out);

void spk_serial_release(void)
{
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ static struct spk_synth synth_acntpc = {
	.startup = SYNTH_START,
	.checkval = SYNTH_CHECK,
	.vars = vars,
	.io_ops = &spk_serial_io_ops,
	.probe = synth_probe,
	.release = accent_release,
	.synth_immediate = synth_immediate,
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ static struct spk_synth synth_acntsa = {
	.startup = SYNTH_START,
	.checkval = SYNTH_CHECK,
	.vars = vars,
	.io_ops = &spk_serial_io_ops,
	.probe = synth_probe,
	.release = spk_serial_release,
	.synth_immediate = spk_synth_immediate,
+4 −3
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ static struct spk_synth synth_apollo = {
	.startup = SYNTH_START,
	.checkval = SYNTH_CHECK,
	.vars = vars,
	.io_ops = &spk_serial_io_ops,
	.probe = spk_serial_synth_probe,
	.release = spk_serial_release,
	.synth_immediate = spk_synth_immediate,
@@ -169,7 +170,7 @@ static void do_catch_up(struct spk_synth *synth)
		set_current_state(TASK_INTERRUPTIBLE);
		full_time_val = full_time->u.n.value;
		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
		if (!spk_serial_out(synth, ch)) {
		if (!synth->io_ops->synth_out(synth, ch)) {
			outb(UART_MCR_DTR, speakup_info.port_tts + UART_MCR);
			outb(UART_MCR_DTR | UART_MCR_RTS,
					speakup_info.port_tts + UART_MCR);
@@ -182,7 +183,7 @@ static void do_catch_up(struct spk_synth *synth)
			full_time_val = full_time->u.n.value;
			delay_time_val = delay_time->u.n.value;
			spin_unlock_irqrestore(&speakup_info.spinlock, flags);
			if (spk_serial_out(synth, synth->procspeech))
			if (synth->io_ops->synth_out(synth, synth->procspeech))
				schedule_timeout(msecs_to_jiffies
						 (delay_time_val));
			else
@@ -195,7 +196,7 @@ static void do_catch_up(struct spk_synth *synth)
		synth_buffer_getc();
		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
	}
	spk_serial_out(synth, PROCSPEECH);
	synth->io_ops->synth_out(synth, PROCSPEECH);
}

module_param_named(ser, synth_apollo.ser, int, 0444);
+2 −1
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ static struct spk_synth synth_audptr = {
	.startup = SYNTH_START,
	.checkval = SYNTH_CHECK,
	.vars = vars,
	.io_ops = &spk_serial_io_ops,
	.probe = synth_probe,
	.release = spk_serial_release,
	.synth_immediate = spk_synth_immediate,
@@ -135,7 +136,7 @@ static void synth_flush(struct spk_synth *synth)
		udelay(1);
	}
	outb(SYNTH_CLEAR, speakup_info.port_tts);
	spk_serial_out(synth, PROCSPEECH);
	synth->io_ops->synth_out(synth, PROCSPEECH);
}

static void synth_version(struct spk_synth *synth)
Loading