tech-kern archive

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

Re: btuart and SOCKET Bluetooth CF



Hi! Iain,


From: Iain Hibbert <plunky%rya-online.net@localhost>
Date: Sun, 14 Feb 2010 10:44:43 +0000 (GMT)

> On Sun, 14 Feb 2010, KIYOHARA Takashi wrote:

> You didn't count the whole lifetime of that byte..

Oops.  I missunderstand.  Fix.


> > I devised a different method.  This executes processing to attach
> > different according to cfdata->cf_atname.
> 
> I think depending on ldisc->l_name was cleaner. (no need for #ifdef)

Is it '#if NCOM > 0' that you indicate?
The variable com_cdevsw is necessary for us.  It is declared in com.c.

As for NOKIA DTL, it is all supported that I know with com@pcmcia.
However, some btuart modules seems to be provided by the serial dongle.
In a word, you can use with zs(4).


> in btuart_dtl_output_*(), M_WAITOK is not permitted, and m_copyback() can
> fail, the result should be tested..

Fix.  ;-)

Thanks,
--
kiyohara

Index: btuart.c
===================================================================
RCS file: /cvsroot/src/sys/dev/bluetooth/btuart.c,v
retrieving revision 1.23
diff -u -r1.23 btuart.c
--- btuart.c    12 May 2009 12:10:46 -0000      1.23
+++ btuart.c    16 Feb 2010 05:47:11 -0000
@@ -1,7 +1,7 @@
 /*     $NetBSD: btuart.c,v 1.23 2009/05/12 12:10:46 cegger Exp $       */
 
 /*-
- * Copyright (c) 2006, 2007 KIYOHARA Takashi
+ * Copyright (c) 2006, 2007, 2010 KIYOHARA Takashi
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,8 @@
 #include <sys/cdefs.h>
 __KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.23 2009/05/12 12:10:46 cegger Exp $");
 
+#include "com.h"
+
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/device.h>
@@ -49,8 +51,14 @@
 #include <netbt/bluetooth.h>
 #include <netbt/hci.h>
 
+#if NCOM > 0
+#include <dev/pcmcia/pcmciadevs.h>
+#include <dev/pcmcia/pcmciavar.h>
+#endif
+
 #include "ioconf.h"
 
+
 struct btuart_softc {
        device_t        sc_dev;
        struct tty *    sc_tp;          /* tty pointer */
@@ -61,6 +69,7 @@
 
        int             sc_state;       /* receive state */
        int             sc_want;        /* how much we want */
+       bool            sc_pad;         /* pad will receive before next pkt */
        struct mbuf *   sc_rxp;         /* incoming packet */
 
        bool            sc_xmit;        /* transmit is active */
@@ -73,13 +82,28 @@
 };
 
 /* sc_state */
-#define BTUART_RECV_PKT_TYPE   0       /* packet type */
-#define BTUART_RECV_ACL_HDR    1       /* acl header */
-#define BTUART_RECV_SCO_HDR    2       /* sco header */
-#define BTUART_RECV_EVENT_HDR  3       /* event header */
-#define BTUART_RECV_ACL_DATA   4       /* acl packet data */
-#define BTUART_RECV_SCO_DATA   5       /* sco packet data */
-#define BTUART_RECV_EVENT_DATA 6       /* event packet data */
+enum state {
+       BTUART_RECV_PKT_TYPE,           /* packet type */
+       BTUART_RECV_ACL_HDR,            /* acl header */
+       BTUART_RECV_SCO_HDR,            /* sco header */
+       BTUART_RECV_EVENT_HDR,          /* event header */
+       BTUART_RECV_ACL_DATA,           /* acl packet data */
+       BTUART_RECV_SCO_DATA,           /* sco packet data */
+       BTUART_RECV_EVENT_DATA,         /* event packet data */
+
+       BTUART_RECV_DTL_HDR,            /* DTL header */
+       BTUART_RECV_DTL_CTRL_DATA,      /* DTL control data */
+       BTUART_RECV_DTL_ACL_DATA,       /* DTL acl data */
+       BTUART_RECV_DTL_SCO_DATA,       /* DTL sco data */
+       BTUART_RECV_DTL_EVENT_DATA,     /* DTL event data */
+};
+
+struct btuart_dtl_header {     /* NOKIA DTL-1/4 header */
+       uint8_t type;           /*   packet type */
+       uint8_t rsvd;
+       uint16_t len;           /*   data length */
+} __packed;
+#define BTUART_DTL_HEADER_TYPE 0x80
 
 void btuartattach(int);
 static int btuart_match(device_t, cfdata_t, void *);
