Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Add a driver for HP5300 which uses a homebrew SC...
details: https://anonhg.NetBSD.org/src/rev/82b1b2310f41
branches: trunk
changeset: 502063:82b1b2310f41
user: augustss <augustss%NetBSD.org@localhost>
date: Thu Jan 11 06:00:31 2001 +0000
description:
Add a driver for HP5300 which uses a homebrew SCSI-over-USB protocol.
Furthermore, it uses Avisions scanner-over-SCSI protocol (but that's
not visible in the driver).
Thanks to Lloyd Parkes for testing and debugging and to Jukka Marin for
testing.
XXX This driver should be extended to handle Microtek scanners as well.
diffstat:
sys/dev/usb/files.usb | 44 +-
sys/dev/usb/usscanner.c | 724 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 754 insertions(+), 14 deletions(-)
diffs (truncated from 831 to 300 lines):
diff -r 02bbac9adc00 -r 82b1b2310f41 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb Thu Jan 11 05:31:02 2001 +0000
+++ b/sys/dev/usb/files.usb Thu Jan 11 06:00:31 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.24 2001/01/02 18:52:44 augustss Exp $
+# $NetBSD: files.usb,v 1.25 2001/01/11 06:00:31 augustss Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -41,11 +41,14 @@
attach ucom at ucombus
file dev/usb/ucom.c ucom | ucombus needs-flag
+
# Generic devices
device ugen
attach ugen at uhub
file dev/usb/ugen.c ugen needs-flag
+
+# HID
# Generic HID devices
device uhid
attach uhid at uhub
@@ -57,26 +60,25 @@
file dev/usb/ukbd.c ukbd needs-flag
file dev/usb/ukbdmap.c ukbd
+# Mice
+device ums: wsmousedev
+attach ums at uhub
+file dev/usb/ums.c ums
+
+
# Printers
device ulpt
attach ulpt at uhub
file dev/usb/ulpt.c ulpt needs-flag
+
# Mass storage
device umass: scsi, atapi
attach umass at uhub
file dev/usb/umass.c umass
-# Modems
-device umodem: ucombus
-attach umodem at uhub
-file dev/usb/umodem.c umodem
-# Mice
-device ums: wsmousedev
-attach ums at uhub
-file dev/usb/ums.c ums
-
+# Misc
# Diamond Multimedia Rio 500
device urio
attach urio at uhub
@@ -87,6 +89,12 @@
attach uvisor at uhub
file dev/usb/uvisor.c uvisor
+# YAP phone firmware loader
+device uyap: ezload
+attach uyap at uhub
+file dev/usb/uyap.c uyap
+
+
# Ethernet adapters
# ADMtek AN986 Pegasus
device aue: arp, ether, ifnet, mii, mii_phy
@@ -108,18 +116,26 @@
attach upl at uhub
file dev/usb/if_upl.c upl
+
# Serial drivers
+# Modems
+device umodem: ucombus
+attach umodem at uhub
+file dev/usb/umodem.c umodem
+
# FTDI serial driver
device uftdi: ucombus
attach uftdi at uhub
file dev/usb/uftdi.c uftdi
+
# Scanners
+# Generic scanner support
device uscanner
attach uscanner at uhub
file dev/usb/uscanner.c uscanner needs-flag
-# YAP phone firmware loader
-device uyap: ezload
-attach uyap at uhub
-file dev/usb/uyap.c uyap
+# Avision SCSI over USB, HP5300
+device usscanner: scsi
+attach usscanner at uhub
+file dev/usb/usscanner.c usscanner
diff -r 02bbac9adc00 -r 82b1b2310f41 sys/dev/usb/usscanner.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/usb/usscanner.c Thu Jan 11 06:00:31 2001 +0000
@@ -0,0 +1,724 @@
+/* $NetBSD: usscanner.c,v 1.1 2001/01/11 06:00:31 augustss Exp $ */
+
+/*
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart%augustsson.net@localhost) and LLoyd Parkes.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+
+#include <dev/usb/usbdevs.h>
+
+#include <sys/scsiio.h>
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsiconf.h>
+#include <dev/scsipi/atapiconf.h>
+
+#ifdef USSCANNER_DEBUG
+#define DPRINTF(x) if (usscannerdebug) logprintf x
+#define DPRINTFN(n,x) if (usscannerdebug>(n)) logprintf x
+int usscannerdebug = 15;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+
+#define USSCANNER_CONFIG_NO 1
+#define USSCANNER_IFACE_IDX 0
+
+#define USSCANNER_SCSIID_HOST 0x00
+#define USSCANNER_SCSIID_DEVICE 0x01
+
+#define USSCANNER_MAX_TRANSFER_SIZE MAXBSIZE
+
+#define USSCANNER_TIMEOUT 2000
+
+Static struct scsipi_device usscanner_dev =
+{
+ NULL, /* Use default error handler */
+ NULL, /* have a queue, served by this */
+ NULL, /* have no async handler */
+ NULL, /* Use default 'done' routine */
+};
+
+struct usscanner_softc {
+ USBBASEDEVICE sc_dev;
+ usbd_device_handle sc_udev;
+ usbd_interface_handle sc_iface;
+
+ int sc_in_addr;
+ usbd_pipe_handle sc_in_pipe;
+
+ int sc_intr_addr;
+ usbd_pipe_handle sc_intr_pipe;
+ usbd_xfer_handle sc_intr_xfer;
+ u_char sc_status;
+
+ int sc_out_addr;
+ usbd_pipe_handle sc_out_pipe;
+
+ usbd_xfer_handle sc_cmd_xfer;
+ void *sc_cmd_buffer;
+ usbd_xfer_handle sc_data_xfer;
+ void *sc_data_buffer;
+
+ int sc_state;
+#define UAS_IDLE 0
+#define UAS_CMD 1
+#define UAS_DATA 2
+#define UAS_SENSECMD 3
+#define UAS_SENSEDATA 4
+#define UAS_STATUS 5
+
+ struct scsipi_xfer *sc_xs;
+
+ device_ptr_t sc_child; /* child device, for detach */
+
+ struct scsipi_link sc_link;
+ struct atapi_adapter sc_atapi_adapter;
+#define sc_adapter sc_atapi_adapter._generic
+
+ int sc_refcnt;
+ char sc_dying;
+};
+
+
+Static void usscanner_cleanup(struct usscanner_softc *sc);
+Static int usscanner_scsipi_cmd(struct scsipi_xfer *xs);
+Static void usscanner_scsipi_minphys(struct buf *bp);
+Static void usscanner_done(struct usscanner_softc *sc);
+Static void usscanner_sense(struct usscanner_softc *sc);
+typedef void callback(usbd_xfer_handle, usbd_private_handle, usbd_status);
+Static callback usscanner_intr_cb;
+Static callback usscanner_cmd_cb;
+Static callback usscanner_data_cb;
+Static callback usscanner_sensecmd_cb;
+Static callback usscanner_sensedata_cb;
+
+USB_DECLARE_DRIVER(usscanner);
+
+USB_MATCH(usscanner)
+{
+ USB_MATCH_START(usscanner, uaa);
+
+ DPRINTFN(50,("usscanner_match\n"));
+
+ if (uaa->iface != NULL)
+ return (UMATCH_NONE);
+
+ if (uaa->vendor == USB_VENDOR_HP &&
+ uaa->product == USB_PRODUCT_HP_5300C)
+ return (UMATCH_VENDOR_PRODUCT);
+ else
+ return (UMATCH_NONE);
+}
+
+USB_ATTACH(usscanner)
+{
+ USB_ATTACH_START(usscanner, sc, uaa);
+ usbd_device_handle dev = uaa->device;
+ usbd_interface_handle iface;
+ char devinfo[1024];
+ usbd_status err;
+ usb_endpoint_descriptor_t *ed;
+ u_int8_t epcount;
+ int i;
+
+ DPRINTFN(10,("usscanner_attach: sc=%p\n", sc));
+
+ usbd_devinfo(dev, 0, devinfo);
+ USB_ATTACH_SETUP;
+ printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
+
+ err = usbd_set_config_no(dev, USSCANNER_CONFIG_NO, 1);
+ if (err) {
+ printf("%s: setting config no failed\n",
+ USBDEVNAME(sc->sc_dev));
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ err = usbd_device2interface_handle(dev, USSCANNER_IFACE_IDX, &iface);
+ if (err) {
+ printf("%s: getting interface handle failed\n",
+ USBDEVNAME(sc->sc_dev));
+ USB_ATTACH_ERROR_RETURN;
+ }
+
+ sc->sc_udev = dev;
+ sc->sc_iface = iface;
+
+ epcount = 0;
Home |
Main Index |
Thread Index |
Old Index