vserver 1.9.3
[linux-2.6.git] / Documentation / usb / sn9c102.txt
1
2                         SN9C10[12] PC Camera Controllers
3                                 Driver for Linux
4                         ================================
5
6                                - Documentation -
7
8
9 Index
10 =====
11 1.  Copyright
12 2.  License
13 3.  Overview
14 4.  Module dependencies
15 5.  Module loading
16 6.  Module parameters
17 7.  Optional device control through "sysfs"
18 8.  Supported devices
19 9.  How to add support for new image sensors
20 10. Notes for V4L2 application developers
21 11. Contact information
22 12. Credits
23
24
25 1. Copyright
26 ============
27 Copyright (C) 2004 by Luca Risolia <luca.risolia@studio.unibo.it>
28
29 SONiX is a trademark of SONiX Technology Company Limited, inc.
30 This driver is not sponsored or developed by SONiX.
31
32
33 2. License
34 ==========
35 This program is free software; you can redistribute it and/or modify
36 it under the terms of the GNU General Public License as published by
37 the Free Software Foundation; either version 2 of the License, or
38 (at your option) any later version.
39
40 This program is distributed in the hope that it will be useful,
41 but WITHOUT ANY WARRANTY; without even the implied warranty of
42 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43 GNU General Public License for more details.
44
45 You should have received a copy of the GNU General Public License
46 along with this program; if not, write to the Free Software
47 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48
49
50 3. Overview
51 ===========
52 This driver attempts to support the video streaming capabilities of the devices
53 mounting the SONiX SN9C101 or SONiX SN9C102 PC Camera Controllers.
54
55 - It's worth to note that SONiX has never collaborated with me during the
56 development of this project, despite of several requests for enough detailed
57 specifications of the register tables, compression engine and video data format
58 of the above chips -
59
60 Up to 64 cameras can be handled at the same time. They can be connected and
61 disconnected from the host many times without turning off the computer, if
62 your system supports the hotplug facility.
63
64 The driver relies on the Video4Linux2 and USB core modules. It has been
65 designed to run properly on SMP systems as well.
66
67 The latest version of the SN9C10[12] driver can be found at the following URL:
68 http://go.lamarinapunto.com/
69
70
71 4. Module dependencies
72 ======================
73 For it to work properly, the driver needs kernel support for Video4Linux and
74 USB.
75
76 The following options of the kernel configuration file must be enabled and
77 corresponding modules must be compiled:
78
79         # Multimedia devices
80         #
81         CONFIG_VIDEO_DEV=m
82
83         # USB support
84         #
85         CONFIG_USB=m
86
87 In addition, depending on the hardware being used, the modules below are
88 necessary:
89
90         # USB Host Controller Drivers
91         #
92         CONFIG_USB_EHCI_HCD=m
93         CONFIG_USB_UHCI_HCD=m
94         CONFIG_USB_OHCI_HCD=m
95
96 And finally:
97
98         # USB Multimedia devices
99         #
100         CONFIG_USB_SN9C102=m
101
102
103 5. Module loading
104 =================
105 To use the driver, it is necessary to load the "sn9c102" module into memory
106 after every other module required: "videodev", "usbcore" and, depending on
107 the USB host controller you have, "ehci-hcd", "uhci-hcd" or "ohci-hcd".
108
109 Loading can be done as shown below:
110
111         [root@localhost home]# modprobe usbcore
112         [root@localhost home]# modprobe sn9c102
113
114 At this point the devices should be recognized. You can invoke "dmesg" to
115 analyze kernel messages and verify that the loading process has gone well:
116
117         [user@localhost home]$ dmesg
118
119
120 6. Module parameters
121 ====================
122 Module parameters are listed below:
123 -------------------------------------------------------------------------------
124 Name:           video_nr
125 Type:           int array (min = 0, max = 32)
126 Syntax:         <-1|n[,...]> 
127 Description:    Specify V4L2 minor mode number:
128                 -1 = use next available
129                  n = use minor number n
130                 You can specify up to 32 cameras this way.
131                 For example:
132                 video_nr=-1,2,-1 would assign minor number 2 to the second
133                 recognized camera and use auto for the first one and for every
134                 other camera.
135 Default:        -1
136 -------------------------------------------------------------------------------
137 Name:           debug
138 Type:           int
139 Syntax:         <n> 
140 Description:    Debugging information level, from 0 to 3:
141                 0 = none (use carefully)
142                 1 = critical errors
143                 2 = significant informations
144                 3 = more verbose messages
145                 Level 3 is useful for testing only, when only one device
146                 is used.
147 Default:        2
148 -------------------------------------------------------------------------------
149
150
151 7. Optional device control through "sysfs"
152 ==========================================
153 It is possible to read and write both the SN9C10[12] and the image sensor
154 registers by using the "sysfs" filesystem interface.
155
156 Every time a supported device is recognized, a read-only file named "green" is
157 created in the /sys/class/video4linux/videoX directory. You can set the green
158 channel's gain by writing the desired value to it. The value may range from 0
159 to 15.
160
161 There are other four entries in the directory above for each registered camera:
162 "reg", "val", "i2c_reg" and "i2c_val". The first two files control the
163 SN9C10[12] bridge, while the other two control the sensor chip. "reg" and
164 "i2c_reg" hold the values of the current register index where the following
165 reading/writing operations are addressed at through "val" and "i2c_val". Their
166 use is not intended for end-users, unless you know what you are doing. Note
167 that "i2c_reg" and "i2c_val" won't be created if the sensor does not actually
168 support the standard I2C protocol. Also, remember that you must be logged in as
169 root before writing to them.
170
171 As an example, suppose we were to want to read the value contained in the
172 register number 1 of the sensor register table - which usually is the product
173 identifier - of the camera registered as "/dev/video0":
174
175         [root@localhost #] cd /sys/class/video4linux/video0
176         [root@localhost #] echo 1 > i2c_reg
177         [root@localhost #] cat i2c_val
178
179 Now let's set the green gain's register of the SN9C10[12] chip to 2:
180
181         [root@localhost #] echo 0x11 > reg
182         [root@localhost #] echo 2 > val
183
184 Note that the SN9C10[12] always returns 0 when some of its registers are read.
185 To avoid race conditions, all the I/O accesses to the files are serialized.
186
187
188 8. Supported devices
189 ====================
190 - I won't mention any of the names of the companies as well as their products
191 here. They have never collaborated with me, so no advertising -
192
193 From the point of view of a driver, what unambiguously identify a device are
194 its vendor and product USB identifiers. Below is a list of known identifiers of
195 devices mounting the SN9C10[12] PC camera controllers:
196
197 Vendor ID  Product ID
198 ---------  ----------
199 0xc45      0x6001
200 0xc45      0x6005
201 0xc45      0x6009
202 0xc45      0x600d
203 0xc45      0x6024
204 0xc45      0x6025
205 0xc45      0x6028
206 0xc45      0x6029
207 0xc45      0x602a
208 0xc45      0x602c
209 0xc45      0x6030
210
211 The list above does NOT imply that all those devices work with this driver: up
212 until now only the ones that mount the following image sensors are supported.
213 Kernel messages will always tell you whether this is the case:
214
215 Model       Manufacturer
216 -----       ------------
217 PAS106B     PixArt Imaging Inc.
218 PAS202BCB   PixArt Imaging Inc.
219 TAS5110C1B  Taiwan Advanced Sensor Corporation
220 TAS5130D1B  Taiwan Advanced Sensor Corporation
221
222 If you think your camera is based on the above hardware and is not actually
223 listed in the above table, you may try to add the specific USB VendorID and
224 ProductID identifiers to the sn9c102_id_table[] in the file "sn9c102_sensor.h";
225 then compile, load the module again and look at the kernel output.
226 If this works, please send an email to me reporting the kernel messages, so
227 that I will add a new entry in the list of supported devices.
228
229 Donations of new models for further testing and support would be much
230 appreciated. I won't add official support for hardware that I don't actually
231 have.
232
233
234 9. How to add support for new image sensors
235 ===========================================
236 It should be easy to write code for new sensors by using the small API that I
237 have created for this purpose, which is present in "sn9c102_sensor.h"
238 (documentation is included there). As an example, have a look at the code in
239 "sn9c102_pas106b.c", which uses the mentioned interface.
240
241 At the moment, not yet supported image sensors are: HV7131[D|E1] (VGA),
242 MI03 (VGA), OV7620 (VGA).
243
244
245 10. Notes for V4L2 application developers
246 =========================================
247 This driver follows the V4L2 API specifications. In particular, it enforces two
248 rules:
249
250 - exactly one I/O method, either "mmap" or "read", is associated with each
251 file descriptor. Once it is selected, the application must close and reopen the
252 device to switch to the other I/O method;
253
254 - previously mapped buffer memory must always be unmapped before calling any
255 of the "VIDIOC_S_CROP", "VIDIOC_TRY_FMT" and "VIDIOC_S_FMT" ioctl's. The same
256 number of buffers as before will be allocated again to match the size of the
257 new video frames, so you have to map them again before any I/O attempts.
258
259 Consistently with the hardware limits, this driver also supports image
260 downscaling with arbitrary scaling factors from 1, 2 and 4 in both directions.
261 However the V4L2 API specifications don't correctly define how the scaling
262 factor can be choosen arbitrarily by the "negotiation" of the "source" and
263 "target" rectangles. To work around this flaw, we have added the convention
264 that, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, the
265 scaling factor is restored to 1.
266
267
268 11. Contact information
269 =======================
270 I may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
271
272 I can accept GPG/PGP encrypted e-mail. My GPG key ID is 'FCE635A4'.
273 My public 1024-bit key should be available at any keyserver; the fingerprint
274 is: '88E8 F32F 7244 68BA 3958  5D40 99DA 5D2A FCE6 35A4'.
275
276
277 12. Credits
278 ===========
279 I would thank the following persons:
280
281 - Stefano Mozzi, who donated 45 EU;
282 - Luca Capello for the donation of a webcam;
283 - Mizuno Takafumi for the donation of a webcam;
284 - Carlos Eduardo Medaglia Dyonisio, who added the support for the PAS202BCB
285   image sensor.