* Patch: usblp quirk for zebra printers
@ 2008-05-21 17:57 P. Christeas
2008-05-21 22:37 ` Pete Zaitcev
0 siblings, 1 reply; 3+ messages in thread
From: P. Christeas @ 2008-05-21 17:57 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Pete Zaitcev, lkml
[-- Attachment #1: Type: text/plain, Size: 173 bytes --]
Hi,
I guess such a quirk may be a little odd, but it has been a blocking point in
my system not being able to support more than one printer.
Please comment. (and cc. me)
[-- Attachment #2: 0001-USB-Quirk-for-Zebra-printers-not-reporting-their-S.patch --]
[-- Type: text/x-diff, Size: 2668 bytes --]
From 2c87e2cbc8d33b49b6e7a20b9b85570840bb0e12 Mon Sep 17 00:00:00 2001
From: P.Christeas <p_christ@hol.gr>
Date: Wed, 21 May 2008 20:47:52 +0300
Subject: [PATCH] USB: Quirk for Zebra printers not reporting their S/N.
Those printers (and maybe others) don't report their Serial
Number as a part of their IEEE1284 device id string. Thus,
printing backends like CUPS cannot select among multiple
devices at the same host.
Workaround this situation by appending the SN in usblp.c .
---
drivers/usb/class/usblp.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 0647164..a4d324b 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -210,6 +210,7 @@ struct quirk_printer_struct {
#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
#define USBLP_QUIRK_BAD_CLASS 0x4 /* descriptor uses vendor-specific Class or SubClass */
+#define USBLP_QUIRK_ID_NO_SERIAL 0x8 /* Printer does not report its serial no. in GET_ID request */
static const struct quirk_printer_struct quirk_printers[] = {
{ 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
@@ -227,6 +228,7 @@ static const struct quirk_printer_struct quirk_printers[] = {
{ 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
{ 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <kernel@zut.de> */
{ 0x04b8, 0x0202, USBLP_QUIRK_BAD_CLASS }, /* Seiko Epson Receipt Printer M129C */
+ { 0x0a5f, 0x000a, USBLP_QUIRK_ID_NO_SERIAL }, /* Zebra printers don't report their serial */
{ 0, 0 }
};
@@ -1330,6 +1332,23 @@ static int usblp_cache_device_id_string(struct usblp *usblp)
length = 2;
else if (length >= USBLP_DEVICE_ID_SIZE)
length = USBLP_DEVICE_ID_SIZE - 1;
+
+ /* If printer doesn't report its serial, we append it */
+ if ((usblp->quirks & USBLP_QUIRK_ID_NO_SERIAL) && (usblp->dev->serial) &&
+ (length + strlen(usblp->dev->serial) + 5 <USBLP_DEVICE_ID_SIZE) ) {
+
+ if (usblp->device_id_string[length-1] != ';')
+ usblp->device_id_string[length++]= ';';
+
+ strcpy(&usblp->device_id_string[length],"SN:");
+ length+=3;
+ strcat(&usblp->device_id_string[length],usblp->dev->serial);
+ length += strlen(usblp->dev->serial);
+ usblp->device_id_string[length++]= ';';
+
+ *((__be16 *)usblp->device_id_string) = cpu_to_be16(length);
+ }
+
usblp->device_id_string[length] = '\0';
dbg("usblp%d Device ID string [len=%d]=\"%s\"",
--
1.5.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Patch: usblp quirk for zebra printers
2008-05-21 17:57 Patch: usblp quirk for zebra printers P. Christeas
@ 2008-05-21 22:37 ` Pete Zaitcev
2008-05-25 9:03 ` P. Christeas
0 siblings, 1 reply; 3+ messages in thread
From: Pete Zaitcev @ 2008-05-21 22:37 UTC (permalink / raw)
To: P. Christeas; +Cc: Oliver Neukum, lkml, zaitcev, linux-usb, twaugh
On Wed, 21 May 2008 20:57:49 +0300, "P. Christeas" <p_christ@hol.gr> wrote:
> I guess such a quirk may be a little odd, but it has been a blocking point in
> my system not being able to support more than one printer.
> @@ -1330,6 +1332,23 @@ static int usblp_cache_device_id_string(struct usblp *usblp)
.....
> + strcpy(&usblp->device_id_string[length],"SN:");
> + length+=3;
> + strcat(&usblp->device_id_string[length],usblp->dev->serial);
> + length += strlen(usblp->dev->serial);
> + usblp->device_id_string[length++]= ';';
> +
> + *((__be16 *)usblp->device_id_string) = cpu_to_be16(length);
I see...
> Please comment. (and cc. me)
Personally, I don't like this. In kernel, we typically try not to
fake things in lower levels in order to fool upper levels. There are
always knock-off effects. Sometimes we have to do it, but in my
experience CUPS folks always were for doing the right thing.
Let's ask them if extracting the S/N from sysfs is too onerous.
I'm cc-ing this to Tim Waugh.
BTW, Please try to tinker with the following udev ruleset:
BUS="usb", KERNEL="lp[0-9]*", SYSFS{serial}=="XXXXXXX", SYMLINK+="mylp0"
BUS="usb", KERNEL="lp[0-9]*", SYSFS{serial}=="YYYYYYY", SYMLINK+="mylp1"
Encoding your serial numbers into udev rules is not pleasant, but
the above should provide a stop-gap solution without patching kernels.
-- Pete
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch: usblp quirk for zebra printers
2008-05-21 22:37 ` Pete Zaitcev
@ 2008-05-25 9:03 ` P. Christeas
0 siblings, 0 replies; 3+ messages in thread
From: P. Christeas @ 2008-05-25 9:03 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Oliver Neukum, lkml, linux-usb, twaugh
On Thursday 22 May 2008, Pete Zaitcev wrote:
> On Wed, 21 May 2008 20:57:49 +0300, "P. Christeas" <p_christ@hol.gr> wrote:
> > I guess such a quirk may be a little odd, but it has been a blocking
> > point in my system not being able to support more than one printer.
> Personally, I don't like this. In kernel, we typically try not to
> fake things in lower levels in order to fool upper levels.
>...
> I'm cc-ing this to Tim Waugh.
I'm now working in a more "politically correct" way around that issue [1]. The
outline is that we _add_ a backend to CUPS[2], which will bring back USB
addressing by /dev/.. name. Then, we could implement udev rulesets which will
create "by-id" symlinks to the usblpX devices.
My work is at github under "cups-usbbackend".
[1] it is a blocking point for my business, as I cannot attach a second
printer.
[2] it could remain a complementary package until we really agree we want that
code mainline.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-25 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-21 17:57 Patch: usblp quirk for zebra printers P. Christeas
2008-05-21 22:37 ` Pete Zaitcev
2008-05-25 9:03 ` P. Christeas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.