<chapter>
  <Title>How to get USB devices working under Linux</>

<Sect1><Title>Basic USB Configuration</>

<Para>
You need a late version kernel. Kernel versions 2.2.7 and later
contain the USB code. You should, in an ideal world, be running the
current 2.4.0-test kernel, ideally with any pre-patches for the next
kernel. The current 2.2.x kernels do contain some USB code, but it
is less well supported, and development is patchy.
USB code is in fairly early
development, so the changes between each version (and the bugs) tend
to change fairly fast. Support on the mailing list for anything except
the lastest version is scant at best.
</>

<Para>
The user assistance mailing list is 
<Email>linux-usb-users@lists.sourceforge.net</Email>. To 
subscribe or unsubscribe, go to <ulink url="http://lists.sourceforge.net/mailman/listinfo/linux-usb-devel">http://lists.sourceforge.net/mailman/listinfo/linux-usb-devel</ulink>
</>

<Para>
You need to configure USB into your kernel. Use of <UserInput> make
menuconfig </UserInput> is recommended.  Under <UserInput> USB
support</UserInput>, you need to select <UserInput>Support for
USB</UserInput>. You also need to select either <UserInput>UHCI (Intel
PIIX4, VIA, ...) support</UserInput>, <UserInput>UHCI Alternate
Driver (JE) support</UserInput> or
<UserInput>OHCI-HCD (Compaq, iMacs, OPTi, SiS, ALi, ...) support</UserInput>.
 Which one you select is dependent on what
kind of motherboard or adapter you have. Intel and Via motherboards,
and Via-based adapters are UHCI, and you can use either of the two
UHCI drivers - there seems to be little user visible difference
between them. Ali and SiS chipsets, Compaq and NEC
motherboards, iMacs and any adapter using Opti chips (just about all
of them) are OHCI, and you should use OHCI-HCD. If you do not know
what kind of controller to choose, check your motherboard
documentation.  You can also look at <FileName>/proc/pci</FileName>
for a hint - if the USB entry is of the form 0xHHHH, where HHHH are
hex digits (e.g. something like <UserInput>I/O at 0xe400</UserInput>),
then it is UHCI. If it is of the form <UserInput>32 bit memory at
0xHH000000</UserInput>, where HH are hex digits (e.g. something like
<UserInput>32 bit memory at 0xee000000</UserInput>), then it is OHCI.
Failing that, just try both.
</>

<Para>
Always build in the Preliminary USB device filesystem. Leaving this out
will make resolving problems almost impossible, and is essential if
you need to check that your kernel is configured correctly, and
your USB devices are being recognised correctly.
</para>

<Para>
You also need to select whichever devices you want to use, for example
<UserInput>USB Human Interface Device (HID) support</UserInput> for a
 USB keyboard, mouse,
joystick, tablet or gamepad, <UserInput>USB Scanner support</UserInput> for
certain scanners, <UserInput>USB Audio support</UserInput> for USB
speakers, <UserInput>USB Modem (CDC ACM) support</UserInput> for
a POTS or ISDN modem, <UserInput>USB Printer support</UserInput>
for a USB printer, <UserInput>USB Serial Converter support</UserInput>
(with the appropriate subordinate options) for some serial port type devices,
<UserInput>USB CPiA Camera support</UserInput> for cameras based on the
Vision CPiA chipset, <UserInput>USB IBM (Xirlink) C-it Camera support
</UserInput> for camera based on the IBM camera chipset,
<UserInput>USB OV511 Camera support</UserInput> for cameras
based on OmniVision's OV511 chipset, <UserInput>USB Kodak DC-2xx Camera
support</UserInput> for downloading images from Kodak's DC-200 series
cameras, <UserInput>USB Mass Storage support</UserInput> for
mass storage devices,
<UserInput>USS720 parport driver</UserInput> for certain parallel port
adapters, <UserInput>DABUSB driver</UserInput> for an experimental
Digital Audio Broadcast receiver and <UserInput>PLUSB Prolific USB-Network
driver</UserInput> for certain USB to USB type connections.
You should be able to use modules, kernel only, or split modules and
kernel code.
</>

<Para>
USB hubs are automatically supported. Some devices may stop and start
working between kernel versions. Remember that you are using
experimental code. Devices not listed in this document are not working
at the time of writing, although developers are always welcome to
contribute to the current codebase. 
</>

<Para>
Rebuild the kernel and the modules (if you configured to build as modules),
and install the new kernel and the new modules. Reboot the system. If you need
instruction on how to do this, refer to the
<ulink url="http://www.linuxdoc.org/HOWTO/Kernel-HOWTO.html">Linux Kernel HOWTO</ulink>.
</>

<Para>
If you are using modules, you need to load the following modules:
<ItemizedList>
<ListItem>
<Para>
<filename>usbcore.o</filename>
</>
</ListItem>
<ListItem>
<Para>
<filename>usb-uhci.o</filename>, <filename>uhci.o</filename>
or <filename>usb-ohci.o</filename>
</>
</ListItem>
</ItemizedList>
and any driver modules, such as
<filename>scanner.o</filename> or <filename>printer.o</filename>.
</>

<Para>
Inspect the kernel logs.
If there isn't anything that could be USB related,
likely causes are use of the wrong driver (UHCI when you needed
OHCI or OHCI when you needed UHCI), not physically installing
the hardware, a BIOS configuration that disables USB or stuffing up
the configuration or installation of the kernel.
</>

</Sect1>

<Sect1><Title>USB Device Filesystem</title>
<para>
The USB device filesystem is a dynamically generated filesystem, similar to
the <FileName>/proc</FileName> filesystem. This filesystem can be mounted
just about anywhere, however it is customarily mounted on
<FileName>/proc/bus/usb</FileName>,
which is an entry node created by the USB code, intended to be used as a
mount point for this system. Mounting in other locations may break
user space utilities, but should not affect the kernel support.
</para>

<para>
You need to select "Preliminary USB Device Filesystem" to make this work.
You also need to enable general <FileName>/proc</Filename> support, and
to have it mounted (normally automatic).
</>

<para>
To mount the filesystem, you need to be root. Use the mount
command: <UserInput>mount -t usbdevfs none /proc/bus/usb</UserInput>.
Note that the <UserInput>none</UserInput> keyword is arbitrary - you
can use anything, and some people prefer to use <UserInput>usbdevfs
</UserInput>, as it makes the mount output look better.
</para>

<para>
If you do not want to have to mount the filesystem each time you reboot
the system, you can add the following to <FileName>/etc/fstab</FileName>
after the <FileName>/proc</FileName> entry:
<screen>
none            /proc/bus/usb             usbdevfs        defaults   0   0
</screen>
This has the same effect as the mount command.
</para>

<para>
After you have mounted the filesystem, the contents of
<FileName>/proc/bus/usb</FileName> should look something like:
<screen>
dr-xr-xr-x   1 root     root            0 Jan 26 10:40 001
-r--r--r--   1 root     root            0 Jan 26 10:40 devices
-r--r--r--   1 root     root            0 Jan 26 10:40 drivers
</screen>.
You may have more than one numbered directory entry if your machine
has more than one universal serial bus controller.
</para>

<para>
Full interpretation of the <FileName>devices</FileName> and
<FileName>drivers</FileName> files is provided later in this guide, in the
user's section. The numbered entries are machine readable, but are not
usually of any use to a user.
</para>
</Sect1>

<Sect1><Title>USB Human Interface Device (HID) Configuration</Title>

<Sect2><Title>General HID Configuration</Title>
<Para>
There are two options for using a USB mouse or a USB keyboard - the
standalone Boot Protocol (HIDBP) way and the full featured HID driver
way. The Boot Protocol way is generally inferior, and this document
describes the full featured way. The Boot Protocol way may be
appropriate for embedded systems and other systems with resource
constraints and no real need for the full keyboard and mouse
capabilities.
</Para>

<Para>
It is important to remember that the HID driver handles those devices
(or actually those interfaces on each device) that claim to comply
with the <ulink
url="http://www.usb.org/developers/hidpage/">Human Interface
Device (HID) specification</ulink>. However the HID specification
doesn't say anything about what the HID driver should do with
information received from a HID device, or where the information that
is sent to a device comes from, since this is obviously dependent on
what the device is supposed to be doing, and what the operating system
is. Linux (at the operating system kernel level) supports four
interfaces to a HID device - keyboard, mouse, joystick and a generic
interface, known as the event interface. These are implemented by the
Input device level.
</para>
</Sect2>

<Sect2><Title>HID Mouse Configuration</Title>
<Para>
In the kernel configuration stage, you need to turn on
<UserInput>USB Human Interface Device (HID) support</UserInput> in the
<UserInput>USB support</UserInput> and
<UserInput>Mouse Support</UserInput> in the <UserInput>Input core
support</UserInput>. You don't need to worry about the screen
resolution entries for a normal mouse - these are for mouse-like
devices such as a graphics tablet. Do <emphasis>not</emphasis> turn on
<UserInput>USB HIDBP Mouse support</UserInput>. Perform the normal
kernel rebuild and installation steps. If you are installing as
modules, you need to load the <FileName>input.o</FileName>,
<FileName>hid.o</FileName> and <FileName>mousedev.o</FileName> modules.
</para>

<Para>
Plug in a USB mouse and check that your mouse has been correctly sensed
by the kernel. If you don't have a kernel message, look for the
changes to <filename>/proc/bus/usb/devices</filename>.
</para>

<Para>
Since USB supports multiple identical devices, you can have multiple
mice plugged in. You can get each mouse seperately, or you can get
them all mixed together. You almost always want the mixed version, and
that is what will be used in this example.
You need to set up a device node entry for the mixed mice. It is
customary to create the entries for this device in the
<FileName>/dev/input/</FileName> directory. Use the following commands:
<screen>
mkdir /dev/input
mknod /dev/input/mice c 13 63
</screen>
</>

<Para>
If you <UserInput>cat /dev/input/mice</UserInput> you should see
some bizarre looking characters as you move the mouse or click any
of the buttons.
</para>

<Para>
If you want to use the mouse under X, you have various options. Which one
you select is dependent on what version of XFree86 you are using and
whether you are using only USB for your
mouse (or mice), or whether you want to use a USB mouse and some
other kind of pointer device.
</para>

<para>
<ItemizedList>
<ListItem>
<Para> You need to edit the <Filename>XF86Config</Filename> file
 (usually <Filename>/usr/X11R6/lib/X11/XF86Config</Filename> or
 <FileName>/etc/X11/XF86Config</FileName>).
</para>
</listitem>

<listitem>
<para>
If you are using XFree86 version 4.0 or later,
add a <SystemItem>InputDevice</SystemItem> section that looks
like the following:
<screen>
Section "InputDevice"
     Identifier  "USB Mice"
     Driver      "mouse"
     Option      "Protocol"   "IMPS/2"
     Option      "Device"     "/dev/input/mice"
EndSection
</screen>
or, if you want to use a wheel mouse, something like:
<screen>
Section "InputDevice"
     Identifier  "USB Mice"
     Driver      "mouse"
     Option      "Protocol"   "IMPS/2"
     Option      "Device"     "/dev/input/mice"
     Option      "ZAxisMapping"   "4 5"
     Option      "Buttons"        "5"
EndSection
</screen>
may be more useful. Consult the XFree86 documentation for a detailed
explaination and more examples.
</para>
<para>
You also need to add an entry to each applicable
<SystemItem>ServerLayout</SystemItem> Section. These are normally at the
end of the configuration file. If you only have a USB mouse (or USB mice),
then replace the line with the <SystemItem>"CorePointer"</Systemitem> entry
with the following line:
<screen>
     InputDevice "USB Mice" "CorePointer"
</screen>
If you want to use both a USB mouse (or USB mice) and some other kind of pointer
device, then add (do not replace) the following line to the applicable
<SystemItem>ServerLayout</SystemItem> sections:
<screen>
     InputDevice "USB Mice" "SendCoreEvents"
</screen>
</para>
</listitem>

<listitem>
<para>
If you are using only a USB mouse (or USB mice) with XFree86 3.3,
edit the <SystemItem>Pointer</SystemItem> section so that it
looks like the following:
<screen>
Section "Pointer"
    Protocol    "IMPS/2"
    Device      "/dev/input/mice"
EndSection
</screen>
</para>
</listitem>

<listitem>
<para>
If you are trying to use a USB mouse (or USB mice) in addition
to another pointer type device with XFree86 3.3,
then you need to use the <SystemItem>
XInput</SystemItem> extensions. Keep the existing <SystemItem>
Pointer</SystemItem> (or modify it as required for the other device if you
are doing an initial installation), and add the following entry (anywhere
 sensible, ideally in the <SystemItem>Input devices</SystemItem>
 area):
<screen>
Section "Xinput"
   SubSection "Mouse"
        DeviceName   "USB Mice"
        Protocol     "IMPS/2"
        Port         "/dev/input/mice"
        AlwaysCore
   EndSubSection
EndSection
</screen>
</>
</ListItem>

<ListItem>
<Para>
Restart the X server. If you don't have any mouse support at
this point, remember that Ctrl-Alt-F1 will get you a virtual terminal
that you can use to kill the xserver and start debugging from the error
messages.
</>
</ListItem>

</ItemizedList>
</>

<Para>
If you want to use the mouse under gpm, run (or kill and restart if it
is already running) gpm with the following options.
<UserInput>gpm -m /dev/input/mice -t imps2</UserInput>
(as superuser remember). You can make this the default if you edit the
initialisation files. These are typically named something like 
<FileName>rc.d</FileName> and are in <FileName>/etc/rc.d/</FileName> on
RedHat distributions.
</>

<Para>
If you have both a USB mouse (or USB mice) and some other kind of pointer
device, you may wish to use gpm in repeater mode. If you have a PS/2 mouse
on <filename>/dev/psaux</filename> and a USB mouse (or USB mice) on
<filename>/dev/input/mice</filename>, then the following gpm command
would probably be appropriate:
<UserInput>gpm -m /dev/input/mice -t imps2 -M -m /dev/psaux -t ps2 -R imps2</userinput>.
Note that this will make the output appear on <filename>/dev/gpmdata</filename>,
which is a FIFO and does not need to be created in advance. You can use this as
the mouse "device" to non-X programs, and both mice will work together.
</para>
</Sect2>

<Sect2><Title>Keyboard Configuration</>

<para>
You may not need any operating system support at all to use a USB keyboard
if you have a PC architecture.
There are several BIOS available where the BIOS can provide USB support
from a keyboard plugged into the root hub on the motherboard. This may or
may not work through other hubs and does not normally work with
add-in boards, so you might want to add in support anyway. You definately want
to add keyboard support if you add any operating system support, as the Linux
USB support will disable the BIOS support. You also need to use Linux USB
keyboard support if you want to use any of the "multimedia" types keys that
are provided with some USB keybords.
</>

<Para>
In the kernel configuration stage, you need to turn on
<UserInput>USB Human Interface Device (HID) support</UserInput> in
<UserInput>USB support</UserInput> and <UserInput>Keyboard
support</UserInput> in <UserInput>Input core support</UserInput>. Do
<emphasis>not</emphasis> turn on <UserInput>USB HIDBP Keyboard
support</UserInput>. Perform the normal kernel rebuild and
installation steps. If you are installing as modules, you need to load
the <FileName>hid.o</FileName>, <FileName>input.o</FileName> and
<FileName>keybdev.o</FileName> modules.
</para>


<Para>
Check the kernel logs to ensure that your keyboard is being correctly sensed
by the kernel.
</>


<Para>
At this point, you should be able to use your USB keyboard as
a normal keyboard. Be aware that LILO is not USB aware, and that
unless your BIOS supports a USB keyboard, you may not be able to
select a non-default boot image using the USB keyboard. I have
personally used only a USB keyboard (and USB mouse) and have
experienced no problems.
</>
</Sect2>

<Sect2><Title>USB Joystick and Gamepad support</>
<para>
In the kernel configuration stage, you need to turn on
<UserInput>USB Human Interface Device (HID) support</UserInput> in
<UserInput>USB support</UserInput> and
<UserInput>Joystick support</UserInput> in <UserInput>Input core
support</UserInput>. 
Perform the normal kernel rebuild and installation steps.
If you are installing as modules, you need to load
the <FileName>hid.o</FileName>, <FileName>input.o</FileName> and
<FileName>joydev.o</FileName> modules.
</para>


<Para>
You need to set up a device node entry for the joystick. It is
customary to create the entries for USB device in the
<FileName>/dev/input/</FileName> directory. You can use the following
commands to create four device nodes, although there is no reason why
you can not use more:
<screen>
mknod /dev/input/js0 c 13 0
mknod /dev/input/js1 c 13 1
mknod /dev/input/js2 c 13 2
mknod /dev/input/js3 c 13 3
</screen>
</>

<Para>
If you plug in a gamepad or joystick and
<UserInput>cat /dev/input/js0</UserInput> you should see
some bizarre looking characters as you move the stick or click any
of the buttons.
</para>

<para>
You should now be able to use the USB joystick or gamepad with any
of the normal games or other joystick compatible applications.
</>
</Sect2>
</Sect1>

<Sect1><Title>USB Scanner Support</>

<para>
USB scanners do not have a common class specification, hence it is
not possible to make a device driver that works for all scanners.
Not withstanding this, Linux USB does have a generic scanner driver
that provides the communication link between the device and user space.
</para>

<para>
In addition to the generic scanner interface, there is also a specific
driver for the Microtek X6 USB, and similar scanners such as the
Phantom 336CX, Phantom C6 and ScanMaker V6USL. Only the X6 is well
supported. 
</para>

<Sect2><Title>Generic Scanner Driver</Title>
<para>
The USB Scanner driver is capable of supporting just about any
scanner. However meaningful output depends on the availability of a
suitable user space tool, such as SANE, see
<ulink url="http://www.mostang.com/sane">http://www.mostang.com/sane</ulink>.
</>

<para>
If your scanner is not automatically associated with the scanner
driver, you have two options. The first option is to edit the source
code for the scanner driver - I assume that if you can do this, you
won't need any instructions. The second option is to use modules, and
to load the module with the vendor and product IDs specified as module
options:
<UserInput>insmod scanner.o vendor=0xXXXX product=0xYYYY</UserInput>,
where XXXX is the hexadecimal vendor ID code, and YYYY is the
hexadecimal product ID code, which you can extract from the
contents of <filename>/proc/bus/usb/devices</filename> when
you have the scanner plugged in.
</para>

<para>
You need to create an appropriate device file entry, using commands
(as root) like the following:
<screen>
mknod /dev/usb/scanner0 c 180 48
chmod a+rw /dev/usb/scanner0
</screen>
</>

<para>
To use the scanner device, you will need a suitable tool. SANE is
strongly recommended. If you don't already have it installed or your
installation is old, you will need to retrieve the package from the
closest of the sites referenced at <ulink
url="http://www.mostang.com/sane/source.html">
http://www.mostang.com/sane/source.html</ulink>.
</>

<para>
For instructions on building and installing SANE, refer to the various
README files within the SANE distribution, and more detailed instructions
for specific scanners that are provided later in this document.
</>
</Sect2>

<Sect2><title>Microtek X6USB Scanner Driver</title>
<para>
The Microtek scanner driver presents the scanner as a generic SCSI
device, which is probably <FileName>/dev/sg0</filename> unless you 
have some other device that uses the SCSI generic device interface. 
</para>

<para>
In addition to selecting the <UserInput>Microtek X6USB scanner
support</UserInput> entry in <UserInput>USB support</UserInput>, you
also need to select <UserInput>SCSI generic support</UserInput> under
<UserInput>SCSI support</UserInput>.
</para>

<para>
You need a very recent SANE release (1.0.3) or later to use this
driver. If you don't already have it installed or your
installation is old, you will need to retrieve the package from the
closest of the sites referenced at <ulink
url="http://www.mostang.com/sane/source.html">
http://www.mostang.com/sane/source.html</ulink>.
</>

<para>
For instructions on building and installing SANE, refer to the various
README files within the SANE distribution, and more detailed instructions
for specific scanners that are provided later in this document.
</para>

</Sect2>

</Sect1>

<Sect1><Title>USB Audio Support</>
<para>
USB audio systems such as speakers normally comply with
<ulink url="http://www.usb.org/developers/devclass_docs/audio10.pdf">
the USB audio class specification</ulink>. If your audio device does not
comply with the specification, it will not work with Linux at this time.
</>

<para>
You need to turn on the <UserInput>Sound card support</UserInput> kernel
option, which is in the <UserInput>Sound</UserInput> section. You will
then be able to turn on the <UserInput>USB Audio support</UserInput> option
in the normal USB section.
</>

<para>
If you elected to use modules, you need to load the module called
<FileName>audio.o</FileName>.
</para>

<para>
You can test your installation by dumping some random data out to the
audio interface, using a command like
<UserInput>cat /bin/bash > /dev/dsp</UserInput>. USB audio is integrated into
the normal Linux sound architecture, and most tools should work fine with USB
speakers. See the <ulink url="http://www.linuxdoc.org/HOWTO/Sound-Playing-HOWTO.html">
Sound HOWTO</ulink> for more details and suggestions.
</para>
</Sect1>

<Sect1><Title>USB Modem Support</>

<para>
USB modems (for plain old telephone service, ISDN or cable)
are supposed to conform to the
<ulink url="http://www.usb.org/developers/devclass_docs/usbcdc11.pdf">
Communication Device Class (CDC) specification</ulink>, and usually
to the Abstract Control Model (ACM) sub-class. If your modem doesn't
comply with the specification, it will not work with this driver.
</>

<para>
You need to select the
<UserInput>USB Modem (CDC ACM) support</UserInput> kernel option.
If you build as modules, you need to install the <FileName>acm.o</FileName>
option.
</>

<para>
You need to set up the device node entries for the various
modems.  You can use up to 32 modems with this driver.
Use the following commands to set up the first four:
<screen>
mknod /dev/usb/ttyACM0 c 166 0
mknod /dev/usb/ttyACM1 c 166 1
mknod /dev/usb/ttyACM2 c 166 2
mknod /dev/usb/ttyACM3 c 166 3
</screen>
</>

<para>
You should now be able to use a terminal emulator program to attach to
this device and connect to your modem or other terminal
device. Apparently this driver is working quite well, but I have not
personally tested it.
</>

</Sect1>

<Sect1><Title>Printer Support</>

<para>
You need to set up a device node entry for the printer. Use the
following command:
<screen>
mknod /dev/usb/lp0 c 180 0
</screen>
</>

<para>
Different printer tools are installed with various different rights,
and this may affect the access priviledges that you need with
the device entry. It is normally correct to make <FileName>/dev/usb/lp0</FileName>
rights the same as <FileName>/dev/lp0</FileName>, using the
<SystemItem>chmod</SystemItem>, <SystemItem>chown</systemitem> and
<systemitem>chgrp</systemitem> commands.
</para>

<para>
You should now be able to use this device in a normal
<FileName>/etc/printcap</FileName> entry. I recommend use of automated
tools to generate such files, such as RedHat's control panel
print-tool.I find this driver to be pretty good, although perhaps a
bit slow.
</>

<para>
If this does not appear to work, check that you have actually 
loaded the module, and double-check the <FileName>/etc/printcap</FileName>
entry - especially that the device file matches the one you just
created. Also note that some printers require special control
characters to be sent to the printer to get the USB interface to be
made operational. This is printer specific.
</>

</Sect1>

