2007-11-19 21:51:36 +03:00
|
|
|
/* $NetBSD: irframe_tty.c,v 1.47 2007/11/19 18:51:48 ad Exp $ */
|
2001-12-05 02:33:33 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO
|
2001-12-13 20:14:21 +03:00
|
|
|
* Test dongle code.
|
2001-12-05 02:33:33 +03:00
|
|
|
*/
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2001-12-05 04:13:58 +03:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) and Tommy Bohlin
|
|
|
|
* (tommy@gatespace.com).
|
2001-12-04 02:32:32 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loosely based on ppp_tty.c.
|
2001-12-05 17:50:13 +03:00
|
|
|
* Framing and dongle handling written by Tommy Bohlin.
|
2001-12-04 02:32:32 +03:00
|
|
|
*/
|
|
|
|
|
2003-07-14 19:47:00 +04:00
|
|
|
#include <sys/cdefs.h>
|
2007-11-19 21:51:36 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.47 2007/11/19 18:51:48 ad Exp $");
|
2003-07-14 19:47:00 +04:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/kernel.h>
|
2001-12-14 15:56:58 +03:00
|
|
|
#include <sys/lock.h>
|
2001-12-04 22:56:43 +03:00
|
|
|
#include <sys/malloc.h>
|
2001-12-04 02:32:32 +03:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/file.h>
|
2001-12-04 22:56:43 +03:00
|
|
|
#include <sys/vnode.h>
|
2001-12-04 02:32:32 +03:00
|
|
|
#include <sys/poll.h>
|
2006-05-15 01:42:26 +04:00
|
|
|
#include <sys/kauth.h>
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
#include <dev/ir/ir.h>
|
2001-12-05 17:50:13 +03:00
|
|
|
#include <dev/ir/sir.h>
|
2001-12-04 02:32:32 +03:00
|
|
|
#include <dev/ir/irdaio.h>
|
|
|
|
#include <dev/ir/irframevar.h>
|
|
|
|
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
#define DPRINTF(x) if (irframetdebug) printf x
|
2001-12-05 07:31:02 +03:00
|
|
|
int irframetdebug = 0;
|
2001-12-04 02:32:32 +03:00
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*****/
|
|
|
|
|
2001-12-13 18:09:07 +03:00
|
|
|
/* Max size with framing. */
|
|
|
|
#define MAX_IRDA_FRAME (2*IRDA_MAX_FRAME_SIZE + IRDA_MAX_EBOFS + 4)
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2003-06-13 19:09:17 +04:00
|
|
|
struct irt_frame {
|
2001-12-04 22:56:43 +03:00
|
|
|
u_char *buf;
|
|
|
|
u_int len;
|
|
|
|
};
|
2001-12-14 15:56:58 +03:00
|
|
|
#define MAXFRAMES 8
|
2001-12-04 22:56:43 +03:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
struct irframet_softc {
|
|
|
|
struct irframe_softc sc_irp;
|
|
|
|
struct tty *sc_tp;
|
2001-12-04 22:56:43 +03:00
|
|
|
|
2001-12-05 02:33:33 +03:00
|
|
|
int sc_dongle;
|
2001-12-05 22:59:54 +03:00
|
|
|
int sc_dongle_private;
|
2001-12-05 02:33:33 +03:00
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
int sc_state;
|
|
|
|
#define IRT_RSLP 0x01 /* waiting for data (read) */
|
|
|
|
#if 0
|
|
|
|
#define IRT_WSLP 0x02 /* waiting for data (write) */
|
|
|
|
#define IRT_CLOSING 0x04 /* waiting for output to drain */
|
|
|
|
#endif
|
2001-12-14 15:56:58 +03:00
|
|
|
struct lock sc_wr_lk;
|
2001-12-04 22:56:43 +03:00
|
|
|
|
2001-12-14 15:56:58 +03:00
|
|
|
struct irda_params sc_params;
|
2001-12-04 22:56:43 +03:00
|
|
|
|
|
|
|
u_char* sc_inbuf;
|
|
|
|
int sc_framestate;
|
|
|
|
#define FRAME_OUTSIDE 0
|
|
|
|
#define FRAME_INSIDE 1
|
|
|
|
#define FRAME_ESCAPE 2
|
|
|
|
int sc_inchars;
|
|
|
|
int sc_inFCS;
|
|
|
|
struct callout sc_timeout;
|
|
|
|
|
|
|
|
u_int sc_nframes;
|
|
|
|
u_int sc_framei;
|
|
|
|
u_int sc_frameo;
|
2003-06-13 19:09:17 +04:00
|
|
|
struct irt_frame sc_frames[MAXFRAMES];
|
2006-06-10 01:58:57 +04:00
|
|
|
u_int8_t sc_buffer[MAX_IRDA_FRAME];
|
2001-12-04 22:56:43 +03:00
|
|
|
struct selinfo sc_rsel;
|
2002-10-23 13:10:23 +04:00
|
|
|
/* XXXJRT Nothing selnotify's sc_wsel */
|
|
|
|
struct selinfo sc_wsel;
|
2001-12-04 02:32:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* line discipline methods */
|
2005-05-30 02:15:25 +04:00
|
|
|
int irframetopen(dev_t, struct tty *);
|
|
|
|
int irframetclose(struct tty *, int);
|
2007-03-04 08:59:00 +03:00
|
|
|
int irframetioctl(struct tty *, u_long, void *, int, struct lwp *);
|
2005-05-30 02:15:25 +04:00
|
|
|
int irframetinput(int, struct tty *);
|
|
|
|
int irframetstart(struct tty *);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
/* pseudo device init */
|
2001-12-04 02:32:32 +03:00
|
|
|
void irframettyattach(int);
|
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
/* irframe methods */
|
2005-12-11 15:16:03 +03:00
|
|
|
static int irframet_open(void *, int, int, struct lwp *);
|
|
|
|
static int irframet_close(void *, int, int, struct lwp *);
|
2005-05-30 02:15:25 +04:00
|
|
|
static int irframet_read(void *, struct uio *, int);
|
|
|
|
static int irframet_write(void *, struct uio *, int);
|
2005-12-11 15:16:03 +03:00
|
|
|
static int irframet_poll(void *, int, struct lwp *);
|
2005-05-30 02:15:25 +04:00
|
|
|
static int irframet_kqfilter(void *, struct knote *);
|
|
|
|
|
|
|
|
static int irframet_set_params(void *, struct irda_params *);
|
|
|
|
static int irframet_get_speeds(void *, int *);
|
|
|
|
static int irframet_get_turnarounds(void *, int *);
|
2001-12-04 22:56:43 +03:00
|
|
|
|
|
|
|
/* internal */
|
2005-05-30 02:15:25 +04:00
|
|
|
static int irt_write_frame(struct tty *, u_int8_t *, size_t);
|
|
|
|
static int irt_putc(struct tty *, int);
|
|
|
|
static void irt_frame(struct irframet_softc *, u_char *, u_int);
|
|
|
|
static void irt_timeout(void *);
|
|
|
|
static void irt_ioctl(struct tty *, u_long, void *);
|
|
|
|
static void irt_setspeed(struct tty *, u_int);
|
|
|
|
static void irt_setline(struct tty *, u_int);
|
|
|
|
static void irt_delay(struct tty *, u_int);
|
|
|
|
|
|
|
|
static const struct irframe_methods irframet_methods = {
|
2001-12-04 02:32:32 +03:00
|
|
|
irframet_open, irframet_close, irframet_read, irframet_write,
|
2002-10-23 13:10:23 +04:00
|
|
|
irframet_poll, irframet_kqfilter, irframet_set_params,
|
2001-12-04 22:56:43 +03:00
|
|
|
irframet_get_speeds, irframet_get_turnarounds
|
2001-12-04 02:32:32 +03:00
|
|
|
};
|
|
|
|
|
2005-05-30 02:15:25 +04:00
|
|
|
static void irts_none(struct tty *, u_int);
|
|
|
|
static void irts_tekram(struct tty *, u_int);
|
|
|
|
static void irts_jeteye(struct tty *, u_int);
|
|
|
|
static void irts_actisys(struct tty *, u_int);
|
|
|
|
static void irts_litelink(struct tty *, u_int);
|
|
|
|
static void irts_girbil(struct tty *, u_int);
|
2001-12-05 22:59:54 +03:00
|
|
|
|
|
|
|
#define NORMAL_SPEEDS (IRDA_SPEEDS_SIR & ~IRDA_SPEED_2400)
|
|
|
|
#define TURNT_POS (IRDA_TURNT_10000 | IRDA_TURNT_5000 | IRDA_TURNT_1000 | \
|
|
|
|
IRDA_TURNT_500 | IRDA_TURNT_100 | IRDA_TURNT_50 | IRDA_TURNT_10)
|
2005-05-30 02:15:25 +04:00
|
|
|
static const struct dongle {
|
|
|
|
void (*setspeed)(struct tty *, u_int);
|
2001-12-05 22:59:54 +03:00
|
|
|
u_int speedmask;
|
|
|
|
u_int turnmask;
|
|
|
|
} irt_dongles[DONGLE_MAX] = {
|
|
|
|
/* Indexed by dongle number from irdaio.h */
|
|
|
|
{ irts_none, IRDA_SPEEDS_SIR, IRDA_TURNT_10000 },
|
|
|
|
{ irts_tekram, IRDA_SPEEDS_SIR, IRDA_TURNT_10000 },
|
|
|
|
{ irts_jeteye, IRDA_SPEED_9600|IRDA_SPEED_19200|IRDA_SPEED_115200,
|
|
|
|
IRDA_TURNT_10000 },
|
|
|
|
{ irts_actisys, NORMAL_SPEEDS & ~IRDA_SPEED_38400, TURNT_POS },
|
|
|
|
{ irts_actisys, NORMAL_SPEEDS, TURNT_POS },
|
|
|
|
{ irts_litelink, NORMAL_SPEEDS, TURNT_POS },
|
|
|
|
{ irts_girbil, IRDA_SPEEDS_SIR, IRDA_TURNT_10000 | IRDA_TURNT_5000 },
|
|
|
|
};
|
|
|
|
|
2005-11-27 08:35:52 +03:00
|
|
|
static struct linesw irframet_disc = {
|
|
|
|
.l_name = "irframe",
|
|
|
|
.l_open = irframetopen,
|
|
|
|
.l_close = irframetclose,
|
|
|
|
.l_read = ttyerrio,
|
|
|
|
.l_write = ttyerrio,
|
|
|
|
.l_ioctl = irframetioctl,
|
|
|
|
.l_rint = irframetinput,
|
|
|
|
.l_start = irframetstart,
|
|
|
|
.l_modem = ttymodem,
|
|
|
|
.l_poll = ttyerrpoll
|
|
|
|
};
|
|
|
|
|
2007-03-06 23:45:59 +03:00
|
|
|
/* glue to attach irframe device */
|
|
|
|
static void irframet_attach(struct device *, struct device *, void *);
|
|
|
|
static int irframet_detach(struct device *, int);
|
|
|
|
|
|
|
|
CFATTACH_DECL(irframet, sizeof(struct irframet_softc),
|
|
|
|
NULL, irframet_attach, irframet_detach, NULL);
|
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
irframettyattach(int n)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
2007-03-08 22:35:44 +03:00
|
|
|
extern struct cfdriver irframe_cd;
|
2005-11-27 08:35:52 +03:00
|
|
|
|
|
|
|
(void) ttyldisc_attach(&irframet_disc);
|
2007-03-06 23:45:59 +03:00
|
|
|
|
2007-03-08 22:35:44 +03:00
|
|
|
/* XXX might fail if "real" attachments have pulled this in */
|
|
|
|
/* XXX should not be done here */
|
|
|
|
config_cfdriver_attach(&irframe_cd);
|
|
|
|
|
2007-03-06 23:45:59 +03:00
|
|
|
config_cfattach_attach("irframe", &irframet_ca);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
irframet_attach(struct device *parent, struct device *self, void *aux)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* pseudo-device attachment does not print name */
|
|
|
|
printf("%s", self->dv_xname);
|
|
|
|
#if 0 /* XXX can't do it yet because pseudo-devices don't get aux */
|
|
|
|
struct ir_attach_args ia;
|
|
|
|
|
|
|
|
ia.ia_methods = &irframet_methods;
|
|
|
|
ia.ia_handle = aux->xxx;
|
|
|
|
|
|
|
|
irframe_attach(parent, self, &ia);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
irframet_detach(struct device *dev, int flags)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (irframe_detach(dev, flags));
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Line specific open routine for async tty devices.
|
|
|
|
* Attach the given tty to the first available irframe unit.
|
|
|
|
* Called from device open routine or ttioctl.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
irframetopen(dev_t dev, struct tty *tp)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
2005-12-11 15:16:03 +03:00
|
|
|
struct lwp *l = curlwp; /* XXX */
|
2001-12-04 02:32:32 +03:00
|
|
|
struct irframet_softc *sc;
|
|
|
|
int error, s;
|
2007-03-06 23:45:59 +03:00
|
|
|
struct cfdata *cfdata;
|
|
|
|
struct ir_attach_args ia;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s\n", __FUNCTION__));
|
|
|
|
|
2006-10-01 23:28:43 +04:00
|
|
|
if ((error = kauth_authorize_device_tty(l->l_cred,
|
|
|
|
KAUTH_DEVICE_TTY_OPEN, tp)))
|
2001-12-04 02:32:32 +03:00
|
|
|
return (error);
|
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: linesw=%p disc=%s\n", __FUNCTION__, tp->t_linesw,
|
|
|
|
tp->t_linesw->l_name));
|
2005-11-27 08:35:52 +03:00
|
|
|
if (tp->t_linesw == &irframet_disc) {
|
2001-12-04 02:32:32 +03:00
|
|
|
sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
DPRINTF(("%s: sc=%p sc_tp=%p\n", __FUNCTION__, sc, sc->sc_tp));
|
|
|
|
if (sc != NULL) {
|
|
|
|
splx(s);
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-06 23:45:59 +03:00
|
|
|
cfdata = malloc(sizeof(struct cfdata), M_DEVBUF, M_WAITOK);
|
|
|
|
cfdata->cf_name = "irframe";
|
|
|
|
cfdata->cf_atname = "irframet";
|
|
|
|
cfdata->cf_fstate = FSTATE_STAR;
|
|
|
|
cfdata->cf_unit = 0;
|
|
|
|
sc = (struct irframet_softc *)config_attach_pseudo(cfdata);
|
|
|
|
|
|
|
|
/* XXX should be done in irframet_attach() */
|
|
|
|
ia.ia_methods = &irframet_methods;
|
|
|
|
ia.ia_handle = tp;
|
|
|
|
irframe_attach(0, (struct device *)sc, &ia);
|
|
|
|
|
|
|
|
tp->t_sc = sc;
|
2001-12-04 02:32:32 +03:00
|
|
|
sc->sc_tp = tp;
|
2001-12-05 07:07:06 +03:00
|
|
|
printf("%s attached at tty%02d\n", sc->sc_irp.sc_dev.dv_xname,
|
|
|
|
minor(tp->t_dev));
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: set sc=%p\n", __FUNCTION__, sc));
|
|
|
|
|
2007-11-10 21:29:36 +03:00
|
|
|
mutex_spin_enter(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
ttyflush(tp, FREAD | FWRITE);
|
2007-11-10 21:29:36 +03:00
|
|
|
mutex_spin_exit(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-05 02:33:33 +03:00
|
|
|
sc->sc_dongle = DONGLE_NONE;
|
2001-12-05 22:59:54 +03:00
|
|
|
sc->sc_dongle_private = 0;
|
2001-12-05 02:33:33 +03:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
splx(s);
|
2001-12-04 22:56:43 +03:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Line specific close routine, called from device close routine
|
|
|
|
* and from ttioctl.
|
|
|
|
* Detach the tty from the irframe unit.
|
|
|
|
* Mimics part of ttyclose().
|
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
irframetclose(struct tty *tp, int flag)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int s;
|
2007-03-06 23:45:59 +03:00
|
|
|
struct cfdata *cfdata;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
|
|
|
|
|
|
|
s = spltty();
|
2007-11-10 21:29:36 +03:00
|
|
|
mutex_spin_enter(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
ttyflush(tp, FREAD | FWRITE);
|
2007-11-10 21:29:36 +03:00
|
|
|
mutex_spin_exit(&tty_lock); /* XXX */
|
2005-11-27 08:35:52 +03:00
|
|
|
ttyldisc_release(tp->t_linesw);
|
|
|
|
tp->t_linesw = ttyldisc_default();
|
2001-12-04 02:32:32 +03:00
|
|
|
if (sc != NULL) {
|
|
|
|
tp->t_sc = NULL;
|
2001-12-04 22:56:43 +03:00
|
|
|
printf("%s detached from tty%02d\n", sc->sc_irp.sc_dev.dv_xname,
|
2001-12-04 02:32:32 +03:00
|
|
|
minor(tp->t_dev));
|
|
|
|
|
2007-03-06 23:45:59 +03:00
|
|
|
if (sc->sc_tp == tp) {
|
|
|
|
cfdata = sc->sc_irp.sc_dev.dv_cfdata;
|
|
|
|
config_detach(&sc->sc_irp.sc_dev, 0);
|
|
|
|
free(cfdata, M_DEVBUF);
|
|
|
|
}
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Line specific (tty) ioctl routine.
|
|
|
|
* This discipline requires that tty device drivers call
|
|
|
|
* the line specific l_ioctl routine from their ioctl routines.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2007-03-04 08:59:00 +03:00
|
|
|
irframetioctl(struct tty *tp, u_long cmd, void *data, int flag,
|
2006-11-16 04:32:37 +03:00
|
|
|
struct lwp *l)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int error;
|
2001-12-05 22:59:54 +03:00
|
|
|
int d;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
|
|
|
|
|
|
|
if (sc == NULL || tp != sc->sc_tp)
|
2002-03-17 22:40:26 +03:00
|
|
|
return (EPASSTHROUGH);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
error = 0;
|
|
|
|
switch (cmd) {
|
2001-12-05 02:33:33 +03:00
|
|
|
case IRFRAMETTY_GET_DEVICE:
|
2006-03-28 21:38:24 +04:00
|
|
|
*(int *)data = device_unit(&sc->sc_irp.sc_dev);
|
2001-12-05 02:33:33 +03:00
|
|
|
break;
|
|
|
|
case IRFRAMETTY_GET_DONGLE:
|
|
|
|
*(int *)data = sc->sc_dongle;
|
|
|
|
break;
|
|
|
|
case IRFRAMETTY_SET_DONGLE:
|
2001-12-05 22:59:54 +03:00
|
|
|
d = *(int *)data;
|
|
|
|
if (d < 0 || d >= DONGLE_MAX)
|
|
|
|
return (EINVAL);
|
|
|
|
sc->sc_dongle = d;
|
2001-12-05 02:33:33 +03:00
|
|
|
break;
|
2001-12-04 02:32:32 +03:00
|
|
|
default:
|
2002-03-17 22:40:26 +03:00
|
|
|
error = EPASSTHROUGH;
|
2001-12-04 02:32:32 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-12-05 17:50:13 +03:00
|
|
|
* Start output on async tty interface.
|
2001-12-04 02:32:32 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
irframetstart(struct tty *tp)
|
|
|
|
{
|
|
|
|
/*struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;*/
|
2001-12-20 14:30:13 +03:00
|
|
|
int s;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
|
|
|
|
2001-12-20 14:30:13 +03:00
|
|
|
s = spltty();
|
2001-12-04 02:32:32 +03:00
|
|
|
if (tp->t_oproc != NULL)
|
|
|
|
(*tp->t_oproc)(tp);
|
2001-12-20 14:30:13 +03:00
|
|
|
splx(s);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
void
|
2005-05-30 02:15:25 +04:00
|
|
|
irt_frame(struct irframet_softc *sc, u_char *tbuf, u_int len)
|
2001-12-04 22:56:43 +03:00
|
|
|
{
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: nframe=%d framei=%d frameo=%d\n",
|
|
|
|
__FUNCTION__, sc->sc_nframes, sc->sc_framei, sc->sc_frameo));
|
|
|
|
|
2001-12-26 13:56:58 +03:00
|
|
|
if (sc->sc_inbuf == NULL) /* XXX happens if device is closed? */
|
|
|
|
return;
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_nframes >= MAXFRAMES) {
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
printf("%s: dropped frame\n", __FUNCTION__);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sc->sc_frames[sc->sc_framei].buf == NULL)
|
|
|
|
return;
|
2005-05-30 02:15:25 +04:00
|
|
|
memcpy(sc->sc_frames[sc->sc_framei].buf, tbuf, len);
|
2001-12-04 22:56:43 +03:00
|
|
|
sc->sc_frames[sc->sc_framei].len = len;
|
|
|
|
sc->sc_framei = (sc->sc_framei+1) % MAXFRAMES;
|
|
|
|
sc->sc_nframes++;
|
|
|
|
if (sc->sc_state & IRT_RSLP) {
|
|
|
|
sc->sc_state &= ~IRT_RSLP;
|
|
|
|
DPRINTF(("%s: waking up reader\n", __FUNCTION__));
|
|
|
|
wakeup(sc->sc_frames);
|
|
|
|
}
|
2002-10-23 13:10:23 +04:00
|
|
|
selnotify(&sc->sc_rsel, 0);
|
2001-12-04 22:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
irt_timeout(void *v)
|
|
|
|
{
|
|
|
|
struct irframet_softc *sc = v;
|
|
|
|
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
if (sc->sc_framestate != FRAME_OUTSIDE)
|
|
|
|
printf("%s: input frame timeout\n", __FUNCTION__);
|
|
|
|
#endif
|
|
|
|
sc->sc_framestate = FRAME_OUTSIDE;
|
|
|
|
}
|
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
int
|
|
|
|
irframetinput(int c, struct tty *tp)
|
|
|
|
{
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
|
2001-12-05 07:07:06 +03:00
|
|
|
c &= 0xff;
|
|
|
|
|
|
|
|
#if IRFRAMET_DEBUG
|
|
|
|
if (irframetdebug > 1)
|
|
|
|
DPRINTF(("%s: tp=%p c=0x%02x\n", __FUNCTION__, tp, c));
|
|
|
|
#endif
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
if (sc == NULL || tp != (struct tty *)sc->sc_tp)
|
|
|
|
return (0);
|
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_inbuf == NULL)
|
|
|
|
return (0);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
switch (c) {
|
|
|
|
case SIR_BOF:
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: BOF\n", __FUNCTION__));
|
2001-12-04 22:56:43 +03:00
|
|
|
sc->sc_framestate = FRAME_INSIDE;
|
|
|
|
sc->sc_inchars = 0;
|
|
|
|
sc->sc_inFCS = INITFCS;
|
|
|
|
break;
|
|
|
|
case SIR_EOF:
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: EOF state=%d inchars=%d fcs=0x%04x\n",
|
|
|
|
__FUNCTION__,
|
|
|
|
sc->sc_framestate, sc->sc_inchars, sc->sc_inFCS));
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_framestate == FRAME_INSIDE &&
|
|
|
|
sc->sc_inchars >= 4 && sc->sc_inFCS == GOODFCS) {
|
|
|
|
irt_frame(sc, sc->sc_inbuf, sc->sc_inchars - 2);
|
|
|
|
} else if (sc->sc_framestate != FRAME_OUTSIDE) {
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
printf("%s: malformed input frame\n", __FUNCTION__);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
sc->sc_framestate = FRAME_OUTSIDE;
|
|
|
|
break;
|
|
|
|
case SIR_CE:
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: CE\n", __FUNCTION__));
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_framestate == FRAME_INSIDE)
|
|
|
|
sc->sc_framestate = FRAME_ESCAPE;
|
|
|
|
break;
|
|
|
|
default:
|
2001-12-05 07:31:02 +03:00
|
|
|
#if IRFRAMET_DEBUG
|
|
|
|
if (irframetdebug > 1)
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: c=0x%02x, inchar=%d state=%d\n", __FUNCTION__, c,
|
|
|
|
sc->sc_inchars, sc->sc_state));
|
2001-12-05 07:31:02 +03:00
|
|
|
#endif
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_framestate != FRAME_OUTSIDE) {
|
|
|
|
if (sc->sc_framestate == FRAME_ESCAPE) {
|
|
|
|
sc->sc_framestate = FRAME_INSIDE;
|
|
|
|
c ^= SIR_ESC_BIT;
|
|
|
|
}
|
2001-12-14 15:56:58 +03:00
|
|
|
if (sc->sc_inchars < sc->sc_params.maxsize + 2) {
|
2001-12-04 22:56:43 +03:00
|
|
|
sc->sc_inbuf[sc->sc_inchars++] = c;
|
|
|
|
sc->sc_inFCS = updateFCS(sc->sc_inFCS, c);
|
|
|
|
} else {
|
|
|
|
sc->sc_framestate = FRAME_OUTSIDE;
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
printf("%s: input frame overrun\n",
|
|
|
|
__FUNCTION__);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
2001-12-05 07:07:06 +03:00
|
|
|
#if 1
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_framestate != FRAME_OUTSIDE) {
|
2001-12-05 07:07:06 +03:00
|
|
|
callout_reset(&sc->sc_timeout, hz/20, irt_timeout, sc);
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
2001-12-05 07:07:06 +03:00
|
|
|
#endif
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
return (0);
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*** irframe methods ***/
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
irframet_open(void *h, int flag, int mode,
|
|
|
|
struct lwp *l)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2001-12-04 23:53:21 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
2001-12-04 23:53:21 +03:00
|
|
|
|
2001-12-14 15:56:58 +03:00
|
|
|
sc->sc_params.speed = 0;
|
|
|
|
sc->sc_params.ebofs = IRDA_DEFAULT_EBOFS;
|
|
|
|
sc->sc_params.maxsize = 0;
|
2001-12-04 23:53:21 +03:00
|
|
|
sc->sc_framestate = FRAME_OUTSIDE;
|
|
|
|
sc->sc_nframes = 0;
|
|
|
|
sc->sc_framei = 0;
|
|
|
|
sc->sc_frameo = 0;
|
2007-07-10 00:51:58 +04:00
|
|
|
callout_init(&sc->sc_timeout, 0);
|
2001-12-14 15:56:58 +03:00
|
|
|
lockinit(&sc->sc_wr_lk, PZERO, "irfrtl", 0, 0);
|
2001-12-04 23:53:21 +03:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
irframet_close(void *h, int flag, int mode,
|
|
|
|
struct lwp *l)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2001-12-04 23:53:21 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int i, s;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
2001-12-04 23:53:21 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
irframet_read(void *h, struct uio *uio, int flag)
|
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2001-12-04 22:56:43 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int error = 0;
|
|
|
|
int s;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2006-10-07 18:31:53 +04:00
|
|
|
DPRINTF(("%s: resid=%zd, iovcnt=%d, offset=%ld\n",
|
2005-02-27 03:26:58 +03:00
|
|
|
__FUNCTION__, uio->uio_resid, uio->uio_iovcnt,
|
2001-12-04 22:56:43 +03:00
|
|
|
(long)uio->uio_offset));
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: nframe=%d framei=%d frameo=%d\n",
|
|
|
|
__FUNCTION__, sc->sc_nframes, sc->sc_framei, sc->sc_frameo));
|
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
s = splir();
|
2001-12-04 22:56:43 +03:00
|
|
|
while (sc->sc_nframes == 0) {
|
|
|
|
if (flag & IO_NDELAY) {
|
|
|
|
splx(s);
|
|
|
|
return (EWOULDBLOCK);
|
|
|
|
}
|
|
|
|
sc->sc_state |= IRT_RSLP;
|
|
|
|
DPRINTF(("%s: sleep\n", __FUNCTION__));
|
|
|
|
error = tsleep(sc->sc_frames, PZERO | PCATCH, "irtrd", 0);
|
|
|
|
DPRINTF(("%s: woke, error=%d\n", __FUNCTION__, error));
|
|
|
|
if (error) {
|
|
|
|
sc->sc_state &= ~IRT_RSLP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do just one frame transfer per read */
|
|
|
|
if (!error) {
|
|
|
|
if (uio->uio_resid < sc->sc_frames[sc->sc_frameo].len) {
|
2001-12-14 15:56:58 +03:00
|
|
|
DPRINTF(("%s: uio buffer smaller than frame size "
|
2006-10-07 18:31:53 +04:00
|
|
|
"(%zd < %d)\n", __FUNCTION__, uio->uio_resid,
|
2001-12-14 15:56:58 +03:00
|
|
|
sc->sc_frames[sc->sc_frameo].len));
|
2001-12-04 22:56:43 +03:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
DPRINTF(("%s: moving %d bytes\n", __FUNCTION__,
|
|
|
|
sc->sc_frames[sc->sc_frameo].len));
|
2001-12-05 07:07:06 +03:00
|
|
|
error = uiomove(sc->sc_frames[sc->sc_frameo].buf,
|
2001-12-04 22:56:43 +03:00
|
|
|
sc->sc_frames[sc->sc_frameo].len, uio);
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: error=%d\n", __FUNCTION__, error));
|
2001-12-04 22:56:43 +03:00
|
|
|
}
|
2001-12-05 07:07:06 +03:00
|
|
|
sc->sc_frameo = (sc->sc_frameo+1) % MAXFRAMES;
|
2001-12-04 22:56:43 +03:00
|
|
|
sc->sc_nframes--;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return (error);
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
2001-12-04 22:56:43 +03:00
|
|
|
int
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_putc(struct tty *tp, int c)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2001-12-05 17:50:13 +03:00
|
|
|
#if IRFRAMET_DEBUG
|
|
|
|
if (irframetdebug > 3)
|
|
|
|
DPRINTF(("%s: tp=%p c=0x%02x cc=%d\n", __FUNCTION__, tp, c,
|
|
|
|
tp->t_outq.c_cc));
|
|
|
|
#endif
|
2001-12-04 02:32:32 +03:00
|
|
|
if (tp->t_outq.c_cc > tp->t_hiwat) {
|
|
|
|
irframetstart(tp);
|
2007-11-07 18:56:11 +03:00
|
|
|
mutex_spin_enter(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
/*
|
|
|
|
* This can only occur if FLUSHO is set in t_lflag,
|
|
|
|
* or if ttstart/oproc is synchronous (or very fast).
|
|
|
|
*/
|
|
|
|
if (tp->t_outq.c_cc <= tp->t_hiwat) {
|
2007-11-07 18:56:11 +03:00
|
|
|
mutex_spin_exit(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
goto go;
|
|
|
|
}
|
2007-11-07 18:56:11 +03:00
|
|
|
error = ttysleep(tp, &tp->t_outq.c_cv, true, 0);
|
|
|
|
mutex_spin_exit(&tty_lock);
|
2001-12-04 02:32:32 +03:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
go:
|
2001-12-05 07:31:02 +03:00
|
|
|
if (putc(c, &tp->t_outq) < 0) {
|
2001-12-04 02:32:32 +03:00
|
|
|
printf("irframe: putc failed\n");
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
irframet_write(void *h, struct uio *uio, int flag)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
2001-12-05 17:50:13 +03:00
|
|
|
struct tty *tp = h;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int n;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2006-10-07 18:31:53 +04:00
|
|
|
DPRINTF(("%s: resid=%zd, iovcnt=%d, offset=%ld\n",
|
2005-02-27 03:26:58 +03:00
|
|
|
__FUNCTION__, uio->uio_resid, uio->uio_iovcnt,
|
2001-12-05 07:07:06 +03:00
|
|
|
(long)uio->uio_offset));
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2006-06-10 01:58:57 +04:00
|
|
|
n = irda_sir_frame(sc->sc_buffer, sizeof(sc->sc_buffer), uio,
|
|
|
|
sc->sc_params.ebofs);
|
2001-12-06 03:11:18 +03:00
|
|
|
if (n < 0) {
|
|
|
|
#ifdef IRFRAMET_DEBUG
|
|
|
|
printf("%s: irda_sir_frame() error=%d\n", __FUNCTION__, -n);
|
|
|
|
#endif
|
2001-12-05 17:50:13 +03:00
|
|
|
return (-n);
|
2001-12-06 03:11:18 +03:00
|
|
|
}
|
2006-06-10 01:58:57 +04:00
|
|
|
return (irt_write_frame(tp, sc->sc_buffer, n));
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-05-30 02:15:25 +04:00
|
|
|
irt_write_frame(struct tty *tp, u_int8_t *tbuf, size_t len)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
2001-12-14 15:56:58 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-05 17:50:13 +03:00
|
|
|
int error, i;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2006-10-07 18:31:53 +04:00
|
|
|
DPRINTF(("%s: tp=%p len=%zd\n", __FUNCTION__, tp, len));
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-14 15:56:58 +03:00
|
|
|
lockmgr(&sc->sc_wr_lk, LK_EXCLUSIVE, NULL);
|
2001-12-04 02:32:32 +03:00
|
|
|
error = 0;
|
2001-12-05 17:50:13 +03:00
|
|
|
for (i = 0; !error && i < len; i++)
|
2005-05-30 02:15:25 +04:00
|
|
|
error = irt_putc(tp, tbuf[i]);
|
2001-12-14 15:56:58 +03:00
|
|
|
lockmgr(&sc->sc_wr_lk, LK_RELEASE, NULL);
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
irframetstart(tp);
|
|
|
|
|
2001-12-05 17:50:13 +03:00
|
|
|
DPRINTF(("%s: done, error=%d\n", __FUNCTION__, error));
|
2001-12-05 07:07:06 +03:00
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-12-11 15:16:03 +03:00
|
|
|
irframet_poll(void *h, int events, struct lwp *l)
|
2001-12-04 02:32:32 +03:00
|
|
|
{
|
2001-12-04 22:56:43 +03:00
|
|
|
struct tty *tp = h;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-04 02:32:32 +03:00
|
|
|
int revents = 0;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
DPRINTF(("%s: sc=%p\n", __FUNCTION__, sc));
|
|
|
|
|
|
|
|
s = splir();
|
2001-12-05 17:50:13 +03:00
|
|
|
/* XXX is this a good check? */
|
2001-12-04 02:32:32 +03:00
|
|
|
if (events & (POLLOUT | POLLWRNORM))
|
2001-12-05 17:50:13 +03:00
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat)
|
|
|
|
revents |= events & (POLLOUT | POLLWRNORM);
|
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
if (events & (POLLIN | POLLRDNORM)) {
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_nframes > 0) {
|
2001-12-04 02:32:32 +03:00
|
|
|
DPRINTF(("%s: have data\n", __FUNCTION__));
|
|
|
|
revents |= events & (POLLIN | POLLRDNORM);
|
|
|
|
} else {
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: recording select\n", __FUNCTION__));
|
2005-12-11 15:16:03 +03:00
|
|
|
selrecord(l, &sc->sc_rsel);
|
2001-12-04 02:32:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return (revents);
|
|
|
|
}
|
|
|
|
|
2002-10-23 13:10:23 +04:00
|
|
|
static void
|
|
|
|
filt_irframetrdetach(struct knote *kn)
|
|
|
|
{
|
|
|
|
struct tty *tp = kn->kn_hook;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splir();
|
2002-11-26 21:49:40 +03:00
|
|
|
SLIST_REMOVE(&sc->sc_rsel.sel_klist, kn, knote, kn_selnext);
|
2002-10-23 13:10:23 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
filt_irframetread(struct knote *kn, long hint)
|
2002-10-23 13:10:23 +04:00
|
|
|
{
|
|
|
|
struct tty *tp = kn->kn_hook;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
|
|
|
|
kn->kn_data = sc->sc_nframes;
|
|
|
|
return (kn->kn_data > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filt_irframetwdetach(struct knote *kn)
|
|
|
|
{
|
|
|
|
struct tty *tp = kn->kn_hook;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
s = splir();
|
2002-11-26 21:49:40 +03:00
|
|
|
SLIST_REMOVE(&sc->sc_wsel.sel_klist, kn, knote, kn_selnext);
|
2002-10-23 13:10:23 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
filt_irframetwrite(struct knote *kn, long hint)
|
2002-10-23 13:10:23 +04:00
|
|
|
{
|
|
|
|
struct tty *tp = kn->kn_hook;
|
|
|
|
|
|
|
|
/* XXX double-check this */
|
|
|
|
|
|
|
|
if (tp->t_outq.c_cc <= tp->t_lowat) {
|
|
|
|
kn->kn_data = tp->t_lowat - tp->t_outq.c_cc;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
kn->kn_data = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct filterops irframetread_filtops =
|
|
|
|
{ 1, NULL, filt_irframetrdetach, filt_irframetread };
|
|
|
|
static const struct filterops irframetwrite_filtops =
|
|
|
|
{ 1, NULL, filt_irframetwdetach, filt_irframetwrite };
|
|
|
|
|
|
|
|
int
|
|
|
|
irframet_kqfilter(void *h, struct knote *kn)
|
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
struct klist *klist;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
switch (kn->kn_filter) {
|
|
|
|
case EVFILT_READ:
|
2002-11-26 21:49:40 +03:00
|
|
|
klist = &sc->sc_rsel.sel_klist;
|
2002-10-23 13:10:23 +04:00
|
|
|
kn->kn_fop = &irframetread_filtops;
|
|
|
|
break;
|
|
|
|
case EVFILT_WRITE:
|
2002-11-26 21:49:40 +03:00
|
|
|
klist = &sc->sc_wsel.sel_klist;
|
2002-10-23 13:10:23 +04:00
|
|
|
kn->kn_fop = &irframetwrite_filtops;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
kn->kn_hook = tp;
|
|
|
|
|
|
|
|
s = splir();
|
|
|
|
SLIST_INSERT_HEAD(klist, kn, kn_selnext);
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-12-04 02:32:32 +03:00
|
|
|
int
|
|
|
|
irframet_set_params(void *h, struct irda_params *p)
|
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2005-02-27 03:26:58 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-04 22:56:43 +03:00
|
|
|
int i;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-05 07:07:06 +03:00
|
|
|
DPRINTF(("%s: tp=%p speed=%d ebofs=%d maxsize=%d\n",
|
|
|
|
__FUNCTION__, tp, p->speed, p->ebofs, p->maxsize));
|
2001-12-04 02:32:32 +03:00
|
|
|
|
2001-12-14 15:56:58 +03:00
|
|
|
if (p->speed != sc->sc_params.speed) {
|
2001-12-13 18:09:07 +03:00
|
|
|
/* Checked in irframe.c */
|
2001-12-14 15:56:58 +03:00
|
|
|
lockmgr(&sc->sc_wr_lk, LK_EXCLUSIVE, NULL);
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_dongles[sc->sc_dongle].setspeed(tp, p->speed);
|
2001-12-14 15:56:58 +03:00
|
|
|
lockmgr(&sc->sc_wr_lk, LK_RELEASE, NULL);
|
|
|
|
sc->sc_params.speed = p->speed;
|
2001-12-04 23:53:21 +03:00
|
|
|
}
|
|
|
|
|
2001-12-13 18:09:07 +03:00
|
|
|
/* Max size checked in irframe.c */
|
2001-12-14 15:56:58 +03:00
|
|
|
sc->sc_params.ebofs = p->ebofs;
|
2001-12-13 18:09:07 +03:00
|
|
|
/* Max size checked in irframe.c */
|
2001-12-14 15:56:58 +03:00
|
|
|
if (sc->sc_params.maxsize != p->maxsize) {
|
|
|
|
sc->sc_params.maxsize = p->maxsize;
|
2001-12-04 22:56:43 +03:00
|
|
|
if (sc->sc_inbuf != NULL)
|
|
|
|
free(sc->sc_inbuf, M_DEVBUF);
|
|
|
|
for (i = 0; i < MAXFRAMES; i++)
|
|
|
|
if (sc->sc_frames[i].buf != NULL)
|
|
|
|
free(sc->sc_frames[i].buf, M_DEVBUF);
|
2001-12-14 15:56:58 +03:00
|
|
|
if (sc->sc_params.maxsize != 0) {
|
|
|
|
sc->sc_inbuf = malloc(sc->sc_params.maxsize+2,
|
|
|
|
M_DEVBUF, M_WAITOK);
|
2001-12-04 22:56:43 +03:00
|
|
|
for (i = 0; i < MAXFRAMES; i++)
|
2001-12-14 15:56:58 +03:00
|
|
|
sc->sc_frames[i].buf =
|
|
|
|
malloc(sc->sc_params.maxsize,
|
|
|
|
M_DEVBUF, M_WAITOK);
|
2001-12-04 22:56:43 +03:00
|
|
|
} else {
|
|
|
|
sc->sc_inbuf = NULL;
|
|
|
|
for (i = 0; i < MAXFRAMES; i++)
|
|
|
|
sc->sc_frames[i].buf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sc->sc_framestate = FRAME_OUTSIDE;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
irframet_get_speeds(void *h, int *speeds)
|
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2005-02-27 03:26:58 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
2001-12-05 22:59:54 +03:00
|
|
|
|
2001-12-06 03:11:18 +03:00
|
|
|
if (sc == NULL) /* during attach */
|
|
|
|
*speeds = IRDA_SPEEDS_SIR;
|
|
|
|
else
|
|
|
|
*speeds = irt_dongles[sc->sc_dongle].speedmask;
|
2001-12-04 02:32:32 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
irframet_get_turnarounds(void *h, int *turnarounds)
|
|
|
|
{
|
|
|
|
struct tty *tp = h;
|
2005-02-27 03:26:58 +03:00
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
2001-12-04 02:32:32 +03:00
|
|
|
|
|
|
|
DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
|
2001-12-05 22:59:54 +03:00
|
|
|
|
|
|
|
*turnarounds = irt_dongles[sc->sc_dongle].turnmask;
|
2001-12-04 02:32:32 +03:00
|
|
|
return (0);
|
|
|
|
}
|
2001-12-05 22:59:54 +03:00
|
|
|
|
2001-12-20 12:26:35 +03:00
|
|
|
void
|
|
|
|
irt_ioctl(struct tty *tp, u_long cmd, void *arg)
|
|
|
|
{
|
2002-09-06 17:18:43 +04:00
|
|
|
const struct cdevsw *cdev;
|
2001-12-20 12:26:35 +03:00
|
|
|
int error;
|
|
|
|
dev_t dev;
|
|
|
|
|
|
|
|
dev = tp->t_dev;
|
2002-09-06 17:18:43 +04:00
|
|
|
cdev = cdevsw_lookup(dev);
|
|
|
|
if (cdev != NULL)
|
2005-12-11 15:16:03 +03:00
|
|
|
error = (*cdev->d_ioctl)(dev, cmd, arg, 0, curlwp);
|
2002-09-06 17:18:43 +04:00
|
|
|
else
|
|
|
|
error = ENXIO;
|
2001-12-20 12:26:35 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (error)
|
|
|
|
printf("irt_ioctl: cmd=0x%08lx error=%d\n", cmd, error);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
void
|
|
|
|
irt_setspeed(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
struct termios tt;
|
|
|
|
|
2001-12-20 12:26:35 +03:00
|
|
|
irt_ioctl(tp, TIOCGETA, &tt);
|
2001-12-05 22:59:54 +03:00
|
|
|
tt.c_ispeed = tt.c_ospeed = speed;
|
2001-12-20 14:30:13 +03:00
|
|
|
tt.c_cflag &= ~HUPCL;
|
|
|
|
tt.c_cflag |= CLOCAL;
|
2001-12-20 12:26:35 +03:00
|
|
|
irt_ioctl(tp, TIOCSETAF, &tt);
|
2001-12-05 22:59:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
irt_setline(struct tty *tp, u_int line)
|
|
|
|
{
|
2001-12-20 12:26:35 +03:00
|
|
|
int mline;
|
|
|
|
|
|
|
|
irt_ioctl(tp, TIOCMGET, &mline);
|
|
|
|
mline &= ~(TIOCM_DTR | TIOCM_RTS);
|
|
|
|
mline |= line;
|
2007-03-04 08:59:00 +03:00
|
|
|
irt_ioctl(tp, TIOCMSET, (void *)&mline);
|
2001-12-05 22:59:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
irt_delay(struct tty *tp, u_int ms)
|
2001-12-05 22:59:54 +03:00
|
|
|
{
|
|
|
|
if (cold)
|
|
|
|
delay(ms * 1000);
|
|
|
|
else
|
2001-12-12 20:21:36 +03:00
|
|
|
tsleep(&irt_delay, PZERO, "irtdly", ms * hz / 1000 + 1);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* No dongle
|
|
|
|
**********************************************************************/
|
|
|
|
void
|
|
|
|
irts_none(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Tekram
|
|
|
|
**********************************************************************/
|
|
|
|
#define TEKRAM_PW 0x10
|
|
|
|
|
|
|
|
#define TEKRAM_115200 (TEKRAM_PW|0x00)
|
|
|
|
#define TEKRAM_57600 (TEKRAM_PW|0x01)
|
|
|
|
#define TEKRAM_38400 (TEKRAM_PW|0x02)
|
|
|
|
#define TEKRAM_19200 (TEKRAM_PW|0x03)
|
|
|
|
#define TEKRAM_9600 (TEKRAM_PW|0x04)
|
|
|
|
#define TEKRAM_2400 (TEKRAM_PW|0x08)
|
|
|
|
|
|
|
|
#define TEKRAM_TV (TEKRAM_PW|0x05)
|
|
|
|
|
|
|
|
void
|
|
|
|
irts_tekram(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
irt_setspeed(tp, 9600);
|
|
|
|
irt_setline(tp, 0);
|
|
|
|
irt_delay(tp, 50);
|
2001-12-20 12:26:35 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_setline(tp, TIOCM_RTS);
|
|
|
|
irt_delay(tp, 1);
|
2001-12-20 12:26:35 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
irt_delay(tp, 1); /* 50 us */
|
2001-12-20 12:26:35 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_setline(tp, TIOCM_DTR);
|
|
|
|
irt_delay(tp, 1); /* 7 us */
|
2001-12-20 12:26:35 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
switch(speed) {
|
|
|
|
case 115200: s = TEKRAM_115200; break;
|
|
|
|
case 57600: s = TEKRAM_57600; break;
|
|
|
|
case 38400: s = TEKRAM_38400; break;
|
|
|
|
case 19200: s = TEKRAM_19200; break;
|
|
|
|
case 2400: s = TEKRAM_2400; break;
|
|
|
|
default: s = TEKRAM_9600; break;
|
|
|
|
}
|
|
|
|
irt_putc(tp, s);
|
2001-12-20 14:30:13 +03:00
|
|
|
irframetstart(tp);
|
|
|
|
|
2001-12-12 20:52:06 +03:00
|
|
|
irt_delay(tp, 100);
|
2001-12-20 12:26:35 +03:00
|
|
|
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
if (speed != 9600)
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
irt_delay(tp, 1); /* 50 us */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Jeteye
|
|
|
|
**********************************************************************/
|
|
|
|
void
|
|
|
|
irts_jeteye(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
switch (speed) {
|
|
|
|
case 19200:
|
|
|
|
irt_setline(tp, TIOCM_DTR);
|
|
|
|
break;
|
|
|
|
case 115200:
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
break;
|
|
|
|
default: /*9600*/
|
|
|
|
irt_setline(tp, TIOCM_RTS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Actisys
|
|
|
|
**********************************************************************/
|
|
|
|
void
|
|
|
|
irts_actisys(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int pulses;
|
|
|
|
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
|
|
|
|
switch(speed) {
|
|
|
|
case 19200: pulses=1; break;
|
|
|
|
case 57600: pulses=2; break;
|
|
|
|
case 115200: pulses=3; break;
|
|
|
|
case 38400: pulses=4; break;
|
|
|
|
default: /* 9600 */ pulses=0; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_dongle_private == 0) {
|
|
|
|
sc->sc_dongle_private = 1;
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
2005-02-27 03:26:58 +03:00
|
|
|
/*
|
2001-12-05 22:59:54 +03:00
|
|
|
* Must wait at least 50ms after initial
|
|
|
|
* power on to charge internal capacitor
|
|
|
|
*/
|
|
|
|
irt_delay(tp, 50);
|
|
|
|
}
|
|
|
|
irt_setline(tp, TIOCM_RTS);
|
|
|
|
delay(2);
|
|
|
|
for (;;) {
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
delay(2);
|
|
|
|
if (--pulses <= 0)
|
|
|
|
break;
|
2005-02-27 03:26:58 +03:00
|
|
|
irt_setline(tp, TIOCM_DTR);
|
2001-12-05 22:59:54 +03:00
|
|
|
delay(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Litelink
|
|
|
|
**********************************************************************/
|
|
|
|
void
|
|
|
|
irts_litelink(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
|
|
|
|
int pulses;
|
|
|
|
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
|
|
|
|
switch(speed) {
|
|
|
|
case 57600: pulses=1; break;
|
|
|
|
case 38400: pulses=2; break;
|
|
|
|
case 19200: pulses=3; break;
|
|
|
|
case 9600: pulses=4; break;
|
|
|
|
default: /* 115200 */ pulses=0; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->sc_dongle_private == 0) {
|
|
|
|
sc->sc_dongle_private = 1;
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
}
|
|
|
|
irt_setline(tp, TIOCM_RTS);
|
|
|
|
irt_delay(tp, 1); /* 15 us */;
|
|
|
|
for (;;) {
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
irt_delay(tp, 1); /* 15 us */;
|
|
|
|
if (--pulses <= 0)
|
|
|
|
break;
|
2005-02-27 03:26:58 +03:00
|
|
|
irt_setline(tp, TIOCM_DTR);
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_delay(tp, 1); /* 15 us */;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Girbil
|
|
|
|
**********************************************************************/
|
|
|
|
/* Control register 1 */
|
|
|
|
#define GIRBIL_TXEN 0x01 /* Enable transmitter */
|
|
|
|
#define GIRBIL_RXEN 0x02 /* Enable receiver */
|
|
|
|
#define GIRBIL_ECAN 0x04 /* Cancel self emmited data */
|
|
|
|
#define GIRBIL_ECHO 0x08 /* Echo control characters */
|
|
|
|
|
|
|
|
/* LED Current Register */
|
|
|
|
#define GIRBIL_HIGH 0x20
|
|
|
|
#define GIRBIL_MEDIUM 0x21
|
|
|
|
#define GIRBIL_LOW 0x22
|
|
|
|
|
|
|
|
/* Baud register */
|
|
|
|
#define GIRBIL_2400 0x30
|
2005-02-27 03:26:58 +03:00
|
|
|
#define GIRBIL_4800 0x31
|
2001-12-05 22:59:54 +03:00
|
|
|
#define GIRBIL_9600 0x32
|
|
|
|
#define GIRBIL_19200 0x33
|
2005-02-27 03:26:58 +03:00
|
|
|
#define GIRBIL_38400 0x34
|
|
|
|
#define GIRBIL_57600 0x35
|
2001-12-05 22:59:54 +03:00
|
|
|
#define GIRBIL_115200 0x36
|
|
|
|
|
|
|
|
/* Mode register */
|
|
|
|
#define GIRBIL_IRDA 0x40
|
|
|
|
#define GIRBIL_ASK 0x41
|
|
|
|
|
|
|
|
/* Control register 2 */
|
|
|
|
#define GIRBIL_LOAD 0x51 /* Load the new baud rate value */
|
|
|
|
|
|
|
|
void
|
|
|
|
irts_girbil(struct tty *tp, u_int speed)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
irt_setspeed(tp, 9600);
|
|
|
|
irt_setline(tp, TIOCM_DTR);
|
|
|
|
irt_delay(tp, 5);
|
|
|
|
irt_setline(tp, TIOCM_RTS);
|
|
|
|
irt_delay(tp, 20);
|
|
|
|
switch(speed) {
|
|
|
|
case 115200: s = GIRBIL_115200; break;
|
|
|
|
case 57600: s = GIRBIL_57600; break;
|
|
|
|
case 38400: s = GIRBIL_38400; break;
|
|
|
|
case 19200: s = GIRBIL_19200; break;
|
|
|
|
case 4800: s = GIRBIL_4800; break;
|
|
|
|
case 2400: s = GIRBIL_2400; break;
|
|
|
|
default: s = GIRBIL_9600; break;
|
|
|
|
}
|
|
|
|
irt_putc(tp, GIRBIL_TXEN|GIRBIL_RXEN);
|
|
|
|
irt_putc(tp, s);
|
|
|
|
irt_putc(tp, GIRBIL_LOAD);
|
2001-12-20 14:30:13 +03:00
|
|
|
irframetstart(tp);
|
2001-12-05 22:59:54 +03:00
|
|
|
irt_delay(tp, 100);
|
|
|
|
irt_setline(tp, TIOCM_DTR | TIOCM_RTS);
|
|
|
|
if (speed != 9600)
|
|
|
|
irt_setspeed(tp, speed);
|
|
|
|
}
|