📄 sn9c102.txt
字号:
[root@localhost #] cat i2c_valNote that "cat" will fail if sensor registers cannot be read.Now let's set the green gain's register of the SN9C101 or SN9C102 chips to 2: [root@localhost #] echo 0x11 > reg [root@localhost #] echo 2 > valNote that the SN9C10x always returns 0 when some of its registers are read.To avoid race conditions, all the I/O accesses to the above files areserialized.The sysfs interface also provides the "frame_header" entry, which exports theframe header of the most recent requested and captured video frame. The headeris 12-bytes long and is appended to every video frame by the SN9C10xcontrollers. As an example, this additional information can be used by the userapplication for implementing auto-exposure features via software. The following table describes the frame header:Byte # Value Description------ ----- -----------0x00 0xFF Frame synchronisation pattern.0x01 0xFF Frame synchronisation pattern.0x02 0x00 Frame synchronisation pattern.0x03 0xC4 Frame synchronisation pattern.0x04 0xC4 Frame synchronisation pattern.0x05 0x96 Frame synchronisation pattern.0x06 0x00 or 0x01 Unknown meaning. The exact value depends on the chip.0x07 0xXX Variable value, whose bits are ff00uzzc, where ff is a frame counter, u is unknown, zz is a size indicator (00 = VGA, 01 = SIF, 10 = QSIF) and c stands for "compression enabled" (1 = yes, 0 = no).0x08 0xXX Brightness sum inside Auto-Exposure area (low-byte).0x09 0xXX Brightness sum inside Auto-Exposure area (high-byte). For a pure white image, this number will be equal to 500 times the area of the specified AE area. For images that are not pure white, the value scales down according to relative whiteness.0x0A 0xXX Brightness sum outside Auto-Exposure area (low-byte).0x0B 0xXX Brightness sum outside Auto-Exposure area (high-byte). For a pure white image, this number will be equal to 125 times the area outside of the specified AE area. For images that are not pure white, the value scales down according to relative whiteness.The AE area (sx, sy, ex, ey) in the active window can be set by programming theregisters 0x1c, 0x1d, 0x1e and 0x1f of the SN9C10x controllers, where one unitcorresponds to 32 pixels.[1] The frame header has been documented by Bertrik Sikken.9. Supported devices====================None of the names of the companies as well as their products will be mentionedhere. They have never collaborated with the author, so no advertising.From the point of view of a driver, what unambiguously identify a device areits vendor and product USB identifiers. Below is a list of known identifiers ofdevices mounting the SN9C10x PC camera controllers:Vendor ID Product ID--------- ----------0x0c45 0x60010x0c45 0x60050x0c45 0x60090x0c45 0x600d0x0c45 0x60240x0c45 0x60250x0c45 0x60280x0c45 0x60290x0c45 0x602a0x0c45 0x602b0x0c45 0x602c0x0c45 0x60300x0c45 0x60800x0c45 0x60820x0c45 0x60830x0c45 0x60880x0c45 0x608a0x0c45 0x608b0x0c45 0x608c0x0c45 0x608e0x0c45 0x608f0x0c45 0x60a00x0c45 0x60a20x0c45 0x60a30x0c45 0x60a80x0c45 0x60aa0x0c45 0x60ab0x0c45 0x60ac0x0c45 0x60ae0x0c45 0x60af0x0c45 0x60b00x0c45 0x60b20x0c45 0x60b30x0c45 0x60b80x0c45 0x60ba0x0c45 0x60bb0x0c45 0x60bc0x0c45 0x60beThe list above does not imply that all those devices work with this driver: upuntil now only the ones that mount the following image sensors are supported;kernel messages will always tell you whether this is the case:Model Manufacturer----- ------------HV7131D Hynix Semiconductor, Inc.MI-0343 Micron Technology, Inc.PAS106B PixArt Imaging, Inc.PAS202BCB PixArt Imaging, Inc.TAS5110C1B Taiwan Advanced Sensor CorporationTAS5130D1B Taiwan Advanced Sensor CorporationAll the available control settings of each image sensor are supported throughthe V4L2 interface.Donations of new models for further testing and support would be muchappreciated. Non-available hardware will not be supported by the author of thisdriver.10. How to add plug-in's for new image sensors==============================================It should be easy to write plug-in's for new sensors by using the small APIthat has been created for this purpose, which is present in "sn9c102_sensor.h"(documentation is included there). As an example, have a look at the code in"sn9c102_pas106b.c", which uses the mentioned interface.At the moment, possible unsupported image sensors are: CIS-VF10 (VGA),OV7620 (VGA), OV7630 (VGA).11. Notes for V4L2 application developers=========================================This driver follows the V4L2 API specifications. In particular, it enforces tworules:- exactly one I/O method, either "mmap" or "read", is associated with eachfile descriptor. Once it is selected, the application must close and reopen thedevice to switch to the other I/O method;- although it is not mandatory, previously mapped buffer memory should alwaysbe unmapped before calling any "VIDIOC_S_CROP" or "VIDIOC_S_FMT" ioctl's.The same number of buffers as before will be allocated again to match the sizeof the new video frames, so you have to map the buffers again before any I/Oattempts on them.Consistently with the hardware limits, this driver also supports imagedownscaling with arbitrary scaling factors from 1, 2 and 4 in both directions.However, the V4L2 API specifications don't correctly define how the scalingfactor can be chosen arbitrarily by the "negotiation" of the "source" and"target" rectangles. To work around this flaw, we have added the conventionthat, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, thescaling factor is restored to 1.This driver supports two different video formats: the first one is the "8-bitSequential Bayer" format and can be used to obtain uncompressed video datafrom the device through the current I/O method, while the second one provides"raw" compressed video data (without frame headers not related to thecompressed data). The compression quality may vary from 0 to 1 and can beselected or queried thanks to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2ioctl's. For maximum flexibility, both the default active video format and thedefault compression quality depend on how the image sensor being used isinitialized (as described in the documentation of the API for the image sensorssupplied by this driver).12. Video frame formats [1]=======================The SN9C10x PC Camera Controllers can send images in two possible videoformats over the USB: either native "Sequential RGB Bayer" or Huffmancompressed. The latter is used to achieve high frame rates. The current videoformat may be selected or queried from the user application by calling theVIDIOC_S_FMT or VIDIOC_G_FMT ioctl's, as described in the V4L2 APIspecifications.The name "Sequential Bayer" indicates the organization of the red, green andblue pixels in one video frame. Each pixel is associated with a 8-bit longvalue and is disposed in memory according to the pattern shown below:B[0] G[1] B[2] G[3] ... B[m-2] G[m-1]G[m] R[m+1] G[m+2] R[m+2] ... G[2m-2] R[2m-1] ...... B[(n-1)(m-2)] G[(n-1)(m-1)]... G[n(m-2)] R[n(m-1)]The above matrix also represents the sequential or progressive read-out mode ofthe (n, m) Bayer color filter array used in many CCD/CMOS image sensors.One compressed video frame consists of a bitstream that encodes for every R, G,or B pixel the difference between the value of the pixel itself and somereference pixel value. Pixels are organised in the Bayer pattern and the Bayersub-pixels are tracked individually and alternatingly. For example, in thefirst line values for the B and G1 pixels are alternatingly encoded, while inthe second line values for the G2 and R pixels are alternatingly encoded.The pixel reference value is calculated as follows:- the 4 top left pixels are encoded in raw uncompressed 8-bit format;- the value in the top two rows is the value of the pixel left of the current pixel;- the value in the left column is the value of the pixel above the current pixel;- for all other pixels, the reference value is the average of the value of the pixel on the left and the value of the pixel above the current pixel;- there is one code in the bitstream that specifies the value of a pixel directly (in 4-bit resolution);- pixel values need to be clamped inside the range [0..255] for proper decoding.The algorithm purely describes the conversion from compressed Bayer code usedin the SN9C10x chips to uncompressed Bayer. Additional steps are required toconvert this to a color image (i.e. a color interpolation algorithm). The following Huffman codes have been found:0: +0 (relative to reference pixel value) 100: +4101: -4?1110xxxx: set absolute value to xxxx.0000 1101: +111111: -1111001: +20110000: -20110001: ??? - these codes are apparently not used[1] The Huffman compression algorithm has been reverse-engineered and documented by Bertrik Sikken.13. Contact information=======================The author may be contacted by e-mail at <luca.risolia@studio.unibo.it>.GPG/PGP encrypted e-mail's are accepted. The GPG key ID of the author is'FCE635A4'; the public 1024-bit key should be available at any keyserver;the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.14. Credits===========Many thanks to following persons for their contribute (listed in alphabeticalorder):- Luca Capello for the donation of a webcam;- Joao Rodrigo Fuzaro, Joao Limirio, Claudio Filho and Caio Begotti for the donation of a webcam;- Carlos Eduardo Medaglia Dyonisio, who added the support for the PAS202BCB image sensor;- Stefano Mozzi, who donated 45 EU;- Bertrik Sikken, who reverse-engineered and documented the Huffman compression algorithm used in the SN9C10x controllers and implemented the first decoder;- Mizuno Takafumi for the donation of a webcam;- An "anonymous" donator (who didn't want his name to be revealed) for the donation of a webcam.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -