Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ir Implement speed setting.



details:   https://anonhg.NetBSD.org/src/rev/5ff9c22ebc49
branches:  trunk
changeset: 518725:5ff9c22ebc49
user:      augustss <augustss%NetBSD.org@localhost>
date:      Tue Dec 04 20:53:21 2001 +0000

description:
Implement speed setting.

diffstat:

 sys/dev/ir/irframe_tty.c |  73 +++++++++++++++++++++++++++++------------------
 1 files changed, 45 insertions(+), 28 deletions(-)

diffs (133 lines):

diff -r 79707029c653 -r 5ff9c22ebc49 sys/dev/ir/irframe_tty.c
--- a/sys/dev/ir/irframe_tty.c  Tue Dec 04 20:52:48 2001 +0000
+++ b/sys/dev/ir/irframe_tty.c  Tue Dec 04 20:53:21 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irframe_tty.c,v 1.2 2001/12/04 19:56:43 augustss Exp $ */
+/*     $NetBSD: irframe_tty.c,v 1.3 2001/12/04 20:53:21 augustss Exp $ */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -248,14 +248,6 @@
 
        splx(s);
 
-       sc->sc_ebofs = IRDA_DEFAULT_EBOFS;
-       sc->sc_maxsize = 0;
-       sc->sc_framestate = FRAME_OUTSIDE;
-       sc->sc_nframes = 0;
-       sc->sc_framei = 0;
-       sc->sc_frameo = 0;
-       callout_init(&sc->sc_timeout);
-
        return (0);
 }
 
@@ -270,24 +262,9 @@
 {
        struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
        int s;
-       int i;
 
        DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
 
-       callout_stop(&sc->sc_timeout);
-       s = splir();
-       if (sc->sc_inbuf != NULL) {
-               free(sc->sc_inbuf, M_DEVBUF);
-               sc->sc_inbuf = NULL;
-       }
-       for (i = 0; i < MAXFRAMES; i++) {
-               if (sc->sc_frames[i].buf != NULL) {
-                       free(sc->sc_frames[i].buf, M_DEVBUF);
-                       sc->sc_frames[i].buf = NULL;
-               }
-       }
-       splx(s);
-
        s = spltty();
        ttyflush(tp, FREAD | FWRITE);
        tp->t_linesw = linesw[0]; /* default line discipline */
@@ -461,9 +438,18 @@
 irframet_open(void *h, int flag, int mode, struct proc *p)
 {
        struct tty *tp = h;
+       struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
 
-       tp = tp;
        DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
+
+       sc->sc_ebofs = IRDA_DEFAULT_EBOFS;
+       sc->sc_maxsize = 0;
+       sc->sc_framestate = FRAME_OUTSIDE;
+       sc->sc_nframes = 0;
+       sc->sc_framei = 0;
+       sc->sc_frameo = 0;
+       callout_init(&sc->sc_timeout);
+
        return (0);
 }
 
@@ -471,9 +457,25 @@
 irframet_close(void *h, int flag, int mode, struct proc *p)
 {
        struct tty *tp = h;
+       struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
+       int i, s;
 
-       tp = tp;
        DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
+
+       callout_stop(&sc->sc_timeout);
+       s = splir();
+       if (sc->sc_inbuf != NULL) {
+               free(sc->sc_inbuf, M_DEVBUF);
+               sc->sc_inbuf = NULL;
+       }
+       for (i = 0; i < MAXFRAMES; i++) {
+               if (sc->sc_frames[i].buf != NULL) {
+                       free(sc->sc_frames[i].buf, M_DEVBUF);
+                       sc->sc_frames[i].buf = NULL;
+               }
+       }
+       splx(s);
+
        return (0);
 }
 
@@ -636,6 +638,7 @@
        DPRINTF(("%s: sc=%p\n", __FUNCTION__, sc));
 
        s = splir();
+       /* XXX should check with tty */
        if (events & (POLLOUT | POLLWRNORM))
                revents |= events & (POLLOUT | POLLWRNORM);
        if (events & (POLLIN | POLLRDNORM)) {
@@ -656,12 +659,26 @@
 irframet_set_params(void *h, struct irda_params *p)
 {
        struct tty *tp = h;
-       struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
+       struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;  
+       struct termios tt;
        int i;
 
        DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
 
-       /* XXX speed */
+       switch (p->speed) {
+       case   2400:
+       case   9600:
+       case  19200:
+       case  38400:
+       case  57600:
+       case 115200:
+               break;
+       default: return (EINVAL);
+       }
+       ttioctl(tp, TIOCGETA,  (caddr_t)&tt, 0, curproc);
+       tt.c_ispeed = tt.c_ospeed = p->speed;
+       ttioctl(tp, TIOCSETAF, (caddr_t)&tt, 0, curproc);
+
        sc->sc_ebofs = p->ebofs;
        if (sc->sc_maxsize != p->maxsize) {
                sc->sc_maxsize = p->maxsize;



Home | Main Index | Thread Index | Old Index