Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Dec 2001 21:58:45 +0100 (CET)
From:      "Erik H. Bakke" <ebakke@trolltech.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/32652: Add new scanners and a new ioctl to uscanner
Message-ID:  <200112092058.fB9Kwj500404@steinbit.troll.no>

next in thread | raw e-mail | index | archive | help

>Number:         32652
>Category:       kern
>Synopsis:       Add new scanners and a new ioctl to uscanner
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 09 13:10:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Erik H. Bakke
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD steinbit.troll.no 5.0-CURRENT FreeBSD 5.0-CURRENT #14: Sun Dec 9 20:12:22 CET 2001 root@steinbit.troll.no:/usr/src/sys/i386/compile/WETLANDER i386


	
>Description:
	Add support for new AGFA scanners to uscanner: Ref: kern/32649
	SnapScan 1236U
	SnapScan e20
	SnapScan e25
	SnapScan e26
	SnapScan e40
	SnapScan e50
	SnapScan e52

	This patch also adds support for a new IOCTL to uscanner.
	USB_GET_DEVICE_ID is intended to make it easier to query for
	the vendor and product IDs, and facilitates the use of USB
	scanners with the sane port.
	A patch for ports/graphics/sane-backends to use the ioctl is
	on its way.
>How-To-Repeat:
	
>Fix:

diff -ruN usb.bak/usb.h usb/usb.h
--- usb.bak/usb.h	Sun Dec  9 21:44:13 2001
+++ usb/usb.h	Sun Dec  9 21:41:01 2001
@@ -567,4 +567,7 @@
 #define USB_GET_CM_OVER_DATA	_IOR ('U', 130, int)
 #define USB_SET_CM_OVER_DATA	_IOW ('U', 131, int)
 
+/* Scanner device */
+#define USB_GET_DEVICE_ID	_IOR('U', 140, int)
+
 #endif /* _USB_H_ */
diff -ruN usb.bak/uscanner.c usb/uscanner.c
--- usb.bak/uscanner.c	Sun Dec  9 21:44:13 2001
+++ usb/uscanner.c	Sun Dec  9 21:41:10 2001
@@ -95,6 +95,13 @@
 	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCAN1212U },
 	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCAN1212U2 },
 	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANTOUCH },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCAN1236U },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE20 },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE25 },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE26 },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE40 },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE50 },
+	{ USB_VENDOR_AGFA, USB_PRODUCT_AGFA_SNAPSCANE52 },
 
 	/* Kye */
 	{ USB_VENDOR_KYE, USB_PRODUCT_KYE_VIVIDPRO },
@@ -197,6 +204,8 @@
 
 	int			sc_refcnt;
 	u_char			sc_dying;
+	u_int16_t		sc_vendor_id;
+	u_int16_t		sc_product_id;
 };
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -207,7 +216,7 @@
 d_read_t  uscannerread;
 d_write_t uscannerwrite;
 d_poll_t  uscannerpoll;
-
+d_ioctl_t uscannerioctl;
 #define USCANNER_CDEV_MAJOR	156
 
 Static struct cdevsw uscanner_cdevsw = {
@@ -215,7 +224,7 @@
 	/* close */	uscannerclose,
 	/* read */	uscannerread,
 	/* write */	uscannerwrite,
-	/* ioctl */	noioctl,
+	/* ioctl */	uscannerioctl,
 	/* poll */	uscannerpoll,
 	/* mmap */	nommap,
 	/* strategy */	nostrategy,
@@ -267,6 +276,8 @@
 	printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
 
 	sc->sc_udev = uaa->device;
+	sc->sc_vendor_id = uaa->vendor;
+	sc->sc_product_id = uaa->product;
 
 	err = usbd_set_config_no(uaa->device, 1, 1); /* XXX */
 	if (err) {
@@ -338,9 +349,10 @@
 
 	USB_GET_SC_OPEN(uscanner, unit, sc);
 
- 	DPRINTFN(5, ("uscanneropen: flag=%d, mode=%d, unit=%d\n", 
+ 	DPRINTFN(5, ("uscanneropen: flag=%d, mode=%d, unit=%d\n",
 		     flag, mode, unit));
 
+	printf( "uscanneropen()\n" );
 	if (sc->sc_dying)
 		return (ENXIO);
 
@@ -664,6 +676,28 @@
 	return (revents);
 }
 
+int
+uscannerioctl( dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread* td )
+{
+	struct uscanner_softc* sc;
+
+	USB_GET_SC( uscanner, USCANNERUNIT( dev ), sc );
+
+	if( sc->sc_dying )
+		return( EIO );
+
+	switch( cmd ) {
+	case USB_GET_DEVICE_ID:
+		*(u_int32_t*)addr = ( sc->sc_vendor_id << 16 ) | sc->sc_product_id;
+		break;
+	default:
+		return EINVAL;
+	}
+	return 0;
+}
+
 #if defined(__FreeBSD__)
 DRIVER_MODULE(uscanner, uhub, uscanner_driver, uscanner_devclass, usbd_driver_load, 0);
 #endif
+
+



>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112092058.fB9Kwj500404>