diff: hp usb printers quirk + bonus

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

diff: hp usb printers quirk + bonus

Vladimir Kirillov-2
Hello, tech@!

Since a lot of HP usb printers work badly (or do not work at all)
with ulpt and they want all cups and hplip goo, I've added a
new UQ_SHOULD_UGEN quirk to let ulpt(4) know when to skip the device.

As a bonus, a usbdevs 0X->0x consistency conversion.

Index: ulpt.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ulpt.c,v
retrieving revision 1.37
diff -u -p -r1.37 ulpt.c
--- ulpt.c 24 Sep 2010 08:33:59 -0000 1.37
+++ ulpt.c 18 Dec 2010 08:06:12 -0000
@@ -153,8 +153,12 @@ ulpt_match(struct device *parent, void *
     id->bInterfaceSubClass == UISUBCLASS_PRINTER &&
     ((id->bInterfaceProtocol == UIPROTO_PRINTER_UNI) ||
      (id->bInterfaceProtocol == UIPROTO_PRINTER_BI) ||
-     (id->bInterfaceProtocol == UIPROTO_PRINTER_1284)))
+     (id->bInterfaceProtocol == UIPROTO_PRINTER_1284))) {
+ if (usbd_get_quirks(uaa->device)->uq_flags & UQ_SHOULD_UGEN)
+ return (UMATCH_NONE);
+
  return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
+ }
  return (UMATCH_NONE);
 }
 
Index: usb_quirks.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.63
diff -u -p -r1.63 usb_quirks.c
--- usb_quirks.c 2 Dec 2010 06:39:09 -0000 1.63
+++ usb_quirks.c 18 Dec 2010 08:06:12 -0000
@@ -104,6 +104,7 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_HP, USB_PRODUCT_HP_816C,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_959C,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_1220C,    ANY,   { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_LJ1010,    ANY,   { UQ_SHOULD_UGEN  }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920,    ANY,   { UQ_BROKEN_BIDIR }},
Index: usb_quirks.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.16
diff -u -p -r1.16 usb_quirks.h
--- usb_quirks.h 19 Jul 2010 05:08:37 -0000 1.16
+++ usb_quirks.h 18 Dec 2010 08:06:12 -0000
@@ -49,6 +49,8 @@ struct usbd_quirks {
 #define UQ_MS_LEADING_BYTE 0x00010000 /* mouse sends unknown leading byte */
 #define UQ_EHCI_NEEDTO_DISOWN 0x00020000 /* must hand device over to USB 1.1
  if attached to EHCI */
+#define UQ_SHOULD_UGEN 0x00040000 /* device should not be matched by any
+        specific driver */
 };
 
 extern const struct usbd_quirks usbd_no_quirk;
Index: usbdevs
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.533
diff -u -p -r1.533 usbdevs
--- usbdevs 17 Dec 2010 21:00:13 -0000 1.533
+++ usbdevs 18 Dec 2010 08:06:13 -0000
@@ -1913,6 +1913,7 @@ product HP 840C 0x0604 DeskJet 840c
 product HP 2200C 0x0605 ScanJet 2200C
 product HP 5300C 0x0701 Scanjet 5300C
 product HP 816C 0x0804 DeskJet 816C
+product HP LJ1010 0x0c17 LaserJet 1010
 product HP 970CSE 0x1004 Deskjet 970Cse
 product HP 5400C 0x1005 Scanjet 5400C
 product HP 2215 0x1016  iPAQ 22xx/Jornada 548
@@ -3270,30 +3271,30 @@ product SEALEVEL 2403_1 0x2413 SeaPORT+
 product SEALEVEL 2403_2 0x2423 SeaPORT+4 (2403) Port 2
 product SEALEVEL 2403_3 0x2433 SeaPORT+4 (2403) Port 3
 product SEALEVEL 2403_4 0x2443 SeaPORT+4 (2403) Port 4
