[sane-devel] Sane and HAL

abel deuring adeuring at gmx.net
Mon Jan 1 23:16:53 CET 2007


Hi all,

a happy new year to you all!

I tried to become a bit more familiar with HAL
(http://freedesktop.org/wiki/Software_2fhal) and I think that this
is a project that Sane should support. And no, it will not create
any compatibility problems, as feared by some colleagues during the
short discussion in December last year.

As I understand it, HAL is mainly a daemon that manages a
list/database of hardware resources, monitors hotplugging, and
provides mechanisms for device configuration and other things like
automatic launch of an application, if a certain device is
detected/plugged in.

The minimum we can (and IMO should) do is to provide an XML file (or
".fdi file" in HAL terminology) that describes the scanners
supported by Sane, and optionally the unsupported scanners. The fdi
file contains information like scanner vendor/model name, interface
type (USB/SCSI/parport...), Sane backend(s) for the device, and
"unique device information", like USB vendor/product ID or the SCSI
vendor/product strings.

This file can be easily generated from our *.desc files. Right now,
the latter contain already all required information for USB
scanners; for the SCSI interface, we would need to add the keyword
:scsiid; an entry for this keyword should look like

:scsiid "SHARP" "JX250 SCSI"

A similar keyword would be needed for the Firewire interface, but I
have no idea, how Firewire devices can be identified; if some
parport scanners supported by a Sane backend can also tell something
about themselves in some standardized way, this should be included
too in the *.desc files.

I wrote a little Python script that transforms the data from the
*.desc files into an .fdi file; if this file if placed at
/usr/share/hal/fdi/... , the program lshal for example lists a
number of details about the available scanners (e.g., vendor/model
name and useable backend(s)); similary, "interested" applications
can use this data to find a scanner and a suitable Sane backend and
launch for example xsane or access the scanner directly. (If anybody
is interested, how practical work with HAL looks like, the source
code of lshal is a good start. It is not too long and easy to read.)

This leads to a second option: HAL provides so-called UDIs (means
"uniform device identifiers", I believe), strings of the form
"/org/freedesktop/Hal/devices/usb_device_4c5_10e0_100_noserial_if0".
If such a udi represents a scanner, it can be used to look up a
backend that supports the device and to find the SG device file or
the USB bus and device numbers that can be used to build the Sane
specific strings to identify and open a device like "sharp:/dev/sg2"
or "plustek:libusb:002:004".

We can leave the work to build the latter, Sane-specific,
identifiers to applications that are HAL-aware, or we can add
support for device identifiers like "udi:sharp:/org/freedesktop/..."
to sane-backends.

A possible place would be the function sane_open in dll.c, which
already replaces device identifiers defined in dll.aliases by
"regular" IDs, so we would add just another "substitution mechanism".

Another option would be another meta-backend named "udi", but I
believe that this would be overkill.

Open questions:

- do all backends for USB scanners use libusb, or do some backends
use other ways to access the device; if yes, what kind of "device
identifiers" are used?
- Handling of parport scanners. This can be a bit more complicated,
if they cannot be automatically detected. On the other hand, the HAL
people already discussed the question of devices that need some user
help for identification and configuration:
http://lists.freedesktop.org/archives/hal/2006-September/006086.html
I can't claim that I understand all ideas, but a possible advantage
I see is to get rid of the "permission problem" for these scanners.
If I understand and remember some discussions on this list
correctly, users quite often need to access a parport scanner with
root rights. HAL might be a way to integrate the permission handling
for parport scanners into the general "permission management" of a
Linux distribution.

Abel


PS: Seems that we all forgot to celebrate "10 years Sane" last year:
According to ChangeLog-1.0.0, version 0.1 was released on 1 Dec 1996.



More information about the sane-devel mailing list