File: quickcam.tex

package info (click to toggle)
qcam 0.91-6
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 256 kB
  • ctags: 242
  • sloc: ansic: 2,967; makefile: 99; sh: 29
file content (74 lines) | stat: -rw-r--r-- 2,932 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%
\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}