-product SEALEVEL 2801_1 0X2811 SeaLINK+8/232 (2801) Port 1
-product SEALEVEL 2801_2 0X2821 SeaLINK+8/232 (2801) Port 2
-product SEALEVEL 2801_3 0X2831 SeaLINK+8/232 (2801) Port 3
-product SEALEVEL 2801_4 0X2841 SeaLINK+8/232 (2801) Port 4
-product SEALEVEL 2801_5 0X2851 SeaLINK+8/232 (2801) Port 5
-product SEALEVEL 2801_6 0X2861 SeaLINK+8/232 (2801) Port 6
-product SEALEVEL 2801_7 0X2871 SeaLINK+8/232 (2801) Port 7
-product SEALEVEL 2801_8 0X2881 SeaLINK+8/232 (2801) Port 8
-product SEALEVEL 2802_1 0X2812 SeaLINK+8/485 (2802) Port 1
-product SEALEVEL 2802_2 0X2822 SeaLINK+8/485 (2802) Port 2
-product SEALEVEL 2802_3 0X2832 SeaLINK+8/485 (2802) Port 3
-product SEALEVEL 2802_4 0X2842 SeaLINK+8/485 (2802) Port 4
-product SEALEVEL 2802_5 0X2852 SeaLINK+8/485 (2802) Port 5
-product SEALEVEL 2802_6 0X2862 SeaLINK+8/485 (2802) Port 6
-product SEALEVEL 2802_7 0X2872 SeaLINK+8/485 (2802) Port 7
-product SEALEVEL 2802_8 0X2882 SeaLINK+8/485 (2802) Port 8
-product SEALEVEL 2803_1 0X2813 SeaLINK+8 (2803) Port 1
-product SEALEVEL 2803_2 0X2823 SeaLINK+8 (2803) Port 2
-product SEALEVEL 2803_3 0X2833 SeaLINK+8 (2803) Port 3
-product SEALEVEL 2803_4 0X2843 SeaLINK+8 (2803) Port 4
-product SEALEVEL 2803_5 0X2853 SeaLINK+8 (2803) Port 5
-product SEALEVEL 2803_6 0X2863 SeaLINK+8 (2803) Port 6
-product SEALEVEL 2803_7 0X2873 SeaLINK+8 (2803) Port 7
-product SEALEVEL 2803_8 0X2883 SeaLINK+8 (2803) Port 8
+product SEALEVEL 2801_1 0x2811 SeaLINK+8/232 (2801) Port 1
+product SEALEVEL 2801_2 0x2821 SeaLINK+8/232 (2801) Port 2
+product SEALEVEL 2801_3 0x2831 SeaLINK+8/232 (2801) Port 3
+product SEALEVEL 2801_4 0x2841 SeaLINK+8/232 (2801) Port 4
+product SEALEVEL 2801_5 0x2851 SeaLINK+8/232 (2801) Port 5
+product SEALEVEL 2801_6 0x2861 SeaLINK+8/232 (2801) Port 6
+product SEALEVEL 2801_7 0x2871 SeaLINK+8/232 (2801) Port 7
+product SEALEVEL 2801_8 0x2881 SeaLINK+8/232 (2801) Port 8
+product SEALEVEL 2802_1 0x2812 SeaLINK+8/485 (2802) Port 1
+product SEALEVEL 2802_2 0x2822 SeaLINK+8/485 (2802) Port 2
+product SEALEVEL 2802_3 0x2832 SeaLINK+8/485 (2802) Port 3
+product SEALEVEL 2802_4 0x2842 SeaLINK+8/485 (2802) Port 4
+product SEALEVEL 2802_5 0x2852 SeaLINK+8/485 (2802) Port 5
+product SEALEVEL 2802_6 0x2862 SeaLINK+8/485 (2802) Port 6
+product SEALEVEL 2802_7 0x2872 SeaLINK+8/485 (2802) Port 7
+product SEALEVEL 2802_8 0x2882 SeaLINK+8/485 (2802) Port 8
+product SEALEVEL 2803_1 0x2813 SeaLINK+8 (2803) Port 1
+product SEALEVEL 2803_2 0x2823 SeaLINK+8 (2803) Port 2
+product SEALEVEL 2803_3 0x2833 SeaLINK+8 (2803) Port 3
+product SEALEVEL 2803_4 0x2843 SeaLINK+8 (2803) Port 4
+product SEALEVEL 2803_5 0x2853 SeaLINK+8 (2803) Port 5
+product SEALEVEL 2803_6 0x2863 SeaLINK+8 (2803) Port 6
+product SEALEVEL 2803_7 0x2873 SeaLINK+8 (2803) Port 7
+product SEALEVEL 2803_8 0x2883 SeaLINK+8 (2803) Port 8
 
 /* Senao products */
 product SENAO RT2870_3 0x0605 RT2870

Reply | Threaded
Open this post in threaded view
|

Re: diff: hp usb printers quirk + bonus

j4nKy
On Sat, Dec 18, 2010 at 10:14:54AM +0200, Vladimir Kirillov wrote:
> Hello, tech@!
>
> Since a lot of HP usb printers work badly (or do not work at all)
> with ulpt and they want all cups and hplip goo, I've added a
> new UQ_SHOULD_UGEN quirk to let ulpt(4) know when to skip the device.

I suggested a quirk to choose ugen recently and there was some
resistence.

however, I think in this case, perhaps forcing HP printers to not
match ulpt is the more correct thing to do.

> As a bonus, a usbdevs 0X->0x consistency conversion.

please don't mix differring purposes in the same patch.

--
[hidden email]
SDF Public Access UNIX System - http://sdf.lonestar.org

Reply | Threaded
Open this post in threaded view
|

Re: diff: hp usb printers quirk + bonus

j4nKy
On Sat, Dec 18, 2010 at 08:48:10AM +0000, Jacob Meuser wrote:
> On Sat, Dec 18, 2010 at 10:14:54AM +0200, Vladimir Kirillov wrote:
> > Hello, tech@!
> >
> > Since a lot of HP usb printers work badly (or do not work at all)
> > with ulpt and they want all cups and hplip goo, I've added a
> > new UQ_SHOULD_UGEN quirk to let ulpt(4) know when to skip the device.
>
> I suggested a quirk to choose ugen recently and there was some
> resistence.

and looking at your patch ... if there will be a quirk that says
to attach at ugen, it should really make it attach at ugen, immediately,
and not be a flag to be used in other drivers.

--
[hidden email]
SDF Public Access UNIX System - http://sdf.lonestar.org

Reply | Threaded
Open this post in threaded view
|

Re: diff: hp usb printers quirk + bonus

Vladimir Kirillov-2
On 09:01 Sat 18 Dec, Jacob Meuser wrote:

> On Sat, Dec 18, 2010 at 08:48:10AM +0000, Jacob Meuser wrote:
> > On Sat, Dec 18, 2010 at 10:14:54AM +0200, Vladimir Kirillov wrote:
> > > Hello, tech@!
> > >
> > > Since a lot of HP usb printers work badly (or do not work at all)
> > > with ulpt and they want all cups and hplip goo, I've added a
> > > new UQ_SHOULD_UGEN quirk to let ulpt(4) know when to skip the device.
> >
> > I suggested a quirk to choose ugen recently and there was some
> > resistence.
>
> and looking at your patch ... if there will be a quirk that says
> to attach at ugen, it should really make it attach at ugen, immediately,
> and not be a flag to be used in other drivers.

Agree. I've tweaked the diff to hook into usbd_probe_and_attach().

By the way, if we'll be checking for quirks and such an early stage,
we could add the quirks field to usb_attach_arg to avoid calling
usbd_get_quirks() in future, right?

