# HOWTO: Parallel Port Scanner

## Hypnos

Who is this for?

If you have a scanner attached to your computer by a parallel printer cable, but expects to do so through a SCSI adapter card rather than directly to the motherboard.  If you have a native parallel port scanner, read the other contributions later in this thread.

Requirements

You must be running a 2.6.x series kernel and a have the sources installed.

Configuring the Kernel (kernel <= 2.6.10)

a) Download the patch

http://penguin-breeder.org/kernel/download/linux-ppscsi-2.6.x.patch.gz

b) Patch the kernel as root in the kernel source directory:

```
# gzcat <path to download>  | patch -p1
```

c) Enable the following options (I recommend modules if you need to suspend-to-disk):

```
Device Drivers 

    -> SCSI device support

        <M> SCSI device support

        <M> SCSI generic support

        -> SCSI low-level drivers 

           <M> Parallel Port SCSI adapters 

           <M> <your scanner>
```

My scanner is an HP ScanJet 5100C, so I selected "Shuttle EPST".  A rough mapping from scanner badge to optimum driver is here:

http://www.buzzard.org.uk/jonathan/scanners.html

d) Compile and install kernel

```
# make

# make modules_install

# cp arch/i386/boot/bzImage /boot/<whatever>

```

e) If you enabled the items above as modules

Add the module for <your scanner> as well as sg  to /etc/modules.autoload.d/kernel-2.6; the remaining SCSI modules will be loaded automatically.  Use "modprobe" to load them manually to test without rebooting.

Configuring the Kernel (kernel >=2.6.10)

Use the ebuild at Bug #119196

Configuring /dev (devfsd)

a) Add the following lines to /etc/devfsd.con

```
# Set SCSI generic permissions (for scanner)

REGISTER   ^scsi/host0/bus0/target0/lun0/generic$  PERMISSIONS root.scanner 660

REGISTER   ^scsi/host0/bus0/target0/lun0/generic$  CFUNCTION GLOBAL mksymlink $devname scanner

LOOKUP  ^scanner$  CFUNCTION GLOBAL mksymlink scsi/host0/bus0/target0/lun0/generic scanner
```

b) Do "killall -HUP devfsd" as root to load the new configuration

Configuring /dev (udev)

My rule file in "/etc/udev/rules.d":

```
BUS=="scsi", SYSFS{vendor}=="HP*", SYSFS{model}=="C5190A*", NAME="%k", GROUP="uucp", MODE="0660", SYMLINK+="scanner"
```

Using the scanner

"emerge sane-frontends" for command line tools, or "emerge xsane" for that and a GTK2 front-end.  

Enjoy!

----------

## rhowardiv

Great howto, thank you. Needs updating, though:

The patch in step a) is inadequate for kernel 2.6.9 and 2.6.10 (and possibly earlier 2.6 versions as well).

You will probably get symbol errors for symbols scsi_sleep and parport_get_port when trying to load the module for your scsi driver.

Here's a new patch for 2.6.9.

Here's a new patch for 2.6.10.

EDIT: this 2.6.10 patch is new and works now

As I found out from the linux-parport mailing list archive:

For 2.6.9, all occurences of "scsi_sleep" in the 2.6.x patch must be replaced with "msleep".

For 2.6.10, the following lines were added to the patch:

```
diff -Nru a/drivers/parport/share.c b/drivers/parport/share.c

--- a/drivers/parport/share.c   2005-01-10 20:00:22 +02:00

+++ b/drivers/parport/share.c   2005-01-10 20:00:22 +02:00

@@ -1007,6 +1007,7 @@

  EXPORT_SYMBOL(parport_unregister_driver);

  EXPORT_SYMBOL(parport_register_device);

  EXPORT_SYMBOL(parport_unregister_device);

+EXPORT_SYMBOL(parport_get_port);

  EXPORT_SYMBOL(parport_put_port);

  EXPORT_SYMBOL(parport_find_number);

  EXPORT_SYMBOL(parport_find_base);

```

If you try the new patches I assembled, please let me know whether or not they work (I haven't used them yet, I hand-patched my own source after applying the 2.6.x patch and finding it didn't work).

Thanks!Last edited by rhowardiv on Sun Jan 30, 2005 7:52 pm; edited 2 times in total

----------

## Hypnos

Thanks!

Also, I've recently switched to udev exclusively.  Here's my rule file:

```
BUS="scsi",SYSFS{vendor}="HP      ",SYSFS{model}="C5190A          ", SYMLINK="scanner", NAME="%k", GROUP="scanner", MODE="0660"
```

----------

## dencar

rhowardiv said:

 *Quote:*   

> If you try the new patches I assembled, please let me know whether or not they work (I haven't used them yet, I hand-patched my own source after applying the 2.6.x patch and finding it didn't work).
> 
> Thanks!

 

```
root@dencar /usr/src/linux # gzcat /home/dennis/linux-ppscsi-2.6.10.patch.gz  | patch -p1

patching file drivers/scsi/Kconfig

Hunk #1 succeeded at 902 (offset 55 lines).

patching file drivers/scsi/Makefile

Hunk #1 succeeded at 140 (offset 17 lines).

patching file drivers/scsi/epsa2.c

patching file drivers/scsi/epst.c

patching file drivers/scsi/onscsi.c

patching file drivers/scsi/ppscsi.c

patching file drivers/scsi/ppscsi.h

patching file drivers/scsi/sparcsi.c

patching file drivers/scsi/t348.c

patching file drivers/scsi/t358.c

patching file drivers/scsi/vpi0.c

patching file drivers/scsi/vpi2.c

patching file drivers/parport/share.c

Hunk #1 FAILED at 1007.

1 out of 1 hunk FAILED -- saving rejects to file drivers/parport/share.c.rej

```

share.c.rej says:

 *Quote:*   

> ***************
> 
> *** 1007,1012 ****
> 
>    EXPORT_SYMBOL(parport_unregister_driver);
> ...

 

Should I patch that manually? Thanks.

----------

## rhowardiv

I'd go ahead and add that line to drivers/parport/share.c manually. Sorry the patch didn't all work.

Hypnos, or anyone, I'm new to building patch files...is there something I need to watch out for when combining two patches? I can't see any obvious problems. I tried rebuilding the bad diff in the patch and got the same results. 

Any insights?

thanks

----------

## Hypnos

There should be no problem if you know C or can impute the syntax.

Try it!

----------

## rhowardiv

OK, I took a few moments to create and test a fresh patch for 2.6.10 that works.

 *Quote:*   

> Here's a new patch for 2.6.10.

 

Hope it's useful.

----------

## DRi_

Hi all, 

I probed the last patch but nothing work. Ok, then I open /src/usr/linux/drivers/parport/share.c and saw that 

 the variable:

```

+EXPORT_SYMBOL(parport_get_port); 
```

didn't exist in this file. I put this variable in the share.c, genkernel all, 

modified /etc/modules.autoload/kernel.2.6

add modules sg and epst

modprobe sg , modprobe epst 

```
sane-find-scanner

found SCSI processor "HP C5190A 3740" at /dev/scanner

found SCSI processor "HP C5190A 3740" at /dev/sg0

  # Your SCSI scanner was detected. It may or may not be supported by SANE. Try

  # scanimage -L and read the backend's manpage.

  # No USB scanners found. If you expected something different, make sure that

  # you have loaded a driver for your USB host controller and have installed a

  # kernel scanner module.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports

  # can't be detected by this program.

  # You may want to run this program as root to find all devices. Once you

  # found the scanner devices, be sure to adjust access permissions as

  # necessary.

```

And now it works.

----------

## MatzeG

I'm currently using kernelversion 2.6.12-r6 and tried to apply the patch, because I have a scanner that needs this drivers (onscsi).

I applied the newest patch mentioned above, although it's not 2.6.10. All seemed to be fine, but when I compile the driver for the scanner as module, 

and try to modprobe it, it gives me:

WARNING: Error inserting ppscsi (/lib/modules/2.6.12-gentoo-r6/kernel/drivers/scsi/ppscsi.ko): Unknown symbol in module, or unknown parameter (see dmesg)

FATAL: Error inserting onscsi (/lib/modules/2.6.12-gentoo-r6/kernel/drivers/scsi/onscsi.ko): Unknown symbol in module, or unknown parameter (see dmesg)

and in dmesg:

ppscsi: Unknown symbol parport_get_port

onscsi: Unknown symbol ppsc_make_map

onscsi: Unknown symbol ppsc_queuecommand

onscsi: Unknown symbol ppsc_abort

onscsi: Unknown symbol ppsc_reset

onscsi: Unknown symbol ppsc_proc_info

onscsi: Unknown symbol ppsc_detect

onscsi: Unknown symbol ppsc_biosparam

onscsi: Unknown symbol ppsc_release

I checked if it is in /usr/src/linux/drivers/parport/share.c and it is, 

but after the compilation, it is not in /lib/modules/2.6.12-gentoo-r6/modules.symbols.

Can anyone help me with this, please?

Thank you very much, 

Matthias

----------

## Hypnos

Is reverting to kernel 2.6.10 an option?  If that works, it just means that the patch needs some work to be updated.

----------

## MatzeG

Well, i have virtually no knowledge on how to update this patch, 

but will try it with 2.6.10 and keep you informed.

What version are you using?

Thanks, 

Matthias

----------

## Hypnos

2.6.7

----------

## Alexandr

Btw,  linux-ppscsi-2.6.9.patch.gz (from http://penguin-breeder.org/kernel/download/) works fine with gentoo-sources-2.6.9-r9...

Even without "Configuring /dev" section from 1st post...

----------

## TemplarKnight

 *Hypnos wrote:*   

> 
> 
> c) Enable the following options (I recommend modules if you need to suspend-to-disk):
> 
> ```
> ...

 

I have a mustek 1200CP parallel port scanner, which scanner driver should i chose as module in the kernel?? (I successfully patched my 2.6.12-suspend2-r6 kernel)

Anybody knows?  :Question: 

----------

## Alexandr

Wow, TemplarKnight, used what patch you successfully patched your kernel?

----------

## TemplarKnight

 *Alexandr wrote:*   

> Wow, TemplarKnight, used what patch you successfully patched your kernel?

 

the 2.6.10 that rhowardiv shows...

but no luck cause there seems to be no in kernel driver for my scanner...

----------

## Hypnos

It seems like your scanner doesn't require ppscsi; rather the SANE driver can talk to it directly over the parallel port:

http://penguin-breeder.org/sane/mustek_pp/

----------

## TemplarKnight

 *Hypnos wrote:*   

> It seems like your scanner doesn't require ppscsi; rather the SANE driver can talk to it directly over the parallel port:
> 
> http://penguin-breeder.org/sane/mustek_pp/

 

you are the man....

but sorry for another noobish question....how do i get my parallel port in kernel?? where is it in 2.6 kernel configuration??

----------

## Hypnos

I think it's on my default.  It's under "Device Drivers" -> "Parallel Port" or something like that.

Make sure that IEEE 1284 support is activated.

----------

## TemplarKnight

 *Hypnos wrote:*   

> I think it's on my default.  It's under "Device Drivers" -> "Parallel Port" or something like that.
> 
> Make sure that IEEE 1284 support is activated.

 

You are so the man!!!   :Very Happy:   :Very Happy: 

Thanks a lot, its working now. 

My kernel didnt have  neither parallel port support nor 1284 support.

My current kernel config is ::

```
tuxy birbilakos # grep PPDEV /usr/src/linux/.config

CONFIG_PPDEV=m

tuxy birbilakos # grep 1284 /usr/src/linux/.config

CONFIG_PARPORT_1284=y
```

(which i think if put as a module is also ok)

Also at Bios i have my Parallel Port type: EPP (havent tried the others, may also work...)

xsane does all the job....

some permission config now for it ...

Thanks again Hypnos (Are u Greek??) for this tutorial.  :Cool: 

----------

## Hypnos

 *TemplarKnight wrote:*   

> Thanks again Hypnos (Are u Greek??) for this tutorial. 

 

Nope, ugly American.   :Razz: 

----------

## afterstep

hi all, I tryed to compile the ppscsi path on 2.6.12-r10 but when I try to load epst module it wait forever whitout messages.

my scanner is hp5100c

----------

## yesi

hi!

i've just seen your topic after having got to work my (parallel port) scanner.

what i did:

i chose mine http://www.sane-project.org/cgi-bin/driver.pl?manu=medion&model=&bus=par

i put in /etc/make.conf

 *Quote:*   

> SANE_BACKENDS="the_name_of_your_backend_goes_here"--------->>>>>>>>>>>here, it's dangerous http://gentoo-wiki.com/HOWTO_Install_a_USB_scanner

 

here, this is mustek_pp for my model

 some options for the kernel must be necessary... :Smile: 

i installed  *Quote:*   

> sane-backends xsane sane-frontends

 

( i chose the FLAG gimp)

the most importance files in /etc/sane.d are dll.conf and my mustek_pp.conf and the others files you can remove them.

in /etc/sane.d/dll.conf

 *Quote:*   

> 
> 
> ...
> 
> # all toto
> ...

 

in /etc/sane.d/mustek_pp.conf

i chose one  of mine.

i added:

```
# gpasswd -a root scanner

# gpasswd -a <user> scanner
```

i tested

```
sane-find-scanner -q
```

 *Quote:*   

> found USB scanner (vendor=0x046d, product=0x08b2) at libusb:002:002

 --->strange!!!!!!!! ::::::  :Smile: 

```
scanimage -L
```

 *Quote:*   

> device `mustek_pp:Mustek-1200CP' is a Mustek 1200CP flatbed scanner

 

```
grep scanner /etc/group

scanner:x:1977:root,yesi
```

with root, it works but not with the user...(because of "udev" i suppose)

i'll go to get a look in the forum.

----------

## yesi

i remove in /etc/make.conf the line 

 *Quote:*   

> SANE_BACKENDS="mustek_pp"

 

and i compile again with  *Quote:*   

> media-gfx/sane-backends -usb

  in /etc/portage/package.use

the packages: sane-backends sane-frontends xsane

and it works fine in root.

```
sane-find-scanner -q
```

--> nothing

```
scanimage -L
```

-->device `mustek_pp:Mustek-1200CP' is a Mustek 1200CP flatbed scanner

 :Smile: 

----------

## Hypnos

Thanks to everyone -- I'll make it clear in my original post that those steps are for parellel port-SCSI translation, and to look below for native parallel ports scanners.

----------

## Hypnos

Hello,

If you have a new enough kernel, you no longer have to patch -- just compile the modules seperately.  See the top post, which I have edited again.

----------

## Alexandr

About ppscsi-beta2.tar.gz ...

```
# make install

make: *** No rule to make target `install'.  Stop.
```

Well, i'm extracted all files to /ppscsi-beta2 dir... but if i just "# make" and then insmod <2 modules>.ko - it's work...

