diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-24 12:50:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-24 12:50:13 -0400 |
commit | 76d21c563569bcea6bc67d65cc2c460cff643058 (patch) | |
tree | 4dd2c9846ea7838077099646418978e354df1680 /Documentation/video4linux | |
parent | 6e50e9f9f4a8277b4d76de417ca77cf3921bd524 (diff) | |
parent | 472af2b05bdefcaee7e754e22cbf131110017ad6 (diff) |
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (442 commits)
[media] videobuf2-dma-contig: make cookie() return a pointer to dma_addr_t
[media] sh_mobile_ceu_camera: Do not call vb2's mem_ops directly
[media] V4L: soc-camera: explicitly require V4L2_BUF_TYPE_VIDEO_CAPTURE
[media] v4l: soc-camera: Store negotiated buffer settings
[media] rc: interim support for 32-bit NEC-ish scancodes
[media] mceusb: topseed 0x0011 needs gen3 init for tx to work
[media] lirc_zilog: error out if buffer read bytes != chunk size
[media] lirc: silence some compile warnings
[media] hdpvr: use same polling interval as other OS
[media] ir-kbd-i2c: pass device code w/key in hauppauge case
[media] rc/keymaps: Remove the obsolete rc-rc5-tv keymap
[media] remove the old RC_MAP_HAUPPAUGE_NEW RC map
[media] rc/keymaps: Rename Hauppauge table as rc-hauppauge
[media] rc-rc5-hauppauge-new: Fix Hauppauge Grey mapping
[media] rc-rc5-hauppauge-new: Add support for the old Black RC
[media] rc-rc5-hauppauge-new: Add the old control to the table
[media] rc-winfast: Fix the keycode tables
[media] a800: Fix a few wrong IR key assignments
[media] opera1: Use multimedia keys instead of an app-specific mapping
[media] dw2102: Use multimedia keys instead of an app-specific mapping
...
Fix up trivial conflicts (remove/modify and some real conflicts) in:
arch/arm/mach-omap2/devices.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/dabusb/dabusb.c
drivers/staging/dabusb/dabusb.h
drivers/staging/easycap/easycap_ioctl.c
drivers/staging/usbvideo/usbvideo.c
drivers/staging/usbvideo/vicam.c
Diffstat (limited to 'Documentation/video4linux')
-rw-r--r-- | Documentation/video4linux/README.ivtv | 3 | ||||
-rw-r--r-- | Documentation/video4linux/gspca.txt | 10 | ||||
-rw-r--r-- | Documentation/video4linux/omap3isp.txt | 278 | ||||
-rw-r--r-- | Documentation/video4linux/v4l2-framework.txt | 267 |
4 files changed, 518 insertions, 40 deletions
diff --git a/Documentation/video4linux/README.ivtv b/Documentation/video4linux/README.ivtv index 42b06686eb78..2579b5b709ed 100644 --- a/Documentation/video4linux/README.ivtv +++ b/Documentation/video4linux/README.ivtv | |||
@@ -36,8 +36,7 @@ Additional features for the PVR-350 (CX23415 based): | |||
36 | * Provides comprehensive OSD (On Screen Display: ie. graphics overlaying the | 36 | * Provides comprehensive OSD (On Screen Display: ie. graphics overlaying the |
37 | video signal) | 37 | video signal) |
38 | * Provides a framebuffer (allowing X applications to appear on the video | 38 | * Provides a framebuffer (allowing X applications to appear on the video |
39 | device) (this framebuffer is not yet part of the kernel. In the meantime it | 39 | device) |
40 | is available from www.ivtvdriver.org). | ||
41 | * Supports raw YUV output. | 40 | * Supports raw YUV output. |
42 | 41 | ||
43 | IMPORTANT: In case of problems first read this page: | 42 | IMPORTANT: In case of problems first read this page: |
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt index 261776e0c5e1..5c542e60f51d 100644 --- a/Documentation/video4linux/gspca.txt +++ b/Documentation/video4linux/gspca.txt | |||
@@ -103,6 +103,7 @@ spca561 046d:092d Logitech QC Elch2 | |||
103 | spca561 046d:092e Logitech QC Elch2 | 103 | spca561 046d:092e Logitech QC Elch2 |
104 | spca561 046d:092f Logitech QuickCam Express Plus | 104 | spca561 046d:092f Logitech QuickCam Express Plus |
105 | sunplus 046d:0960 Logitech ClickSmart 420 | 105 | sunplus 046d:0960 Logitech ClickSmart 420 |
106 | nw80x 046d:d001 Logitech QuickCam Pro (dark focus ring) | ||
106 | sunplus 0471:0322 Philips DMVC1300K | 107 | sunplus 0471:0322 Philips DMVC1300K |
107 | zc3xx 0471:0325 Philips SPC 200 NC | 108 | zc3xx 0471:0325 Philips SPC 200 NC |
108 | zc3xx 0471:0326 Philips SPC 300 NC | 109 | zc3xx 0471:0326 Philips SPC 300 NC |
@@ -150,10 +151,12 @@ sunplus 04fc:5330 Digitrex 2110 | |||
150 | sunplus 04fc:5360 Sunplus Generic | 151 | sunplus 04fc:5360 Sunplus Generic |
151 | spca500 04fc:7333 PalmPixDC85 | 152 | spca500 04fc:7333 PalmPixDC85 |
152 | sunplus 04fc:ffff Pure DigitalDakota | 153 | sunplus 04fc:ffff Pure DigitalDakota |
154 | nw80x 0502:d001 DVC V6 | ||
153 | spca501 0506:00df 3Com HomeConnect Lite | 155 | spca501 0506:00df 3Com HomeConnect Lite |
154 | sunplus 052b:1507 Megapixel 5 Pretec DC-1007 | 156 | sunplus 052b:1507 Megapixel 5 Pretec DC-1007 |
155 | sunplus 052b:1513 Megapix V4 | 157 | sunplus 052b:1513 Megapix V4 |
156 | sunplus 052b:1803 MegaImage VI | 158 | sunplus 052b:1803 MegaImage VI |
159 | nw80x 052b:d001 EZCam Pro p35u | ||
157 | tv8532 0545:808b Veo Stingray | 160 | tv8532 0545:808b Veo Stingray |
158 | tv8532 0545:8333 Veo Stingray | 161 | tv8532 0545:8333 Veo Stingray |
159 | sunplus 0546:3155 Polaroid PDC3070 | 162 | sunplus 0546:3155 Polaroid PDC3070 |
@@ -177,6 +180,7 @@ sunplus 055f:c530 Mustek Gsmart LCD 3 | |||
177 | sunplus 055f:c540 Gsmart D30 | 180 | sunplus 055f:c540 Gsmart D30 |
178 | sunplus 055f:c630 Mustek MDC4000 | 181 | sunplus 055f:c630 Mustek MDC4000 |
179 | sunplus 055f:c650 Mustek MDC5500Z | 182 | sunplus 055f:c650 Mustek MDC5500Z |
183 | nw80x 055f:d001 Mustek Wcam 300 mini | ||
180 | zc3xx 055f:d003 Mustek WCam300A | 184 | zc3xx 055f:d003 Mustek WCam300A |
181 | zc3xx 055f:d004 Mustek WCam300 AN | 185 | zc3xx 055f:d004 Mustek WCam300 AN |
182 | conex 0572:0041 Creative Notebook cx11646 | 186 | conex 0572:0041 Creative Notebook cx11646 |
@@ -195,14 +199,20 @@ gl860 05e3:0503 Genesys Logic PC Camera | |||
195 | gl860 05e3:f191 Genesys Logic PC Camera | 199 | gl860 05e3:f191 Genesys Logic PC Camera |
196 | spca561 060b:a001 Maxell Compact Pc PM3 | 200 | spca561 060b:a001 Maxell Compact Pc PM3 |
197 | zc3xx 0698:2003 CTX M730V built in | 201 | zc3xx 0698:2003 CTX M730V built in |
202 | nw80x 06a5:0000 Typhoon Webcam 100 USB | ||
203 | nw80x 06a5:d001 Divio based webcams | ||
204 | nw80x 06a5:d800 Divio Chicony TwinkleCam, Trust SpaceCam | ||
198 | spca500 06bd:0404 Agfa CL20 | 205 | spca500 06bd:0404 Agfa CL20 |
199 | spca500 06be:0800 Optimedia | 206 | spca500 06be:0800 Optimedia |
207 | nw80x 06be:d001 EZCam Pro p35u | ||
200 | sunplus 06d6:0031 Trust 610 LCD PowerC@m Zoom | 208 | sunplus 06d6:0031 Trust 610 LCD PowerC@m Zoom |
201 | spca506 06e1:a190 ADS Instant VCD | 209 | spca506 06e1:a190 ADS Instant VCD |
210 | ov534 06f8:3002 Hercules Blog Webcam | ||
202 | ov534_9 06f8:3003 Hercules Dualpix HD Weblog | 211 | ov534_9 06f8:3003 Hercules Dualpix HD Weblog |
203 | sonixj 06f8:3004 Hercules Classic Silver | 212 | sonixj 06f8:3004 Hercules Classic Silver |
204 | sonixj 06f8:3008 Hercules Deluxe Optical Glass | 213 | sonixj 06f8:3008 Hercules Deluxe Optical Glass |
205 | pac7302 06f8:3009 Hercules Classic Link | 214 | pac7302 06f8:3009 Hercules Classic Link |
215 | nw80x 0728:d001 AVerMedia Camguard | ||
206 | spca508 0733:0110 ViewQuest VQ110 | 216 | spca508 0733:0110 ViewQuest VQ110 |
207 | spca501 0733:0401 Intel Create and Share | 217 | spca501 0733:0401 Intel Create and Share |
208 | spca501 0733:0402 ViewQuest M318B | 218 | spca501 0733:0402 ViewQuest M318B |
diff --git a/Documentation/video4linux/omap3isp.txt b/Documentation/video4linux/omap3isp.txt new file mode 100644 index 000000000000..69be2c782b98 --- /dev/null +++ b/Documentation/video4linux/omap3isp.txt | |||
@@ -0,0 +1,278 @@ | |||
1 | OMAP 3 Image Signal Processor (ISP) driver | ||
2 | |||
3 | Copyright (C) 2010 Nokia Corporation | ||
4 | Copyright (C) 2009 Texas Instruments, Inc. | ||
5 | |||
6 | Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
7 | Sakari Ailus <sakari.ailus@iki.fi> | ||
8 | David Cohen <dacohen@gmail.com> | ||
9 | |||
10 | |||
11 | Introduction | ||
12 | ============ | ||
13 | |||
14 | This file documents the Texas Instruments OMAP 3 Image Signal Processor (ISP) | ||
15 | driver located under drivers/media/video/omap3isp. The original driver was | ||
16 | written by Texas Instruments but since that it has been rewritten (twice) at | ||
17 | Nokia. | ||
18 | |||
19 | The driver has been successfully used on the following versions of OMAP 3: | ||
20 | |||
21 | 3430 | ||
22 | 3530 | ||
23 | 3630 | ||
24 | |||
25 | The driver implements V4L2, Media controller and v4l2_subdev interfaces. | ||
26 | Sensor, lens and flash drivers using the v4l2_subdev interface in the kernel | ||
27 | are supported. | ||
28 | |||
29 | |||
30 | Split to subdevs | ||
31 | ================ | ||
32 | |||
33 | The OMAP 3 ISP is split into V4L2 subdevs, each of the blocks inside the ISP | ||
34 | having one subdev to represent it. Each of the subdevs provide a V4L2 subdev | ||
35 | interface to userspace. | ||
36 | |||
37 | OMAP3 ISP CCP2 | ||
38 | OMAP3 ISP CSI2a | ||
39 | OMAP3 ISP CCDC | ||
40 | OMAP3 ISP preview | ||
41 | OMAP3 ISP resizer | ||
42 | OMAP3 ISP AEWB | ||
43 | OMAP3 ISP AF | ||
44 | OMAP3 ISP histogram | ||
45 | |||
46 | Each possible link in the ISP is modelled by a link in the Media controller | ||
47 | interface. For an example program see [2]. | ||
48 | |||
49 | |||
50 | Controlling the OMAP 3 ISP | ||
51 | ========================== | ||
52 | |||
53 | In general, the settings given to the OMAP 3 ISP take effect at the beginning | ||
54 | of the following frame. This is done when the module becomes idle during the | ||
55 | vertical blanking period on the sensor. In memory-to-memory operation the pipe | ||
56 | is run one frame at a time. Applying the settings is done between the frames. | ||
57 | |||
58 | All the blocks in the ISP, excluding the CSI-2 and possibly the CCP2 receiver, | ||
59 | insist on receiving complete frames. Sensors must thus never send the ISP | ||
60 | partial frames. | ||
61 | |||
62 | Autoidle does have issues with some ISP blocks on the 3430, at least. | ||
63 | Autoidle is only enabled on 3630 when the omap3isp module parameter autoidle | ||
64 | is non-zero. | ||
65 | |||
66 | |||
67 | Events | ||
68 | ====== | ||
69 | |||
70 | The OMAP 3 ISP driver does support the V4L2 event interface on CCDC and | ||
71 | statistics (AEWB, AF and histogram) subdevs. | ||
72 | |||
73 | The CCDC subdev produces V4L2_EVENT_OMAP3ISP_HS_VS type event on HS_VS | ||
74 | interrupt which is used to signal frame start. The event is triggered exactly | ||
75 | when the reception of the first line of the frame starts in the CCDC module. | ||
76 | The event can be subscribed on the CCDC subdev. | ||
77 | |||
78 | (When using parallel interface one must pay account to correct configuration | ||
79 | of the VS signal polarity. This is automatically correct when using the serial | ||
80 | receivers.) | ||
81 | |||
82 | Each of the statistics subdevs is able to produce events. An event is | ||
83 | generated whenever a statistics buffer can be dequeued by a user space | ||
84 | application using the VIDIOC_OMAP3ISP_STAT_REQ IOCTL. The events available | ||
85 | are: | ||
86 | |||
87 | V4L2_EVENT_OMAP3ISP_AEWB | ||
88 | V4L2_EVENT_OMAP3ISP_AF | ||
89 | V4L2_EVENT_OMAP3ISP_HIST | ||
90 | |||
91 | The type of the event data is struct omap3isp_stat_event_status for these | ||
92 | ioctls. If there is an error calculating the statistics, there will be an | ||
93 | event as usual, but no related statistics buffer. In this case | ||
94 | omap3isp_stat_event_status.buf_err is set to non-zero. | ||
95 | |||
96 | |||
97 | Private IOCTLs | ||
98 | ============== | ||
99 | |||
100 | The OMAP 3 ISP driver supports standard V4L2 IOCTLs and controls where | ||
101 | possible and practical. Much of the functions provided by the ISP, however, | ||
102 | does not fall under the standard IOCTLs --- gamma tables and configuration of | ||
103 | statistics collection are examples of such. | ||
104 | |||
105 | In general, there is a private ioctl for configuring each of the blocks | ||
106 | containing hardware-dependent functions. | ||
107 | |||
108 | The following private IOCTLs are supported: | ||
109 | |||
110 | VIDIOC_OMAP3ISP_CCDC_CFG | ||
111 | VIDIOC_OMAP3ISP_PRV_CFG | ||
112 | VIDIOC_OMAP3ISP_AEWB_CFG | ||
113 | VIDIOC_OMAP3ISP_HIST_CFG | ||
114 | VIDIOC_OMAP3ISP_AF_CFG | ||
115 | VIDIOC_OMAP3ISP_STAT_REQ | ||
116 | VIDIOC_OMAP3ISP_STAT_EN | ||
117 | |||
118 | The parameter structures used by these ioctls are described in | ||
119 | include/linux/omap3isp.h. The detailed functions of the ISP itself related to | ||
120 | a given ISP block is described in the Technical Reference Manuals (TRMs) --- | ||
121 | see the end of the document for those. | ||
122 | |||
123 | While it is possible to use the ISP driver without any use of these private | ||
124 | IOCTLs it is not possible to obtain optimal image quality this way. The AEWB, | ||
125 | AF and histogram modules cannot be used without configuring them using the | ||
126 | appropriate private IOCTLs. | ||
127 | |||
128 | |||
129 | CCDC and preview block IOCTLs | ||
130 | ============================= | ||
131 | |||
132 | The VIDIOC_OMAP3ISP_CCDC_CFG and VIDIOC_OMAP3ISP_PRV_CFG IOCTLs are used to | ||
133 | configure, enable and disable functions in the CCDC and preview blocks, | ||
134 | respectively. Both IOCTLs control several functions in the blocks they | ||
135 | control. VIDIOC_OMAP3ISP_CCDC_CFG IOCTL accepts a pointer to struct | ||
136 | omap3isp_ccdc_update_config as its argument. Similarly VIDIOC_OMAP3ISP_PRV_CFG | ||
137 | accepts a pointer to struct omap3isp_prev_update_config. The definition of | ||
138 | both structures is available in [1]. | ||
139 | |||
140 | The update field in the structures tells whether to update the configuration | ||
141 | for the specific function and the flag tells whether to enable or disable the | ||
142 | function. | ||
143 | |||
144 | The update and flag bit masks accept the following values. Each separate | ||
145 | functions in the CCDC and preview blocks is associated with a flag (either | ||
146 | disable or enable; part of the flag field in the structure) and a pointer to | ||
147 | configuration data for the function. | ||
148 | |||
149 | Valid values for the update and flag fields are listed here for | ||
150 | VIDIOC_OMAP3ISP_CCDC_CFG. Values may be or'ed to configure more than one | ||
151 | function in the same IOCTL call. | ||
152 | |||
153 | OMAP3ISP_CCDC_ALAW | ||
154 | OMAP3ISP_CCDC_LPF | ||
155 | OMAP3ISP_CCDC_BLCLAMP | ||
156 | OMAP3ISP_CCDC_BCOMP | ||
157 | OMAP3ISP_CCDC_FPC | ||
158 | OMAP3ISP_CCDC_CULL | ||
159 | OMAP3ISP_CCDC_CONFIG_LSC | ||
160 | OMAP3ISP_CCDC_TBL_LSC | ||
161 | |||
162 | The corresponding values for the VIDIOC_OMAP3ISP_PRV_CFG are here: | ||
163 | |||
164 | OMAP3ISP_PREV_LUMAENH | ||
165 | OMAP3ISP_PREV_INVALAW | ||
166 | OMAP3ISP_PREV_HRZ_MED | ||
167 | OMAP3ISP_PREV_CFA | ||
168 | OMAP3ISP_PREV_CHROMA_SUPP | ||
169 | OMAP3ISP_PREV_WB | ||
170 | OMAP3ISP_PREV_BLKADJ | ||
171 | OMAP3ISP_PREV_RGB2RGB | ||
172 | OMAP3ISP_PREV_COLOR_CONV | ||
173 | OMAP3ISP_PREV_YC_LIMIT | ||
174 | OMAP3ISP_PREV_DEFECT_COR | ||
175 | OMAP3ISP_PREV_GAMMABYPASS | ||
176 | OMAP3ISP_PREV_DRK_FRM_CAPTURE | ||
177 | OMAP3ISP_PREV_DRK_FRM_SUBTRACT | ||
178 | OMAP3ISP_PREV_LENS_SHADING | ||
179 | OMAP3ISP_PREV_NF | ||
180 | OMAP3ISP_PREV_GAMMA | ||
181 | |||
182 | The associated configuration pointer for the function may not be NULL when | ||
183 | enabling the function. When disabling a function the configuration pointer is | ||
184 | ignored. | ||
185 | |||
186 | |||
187 | Statistic blocks IOCTLs | ||
188 | ======================= | ||
189 | |||
190 | The statistics subdevs do offer more dynamic configuration options than the | ||
191 | other subdevs. They can be enabled, disable and reconfigured when the pipeline | ||
192 | is in streaming state. | ||
193 | |||
194 | The statistics blocks always get the input image data from the CCDC (as the | ||
195 | histogram memory read isn't implemented). The statistics are dequeueable by | ||
196 | the user from the statistics subdev nodes using private IOCTLs. | ||
197 | |||
198 | The private IOCTLs offered by the AEWB, AF and histogram subdevs are heavily | ||
199 | reflected by the register level interface offered by the ISP hardware. There | ||
200 | are aspects that are purely related to the driver implementation and these are | ||
201 | discussed next. | ||
202 | |||
203 | VIDIOC_OMAP3ISP_STAT_EN | ||
204 | ----------------------- | ||
205 | |||
206 | This private IOCTL enables/disables a statistic module. If this request is | ||
207 | done before streaming, it will take effect as soon as the pipeline starts to | ||
208 | stream. If the pipeline is already streaming, it will take effect as soon as | ||
209 | the CCDC becomes idle. | ||
210 | |||
211 | VIDIOC_OMAP3ISP_AEWB_CFG, VIDIOC_OMAP3ISP_HIST_CFG and VIDIOC_OMAP3ISP_AF_CFG | ||
212 | ----------------------------------------------------------------------------- | ||
213 | |||
214 | Those IOCTLs are used to configure the modules. They require user applications | ||
215 | to have an in-depth knowledge of the hardware. Most of the fields explanation | ||
216 | can be found on OMAP's TRMs. The two following fields common to all the above | ||
217 | configure private IOCTLs require explanation for better understanding as they | ||
218 | are not part of the TRM. | ||
219 | |||
220 | omap3isp_[h3a_af/h3a_aewb/hist]_config.buf_size: | ||
221 | |||
222 | The modules handle their buffers internally. The necessary buffer size for the | ||
223 | module's data output depends on the requested configuration. Although the | ||
224 | driver supports reconfiguration while streaming, it does not support a | ||
225 | reconfiguration which requires bigger buffer size than what is already | ||
226 | internally allocated if the module is enabled. It will return -EBUSY on this | ||
227 | case. In order to avoid such condition, either disable/reconfigure/enable the | ||
228 | module or request the necessary buffer size during the first configuration | ||
229 | while the module is disabled. | ||
230 | |||
231 | The internal buffer size allocation considers the requested configuration's | ||
232 | minimum buffer size and the value set on buf_size field. If buf_size field is | ||
233 | out of [minimum, maximum] buffer size range, it's clamped to fit in there. | ||
234 | The driver then selects the biggest value. The corrected buf_size value is | ||
235 | written back to user application. | ||
236 | |||
237 | omap3isp_[h3a_af/h3a_aewb/hist]_config.config_counter: | ||
238 | |||
239 | As the configuration doesn't take effect synchronously to the request, the | ||
240 | driver must provide a way to track this information to provide more accurate | ||
241 | data. After a configuration is requested, the config_counter returned to user | ||
242 | space application will be an unique value associated to that request. When | ||
243 | user application receives an event for buffer availability or when a new | ||
244 | buffer is requested, this config_counter is used to match a buffer data and a | ||
245 | configuration. | ||
246 | |||
247 | VIDIOC_OMAP3ISP_STAT_REQ | ||
248 | ------------------------ | ||
249 | |||
250 | Send to user space the oldest data available in the internal buffer queue and | ||
251 | discards such buffer afterwards. The field omap3isp_stat_data.frame_number | ||
252 | matches with the video buffer's field_count. | ||
253 | |||
254 | |||
255 | Technical reference manuals (TRMs) and other documentation | ||
256 | ========================================================== | ||
257 | |||
258 | OMAP 3430 TRM: | ||
259 | <URL:http://focus.ti.com/pdfs/wtbu/OMAP34xx_ES3.1.x_PUBLIC_TRM_vZM.zip> | ||
260 | Referenced 2011-03-05. | ||
261 | |||
262 | OMAP 35xx TRM: | ||
263 | <URL:http://www.ti.com/litv/pdf/spruf98o> Referenced 2011-03-05. | ||
264 | |||
265 | OMAP 3630 TRM: | ||
266 | <URL:http://focus.ti.com/pdfs/wtbu/OMAP36xx_ES1.x_PUBLIC_TRM_vQ.zip> | ||
267 | Referenced 2011-03-05. | ||
268 | |||
269 | DM 3730 TRM: | ||
270 | <URL:http://www.ti.com/litv/pdf/sprugn4h> Referenced 2011-03-06. | ||
271 | |||
272 | |||
273 | References | ||
274 | ========== | ||
275 | |||
276 | [1] include/linux/omap3isp.h | ||
277 | |||
278 | [2] http://git.ideasonboard.org/?p=media-ctl.git;a=summary | ||
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index f22f35c271f3..3b15608ee070 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -71,6 +71,10 @@ sub-device instances, the video_device struct stores V4L2 device node data | |||
71 | and in the future a v4l2_fh struct will keep track of filehandle instances | 71 | and in the future a v4l2_fh struct will keep track of filehandle instances |
72 | (this is not yet implemented). | 72 | (this is not yet implemented). |
73 | 73 | ||
74 | The V4L2 framework also optionally integrates with the media framework. If a | ||
75 | driver sets the struct v4l2_device mdev field, sub-devices and video nodes | ||
76 | will automatically appear in the media framework as entities. | ||
77 | |||
74 | 78 | ||
75 | struct v4l2_device | 79 | struct v4l2_device |
76 | ------------------ | 80 | ------------------ |
@@ -83,11 +87,20 @@ You must register the device instance: | |||
83 | 87 | ||
84 | v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev); | 88 | v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev); |
85 | 89 | ||
86 | Registration will initialize the v4l2_device struct and link dev->driver_data | 90 | Registration will initialize the v4l2_device struct. If the dev->driver_data |
87 | to v4l2_dev. If v4l2_dev->name is empty then it will be set to a value derived | 91 | field is NULL, it will be linked to v4l2_dev. |
88 | from dev (driver name followed by the bus_id, to be precise). If you set it | 92 | |
89 | up before calling v4l2_device_register then it will be untouched. If dev is | 93 | Drivers that want integration with the media device framework need to set |
90 | NULL, then you *must* setup v4l2_dev->name before calling v4l2_device_register. | 94 | dev->driver_data manually to point to the driver-specific device structure |
95 | that embed the struct v4l2_device instance. This is achieved by a | ||
96 | dev_set_drvdata() call before registering the V4L2 device instance. They must | ||
97 | also set the struct v4l2_device mdev field to point to a properly initialized | ||
98 | and registered media_device instance. | ||
99 | |||
100 | If v4l2_dev->name is empty then it will be set to a value derived from dev | ||
101 | (driver name followed by the bus_id, to be precise). If you set it up before | ||
102 | calling v4l2_device_register then it will be untouched. If dev is NULL, then | ||
103 | you *must* setup v4l2_dev->name before calling v4l2_device_register. | ||
91 | 104 | ||
92 | You can use v4l2_device_set_name() to set the name based on a driver name and | 105 | You can use v4l2_device_set_name() to set the name based on a driver name and |
93 | a driver-global atomic_t instance. This will generate names like ivtv0, ivtv1, | 106 | a driver-global atomic_t instance. This will generate names like ivtv0, ivtv1, |
@@ -108,6 +121,7 @@ You unregister with: | |||
108 | 121 | ||
109 | v4l2_device_unregister(struct v4l2_device *v4l2_dev); | 122 | v4l2_device_unregister(struct v4l2_device *v4l2_dev); |
110 | 123 | ||
124 | If the dev->driver_data field points to v4l2_dev, it will be reset to NULL. | ||
111 | Unregistering will also automatically unregister all subdevs from the device. | 125 | Unregistering will also automatically unregister all subdevs from the device. |
112 | 126 | ||
113 | If you have a hotpluggable device (e.g. a USB device), then when a disconnect | 127 | If you have a hotpluggable device (e.g. a USB device), then when a disconnect |
@@ -167,6 +181,21 @@ static int __devinit drv_probe(struct pci_dev *pdev, | |||
167 | state->instance = atomic_inc_return(&drv_instance) - 1; | 181 | state->instance = atomic_inc_return(&drv_instance) - 1; |
168 | } | 182 | } |
169 | 183 | ||
184 | If you have multiple device nodes then it can be difficult to know when it is | ||
185 | safe to unregister v4l2_device. For this purpose v4l2_device has refcounting | ||
186 | support. The refcount is increased whenever video_register_device is called and | ||
187 | it is decreased whenever that device node is released. When the refcount reaches | ||
188 | zero, then the v4l2_device release() callback is called. You can do your final | ||
189 | cleanup there. | ||
190 | |||
191 | If other device nodes (e.g. ALSA) are created, then you can increase and | ||
192 | decrease the refcount manually as well by calling: | ||
193 | |||
194 | void v4l2_device_get(struct v4l2_device *v4l2_dev); | ||
195 | |||
196 | or: | ||
197 | |||
198 | int v4l2_device_put(struct v4l2_device *v4l2_dev); | ||
170 | 199 | ||
171 | struct v4l2_subdev | 200 | struct v4l2_subdev |
172 | ------------------ | 201 | ------------------ |
@@ -254,6 +283,26 @@ A sub-device driver initializes the v4l2_subdev struct using: | |||
254 | Afterwards you need to initialize subdev->name with a unique name and set the | 283 | Afterwards you need to initialize subdev->name with a unique name and set the |
255 | module owner. This is done for you if you use the i2c helper functions. | 284 | module owner. This is done for you if you use the i2c helper functions. |
256 | 285 | ||
286 | If integration with the media framework is needed, you must initialize the | ||
287 | media_entity struct embedded in the v4l2_subdev struct (entity field) by | ||
288 | calling media_entity_init(): | ||
289 | |||
290 | struct media_pad *pads = &my_sd->pads; | ||
291 | int err; | ||
292 | |||
293 | err = media_entity_init(&sd->entity, npads, pads, 0); | ||
294 | |||
295 | The pads array must have been previously initialized. There is no need to | ||
296 | manually set the struct media_entity type and name fields, but the revision | ||
297 | field must be initialized if needed. | ||
298 | |||
299 | A reference to the entity will be automatically acquired/released when the | ||
300 | subdev device node (if any) is opened/closed. | ||
301 | |||
302 | Don't forget to cleanup the media entity before the sub-device is destroyed: | ||
303 | |||
304 | media_entity_cleanup(&sd->entity); | ||
305 | |||
257 | A device (bridge) driver needs to register the v4l2_subdev with the | 306 | A device (bridge) driver needs to register the v4l2_subdev with the |
258 | v4l2_device: | 307 | v4l2_device: |
259 | 308 | ||
@@ -263,6 +312,9 @@ This can fail if the subdev module disappeared before it could be registered. | |||
263 | After this function was called successfully the subdev->dev field points to | 312 | After this function was called successfully the subdev->dev field points to |
264 | the v4l2_device. | 313 | the v4l2_device. |
265 | 314 | ||
315 | If the v4l2_device parent device has a non-NULL mdev field, the sub-device | ||
316 | entity will be automatically registered with the media device. | ||
317 | |||
266 | You can unregister a sub-device using: | 318 | You can unregister a sub-device using: |
267 | 319 | ||
268 | v4l2_device_unregister_subdev(sd); | 320 | v4l2_device_unregister_subdev(sd); |
@@ -319,6 +371,61 @@ controlled through GPIO pins. This distinction is only relevant when setting | |||
319 | up the device, but once the subdev is registered it is completely transparent. | 371 | up the device, but once the subdev is registered it is completely transparent. |
320 | 372 | ||
321 | 373 | ||
374 | V4L2 sub-device userspace API | ||
375 | ----------------------------- | ||
376 | |||
377 | Beside exposing a kernel API through the v4l2_subdev_ops structure, V4L2 | ||
378 | sub-devices can also be controlled directly by userspace applications. | ||
379 | |||
380 | Device nodes named v4l-subdevX can be created in /dev to access sub-devices | ||
381 | directly. If a sub-device supports direct userspace configuration it must set | ||
382 | the V4L2_SUBDEV_FL_HAS_DEVNODE flag before being registered. | ||
383 | |||
384 | After registering sub-devices, the v4l2_device driver can create device nodes | ||
385 | for all registered sub-devices marked with V4L2_SUBDEV_FL_HAS_DEVNODE by calling | ||
386 | v4l2_device_register_subdev_nodes(). Those device nodes will be automatically | ||
387 | removed when sub-devices are unregistered. | ||
388 | |||
389 | The device node handles a subset of the V4L2 API. | ||
390 | |||
391 | VIDIOC_QUERYCTRL | ||
392 | VIDIOC_QUERYMENU | ||
393 | VIDIOC_G_CTRL | ||
394 | VIDIOC_S_CTRL | ||
395 | VIDIOC_G_EXT_CTRLS | ||
396 | VIDIOC_S_EXT_CTRLS | ||
397 | VIDIOC_TRY_EXT_CTRLS | ||
398 | |||
399 | The controls ioctls are identical to the ones defined in V4L2. They | ||
400 | behave identically, with the only exception that they deal only with | ||
401 | controls implemented in the sub-device. Depending on the driver, those | ||
402 | controls can be also be accessed through one (or several) V4L2 device | ||
403 | nodes. | ||
404 | |||
405 | VIDIOC_DQEVENT | ||
406 | VIDIOC_SUBSCRIBE_EVENT | ||
407 | VIDIOC_UNSUBSCRIBE_EVENT | ||
408 | |||
409 | The events ioctls are identical to the ones defined in V4L2. They | ||
410 | behave identically, with the only exception that they deal only with | ||
411 | events generated by the sub-device. Depending on the driver, those | ||
412 | events can also be reported by one (or several) V4L2 device nodes. | ||
413 | |||
414 | Sub-device drivers that want to use events need to set the | ||
415 | V4L2_SUBDEV_USES_EVENTS v4l2_subdev::flags and initialize | ||
416 | v4l2_subdev::nevents to events queue depth before registering the | ||
417 | sub-device. After registration events can be queued as usual on the | ||
418 | v4l2_subdev::devnode device node. | ||
419 | |||
420 | To properly support events, the poll() file operation is also | ||
421 | implemented. | ||
422 | |||
423 | Private ioctls | ||
424 | |||
425 | All ioctls not in the above list are passed directly to the sub-device | ||
426 | driver through the core::ioctl operation. | ||
427 | |||
428 | |||
322 | I2C sub-device drivers | 429 | I2C sub-device drivers |
323 | ---------------------- | 430 | ---------------------- |
324 | 431 | ||
@@ -457,6 +564,10 @@ You should also set these fields: | |||
457 | Otherwise you give it a pointer to a struct mutex_lock and before any | 564 | Otherwise you give it a pointer to a struct mutex_lock and before any |
458 | of the v4l2_file_operations is called this lock will be taken by the | 565 | of the v4l2_file_operations is called this lock will be taken by the |
459 | core and released afterwards. | 566 | core and released afterwards. |
567 | - prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. | ||
568 | If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. | ||
569 | If you want to have a separate priority state per (group of) device node(s), | ||
570 | then you can point it to your own struct v4l2_prio_state. | ||
460 | - parent: you only set this if v4l2_device was registered with NULL as | 571 | - parent: you only set this if v4l2_device was registered with NULL as |
461 | the parent device struct. This only happens in cases where one hardware | 572 | the parent device struct. This only happens in cases where one hardware |
462 | device has multiple PCI devices that all share the same v4l2_device core. | 573 | device has multiple PCI devices that all share the same v4l2_device core. |
@@ -466,13 +577,34 @@ You should also set these fields: | |||
466 | (cx8802). Since the v4l2_device cannot be associated with a particular | 577 | (cx8802). Since the v4l2_device cannot be associated with a particular |
467 | PCI device it is setup without a parent device. But when the struct | 578 | PCI device it is setup without a parent device. But when the struct |
468 | video_device is setup you do know which parent PCI device to use. | 579 | video_device is setup you do know which parent PCI device to use. |
580 | - flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework | ||
581 | handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct | ||
582 | v4l2_fh. Eventually this flag will disappear once all drivers use the core | ||
583 | priority handling. But for now it has to be set explicitly. | ||
469 | 584 | ||
470 | If you use v4l2_ioctl_ops, then you should set either .unlocked_ioctl or | 585 | If you use v4l2_ioctl_ops, then you should set .unlocked_ioctl to video_ioctl2 |
471 | .ioctl to video_ioctl2 in your v4l2_file_operations struct. | 586 | in your v4l2_file_operations struct. |
587 | |||
588 | Do not use .ioctl! This is deprecated and will go away in the future. | ||
472 | 589 | ||
473 | The v4l2_file_operations struct is a subset of file_operations. The main | 590 | The v4l2_file_operations struct is a subset of file_operations. The main |
474 | difference is that the inode argument is omitted since it is never used. | 591 | difference is that the inode argument is omitted since it is never used. |
475 | 592 | ||
593 | If integration with the media framework is needed, you must initialize the | ||
594 | media_entity struct embedded in the video_device struct (entity field) by | ||
595 | calling media_entity_init(): | ||
596 | |||
597 | struct media_pad *pad = &my_vdev->pad; | ||
598 | int err; | ||
599 | |||
600 | err = media_entity_init(&vdev->entity, 1, pad, 0); | ||
601 | |||
602 | The pads array must have been previously initialized. There is no need to | ||
603 | manually set the struct media_entity type and name fields. | ||
604 | |||
605 | A reference to the entity will be automatically acquired/released when the | ||
606 | video device is opened/closed. | ||
607 | |||
476 | v4l2_file_operations and locking | 608 | v4l2_file_operations and locking |
477 | -------------------------------- | 609 | -------------------------------- |
478 | 610 | ||
@@ -502,6 +634,9 @@ for you. | |||
502 | return err; | 634 | return err; |
503 | } | 635 | } |
504 | 636 | ||
637 | If the v4l2_device parent device has a non-NULL mdev field, the video device | ||
638 | entity will be automatically registered with the media device. | ||
639 | |||
505 | Which device is registered depends on the type argument. The following | 640 | Which device is registered depends on the type argument. The following |
506 | types exist: | 641 | types exist: |
507 | 642 | ||
@@ -577,6 +712,13 @@ release, of course) will return an error as well. | |||
577 | When the last user of the video device node exits, then the vdev->release() | 712 | When the last user of the video device node exits, then the vdev->release() |
578 | callback is called and you can do the final cleanup there. | 713 | callback is called and you can do the final cleanup there. |
579 | 714 | ||
715 | Don't forget to cleanup the media entity associated with the video device if | ||
716 | it has been initialized: | ||
717 | |||
718 | media_entity_cleanup(&vdev->entity); | ||
719 | |||
720 | This can be done from the release callback. | ||
721 | |||
580 | 722 | ||
581 | video_device helper functions | 723 | video_device helper functions |
582 | ----------------------------- | 724 | ----------------------------- |
@@ -636,39 +778,25 @@ struct v4l2_fh | |||
636 | -------------- | 778 | -------------- |
637 | 779 | ||
638 | struct v4l2_fh provides a way to easily keep file handle specific data | 780 | struct v4l2_fh provides a way to easily keep file handle specific data |
639 | that is used by the V4L2 framework. Using v4l2_fh is optional for | 781 | that is used by the V4L2 framework. New drivers must use struct v4l2_fh |
640 | drivers. | 782 | since it is also used to implement priority handling (VIDIOC_G/S_PRIORITY) |
783 | if the video_device flag V4L2_FL_USE_FH_PRIO is also set. | ||
641 | 784 | ||
642 | The users of v4l2_fh (in the V4L2 framework, not the driver) know | 785 | The users of v4l2_fh (in the V4L2 framework, not the driver) know |
643 | whether a driver uses v4l2_fh as its file->private_data pointer by | 786 | whether a driver uses v4l2_fh as its file->private_data pointer by |
644 | testing the V4L2_FL_USES_V4L2_FH bit in video_device->flags. | 787 | testing the V4L2_FL_USES_V4L2_FH bit in video_device->flags. This bit is |
645 | 788 | set whenever v4l2_fh_init() is called. | |
646 | Useful functions: | ||
647 | |||
648 | - v4l2_fh_init() | ||
649 | |||
650 | Initialise the file handle. This *MUST* be performed in the driver's | ||
651 | v4l2_file_operations->open() handler. | ||
652 | |||
653 | - v4l2_fh_add() | ||
654 | 789 | ||
655 | Add a v4l2_fh to video_device file handle list. May be called after | 790 | struct v4l2_fh is allocated as a part of the driver's own file handle |
656 | initialising the file handle. | 791 | structure and file->private_data is set to it in the driver's open |
657 | 792 | function by the driver. | |
658 | - v4l2_fh_del() | ||
659 | |||
660 | Unassociate the file handle from video_device(). The file handle | ||
661 | exit function may now be called. | ||
662 | 793 | ||
663 | - v4l2_fh_exit() | 794 | In many cases the struct v4l2_fh will be embedded in a larger structure. |
795 | In that case you should call v4l2_fh_init+v4l2_fh_add in open() and | ||
796 | v4l2_fh_del+v4l2_fh_exit in release(). | ||
664 | 797 | ||
665 | Uninitialise the file handle. After uninitialisation the v4l2_fh | 798 | Drivers can extract their own file handle structure by using the container_of |
666 | memory can be freed. | 799 | macro. Example: |
667 | |||
668 | struct v4l2_fh is allocated as a part of the driver's own file handle | ||
669 | structure and is set to file->private_data in the driver's open | ||
670 | function by the driver. Drivers can extract their own file handle | ||
671 | structure by using the container_of macro. Example: | ||
672 | 800 | ||
673 | struct my_fh { | 801 | struct my_fh { |
674 | int blah; | 802 | int blah; |
@@ -685,15 +813,21 @@ int my_open(struct file *file) | |||
685 | 813 | ||
686 | ... | 814 | ... |
687 | 815 | ||
816 | my_fh = kzalloc(sizeof(*my_fh), GFP_KERNEL); | ||
817 | |||
818 | ... | ||
819 | |||
688 | ret = v4l2_fh_init(&my_fh->fh, vfd); | 820 | ret = v4l2_fh_init(&my_fh->fh, vfd); |
689 | if (ret) | 821 | if (ret) { |
822 | kfree(my_fh); | ||
690 | return ret; | 823 | return ret; |
824 | } | ||
691 | 825 | ||
692 | v4l2_fh_add(&my_fh->fh); | 826 | ... |
693 | 827 | ||
694 | file->private_data = &my_fh->fh; | 828 | file->private_data = &my_fh->fh; |
695 | 829 | v4l2_fh_add(&my_fh->fh); | |
696 | ... | 830 | return 0; |
697 | } | 831 | } |
698 | 832 | ||
699 | int my_release(struct file *file) | 833 | int my_release(struct file *file) |
@@ -702,8 +836,65 @@ int my_release(struct file *file) | |||
702 | struct my_fh *my_fh = container_of(fh, struct my_fh, fh); | 836 | struct my_fh *my_fh = container_of(fh, struct my_fh, fh); |
703 | 837 | ||
704 | ... | 838 | ... |
839 | v4l2_fh_del(&my_fh->fh); | ||
840 | v4l2_fh_exit(&my_fh->fh); | ||
841 | kfree(my_fh); | ||
842 | return 0; | ||
705 | } | 843 | } |
706 | 844 | ||
845 | Below is a short description of the v4l2_fh functions used: | ||
846 | |||
847 | int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev) | ||
848 | |||
849 | Initialise the file handle. This *MUST* be performed in the driver's | ||
850 | v4l2_file_operations->open() handler. | ||
851 | |||
852 | void v4l2_fh_add(struct v4l2_fh *fh) | ||
853 | |||
854 | Add a v4l2_fh to video_device file handle list. Must be called once the | ||
855 | file handle is completely initialized. | ||
856 | |||
857 | void v4l2_fh_del(struct v4l2_fh *fh) | ||
858 | |||
859 | Unassociate the file handle from video_device(). The file handle | ||
860 | exit function may now be called. | ||
861 | |||
862 | void v4l2_fh_exit(struct v4l2_fh *fh) | ||
863 | |||
864 | Uninitialise the file handle. After uninitialisation the v4l2_fh | ||
865 | memory can be freed. | ||
866 | |||
867 | |||
868 | If struct v4l2_fh is not embedded, then you can use these helper functions: | ||
869 | |||
870 | int v4l2_fh_open(struct file *filp) | ||
871 | |||
872 | This allocates a struct v4l2_fh, initializes it and adds it to the struct | ||
873 | video_device associated with the file struct. | ||
874 | |||
875 | int v4l2_fh_release(struct file *filp) | ||
876 | |||
877 | This deletes it from the struct video_device associated with the file | ||
878 | struct, uninitialised the v4l2_fh and frees it. | ||
879 | |||
880 | These two functions can be plugged into the v4l2_file_operation's open() and | ||
881 | release() ops. | ||
882 | |||
883 | |||
884 | Several drivers need to do something when the first file handle is opened and | ||
885 | when the last file handle closes. Two helper functions were added to check | ||
886 | whether the v4l2_fh struct is the only open filehandle of the associated | ||
887 | device node: | ||
888 | |||
889 | int v4l2_fh_is_singular(struct v4l2_fh *fh) | ||
890 | |||
891 | Returns 1 if the file handle is the only open file handle, else 0. | ||
892 | |||
893 | int v4l2_fh_is_singular_file(struct file *filp) | ||
894 | |||
895 | Same, but it calls v4l2_fh_is_singular with filp->private_data. | ||
896 | |||
897 | |||
707 | V4L2 events | 898 | V4L2 events |
708 | ----------- | 899 | ----------- |
709 | 900 | ||