linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Okash Khawaja <okash.khawaja@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	linux-kernel@vger.kernel.org
Cc: William Hubbs <w.d.hubbs@gmail.com>,
	Chris Brannon <chris@the-brannons.com>,
	Kirk Reiser <kirk@reisers.ca>,
	speakup@linux-speakup.org, devel@driverdev.osuosl.org,
	Okash Khawaja <okash.khawaja@gmail.com>
Subject: [patch 1/1] staging: speakup: add send_xchar and tiocmset methods
Date: Sat, 22 Apr 2017 09:00:28 +0100	[thread overview]
Message-ID: <20170422080241.612070589@gmail.com> (raw)
In-Reply-To: 20170422080027.000543118@gmail.com

[-- Attachment #1: 01_add_send_xchar_and_tiocmset_methods --]
[-- Type: text/plain, Size: 4438 bytes --]

This adds two methods to spk_synth struct: send_xchar and tiocmset, and
creates serial implementation for each of them. It takes existing code
in apollo, audptr and spkout which already fits the behaviour of
send_xchar and tiocmset. In follow-up patches there will be TTY-based
implementations of these methods. Then migrating the synths to TTY will
include repointing these methods to their TTY implementations

Rest of the changes simply make use of serial implementation of these two
functions.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Index: linux-staging/drivers/staging/speakup/serialio.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/serialio.c
+++ linux-staging/drivers/staging/speakup/serialio.c
@@ -26,8 +26,13 @@ static const struct old_serial_port *ser
 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);
+
 struct spk_io_ops spk_serial_io_ops = {
 	.synth_out = spk_serial_out,
+	.send_xchar = spk_serial_send_xchar,
+	.tiocmset = spk_serial_tiocmset,
 };
 EXPORT_SYMBOL_GPL(spk_serial_io_ops);
 
@@ -136,6 +141,24 @@ static void start_serial_interrupt(int i
 	outb(1, speakup_info.port_tts + UART_FCR);	/* Turn FIFO On */
 }
 
+static void spk_serial_send_xchar(char ch)
+{
+	int timeout = SPK_XMITR_TIMEOUT;
+
+	while (spk_serial_tx_busy()) {
+		if (!--timeout)
+			break;
+		udelay(1);
+	}
+	outb(ch, speakup_info.port_tts);
+}
+
+static void spk_serial_tiocmset(unsigned int set, unsigned int clear)
+{
+	int old = inb(speakup_info.port_tts + UART_MCR);
+	outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR);
+}
+
 int spk_serial_synth_probe(struct spk_synth *synth)
 {
 	const struct old_serial_port *ser;
Index: linux-staging/drivers/staging/speakup/speakup_apollo.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_apollo.c
+++ linux-staging/drivers/staging/speakup/speakup_apollo.c
@@ -171,9 +171,8 @@ static void do_catch_up(struct spk_synth
 		full_time_val = full_time->u.n.value;
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 		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);
+			synth->io_ops->tiocmset(0, UART_MCR_RTS);
+			synth->io_ops->tiocmset(UART_MCR_RTS, 0);
 			schedule_timeout(msecs_to_jiffies(full_time_val));
 			continue;
 		}
Index: linux-staging/drivers/staging/speakup/speakup_audptr.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_audptr.c
+++ linux-staging/drivers/staging/speakup/speakup_audptr.c
@@ -128,14 +128,7 @@ static struct spk_synth synth_audptr = {
 
 static void synth_flush(struct spk_synth *synth)
 {
-	int timeout = SPK_XMITR_TIMEOUT;
-
-	while (spk_serial_tx_busy()) {
-		if (!--timeout)
-			break;
-		udelay(1);
-	}
-	outb(SYNTH_CLEAR, speakup_info.port_tts);
+	synth->io_ops->send_xchar(SYNTH_CLEAR);
 	synth->io_ops->synth_out(synth, PROCSPEECH);
 }
 
Index: linux-staging/drivers/staging/speakup/speakup_spkout.c
===================================================================
--- linux-staging.orig/drivers/staging/speakup/speakup_spkout.c
+++ linux-staging/drivers/staging/speakup/speakup_spkout.c
@@ -126,14 +126,7 @@ static struct spk_synth synth_spkout = {
 
 static void synth_flush(struct spk_synth *synth)
 {
-	int timeout = SPK_XMITR_TIMEOUT;
-
-	while (spk_serial_tx_busy()) {
-		if (!--timeout)
-			break;
-		udelay(1);
-	}
-	outb(SYNTH_CLEAR, speakup_info.port_tts);
+	synth->io_ops->send_xchar(SYNTH_CLEAR);
 }
 
 module_param_named(ser, synth_spkout.ser, int, 0444);
Index: linux-staging/drivers/staging/speakup/spk_types.h
===================================================================
--- linux-staging.orig/drivers/staging/speakup/spk_types.h
+++ linux-staging/drivers/staging/speakup/spk_types.h
@@ -150,6 +150,8 @@ struct spk_synth;
 
 struct spk_io_ops {
 	int (*synth_out)(struct spk_synth *synth, const char ch);
+	void (*send_xchar)(char ch);
+	void (*tiocmset)(unsigned int set, unsigned int clear);
 };
 
 struct spk_synth {

      reply	other threads:[~2017-04-22  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-22  8:00 [patch 0/1] staging: speakup: refactor to allow smoother migration to TTY-based comms with external synths Okash Khawaja
2017-04-22  8:00 ` Okash Khawaja [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170422080241.612070589@gmail.com \
    --to=okash.khawaja@gmail.com \
    --cc=chris@the-brannons.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kirk@reisers.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=speakup@linux-speakup.org \
    --cc=w.d.hubbs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).