P.S. System uname: 2.6.12-gentoo-r10 i686 AMD Athlon(tm)

----------

## Hypnos

 *Alexandr wrote:*   

> About ppscsi-beta2.tar.gz ...
> 
> ```
> # make install
> 
> ...

 

You are correct -- I was confusing with my other kernel module sets  :Smile:   Fixed.

----------

## svenk

Hello

 *yesi wrote:*   

> here, this is mustek_pp for my model

 

I also got a parallel port scanner, working with sane, mustek_pp.

But my problem is: It's extremly slow!

Compared to other scanners, that's not normal.

Example: Another mustek scanner (but a little more old) scanns a page with 300dpi color on win95 in 2mins.

My scanner needs about 30mins (at gentoo linux)

Has anybody here got the same problems?

Sven

----------

## Hypnos

svenk,

I'm having a similar problem when trying to scan in color.  Lineart and grayscale are quite fast (~ 10 seconds).

No answers yet ...

One thing that happens on parallel port-SCSI translation is that the whole computer slows down -- something about the interrupts being hogged.

UPDATE:  No, it only takes ~3 minutes for me; the computer does grind to a halt while it's scanning, though.

If you have a native parallel port scanner, make sure that ECP mode is enabled in your BIOS and in your kernel.

----------

## sludink

Very much thanks for this Howto! Have bought the same HP 5100C yesterday.

 *Quote:*   

> My rule file in "/etc/udev/rules.d":
> 
> ```
> 
> BUS="scsi",SYSFS{vendor}="HP      ",SYSFS{model}="C5190A          ", SYMLINK="scanner", NAME="%k", GROUP="scanner", MODE="0660"
> ...

 

May I add some stuff for clarity and scanner/udev newbies like me:

The code can be put in a new file, which I call /etc/udev/rules.d/20-scanner.rules

After that, make udev reread its config rules: 

```

# udevstart
```

After that, run as root:

```

# sudo scanimage -L
```

to test. My answer is

```
device `hp:/dev/sg0' is a Hewlett-Packard C5190A flatbed scanner
```

Now, xsane mustn't be run as root. To allow normal users to run xsane, they should be in the scanner group.

For user foo, this means editing the groups file /etc/group to contain:

```
scanner:x:407:foo
```

After this, log out of ALL sessions (including the one X is started from if that one exists)

Log in again as normal user, and all should work.

----------

## Kess

I couldn't find any ebuild for the ppscsi suite, so I created one. It is avaible at http://storage.perlig.de/misc/ppscsi-0.0_beta2.ebuild

----------

## Hypnos

 *Kess wrote:*   

> I couldn't find any ebuild for the ppscsi suite, so I created one. It is avaible at http://storage.perlig.de/misc/ppscsi-0.0_beta2.ebuild

 

Looks good -- consider submitting it to bugs.gentoo.org

----------

## yesi

my scanner is a Medion MD 9890

 *Quote:*   

> #  scanner <name> <port> <type>
> 
> scanner Mustek-1200CP 0x378 cis1200

 

my problem of permission for lambda user is still here.

at the beginning, i've dropped it because it was not important because I was the only user of my gentoo...

but now, it's different.

my scanner works fine with root.

so i 've searched about udev to let the simple user to use it but i 've found nothing...

i've got the scanner connected to my printer (the printer is an usb-->/dev/usb/lp0) and connected to my parallel port but i don't have any /dev/lp0 

here is my /dev/

 *Quote:*   

> adsp     cdroms   dvd       graveur  hdc      loop0   mem        port   ram12  ram7    stderr  tty12  tty20  tty29  tty37  tty45  tty53  tty61  ttyS3    vcs4    vcsa4
> 
> adsp2    cdrw     fb        hda      hdd      loop1   misc       ppp    ram13  ram8    stdin   tty13  tty21  tty3   tty38  tty46  tty54  tty62  urandom  vcs5    vcsa5
> 
> agpgart  console  fb0       hda1     hdd1     loop2   mixer      psaux  ram14  ram9    stdout  tty14  tty22  tty30  tty39  tty47  tty55  tty63  v4l      vcs6    vcsa6
> ...

 

so how could i define an udev rule ?

udevinfo -a -p $(udevinfo -q path -n /dev/????????????????????????)

thank in advance.

----------

## svenk

 *yesi wrote:*   

> so how could i define an udev rule ?

 

Like sludink has already written, set up a rule in /etc/rules.d/udev. Other solution: Set up xinetd. Works nicely but of course udev is cooler  :Wink: 

Greetings,

Sven

----------

## RuiP

 *yesi wrote:*   

> my scanner is a Medion MD 9890
> 
>  *Quote:*   #  scanner <name> <port> <type>
> 
> scanner Mustek-1200CP 0x378 cis1200 
> ...

 

hi,

check

http://gentoo-wiki.com/HOWTO_Install_a_USB_scanner#UDEV

and http://webpages.charter.net/decibelshelp/LinuxHelp_UDEVPrimer.html#udevrules

it explains udev rules and permition setting for normal user.

Good luck

----------

## Hypnos

I have updated my udev rule for the newer udev versions -- the top post is edited to reflect this new udev rule.

----------

## yesi

hi!

i bad at explaining... :Smile: 

sur, i've had a look at the udev rules already:

 *Quote:*   

> cat /etc/udev/rules.d/50-udev.rules |grep scanner

 the output have nothing.

with the udevread.py from http://webpages.charter.net/decibelshelp/LinuxHelp_UDEVPrimer.html#udevrules i've got some troubles to have the end of output:

 *Quote:*   

> -----------------------------
> 
> ---> Character Device # 4
> 
> -----------------------------
> ...

 

and the problem that i don't know which device in /dev is connected to my scanner...if i've known , it'd be easy to make an udev rule...

@sven : i'll be interested with xineted but i don't know the rule

----------

## Hypnos

You have to add your own rule file in /etc/udev/rules.d -- there is no default scanner rule.

If it's a ppSCSI scanner, the device is usually /dev/sg0 -- use this with the tool 'udevinfo'

----------

## yesi

hi,

 :Smile: 

yes, i know that i must add myself the rule for my scanner but the probleme that i don't know which device is connected to my scanner...i mean that /dev/sg* doen't existe in my /dev (it's why i put the out of my /dev in my last post)

the scrip udevread.py would be helped me to find the good device but there was some errors...

so how could i know about the good device of my scanner?

thanks in advance.

----------

## Hypnos

If you have a USB scanner, plugging/unplugging should reveal the device in dmes (run "dmesg")

If you have a parallel port-to-SCSI scanner, the device is shown in dmesg when you load the driver module.

----------

## yesi

i've got "harded modules " compiled in the kernel so i can't unload/load the module...

it's a strange probleme for me since i use the printer parrallel port to connect my scanner...

----------

## Hypnos

 *yesi wrote:*   

> i've got "harded modules " compiled in the kernel so i can't unload/load the module...
> 
> it's a strange probleme for me since i use the printer parrallel port to connect my scanner...

 

Then it should still be in dmesg, on bootup.

I have my scanner connected through my printer as well.

----------

## yesi

here's my /dev

 *Quote:*   

> adsp     cdroms   dvd       graveur  hdc      loop0   mem        port   ram12  ram7    stderr  tty12
> 
> adsp2    cdrw     fb        hda      hdd      loop1   misc       ppp    ram13  ram8    stdin   tty13
> 
> agpgart  console  fb0       hda1     hdd1     loop2   mixer      psaux  ram14  ram9    stdout  tty14
> ...

 

and my dmesg:

 *Quote:*   

> e, yres_virtual=3750
> 
> Console: switching to colour frame buffer device 128x48
> 
> fbsplash: console 0 using theme 'emergence'
> ...

 

there's for my parallel port in dmesg:

 *Quote:*   

> parport: PnPBIOS parport detected.
> 
> parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE,EPP]

 

but no lp0 neither sg0...

----------

## Hypnos

Do you have lp support in the kernel?  Then the printer should appear (at least be detected); my dmesg output when I load the module 'lp':

```
lp0: using parport0 (interrupt-driven).
```

The device appears as /dev/lp0.

What is the name of the driver for your scanner?  Is that in the kernel?  The dmesg output when my driver module ('epst') is loaded, and sees the scanner:

```
epst.0: epst 0.92 (0.92), Shuttle EPST at 0x378 mode 2 (PS/2) dly 1 nice 0 sg 16scsi2 : epst

  Vendor: HP        Model: C5190A            Rev: 3740

  Type:   Processor                          ANSI SCSI revision: 02