@@ -99,12 +123,20 @@
 static void btuart_output_sco(device_t, struct mbuf *);
 static void btuart_stats(device_t, struct bt_stats *, int);
 
+static int btuart_dtl_probe(dev_t);
+static void btuart_dtl_attach(device_t, device_t, void *);
+static void btuart_dtl_output_cmd(device_t, struct mbuf *);
+static void btuart_dtl_output_acl(device_t, struct mbuf *);
+static void btuart_dtl_output_sco(device_t, struct mbuf *);
+
 /*
  * It doesn't need to be exported, as only btuartattach() uses it,
  * but there's no "official" way to make it static.
  */
 CFATTACH_DECL_NEW(btuart, sizeof(struct btuart_softc),
     btuart_match, btuart_attach, btuart_detach, NULL);
+CFATTACH_DECL_NEW(btuart_dtl, sizeof(struct btuart_softc),
+    btuart_match, btuart_dtl_attach, btuart_detach, NULL);
 
 static struct linesw btuart_disc = {
        .l_name =       "btuart",
@@ -128,6 +160,15 @@
        .get_stats =    btuart_stats,
        .ipl =          IPL_TTY,
 };
+static const struct hci_if btuart_dtl_hci = {
+       .enable =       btuart_enable,
+       .disable =      btuart_disable,
+       .output_cmd =   btuart_dtl_output_cmd,
+       .output_acl =   btuart_dtl_output_acl,
+       .output_sco =   btuart_dtl_output_sco,
+       .get_stats =    btuart_stats,
+       .ipl =          IPL_TTY,
+};
 
 /*****************************************************************************
  *
@@ -155,9 +196,17 @@
                aprint_error("%s: unable to register cfattach, error = %d\n",
                    btuart_cd.cd_name, error);
 
-               config_cfdriver_detach(&btuart_cd);
                (void) ttyldisc_detach(&btuart_disc);
        }
+       error = config_cfattach_attach(btuart_cd.cd_name, &btuart_dtl_ca);
+       if (error) {
+               aprint_error("%s: unable to register cfattach(2), error = %d\n",
+                   btuart_cd.cd_name, error);
+
+               config_cfattach_detach(btuart_cd.cd_name, &btuart_ca);
+               (void) ttyldisc_detach(&btuart_disc);
+       }
+       return;
 }
 
 /*
@@ -187,6 +236,9 @@
        MBUFQ_INIT(&sc->sc_aclq);
        MBUFQ_INIT(&sc->sc_scoq);
 
+       sc->sc_state = BTUART_RECV_PKT_TYPE;
+       sc->sc_want = 1;
+
        /* Attach Bluetooth unit */
        sc->sc_unit = hci_attach(&btuart_hci, self, 0);
        if (sc->sc_unit == NULL)
@@ -218,7 +270,7 @@
  */
 
 static int
