Re: [PATCH 3/3] [IrDA] Kingsun KS-959 IrDA USB driver

2007-08-28 Thread David Miller
From: Samuel Ortiz [EMAIL PROTECTED]
Date: Mon, 27 Aug 2007 01:15:17 +0300

 This dongle does not follow the usb-irda specification, so it needs its own
 special driver. First, it uses control URBs for data transfer, instead of
 bulk or interrupt transfers; the only interrupt endpoint exposed seems to
 be a dummy to prevent the interface from being rejected. Second, it uses
 obfuscation and padding at the USB traffic level, for no apparent reason
 other than to make reverse engineering harder (full details on obfuscation
 in comments at beginning of source). Although it is advertised as a 4 Mbps
 FIR dongle, it apparently loses packets at speeds greater than 57600 bps.
 
 On plugin, this dongle reports vendor and device IDs: 0x07d0:0x4959 .
 
 The Windows driver that is used normally to control this dongle has a
 filename of KS-959.SYS .
 
 Signed-off-by: Alex Villacís Lasso [EMAIL PROTECTED]
 Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]

Also 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


[PATCH 3/3] [IrDA] Kingsun KS-959 IrDA USB driver

2007-08-26 Thread Samuel Ortiz
This dongle does not follow the usb-irda specification, so it needs its own
special driver. First, it uses control URBs for data transfer, instead of
bulk or interrupt transfers; the only interrupt endpoint exposed seems to
be a dummy to prevent the interface from being rejected. Second, it uses
obfuscation and padding at the USB traffic level, for no apparent reason
other than to make reverse engineering harder (full details on obfuscation
in comments at beginning of source). Although it is advertised as a 4 Mbps
FIR dongle, it apparently loses packets at speeds greater than 57600 bps.

On plugin, this dongle reports vendor and device IDs: 0x07d0:0x4959 .

The Windows driver that is used normally to control this dongle has a
filename of KS-959.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/ks959-sir.c |  939 +++
 3 files changed, 954 insertions(+)

Index: net-2.6.24-quilt/drivers/net/irda/Kconfig
===
--- net-2.6.24-quilt.orig/drivers/net/irda/Kconfig  2007-08-25 
02:43:16.0 +0300
+++ net-2.6.24-quilt/drivers/net/irda/Kconfig   2007-08-25 03:05:15.0 
+0300
@@ -176,6 +176,20 @@
  To compile it as a module, choose M here: the module will be called
  ksdazzle-sir.
 
+config KS959_DONGLE
+   tristate KingSun KS-959 IrDA-USB dongle (EXPERIMENTAL)
+   depends on IRDA  USB  EXPERIMENTAL
+   help
+ Say Y or M here if you want to build support for the KingSun KS-959
+ 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 speeds only (9600 through 57600 bps).
+
+ To compile it as a module, choose M here: the module will be called
+ ks959-sir.
+
 comment Old SIR device drivers
 
 config IRPORT_SIR
Index: net-2.6.24-quilt/drivers/net/irda/ks959-sir.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ net-2.6.24-quilt/drivers/net/irda/ks959-sir.c   2007-08-25 
03:04:30.0 +0300
@@ -0,0 +1,939 @@
+/*
+*
+* Filename:  ks959-sir.c
+* Version:   0.1.2
+* Description:   Irda KingSun KS-959 USB Dongle
+* Status:Experimental
+* Author:Alex Villacís Lasso [EMAIL PROTECTED]
+* with help from Domen Puncer [EMAIL PROTECTED]
+*
+*Based on stir4200, mcs7780, kingsun-sir drivers.
+*
+*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.
+*
+*/
+
+/*
+ * Following is my most current (2007-07-17) understanding of how the Kingsun
+ * KS-959 dongle is supposed to work. This information was deduced by
+ * reverse-engineering and examining the USB traffic captured with USBSnoopy
+ * from the WinXP driver. Feel free to update here as more of the dongle is
+ * known.
+ *
+ * My most sincere thanks must go to Domen Puncer [EMAIL PROTECTED] for
+ * invaluable help in cracking the obfuscation and padding required for this
+ * dongle.
+ *
+ * General: This dongle exposes one interface with one interrupt IN endpoint.
+ * However, the interrupt endpoint is NOT used at all for this dongle. Instead,
+ * this dongle uses control transfers for everything, including sending and
+ * receiving the IrDA frame data. Apparently the interrupt endpoint is just a
+ * dummy to ensure the dongle has a valid interface to present to the PC.And I
+ * thought the DonShine dongle was weird... In addition, this dongle uses
+ * obfuscation (?!?!), applied at the USB level, to hide the traffic, both sent
+ * and received, from the dongle. I call it obfuscation because the XOR keying
+ * and padding required to produce an USB traffic acceptable for the dongle can
+ * not be explained by any other technical requirement.
+ *
+ * Transmission: To transmit an IrDA frame, the driver must prepare a control
+ * URB with the following as a setup packet:
+ *bRequestTypeUSB_DIR_OUT |