Attached scsi generic sg0 at scsi2, channel 0, id 0, lun 0,  type 3
```

The device appears as /dev/sg0

----------

## yesi

ok it seems that my lp was not loaded. :p

and the output in dmesg

 *Quote:*   

> lp0: using parport0 (interrupt-driven)

 

but for the module of the scanner, i think it is built "hard" in the kernel...

i'm not sur about the driver perhaps cis1200

perhaps, i'll try xinet.d méthode...i'm going to have a look...

----------

## Ocelot

Curious.

----------

## yesi

my solution:

i set in the kernel

 *Quote:*   

> CONFIG_PPDEV=y

 

to have /dev/parport0

i changed the group

```
chown root:saned /dev/parport0
```

 *Quote:*   

> 
> 
> crw-rw----  1 root root 99, 0 mar 31 11:30 /dev/parport0

 

to

 *Quote:*   

> crw-rw----  1 root saned 99, 0 mar 31 11:30 /dev/parport0

 

and since after rebooting, the group saned become again root

i put in my /etc/conf.d/local.start

```
chown root:saned /dev/parport0
```

if there's an another solution for group, i'll be happy.

and in /etc/xinetd.d/saned 

 *Quote:*   

> 
> 
> service sane-port
> 
>             {
> ...

 

```

gpasswd saned

gpasswd -a root saned

gpasswd -a your_user saned

```

----------

## yesi

ok there's an another methode simpler:

 *Quote:*   

> CONFIG_PPDEV=y

  is important

 and 

add in a file named /etc/udev/rules.d/10-parport.rules

 *Quote:*   

> 
> 
> KERNEL="parport0", GROUP="scanner"

 

to have  *Quote:*   

> crw-rw----  1 root scanner 99, 0 mar 31  2006 /dev/parport0

 

and

```

gpasswd -a root saned

gpasswd -a your_user saned

```

at the end, i'm satisfied.  :Smile: 

thanks a lot, guys!

ps: saned does not need anymore...

----------

## wipp

Hi guys

My scanner stopped working after switching from 2.6.15-r1 to 2.6.16-r* gentoo-sources (same .config file).

In xsane I get a segmentation fault right after clicking "scan preview".

Restarting xsane results in a message "No devices found" (even after rebooting the scanner).

```
modprobe -rf ppscsi
```

complains about ppscsi beeing in use.

```
FATAL: Module ppscsi is in use.
```

The same happens for onscsi.

Are there new drivers in process or can this be fixed?

----------

## Hypnos

Um, have you tried rebuilding ppscsi?

----------

## wipp

Yes, that's what I do everytime after building a new kernel.

I even switched to ppscsi-beta2-20060424.

----------

## Hypnos

I have nothing to offer but to suggest contacting the ppscsi developers.

----------

## wipp

ok, wrote a mail to penguin breeder.

Anyone else having this issue? Ore is this specific to my hardware?

----------

## blue_american

Does this solution work on Plustek scanners? And if it works, in my case my scanner scans negatives, will this work too? Thanks.

----------

## Hypnos

 *blue_american wrote:*   

> Does this solution work on Plustek scanners? And if it works, in my case my scanner scans negatives, will this work too? Thanks.

 

Try it, report back.    :Smile: 

----------

## blue_american

Hi.

First of all, I don't know which modules to load. I tried to load them all and it stuck on sparcsi.ko.

If I lunch xsane, will open with the tv card selected  :Razz: 

Anyone actually got a plustek working on 2.6?

----------

## Hypnos

Updated top post to include info about new ebuild.

----------

## keba

Hi,

your patch is great, it solved half of my problem! But I still have one. I'm using Kernel 2.6.22 and I get the following error:

```

make -C /lib/modules/`uname -r`/build M=`pwd` modules

make[1]: Entering directory `/usr/src/linux-2.6.22-gentoo-r2'

  CC [M]  /home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.o

In file included from /home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.c:55:

/home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.h:16:26: error: linux/config.h: No such file or directory

/home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.c: In function 'ppsc_detect':

/home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.c:1151: warning: assignment from incompatible pointer type

make[2]: *** [/home/jonathan/Documents/downloads/ppscsi-beta2/ppscsi.o] Error 1

make[1]: *** [_module_/home/jonathan/Documents/downloads/ppscsi-beta2] Error 2

make[1]: Leaving directory `/usr/src/linux-2.6.22-gentoo-r2'

make: *** [all] Error 2

```

I have re-emerged the linux-headers but there is no config.h! What can I do?

----------

## keba

Well, I found the solution, and it's quit easy. /lib/modules/"kernel-version/build/linux/config.h got renamed to autoconf.h around kernel 2.6.19. My last kernel (before 2.6.22) was 2.6.18... So I created a patch. The first part (which changes ppscsi.c) is identical to what you already found out in this thread. The second part changes ppscsi.h:

```

--- ppscsi.c.orig   2007-04-02 13:34:27.000000000 +0100

+++ ppscsi.c   2007-04-02 13:34:41.000000000 +0100

@@ -1144,8 +1144,12 @@

       pha->device[p] = '.';

       pha->device[p+1] = '0' + i;

       pha->device[p+2] = 0;

-

-      INIT_WORK(&pha->wq, ppsc_tq_int, pha);

+      

+      #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)

+         INIT_WORK(&pha->wq, ppsc_tq_int, pha);

+      #else

+         INIT_WORK(&pha->wq, ppsc_tq_int);

+      #endif

 

       init_timer (&pha->timer);

       pha->timer.data = (unsigned long) pha;

 

--- ppscsi.h.orig   2007-08-23 13:34:27.000000000 +0100

+++ ppscsi.h   2007-08-23 13:34:41.000000000 +0100

lines 15-17

#include <linux/module.h>

-#include <linux/config.h>

+#include <linux/autoconf.h>

#include <linux/version.h>

```

Hope this will help you.

----------

## logistiker

Can anyone post a newer patch for gentoo-sources 2.6.25?  The posted patches only work until 2.6.24.

https://bugs.gentoo.org/show_bug.cgi?id=119196

----------

## Desperadoss

 *logistiker wrote:*   

> Can anyone post a newer patch for gentoo-sources 2.6.25?  The posted patches only work until 2.6.24.
> 
> https://bugs.gentoo.org/show_bug.cgi?id=119196

 

i dont find any new patch !

----------

## Hypnos

I sold the scanner, so I can't help -- good luck!

----------

## Liftyor

ppscsi-2.6.25.diff

```

diff -u old/ppscsi.c new/ppscsi.c

