📄 sn9c102.txt
字号:
0x0A [7:0] Y sum outside Auto-Exposure area (low-byte)0x0B [7:0] Y sum outside Auto-Exposure area (high-byte) where Y sum = (R/4 + 5G/16 + B/8) / 1280x0C 0xXX Not used0x0D 0xXX Not used0x0E 0xXX Not used0x0F 0xXX Not used0x10 0xXX Not used0x11 0xXX Not usedThe following table describes the frame header exported by the SN9C103:Byte # Value or bits Description------ ------------- -----------0x00 0xFF Frame synchronisation pattern0x01 0xFF Frame synchronisation pattern0x02 0x00 Frame synchronisation pattern0x03 0xC4 Frame synchronisation pattern0x04 0xC4 Frame synchronisation pattern0x05 0x96 Frame synchronisation pattern0x06 [6:0] Read channel gain control = (1/2+R_GAIN/64)0x07 [6:0] Blue channel gain control = (1/2+B_GAIN/64) [7:4]0x08 [ 0 ] Compression mode. 0=No compression, 1=Compression enabled [2:1] Maximum scale factor for compression [ 3 ] 1 = USB fifo(2K bytes) is full [ 4 ] 1 = Digital gain is finish [ 5 ] 1 = Exposure is finish [7:6] Frame index0x09 [7:0] Y sum inside Auto-Exposure area (low-byte)0x0A [7:0] Y sum inside Auto-Exposure area (high-byte) where Y sum = (R/4 + 5G/16 + B/8) / 320x0B [7:0] Y sum outside Auto-Exposure area (low-byte)0x0C [7:0] Y sum outside Auto-Exposure area (high-byte) where Y sum = (R/4 + 5G/16 + B/8) / 1280x0D [1:0] Audio frame number [ 2 ] 1 = Audio is recording0x0E [7:0] Audio summation (low-byte)0x0F [7:0] Audio summation (high-byte)0x10 [7:0] Audio sample count0x11 [7:0] Audio peak data in audio frameThe AE area (sx, sy, ex, ey) in the active window can be set by programming theregisters 0x1c, 0x1d, 0x1e and 0x1f of the SN9C1xx controllers, where one unitcorresponds to 32 pixels.[1] The frame headers exported by the SN9C105 and SN9C120 are not described.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 assembling the SN9C1xx PC camera controllers:Vendor ID Product ID--------- ----------0x0458 0x70250x045e 0x00f50x045e 0x00f70x0471 0x03270x0471 0x03280x0c45 0x60010x0c45 0x60050x0c45 0x60070x0c45 0x60090x0c45 0x600d0x0c45 0x60110x0c45 0x60190x0c45 0x60240x0c45 0x60250x0c45 0x60280x0c45 0x60290x0c45 0x602a0x0c45 0x602b0x0c45 0x602c0x0c45 0x602d0x0c45 0x602e0x0c45 0x60300x0c45 0x603f0x0c45 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 0x60be0x0c45 0x60c00x0c45 0x60c20x0c45 0x60c80x0c45 0x60cc0x0c45 0x60ea0x0c45 0x60ec0x0c45 0x60ef0x0c45 0x60fa0x0c45 0x60fb0x0c45 0x60fc0x0c45 0x60fe0x0c45 0x61020x0c45 0x61080x0c45 0x610f0x0c45 0x61300x0c45 0x61380x0c45 0x613a0x0c45 0x613b0x0c45 0x613c0x0c45 0x613eThe list above does not imply that all those devices work with this driver: upuntil now only the ones that assemble the following pairs of SN9C1xx bridgesand image sensors are supported; kernel messages will always tell you whetherthis is the case (see "Module loading" paragraph):Image sensor / SN9C1xx bridge | SN9C10[12] SN9C103 SN9C105 SN9C120-------------------------------------------------------------------------------HV7131D Hynix Semiconductor | Yes No No NoHV7131R Hynix Semiconductor | No Yes Yes YesMI-0343 Micron Technology | Yes No No NoMI-0360 Micron Technology | No Yes Yes YesOV7630 OmniVision Technologies | Yes Yes Yes YesOV7660 OmniVision Technologies | No No Yes YesPAS106B PixArt Imaging | Yes No No NoPAS202B PixArt Imaging | Yes Yes No NoTAS5110C1B Taiwan Advanced Sensor | Yes No No NoTAS5110D Taiwan Advanced Sensor | Yes No No NoTAS5130D1B Taiwan Advanced Sensor | Yes No No No"Yes" means that the pair is supported by the driver, while "No" means that thepair does not exist or is not supported by the driver.Only some of the available control settings of each image sensor are supportedthrough the 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. 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 provideseither "raw" compressed video data (without frame headers not related to thecompressed data) or standard JPEG (with frame headers). The compression qualitymay vary from 0 to 1 and can be selected or queried thanks to theVIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's. For maximum flexibility,both the default active video format and the default compression qualitydepend on how the image sensor being used is initialized.11. Video frame formats [1]=======================The SN9C1xx PC Camera Controllers can send images in two possible videoformats over the USB: either native "Sequential RGB Bayer" or compressed.The compression is used to achieve high frame rates. With regard to theSN9C101, SN9C102 and SN9C103, the compression is based on the Huffman encodingalgorithm described below, while with regard to the SN9C105 and SN9C120 thecompression is based on the JPEG standard.The current video format may be selected or queried from the user applicationby calling the VIDIOC_S_FMT or VIDIOC_G_FMT ioctl's, as described in the V4L2API specifications.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 or CMOS image sensors.The Huffman compressed video frame consists of a bitstream that encodes forevery R, G, or B pixel the difference between the value of the pixel itself andsome reference pixel value. Pixels are organised in the Bayer pattern and theBayer sub-pixels are tracked individually and alternatingly. For example, inthe first line values for the B and G1 pixels are alternatingly encoded, whilein the 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 SN9C101, SN9C102 and SN9C103 chips to uncompressed Bayer. Additionalsteps are required to convert this to a color image (i.e. a color interpolationalgorithm).The following Huffman codes have been found:0: +0 (relative to reference pixel value)100: +4101: -4?1110xxxx: set absolute value to xxxx.00001101: +111111: -1111001: +20110000: -20110001: ??? - these codes are apparently not used[1] The Huffman compression algorithm has been reverse-engineered and documented by Bertrik Sikken.12. 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'.13. Credits===========Many thanks to following persons for their contribute (listed in alphabeticalorder):- David Anderson for the donation of a webcam;- Luca Capello for the donation of a webcam;- Philippe Coval for having helped testing the PAS202BCA image sensor;- Joao Rodrigo Fuzaro, Joao Limirio, Claudio Filho and Caio Begotti for the donation of a webcam;- Dennis Heitmann for the donation of a webcam;- Jon Hollstrom for the donation of a webcam;- Nick McGill 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;- Andrew Pearce for the donation of a webcam;- John Pullan for the donation of a webcam;- Bertrik Sikken, who reverse-engineered and documented the Huffman compression algorithm used in the SN9C101, SN9C102 and SN9C103 controllers and implemented the first decoder;- Ronny Standke for the donation of a webcam;- 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.- an anonymous donator for the donation of four webcams and two boards with ten image sensors.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -