2006-12-22 11:33:13

by Martin Williges

[permalink] [raw]
Subject: [PATCH 1/1] usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers

from: Martin Williges <[email protected]>

this patch gets the Kyocera FS 820 working with cups 1.2 via usb again. It
adds the printer to the list of "quirky" printers. Patch is based on
linux-2.6.19.

Signed-off-by: Martin Williges <[email protected]>

---

Background:
I have little knowledge of usb, the following is based on my observations and
assumptions. With cups 1.2.6 going stable in gentoo, the usb backend does not
find the printer and thus users are not able to add the printer if it?s
connected via usb. In cups 1.1.x, the backend just reported a default bunch
of devices a printer might be connected to.
As far as I could see, cups detects the printer (/dev/usb/lp0) and sends an
ioctl which times out. I traced the timeout:
usblp.c calls usb_control_msg() (in message.c)
->usb_internal_control_msg()
->usb_start_wait_urb()
this function times out, the printer does not answer (0/1023 chars read).

Funny thing is, reading the identification works directly after plugging the
printer in, but not some seconds after. The patch lets the cups usb backend
find the printer again. So maybe the patch is a little crude. If someone has
a better idea, I may be able provide straces, syslog with DEBUG on,...

--- usblp.c.orig 2006-11-29 22:57:37.000000000 +0100
+++ usblp.c 2006-12-22 12:08:00.000000000 +0100
@@ -217,6 +217,7 @@ static const struct quirk_printer_struct
{ 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */
{ 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */
{ 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
+ { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <[email protected]> */
{ 0, 0 }
};


2006-12-22 13:09:40

by Daniel Drake

[permalink] [raw]
Subject: Re: [PATCH 1/1] usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers

Martin Williges wrote:
> --- usblp.c.orig 2006-11-29 22:57:37.000000000 +0100
> +++ usblp.c 2006-12-22 12:08:00.000000000 +0100
> @@ -217,6 +217,7 @@ static const struct quirk_printer_struct

Your mailer has mangled tabs into whitespace. Also, your patch needs to
be applicable with -p1 from the root kernel dir.

Given the description of the problem it is probably more worthwhile to
provide logs with USB debugging enabled, and usbmon logs, so that the
real problem can be found.

Daniel

2006-12-23 10:03:55

by Martin Williges

[permalink] [raw]
Subject: Re: [PATCH 1/1] usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers

Am Freitag, 22. Dezember 2006 14:10 schrieben Sie:

> Your mailer has mangled tabs into whitespace. Also, your patch needs to
> be applicable with -p1 from the root kernel dir.

I think, it was more the copy and paste from the shell; should have included
the file instead.

> Given the description of the problem it is probably more worthwhile to
> provide logs with USB debugging enabled, and usbmon logs, so that the
> real problem can be found.

I?ll gladly do that best I can, but might need some help what to do. In the
following is what I found so far.

Two straces of the usb backend. First one that worked ok (some seconds after
pluuging the printer in):

[...]
rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0
open("/dev/usblp0", O_RDWR|O_EXCL|O_LARGEFILE) = -1 ENOENT (No such file or
directory)
open("/dev/usb/lp0", O_RDWR|O_EXCL|O_LARGEFILE) = 3
ioctl(0x3, 0x84005001, 0xbfd67cd1) = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 2), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb7fd4000
write(1, "direct usb://Kyocera/FS-820 \"Kyo"..., 161direct
usb://Kyocera/FS-820 "Kyocera FS-820" "Kyocera FS-820 USB
#1" "ID:FS-820;MFG:Kyocera;CMD:PCLXL,PCL5E,PJL;MDL:FS-820;CLS:PRINTER;DES:Kyocera
Mita FS-820;"
) = 161
close(3) = 0
open("/dev/usblp1", O_RDWR|O_EXCL|O_LARGEFILE) = -1 ENOENT (No such file or
directory)
[...]

the ususal case (does not work):

[...]
rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0
open("/dev/usblp0", O_RDWR|O_EXCL|O_LARGEFILE) = -1 ENOENT (No such file or
directory)
open("/dev/usb/lp0", O_RDWR|O_EXCL|O_LARGEFILE) = 3
ioctl(0x3, 0x84005001, 0xbfc397b1) = -1 (errno 5)
close(3) = 0
open("/dev/usblp1", O_RDWR|O_EXCL|O_LARGEFILE) = -1 ENOENT (No such file or
directory)
[...]

Here a piece of the kernel messages with CONFIG_USB_DEBUG=y (started the usb
backend two times, reading printer ID does not work):

[...]
Dec 21 18:48:17 heinrich usb 3-5.4: usb timed out on ep0in len=0/1023
Dec 21 18:48:37 heinrich usb 3-5.4: usb timed out on ep0in len=0/1023
[...]

yes, that?s all with CONFIG_USB_DEBUG.

Then, there are syslog messages with "#define DEBUG" in usblp.c:

After plugging in the printer:
[...]
Dec 21 19:56:12 heinrich usb 1-5.4: new full speed USB device using ehci_hcd
and address 6
Dec 21 19:56:12 heinrich usb 1-5.4: configuration #1 chosen from 1 choice
Dec 21 19:56:12 heinrich drivers/usb/class/usblp.c: usblp0 set protocol 2
Dec 21 19:56:12 heinrich drivers/usb/class/usblp.c: usblp_control_msg: rq:
0x00 dir: 1 recip: 1 value: 0 idx:
0 len: 0x3ff result: 91
Dec 21 19:56:12 heinrich drivers/usb/class/usblp.c: usblp0 Device ID string
[len=91]="ID:FS-820;MFG:Kyocera;C
MD:PCLXL,PCL5E,PJL;MDL:FS-820;CLS:PRINTER;DES:Kyocera Mita FS-820;"
Dec 21 19:56:12 heinrich drivers/usb/class/usblp.c: usblp_control_msg: rq:
0x01 dir: 1 recip: 1 value: 0 idx:
0 len: 0x1 result: 1
Dec 21 19:56:12 heinrich drivers/usb/class/usblp.c: usblp0: USB Bidirectional
printer dev 6 if 0 alt 0 proto
2 vid 0x0482 pid 0x0010
Dec 21 19:56:15 heinrich drivers/usb/class/usblp.c: usblp_ioctl:
cmd=0x84005001 (P nr=1 len=1024 dir=2)
Dec 21 19:56:15 heinrich drivers/usb/class/usblp.c: usblp_control_msg: rq:
0x00 dir: 1 recip: 1 value: 0 idx:
0 len: 0x3ff result: 91
Dec 21 19:56:15 heinrich drivers/usb/class/usblp.c: usblp0 Device ID string
[len=91]="ID:FS-820;MFG:Kyocera;C
MD:PCLXL,PCL5E,PJL;MDL:FS-820;CLS:PRINTER;DES:Kyocera Mita FS-820;"

[So far, so good. I then call the usb backend to read the printer ID]:

Dec 21 19:56:18 heinrich drivers/usb/class/usblp.c: usblp_ioctl:
cmd=0x84005001 (P nr=1 len=1024 dir=2)
Dec 21 19:56:23 heinrich drivers/usb/class/usblp.c: usblp_control_msg: rq:
0x00 dir: 1 recip: 1 value: 0 idx:
0 len: 0x3ff result: -110
Dec 21 19:56:23 heinrich drivers/usb/class/usblp.c: usblp0: error = -110
reading IEEE-1284 Device ID string
[...]

This is what I know until know. What can I do next? Learning about usbmon?

Thanks for hints.

Martin

2006-12-23 14:29:06

by Martin Williges

[permalink] [raw]
Subject: Re: [PATCH 1/1] usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers

So after reading about usbmon, here are some logs.

Printer is inserted and on. Starting cups usb backend to get information
gives:

df827bc0 1861979946 S Bi:002:02 -115 8192 <
ddba34e0 1861979979 S Ci:002:00 s a1 00 0000 0000 03ff 1023 <
ddba34e0 1866979395 C Ci:002:00 -104 0
df827bc0 1866980389 C Bi:002:02 -2 0

Plugging the printer in with usbmon logging gives:

dfaede40 1932904692 S Ii:001:01 -115 2 <
ddba3460 1932904708 S Ci:001:00 s a3 00 0000 0001 0004 4 <
ddba3460 1932904711 C Ci:001:00 0 4 = 00010000
ddba3460 1932904712 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1932904717 C Ci:001:00 0 4 = 01010100
ddba3460 1932904718 S Co:001:00 s 23 01 0010 0002 0000 0
ddba3460 1932904719 C Co:001:00 0 0
ddba3460 1932904722 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1932904723 C Ci:001:00 0 4 = 01010000
ddba3460 1932936690 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1932936692 C Ci:001:00 0 4 = 01010000
ddba3460 1932968689 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1932968698 C Ci:001:00 0 4 = 01010000
ddba3460 1933000687 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1933000689 C Ci:001:00 0 4 = 01010000
ddba3460 1933032693 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1933032694 C Ci:001:00 0 4 = 01010000
ddba3460 1933032703 S Co:001:00 s 23 03 0004 0002 0000 0
ddba3460 1933048686 C Co:001:00 0 0
ddba3460 1933104684 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1933104690 C Ci:001:00 0 4 = 03011000
dfaede40 1933156684 C Ii:001:01 0 1 = 04
dfaede40 1933156686 S Ii:001:01 -115 2 <
ddba3460 1933160683 S Co:001:00 s 23 01 0014 0002 0000 0
ddba3460 1933160684 C Co:001:00 0 0
ddba3460 1933171377 S Ci:000:00 s 80 06 0100 0000 0040 64 <
ddba3460 1933172589 C Ci:000:00 0 8 = 12010101 00000008
ddba3460 1933172597 S Co:001:00 s 23 03 0004 0002 0000 0
ddba3460 1933184681 C Co:001:00 0 0
ddba3460 1933240680 S Ci:001:00 s a3 00 0000 0002 0004 4 <
ddba3460 1933240686 C Ci:001:00 0 4 = 03011000
ddba3460 1933296678 S Co:001:00 s 23 01 0014 0002 0000 0
ddba3460 1933296679 C Co:001:00 0 0
ddba3460 1933296681 S Co:000:00 s 00 05 0003 0000 0000 0
ddba3460 1933298535 C Co:000:00 0 0
ddba3460 1933316680 S Ci:003:00 s 80 06 0100 0000 0012 18 <
ddba3460 1933318528 C Ci:003:00 0 18 = 12010101 00000008 82041000 00000102
0301
ddba3460 1933318537 S Ci:003:00 s 80 06 0200 0000 0009 9 <
ddba3460 1933321527 C Ci:003:00 0 9 = 09022000 010100c0 32
ddba3460 1933321532 S Ci:003:00 s 80 06 0200 0000 0020 32 <
ddba3460 1933324525 C Ci:003:00 0 32 = 09022000 010100c0 32090400 00020701
02000705 01024000 00070582 02400000
ddba34e0 1933324536 S Ci:003:00 s 80 06 0300 0000 00ff 255 <
ddba34e0 1933327524 C Ci:003:00 0 4 = 04030904
ddba34e0 1933327531 S Ci:003:00 s 80 06 0302 0409 00ff 255 <
ddba34e0 1933330523 C Ci:003:00 0 42 = 2a034b00 79006f00 63006500 72006100
20004d00 69007400 61002000 46005300
ddba34e0 1933330530 S Ci:003:00 s 80 06 0301 0409 00ff 255 <
ddba34e0 1933333522 C Ci:003:00 0 26 = 1a034b00 79006f00 63006500 72006100
20004d00 69007400 6100
ddba34e0 1933333527 S Ci:003:00 s 80 06 0303 0409 00ff 255 <
ddba34e0 1933336520 C Ci:003:00 0 22 = 16035800 4c004600 34005900 30003700
37003900 3100
ddba34e0 1933378426 S Co:003:00 s 00 09 0001 0000 0000 0
ddba34e0 1933379513 C Co:003:00 0 0
cf590ea0 1933379625 S Co:003:00 s 01 0b 0000 0000 0000 0
cf590ea0 1933382511 C Co:003:00 0 0
cf590ea0 1933382539 S Ci:003:00 s a1 00 0000 0000 03ff 1023 <
cf590ea0 1933385510 C Ci:003:00 0 91 = 005b4944 3a46532d 3832303b 4d46473a
4b796f63 6572613b 434d443a 50434c58
cf590ea0 1933396519 S Ci:001:00 s a3 00 0000 0003 0004 4 <
cf590ea0 1933396524 C Ci:001:00 0 4 = 00010000
cf590ea0 1933396531 S Ci:001:00 s a3 00 0000 0002 0004 4 <
cf590ea0 1933396533 C Ci:001:00 0 4 = 03010000
de8fbac0 1935981340 S Bi:003:02 -115 8192 <
de8fb1c0 1935981363 S Ci:003:00 s a1 00 0000 0000 03ff 1023 <
de8fbac0 1935982496 C Bi:003:02 0 0
de8fb1c0 1935982501 C Ci:003:00 0 91 = 005b4944 3a46532d 3832303b 4d46473a
4b796f63 6572613b 434d443a 50434c58

starting the cups usb backend some seconds after plugging the printer in gives

de8fbac0 2123539163 S Bi:003:02 -115 8192 <
ddba3860 2123539196 S Ci:003:00 s a1 00 0000 0000 03ff 1023 <
ddba3860 2128538251 C Ci:003:00 -104 0
de8fbac0 2128539243 C Bi:003:02 -2 0

just as before.


2006-12-28 19:52:31

by Martin Williges

[permalink] [raw]
Subject: Re: [PATCH 1/1] usblp.c - add Kyocera Mita FS 820 to list of "quirky" printers

from: Martin Williges <[email protected]>

This patch gets the Kyocera FS-820 working with cups 1.2 via usb again. It
adds the printer to the list of "quirky" printers. The printer seems not
answer to ID requests some seconds after plugging in. Patch is based on
linux-2.6.19.1.

Signed-off-by: Martin Williges <[email protected]>

---

Background:
As far as I could see (strace, usbmon), the Kyocera FS-820 answers to ID
requests only a few seconds after plugging it in. This applies to detecting
it with cups and is also true for the printing itself, which is initiated
with an ID request. Since I have little usb knowledge, maybe someone can
interpret the data, especially the fist bulk transfer - why request 8192
bytes? This is the second version of the patch.

usbmon output of printing an email without patch:
tail -F /tmp/printlog.txt
c636e140 3374734463 S Bi:002:02 -115 8192 <
c9d43b40 3374734494 S Ci:002:00 s a1 00 0000 0000 03ff 1023 <
c9d43b40 3379732301 C Ci:002:00 -104 0
c636e140 3379733294 C Bi:002:02 -2 0
[...repeating...]

with patch:
tail -F /tmp/printlog.txt
d9cb82c0 3729790131 S Ci:002:00 s a1 00 0000 0000 03ff 1023 <
d9cb82c0 3729791725 C Ci:002:00 0 91 = 005b4944 3a46532d 3832303b 4d46473a
4b796f63 6572613b 434d443a 50434c58 df956320 3732493190 S Bo:002:01 -115
1347 = 1b252d31 32333435 5840504a 4c0a4050 4a4c2053 4554204d 414e5541
4c464545 [...more data...]

--- linux-2.6.19.1/drivers/usb/class/usblp.c.orig 2006-12-28 20:15:34.000000000 +0100
+++ linux-2.6.19.1/drivers/usb/class/usblp.c 2006-12-28 19:32:52.000000000 +0100
@@ -217,6 +217,7 @@ static const struct quirk_printer_struct
{ 0x0409, 0xbef4, USBLP_QUIRK_BIDIR }, /* NEC Picty760 (HP OEM) */
{ 0x0409, 0xf0be, USBLP_QUIRK_BIDIR }, /* NEC Picty920 (HP OEM) */
{ 0x0409, 0xf1be, USBLP_QUIRK_BIDIR }, /* NEC Picty800 (HP OEM) */
+ { 0x0482, 0x0010, USBLP_QUIRK_BIDIR }, /* Kyocera Mita FS 820, by zut <[email protected]> */
{ 0, 0 }
};