--- old/ppscsi.c   2008-07-04 23:39:44.000000000 +0400

+++ new/ppscsi.c   2008-07-04 23:40:05.000000000 +0400

@@ -422,16 +422,16 @@

 

    bf &= (!((1<<pha->cur_cmd->device->id) & pha->slow_targets));

    

-   r = pha->cur_cmd->use_sg;

+   r = pha->cur_cmd->sdb.table.nents;

    if (r) {

       b = 0;

-      p = (struct scatterlist *)pha->cur_cmd->request_buffer;

+      p = (struct scatterlist *)pha->cur_cmd->sdb.table.sgl;

       for (k=0;k<r;k++) {

          b += p->length;

          p++;

       }

    } else { 

-      b = pha->cur_cmd->request_bufflen;

+      b = pha->cur_cmd->sdb.length;

    }

 

    bf &= (b > 127);

@@ -565,16 +565,16 @@

             pha->data_dir = phase & PPSC_IO;

             pha->data_count = 0;

 

-            pha->sg_count = pha->cur_cmd->use_sg;

+            pha->sg_count = pha->cur_cmd->sdb.table.nents;

             if (pha->sg_count) {

                pha->sg_count--;

                pha->sg_list = 

-                  (struct scatterlist *)pha->cur_cmd->request_buffer;

+                  (struct scatterlist *)pha->cur_cmd->sdb.table.sgl;

                pha->cur_buf = sg_virt(pha->sg_list); /* page_address(pha->sg_list->page) + pha->sg_list->offset; */

                pha->cur_len = pha->sg_list->length;

             } else {

-               pha->cur_buf = pha->cur_cmd->request_buffer;

-               pha->cur_len = pha->cur_cmd->request_bufflen;

+               pha->cur_buf = pha->cur_cmd->sdb.table.sgl;

+               pha->cur_len = pha->cur_cmd->sdb.length;

             }

 

             pha->last_phase = phase;