<Sect1><Title>USB Serial Converter support</>
<Para>
This serial driver supports a wide range of USB to serial adapters. It
also allows communication with the Handspring Visor. You need to turn on
<UserInput>USB Serial Converter support</UserInput>, and then select
whichever of the various particular drivers you need. The
<UserInput>Generic Serial Driver</UserInput> can be used with a wide
range of converters, by specifying the vendor and product ID codes when
you load the USB serial converter module:
<UserInput>insmod usb-serial.o vendor=0xVVVV product-0xPPPP</UserInput>,
where you need to change the <UserInput>VVVV</UserInput> and
<UserInput>PPPP</UserInput> to match your device.
</>

<para>
The serial port driver uses a major number of 188. Up to sixteen serial
ports are supported. To create the appropriate device entries, use the
following commands:
<screen>
mknod /dev/usb/ttyUSB0 c 188 0
mknod /dev/usb/ttyUSB1 c 188 1
mknod /dev/usb/ttyUSB2 c 188 2
mknod /dev/usb/ttyUSB3 c 188 3
mknod /dev/usb/ttyUSB4 c 188 4
mknod /dev/usb/ttyUSB5 c 188 5
mknod /dev/usb/ttyUSB6 c 188 6
mknod /dev/usb/ttyUSB7 c 188 7
mknod /dev/usb/ttyUSB8 c 188 8
mknod /dev/usb/ttyUSB9 c 188 9
mknod /dev/usb/ttyUSB10 c 188 10
mknod /dev/usb/ttyUSB11 c 188 11
mknod /dev/usb/ttyUSB12 c 188 12
mknod /dev/usb/ttyUSB13 c 188 13
mknod /dev/usb/ttyUSB14 c 188 14
mknod /dev/usb/ttyUSB15 c 188 15
</screen>
</>

<para>
You should now be able to plug in a serial device into the adapter,
and use the <FileName>/dev/usb/ttyUSB0</Filename> just as if it were a
normal serial port.
</>

<para>
To communicate with the Handspring Visor, you need an additional application
package known as <ulink url="ftp://ryeham.ee.ryerson.ca/pub/PalmOS/pilot-link.0.9.3.tar.gz">Pilot-Xfer</>. Installation and use of this
package is covered later in this guide.
</para>

</Sect1>


<Sect1><Title>USB Cameras</>


<Sect2><Title>Generic camera configuration</>

<para>
Under Linux, USB cameras use the Video4Linux interface.
You need to set up a device node entry for the USB camera.
Use the following command, if you have no other Video4Linux
devices:
<screen>
mknod /dev/video0 c 81 0
ln -s /dev/video0 /dev/video
</screen>
</>

<para>
To use the device, you need some video tools. There are a fairly wide range
of tools available. <ulink url="http://www.thedirks.org/v4l2/">
http://www.thedirks.org/v4l2</ulink> has a package that
is a generally named something like <FileName>apps20000611.tgz</FileName>,
depending on the date of release. It has both X and text-mode tools. Using
the text mode tools will allow you to do things like
<screen>
./vctrl 320x240x24
./vcat | rawtoppm -bgr 320 240 | xv -
</screen>
These tools default to using <FileName>/dev/video</FileName> if not
otherwise specified, hence the symbolic link made previously.
</>

<para>
There are other suitable tools available. Links to some of these tools
are provided in the Linux USB web site at <ulink
url="http://www.linux-usb.org">http://www.linux-usb.org</ulink>.
</para>

</Sect2>


<Sect2><Title>USB CPiA Camera support</>
<para>
This driver supports a certain chipset made by Vision, and used
in a range of USB cameras (notably the Creative WebCamII). 
To make the CPiA camera driver work, you need to select
<UserInput>Video For Linux</UserInput> (under 
<UserInput>Multimedia devices</UserInput>), and then select
<UserInput>CPiA Video For Linux</UserInput> and
<UserInput>CPiA USB Lowlevel Support</UserInput> options within
the <UserInput>Video For Linux</UserInput>.
</>

</Sect2>

<Sect2><Title>USB OV511 Camera support</>

