%
\documentclass[12pt]{article}
\begin{document}
\begin{center}
Programming the Connectix QuickCam
\vskip5mm
Scott Laird ({\tt scott@laird.com}).
\end{center}
\vskip10mm
{\it Note:  This document is still under construction, and is included
to help others trying to program the QuickCam.  This is document may
be completely inaccurate, and may not apply to your QuickCam.  Use
this information at your own risk.}\vskip5mm

The QuickCam isn't all that hard to program, lack of documentation
notwithstanding.  The protocol seems fairly straightforward, except
for a few oddities when changing bit depth.

Communication with the camera is done via the parallel port.  There
are three registers used to control the parallel port, the data
register, the status register, and the control register.  Typically,
the first parallel port's data register is at {\tt0x378}, the status
register is at {\tt0x379}, and the control register is at {\tt0x37A}.
The second port is typically located starting at {\tt0x278}, and there
may also be a port at {\tt0x3B8}.

The first thing to do is reset the camera.  This is best accomplished
by sending a 0x20 to the control port, followed by a 0x75 to the data
port, followed by a 0x0B to the control port, followed by a 0x0E to
the control port.

Next, communicate with the camera by sending commands.  The basic
sequence for sending command bytes is:  send the command to the data
port.  Wait for a bit, send it again.  Wait some more, and send it a
third time.  Write a 0x06 to the control port, wait for the $2^3$ bit
on the status port to go high, then write a 0x0E to the control port
and wait for the $2^3$ bit to go low.  The known commands are listed
in this table.

\vskip5mm

\begin{center}
\begin{tabular}{rrll}
Number & Bytes & Name & Notes \\ \hline
{\tt 0x07} & 2 & Scan & \\
{\tt 0x0B }& 2 & Brightness & \\
{\tt 0x11 }& 2 & Height & \\
{\tt 0x13 }& 2 & Width & Varies depending on BPP value \\
{\tt 0x19 }& 2 & Contrast & \\
{\tt 0x1F }& 2 & White Balance & \\
{\tt 0x75 }& 1 & Reset
\end{tabular}
\end{center}

To set the brightness to 0x82, you'd send a 0x0B command byte followed
by a 0x82 command byte.

A few of these commands need some more explanation.  The scan command
takes one argument, which sets the resolution and bit depth.  For a
320x240 scan, the argument is 0, for 160x120 the argument is 4, and
for 80x60 the argument is 8.  For 6 bit-per-pixel scaning, add 2 to
these values.  Once the scan command is received, the QuickCam starts
feeding data back to the computer.

The width command is a bit odd -- the width passed to the camera is
the ``true'' width divided by 2 in 4bpp mode, or the ``true'' width
divided by 4 in 6bpp mode.  For a 80x60 scan, then the width would be
set to 40 in 4bpp mode or 20 in 6bpp mode.

The data returned in a scan is returned in the high nibble of the
status register.  See my code for an example on how to handshake.

\end{document}