@@ -620,7 +620,7 @@

 

             if (pha->cur_cmd->cmnd[0] == REQUEST_SENSE) {

 

-               sb = (char *)pha->cur_cmd->request_buffer;

+               sb = (char *)pha->cur_cmd->sdb.table.sgl;

                printk("%s: Sense key: %x ASC: %x ASCQ: %x\n",

                       pha->device, sb[2] & 0xff,

                       sb[12] & 0xff, sb[13] & 0xff);

@@ -815,9 +815,9 @@

       cmd->cmnd[4] = sizeof(cmd->sense_buffer);

       cmd->cmnd[5] = 0;

       cmd->cmd_len = 6;

-      cmd->use_sg = 0;

-      cmd->request_buffer = (char *) cmd->sense_buffer;

-      cmd->request_bufflen = sizeof(cmd->sense_buffer);

+      cmd->sdb.table.nents = 0;

+      cmd->sdb.table.sgl = (char *) cmd->sense_buffer;

+      cmd->sdb.length = sizeof(cmd->sense_buffer);

 

       pha->cur_cmd = cmd;

       ppsc_do_claimed(pha,ppsc_start);

@@ -1014,9 +1014,9 @@

    cmd.device = &dev;

    cmd.cmd_len = 6;

    for (i=0;i<6;i++) cmd.cmnd[i] = inq[i];

-   cmd.use_sg = 0;

-   cmd.request_buffer = buf;

-   cmd.request_bufflen = 36;

+   cmd.sdb.table.nents = 0;

+   cmd.sdb.table.sgl = buf;

+   cmd.sdb.length = 36;

 

    return ppsc_command(&cmd);

    

```

It worked for me on 2.6.25.4.

Apply it on http://penguin-breeder.org/kernel/download/ppscsi-beta2-20060424.tar.gz after http://www.kivela.net/jaska/projects/ubuntu-ppscsi/ppscsi-beta2-for-2.6.24.diff.txt (http://www.kivela.net/jaska/projects/ubuntu-ppscsi).

I'm not a kernel hacker, I just found a similiar patch here:  :Very Happy: 

http://aur.archlinux.org/packages.php?do_Details&ID=14443

https://bugs.gentoo.org/attachment.cgi?id=145284

----------

## logistiker

For anyone who's interested, I created a tarball with all the combined patches along with the latest patch (modified for older kernel support).  It works with 2.6.25 as well as < 2.6.25.  

https://bugs.gentoo.org/attachment.cgi?id=159853

https://bugs.gentoo.org/show_bug.cgi?id=119196

----------

## logistiker

Anyone have any idea how to fix this compile warning?  I'd like to have this work for 2.6.28.

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c: In function ‘ppsc_engine’:

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c:597: warning: assignment from incompatible pointer type

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c: In function ‘ppsc_cleanup’:

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c:849: warning: assignment from incompatible pointer type

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c: In function ‘ppsc_inquire’:

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c:1054: warning: assignment from incompatible pointer type

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c: In function ‘ppsc_detect’:

/var/tmp/portage/portage/media-gfx/ppscsi-20060424-r2/work/ppscsi-beta2/ppscsi.c:1192: warning: assignment from incompatible pointer type

----------

## keba

For kernel 2.6.32, I got it to work like the Ubuntu guys did. First, make sure you have the following kernel options enabled (you might also need some of the other options):

```

Device Drivers -->

    Parallel Port Support -->

        [*] PC-style Hardware

```

The Ubuntu guys used a Tutorial from an italian page, which basically said to do this:

```

wget http://penguin-breeder.org/kernel/download/ppscsi-beta2-20060424.tar.gz

wget http://www.iadegesso.netsons.org/assets/files/ppscsi-patch-2_6_27up.tar.gz

tar xf ppscsi-beta2-20060424.tar.gz

tar xf ppscsi-patch-2_6_27up.tar.gz

mv ppscsi.*.patch ppscsi-beta2

cd ppscsi-beta2

patch -Np1 -i ppscsi.c.patch

patch -Np0 -i ppscsi.h.patch

make

```

You can then insmod the modules in the directory where you compiled them and/or add the modules to your configuration permanently if you want:

```

mkdir /lib/modules/`uname -r`/kernel/drivers/parport

cp ppscsi.ko epst.ko /lib/modules/`uname -r`/kernel/drivers/parport

depmod

echo "" >> /etc/conf.d/modules

echo "modules_2_6=\"${modules_2_6} ppscsi\"" >> /etc/conf.d/modules

echo "module_ppscsi_args_2_6=\"\"" >> /etc/conf.d/modules

echo "" >> /etc/conf.d/modules

echo "modules_2_6=\"${modules_2_6} epst\"" >> /etc/conf.d/modules

echo "module_epst_args_2_6=\"\"" >> /etc/conf.d/modules

```

----------

## keba

Looks like it still doesn't work on kernels > 2.6.30. ppscsi loads without a problem, but loading epst.ko hangs without any notification. I guess it's because of the ppscsi detection that doesn't work. Issuing make always gives the following errors although the modules build:

```

  CC [M]  /home/xxx/ppscsi-beta2/ppscsi.o

/home/xxx/ppscsi-beta2/ppscsi.c: In function ‘ppsc_cleanup’:

/home/xxx/ppscsi-beta2/ppscsi.c:849: warning: assignment from incompatible pointer type

/home/xxx/ppscsi-beta2/ppscsi.c: In function ‘ppsc_detect’:

/home/xxx/ppscsi-beta2/ppscsi.c:1192: warning: assignment from incompatible pointer type

```

----------

## keba

There is a new patch from here. I'm testing it right now.

----------

## keba

Works   :Very Happy:   :Very Happy:   :Very Happy:  I got my HP Scanjet 5100c back to work on Kernel 2.6.32. epst.ko takes a while to load, but it does. And Skanlite (KDE) is a great app.

```

wget http://penguin-breeder.org/kernel/download/ppscsi-beta2-20060424.tar.gz

wget http://infabo.net/wp-content/uploads/2010/01/ppscsi.patch.tar.gz

tar -xzf ppscsi-beta2-20060424.tar.gz

tar -xzf ppscsi.patch.tar.gz

cd ppscsi-beta2

patch -p1 < ../ppscsi.patch

make

mkdir /lib/modules/`uname -r`/kernel/drivers/parport

cp ppscsi.ko epst.ko /lib/modules/`uname -r`/kernel/drivers/parport

depmod -a

modprobe ppscsi

modprobe epst

```

----------

## keba

EDIT: New download location

There is a new patched version that compiles without an error. I got it from here, so you might want to check it out from time to time.

```

wget http://homepages.woosh.co.nz/gryphon/files/ppscsi-patched-karmic.tar.gz

tar -zxvf ppscsi-patched-karmic.tar.gz

cd ppscsi-beta2

make

mkdir /lib/modules/`uname -r`/kernel/drivers/parport

cp ppscsi.ko epst.ko /lib/modules/`uname -r`/kernel/drivers/parport

depmod -a

modprobe ppscsi

modprobe epst

```

----------

## keba

Important for kernel 2.6.33:

/usr/src/linux/include/linux/autoconf.h was moved to /usr/src/linux/include/generated/autoconf.h

As a result, in ppscsi.h, change

```
#include <linux/autoconf.h>
```

to 

```
#include <generated/autoconf.h>
```

----------

## keba

New Download Location:

http://homepages.woosh.co.nz/gryphon/files/ppscsi-patched-karmic.tar.gz

Important for Kernel 2.6.34:

Make sure to change the line noted in the post above, like for kernel 2.6.33. Works fine.

----------

## keba

Important for Kernel 2.6.35:

Make sure to change the line noted in the post above, like for kernel 2.6.33. Works fine as well.

----------

## seo123

 *keba wrote:*   

> Important for Kernel 2.6.35:
> 
> Make sure to change the line noted in the post above, like for kernel 2.6.33. Works fine as well.

 

yes, now it works. i forget to change it and wasted a half day. sometimes ppl are blind  :Smile: 

----------

## keba

Cool, some people are still following this thread. I wasn't sure if this helped anyone. Apparently it does. Have fun with your scanner  :Wink: 

----------

## keba

The above works for kernel 2.6.36, but is not yet tested for 2.6.37 and 2.6.38...

----------

## keba

complete system freeze when loading epst.ko in kernel 2.6.38

----------

## keba

So the problem is this code:

```

struct scsi_host_template   driver_template = PPSC_TEMPLATE(onscsi);

```

in t348.c:302, t358.c:378, onscsi.c:529, epsa2.c:492, epst.c:463, vpi0.c:261 and sparcsi.c:373 because it's (apparently) an "initialization from incompatible pointer type". This structure is declared in /usr/src/linux/include/scsi/libiscsi.h, /usr/src/linux/include/scsi/scsi_host.h and /usr/src/linux/drivers/scsi/scsi_priv.h

When loading the modules, it produces a kernel panic, which explains the system freeze (see post above).

I don't know how to fix this, as I'm no C programmer, but maybe someone here knows? That would be a great help...

----------

## keba

It turns out that from kernel >=2.6.37, ppscsi doesn't work any more. A guy over at the ubuntu forums has managed to get the code to compile without errors, but the scanner doesn't get recognized any more.

This is his patch:

```

diff -crB ppscsi-beta2/ppscsi.c ppscsi-beta3/ppscsi.c

*** ppscsi-beta2/ppscsi.c   2010-01-07 01:47:53.000000000 +0100

--- ppscsi-beta3/ppscsi.c   2011-06-02 08:38:37.000000000 +0200

***************

*** 188,194 ****

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (void *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

--- 188,194 ----

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (struct work_struct *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

***************

*** 383,391 ****

     return cmd->result;

  }

  

! int ppsc_queuecommand (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))

  {

!    PHA *pha = (PHA *) cmd->device->host->hostdata[0];

  

     if (pha->cur_cmd) {

        printk("%s: Driver is busy\n",pha->device);

--- 383,391 ----

     return cmd->result;

  }

  

! int ppsc_queuecommand (struct Scsi_Host *host, struct scsi_cmnd *cmd)

  {

!    PHA *pha = (PHA *) host->hostdata[0];

  

     if (pha->cur_cmd) {

        printk("%s: Driver is busy\n",pha->device);

***************

*** 393,399 ****

     }

  

     pha->cur_cmd = cmd;

!    pha->done = done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

--- 393,399 ----

     }

  

     pha->cur_cmd = cmd;

!    pha->done = cmd->scsi_done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

***************

*** 1232,1238 ****

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!       hreg->unique_id = (int) pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

--- 1232,1238 ----

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!       hreg->unique_id = (unsigned long)pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

diff -crB ppscsi-beta2/ppscsi.h ppscsi-beta3/ppscsi.h

*** ppscsi-beta2/ppscsi.h   2010-01-07 01:47:53.000000000 +0100

--- ppscsi-beta3/ppscsi.h   2011-06-02 08:39:19.000000000 +0200

***************

*** 13,19 ****

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <linux/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

--- 13,19 ----

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <generated/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

***************

*** 32,38 ****

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct scsi_cmnd *, void (* done)(struct scsi_cmnd *));

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

--- 32,38 ----

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

```

----------

## hwertz

So, I got ppscsi-patched-karmic.tar.gz (per the Ubuntu thread) and the patch just above (which I saved as ppscsi-2.6.37.patch.)   Look out for a possible ppscsi.c.rej, I had a few lines not patch due to some tabs turning into spaces in my cut'n paste (and patch -l flag not handling it for some reason.)   Against that, 

```

*** ppscsi.c~   Mon Oct 31 01:00:05 2011

--- ppscsi.c    Mon Oct 31 01:55:36 2011

***************

*** 382,390 ****

  

        return cmd->result;

  }

  

