2 SN9C10x PC Camera Controllers
4 =============================
15 5. Driver installation
18 8. Optional device control through "sysfs"
20 10. How to add support for new image sensors
21 11. Notes for V4L2 application developers
22 12. Contact information
28 Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>
33 SONiX is a trademark of SONiX Technology Company Limited, inc.
34 This software is not sponsored or developed by SONiX.
39 This program is free software; you can redistribute it and/or modify
40 it under the terms of the GNU General Public License as published by
41 the Free Software Foundation; either version 2 of the License, or
42 (at your option) any later version.
44 This program is distributed in the hope that it will be useful,
45 but WITHOUT ANY WARRANTY; without even the implied warranty of
46 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 GNU General Public License for more details.
49 You should have received a copy of the GNU General Public License
50 along with this program; if not, write to the Free Software
51 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
56 This driver attempts to support the video and audio streaming capabilities of
57 the devices mounting the SONiX SN9C101, SN9C102 and SN9C103 (or SUI-102) PC
60 It's worth to note that SONiX has never collaborated with the author during the
61 development of this project, despite several requests for enough detailed
62 specifications of the register tables, compression engine and video data format
65 The driver relies on the Video4Linux2 and USB core modules. It has been
66 designed to run properly on SMP systems as well.
68 The latest version of the SN9C10x driver can be found at the following URL:
69 http://www.linux-projects.org/
71 Some of the features of the driver are:
73 - full compliance with the Video4Linux2 API (see also "Notes for V4L2
74 application developers" paragraph);
75 - available mmap or read/poll methods for video streaming through isochronous
77 - automatic detection of image sensor;
78 - support for any window resolutions and optional panning within the maximum
79 pixel area of image sensor;
80 - image downscaling with arbitrary scaling factors from 1, 2 and 4 in both
81 directions (see "Notes for V4L2 application developers" paragraph);
82 - two different video formats for uncompressed or compressed data (see also
83 "Notes for V4L2 application developers" paragraph);
84 - full support for the capabilities of many of the possible image sensors that
85 can be connected to the SN9C10x bridges, including, for istance, red, green,
86 blue and global gain adjustments and exposure (see "Supported devices"
87 paragraph for details);
88 - use of default color settings for sunlight conditions;
89 - dynamic I/O interface for both SN9C10x and image sensor control (see
90 "Optional device control through 'sysfs'" paragraph);
91 - dynamic driver control thanks to various module parameters (see "Module
92 parameters" paragraph);
93 - up to 64 cameras can be handled at the same time; they can be connected and
94 disconnected from the host many times without turning off the computer, if
95 your system supports hotplugging;
99 5. Module dependencies
100 ======================
101 For it to work properly, the driver needs kernel support for Video4Linux and
104 The following options of the kernel configuration file must be enabled and
105 corresponding modules must be compiled:
115 In addition, depending on the hardware being used, the modules below are
118 # USB Host Controller Drivers
120 CONFIG_USB_EHCI_HCD=m
121 CONFIG_USB_UHCI_HCD=m
122 CONFIG_USB_OHCI_HCD=m
126 # USB Multimedia devices
133 To use the driver, it is necessary to load the "sn9c102" module into memory
134 after every other module required: "videodev", "usbcore" and, depending on
135 the USB host controller you have, "ehci-hcd", "uhci-hcd" or "ohci-hcd".
137 Loading can be done as shown below:
139 [root@localhost home]# modprobe sn9c102
141 At this point the devices should be recognized. You can invoke "dmesg" to
142 analyze kernel messages and verify that the loading process has gone well:
144 [user@localhost home]$ dmesg
149 Module parameters are listed below:
150 -------------------------------------------------------------------------------
152 Type: int array (min = 0, max = 64)
154 Description: Specify V4L2 minor mode number:
155 -1 = use next available
156 n = use minor number n
157 You can specify up to 64 cameras this way.
159 video_nr=-1,2,-1 would assign minor number 2 to the second
160 recognized camera and use auto for the first one and for every
163 -------------------------------------------------------------------------------
167 Description: Debugging information level, from 0 to 3:
168 0 = none (use carefully)
170 2 = significant informations
171 3 = more verbose messages
172 Level 3 is useful for testing only, when only one device
173 is used. It also shows some more informations about the
174 hardware being detected. This parameter can be changed at
175 runtime thanks to the /sys filesystem.
177 -------------------------------------------------------------------------------
180 8. Optional device control through "sysfs"
181 ==========================================
182 It is possible to read and write both the SN9C10x and the image sensor
183 registers by using the "sysfs" filesystem interface.
185 Every time a supported device is recognized, a write-only file named "green" is
186 created in the /sys/class/video4linux/videoX directory. You can set the green
187 channel's gain by writing the desired value to it. The value may range from 0
188 to 15 for SN9C101 or SN9C102 bridges, from 0 to 127 for SN9C103 bridges.
189 Similarly, only for SN9C103 controllers, blue and red gain control files are
190 available in the same directory, for which accepted values may range from 0 to
193 There are other four entries in the directory above for each registered camera:
194 "reg", "val", "i2c_reg" and "i2c_val". The first two files control the
195 SN9C10x bridge, while the other two control the sensor chip. "reg" and
196 "i2c_reg" hold the values of the current register index where the following
197 reading/writing operations are addressed at through "val" and "i2c_val". Their
198 use is not intended for end-users, unless you know what you are doing. Note
199 that "i2c_reg" and "i2c_val" won't be created if the sensor does not actually
200 support the standard I2C protocol. Also, remember that you must be logged in as
201 root before writing to them.
203 As an example, suppose we were to want to read the value contained in the
204 register number 1 of the sensor register table - which is usually the product
205 identifier - of the camera registered as "/dev/video0":
207 [root@localhost #] cd /sys/class/video4linux/video0
208 [root@localhost #] echo 1 > i2c_reg
209 [root@localhost #] cat i2c_val
211 Note that "cat" will fail if sensor registers cannot be read.
213 Now let's set the green gain's register of the SN9C101 or SN9C102 chips to 2:
215 [root@localhost #] echo 0x11 > reg
216 [root@localhost #] echo 2 > val
218 Note that the SN9C10x always returns 0 when some of its registers are read.
219 To avoid race conditions, all the I/O accesses to the files are serialized.
224 None of the names of the companies as well as their products will be mentioned
225 here. They have never collaborated with the author, so no advertising.
227 From the point of view of a driver, what unambiguously identify a device are
228 its vendor and product USB identifiers. Below is a list of known identifiers of
229 devices mounting the SN9C10x PC camera controllers:
272 The list above does not imply that all those devices work with this driver: up
273 until now only the ones that mount the following image sensors are supported;
274 kernel messages will always tell you whether this is the case:
278 PAS106B PixArt Imaging Inc.
279 PAS202BCB PixArt Imaging Inc.
280 TAS5110C1B Taiwan Advanced Sensor Corporation
281 TAS5130D1B Taiwan Advanced Sensor Corporation
283 All the available control settings of each image sensor are supported through
286 If you think your camera is based on the above hardware and is not actually
287 listed in the above table, you may try to add the specific USB VendorID and
288 ProductID identifiers to the sn9c102_id_table[] in the file "sn9c102_sensor.h";
289 then compile, load the module again and look at the kernel output.
290 If this works, please send an email to the author reporting the kernel
291 messages, so that a new entry in the list of supported devices can be added.
293 Donations of new models for further testing and support would be much
294 appreciated. Non-available hardware won't be supported by the author of this
298 10. How to add support for new image sensors
299 ============================================
300 It should be easy to write code for new sensors by using the small API that I
301 have created for this purpose, which is present in "sn9c102_sensor.h"
302 (documentation is included there). As an example, have a look at the code in
303 "sn9c102_pas106b.c", which uses the mentioned interface.
305 At the moment, possible unsupported image sensors are: HV7131x series (VGA),
306 MI03x series (VGA), OV7620 (VGA), OV7630 (VGA), CIS-VF10 (VGA).
309 11. Notes for V4L2 application developers
310 =========================================
311 This driver follows the V4L2 API specifications. In particular, it enforces two
314 - exactly one I/O method, either "mmap" or "read", is associated with each
315 file descriptor. Once it is selected, the application must close and reopen the
316 device to switch to the other I/O method;
318 - previously mapped buffer memory must always be unmapped before calling any
319 of the "VIDIOC_S_CROP", "VIDIOC_TRY_FMT" and "VIDIOC_S_FMT" ioctl's. The same
320 number of buffers as before will be allocated again to match the size of the
321 new video frames, so you have to map the buffers again before any I/O attempts
324 Consistently with the hardware limits, this driver also supports image
325 downscaling with arbitrary scaling factors from 1, 2 and 4 in both directions.
326 However, the V4L2 API specifications don't correctly define how the scaling
327 factor can be chosen arbitrarily by the "negotiation" of the "source" and
328 "target" rectangles. To work around this flaw, we have added the convention
329 that, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, the
330 scaling factor is restored to 1.
332 This driver supports two different video formats: the first one is the "8-bit
333 Sequential Bayer" format and can be used to obtain uncompressed video data
334 from the device through the current I/O method, while the second one provides
335 "raw" compressed video data (without the initial and final frame headers). The
336 compression quality may vary from 0 to 1 and can be selected or queried thanks
337 to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's. For maximum
338 flexibility, the default active video format depends on how the image sensor
339 being used is initialized (as described in the documentation of the API for the
340 image sensors supplied by this driver).
343 12. Contact information
344 =======================
345 I may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
347 I can accept GPG/PGP encrypted e-mail. My GPG key ID is 'FCE635A4'.
348 My public 1024-bit key should be available at any keyserver; the fingerprint
349 is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
354 I would thank the following persons:
356 - Stefano Mozzi, who donated 45 EU;
357 - Luca Capello for the donation of a webcam;
358 - Mizuno Takafumi for the donation of a webcam;
359 - Carlos Eduardo Medaglia Dyonisio, who added the support for the PAS202BCB