summaryrefslogtreecommitdiffstats
path: root/perl-install/scanner.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2003-02-14 23:48:59 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2003-02-14 23:48:59 +0000
commita7759e59f17339920553a03e31230dbc20c68d1c (patch)
tree562505c94eda4a269457c659ec59f9862af7146f /perl-install/scanner.pm
parent2ec37355a7a644be263e1c35f4afc3d6256a5b96 (diff)
downloaddrakx-backup-do-not-use-a7759e59f17339920553a03e31230dbc20c68d1c.tar
drakx-backup-do-not-use-a7759e59f17339920553a03e31230dbc20c68d1c.tar.gz
drakx-backup-do-not-use-a7759e59f17339920553a03e31230dbc20c68d1c.tar.bz2
drakx-backup-do-not-use-a7759e59f17339920553a03e31230dbc20c68d1c.tar.xz
drakx-backup-do-not-use-a7759e59f17339920553a03e31230dbc20c68d1c.zip
Improved manual scanner configuration, bug fixes.
Diffstat (limited to 'perl-install/scanner.pm')
-rwxr-xr-xperl-install/scanner.pm44
1 files changed, 42 insertions, 2 deletions
diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm
index b0a6fef1e..30a033d93 100755
--- a/perl-install/scanner.pm
+++ b/perl-install/scanner.pm
@@ -204,6 +204,40 @@ sub detect {
return @res;
}
+sub get_usb_ids_for_port {
+ my ($port) = @_;
+ my $vendorid;
+ my $productid;
+ if ($port =~ /^\s*libusb:(\d+):(\d+)\s*$/) {
+ # Use "lsusb" to find the USB IDs
+ open DETECT, "LC_ALL=C lsusb -s $1:$2 |";
+ while (my $line = <DETECT>) {
+ if ($line =~ /ID\s+([0-9a-f]+):(0x[0-9a-f]+)($|\s+)/) {
+ # Scanner connected via scanner.o kernel module
+ $vendorid = "0x$1";
+ $productid = "0x$2";
+ last;
+ }
+ }
+ close DETECT;
+ } else {
+ # Run "sane-find-scanner" on the port
+ open DETECT, "LC_ALL=C sane-find-scanner -q $port |";
+ while (my $line = <DETECT>) {
+ if ($line =~ /^\s*found\s+USB\s+scanner/i) {
+ if ($line =~ /vendor=(0x[0-9a-f]+)[^0-9a-f]+.*prod(|uct)=(0x[0-9a-f]+)[^0-9a-f]+/) {
+ # Scanner connected via scanner.o kernel module
+ $vendorid = $1;
+ $productid = $3;
+ last;
+ }
+ }
+ }
+ close DETECT;
+ }
+ return ($vendorid, $productid);
+}
+
sub readScannerDB {
my ($file) = @_;
my ($card, %cards);
@@ -306,7 +340,13 @@ sub updateScannerDBfromSane {
}
}
- foreach my $f (glob_("$_sanesrcdir/*.desc")) {
+ my @descfiles;
+ push (@descfiles,
+ glob_("$_sanesrcdir/doc/descriptions/*.desc"));
+ push (@descfiles,
+ glob_("$_sanesrcdir/doc/descriptions-external/*.desc"));
+
+ foreach my $f (@descfiles) {
my $F = common::openFileMaybeCompressed($f);
$to_add .= "\n# from $f";
my ($lineno, $cmd, $val) = 0;
@@ -321,7 +361,7 @@ sub updateScannerDBfromSane {
if (0 && member($name, keys %$scanner::scannerDB)) {
print "#[$name] already in ScannerDB!\n";
} else {
- # SANE bug "snapscan" calls itself "SnapScan"
+ # SANE bug: "snapscan" calls itself "SnapScan"
$backend =~ s/SnapScan/snapscan/g;
$to_add .= "\nNAME $name\nSERVER $backend\nDRIVER $intf\n";
# Go through the configuration lines of