!  int ppsc_queuecommand (struct Scsi_Host *host, struct scsi_cmnd *cmd)

  {

      PHA *pha = (PHA *) host->hostdata[0];

  

        if (pha->cur_cmd) {

--- 382,390 ----

  

        return cmd->result;

  }

  

!  int ppsc_queuecommand_lck (struct Scsi_Host *host, struct scsi_cmnd *cmd)

  {

      PHA *pha = (PHA *) host->hostdata[0];

  

        if (pha->cur_cmd) {

***************

*** 400,407 ****

--- 400,409 ----

  

        return 0;

  }

  

+ static DEF_SCSI_QCMD(ppsc_queuecommand)

+ 

  static void ppsc_arb_fail (PHA *pha)

  {

        PPSC_FAIL(DID_BUS_BUSY,"Arbitration failure");

  }

```

     I'll try it tomorrow.  But, the important change in 2.6.37 is that it runs your scsi driver with no locks whatsoever, unless you rename the queue command and add DEF_SCSI_QCMD like the above.  The 2.6.37_rc1 kernel changes (edit: http://www.gossamer-threads.com/lists/linux/kernel/1301610) show a patch like this to all the drivers included with the kernel, and looking at 2.6.38-gentoo-r3 source on my box shows that I don't think there's *any* SCSI driver set up to do it's own locks yet. (I'd assume due to timing requirements that fiddling a parallel port is exceptionally unlikely to work with interrupts enabled, which is why it's not working as-is.)

----------

## keba

And I was about to throw out the scanner. Do you think you can get it working? If so, could you tell me as soon as possible please? Thanks you

----------

## hwertz

I found something odd with the switch from foo_queuecommand to foo_queuecommand_lck in various SCSI drivers -- the DEF_SCSI_QCMD wraps ppsc_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))  wrapping some locks around it, which results in ppsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmd).  So I actually had to revert one portion of the patch 2 posts above.  This is verified "works for me" on Ubuntu 11.04 with 2.6.38-11-generic (since that happens to be what it's on now -- my gentoo box is at home and this scanner is at my parents.)  This patch incorporates the rest of that patch already, and goes directly onto ppscsi-patched-karmic.tar.gz

```
diff -cr ppscsi-beta2/ppscsi.c ppscsi-beta2-updated/ppscsi.c

*** ppscsi-beta2/ppscsi.c   2010-01-06 18:47:53.000000000 -0600

--- ppscsi-beta2-updated/ppscsi.c   2011-10-31 14:15:02.000000000 -0500

***************

*** 188,194 ****

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (void *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

--- 188,194 ----

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (struct work_struct *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

***************

*** 383,389 ****

     return cmd->result;

  }

  

! int ppsc_queuecommand (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))

  {

     PHA *pha = (PHA *) cmd->device->host->hostdata[0];

  

--- 383,389 ----

     return cmd->result;

  }

  

! int ppsc_queuecommand_lck (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))

  {

     PHA *pha = (PHA *) cmd->device->host->hostdata[0];

  

***************

*** 393,405 ****

     }

  

     pha->cur_cmd = cmd;

!    pha->done = done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

  

     return 0;

  }

  

  static void ppsc_arb_fail (PHA *pha)

  {

--- 393,407 ----

     }

  

     pha->cur_cmd = cmd;

!     pha->done = cmd->scsi_done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

  

     return 0;

  }

+ DEF_SCSI_QCMD(ppsc_queuecommand)

+ 

  

  static void ppsc_arb_fail (PHA *pha)

  {

***************

*** 1232,1238 ****

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!       hreg->unique_id = (int) pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

--- 1234,1240 ----

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!        hreg->unique_id = (unsigned long)pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

diff -cr ppscsi-beta2/ppscsi.h ppscsi-beta2-updated/ppscsi.h

*** ppscsi-beta2/ppscsi.h   2010-01-06 18:47:53.000000000 -0600

--- ppscsi-beta2-updated/ppscsi.h   2011-10-31 15:56:35.000000000 -0500

***************

*** 13,19 ****

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <linux/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

--- 13,19 ----

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <generated/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

***************

*** 32,38 ****

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct scsi_cmnd *, void (* done)(struct scsi_cmnd *));

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

--- 32,38 ----

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmd);

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

```

     If you go to the ubuntuforums thread linked to 3 or 4 posts above this, that forum let me attach a .patch.gz (it won't take .patch files but takes gzips..) so you won't have to worry about cut'n'paste mangling the patch.

----------

## hwertz

So, I'm pasting this from the post I made on ubuntuforums, and modifying as appropriate for Ubuntu.

     A few more items to make it nice:

     I haven't moved this scanner to one of my gentoo boxes yet to see if udev for gentoo has this same problem, but on Ubuntu it does -- the scanner device is owned by root, and only accessible by root.  To fix the permissions problems the scanner has by default so xsane and such don't have to be run as root.  This is in /etc/udev/rules.d/45-libsane.rules:

```

SUBSYSTEM=="scsi_generic",ATTRS{type}=="3", NAME="%k", SYMLINK="scanner%n", MODE="0777", GROUP="scanner"

```

     Secondly, Ubuntu has plenty of kernel updates, and who wants to remember to rebuild ppscsi each time?  (This doesn't seem like "the gentoo way" to have this autorun, but the fact of the matter is ppscsi is not equipped for module-rebuild either, if you rebuild your gentoo kernel..)  I figured, make runs very fast when there's nothing to build, and ~30 seconds (on a pretty antiquated box) when it does.  So on the Ubuntu box, I stuck this in /etc/rc.local just before the "exit 0".  On gentoo, this'd be in /etc/conf.d/local.start:

```

(cd /usr/src/ppscsi-beta2/

 make

 insmod ./ppscsi.ko

 insmod ./epst.ko) 

```

     Rebuilds ppscsi if needed, and loads the modules.

----------

## keba

works on kernel 2.6.38!!! Thank you very much!

Now let's try on kernel 3.0.x

----------

## keba

It does not work on kernel 3.0.2   :Sad: 

```

make -C /lib/modules/`uname -r`/build M=`pwd` modules

make[1]: entrant dans le répertoire « /usr/src/linux-3.0.2-pf »

  CC [M]  /home/user/ppscsi-beta2/ppscsi.o

/home/user/ppscsi-beta2/ppscsi.c:73: erreur: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

make[2]: *** [/home/user/ppscsi-beta2/ppscsi.o] Erreur 1

make[1]: *** [_module_/home/user/ppscsi-beta2] Erreur 2

make[1]: quittant le répertoire « /usr/src/linux-3.0.2-pf »

make: *** [all] Erreur 2

```

Also, udev reports that NAME="%k" is not being used because of this:

```

Nov  1 21:23:25 linux udevd[4239]: NAME="%k" is ignored, because it breaks kernel supplied names, please remove it from /etc/udev/rules.d/45-libsane.rules:1

```

----------

## keba

On kernel 3.0.x, 

remove line 73:

```

spinlock_t      ppsc_spinlock = SPIN_LOCK_UNLOCKED;

```

and replace it with 

```

DEFINE_SPINLOCK(ppsc_spinlock);

```

to get it to work

----------

## keba

HOWTO for kernel 3.0.x

Do the following:

1) save the patch below as ppscsi-3.0.patch as a simple text file in the folder where you're downloading the source file of ppscsi-patched-karmic (see below)

2) use these commands

Note: the line starting with "echo" and the one below it are ONE line, it ends with ".rules". You'll have to do this as root

```

wget http://homepages.woosh.co.nz/gryphon/files/ppscsi-patched-karmic.tar.gz

tar -zxvf ppscsi-patched-karmic.tar.gz

cd ppscsi-beta2

patch -p1 -i ../ppscsi-3.0.patch

make

mkdir /lib/modules/`uname -r`/kernel/drivers/parport

cp ppscsi.ko epst.ko /lib/modules/`uname -r`/kernel/drivers/parport

depmod -a

echo "SUBSYSTEM==\"scsi_generic\",ATTRS{type}==\"3\", SYMLINK=\"scanner%n\", MODE=\"0777\", GROUP=\"scanner\"" >> /etc/udev/rules.d/45-libsane.rules

modprobe ppscsi

modprobe epst 

```

Patch for kernel 3.0.x, against ppscsi-patched-karmic.tar.gz:

```

Seulement dans ppscsi-beta2-updated: .directory

diff -crB ppscsi-beta2/ppscsi.c ppscsi-beta2-updated/ppscsi.c

*** ppscsi-beta2/ppscsi.c   2010-01-07 01:47:53.000000000 +0100

--- ppscsi-beta2-updated/ppscsi.c   2011-11-01 21:58:48.000000000 +0100

***************

*** 70,76 ****

  #define PPSC_DEF_NICE   0

  #define PPSC_INITIATOR  7

  

