fedora core 2.6.10-1.12-FC2
[linux-2.6.git] / Documentation / usb / sn9c102.txt
1
2                          SN9C10x PC Camera Controllers
3                                 Driver for Linux
4                          =============================
5
6                                - Documentation -
7
8
9 Index
10 =====
11 1.  Copyright
12 2.  Disclaimer
13 3.  License
14 4.  Overview
15 5.  Driver installation
16 6.  Module loading
17 7.  Module parameters
18 8.  Optional device control through "sysfs"
19 9.  Supported devices
20 10. How to add support for new image sensors
21 11. Notes for V4L2 application developers
22 12. Contact information
23 13. Credits
24
25
26 1. Copyright
27 ============
28 Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>
29
30
31 2. Disclaimer
32 =============
33 SONiX is a trademark of SONiX Technology Company Limited, inc.
34 This software is not sponsored or developed by SONiX.
35
36
37 3. License
38 ==========
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.
43
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.
48
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.
52
53
54 4. Overview
55 ===========
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
58 Camera Controllers.
59
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
63 of the above chips.
64
65 The driver relies on the Video4Linux2 and USB core modules. It has been
66 designed to run properly on SMP systems as well.
67
68 The latest version of the SN9C10x driver can be found at the following URL:
69 http://www.linux-projects.org/
70
71 Some of the features of the driver are:
72
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
76   data transfers;
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;
96 - no known bugs.
97
98
99 5. Module dependencies
100 ======================
101 For it to work properly, the driver needs kernel support for Video4Linux and
102 USB.
103
104 The following options of the kernel configuration file must be enabled and
105 corresponding modules must be compiled:
106
107         # Multimedia devices
108         #
109         CONFIG_VIDEO_DEV=m
110
111         # USB support
112         #
113         CONFIG_USB=m
114
115 In addition, depending on the hardware being used, the modules below are
116 necessary:
117
118         # USB Host Controller Drivers
119         #
120         CONFIG_USB_EHCI_HCD=m
121         CONFIG_USB_UHCI_HCD=m
122         CONFIG_USB_OHCI_HCD=m
123
124 And finally:
125
126         # USB Multimedia devices
127         #
128         CONFIG_USB_SN9C102=m
129
130
131 6. Module loading
132 =================
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".
136
137 Loading can be done as shown below:
138
139         [root@localhost home]# modprobe sn9c102
140
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:
143
144         [user@localhost home]$ dmesg
145
146
147 7. Module parameters
148 ====================
149 Module parameters are listed below:
150 -------------------------------------------------------------------------------
151 Name:           video_nr
152 Type:           int array (min = 0, max = 64)
153 Syntax:         <-1|n[,...]> 
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.
158                 For example:
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
161                 other camera.
162 Default:        -1
163 -------------------------------------------------------------------------------
164 Name:           debug
165 Type:           int
166 Syntax:         <n> 
167 Description:    Debugging information level, from 0 to 3:
168                 0 = none (use carefully)
169                 1 = critical errors
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.
176 Default:        2
177 -------------------------------------------------------------------------------
178
179
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.
184
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
191 127.
192
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.
202
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":
206
207         [root@localhost #] cd /sys/class/video4linux/video0
208         [root@localhost #] echo 1 > i2c_reg
209         [root@localhost #] cat i2c_val
210
211 Note that "cat" will fail if sensor registers cannot be read.
212
213 Now let's set the green gain's register of the SN9C101 or SN9C102 chips to 2:
214
215         [root@localhost #] echo 0x11 > reg
216         [root@localhost #] echo 2 > val
217
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.
220
221
222 9. Supported devices
223 ====================
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.
226
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:
230
231 Vendor ID  Product ID
232 ---------  ----------
233 0x0c45     0x6001
234 0x0c45     0x6005
235 0x0c45     0x6009
236 0x0c45     0x600d
237 0x0c45     0x6024
238 0x0c45     0x6025
239 0x0c45     0x6028
240 0x0c45     0x6029
241 0x0c45     0x602a
242 0x0c45     0x602b
243 0x0c45     0x602c
244 0x0c45     0x6030
245 0x0c45     0x6080
246 0x0c45     0x6082
247 0x0c45     0x6083
248 0x0c45     0x6088
249 0x0c45     0x608a
250 0x0c45     0x608b
251 0x0c45     0x608c
252 0x0c45     0x608e
253 0x0c45     0x608f
254 0x0c45     0x60a0
255 0x0c45     0x60a2
256 0x0c45     0x60a3
257 0x0c45     0x60a8
258 0x0c45     0x60aa
259 0x0c45     0x60ab
260 0x0c45     0x60ac
261 0x0c45     0x60ae
262 0x0c45     0x60af
263 0x0c45     0x60b0
264 0x0c45     0x60b2
265 0x0c45     0x60b3
266 0x0c45     0x60b8
267 0x0c45     0x60ba
268 0x0c45     0x60bb
269 0x0c45     0x60bc
270 0x0c45     0x60be
271
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:
275
276 Model       Manufacturer
277 -----       ------------
278 PAS106B     PixArt Imaging Inc.
279 PAS202BCB   PixArt Imaging Inc.
280 TAS5110C1B  Taiwan Advanced Sensor Corporation
281 TAS5130D1B  Taiwan Advanced Sensor Corporation
282
283 All the available control settings of each image sensor are supported through
284 the V4L2 interface.
285
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.
292
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
295 driver.
296
297
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.
304
305 At the moment, possible unsupported image sensors are: HV7131x series (VGA),
306 MI03x series (VGA), OV7620 (VGA), OV7630 (VGA), CIS-VF10 (VGA).
307
308
309 11. Notes for V4L2 application developers
310 =========================================
311 This driver follows the V4L2 API specifications. In particular, it enforces two
312 rules:
313
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;
317
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
322 on them.
323
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.
331
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).
341
342
343 12. Contact information
344 =======================
345 I may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
346
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'.
350
351
352 13. Credits
353 ===========
354 I would thank the following persons:
355
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
360   image sensor.