<para>
This driver supports a certain chipset made by OmniVision, and used
in a range of USB cameras (notably the Creative WebCam III).
To make the OV511 driver work, you  need to select
<UserInput>Video For Linux</UserInput> support (under
<UserInput>Multimedia devices</UserInput> and <UserInput>USB OV511
Camera support</UserInput> under <UserInput>USB support</UserInput>.
</>

</Sect2>

<Sect2><Title>USB IBM (Xirlink) C-it Camera support</>

<para>
This driver supports the <ulink url="http://www.c-itnow.com/">Xirlink
C-it</ulink> cameras, also sold by IBM.
To make the OV511 driver work, you also need to select
<UserInput>Video For Linux</UserInput> support (under
<UserInput>Multimedia devices</UserInput> and <UserInput>USB IBM
(Xirlink) C-it Camera support</UserInput>
</>

</Sect2>
</Sect1>


<sect1> <title>USB and Digital Still Cameras</title>

    <para> While most digital still cameras support a serial line
    at up to 115 Kbps, the fastest ways to get pictures out of your
    camera onto Linux involve USB:

    <variablelist>
        <varlistentry><term> <emphasis>
             USB Connection for Camera</emphasis></term>
            <listitem><para>Some cameras can connect directly to USB,
            normally using a custom jack on the camera, which is smaller
            than the standard type B jacks you see on the upstream side
            of hubs and other devices. </para></listitem> </varlistentry>
        <varlistentry><term><emphasis>
            USB Connection for Memory</emphasis></term>
            <listitem><para>A number of cameras don't have a direct USB
            hookup, but may come with an adapter that lets you connect
            their memory cards instead.  Those cards are accessed using
            the mass storage driver, as if they were disk drives.  (USB
            mass storage support is discussed elsewhere in this document.)
            You can buy such adapters separately; be sure that Linux supports
            the adapter model you want to use.</para></listitem> </varlistentry>
        <varlistentry><term><emphasis>
            PCMCIA Connection for Memory</emphasis></term>
            <listitem><para>Inexpensive PCMCIA adapters ($10US) let you
            treat memory cards like IDE disks.  This won't be discussed
            any further here, but you should know the option exists.  The
            transfer rate is higher than for USB, but the downside is that
            PCMCIA support is generally only available on laptops.
            </para></listitem> </varlistentry>
        </variablelist>
        </para>

    <para> Only the first of these approaches is discussed in this
    section, where the camera has a direct connection to USB.  The
    table below summarizes the most important information: </para>

    <informaltable>
        <tgroup align="left" cols="4">
            <thead>
                <row>
                    <entry>Still Camera</entry>
                    <entry>Drivers</entry>
                    <entry>Applications</entry>
                    <entry>Notes</entry>
                </row>
            </thead>
            <tbody>
                <!--
                <row>
                    <entry>Canon PowerShot S20</entry>
                    <entry>scanner</entry>
                    <entry>what are the scanner apps?</entry>
                    <entry>(pending kernel bugfixes)</entry>
                </row>
                -->
                <row>
                    <entry>Kodak DC-240/280</entry>
                    <entry>dc2xx</entry>
                    <entry> gPhoto</entry>
                    <entry>The first still cameras supported under Linux.
                        USB lets you download pictures, take new ones,
                        change camera settings, and more.  </entry>
                </row>
                <row>
                    <entry>Kodak DC-220/260/265/290,
                        HP PhotoSmart C-500</entry>
                    <entry>dc2xx</entry>
                    <entry>ODS (no GUI)</entry>
                    <entry>DigitaOS runs these cameras, letting you
                        run scripts on the camera as well as the sort
                        of functionality available on the other
                        DC-2xx series USB cameras. </entry>
                </row>
                <row>
                    <entry>Mustek MDC-800</entry>
                    <entry>mdc800</entry>
                    <entry>gPhoto</entry>
                    <entry>Only one camera at a time supported. </entry>
                </row>
                <row>
                    <entry>Sony DSC-505,
                        Toshiba PDR-M4,
                        and many USB card readers
                        </entry>
                    <entry>storage, fat filesystem</entry>
                    <entry>ls, cp, mc, &amp;c.</entry>
                    <entry>readonly for now </entry>
                </row>
            </tbody>
        </tgroup>
    </informaltable>

    <para> Your kernel may already have the <emphasis>dc2xx</emphasis>,
    <emphasis>mdc800</emphasis> and <emphasis>storage</emphasis> compiled
    as modules, or as part of the kernel.  If it doesn't, rebuild so that
    you have them available. </para>

    <sect2> <title>Filesystem Device Nodes</title>

        <para> If you use the dc2xx or mdc800 driver, you have all the security         hooks you need.  The instructions shown below assume that PAM will be
        set up to change ownership of these nodes to the logged-in user using
        the <filename>/etc/console.perms</filename> file.  If that is not done,        think carefully about the ownership and permissions you use in the
        instructions below.  (Mode 0666 works for trusted systems, such
        as single users workstations with no rlogin.) </para>

        <para> The dc2xx driver supports up to sixteen devices, but most users
        won't need to use more than one or two cameras.  If these device nodes
        aren't part of your distribution, make at least the first few of them
        as follows:
        <screen>
        # mknod -m 0660 /dev/usb/dc2xx0 c 180 80
        # mknod -m 0660 /dev/usb/dc2xx1 c 180 81
        # mknod -m 0660 /dev/usb/dc2xx2 c 180 82
        # mknod -m 0660 /dev/usb/dc2xx3 c 180 83
        ...
        # mknod -m 0660 /dev/usb/dc2xx15 c 180 95
        </screen></para>

        <para> The mdc800 driver supports one device.  If its device node
        isn't part of your distribution, make it as follows:
        <screen>
        # mknod -m 0660 /dev/usb/mdc800 c 180 32
        </screen></para>

        <para> If your connectivity uses the storage driver, see
        the section on that driver for more information. </para>

        </sect2>

    <sect2> <title>Sanity Checking </title>

        <para> After you think your kernel is set up, connect your camera to
        your computer with USB (power it up!) and check to see if a kernel
        message (perhaps in <filename>/var/log/messages</filename>)
        reports the driver saw the
        camera.  If it didn't, you can do a bit of troubleshooting if you've
        got "procfs" and the prototype "usbdevfs" code set up. </para>

        <para> The first check is whether USB is basically set up.  You
        should see the driver listed in <filename>/proc/bus/usb/drivers</filename>;
        if it's not there, use "modprobe" to load it.  There should be a
        bus directory such as <filename>/proc/bus/usb/001</filename> also; if
        there isn't, you may need to
        "modprobe" the right host controller driver (OHCI or UHCI). </para>

        <para> Then make sure that the kernel saw the camera.  With it still
        connected and powered up, check for an entry in
        <filename>/proc/bus/usb/devices</filename>
        corresponding to your camera.  (The product ID string may name it.)
        If there is no camera there, check your USB connections.  If you
        find the camera listed there, make sure it's one of the supported
        cameras.  There should be an "I: ..." line showing that driver.  For
        example, at the end of the line it would have "Driver=dc2xx",
        "Driver=mdc800", or "Driver=storage".  If you don't see that, then
        the troubleshooting gets interesting.  </para>

        </sect2>

    <sect2> <title>gPhoto </title>

        <para> gPhoto is a graphical application that knows how to talk to many         different digital cameras.  At this writing its current version (0.4.3)         knows how to use USB to talk to three cameras:
        appropriate camera model and use an "other" (non-TTY) device path
        name as shown above.  (Use dc2xx0 unless you have multiple cameras.)
        Check the "Camera Summary" to see if it's connected properly. </para>

        <para> At that point, you should be able to download thumbnails of
        all the pictures in the camera, then download the pictures you've
        chosen.  (At this writing, it's visibly faster to use OHCI than
        to use UHCI.) </para>

        <para> More information about gPhoto is available at its web site,
        <ulink url="http://www.gPhoto.org/">www.gPhoto.org</ulink>. </para>

        </sect2>

    <sect2> <title> DigitaOS Cameras and ODS </title>

        <para> At this writing, gPhoto does not know how to communicate
        with cameras using the "DigitaOS" environment.  However, there is
        a separate "Open Digita Services" project which can be used to
        do that.  See that project's web site, at
        <ulink url="http://ods.sourceforge.net/">ods.sourceforge.net</ulink>.
        </para>

        <para> (There are also various Perl and Python scripts available
        to provide some of this functionality, if you prefer to develop
        in those languages rather than in C.) </para>

        </sect2>

    <sect2> <title>Other Approaches (Developers only)</title>

        <para>The solutions described above are, at this writing, the
        most widely used ones.  You may be interested to know about
        some other solutions that might work. </para>

        <para> You can configure the <emphasis>usbserial</emphasis>
        module with "generic serial" driver support.  This lets you
        provide kernel module parameters that let the serial driver
        handle specific bulk-only devices (using USB product and
        vendor IDs).  The Kodak or ODS cameras mentioned above are
        bulk-only, so this might permit <filename>/dev/usb/ttyN</filename>
        style paths to work instead of <filename>/dev/usb/dc2xxN</filename>
        style ones.</para>

        <para> Systems which enable the "prototype usbdevfs" support
        can configure it to allow appropriately intelligent user
        mode programs to access USB devices.  This requires libraries
        that know how to interact with <filename>/proc/bus/usb/NNN/MMM</filename>
        files for each USB device, ways to address security issues that
        arise (programs need read/write access), and ways to have
        user and kernel mode software interact safely.  Such work
        is under way.  See for example the Java USB project  at
        <ulink url="http://jusb.sourceforge.net/">jusb.sourceforge.net</ulink>
        and the C "libusb" at <ulink
        url="http://libusb.sourceforge.net/">libusb.sourceforge.net</ulink>
        </para>

        </sect2>

    </sect1>

<Sect1><Title>Mass Storage Devices</>
<Para>
The mass storage device driver can potentially be used with a wide a
wide range of USB devices, not all of which would normally be
considered to be mass storage. This is because the driver is really an
interface between the USB stack and the SCSI layer. Despite this, the
instructions in this section are oriented around devices like USB
floppy drives, Zip drives, LS120 drives and USB CDROMs.
</>

<Para>
Since the mass storage driver presents the USB device as a SCSI
device, you need to turn on <UserInput>SCSI support</UserInput>, which
is under <UserInput>SCSI support</UserInput> in the configuration
script. You should also turn on subordinate options as appropriate to
your mass storage device - usually one or more of <UserInput>SCSI disk
support</userinput>, <Userinput>SCSI tape support</userinput>,
<userinput>SCSI CD-ROM support</userinput> and <userinput>SCSI generic
support</userinput>.
</>

<Para>
After you have compiled the kernel and rebooted (or added the relevant
modules, which is <FileName>usb-storage.o</FileName>),
you should check <FileName>/proc/scsi/scsi</FileName>. Information
about your device should be listed. 
</>

<para>
You can now mount your device. The exact syntax depends on the device
type. The best way is to make suitable entries in
<FileName>/etc/fstab</FileName>. A suitable entry for a floppy disk
would be: 
<screen>
/dev/sda    /mnt/usbfd       auto            noauto,user 0   0
</screen>
</>

<Para>
A suitable entry for a Zip disk would be:
<screen>
/dev/sda4    /mnt/usbzip      vfat            noauto,user 0   0
</screen>
</>

<Para>
A suitable entry for a CDROM disk would be:
<screen>
/dev/scd0    /mnt/usbcdrom    iso9660         ro,noauto,user 0   0
</screen>
</>

<Para>
A suitable entry for a hard disk with a single partition would be:
<screen>
/dev/sda1    /mnt/usbhd       ext2            defaults   1   2
</screen>
</>

<Para>
Note that the above entries assume you have no other SCSI devices. If
you do have other devices, then the USB disk may not be
<FileName>/dev/sda</FileName>, but could instead be
<FileName>/dev/sdb</FileName>, <FileName>/dev/sdc</FileName> or some
other device. You would then need to substitute the right device entry
for <FileName>/dev/sda</FileName> or <filename>/dev/scd0</filename>
in the entries above.
</>

<Para>
Having created the entr[y/ies] in <FileName>/etc/fstab</FileName>, you
need to create matching mount point[s] in the actual filesystem. So if
you made an entry as shown above for the USB floppy disk, then the
mount point would be made (as root) by:
<screen>
mkdir /mnt/usbfd
</screen>
</>

<Para>
You should now be able to mount your floppy disk with a command like:
<screen>
mount /mnt/usbfd
</screen>
or like:
<screen>
mount /dev/sda
</screen>
</>

</Sect1>

<Sect1><Title>USS720 driver</>
<Para>
The USS720 is a USB to Parallel port chip made by Lucent that normally
acts like a USB Printer Class device. Indeed you can use a USS720
based bridge and a parallel port printer with the USB Printer driver,
(see above). However there is also a mode (known as register mode) which
makes the USS720 look like normal parallel port hardware. This driver
makes use of that mode.
</>

<Para>
If you have the opportunity, look at
<UserInput>/proc/sys/dev/parport</UserInput> before you load the
module or reboot with a kernel with USS720 enabled. You should note
the number of parallel ports you have - typically one, under
<UserInput>/proc/sys/dev/parport/parport0</UserInput>. After you put
USS720 support into your kernel, you should have another port (perhaps
<UserInput>/proc/sys/dev/parport1</UserInput>). If you look at the
appropriate <UserInput>hardware</UserInput> entry, you should see
something like the following:
<screen>
[bradh@rachel bradh]$ more /proc/sys/dev/parport/parport1/hardware
base:   0x0
irq:    none
dma:    none
modes:  PCSPP,TRISTATE,COMPAT,EPP,ECP
</screen>
</>

<Para>
Every distribution should have device node entries
for parallel ports - typically <UserInput>/dev/lpX</UserInput> or
<UserInput>/dev/parX</UserInput>, where the <UserInput>X</UserInput>
is some number. If you need to create them, parallel ports device nodes
use character major number 6.
</>

<Para>
You should now be able to use the USS720 for anything that you would
normally need a parallel port for, except that certain timing sensitive
applications may not work, since the emulation is rather slow.
As for a real USB printer, I suggest use of automated tools to generate a
<UserInput>/etc/printcap</UserInput> entry if you are connecting up a
printer.
</>

<Para>
If you didn't get to select USS720 support at the configuration stage,
you need to turn on <UserInput>Parallel port support</UserInput>
support (under <UserInput>General setup</UserInput> if using
<UserInput>menuconfig</UserInput>).
</>

</Sect1>

<Sect1><Title>DABUSB driver</>
<para>
This device requires hardware that has not yet been released,
and is currently provided mainly to show how to write a driver.
For more information, see
<ulink url="http://dab.in.tum.de">http://dab.in.tum.de</ulink>.
</>
</Sect1>

<Sect1><title>PLUSB Prolific USB-Network driver</>
<para>
Prolific manufacture a range of USB chips, including the
<ulink url="http://www.prolific.com.tw/pl2301.htm">PL2301</ulink> and
<ulink url="http://www.prolific.com.tw/pl2302.htm">PL2302</ulink> devices
that allow two USB host controllers to be linked, providing a simple
point to point link at up to 5Mbps. This driver supports both PL2301 andPL2302
chips.
</>

<para>
Aserton, Bencent, Butterfly, Camtel, Longshine, Prolific, Share Plus,
SIIG, StarMount, Swann, Univex, USBdevices and VVMer cables are all
known to use the PL2301 or PL2302 chips. 
Entrega, Xircom and Belkin adapters do not use Prolific chips and are not
supported by this driver.
</para>

<para>
In addition to selecting this option to either be compiled into the kernel
or to be build as a module, you need to configure the appropriate networking
interfaces. If you have two machines (say <SystemItem>zhora</systemitem> and
<systemitem>rachel</systemitem>, then on <SystemItem>zhora</systemitem> you
would enter <UserInput>ifconfig plusb0 192.168.0.1 pointopoint 192.168.0.2
</UserInput>. On  <systemitem>rachel</systemitem> you would enter
<UserInput>ifconfig plusb0 192.168.0.2 pointopoint 192.168.0.1
</UserInput>. To test that it is working, on <SystemItem>zhora</systemitem>,
enter <UserInput>ping 192.168.0.2</userinput>. If you get packets back, it
is working correctly.
</para>

<para>
For further information on networking, I suggest that you refer to the
many excellent Linux networking documents, including the
<ulink url="http://www.linuxdoc.org/LDP/nag/nag.html">Linux Network Administrators'
Guide</ulink> and the  <ulink url="http://www.linuxdoc.org/HOWTO/Net-HOWTO/index.html">
Linux Network HOWTO</ulink>.
</para>
</Sect1>

<Sect1><title>NetChip 1080-based USB Host-to-Host Link</>
<para>
Netchip manufactures a range of USB devices, including the 1080, which
provides direct connection between two USB hosts.
</>

<para>
In addition to selecting this option to either be compiled into the kernel
or to be build as a module, you need to configure the appropriate networking
interfaces. If you have two machines (say <SystemItem>zhora</systemitem> and
<systemitem>rachel</systemitem>, then on <SystemItem>zhora</systemitem> you
would enter <UserInput>ifconfig usb0 192.168.0.1 pointopoint 192.168.0.2
</UserInput>. On  <systemitem>rachel</systemitem> you would enter
<UserInput>ifconfig usb0 192.168.0.2 pointopoint 192.168.0.1
</UserInput>. To test that it is working, on <SystemItem>zhora</systemitem>,
enter <UserInput>ping 192.168.0.2</userinput>. If you get packets back, it
is working correctly.
</para>

<para>
For further information on networking, I suggest that you refer to the
many excellent Linux networking documents, including the
<ulink url="http://www.linuxdoc.org/LDP/nag/nag.html">Linux Network Administrators'
Guide</ulink> and the  <ulink url="http://www.linuxdoc.org/HOWTO/Net-HOWTO/index.html">
Linux Network HOWTO</ulink>.
</para>
</Sect1>

<Sect1><title>USB ADMtek Pegasus-based device support</>
<para>
This driver suppport a range of ethernet adapters based on a chipset
produce by ADMtek. Just about all adapters that provide 10/100BaseT are
based on this chipset.
</>

<para>
In addition to selecting this option to either be compiled into the kernel
or to be build as a module, you need to configure the appropriate networking
interfaces. The device will appear as another ethernet device, and can be checked
using entries like <UserInput>cat /proc/net/dev</UserInput> or tools like
<command>ifconfig</command>.
</para>

<para>
For further information on networking, I suggest that you refer to the
many excellent Linux networking documents, including the
<ulink url="http://www.linuxdoc.org/LDP/nag/nag.html">Linux Network Administrators'
Guide</ulink> and the  <ulink url="http://www.linuxdoc.org/HOWTO/Net-HOWTO/index.html">
Linux Network HOWTO</ulink>.
</para>
</Sect1>

<Sect1><Title>USB Diamond Rio500 support </Title>
<para>
To be done. See   <ulink url="http://rio500.sourceforge.net">
http://rio500.sourceforge.net</ulink>
</para>
</Sect1>

<Sect1><Title>D-Link USB FM radio support</Title>
<para>
The D-Link USB FM radio driver uses the Video4Linux interface, similar
to the webcams discussed above.
</para>

<para>
If the appropriate device node entries do not exist, you should create them:
<screen>
mknod /dev/video0 c 81 0
mknod /dev/video1 c 81 1
mknod /dev/video2 c 81 2
mknod /dev/video3 c 81 3
ln -s /dev/video0 /dev/video
</screen>
</para>

<para>
After plugging the radio in, all you should you need to do is to start up
an appropriate application - I normally use kradio and KTuner from KDE, although
any Video4Linux radio application should work successfully.
</para>
</Sect1>


</Chapter>




