NetBSD Problem Report #26117

Received: (qmail 23089 invoked by uid 605); 29 Jun 2004 20:18:09 -0000
Message-Id: <200406291958.TAA01082@sopwith.solgatos.com>
Date: Tue, 29 Jun 2004 19:58:25 GMT
From: Dieter <netbsd@sopwith.solgatos.com>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: netbsd@sopwith.solgatos.com
To: gnats-bugs@gnats.netbsd.org
Subject: need ioctl so that sane can identify scanner
X-Send-Pr-Version: 3.95

>Number:         26117
>Category:       kern
>Synopsis:       Sane needs to identify the make/model of scanner.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          analyzed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 29 20:19:00 +0000 2004
>Closed-Date:    
>Last-Modified:  Tue Jan 20 08:45:03 +0000 2009
>Originator:     Dieter
>Release:        NetBSD 1.6.2
>Organization:

>Environment:


System: NetBSD sopwith.uucp 1.6.2 NetBSD 1.6.2 (ALPHA-$Revision: 1.4 $) #11: Tue Jun 29 12:05:05 PDT 2004 root@sopwith.uucp:/usr/src/sys/arch/alpha/compile/SOPWITH alpha
Architecture: alpha
Machine: alpha
>Description:
	Sane(1) needs to know the make and model of scanner it is talking to.
The easy and obvious fix appears to be to implement the USB_GET_DEVICEINFO
ioctl, as found in the ugen driver.  (Note that there is also a USB_DEVICEINFO
ioctl, in usb.c, which fills in the same structure.  I'm not sure why there is
both a USB_DEVICEINFO and a USB_GET_DEVICEINFO.)
>How-To-Repeat:
	Build a kernel with the uscanner driver.  Connect a usb scanner.
Attempt to get sane-backends-1.0.14 working.  kernel_get_vendor_product()
in sanei/sanei_usb.c needs a way to determine the make and model of scanner.
>Fix:
(Note: the Epson 2400 line is already in CVS, but didn't make it into 1.6.2.
The diff is against 1.6.2)

===================================================================
RCS file: RCS/uscanner.c,v
retrieving revision 1.1
diff -r1.1 uscanner.c
186a187
>  {{ USB_VENDOR_EPSON, USB_PRODUCT_EPSON_2400 }, 0 },
694c695,708
< 	return (EINVAL);
---
>   struct uscanner_softc *sc;
>   int error;
> 
>   error = 0;
>   USB_GET_SC(uscanner, USCANNERUNIT(dev), sc);
> 
>   switch (cmd) {
>   case USB_GET_DEVICEINFO:
>     usbd_fill_deviceinfo(sc->sc_udev, (struct usb_device_info *)addr, 1);
>     break;
>   default:
>     error = EINVAL;
>   }
>   return (error);

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: tron@netbsd.org
State-Changed-When: Wed, 07 Sep 2005 22:19:17 +0000
State-Changed-Why:
This is a duplicate of PR kern/19856. NetBSD 2.0 and above support the
Epson 2400 scanner.


Responsible-Changed-From-To: kern-bug-people->tron
Responsible-Changed-By: tron@netbsd.org
Responsible-Changed-When: Thu, 08 Sep 2005 07:04:45 +0000
Responsible-Changed-Why:
I'll investigate this.


State-Changed-From-To: closed->open
State-Changed-By: tron@netbsd.org
State-Changed-When: Thu, 08 Sep 2005 07:04:45 +0000
State-Changed-Why:
I don't think the ioctl() is necessary if you configure your scanner
like this:

[usb] 0x04b8 0x011b
device /dev/uscanner0

However having autoconfiguration would be nice. I'll see if the ioctl()
makes autoconfiguration work on my Epson Perfection 1200 and commit
it if it works.


State-Changed-From-To: open->analyzed
State-Changed-By: tron@netbsd.org
State-Changed-When: Thu, 08 Sep 2005 08:52:34 +0000
State-Changed-Why:
Adding the suggested ioctl() has no effect on the behaviour of
"sane-backends" which doesn't contain any code to use it.