Index: usb_subr.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.77
diff -u -p -r1.77 usb_subr.c
--- usb_subr.c 17 Dec 2010 22:38:54 -0000 1.77
+++ usb_subr.c 18 Dec 2010 09:29:49 -0000
@@ -878,7 +905,6 @@ usbd_probe_and_attach(struct device *par
  uaa.iface = NULL;
  uaa.ifaces = NULL;
  uaa.nifaces = 0;
- uaa.usegeneric = 0;
  uaa.port = port;
  uaa.configno = UHUB_UNK_CONFIGURATION;
  uaa.ifaceno = UHUB_UNK_INTERFACE;
@@ -886,6 +912,11 @@ usbd_probe_and_attach(struct device *par
  uaa.product = UGETW(dd->idProduct);
  uaa.release = UGETW(dd->bcdDevice);
 
+ /* test for generic quirk early */
+ uaa.usegeneric = usbd_get_quirks(dev)->uq_flags & UQ_SHOULD_UGEN;
+ if (uaa.usegeneric)
+ goto trygeneric;
+
  /* First try with device specific drivers. */
  DPRINTF(("usbd_probe_and_attach trying device specific drivers\n"));
  dv = config_found_sm(parent, &uaa, usbd_print, usbd_submatch);
@@ -972,8 +1003,9 @@ usbd_probe_and_attach(struct device *par
  DPRINTF(("usbd_probe_and_attach: no interface drivers found\n"));
 
  /* Finally try the generic driver. */
- uaa.iface = NULL;
  uaa.usegeneric = 1;
+trygeneric:
+ uaa.iface = NULL;
  uaa.configno = UHUB_UNK_CONFIGURATION;
  uaa.ifaceno = UHUB_UNK_INTERFACE;
  dv = config_found_sm(parent, &uaa, usbd_print, usbd_submatch);
Index: usb_quirks.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.c,v
retrieving revision 1.63
diff -u -p -r1.63 usb_quirks.c
--- usb_quirks.c 2 Dec 2010 06:39:09 -0000 1.63
+++ usb_quirks.c 18 Dec 2010 09:29:48 -0000
@@ -104,6 +104,7 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_HP, USB_PRODUCT_HP_816C,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_959C,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_HP, USB_PRODUCT_HP_1220C,    ANY,   { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_HP, USB_PRODUCT_HP_LJ1010,    ANY,   { UQ_SHOULD_UGEN  }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760,    ANY,   { UQ_BROKEN_BIDIR }},
  { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920,    ANY,   { UQ_BROKEN_BIDIR }},
Index: usb_quirks.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_quirks.h,v
retrieving revision 1.16
diff -u -p -r1.16 usb_quirks.h
--- usb_quirks.h 19 Jul 2010 05:08:37 -0000 1.16
+++ usb_quirks.h 18 Dec 2010 09:29:48 -0000
@@ -49,6 +49,8 @@ struct usbd_quirks {
 #define UQ_MS_LEADING_BYTE 0x00010000 /* mouse sends unknown leading byte */
 #define UQ_EHCI_NEEDTO_DISOWN 0x00020000 /* must hand device over to USB 1.1
  if attached to EHCI */
+#define UQ_SHOULD_UGEN 0x00040000 /* device should not be matched by any
+        specific driver */
 };
 
 extern const struct usbd_quirks usbd_no_quirk;
Index: usbdevs
===================================================================
RCS file: /cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.533
diff -u -p -r1.533 usbdevs
--- usbdevs 17 Dec 2010 21:00:13 -0000 1.533
+++ usbdevs 18 Dec 2010 09:29:49 -0000
@@ -1913,6 +1913,7 @@ product HP 840C 0x0604 DeskJet 840c
 product HP 2200C 0x0605 ScanJet 2200C
 product HP 5300C 0x0701 Scanjet 5300C
 product HP 816C 0x0804 DeskJet 816C
+product HP LJ1010 0x0c17 LaserJet 1010
 product HP 970CSE 0x1004 Deskjet 970Cse
 product HP 5400C 0x1005 Scanjet 5400C
 product HP 2215 0x1016  iPAQ 22xx/Jornada 548

Reply | Threaded
Open this post in threaded view
|

Re: diff: hp usb printers quirk + bonus

Vladimir Kirillov-2
On 11:34 Sat 18 Dec, Vladimir Kirillov wrote:
> By the way, if we'll be checking for quirks and such an early stage,
> we could add the quirks field to usb_attach_arg to avoid calling
> usbd_get_quirks() in future, right?

Ignore that, i thought it was a table lookup, but it's a
field in struct usbd_device..