Main webcam page
Last update November 30th, 2004. Bertrik Sikken (bertrik@sikken.nl)

Intro

In this document an analysis is made of the internal registers of the PAS106B CIF color image sensor. This sensor is built into my Sweex 100k webcam, along with a Sonix SN9C101 camera controller. The analysis is aimed at improving support for this webcam under the Linux operating system.

Method

The chips internal registers are analysed using the following methods

Determining writeability

The writeability of registers is determined by writing 0x00 to all registers, then reading the result back and seeing which bits stayed at 0 and which bits were changed into 1. This is repeated, but now with value 0xFF written to all registers.
This provides insight into which bits in a register are actually relevant.

Analysing USB logs

An USB log was captured using an USB capture program.

Some interesting observations that can be made:

Experimentation

The sonixcam driver was slightly modified to allow me to write various values to the registers and then visually inspect the effect on the image as shown by the webcam viewing program (I used xawtv).
It is also interesting to point the webcam at a CRT (computer screen). The flicker pattern seen by the webcam can help identify registers that influence the frame/shutter timing.

Analysis

The table below combines the knowledge from the analysis methods above. (1st column is register number, 2nd is the default value, 3rd is the value read back after writing 0x00, 4th is the value read back after writing 0xFF).

Reg.Def.00FFRemark
00000000Identification register for the PAS106B
01707070
0206027F Pixel clock divider. The pixel clock is equal to the sensor clock from the camera controller divided by this value.
031312FF Frame time, in units of lines. Reg 0x03 [7..0] provides most significant bits. Reg 0x04 [3..0] provides least significant bits. Value must be at least 304 (approx.) in order to avoid incomplete frames.
0406000F
056500FF Shutter time line offset. Determines at which line number the shutter is opened (stays open until end of frame). Each step in this value is equal to 2 lines.
06b100FF Shutter time pixel offset. Determines at which pixel number the shutter is opened (after the appropriate line number has been reached). One step of this value is equal to 2 pixels. This value must always be less than 222 (444 pixels), otherwise the image becomes black.
07c100C1 Black level subtract (the DAC value in the datasheet), sign bit in bit [0] (0 means add, 1 means subtract). The highest two bits of register 0x07 seem to be writeable too, not sure what they contain.
080600FF Black level subtract (the DAC value in the datasheet), magnitude in bits [4..0]. This is equivalent to brightness.
0901001FColor gain B pixel (X4 in datasheet), between 0 and 0x1F
0A01001FColor gain G1 pixel (X4 in datasheet), between 0 and 0x1F
0B01001FColor gain G2 pixel (X4 in datasheet), between 0 and 0x1F
0C01001FColor gain R pixel (X4 in datasheet), between 0 and 0x1F
0D00001FHas no effect. Must be enabled by a bit in another register?
0E04001FGlobal gain (X5 in datasheet), between 0 and 0x1F
0F000007??? If bit 3 = 1, then bit 0 - 2 determine some kind of brightness
1006001F ??? if bit 0 = 0, image is shifted. bit 1: select bayer pattern?,
1106003F ??? bit 3 = half brightness, bit 4 = 1 causes white image, bit 5 = 1 causes black image
1200001F??? never used??? has little effect
13--0001Validate settings. Other settings do not seem to be taken over unless this register is written with 0x01
140200FF???

Frame/shutter timing

First of all, there is a pixel clock that is calculated from the sensor clock by the clock divider in register 0x02:
Tpixel = [reg 0x02] / Fsensor
The pixel clock is used by register 0x06 for example.

All other timing is done in units of lines. The time for one line is equivalent to approximately 444 clock pixel times:
Tline = 444 * Tpixel

Register 0x03/0x04 determines the frame time:
Tframe = [reg 0x03/0x04] * Tline

Register 0x05/0x06 determines when exposure starts within a frame. Therefore the actual length of the exposure cannot be set directly, but it can simply be calculated from:
Texposure = Tframe - Texposure start

Links

Tools Docs