-btuartopen(dev_t devno __unused, struct tty *tp)
+btuartopen(dev_t devno, struct tty *tp)
 {
        struct btuart_softc *sc;
        device_t dev;
@@ -249,7 +301,10 @@
                        break;
 
        cfdata->cf_name = btuart_cd.cd_name;
-       cfdata->cf_atname = btuart_cd.cd_name;
+       if (btuart_dtl_probe(devno))
+               cfdata->cf_atname = "btuart_dtl";
+       else
+               cfdata->cf_atname = "btuart";
        cfdata->cf_unit = unit;
        cfdata->cf_fstate = FSTATE_STAR;
 
@@ -348,11 +403,16 @@
 
        if (space == 0) {
                if (m == NULL) {
+                       /* drop padding between packets (for DTL) */
+                       if (sc->sc_pad) {
+                               sc->sc_pad = false;
+                               return 0;
+                       }
+
                        /* new packet */
                        MGETHDR(m, M_DONTWAIT, MT_DATA);
                        if (m == NULL) {
-                               aprint_error_dev(sc->sc_dev,
-                                   "out of memory\n");
+                               aprint_error_dev(sc->sc_dev, "out of memory\n");
                                sc->sc_stats.err_rx++;
                                return 0;       /* (lost sync) */
                        }
@@ -360,15 +420,11 @@
                        sc->sc_rxp = m;
                        m->m_pkthdr.len = m->m_len = 0;
                        space = MHLEN;
-
-                       sc->sc_state = BTUART_RECV_PKT_TYPE;
-                       sc->sc_want = 1;
                } else {
                        /* extend mbuf */
                        MGET(m->m_next, M_DONTWAIT, MT_DATA);
                        if (m->m_next == NULL) {
-                               aprint_error_dev(sc->sc_dev,
-                                   "out of memory\n");
+                               aprint_error_dev(sc->sc_dev, "out of memory\n");
                                sc->sc_stats.err_rx++;
                                return 0;       /* (lost sync) */
                        }
@@ -435,12 +491,12 @@
 
        case BTUART_RECV_SCO_HDR:       /* Got SCO Header */
                sc->sc_state = BTUART_RECV_SCO_DATA;
-               sc->sc_want =  mtod(m, hci_scodata_hdr_t *)->length;
+               sc->sc_want = mtod(m, hci_scodata_hdr_t *)->length;
                break;
 
        case BTUART_RECV_EVENT_HDR:     /* Got Event Header */
                sc->sc_state = BTUART_RECV_EVENT_DATA;
-               sc->sc_want =  mtod(m, hci_event_hdr_t *)->length;
+               sc->sc_want = mtod(m, hci_event_hdr_t *)->length;
                break;
 
        case BTUART_RECV_ACL_DATA:      /* ACL Packet Complete */
@@ -448,7 +504,9 @@
                        sc->sc_stats.err_rx++;
 
                sc->sc_stats.acl_rx++;
-               sc->sc_rxp = m = NULL;
+               sc->sc_state = BTUART_RECV_PKT_TYPE;
+               sc->sc_want = 1;
+               sc->sc_rxp = NULL;
                break;
 
        case BTUART_RECV_SCO_DATA:      /* SCO Packet Complete */
@@ -456,7 +514,9 @@
                        sc->sc_stats.err_rx++;
 
                sc->sc_stats.sco_rx++;
-               sc->sc_rxp = m = NULL;
+               sc->sc_state = BTUART_RECV_PKT_TYPE;
+               sc->sc_want = 1;
+               sc->sc_rxp = NULL;
                break;
 
        case BTUART_RECV_EVENT_DATA:    /* Event Packet Complete */
@@ -464,7 +524,112 @@
                        sc->sc_stats.err_rx++;
 
                sc->sc_stats.evt_rx++;
-               sc->sc_rxp = m = NULL;
+               sc->sc_state = BTUART_RECV_PKT_TYPE;
+               sc->sc_want = 1;
+               sc->sc_rxp = NULL;
+               break;
+
+       /*
+        * NOKIA DTL-1/4
+        */
+       case BTUART_RECV_DTL_HDR:       /* Got DTL header */
+       {
+               struct btuart_dtl_header *dtlh =
+                   mtod(m, struct btuart_dtl_header *);
+
+               switch (dtlh->type) {
+               case BTUART_DTL_HEADER_TYPE:
+                       sc->sc_state = BTUART_RECV_DTL_CTRL_DATA;
+                       break;
+
+               case BTUART_DTL_HEADER_TYPE | HCI_ACL_DATA_PKT:
+                       sc->sc_state = BTUART_RECV_DTL_ACL_DATA;
+                       break;
+
+               case BTUART_DTL_HEADER_TYPE | HCI_SCO_DATA_PKT:
+                       sc->sc_state = BTUART_RECV_DTL_SCO_DATA;
+                       break;
+
+               case BTUART_DTL_HEADER_TYPE | HCI_EVENT_PKT:
+                       sc->sc_state = BTUART_RECV_DTL_EVENT_DATA;
+                       break;
+
+               default:
+                       aprint_error_dev(sc->sc_dev,
+                           "Unknown packet type=%#x!\n", dtlh->type);
+                       sc->sc_stats.err_rx++;
+                       m_adj(m, 1);
+                       sc->sc_want++;          /* (lost sync) try more 1byte */
+                       return 0;
+               }
+               dtlh->len = le16toh(dtlh->len);
+               sc->sc_want = dtlh->len;
+               sc->sc_pad = dtlh->len & 0x0001;
+               break;
+       }
+
+       /*
+        * we assume (correctly of course :) that the packet headers all fit
+        * into a single pkthdr mbuf
+        */
+       case BTUART_RECV_DTL_CTRL_DATA: /* Control Packet Complete */
+       {
+               struct btuart_dtl_header *dtlh =
+                   mtod(sc->sc_rxp, struct btuart_dtl_header *);
+               int i;
+
+               aprint_normal_dev(sc->sc_dev, "Control Packet received:");
+               for (i = 0; i < dtlh->len && i < m->m_len - sizeof(*dtlh); i++)
+                       aprint_normal(" %02x",
+                           mtod(sc->sc_rxp, uint8_t *)[sizeof(*dtlh) + i]);
+               if (i < dtlh->len)
+                       aprint_normal("(more %dbyte%s)",
+                           dtlh->len - i, dtlh->len - i > 1 ? "s" : "");
+               aprint_normal("\n");
+               m_freem(sc->sc_rxp);
+               sc->sc_state = BTUART_RECV_DTL_HDR;
+               sc->sc_want = sizeof(struct btuart_dtl_header);
+               sc->sc_rxp = NULL;
+               break;
+       }
+
+       case BTUART_RECV_DTL_ACL_DATA:  /* ACL Packet Complete */
+               m_adj(sc->sc_rxp,
+                   sizeof(struct btuart_dtl_header) - sizeof(uint8_t));
+               *mtod(sc->sc_rxp, uint8_t *) = HCI_ACL_DATA_PKT;
+               if (!hci_input_acl(sc->sc_unit, sc->sc_rxp))
+                       sc->sc_stats.err_rx++;
+
+               sc->sc_stats.acl_rx++;
+               sc->sc_state = BTUART_RECV_DTL_HDR;
+               sc->sc_want = sizeof(struct btuart_dtl_header);
+               sc->sc_rxp = NULL;
+               break;
+
+       case BTUART_RECV_DTL_SCO_DATA:  /* SCO Packet Complete */
+               m_adj(sc->sc_rxp,
+                   sizeof(struct btuart_dtl_header) - sizeof(uint8_t));
+               *mtod(sc->sc_rxp, uint8_t *) = HCI_SCO_DATA_PKT;
+               if (!hci_input_sco(sc->sc_unit, sc->sc_rxp))
+                       sc->sc_stats.err_rx++;
+
+               sc->sc_stats.sco_rx++;
+               sc->sc_state = BTUART_RECV_DTL_HDR;
+               sc->sc_want = sizeof(struct btuart_dtl_header);
+               sc->sc_rxp = NULL;
+               break;
+
+       case BTUART_RECV_DTL_EVENT_DATA:/* Event Packet Complete */
+               m_adj(sc->sc_rxp,
+                   sizeof(struct btuart_dtl_header) - sizeof(uint8_t));
+               *mtod(sc->sc_rxp, uint8_t *) = HCI_EVENT_PKT;
+               if (!hci_input_event(sc->sc_unit, sc->sc_rxp))
+                       sc->sc_stats.err_rx++;
+
+               sc->sc_stats.evt_rx++;
+               sc->sc_state = BTUART_RECV_DTL_HDR;
+               sc->sc_want = sizeof(struct btuart_dtl_header);
+               sc->sc_rxp = NULL;
                break;
 
        default:
@@ -667,3 +832,187 @@
 
        splx(s);
 }
+
+
+/*
+ * NOKIA DTL-1/4 functions
+ */
+
+static int
+btuart_dtl_probe(dev_t dev)
+{
+#if NCOM > 0
+       struct pcmcia_softc *pcmcia;
+       struct pcmcia_card *card;
+       device_t com;
+       extern struct cdevsw com_cdevsw;
+       struct {
+               uint32_t vendor;
+               uint32_t product;
+       } dtltbl[] = {
+               { PCMCIA_VENDOR_SOCKET, 0x009f },
+       };
+       int i;
+
+       if (major(dev) != cdevsw_lookup_major(&com_cdevsw))
+               return 0;
+
+       com = device_find_by_driver_unit("com", minor(dev));
+       if (device_is_a(device_parent(com), "pcmcia")) {
+               pcmcia = device_private(device_parent(com));
+               card = &pcmcia->card;
+
+               for (i = 0; i < __arraycount(dtltbl); i++)
+                       if (card->manufacturer == dtltbl[i].vendor &&
+                           card->product == dtltbl[i].product)
+                               return 1;
+       }
+#endif
+       return 0;
+}
+
+static void
+btuart_dtl_attach(device_t parent __unused, device_t self, void *aux __unused)
+{
+       struct btuart_softc *sc = device_private(self);
+
+       sc->sc_dev = self;
+
+       MBUFQ_INIT(&sc->sc_cmdq);
+       MBUFQ_INIT(&sc->sc_aclq);
+       MBUFQ_INIT(&sc->sc_scoq);
+
+       sc->sc_state = BTUART_RECV_DTL_HDR;
+       sc->sc_want = sizeof(struct btuart_dtl_header);
+
+       /* Attach Bluetooth unit */
+       sc->sc_unit = hci_attach(&btuart_dtl_hci, self, 0);
+       if (sc->sc_unit == NULL)
+               aprint_error_dev(self, "HCI attach failed\n");
+}
+
+static void
+btuart_dtl_output_cmd(device_t self, struct mbuf *m)
+{
+       struct btuart_softc *sc = device_private(self);
+       struct btuart_dtl_header dtlh;
+       int s;
+
+       KASSERT(sc->sc_enabled);
+
+       m_adj(m, sizeof(uint8_t));      /* remove hci_cmd_hdr_t's type */
+
+       dtlh.type = HCI_CMD_PKT | BTUART_DTL_HEADER_TYPE;
+       dtlh.rsvd = 0;
+       dtlh.len = htole16(m->m_pkthdr.len);
+
+       M_PREPEND(m, sizeof(dtlh), M_DONTWAIT);
+       if (m == NULL) {
+               aprint_error_dev(sc->sc_dev, "output CMD failed (head)\n");
+               sc->sc_stats.err_tx++;
+               return;
+       }
+       m_copyback(m, 0, sizeof(dtlh), &dtlh);
+       if (m->m_pkthdr.len & 0x1) {
+               m_copyback(m, m->m_pkthdr.len, 1, &dtlh.rsvd);  /* Add pad */
+               if (m->m_pkthdr.len & 0x1) {
+                       aprint_error_dev(sc->sc_dev,
+                           "output CMD failed (tail)\n");
+                       sc->sc_stats.err_tx++;
+                       return;
+               }
+       }
+
+       M_SETCTX(m, NULL);
+
+       s = spltty();
+       MBUFQ_ENQUEUE(&sc->sc_cmdq, m);
+       if (!sc->sc_xmit)
+               btuartstart(sc->sc_tp);
+
+       splx(s);
+}
+
+static void
+btuart_dtl_output_acl(device_t self, struct mbuf *m)
+{
+       struct btuart_softc *sc = device_private(self);
+       struct btuart_dtl_header dtlh;
+       int s;
+
+       KASSERT(sc->sc_enabled);
+
+       m_adj(m, sizeof(uint8_t));      /* remove hci_acldata_hdr_t's type */
+
+       dtlh.type = HCI_ACL_DATA_PKT | BTUART_DTL_HEADER_TYPE;
+       dtlh.rsvd = 0;
+       dtlh.len = htole16(m->m_pkthdr.len);
+
+
+       M_PREPEND(m, sizeof(dtlh), M_DONTWAIT);
+       if (m == NULL) {
+               aprint_error_dev(sc->sc_dev, "output ACL failed (head)\n");
+               sc->sc_stats.err_tx++;
+               return;
+       }
+       m_copyback(m, 0, sizeof(dtlh), &dtlh);
+       if (m->m_pkthdr.len & 0x1) {
+               m_copyback(m, m->m_pkthdr.len, 1, &dtlh.rsvd);  /* Add pad */
+               if (m->m_pkthdr.len & 0x1) {
+                       aprint_error_dev(sc->sc_dev,
+                           "output ACL failed (tail)\n");
+                       sc->sc_stats.err_tx++;
+                       return;
+               }
+       }
+
+       M_SETCTX(m, NULL);
+
+       s = spltty();
+       MBUFQ_ENQUEUE(&sc->sc_aclq, m);
+       if (!sc->sc_xmit)
+               btuartstart(sc->sc_tp);
+
+       splx(s);
+}
+
+static void
+btuart_dtl_output_sco(device_t self, struct mbuf *m)
+{
+       struct btuart_softc *sc = device_private(self);
+       struct btuart_dtl_header dtlh;
+       int s;
+
+       KASSERT(sc->sc_enabled);
+
+       m_adj(m, sizeof(uint8_t));      /* remove hci_scodata_hdr_t's type */
+
+       dtlh.type = HCI_SCO_DATA_PKT | BTUART_DTL_HEADER_TYPE;
+       dtlh.rsvd = 0;
+       dtlh.len = htole16(m->m_pkthdr.len);
+
+
+       M_PREPEND(m, sizeof(dtlh), M_DONTWAIT);
+       if (m == NULL) {
+               aprint_error_dev(sc->sc_dev, "output SCO failed (head)\n");
+               sc->sc_stats.err_tx++;
+               return;
+       }
+       m_copyback(m, 0, sizeof(dtlh), &dtlh);
+       if (m->m_pkthdr.len & 0x1) {
+               m_copyback(m, m->m_pkthdr.len, 1, &dtlh.rsvd);  /* Add pad */
+               if (m->m_pkthdr.len & 0x1) {
+                       aprint_error_dev(sc->sc_dev,
+                           "output SCO failed (tail)\n");
+                       sc->sc_stats.err_tx++;
+                       return;
+               }
+       }
+
+       s = spltty();
+       MBUFQ_ENQUEUE(&sc->sc_scoq, m);
+       if (!sc->sc_xmit)
+               btuartstart(sc->sc_tp);
+
+       splx(s);
+}
Index: Makefile
===================================================================
RCS file: /cvsroot/src/usr.sbin/btattach/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile    6 Dec 2009 12:55:46 -0000       1.2
+++ Makefile    16 Feb 2010 03:28:53 -0000
@@ -2,8 +2,9 @@
 
 PROG=  btattach
 MAN=   btattach.8
-SRCS=  btattach.c init_bcm2035.c init_bgb2xx.c init_csr.c init_digi.c \
-       init_ericsson.c init_st.c init_stlc2500.c init_swave.c init_unistone.c
+SRCS=  btattach.c init_bcm2035.c init_bgb2xx.c init_csr.c      \
+       init_digi.c init_dtl.c init_ericsson.c init_st.c        \
+       init_stlc2500.c init_swave.c init_unistone.c
 
 DPADD+=        ${LIBBLUETOOTH} ${LIBUTIL}
 LDADD+=        -lbluetooth -lutil
Index: btattach.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/btattach/btattach.c,v
retrieving revision 1.5
diff -u -r1.5 btattach.c
--- btattach.c  6 Dec 2009 12:55:46 -0000       1.5
+++ btattach.c  16 Feb 2010 03:28:53 -0000
@@ -54,13 +54,6 @@
 
 const struct devtype types[] = {
     {
-       .name = "bcsp",
-       .line = "bcsp",
-       .descr = "Generic BlueCore Serial Protocol",
-       .cflag = CRTSCTS,
-       .speed = B57600,
-    },
-    {
        .name = "bcm2035",
        .line = "btuart",
        .descr = "Broadcom BCM2035",
@@ -68,6 +61,13 @@
        .speed = B115200,
     },
     {
+       .name = "bcsp",
+       .line = "bcsp",
+       .descr = "Generic BlueCore Serial Protocol",
+       .cflag = CRTSCTS,
+       .speed = B57600,
+    },
+    {
        .name = "bgb2xx",
        .line = "btuart",
        .descr = "Philips BGB2xx module",
@@ -83,7 +83,7 @@
     {
        .name = "csr",
        .line = "btuart",
-       .descr = "CSR Casira serial adaptor",
+       .descr = "Cambridge Silicon Radio based modules (not BCSP)",
        .init = &init_csr,
        .cflag = CRTSCTS,
        .speed = B57600,
@@ -97,6 +97,13 @@
        .speed = B9600,
     },
     {
+       .name = "dtl",
+       .line = "btuart",
+       .descr = "NOKIA DTL-1/4 based modules",
+       .init = &init_dtl,
+       .cflag = CRTSCTS,
+    },
+    {
        .name = "ericsson",
        .line = "btuart",
        .descr = "Ericsson based modules",
Index: btattach.h
===================================================================
RCS file: /cvsroot/src/usr.sbin/btattach/btattach.h,v
retrieving revision 1.3
diff -u -r1.3 btattach.h
--- btattach.h  6 Dec 2009 12:55:46 -0000       1.3
+++ btattach.h  16 Feb 2010 03:28:53 -0000
@@ -43,6 +43,7 @@
 devinit_t init_bgb2xx;
 devinit_t init_csr;
 devinit_t init_digi;
+devinit_t init_dtl;
 devinit_t init_ericsson;
 devinit_t init_st;
 devinit_t init_stlc2500;
--- init_dtl.c.orig     1970-01-01 09:00:00.000000000 +0900
+++ init_dtl.c  2010-02-16 12:48:22.000000000 +0900
@@ -0,0 +1,56 @@
+/*     $NetBSD$        */
+/*
+ * Copyright (c) 2010 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+/*
+ * init information in this file gleaned from drivers/bluetooth/dtl_cs.c(Linux)
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include <bluetooth.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <termios.h>
+
+#include <sys/ioctl.h>
+
+#include "btattach.h"
+
+void
+init_dtl(int fd, unsigned int speed)
+{
+       const int arg = TIOCM_DTR | TIOCM_RTS;
+
+       /* Reset NOKIA DTL */
+       if (ioctl(fd, TIOCMBIC, &arg) < 0)
+               warn("Clear DTR/RTS");
+       if (ioctl(fd, TIOCMBIS, &arg) < 0)
+               warn("Set DTR/RTS");
+
+       /* NOKIA DTL detects speed automaticaly  */
+}


Home | Main Index | Thread Index | Old Index