! spinlock_t      ppsc_spinlock = SPIN_LOCK_UNLOCKED;

  

  static char   ppsc_bulk_map[256];

  

--- 70,76 ----

  #define PPSC_DEF_NICE   0

  #define PPSC_INITIATOR  7

  

! DEFINE_SPINLOCK(ppsc_spinlock); 

  

  static char   ppsc_bulk_map[256];

  

***************

*** 188,194 ****

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (void *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

--- 188,194 ----

     spin_unlock_irqrestore(&ppsc_spinlock,flags);

  }

  

! static void ppsc_tq_int (struct work_struct *data)

  {

     void (*con)(PHA *);

     unsigned long flags;

***************

*** 383,389 ****

     return cmd->result;

  }

  

! int ppsc_queuecommand (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))

  {

     PHA *pha = (PHA *) cmd->device->host->hostdata[0];

  

--- 383,389 ----

     return cmd->result;

  }

  

! int ppsc_queuecommand_lck (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))

  {

     PHA *pha = (PHA *) cmd->device->host->hostdata[0];

  

***************

*** 393,405 ****

     }

  

     pha->cur_cmd = cmd;

!    pha->done = done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

  

     return 0;

  }

  

  static void ppsc_arb_fail (PHA *pha)

  {

--- 393,407 ----

     }

  

     pha->cur_cmd = cmd;

!     pha->done = cmd->scsi_done;

     pha->then = jiffies;

  

     ppsc_do_claimed(pha,ppsc_start);

  

     return 0;

  }

+ DEF_SCSI_QCMD(ppsc_queuecommand)

+ 

  

  static void ppsc_arb_fail (PHA *pha)

  {

***************

*** 1232,1238 ****

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!       hreg->unique_id = (int) pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

--- 1234,1240 ----

        hreg = scsi_register(tpnt,sizeof(PHA*));

        hreg->dma_channel = -1;

        hreg->n_io_port = 0;

!        hreg->unique_id = (unsigned long)pha; /* What should we put in here??? */

        hreg->sg_tablesize = s;

        hreg->hostdata[0]=(unsigned long)pha; /* Will be our pointer */

  

diff -crB ppscsi-beta2/ppscsi.h ppscsi-beta2-updated/ppscsi.h

*** ppscsi-beta2/ppscsi.h   2010-01-07 01:47:53.000000000 +0100

--- ppscsi-beta2-updated/ppscsi.h   2011-11-01 21:58:09.000000000 +0100

***************

*** 13,19 ****

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <linux/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

--- 13,19 ----

  #define   PPSC_H_VERSION   "0.92"

  

  #include <linux/module.h>

! #include <generated/autoconf.h>

  #include <linux/version.h>

  #include <linux/stddef.h>

  #include <linux/types.h>

***************

*** 32,38 ****

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct scsi_cmnd *, void (* done)(struct scsi_cmnd *));

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

--- 32,38 ----

  

  extern int ppsc_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);

  extern int ppsc_command(struct scsi_cmnd *);

! extern int ppsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmd);

  extern int ppsc_abort(struct scsi_cmnd *);

  extern int ppsc_reset(struct scsi_cmnd *);

  extern int ppsc_biosparam(struct scsi_device *, struct block_device *, sector_t capacity, int[]);

```

----------

## infabo

broken in kernel 3.2.0 again. It compiles:

```
make

make -C /lib/modules/`uname -r`/build M="`pwd`" modules

make[1]: Entering directory `/usr/src/linux-headers-3.2.0-24-generic-pae'

  CC [M]  /usr/src/ppscsi-beta2_new/ppscsi.o

/usr/src/ppscsi-beta2_new/ppscsi.c: In function âppsc_inquire.isra.12â:

/usr/src/ppscsi-beta2_new/ppscsi.c:1070:1: warning: the frame size of 1084 bytes is larger than 1024 bytes [-Wframe-larger-than=]

  CC [M]  /usr/src/ppscsi-beta2_new/t348.o

  CC [M]  /usr/src/ppscsi-beta2_new/t358.o

  CC [M]  /usr/src/ppscsi-beta2_new/onscsi.o

  CC [M]  /usr/src/ppscsi-beta2_new/epsa2.o

  CC [M]  /usr/src/ppscsi-beta2_new/epst.o

  CC [M]  /usr/src/ppscsi-beta2_new/vpi0.o

  CC [M]  /usr/src/ppscsi-beta2_new/sparcsi.o

  Building modules, stage 2.

  MODPOST 8 modules

  CC      /usr/src/ppscsi-beta2_new/epsa2.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/epsa2.ko

  CC      /usr/src/ppscsi-beta2_new/epst.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/epst.ko

  CC      /usr/src/ppscsi-beta2_new/onscsi.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/onscsi.ko

  CC      /usr/src/ppscsi-beta2_new/ppscsi.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/ppscsi.ko

  CC      /usr/src/ppscsi-beta2_new/sparcsi.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/sparcsi.ko

  CC      /usr/src/ppscsi-beta2_new/t348.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/t348.ko

  CC      /usr/src/ppscsi-beta2_new/t358.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/t358.ko

  CC      /usr/src/ppscsi-beta2_new/vpi0.mod.o

  LD [M]  /usr/src/ppscsi-beta2_new/vpi0.ko

make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-24-generic-pae'
```

but it triggers an error when inserting the epst-module:

```
modprobe epst

FATAL: Error inserting epst (/lib/modules/3.2.0-24-generic-pae/kernel/drivers/parport/epst.ko): No such device
```

----------

## Hypnos

Does the scanner show up in lsscsi output?  If it does, the driver is now broken; if not, parallel port SCSI support is now broken.

----------

## infabo

No, the scanner does not show up in the lsscsi output. Seems like a problem with the ppscsi driver, correct?

----------

## Hypnos

 *infabo wrote:*   

> No, the scanner does not show up in the lsscsi output. Seems like a problem with the ppscsi driver, correct?

 

It would seem so ... not sure how to fix it, probably need help from a kernel dev.

----------

## infabo

I'm so sorry!   :Embarassed:  The scanner was powered off! I have it plugged into a Gembird SIS-PM programmable power outlet strip, the power-socket for the scanner was offline...  :Embarassed: 

```
[94852.733892] ppSCSI 0.92 (0.92) installed

[94872.444033] epst.0: epst 0.92 (0.92), Shuttle EPST at 0x378 mode 2 (PS/2) dly 1 nice 0 sg 16

[94872.444041] scsi12 : epst

[94872.512283] scsi 12:0:0:0: Processor         HP       C5190A           3740 PQ: 0 ANSI: 2

[94873.186737] scsi 12:0:0:0: Attached scsi generic sg4 type 3

```

Good to see my old HP Scanjet 5100 working on kernel 3.2.0! Yeah!

----------

## zdenek archlinux

Hi

Im a novice on this forum. I doesnt use Gentoo at all, but i think that i have a important message.

Scanner HP Scanjet 5100C works fine on Linux 3.7.10. Now is 15.3.2013 - scanner is 9 year old.

Because many of old patches is today unavailable (like ppscsi-patched-karmic.tar.gz) here is complete driver for kernel 3.7.10.

http://www.zdenek-stepanek.eu/ppscsi-beta2-3.7.10.tar.gz

Please understand that I'm not a programmer. Driver above is only original driver (ppscsi-beta2-20060424.tar.gz) with all patchsets, which I found on this and other forums.

If you have any question, please dont use PM or this forum. You can write to me on email zdenek@gavanet.org, but once more, I'm not a programmer...

Please write me if this driver helped.

Goog luck  :Smile: 

----------

