From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id D10B31F0768; Thu, 13 Apr 2017 13:47:57 -0400 (EDT) Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by befuddled.reisers.ca (Postfix) with ESMTPS id E4DF21F0753 for ; Thu, 13 Apr 2017 13:47:33 -0400 (EDT) Received: by mail-wm0-x244.google.com with SMTP id x75so13957734wma.1 for ; Thu, 13 Apr 2017 10:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:user-agent:date:from:to:cc:subject:references :mime-version:content-disposition; bh=jPAHtWn3+1KlYuA31ysp1xRqwUmUHCJJJ1zBNHAId3c=; b=jjwtsm7bmPMGTBunhVGgff8U4ghBsTh7fxu54l4h48kqPrhmZuof0b4P4wzOBX7IuI lsVll0k1pSUi4gax9LZxcfe+QLUBw83FH6mgLWPpFHXl+YD6udBdaAEnsc7SQSD6sFGm RsHfda4jkkVxybGo01vZX+LtqjJRJyDH2IFG9VSsCYpsIFalEPPaUl9byVIovm72NWhS 5raPN32jsJuAIXpjAWUAOiqoOWHbKNkb/Ux9bWgROwDa3zrU3ECVw1VaBdeuClgBlPzB mLSjMZ1BMYjJ0fusXjXhlbl+ADg3g2BcvynP0sIE8U48d+RT+owUmogtsifc4w/+1oTG pKjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-disposition; bh=jPAHtWn3+1KlYuA31ysp1xRqwUmUHCJJJ1zBNHAId3c=; b=WoqCpeC/p3ndb+jq/yj+uBY+RxW1M2eheEHlOA9HFcQwA0mEUFpGV08U0kEhUqurPc CmYDg3OSqYObdVft+wZgB8rsIaZ+rTt82ZtcDrdTqHoCeObA14X3Hg6znKGi282UesRD K9XmS1LEVZuAF0ZHuHc0EYHkn+YLrZo0K4esHK/CzaKIwP8zGIJY19BDlDm7jKUmigYU 9oAvKe6Gou98ABNEtYprusTfVU+HSJLSpGGe3PZ+fSw60T/up+r7A1PqiR0WOSnu141n UJ/bnoprQfcTadf00AFz1zSasCTZHWujso2M12l06RydjhIJTH6AKWUDJ0w3Ba9JOT5U /4mw== X-Gm-Message-State: AN3rC/5m2CGBizVomF90zdglmwauxJBAuozWlpuYf2M0A5miwD6G9Vha cuP+CJUeFq8XDQ== X-Received: by 10.28.0.201 with SMTP id 192mr22532449wma.126.1492105647286; Thu, 13 Apr 2017 10:47:27 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5e00:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id j32sm24679763wre.67.2017.04.13.10.47.26 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Apr 2017 10:47:26 -0700 (PDT) Message-Id: <20170413174725.870278884@gmail.com> User-Agent: quilt/0.65 Date: Thu, 13 Apr 2017 18:41:29 +0100 From: Okash Khawaja To: Samuel Thibault Cc: speakup@linux-speakup.org, Okash Khawaja Subject: [patch 1/7] staging: speakup: add send_xchar and tiocmset methods References: <20170413174128.794011516@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=01_add_send_xchar_and_tiocmset_methods X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2017 17:47:58 -0000 X-List-Received-Date: Thu, 13 Apr 2017 17:47:58 -0000 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 Reviewed-by: Samuel Thibault 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 {