[PATCH] [IrDA] KingSun/DonShine USB IrDA dongle support

2007-05-09 Thread Samuel Ortiz
From: Alex Villac�s Lasso [EMAIL PROTECTED]

This dongle does not follow the usb-irda specification, so it needs its
own special driver. In addition, it uses interrupt endpoints instead of
bulk ones as the rest of USB IrDA dongles supported by Linux (just to be
different?) and data reads need to be parsed to extract the valid bytes
before being unwrapped (details in the comment at the start of the
source). No speed commands have been discovered for this dongle, and I
suspect it does not have any at all.

On plugin, this dongle reports vendor and device IDs: 0x07c0:0x4200 .

The Windows driver that is used normally to control this dongle has a
filename of DSIR620.SYS .

Signed-off-by: Alex Villac�s Lasso [EMAIL PROTECTED]
Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]

---
 drivers/net/irda/Kconfig   |   14 +
 drivers/net/irda/Makefile  |1 +
 drivers/net/irda/kingsun-sir.c |  657 
 3 files changed, 672 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/irda/kingsun-sir.c

diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 7c8ccc0..9d28c75 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -141,6 +141,20 @@ config ACT200L_DONGLE
  To activate support for ACTiSYS IR-200L dongle you will have to
  start irattach like this: irattach -d act200l.
 
+config KINGSUN_DONGLE
+   tristate KingSun/DonShine DS-620 IrDA-USB dongle
+   depends on IRDA  USB  EXPERIMENTAL
+   help
+ Say Y or M here if you want to build support for the KingSun/DonShine
+ DS-620 IrDA-USB bridge device driver.
+
+ This USB bridge does not conform to the IrDA-USB device class
+ specification, and therefore needs its own specific driver. This
+ dongle supports SIR speed only (9600 bps).
+
+ To compile it as a module, choose M here: the module will be called
+ kingsun-sir.
+
 comment Old SIR device drivers
 
 config IRPORT_SIR
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 5be09f1..233a2f9 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE)  += mcp2120-sir.o
 obj-$(CONFIG_ACT200L_DONGLE)   += act200l-sir.o
 obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o
 obj-$(CONFIG_TOIM3232_DONGLE)  += toim3232-sir.o
+obj-$(CONFIG_KINGSUN_DONGLE)   += kingsun-sir.o
 
 # The SIR helper module
 sir-dev-objs := sir_dev.o sir_dongle.o
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
new file mode 100644
index 000..a1eb130
--- /dev/null
+++ b/drivers/net/irda/kingsun-sir.c
@@ -0,0 +1,657 @@
+/*
+*
+* Filename:  kingsun-sir.c
+* Version:   0.1.1
+* Description:   Irda KingSun/DonShine USB Dongle
+* Status:Experimental
+* Author:Alex Villac�s Lasso [EMAIL PROTECTED]
+*
+*  Based on stir4200 and mcs7780 drivers, with (strange?) differences
+*
+*  This program is free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License.
+*
+*  This program is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  You should have received a copy of the GNU General Public License
+*  along with this program; if not, write to the Free Software
+*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*/
+
+/*
+ * This is my current (2007-04-25) understanding of how this dongle is supposed
+ * to work. This is based on reverse-engineering and examination of the packet
+ * data sent and received by the WinXP driver using USBSnoopy. Feel free to
+ * update here as more of this dongle is known:
+ *
+ * General: Unlike the other USB IrDA dongles, this particular dongle exposes,
+ * not two bulk (in and out) endpoints, but two *interrupt* ones. This dongle,
+ * like the bulk based ones (stir4200.c and mcs7780.c), requires polling in
+ * order to receive data.
+ * Transmission: Just like stir4200, this dongle uses a raw stream of data,
+ * which needs to be wrapped and escaped in a similar way as in stir4200.c.
+ * Reception: Poll-based, as in stir4200. Each read returns the contents of a
+ * 8-byte buffer, of which the first byte (LSB) indicates the number of bytes
+ * (1-7) of valid data contained within the remaining 7 bytes. For example, if
+ * the buffer had the following contents:
+ *  06 ff ff ff c0 01 04 aa
+ * This means that (06) there are 6 bytes of valid data. The byte 0xaa at the
+ * end is garbage (left over from a previous reception) and is 

Re: [PATCH] [IrDA] KingSun/DonShine USB IrDA dongle support

2007-05-09 Thread David Miller
From: Samuel Ortiz [EMAIL PROTECTED]
Date: Thu, 10 May 2007 01:40:27 +0300

 From: Alex Villac$,3u=(Bs Lasso [EMAIL PROTECTED]
 
 This dongle does not follow the usb-irda specification, so it needs its
 own special driver. In addition, it uses interrupt endpoints instead of
 bulk ones as the rest of USB IrDA dongles supported by Linux (just to be
 different?) and data reads need to be parsed to extract the valid bytes
 before being unwrapped (details in the comment at the start of the
 source). No speed commands have been discovered for this dongle, and I
 suspect it does not have any at all.
 
 On plugin, this dongle reports vendor and device IDs: 0x07c0:0x4200 .
 
 The Windows driver that is used normally to control this dongle has a
 filename of DSIR620.SYS .
 
 Signed-off-by: Alex Villac$,3u=(Bs Lasso [EMAIL PROTECTED]
 Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]

Applied, thanks a lot.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html