From: Matthias Scheler <tron@zhadum.de>
To: Dieter <netbsd@sopwith.solgatos.com>
Cc: netbsd-bugs@netbsd.org, NetBSD GNATS <gnats-bugs@netbsd.org>
Subject: Re: kern/26117
Date: Thu, 8 Sep 2005 16:36:30 +0100

 On Thu, Sep 08, 2005 at 08:19:14AM +0100, Dieter wrote:
 > In message <20050908085235.A893463B877@narn.netbsd.org>, tron@netbsd.org writes:
 > > Synopsis: Sane needs to identify the make/model of scanner.
 > > 
 > > State-Changed-From-To: open->analyzed
 > > State-Changed-By: tron@netbsd.org
 > > State-Changed-When: Thu, 08 Sep 2005 08:52:34 +0000
 > > State-Changed-Why:
 > > Adding the suggested ioctl() has no effect on the behaviour of
 > > "sane-backends" which doesn't contain any code to use it.
 > 
 > Chicken and egg.  sane-backends doesn't have code to use the NetBSD
 > ioctl, because NetBSD doesn't have the ioctl yet.

 I recognized that. Because it is however not urgent (NetBSD works fine
 without support for auto detection) I've asked Lennart Augustsson
 for his opinion on this change. If he agress this is the correct
 solution I'll commit it.

 > Here is what I had in sane-backends-1.0.14 to use the ioctl.

 Please use "diff -u" or "cvs diff -u" to generate diffs. It makes them
 better readable and keeps "patch" happy.

 	Kind regards

 -- 
 Matthias Scheler                                  http://scheler.de/~matthias/

From: Dieter <netbsd@sopwith.solgatos.com>
To: Matthias Scheler <tron@zhadum.de>
Cc: netbsd-bugs@netbsd.org, NetBSD GNATS <gnats-bugs@netbsd.org>
Subject: Re: kern/26117 
Date: Thu, 08 Sep 2005 09:04:26 +0100

 > Please use "diff -u" or "cvs diff -u" to generate diffs. It makes them
 > better readable and keeps "patch" happy.

 Here is the output from "rcsdiff -r1.1 -u sanei/sanei_usb.c":


 --- sanei/sanei_usb.c	2004/06/16 18:44:05	1.1
 +++ sanei/sanei_usb.c	2004/06/23 23:02:41
 @@ -65,6 +65,12 @@
  #include "../include/sane/sanei_usb.h"
  #include "../include/sane/sanei_config.h"

 +#ifdef __NetBSD__
 +#include <dev/usb/usb.h>
 +/* #include <dev/usb/usbhid.h>  */  /* got a redefine */
 +#include <sys/ioctl.h>
 +#endif
 +
  typedef enum
  {
    sanei_usb_method_scanner_driver = 0,	/* kernel scanner driver 
 @@ -194,8 +200,39 @@
  	DBG (3, "sanei_usb_get_vendor_product: ioctl (product) "
  	     "of device %d failed: %s\n", fd, strerror (errno));
      }
 -#endif /* defined (__linux__) */
 +  /* end of defined (__linux__) */
 +#elif defined (__NetBSD__)
 +  {
 +#if 1  /* Needs ioctl added to NetBSD */
 +
 +    /* DBG output not showing up ? */
 +
 +    struct usb_device_info struct_usb_device_info;
 +    if (ioctl (fd, USB_GET_DEVICEINFO, &struct_usb_device_info) == -1)
 +      {
 +	DBG (1, "kernel_get_vendor_product: ioctl (usb_deviceinfo, for vendor & product IDs) "
 +	     "of device %d failed: %s\n", fd, strerror (errno));
 +	perror("NetBSD uscanner ioctl(usb_deviceinfo) failed");
 +      }
 +    else
 +      {
 +	*vendorID  = (int) struct_usb_device_info.udi_vendorNo;
 +	*productID = (int) struct_usb_device_info.udi_productNo;
 +	DBG (2, "NetBSD uscanner ioctl says: vendorID = 0x%04x  productID = 0x%04x\n", *vendorID, *productID);
 +	fprintf(stderr, "NetBSD uscanner ioctl says: vendorID = 0x%04x  productID = 0x%04x\n", *vendorID, *productID);
 +      }
 +#endif
 +#ifdef HARD_CODE_NETBSD_EPSON_2400
 +#warning temp hack for NetBSD to add vendorID productID Epson 2400
 +    DBG (1, "NetBSD vendorID productID hardcoded hack\n");
 +    *vendorID  = 0x04b8 ; /* Seiko Epson */
 +    *productID = 0x011b ; /* Perfection 2400 scanner */
 +#endif HARD_CODE_NETBSD_EPSON_2400
 +  }
 +#else
        /* put more os-dependant stuff ... */
 +#warning "You need to add support for your OS"
 +#endif 
  }

  void
 @@ -955,7 +992,8 @@
  	print_buffer (data, len);
        return SANE_STATUS_GOOD;
  #else /* not __linux__ */
 -      DBG (5, "sanei_usb_control_msg: not supported on this OS\n");
 +#warning "sanei_usb_control_msg: not supported on this OS"
 +      DBG (1, "sanei_usb_control_msg: not supported on this OS\n");
        return SANE_STATUS_UNSUPPORTED;
  #endif /* not __linux__ */
      }

Responsible-Changed-From-To: tron->kern-bug-people
Responsible-Changed-By: tron@NetBSD.org
Responsible-Changed-When: Tue, 20 Jan 2009 08:45:03 +0000
Responsible-Changed-Why:
It is unlikely that I'm going to fix this PR.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.