aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/device-drivers.tmpl2
-rw-r--r--Documentation/DocBook/deviceiobook.tmpl2
-rw-r--r--Documentation/DocBook/drm.tmpl839
-rw-r--r--Documentation/DocBook/kgdb.tmpl692
-rw-r--r--Documentation/DocBook/libata.tmpl65
-rw-r--r--Documentation/DocBook/mac80211.tmpl3
-rw-r--r--Documentation/DocBook/media-entities.tmpl11
-rw-r--r--Documentation/DocBook/mtdnand.tmpl8
-rw-r--r--Documentation/DocBook/sh.tmpl10
-rw-r--r--Documentation/DocBook/tracepoint.tmpl13
-rw-r--r--Documentation/DocBook/v4l/common.xml2
-rw-r--r--Documentation/DocBook/v4l/compat.xml126
-rw-r--r--Documentation/DocBook/v4l/controls.xml36
-rw-r--r--Documentation/DocBook/v4l/dev-event.xml31
-rw-r--r--Documentation/DocBook/v4l/io.xml21
-rw-r--r--Documentation/DocBook/v4l/pixfmt.xml12
-rw-r--r--Documentation/DocBook/v4l/v4l2.xml3
-rw-r--r--Documentation/DocBook/v4l/videodev2.h.xml10
-rw-r--r--Documentation/DocBook/v4l/vidioc-dqevent.xml131
-rw-r--r--Documentation/DocBook/v4l/vidioc-enuminput.xml2
-rw-r--r--Documentation/DocBook/v4l/vidioc-g-parm.xml2
-rw-r--r--Documentation/DocBook/v4l/vidioc-qbuf.xml54
-rw-r--r--Documentation/DocBook/v4l/vidioc-querybuf.xml7
-rw-r--r--Documentation/DocBook/v4l/vidioc-queryctrl.xml2
-rw-r--r--Documentation/DocBook/v4l/vidioc-reqbufs.xml36
-rw-r--r--Documentation/DocBook/v4l/vidioc-subscribe-event.xml133
-rw-r--r--Documentation/DocBook/writing-an-alsa-driver.tmpl27
-rw-r--r--Documentation/DocBook/writing_usb_driver.tmpl2
29 files changed, 1936 insertions, 348 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 325cfd1d6d99..c7e5dc7e8cb3 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -14,7 +14,7 @@ DOCBOOKS := z8530book.xml mcabook.xml device-drivers.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
15 mac80211.xml debugobjects.xml sh.xml regulator.xml \ 15 mac80211.xml debugobjects.xml sh.xml regulator.xml \
16 alsa-driver-api.xml writing-an-alsa-driver.xml \ 16 alsa-driver-api.xml writing-an-alsa-driver.xml \
17 tracepoint.xml media.xml 17 tracepoint.xml media.xml drm.xml
18 18
19### 19###
20# The build process is as follows (targets): 20# The build process is as follows (targets):
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl
index f9a6e2c75f12..1b2dd4fc3db2 100644
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -45,7 +45,7 @@
45 </sect1> 45 </sect1>
46 46
47 <sect1><title>Atomic and pointer manipulation</title> 47 <sect1><title>Atomic and pointer manipulation</title>
48!Iarch/x86/include/asm/atomic_32.h 48!Iarch/x86/include/asm/atomic.h
49!Iarch/x86/include/asm/unaligned.h 49!Iarch/x86/include/asm/unaligned.h
50 </sect1> 50 </sect1>
51 51
diff --git a/Documentation/DocBook/deviceiobook.tmpl b/Documentation/DocBook/deviceiobook.tmpl
index 3ed88126ab8f..c1ed6a49e598 100644
--- a/Documentation/DocBook/deviceiobook.tmpl
+++ b/Documentation/DocBook/deviceiobook.tmpl
@@ -316,7 +316,7 @@ CPU B: spin_unlock_irqrestore(&amp;dev_lock, flags)
316 316
317 <chapter id="pubfunctions"> 317 <chapter id="pubfunctions">
318 <title>Public Functions Provided</title> 318 <title>Public Functions Provided</title>
319!Iarch/x86/include/asm/io_32.h 319!Iarch/x86/include/asm/io.h
320!Elib/iomap.c 320!Elib/iomap.c
321 </chapter> 321 </chapter>
322 322
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
new file mode 100644
index 000000000000..7583dc7cf64d
--- /dev/null
+++ b/Documentation/DocBook/drm.tmpl
@@ -0,0 +1,839 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="drmDevelopersGuide">
6 <bookinfo>
7 <title>Linux DRM Developer's Guide</title>
8
9 <copyright>
10 <year>2008-2009</year>
11 <holder>
12 Intel Corporation (Jesse Barnes &lt;jesse.barnes@intel.com&gt;)
13 </holder>
14 </copyright>
15
16 <legalnotice>
17 <para>
18 The contents of this file may be used under the terms of the GNU
19 General Public License version 2 (the "GPL") as distributed in
20 the kernel source COPYING file.
21 </para>
22 </legalnotice>
23 </bookinfo>
24
25<toc></toc>
26
27 <!-- Introduction -->
28
29 <chapter id="drmIntroduction">
30 <title>Introduction</title>
31 <para>
32 The Linux DRM layer contains code intended to support the needs
33 of complex graphics devices, usually containing programmable
34 pipelines well suited to 3D graphics acceleration. Graphics
35 drivers in the kernel can make use of DRM functions to make
36 tasks like memory management, interrupt handling and DMA easier,
37 and provide a uniform interface to applications.
38 </para>
39 <para>
40 A note on versions: this guide covers features found in the DRM
41 tree, including the TTM memory manager, output configuration and
42 mode setting, and the new vblank internals, in addition to all
43 the regular features found in current kernels.
44 </para>
45 <para>
46 [Insert diagram of typical DRM stack here]
47 </para>
48 </chapter>
49
50 <!-- Internals -->
51
52 <chapter id="drmInternals">
53 <title>DRM Internals</title>
54 <para>
55 This chapter documents DRM internals relevant to driver authors
56 and developers working to add support for the latest features to
57 existing drivers.
58 </para>
59 <para>
60 First, we'll go over some typical driver initialization
61 requirements, like setting up command buffers, creating an
62 initial output configuration, and initializing core services.
63 Subsequent sections will cover core internals in more detail,
64 providing implementation notes and examples.
65 </para>
66 <para>
67 The DRM layer provides several services to graphics drivers,
68 many of them driven by the application interfaces it provides
69 through libdrm, the library that wraps most of the DRM ioctls.
70 These include vblank event handling, memory
71 management, output management, framebuffer management, command
72 submission &amp; fencing, suspend/resume support, and DMA
73 services.
74 </para>
75 <para>
76 The core of every DRM driver is struct drm_device. Drivers
77 will typically statically initialize a drm_device structure,
78 then pass it to drm_init() at load time.
79 </para>
80
81 <!-- Internals: driver init -->
82
83 <sect1>
84 <title>Driver initialization</title>
85 <para>
86 Before calling the DRM initialization routines, the driver must
87 first create and fill out a struct drm_device structure.
88 </para>
89 <programlisting>
90 static struct drm_driver driver = {
91 /* don't use mtrr's here, the Xserver or user space app should
92 * deal with them for intel hardware.
93 */
94 .driver_features =
95 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
96 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_MODESET,
97 .load = i915_driver_load,
98 .unload = i915_driver_unload,
99 .firstopen = i915_driver_firstopen,
100 .lastclose = i915_driver_lastclose,
101 .preclose = i915_driver_preclose,
102 .save = i915_save,
103 .restore = i915_restore,
104 .device_is_agp = i915_driver_device_is_agp,
105 .get_vblank_counter = i915_get_vblank_counter,
106 .enable_vblank = i915_enable_vblank,
107 .disable_vblank = i915_disable_vblank,
108 .irq_preinstall = i915_driver_irq_preinstall,
109 .irq_postinstall = i915_driver_irq_postinstall,
110 .irq_uninstall = i915_driver_irq_uninstall,
111 .irq_handler = i915_driver_irq_handler,
112 .reclaim_buffers = drm_core_reclaim_buffers,
113 .get_map_ofs = drm_core_get_map_ofs,
114 .get_reg_ofs = drm_core_get_reg_ofs,
115 .fb_probe = intelfb_probe,
116 .fb_remove = intelfb_remove,
117 .fb_resize = intelfb_resize,
118 .master_create = i915_master_create,
119 .master_destroy = i915_master_destroy,
120#if defined(CONFIG_DEBUG_FS)
121 .debugfs_init = i915_debugfs_init,
122 .debugfs_cleanup = i915_debugfs_cleanup,
123#endif
124 .gem_init_object = i915_gem_init_object,
125 .gem_free_object = i915_gem_free_object,
126 .gem_vm_ops = &amp;i915_gem_vm_ops,
127 .ioctls = i915_ioctls,
128 .fops = {
129 .owner = THIS_MODULE,
130 .open = drm_open,
131 .release = drm_release,
132 .ioctl = drm_ioctl,
133 .mmap = drm_mmap,
134 .poll = drm_poll,
135 .fasync = drm_fasync,
136#ifdef CONFIG_COMPAT
137 .compat_ioctl = i915_compat_ioctl,
138#endif
139 },
140 .pci_driver = {
141 .name = DRIVER_NAME,
142 .id_table = pciidlist,
143 .probe = probe,
144 .remove = __devexit_p(drm_cleanup_pci),
145 },
146 .name = DRIVER_NAME,
147 .desc = DRIVER_DESC,
148 .date = DRIVER_DATE,
149 .major = DRIVER_MAJOR,
150 .minor = DRIVER_MINOR,
151 .patchlevel = DRIVER_PATCHLEVEL,
152 };
153 </programlisting>
154 <para>
155 In the example above, taken from the i915 DRM driver, the driver
156 sets several flags indicating what core features it supports.
157 We'll go over the individual callbacks in later sections. Since
158 flags indicate which features your driver supports to the DRM
159 core, you need to set most of them prior to calling drm_init(). Some,
160 like DRIVER_MODESET can be set later based on user supplied parameters,
161 but that's the exception rather than the rule.
162 </para>
163 <variablelist>
164 <title>Driver flags</title>
165 <varlistentry>
166 <term>DRIVER_USE_AGP</term>
167 <listitem><para>
168 Driver uses AGP interface
169 </para></listitem>
170 </varlistentry>
171 <varlistentry>
172 <term>DRIVER_REQUIRE_AGP</term>
173 <listitem><para>
174 Driver needs AGP interface to function.
175 </para></listitem>
176 </varlistentry>
177 <varlistentry>
178 <term>DRIVER_USE_MTRR</term>
179 <listitem>
180 <para>
181 Driver uses MTRR interface for mapping memory. Deprecated.
182 </para>
183 </listitem>
184 </varlistentry>
185 <varlistentry>
186 <term>DRIVER_PCI_DMA</term>
187 <listitem><para>
188 Driver is capable of PCI DMA. Deprecated.
189 </para></listitem>
190 </varlistentry>
191 <varlistentry>
192 <term>DRIVER_SG</term>
193 <listitem><para>
194 Driver can perform scatter/gather DMA. Deprecated.
195 </para></listitem>
196 </varlistentry>
197 <varlistentry>
198 <term>DRIVER_HAVE_DMA</term>
199 <listitem><para>Driver supports DMA. Deprecated.</para></listitem>
200 </varlistentry>
201 <varlistentry>
202 <term>DRIVER_HAVE_IRQ</term><term>DRIVER_IRQ_SHARED</term>
203 <listitem>
204 <para>
205 DRIVER_HAVE_IRQ indicates whether the driver has a IRQ
206 handler, DRIVER_IRQ_SHARED indicates whether the device &amp;
207 handler support shared IRQs (note that this is required of
208 PCI drivers).
209 </para>
210 </listitem>
211 </varlistentry>
212 <varlistentry>
213 <term>DRIVER_DMA_QUEUE</term>
214 <listitem>
215 <para>
216 If the driver queues DMA requests and completes them
217 asynchronously, this flag should be set. Deprecated.
218 </para>
219 </listitem>
220 </varlistentry>
221 <varlistentry>
222 <term>DRIVER_FB_DMA</term>
223 <listitem>
224 <para>
225 Driver supports DMA to/from the framebuffer. Deprecated.
226 </para>
227 </listitem>
228 </varlistentry>
229 <varlistentry>
230 <term>DRIVER_MODESET</term>
231 <listitem>
232 <para>
233 Driver supports mode setting interfaces.
234 </para>
235 </listitem>
236 </varlistentry>
237 </variablelist>
238 <para>
239 In this specific case, the driver requires AGP and supports
240 IRQs. DMA, as we'll see, is handled by device specific ioctls
241 in this case. It also supports the kernel mode setting APIs, though
242 unlike in the actual i915 driver source, this example unconditionally
243 exports KMS capability.
244 </para>
245 </sect1>
246
247 <!-- Internals: driver load -->
248
249 <sect1>
250 <title>Driver load</title>
251 <para>
252 In the previous section, we saw what a typical drm_driver
253 structure might look like. One of the more important fields in
254 the structure is the hook for the load function.
255 </para>
256 <programlisting>
257 static struct drm_driver driver = {
258 ...
259 .load = i915_driver_load,
260 ...
261 };
262 </programlisting>
263 <para>
264 The load function has many responsibilities: allocating a driver
265 private structure, specifying supported performance counters,
266 configuring the device (e.g. mapping registers &amp; command
267 buffers), initializing the memory manager, and setting up the
268 initial output configuration.
269 </para>
270 <para>
271 Note that the tasks performed at driver load time must not
272 conflict with DRM client requirements. For instance, if user
273 level mode setting drivers are in use, it would be problematic
274 to perform output discovery &amp; configuration at load time.
275 Likewise, if pre-memory management aware user level drivers are
276 in use, memory management and command buffer setup may need to
277 be omitted. These requirements are driver specific, and care
278 needs to be taken to keep both old and new applications and
279 libraries working. The i915 driver supports the "modeset"
280 module parameter to control whether advanced features are
281 enabled at load time or in legacy fashion. If compatibility is
282 a concern (e.g. with drivers converted over to the new interfaces
283 from the old ones), care must be taken to prevent incompatible
284 device initialization and control with the currently active
285 userspace drivers.
286 </para>
287
288 <sect2>
289 <title>Driver private &amp; performance counters</title>
290 <para>
291 The driver private hangs off the main drm_device structure and
292 can be used for tracking various device specific bits of
293 information, like register offsets, command buffer status,
294 register state for suspend/resume, etc. At load time, a
295 driver can simply allocate one and set drm_device.dev_priv
296 appropriately; at unload the driver can free it and set
297 drm_device.dev_priv to NULL.
298 </para>
299 <para>
300 The DRM supports several counters which can be used for rough
301 performance characterization. Note that the DRM stat counter
302 system is not often used by applications, and supporting
303 additional counters is completely optional.
304 </para>
305 <para>
306 These interfaces are deprecated and should not be used. If performance
307 monitoring is desired, the developer should investigate and
308 potentially enhance the kernel perf and tracing infrastructure to export
309 GPU related performance information to performance monitoring
310 tools and applications.
311 </para>
312 </sect2>
313
314 <sect2>
315 <title>Configuring the device</title>
316 <para>
317 Obviously, device configuration will be device specific.
318 However, there are several common operations: finding a
319 device's PCI resources, mapping them, and potentially setting
320 up an IRQ handler.
321 </para>
322 <para>
323 Finding &amp; mapping resources is fairly straightforward. The
324 DRM wrapper functions, drm_get_resource_start() and
325 drm_get_resource_len() can be used to find BARs on the given
326 drm_device struct. Once those values have been retrieved, the
327 driver load function can call drm_addmap() to create a new
328 mapping for the BAR in question. Note you'll probably want a
329 drm_local_map_t in your driver private structure to track any
330 mappings you create.
331<!-- !Fdrivers/gpu/drm/drm_bufs.c drm_get_resource_* -->
332<!-- !Finclude/drm/drmP.h drm_local_map_t -->
333 </para>
334 <para>
335 if compatibility with other operating systems isn't a concern
336 (DRM drivers can run under various BSD variants and OpenSolaris),
337 native Linux calls can be used for the above, e.g. pci_resource_*
338 and iomap*/iounmap. See the Linux device driver book for more
339 info.
340 </para>
341 <para>
342 Once you have a register map, you can use the DRM_READn() and
343 DRM_WRITEn() macros to access the registers on your device, or
344 use driver specific versions to offset into your MMIO space
345 relative to a driver specific base pointer (see I915_READ for
346 example).
347 </para>
348 <para>
349 If your device supports interrupt generation, you may want to
350 setup an interrupt handler at driver load time as well. This
351 is done using the drm_irq_install() function. If your device
352 supports vertical blank interrupts, it should call
353 drm_vblank_init() to initialize the core vblank handling code before
354 enabling interrupts on your device. This ensures the vblank related
355 structures are allocated and allows the core to handle vblank events.
356 </para>
357<!--!Fdrivers/char/drm/drm_irq.c drm_irq_install-->
358 <para>
359 Once your interrupt handler is registered (it'll use your
360 drm_driver.irq_handler as the actual interrupt handling
361 function), you can safely enable interrupts on your device,
362 assuming any other state your interrupt handler uses is also
363 initialized.
364 </para>
365 <para>
366 Another task that may be necessary during configuration is
367 mapping the video BIOS. On many devices, the VBIOS describes
368 device configuration, LCD panel timings (if any), and contains
369 flags indicating device state. Mapping the BIOS can be done
370 using the pci_map_rom() call, a convenience function that
371 takes care of mapping the actual ROM, whether it has been
372 shadowed into memory (typically at address 0xc0000) or exists
373 on the PCI device in the ROM BAR. Note that once you've
374 mapped the ROM and extracted any necessary information, be
375 sure to unmap it; on many devices the ROM address decoder is
376 shared with other BARs, so leaving it mapped can cause
377 undesired behavior like hangs or memory corruption.
378<!--!Fdrivers/pci/rom.c pci_map_rom-->
379 </para>
380 </sect2>
381
382 <sect2>
383 <title>Memory manager initialization</title>
384 <para>
385 In order to allocate command buffers, cursor memory, scanout
386 buffers, etc., as well as support the latest features provided
387 by packages like Mesa and the X.Org X server, your driver
388 should support a memory manager.
389 </para>
390 <para>
391 If your driver supports memory management (it should!), you'll
392 need to set that up at load time as well. How you intialize
393 it depends on which memory manager you're using, TTM or GEM.
394 </para>
395 <sect3>
396 <title>TTM initialization</title>
397 <para>
398 TTM (for Translation Table Manager) manages video memory and
399 aperture space for graphics devices. TTM supports both UMA devices
400 and devices with dedicated video RAM (VRAM), i.e. most discrete
401 graphics devices. If your device has dedicated RAM, supporting
402 TTM is desireable. TTM also integrates tightly with your
403 driver specific buffer execution function. See the radeon
404 driver for examples.
405 </para>
406 <para>
407 The core TTM structure is the ttm_bo_driver struct. It contains
408 several fields with function pointers for initializing the TTM,
409 allocating and freeing memory, waiting for command completion
410 and fence synchronization, and memory migration. See the
411 radeon_ttm.c file for an example of usage.
412 </para>
413 <para>
414 The ttm_global_reference structure is made up of several fields:
415 </para>
416 <programlisting>
417 struct ttm_global_reference {
418 enum ttm_global_types global_type;
419 size_t size;
420 void *object;
421 int (*init) (struct ttm_global_reference *);
422 void (*release) (struct ttm_global_reference *);
423 };
424 </programlisting>
425 <para>
426 There should be one global reference structure for your memory
427 manager as a whole, and there will be others for each object
428 created by the memory manager at runtime. Your global TTM should
429 have a type of TTM_GLOBAL_TTM_MEM. The size field for the global
430 object should be sizeof(struct ttm_mem_global), and the init and
431 release hooks should point at your driver specific init and
432 release routines, which will probably eventually call
433 ttm_mem_global_init and ttm_mem_global_release respectively.
434 </para>
435 <para>
436 Once your global TTM accounting structure is set up and initialized
437 (done by calling ttm_global_item_ref on the global object you
438 just created), you'll need to create a buffer object TTM to
439 provide a pool for buffer object allocation by clients and the
440 kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO,
441 and its size should be sizeof(struct ttm_bo_global). Again,
442 driver specific init and release functions can be provided,
443 likely eventually calling ttm_bo_global_init and
444 ttm_bo_global_release, respectively. Also like the previous
445 object, ttm_global_item_ref is used to create an initial reference
446 count for the TTM, which will call your initalization function.
447 </para>
448 </sect3>
449 <sect3>
450 <title>GEM initialization</title>
451 <para>
452 GEM is an alternative to TTM, designed specifically for UMA
453 devices. It has simpler initialization and execution requirements
454 than TTM, but has no VRAM management capability. Core GEM
455 initialization is comprised of a basic drm_mm_init call to create
456 a GTT DRM MM object, which provides an address space pool for
457 object allocation. In a KMS configuration, the driver will
458 need to allocate and initialize a command ring buffer following
459 basic GEM initialization. Most UMA devices have a so-called
460 "stolen" memory region, which provides space for the initial
461 framebuffer and large, contiguous memory regions required by the
462 device. This space is not typically managed by GEM, and must
463 be initialized separately into its own DRM MM object.
464 </para>
465 <para>
466 Initialization will be driver specific, and will depend on
467 the architecture of the device. In the case of Intel
468 integrated graphics chips like 965GM, GEM initialization can
469 be done by calling the internal GEM init function,
470 i915_gem_do_init(). Since the 965GM is a UMA device
471 (i.e. it doesn't have dedicated VRAM), GEM will manage
472 making regular RAM available for GPU operations. Memory set
473 aside by the BIOS (called "stolen" memory by the i915
474 driver) will be managed by the DRM memrange allocator; the
475 rest of the aperture will be managed by GEM.
476 <programlisting>
477 /* Basic memrange allocator for stolen space (aka vram) */
478 drm_memrange_init(&amp;dev_priv->vram, 0, prealloc_size);
479 /* Let GEM Manage from end of prealloc space to end of aperture */
480 i915_gem_do_init(dev, prealloc_size, agp_size);
481 </programlisting>
482<!--!Edrivers/char/drm/drm_memrange.c-->
483 </para>
484 <para>
485 Once the memory manager has been set up, we can allocate the
486 command buffer. In the i915 case, this is also done with a
487 GEM function, i915_gem_init_ringbuffer().
488 </para>
489 </sect3>
490 </sect2>
491
492 <sect2>
493 <title>Output configuration</title>
494 <para>
495 The final initialization task is output configuration. This involves
496 finding and initializing the CRTCs, encoders and connectors
497 for your device, creating an initial configuration and
498 registering a framebuffer console driver.
499 </para>
500 <sect3>
501 <title>Output discovery and initialization</title>
502 <para>
503 Several core functions exist to create CRTCs, encoders and
504 connectors, namely drm_crtc_init(), drm_connector_init() and
505 drm_encoder_init(), along with several "helper" functions to
506 perform common tasks.
507 </para>
508 <para>
509 Connectors should be registered with sysfs once they've been
510 detected and initialized, using the
511 drm_sysfs_connector_add() function. Likewise, when they're
512 removed from the system, they should be destroyed with
513 drm_sysfs_connector_remove().
514 </para>
515 <programlisting>
516<![CDATA[
517void intel_crt_init(struct drm_device *dev)
518{
519 struct drm_connector *connector;
520 struct intel_output *intel_output;
521
522 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
523 if (!intel_output)
524 return;
525
526 connector = &intel_output->base;
527 drm_connector_init(dev, &intel_output->base,
528 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
529
530 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
531 DRM_MODE_ENCODER_DAC);
532
533 drm_mode_connector_attach_encoder(&intel_output->base,
534 &intel_output->enc);
535
536 /* Set up the DDC bus. */
537 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
538 if (!intel_output->ddc_bus) {
539 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
540 "failed.\n");
541 return;
542 }
543
544 intel_output->type = INTEL_OUTPUT_ANALOG;
545 connector->interlace_allowed = 0;
546 connector->doublescan_allowed = 0;
547
548 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
549 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
550
551 drm_sysfs_connector_add(connector);
552}
553]]>
554 </programlisting>
555 <para>
556 In the example above (again, taken from the i915 driver), a
557 CRT connector and encoder combination is created. A device
558 specific i2c bus is also created, for fetching EDID data and
559 performing monitor detection. Once the process is complete,
560 the new connector is regsitered with sysfs, to make its
561 properties available to applications.
562 </para>
563 <sect4>
564 <title>Helper functions and core functions</title>
565 <para>
566 Since many PC-class graphics devices have similar display output
567 designs, the DRM provides a set of helper functions to make
568 output management easier. The core helper routines handle
569 encoder re-routing and disabling of unused functions following
570 mode set. Using the helpers is optional, but recommended for
571 devices with PC-style architectures (i.e. a set of display planes
572 for feeding pixels to encoders which are in turn routed to
573 connectors). Devices with more complex requirements needing
574 finer grained management can opt to use the core callbacks
575 directly.
576 </para>
577 <para>
578 [Insert typical diagram here.] [Insert OMAP style config here.]
579 </para>
580 </sect4>
581 <para>
582 For each encoder, CRTC and connector, several functions must
583 be provided, depending on the object type. Encoder objects
584 need should provide a DPMS (basically on/off) function, mode fixup
585 (for converting requested modes into native hardware timings),
586 and prepare, set and commit functions for use by the core DRM
587 helper functions. Connector helpers need to provide mode fetch and
588 validity functions as well as an encoder matching function for
589 returing an ideal encoder for a given connector. The core
590 connector functions include a DPMS callback, (deprecated)
591 save/restore routines, detection, mode probing, property handling,
592 and cleanup functions.
593 </para>
594<!--!Edrivers/char/drm/drm_crtc.h-->
595<!--!Edrivers/char/drm/drm_crtc.c-->
596<!--!Edrivers/char/drm/drm_crtc_helper.c-->
597 </sect3>
598 </sect2>
599 </sect1>
600
601 <!-- Internals: vblank handling -->
602
603 <sect1>
604 <title>VBlank event handling</title>
605 <para>
606 The DRM core exposes two vertical blank related ioctls:
607 DRM_IOCTL_WAIT_VBLANK and DRM_IOCTL_MODESET_CTL.
608<!--!Edrivers/char/drm/drm_irq.c-->
609 </para>
610 <para>
611 DRM_IOCTL_WAIT_VBLANK takes a struct drm_wait_vblank structure
612 as its argument, and is used to block or request a signal when a
613 specified vblank event occurs.
614 </para>
615 <para>
616 DRM_IOCTL_MODESET_CTL should be called by application level
617 drivers before and after mode setting, since on many devices the
618 vertical blank counter will be reset at that time. Internally,
619 the DRM snapshots the last vblank count when the ioctl is called
620 with the _DRM_PRE_MODESET command so that the counter won't go
621 backwards (which is dealt with when _DRM_POST_MODESET is used).
622 </para>
623 <para>
624 To support the functions above, the DRM core provides several
625 helper functions for tracking vertical blank counters, and
626 requires drivers to provide several callbacks:
627 get_vblank_counter(), enable_vblank() and disable_vblank(). The
628 core uses get_vblank_counter() to keep the counter accurate
629 across interrupt disable periods. It should return the current
630 vertical blank event count, which is often tracked in a device
631 register. The enable and disable vblank callbacks should enable
632 and disable vertical blank interrupts, respectively. In the
633 absence of DRM clients waiting on vblank events, the core DRM
634 code will use the disable_vblank() function to disable
635 interrupts, which saves power. They'll be re-enabled again when
636 a client calls the vblank wait ioctl above.
637 </para>
638 <para>
639 Devices that don't provide a count register can simply use an
640 internal atomic counter incremented on every vertical blank
641 interrupt, and can make their enable and disable vblank
642 functions into no-ops.
643 </para>
644 </sect1>
645
646 <sect1>
647 <title>Memory management</title>
648 <para>
649 The memory manager lies at the heart of many DRM operations, and
650 is also required to support advanced client features like OpenGL
651 pbuffers. The DRM currently contains two memory managers, TTM
652 and GEM.
653 </para>
654
655 <sect2>
656 <title>The Translation Table Manager (TTM)</title>
657 <para>
658 TTM was developed by Tungsten Graphics, primarily by Thomas
659 Hellström, and is intended to be a flexible, high performance
660 graphics memory manager.
661 </para>
662 <para>
663 Drivers wishing to support TTM must fill out a drm_bo_driver
664 structure.
665 </para>
666 <para>
667 TTM design background and information belongs here.
668 </para>
669 </sect2>
670
671 <sect2>
672 <title>The Graphics Execution Manager (GEM)</title>
673 <para>
674 GEM is an Intel project, authored by Eric Anholt and Keith
675 Packard. It provides simpler interfaces than TTM, and is well
676 suited for UMA devices.
677 </para>
678 <para>
679 GEM-enabled drivers must provide gem_init_object() and
680 gem_free_object() callbacks to support the core memory
681 allocation routines. They should also provide several driver
682 specific ioctls to support command execution, pinning, buffer
683 read &amp; write, mapping, and domain ownership transfers.
684 </para>
685 <para>
686 On a fundamental level, GEM involves several operations: memory
687 allocation and freeing, command execution, and aperture management
688 at command execution time. Buffer object allocation is relatively
689 straightforward and largely provided by Linux's shmem layer, which
690 provides memory to back each object. When mapped into the GTT
691 or used in a command buffer, the backing pages for an object are
692 flushed to memory and marked write combined so as to be coherent
693 with the GPU. Likewise, when the GPU finishes rendering to an object,
694 if the CPU accesses it, it must be made coherent with the CPU's view
695 of memory, usually involving GPU cache flushing of various kinds.
696 This core CPU&lt;-&gt;GPU coherency management is provided by the GEM
697 set domain function, which evaluates an object's current domain and
698 performs any necessary flushing or synchronization to put the object
699 into the desired coherency domain (note that the object may be busy,
700 i.e. an active render target; in that case the set domain function
701 will block the client and wait for rendering to complete before
702 performing any necessary flushing operations).
703 </para>
704 <para>
705 Perhaps the most important GEM function is providing a command
706 execution interface to clients. Client programs construct command
707 buffers containing references to previously allocated memory objects
708 and submit them to GEM. At that point, GEM will take care to bind
709 all the objects into the GTT, execute the buffer, and provide
710 necessary synchronization between clients accessing the same buffers.
711 This often involves evicting some objects from the GTT and re-binding
712 others (a fairly expensive operation), and providing relocation
713 support which hides fixed GTT offsets from clients. Clients must
714 take care not to submit command buffers that reference more objects
715 than can fit in the GTT or GEM will reject them and no rendering
716 will occur. Similarly, if several objects in the buffer require
717 fence registers to be allocated for correct rendering (e.g. 2D blits
718 on pre-965 chips), care must be taken not to require more fence
719 registers than are available to the client. Such resource management
720 should be abstracted from the client in libdrm.
721 </para>
722 </sect2>
723
724 </sect1>
725
726 <!-- Output management -->
727 <sect1>
728 <title>Output management</title>
729 <para>
730 At the core of the DRM output management code is a set of
731 structures representing CRTCs, encoders and connectors.
732 </para>
733 <para>
734 A CRTC is an abstraction representing a part of the chip that
735 contains a pointer to a scanout buffer. Therefore, the number
736 of CRTCs available determines how many independent scanout
737 buffers can be active at any given time. The CRTC structure
738 contains several fields to support this: a pointer to some video
739 memory, a display mode, and an (x, y) offset into the video
740 memory to support panning or configurations where one piece of
741 video memory spans multiple CRTCs.
742 </para>
743 <para>
744 An encoder takes pixel data from a CRTC and converts it to a
745 format suitable for any attached connectors. On some devices,
746 it may be possible to have a CRTC send data to more than one
747 encoder. In that case, both encoders would receive data from
748 the same scanout buffer, resulting in a "cloned" display
749 configuration across the connectors attached to each encoder.
750 </para>
751 <para>
752 A connector is the final destination for pixel data on a device,
753 and usually connects directly to an external display device like
754 a monitor or laptop panel. A connector can only be attached to
755 one encoder at a time. The connector is also the structure
756 where information about the attached display is kept, so it
757 contains fields for display data, EDID data, DPMS &amp;
758 connection status, and information about modes supported on the
759 attached displays.
760 </para>
761<!--!Edrivers/char/drm/drm_crtc.c-->
762 </sect1>
763
764 <sect1>
765 <title>Framebuffer management</title>
766 <para>
767 In order to set a mode on a given CRTC, encoder and connector
768 configuration, clients need to provide a framebuffer object which
769 will provide a source of pixels for the CRTC to deliver to the encoder(s)
770 and ultimately the connector(s) in the configuration. A framebuffer
771 is fundamentally a driver specific memory object, made into an opaque
772 handle by the DRM addfb function. Once an fb has been created this
773 way it can be passed to the KMS mode setting routines for use in
774 a configuration.
775 </para>
776 </sect1>
777
778 <sect1>
779 <title>Command submission &amp; fencing</title>
780 <para>
781 This should cover a few device specific command submission
782 implementations.
783 </para>
784 </sect1>
785
786 <sect1>
787 <title>Suspend/resume</title>
788 <para>
789 The DRM core provides some suspend/resume code, but drivers
790 wanting full suspend/resume support should provide save() and
791 restore() functions. These will be called at suspend,
792 hibernate, or resume time, and should perform any state save or
793 restore required by your device across suspend or hibernate
794 states.
795 </para>
796 </sect1>
797
798 <sect1>
799 <title>DMA services</title>
800 <para>
801 This should cover how DMA mapping etc. is supported by the core.
802 These functions are deprecated and should not be used.
803 </para>
804 </sect1>
805 </chapter>
806
807 <!-- External interfaces -->
808
809 <chapter id="drmExternals">
810 <title>Userland interfaces</title>
811 <para>
812 The DRM core exports several interfaces to applications,
813 generally intended to be used through corresponding libdrm
814 wrapper functions. In addition, drivers export device specific
815 interfaces for use by userspace drivers &amp; device aware
816 applications through ioctls and sysfs files.
817 </para>
818 <para>
819 External interfaces include: memory mapping, context management,
820 DMA operations, AGP management, vblank control, fence
821 management, memory management, and output management.
822 </para>
823 <para>
824 Cover generic ioctls and sysfs layout here. Only need high
825 level info, since man pages will cover the rest.
826 </para>
827 </chapter>
828
829 <!-- API reference -->
830
831 <appendix id="drmDriverApi">
832 <title>DRM Driver API</title>
833 <para>
834 Include auto-generated API reference here (need to reference it
835 from paragraphs above too).
836 </para>
837 </appendix>
838
839</book>
diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl
index 5cff41a5fa7c..55f12ac37acd 100644
--- a/Documentation/DocBook/kgdb.tmpl
+++ b/Documentation/DocBook/kgdb.tmpl
@@ -4,7 +4,7 @@
4 4
5<book id="kgdbOnLinux"> 5<book id="kgdbOnLinux">
6 <bookinfo> 6 <bookinfo>
7 <title>Using kgdb and the kgdb Internals</title> 7 <title>Using kgdb, kdb and the kernel debugger internals</title>
8 8
9 <authorgroup> 9 <authorgroup>
10 <author> 10 <author>
@@ -17,33 +17,8 @@
17 </affiliation> 17 </affiliation>
18 </author> 18 </author>
19 </authorgroup> 19 </authorgroup>
20
21 <authorgroup>
22 <author>
23 <firstname>Tom</firstname>
24 <surname>Rini</surname>
25 <affiliation>
26 <address>
27 <email>trini@kernel.crashing.org</email>
28 </address>
29 </affiliation>
30 </author>
31 </authorgroup>
32
33 <authorgroup>
34 <author>
35 <firstname>Amit S.</firstname>
36 <surname>Kale</surname>
37 <affiliation>
38 <address>
39 <email>amitkale@linsyssoft.com</email>
40 </address>
41 </affiliation>
42 </author>
43 </authorgroup>
44
45 <copyright> 20 <copyright>
46 <year>2008</year> 21 <year>2008,2010</year>
47 <holder>Wind River Systems, Inc.</holder> 22 <holder>Wind River Systems, Inc.</holder>
48 </copyright> 23 </copyright>
49 <copyright> 24 <copyright>
@@ -69,41 +44,76 @@
69 <chapter id="Introduction"> 44 <chapter id="Introduction">
70 <title>Introduction</title> 45 <title>Introduction</title>
71 <para> 46 <para>
72 kgdb is a source level debugger for linux kernel. It is used along 47 The kernel has two different debugger front ends (kdb and kgdb)
73 with gdb to debug a linux kernel. The expectation is that gdb can 48 which interface to the debug core. It is possible to use either
74 be used to "break in" to the kernel to inspect memory, variables 49 of the debugger front ends and dynamically transition between them
75 and look through call stack information similar to what an 50 if you configure the kernel properly at compile and runtime.
76 application developer would use gdb for. It is possible to place 51 </para>
77 breakpoints in kernel code and perform some limited execution 52 <para>
78 stepping. 53 Kdb is simplistic shell-style interface which you can use on a
54 system console with a keyboard or serial console. You can use it
55 to inspect memory, registers, process lists, dmesg, and even set
56 breakpoints to stop in a certain location. Kdb is not a source
57 level debugger, although you can set breakpoints and execute some
58 basic kernel run control. Kdb is mainly aimed at doing some
59 analysis to aid in development or diagnosing kernel problems. You
60 can access some symbols by name in kernel built-ins or in kernel
61 modules if the code was built
62 with <symbol>CONFIG_KALLSYMS</symbol>.
63 </para>
64 <para>
65 Kgdb is intended to be used as a source level debugger for the
66 Linux kernel. It is used along with gdb to debug a Linux kernel.
67 The expectation is that gdb can be used to "break in" to the
68 kernel to inspect memory, variables and look through call stack
69 information similar to the way an application developer would use
70 gdb to debug an application. It is possible to place breakpoints
71 in kernel code and perform some limited execution stepping.
79 </para> 72 </para>
80 <para> 73 <para>
81 Two machines are required for using kgdb. One of these machines is a 74 Two machines are required for using kgdb. One of these machines is
82 development machine and the other is a test machine. The kernel 75 a development machine and the other is the target machine. The
83 to be debugged runs on the test machine. The development machine 76 kernel to be debugged runs on the target machine. The development
84 runs an instance of gdb against the vmlinux file which contains 77 machine runs an instance of gdb against the vmlinux file which
85 the symbols (not boot image such as bzImage, zImage, uImage...). 78 contains the symbols (not boot image such as bzImage, zImage,
86 In gdb the developer specifies the connection parameters and 79 uImage...). In gdb the developer specifies the connection
87 connects to kgdb. The type of connection a developer makes with 80 parameters and connects to kgdb. The type of connection a
88 gdb depends on the availability of kgdb I/O modules compiled as 81 developer makes with gdb depends on the availability of kgdb I/O
89 builtin's or kernel modules in the test machine's kernel. 82 modules compiled as built-ins or loadable kernel modules in the test
83 machine's kernel.
90 </para> 84 </para>
91 </chapter> 85 </chapter>
92 <chapter id="CompilingAKernel"> 86 <chapter id="CompilingAKernel">
93 <title>Compiling a kernel</title> 87 <title>Compiling a kernel</title>
88 <para>
89 <itemizedlist>
90 <listitem><para>In order to enable compilation of kdb, you must first enable kgdb.</para></listitem>
91 <listitem><para>The kgdb test compile options are described in the kgdb test suite chapter.</para></listitem>
92 </itemizedlist>
93 </para>
94 <sect1 id="CompileKGDB">
95 <title>Kernel config options for kgdb</title>
94 <para> 96 <para>
95 To enable <symbol>CONFIG_KGDB</symbol> you should first turn on 97 To enable <symbol>CONFIG_KGDB</symbol> you should first turn on
96 "Prompt for development and/or incomplete code/drivers" 98 "Prompt for development and/or incomplete code/drivers"
97 (CONFIG_EXPERIMENTAL) in "General setup", then under the 99 (CONFIG_EXPERIMENTAL) in "General setup", then under the
98 "Kernel debugging" select "KGDB: kernel debugging with remote gdb". 100 "Kernel debugging" select "KGDB: kernel debugger".
101 </para>
102 <para>
103 While it is not a hard requirement that you have symbols in your
104 vmlinux file, gdb tends not to be very useful without the symbolic
105 data, so you will want to turn
106 on <symbol>CONFIG_DEBUG_INFO</symbol> which is called "Compile the
107 kernel with debug info" in the config menu.
99 </para> 108 </para>
100 <para> 109 <para>
101 It is advised, but not required that you turn on the 110 It is advised, but not required that you turn on the
102 CONFIG_FRAME_POINTER kernel option. This option inserts code to 111 <symbol>CONFIG_FRAME_POINTER</symbol> kernel option which is called "Compile the
103 into the compiled executable which saves the frame information in 112 kernel with frame pointers" in the config menu. This option
104 registers or on the stack at different points which will allow a 113 inserts code to into the compiled executable which saves the frame
105 debugger such as gdb to more accurately construct stack back traces 114 information in registers or on the stack at different points which
106 while debugging the kernel. 115 allows a debugger such as gdb to more accurately construct
116 stack back traces while debugging the kernel.
107 </para> 117 </para>
108 <para> 118 <para>
109 If the architecture that you are using supports the kernel option 119 If the architecture that you are using supports the kernel option
@@ -116,38 +126,160 @@
116 this option. 126 this option.
117 </para> 127 </para>
118 <para> 128 <para>
119 Next you should choose one of more I/O drivers to interconnect debugging 129 Next you should choose one of more I/O drivers to interconnect
120 host and debugged target. Early boot debugging requires a KGDB 130 debugging host and debugged target. Early boot debugging requires
121 I/O driver that supports early debugging and the driver must be 131 a KGDB I/O driver that supports early debugging and the driver
122 built into the kernel directly. Kgdb I/O driver configuration 132 must be built into the kernel directly. Kgdb I/O driver
123 takes place via kernel or module parameters, see following 133 configuration takes place via kernel or module parameters which
124 chapter. 134 you can learn more about in the in the section that describes the
135 parameter "kgdboc".
125 </para> 136 </para>
126 <para> 137 <para>Here is an example set of .config symbols to enable or
127 The kgdb test compile options are described in the kgdb test suite chapter. 138 disable for kgdb:
139 <itemizedlist>
140 <listitem><para># CONFIG_DEBUG_RODATA is not set</para></listitem>
141 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem>
142 <listitem><para>CONFIG_KGDB=y</para></listitem>
143 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem>
144 </itemizedlist>
128 </para> 145 </para>
129 146 </sect1>
147 <sect1 id="CompileKDB">
148 <title>Kernel config options for kdb</title>
149 <para>Kdb is quite a bit more complex than the simple gdbstub
150 sitting on top of the kernel's debug core. Kdb must implement a
151 shell, and also adds some helper functions in other parts of the
152 kernel, responsible for printing out interesting data such as what
153 you would see if you ran "lsmod", or "ps". In order to build kdb
154 into the kernel you follow the same steps as you would for kgdb.
155 </para>
156 <para>The main config option for kdb
157 is <symbol>CONFIG_KGDB_KDB</symbol> which is called "KGDB_KDB:
158 include kdb frontend for kgdb" in the config menu. In theory you
159 would have already also selected an I/O driver such as the
160 CONFIG_KGDB_SERIAL_CONSOLE interface if you plan on using kdb on a
161 serial port, when you were configuring kgdb.
162 </para>
163 <para>If you want to use a PS/2-style keyboard with kdb, you would
164 select CONFIG_KDB_KEYBOARD which is called "KGDB_KDB: keyboard as
165 input device" in the config menu. The CONFIG_KDB_KEYBOARD option
166 is not used for anything in the gdb interface to kgdb. The
167 CONFIG_KDB_KEYBOARD option only works with kdb.
168 </para>
169 <para>Here is an example set of .config symbols to enable/disable kdb:
170 <itemizedlist>
171 <listitem><para># CONFIG_DEBUG_RODATA is not set</para></listitem>
172 <listitem><para>CONFIG_FRAME_POINTER=y</para></listitem>
173 <listitem><para>CONFIG_KGDB=y</para></listitem>
174 <listitem><para>CONFIG_KGDB_SERIAL_CONSOLE=y</para></listitem>
175 <listitem><para>CONFIG_KGDB_KDB=y</para></listitem>
176 <listitem><para>CONFIG_KDB_KEYBOARD=y</para></listitem>
177 </itemizedlist>
178 </para>
179 </sect1>
130 </chapter> 180 </chapter>
131 <chapter id="EnableKGDB"> 181 <chapter id="kgdbKernelArgs">
132 <title>Enable kgdb for debugging</title> 182 <title>Kernel Debugger Boot Arguments</title>
133 <para> 183 <para>This section describes the various runtime kernel
134 In order to use kgdb you must activate it by passing configuration 184 parameters that affect the configuration of the kernel debugger.
135 information to one of the kgdb I/O drivers. If you do not pass any 185 The following chapter covers using kdb and kgdb as well as
136 configuration information kgdb will not do anything at all. Kgdb 186 provides some examples of the configuration parameters.</para>
137 will only actively hook up to the kernel trap hooks if a kgdb I/O 187 <sect1 id="kgdboc">
138 driver is loaded and configured. If you unconfigure a kgdb I/O 188 <title>Kernel parameter: kgdboc</title>
139 driver, kgdb will unregister all the kernel hook points. 189 <para>The kgdboc driver was originally an abbreviation meant to
190 stand for "kgdb over console". Today it is the primary mechanism
191 to configure how to communicate from gdb to kgdb as well as the
192 devices you want to use to interact with the kdb shell.
193 </para>
194 <para>For kgdb/gdb, kgdboc is designed to work with a single serial
195 port. It is intended to cover the circumstance where you want to
196 use a serial console as your primary console as well as using it to
197 perform kernel debugging. It is also possible to use kgdb on a
198 serial port which is not designated as a system console. Kgdboc
199 may be configured as a kernel built-in or a kernel loadable module.
200 You can only make use of <constant>kgdbwait</constant> and early
201 debugging if you build kgdboc into the kernel as a built-in.
140 </para> 202 </para>
203 <sect2 id="kgdbocArgs">
204 <title>kgdboc arguments</title>
205 <para>Usage: <constant>kgdboc=[kbd][[,]serial_device][,baud]</constant></para>
206 <sect3 id="kgdbocArgs1">
207 <title>Using loadable module or built-in</title>
141 <para> 208 <para>
142 All drivers can be reconfigured at run time, if 209 <orderedlist>
143 <symbol>CONFIG_SYSFS</symbol> and <symbol>CONFIG_MODULES</symbol> 210 <listitem><para>As a kernel built-in:</para>
144 are enabled, by echo'ing a new config string to 211 <para>Use the kernel boot argument: <constant>kgdboc=&lt;tty-device&gt;,[baud]</constant></para></listitem>
145 <constant>/sys/module/&lt;driver&gt;/parameter/&lt;option&gt;</constant>. 212 <listitem>
146 The driver can be unconfigured by passing an empty string. You cannot 213 <para>As a kernel loadable module:</para>
147 change the configuration while the debugger is attached. Make sure 214 <para>Use the command: <constant>modprobe kgdboc kgdboc=&lt;tty-device&gt;,[baud]</constant></para>
148 to detach the debugger with the <constant>detach</constant> command 215 <para>Here are two examples of how you might formate the kgdboc
149 prior to trying unconfigure a kgdb I/O driver. 216 string. The first is for an x86 target using the first serial port.
217 The second example is for the ARM Versatile AB using the second
218 serial port.
219 <orderedlist>
220 <listitem><para><constant>kgdboc=ttyS0,115200</constant></para></listitem>
221 <listitem><para><constant>kgdboc=ttyAMA1,115200</constant></para></listitem>
222 </orderedlist>
150 </para> 223 </para>
224 </listitem>
225 </orderedlist></para>
226 </sect3>
227 <sect3 id="kgdbocArgs2">
228 <title>Configure kgdboc at runtime with sysfs</title>
229 <para>At run time you can enable or disable kgdboc by echoing a
230 parameters into the sysfs. Here are two examples:</para>
231 <orderedlist>
232 <listitem><para>Enable kgdboc on ttyS0</para>
233 <para><constant>echo ttyS0 &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para></listitem>
234 <listitem><para>Disable kgdboc</para>
235 <para><constant>echo "" &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para></listitem>
236 </orderedlist>
237 <para>NOTE: You do not need to specify the baud if you are
238 configuring the console on tty which is already configured or
239 open.</para>
240 </sect3>
241 <sect3 id="kgdbocArgs3">
242 <title>More examples</title>
243 <para>You can configure kgdboc to use the keyboard, and or a serial device
244 depending on if you are using kdb and or kgdb, in one of the
245 following scenarios.
246 <orderedlist>
247 <listitem><para>kdb and kgdb over only a serial port</para>
248 <para><constant>kgdboc=&lt;serial_device&gt;[,baud]</constant></para>
249 <para>Example: <constant>kgdboc=ttyS0,115200</constant></para>
250 </listitem>
251 <listitem><para>kdb and kgdb with keyboard and a serial port</para>
252 <para><constant>kgdboc=kbd,&lt;serial_device&gt;[,baud]</constant></para>
253 <para>Example: <constant>kgdboc=kbd,ttyS0,115200</constant></para>
254 </listitem>
255 <listitem><para>kdb with a keyboard</para>
256 <para><constant>kgdboc=kbd</constant></para>
257 </listitem>
258 </orderedlist>
259 </para>
260 </sect3>
261 <para>NOTE: Kgdboc does not support interrupting the target via the
262 gdb remote protocol. You must manually send a sysrq-g unless you
263 have a proxy that splits console output to a terminal program.
264 A console proxy has a separate TCP port for the debugger and a separate
265 TCP port for the "human" console. The proxy can take care of sending
266 the sysrq-g for you.
267 </para>
268 <para>When using kgdboc with no debugger proxy, you can end up
269 connecting the debugger at one of two entry points. If an
270 exception occurs after you have loaded kgdboc, a message should
271 print on the console stating it is waiting for the debugger. In
272 this case you disconnect your terminal program and then connect the
273 debugger in its place. If you want to interrupt the target system
274 and forcibly enter a debug session you have to issue a Sysrq
275 sequence and then type the letter <constant>g</constant>. Then
276 you disconnect the terminal session and connect gdb. Your options
277 if you don't like this are to hack gdb to send the sysrq-g for you
278 as well as on the initial connect, or to use a debugger proxy that
279 allows an unmodified gdb to do the debugging.
280 </para>
281 </sect2>
282 </sect1>
151 <sect1 id="kgdbwait"> 283 <sect1 id="kgdbwait">
152 <title>Kernel parameter: kgdbwait</title> 284 <title>Kernel parameter: kgdbwait</title>
153 <para> 285 <para>
@@ -162,103 +294,204 @@
162 </para> 294 </para>
163 <para> 295 <para>
164 The kernel will stop and wait as early as the I/O driver and 296 The kernel will stop and wait as early as the I/O driver and
165 architecture will allow when you use this option. If you build the 297 architecture allows when you use this option. If you build the
166 kgdb I/O driver as a kernel module kgdbwait will not do anything. 298 kgdb I/O driver as a loadable kernel module kgdbwait will not do
299 anything.
167 </para> 300 </para>
168 </sect1> 301 </sect1>
169 <sect1 id="kgdboc"> 302 <sect1 id="kgdbcon">
170 <title>Kernel parameter: kgdboc</title> 303 <title>Kernel parameter: kgdbcon</title>
171 <para> 304 <para> The kgdbcon feature allows you to see printk() messages
172 The kgdboc driver was originally an abbreviation meant to stand for 305 inside gdb while gdb is connected to the kernel. Kdb does not make
173 "kgdb over console". Kgdboc is designed to work with a single 306 use of the kgdbcon feature.
174 serial port. It was meant to cover the circumstance 307 </para>
175 where you wanted to use a serial console as your primary console as 308 <para>Kgdb supports using the gdb serial protocol to send console
176 well as using it to perform kernel debugging. Of course you can 309 messages to the debugger when the debugger is connected and running.
177 also use kgdboc without assigning a console to the same port. 310 There are two ways to activate this feature.
311 <orderedlist>
312 <listitem><para>Activate with the kernel command line option:</para>
313 <para><constant>kgdbcon</constant></para>
314 </listitem>
315 <listitem><para>Use sysfs before configuring an I/O driver</para>
316 <para>
317 <constant>echo 1 &gt; /sys/module/kgdb/parameters/kgdb_use_con</constant>
318 </para>
319 <para>
320 NOTE: If you do this after you configure the kgdb I/O driver, the
321 setting will not take effect until the next point the I/O is
322 reconfigured.
323 </para>
324 </listitem>
325 </orderedlist>
326 <para>IMPORTANT NOTE: You cannot use kgdboc + kgdbcon on a tty that is an
327 active system console. An example incorrect usage is <constant>console=ttyS0,115200 kgdboc=ttyS0 kgdbcon</constant>
328 </para>
329 <para>It is possible to use this option with kgdboc on a tty that is not a system console.
330 </para>
178 </para> 331 </para>
179 <sect2 id="UsingKgdboc"> 332 </sect1>
180 <title>Using kgdboc</title> 333 </chapter>
181 <para> 334 <chapter id="usingKDB">
182 You can configure kgdboc via sysfs or a module or kernel boot line 335 <title>Using kdb</title>
183 parameter depending on if you build with CONFIG_KGDBOC as a module
184 or built-in.
185 <orderedlist>
186 <listitem><para>From the module load or build-in</para>
187 <para><constant>kgdboc=&lt;tty-device&gt;,[baud]</constant></para>
188 <para> 336 <para>
189 The example here would be if your console port was typically ttyS0, you would use something like <constant>kgdboc=ttyS0,115200</constant> or on the ARM Versatile AB you would likely use <constant>kgdboc=ttyAMA0,115200</constant> 337 </para>
338 <sect1 id="quickKDBserial">
339 <title>Quick start for kdb on a serial port</title>
340 <para>This is a quick example of how to use kdb.</para>
341 <para><orderedlist>
342 <listitem><para>Boot kernel with arguments:
343 <itemizedlist>
344 <listitem><para><constant>console=ttyS0,115200 kgdboc=ttyS0,115200</constant></para></listitem>
345 </itemizedlist></para>
346 <para>OR</para>
347 <para>Configure kgdboc after the kernel booted; assuming you are using a serial port console:
348 <itemizedlist>
349 <listitem><para><constant>echo ttyS0 &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para></listitem>
350 </itemizedlist>
190 </para> 351 </para>
191 </listitem> 352 </listitem>
192 <listitem><para>From sysfs</para> 353 <listitem><para>Enter the kernel debugger manually or by waiting for an oops or fault. There are several ways you can enter the kernel debugger manually; all involve using the sysrq-g, which means you must have enabled CONFIG_MAGIC_SYSRQ=y in your kernel config.</para>
193 <para><constant>echo ttyS0 &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para> 354 <itemizedlist>
355 <listitem><para>When logged in as root or with a super user session you can run:</para>
356 <para><constant>echo g &gt; /proc/sysrq-trigger</constant></para></listitem>
357 <listitem><para>Example using minicom 2.2</para>
358 <para>Press: <constant>Control-a</constant></para>
359 <para>Press: <constant>f</constant></para>
360 <para>Press: <constant>g</constant></para>
194 </listitem> 361 </listitem>
195 </orderedlist> 362 <listitem><para>When you have telneted to a terminal server that supports sending a remote break</para>
196 </para> 363 <para>Press: <constant>Control-]</constant></para>
197 <para> 364 <para>Type in:<constant>send break</constant></para>
198 NOTE: Kgdboc does not support interrupting the target via the 365 <para>Press: <constant>Enter</constant></para>
199 gdb remote protocol. You must manually send a sysrq-g unless you 366 <para>Press: <constant>g</constant></para>
200 have a proxy that splits console output to a terminal problem and 367 </listitem>
201 has a separate port for the debugger to connect to that sends the 368 </itemizedlist>
202 sysrq-g for you. 369 </listitem>
370 <listitem><para>From the kdb prompt you can run the "help" command to see a complete list of the commands that are available.</para>
371 <para>Some useful commands in kdb include:
372 <itemizedlist>
373 <listitem><para>lsmod -- Shows where kernel modules are loaded</para></listitem>
374 <listitem><para>ps -- Displays only the active processes</para></listitem>
375 <listitem><para>ps A -- Shows all the processes</para></listitem>
376 <listitem><para>summary -- Shows kernel version info and memory usage</para></listitem>
377 <listitem><para>bt -- Get a backtrace of the current process using dump_stack()</para></listitem>
378 <listitem><para>dmesg -- View the kernel syslog buffer</para></listitem>
379 <listitem><para>go -- Continue the system</para></listitem>
380 </itemizedlist>
203 </para> 381 </para>
204 <para>When using kgdboc with no debugger proxy, you can end up 382 </listitem>
205 connecting the debugger for one of two entry points. If an 383 <listitem>
206 exception occurs after you have loaded kgdboc a message should print 384 <para>When you are done using kdb you need to consider rebooting the
207 on the console stating it is waiting for the debugger. In case you 385 system or using the "go" command to resuming normal kernel
208 disconnect your terminal program and then connect the debugger in 386 execution. If you have paused the kernel for a lengthy period of
209 its place. If you want to interrupt the target system and forcibly 387 time, applications that rely on timely networking or anything to do
210 enter a debug session you have to issue a Sysrq sequence and then 388 with real wall clock time could be adversely affected, so you
211 type the letter <constant>g</constant>. Then you disconnect the 389 should take this into consideration when using the kernel
212 terminal session and connect gdb. Your options if you don't like 390 debugger.</para>
213 this are to hack gdb to send the sysrq-g for you as well as on the 391 </listitem>
214 initial connect, or to use a debugger proxy that allows an 392 </orderedlist></para>
215 unmodified gdb to do the debugging. 393 </sect1>
394 <sect1 id="quickKDBkeyboard">
395 <title>Quick start for kdb using a keyboard connected console</title>
396 <para>This is a quick example of how to use kdb with a keyboard.</para>
397 <para><orderedlist>
398 <listitem><para>Boot kernel with arguments:
399 <itemizedlist>
400 <listitem><para><constant>kgdboc=kbd</constant></para></listitem>
401 </itemizedlist></para>
402 <para>OR</para>
403 <para>Configure kgdboc after the kernel booted:
404 <itemizedlist>
405 <listitem><para><constant>echo kbd &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para></listitem>
406 </itemizedlist>
216 </para> 407 </para>
217 </sect2> 408 </listitem>
409 <listitem><para>Enter the kernel debugger manually or by waiting for an oops or fault. There are several ways you can enter the kernel debugger manually; all involve using the sysrq-g, which means you must have enabled CONFIG_MAGIC_SYSRQ=y in your kernel config.</para>
410 <itemizedlist>
411 <listitem><para>When logged in as root or with a super user session you can run:</para>
412 <para><constant>echo g &gt; /proc/sysrq-trigger</constant></para></listitem>
413 <listitem><para>Example using a laptop keyboard</para>
414 <para>Press and hold down: <constant>Alt</constant></para>
415 <para>Press and hold down: <constant>Fn</constant></para>
416 <para>Press and release the key with the label: <constant>SysRq</constant></para>
417 <para>Release: <constant>Fn</constant></para>
418 <para>Press and release: <constant>g</constant></para>
419 <para>Release: <constant>Alt</constant></para>
420 </listitem>
421 <listitem><para>Example using a PS/2 101-key keyboard</para>
422 <para>Press and hold down: <constant>Alt</constant></para>
423 <para>Press and release the key with the label: <constant>SysRq</constant></para>
424 <para>Press and release: <constant>g</constant></para>
425 <para>Release: <constant>Alt</constant></para>
426 </listitem>
427 </itemizedlist>
428 </listitem>
429 <listitem>
430 <para>Now type in a kdb command such as "help", "dmesg", "bt" or "go" to continue kernel execution.</para>
431 </listitem>
432 </orderedlist></para>
218 </sect1> 433 </sect1>
219 <sect1 id="kgdbcon"> 434 </chapter>
220 <title>Kernel parameter: kgdbcon</title> 435 <chapter id="EnableKGDB">
221 <para> 436 <title>Using kgdb / gdb</title>
222 Kgdb supports using the gdb serial protocol to send console messages 437 <para>In order to use kgdb you must activate it by passing
223 to the debugger when the debugger is connected and running. There 438 configuration information to one of the kgdb I/O drivers. If you
224 are two ways to activate this feature. 439 do not pass any configuration information kgdb will not do anything
440 at all. Kgdb will only actively hook up to the kernel trap hooks
441 if a kgdb I/O driver is loaded and configured. If you unconfigure
442 a kgdb I/O driver, kgdb will unregister all the kernel hook points.
443 </para>
444 <para> All kgdb I/O drivers can be reconfigured at run time, if
445 <symbol>CONFIG_SYSFS</symbol> and <symbol>CONFIG_MODULES</symbol>
446 are enabled, by echo'ing a new config string to
447 <constant>/sys/module/&lt;driver&gt;/parameter/&lt;option&gt;</constant>.
448 The driver can be unconfigured by passing an empty string. You cannot
449 change the configuration while the debugger is attached. Make sure
450 to detach the debugger with the <constant>detach</constant> command
451 prior to trying to unconfigure a kgdb I/O driver.
452 </para>
453 <sect1 id="ConnectingGDB">
454 <title>Connecting with gdb to a serial port</title>
225 <orderedlist> 455 <orderedlist>
226 <listitem><para>Activate with the kernel command line option:</para> 456 <listitem><para>Configure kgdboc</para>
227 <para><constant>kgdbcon</constant></para> 457 <para>Boot kernel with arguments:
458 <itemizedlist>
459 <listitem><para><constant>kgdboc=ttyS0,115200</constant></para></listitem>
460 </itemizedlist></para>
461 <para>OR</para>
462 <para>Configure kgdboc after the kernel booted:
463 <itemizedlist>
464 <listitem><para><constant>echo ttyS0 &gt; /sys/module/kgdboc/parameters/kgdboc</constant></para></listitem>
465 </itemizedlist></para>
228 </listitem> 466 </listitem>
229 <listitem><para>Use sysfs before configuring an io driver</para> 467 <listitem>
230 <para> 468 <para>Stop kernel execution (break into the debugger)</para>
231 <constant>echo 1 &gt; /sys/module/kgdb/parameters/kgdb_use_con</constant> 469 <para>In order to connect to gdb via kgdboc, the kernel must
232 </para> 470 first be stopped. There are several ways to stop the kernel which
233 <para> 471 include using kgdbwait as a boot argument, via a sysrq-g, or running
234 NOTE: If you do this after you configure the kgdb I/O driver, the 472 the kernel until it takes an exception where it waits for the
235 setting will not take effect until the next point the I/O is 473 debugger to attach.
236 reconfigured. 474 <itemizedlist>
237 </para> 475 <listitem><para>When logged in as root or with a super user session you can run:</para>
476 <para><constant>echo g &gt; /proc/sysrq-trigger</constant></para></listitem>
477 <listitem><para>Example using minicom 2.2</para>
478 <para>Press: <constant>Control-a</constant></para>
479 <para>Press: <constant>f</constant></para>
480 <para>Press: <constant>g</constant></para>
238 </listitem> 481 </listitem>
239 </orderedlist> 482 <listitem><para>When you have telneted to a terminal server that supports sending a remote break</para>
240 </para> 483 <para>Press: <constant>Control-]</constant></para>
241 <para> 484 <para>Type in:<constant>send break</constant></para>
242 IMPORTANT NOTE: Using this option with kgdb over the console 485 <para>Press: <constant>Enter</constant></para>
243 (kgdboc) is not supported. 486 <para>Press: <constant>g</constant></para>
487 </listitem>
488 </itemizedlist>
244 </para> 489 </para>
245 </sect1> 490 </listitem>
246 </chapter> 491 <listitem>
247 <chapter id="ConnectingGDB"> 492 <para>Connect from from gdb</para>
248 <title>Connecting gdb</title>
249 <para>
250 If you are using kgdboc, you need to have used kgdbwait as a boot
251 argument, issued a sysrq-g, or the system you are going to debug
252 has already taken an exception and is waiting for the debugger to
253 attach before you can connect gdb.
254 </para>
255 <para>
256 If you are not using different kgdb I/O driver other than kgdboc,
257 you should be able to connect and the target will automatically
258 respond.
259 </para>
260 <para> 493 <para>
261 Example (using a serial port): 494 Example (using a directly connected port):
262 </para> 495 </para>
263 <programlisting> 496 <programlisting>
264 % gdb ./vmlinux 497 % gdb ./vmlinux
@@ -266,7 +499,7 @@
266 (gdb) target remote /dev/ttyS0 499 (gdb) target remote /dev/ttyS0
267 </programlisting> 500 </programlisting>
268 <para> 501 <para>
269 Example (kgdb to a terminal server on tcp port 2012): 502 Example (kgdb to a terminal server on TCP port 2012):
270 </para> 503 </para>
271 <programlisting> 504 <programlisting>
272 % gdb ./vmlinux 505 % gdb ./vmlinux
@@ -283,6 +516,83 @@
283 communications. You do this prior to issuing the <constant>target 516 communications. You do this prior to issuing the <constant>target
284 remote</constant> command by typing in: <constant>set debug remote 1</constant> 517 remote</constant> command by typing in: <constant>set debug remote 1</constant>
285 </para> 518 </para>
519 </listitem>
520 </orderedlist>
521 <para>Remember if you continue in gdb, and need to "break in" again,
522 you need to issue an other sysrq-g. It is easy to create a simple
523 entry point by putting a breakpoint at <constant>sys_sync</constant>
524 and then you can run "sync" from a shell or script to break into the
525 debugger.</para>
526 </sect1>
527 </chapter>
528 <chapter id="switchKdbKgdb">
529 <title>kgdb and kdb interoperability</title>
530 <para>It is possible to transition between kdb and kgdb dynamically.
531 The debug core will remember which you used the last time and
532 automatically start in the same mode.</para>
533 <sect1>
534 <title>Switching between kdb and kgdb</title>
535 <sect2>
536 <title>Switching from kgdb to kdb</title>
537 <para>
538 There are two ways to switch from kgdb to kdb: you can use gdb to
539 issue a maintenance packet, or you can blindly type the command $3#33.
540 Whenever kernel debugger stops in kgdb mode it will print the
541 message <constant>KGDB or $3#33 for KDB</constant>. It is important
542 to note that you have to type the sequence correctly in one pass.
543 You cannot type a backspace or delete because kgdb will interpret
544 that as part of the debug stream.
545 <orderedlist>
546 <listitem><para>Change from kgdb to kdb by blindly typing:</para>
547 <para><constant>$3#33</constant></para></listitem>
548 <listitem><para>Change from kgdb to kdb with gdb</para>
549 <para><constant>maintenance packet 3</constant></para>
550 <para>NOTE: Now you must kill gdb. Typically you press control-z and
551 issue the command: kill -9 %</para></listitem>
552 </orderedlist>
553 </para>
554 </sect2>
555 <sect2>
556 <title>Change from kdb to kgdb</title>
557 <para>There are two ways you can change from kdb to kgdb. You can
558 manually enter kgdb mode by issuing the kgdb command from the kdb
559 shell prompt, or you can connect gdb while the kdb shell prompt is
560 active. The kdb shell looks for the typical first commands that gdb
561 would issue with the gdb remote protocol and if it sees one of those
562 commands it automatically changes into kgdb mode.</para>
563 <orderedlist>
564 <listitem><para>From kdb issue the command:</para>
565 <para><constant>kgdb</constant></para>
566 <para>Now disconnect your terminal program and connect gdb in its place</para></listitem>
567 <listitem><para>At the kdb prompt, disconnect the terminal program and connect gdb in its place.</para></listitem>
568 </orderedlist>
569 </sect2>
570 </sect1>
571 <sect1>
572 <title>Running kdb commands from gdb</title>
573 <para>It is possible to run a limited set of kdb commands from gdb,
574 using the gdb monitor command. You don't want to execute any of the
575 run control or breakpoint operations, because it can disrupt the
576 state of the kernel debugger. You should be using gdb for
577 breakpoints and run control operations if you have gdb connected.
578 The more useful commands to run are things like lsmod, dmesg, ps or
579 possibly some of the memory information commands. To see all the kdb
580 commands you can run <constant>monitor help</constant>.</para>
581 <para>Example:
582 <informalexample><programlisting>
583(gdb) monitor ps
5841 idle process (state I) and
58527 sleeping system daemon (state M) processes suppressed,
586use 'ps A' to see all.
587Task Addr Pid Parent [*] cpu State Thread Command
588
5890xc78291d0 1 0 0 0 S 0xc7829404 init
5900xc7954150 942 1 0 0 S 0xc7954384 dropbear
5910xc78789c0 944 1 0 0 S 0xc7878bf4 sh
592(gdb)
593 </programlisting></informalexample>
594 </para>
595 </sect1>
286 </chapter> 596 </chapter>
287 <chapter id="KGDBTestSuite"> 597 <chapter id="KGDBTestSuite">
288 <title>kgdb Test Suite</title> 598 <title>kgdb Test Suite</title>
@@ -309,34 +619,36 @@
309 </para> 619 </para>
310 </chapter> 620 </chapter>
311 <chapter id="CommonBackEndReq"> 621 <chapter id="CommonBackEndReq">
312 <title>KGDB Internals</title> 622 <title>Kernel Debugger Internals</title>
313 <sect1 id="kgdbArchitecture"> 623 <sect1 id="kgdbArchitecture">
314 <title>Architecture Specifics</title> 624 <title>Architecture Specifics</title>
315 <para> 625 <para>
316 Kgdb is organized into three basic components: 626 The kernel debugger is organized into a number of components:
317 <orderedlist> 627 <orderedlist>
318 <listitem><para>kgdb core</para> 628 <listitem><para>The debug core</para>
319 <para> 629 <para>
320 The kgdb core is found in kernel/kgdb.c. It contains: 630 The debug core is found in kernel/debugger/debug_core.c. It contains:
321 <itemizedlist> 631 <itemizedlist>
322 <listitem><para>All the logic to implement the gdb serial protocol</para></listitem> 632 <listitem><para>A generic OS exception handler which includes
323 <listitem><para>A generic OS exception handler which includes sync'ing the processors into a stopped state on an multi cpu system.</para></listitem> 633 sync'ing the processors into a stopped state on an multi-CPU
634 system.</para></listitem>
324 <listitem><para>The API to talk to the kgdb I/O drivers</para></listitem> 635 <listitem><para>The API to talk to the kgdb I/O drivers</para></listitem>
325 <listitem><para>The API to make calls to the arch specific kgdb implementation</para></listitem> 636 <listitem><para>The API to make calls to the arch-specific kgdb implementation</para></listitem>
326 <listitem><para>The logic to perform safe memory reads and writes to memory while using the debugger</para></listitem> 637 <listitem><para>The logic to perform safe memory reads and writes to memory while using the debugger</para></listitem>
327 <listitem><para>A full implementation for software breakpoints unless overridden by the arch</para></listitem> 638 <listitem><para>A full implementation for software breakpoints unless overridden by the arch</para></listitem>
639 <listitem><para>The API to invoke either the kdb or kgdb frontend to the debug core.</para></listitem>
328 </itemizedlist> 640 </itemizedlist>
329 </para> 641 </para>
330 </listitem> 642 </listitem>
331 <listitem><para>kgdb arch specific implementation</para> 643 <listitem><para>kgdb arch-specific implementation</para>
332 <para> 644 <para>
333 This implementation is generally found in arch/*/kernel/kgdb.c. 645 This implementation is generally found in arch/*/kernel/kgdb.c.
334 As an example, arch/x86/kernel/kgdb.c contains the specifics to 646 As an example, arch/x86/kernel/kgdb.c contains the specifics to
335 implement HW breakpoint as well as the initialization to 647 implement HW breakpoint as well as the initialization to
336 dynamically register and unregister for the trap handlers on 648 dynamically register and unregister for the trap handlers on
337 this architecture. The arch specific portion implements: 649 this architecture. The arch-specific portion implements:
338 <itemizedlist> 650 <itemizedlist>
339 <listitem><para>contains an arch specific trap catcher which 651 <listitem><para>contains an arch-specific trap catcher which
340 invokes kgdb_handle_exception() to start kgdb about doing its 652 invokes kgdb_handle_exception() to start kgdb about doing its
341 work</para></listitem> 653 work</para></listitem>
342 <listitem><para>translation to and from gdb specific packet format to pt_regs</para></listitem> 654 <listitem><para>translation to and from gdb specific packet format to pt_regs</para></listitem>
@@ -347,11 +659,35 @@
347 </itemizedlist> 659 </itemizedlist>
348 </para> 660 </para>
349 </listitem> 661 </listitem>
662 <listitem><para>gdbstub frontend (aka kgdb)</para>
663 <para>The gdbstub is located in kernel/debug/gdbstub.c. It contains:</para>
664 <itemizedlist>
665 <listitem><para>All the logic to implement the gdb serial protocol</para></listitem>
666 </itemizedlist>
667 </listitem>
668 <listitem><para>kdb frontend</para>
669 <para>The kdb debugger shell is broken down into a number of
670 components. The kdb core is located in kernel/debug/kdb. There
671 are a number of helper functions in some of the other kernel
672 components to make it possible for kdb to examine and report
673 information about the kernel without taking locks that could
674 cause a kernel deadlock. The kdb core contains implements the following functionality.</para>
675 <itemizedlist>
676 <listitem><para>A simple shell</para></listitem>
677 <listitem><para>The kdb core command set</para></listitem>
678 <listitem><para>A registration API to register additional kdb shell commands.</para>
679 <para>A good example of a self-contained kdb module is the "ftdump" command for dumping the ftrace buffer. See: kernel/trace/trace_kdb.c</para></listitem>
680 <listitem><para>The implementation for kdb_printf() which
681 emits messages directly to I/O drivers, bypassing the kernel
682 log.</para></listitem>
683 <listitem><para>SW / HW breakpoint management for the kdb shell</para></listitem>
684 </itemizedlist>
685 </listitem>
350 <listitem><para>kgdb I/O driver</para> 686 <listitem><para>kgdb I/O driver</para>
351 <para> 687 <para>
352 Each kgdb I/O driver has to provide an implemenation for the following: 688 Each kgdb I/O driver has to provide an implementation for the following:
353 <itemizedlist> 689 <itemizedlist>
354 <listitem><para>configuration via builtin or module</para></listitem> 690 <listitem><para>configuration via built-in or module</para></listitem>
355 <listitem><para>dynamic configuration and kgdb hook registration calls</para></listitem> 691 <listitem><para>dynamic configuration and kgdb hook registration calls</para></listitem>
356 <listitem><para>read and write character interface</para></listitem> 692 <listitem><para>read and write character interface</para></listitem>
357 <listitem><para>A cleanup handler for unconfiguring from the kgdb core</para></listitem> 693 <listitem><para>A cleanup handler for unconfiguring from the kgdb core</para></listitem>
@@ -416,15 +752,15 @@
416 underlying low level to the hardware driver having "polling hooks" 752 underlying low level to the hardware driver having "polling hooks"
417 which the to which the tty driver is attached. In the initial 753 which the to which the tty driver is attached. In the initial
418 implementation of kgdboc it the serial_core was changed to expose a 754 implementation of kgdboc it the serial_core was changed to expose a
419 low level uart hook for doing polled mode reading and writing of a 755 low level UART hook for doing polled mode reading and writing of a
420 single character while in an atomic context. When kgdb makes an I/O 756 single character while in an atomic context. When kgdb makes an I/O
421 request to the debugger, kgdboc invokes a call back in the serial 757 request to the debugger, kgdboc invokes a call back in the serial
422 core which in turn uses the call back in the uart driver. It is 758 core which in turn uses the call back in the UART driver. It is
423 certainly possible to extend kgdboc to work with non-uart based 759 certainly possible to extend kgdboc to work with non-UART based
424 consoles in the future. 760 consoles in the future.
425 </para> 761 </para>
426 <para> 762 <para>
427 When using kgdboc with a uart, the uart driver must implement two callbacks in the <constant>struct uart_ops</constant>. Example from drivers/8250.c:<programlisting> 763 When using kgdboc with a UART, the UART driver must implement two callbacks in the <constant>struct uart_ops</constant>. Example from drivers/8250.c:<programlisting>
428#ifdef CONFIG_CONSOLE_POLL 764#ifdef CONFIG_CONSOLE_POLL
429 .poll_get_char = serial8250_get_poll_char, 765 .poll_get_char = serial8250_get_poll_char,
430 .poll_put_char = serial8250_put_poll_char, 766 .poll_put_char = serial8250_put_poll_char,
@@ -434,7 +770,7 @@
434 <constant>#ifdef CONFIG_CONSOLE_POLL</constant>, as shown above. 770 <constant>#ifdef CONFIG_CONSOLE_POLL</constant>, as shown above.
435 Keep in mind that polling hooks have to be implemented in such a way 771 Keep in mind that polling hooks have to be implemented in such a way
436 that they can be called from an atomic context and have to restore 772 that they can be called from an atomic context and have to restore
437 the state of the uart chip on return such that the system can return 773 the state of the UART chip on return such that the system can return
438 to normal when the debugger detaches. You need to be very careful 774 to normal when the debugger detaches. You need to be very careful
439 with any kind of lock you consider, because failing here is most 775 with any kind of lock you consider, because failing here is most
440 going to mean pressing the reset button. 776 going to mean pressing the reset button.
@@ -453,6 +789,10 @@
453 <itemizedlist> 789 <itemizedlist>
454 <listitem><para>Jason Wessel<email>jason.wessel@windriver.com</email></para></listitem> 790 <listitem><para>Jason Wessel<email>jason.wessel@windriver.com</email></para></listitem>
455 </itemizedlist> 791 </itemizedlist>
792 In Jan 2010 this document was updated to include kdb.
793 <itemizedlist>
794 <listitem><para>Jason Wessel<email>jason.wessel@windriver.com</email></para></listitem>
795 </itemizedlist>
456 </para> 796 </para>
457 </chapter> 797 </chapter>
458</book> 798</book>
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index ba9975771503..8c5411cfeaf0 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -81,16 +81,14 @@ void (*port_disable) (struct ata_port *);
81 </programlisting> 81 </programlisting>
82 82
83 <para> 83 <para>
84 Called from ata_bus_probe() and ata_bus_reset() error paths, 84 Called from ata_bus_probe() error path, as well as when
85 as well as when unregistering from the SCSI module (rmmod, hot 85 unregistering from the SCSI module (rmmod, hot unplug).
86 unplug).
87 This function should do whatever needs to be done to take the 86 This function should do whatever needs to be done to take the
88 port out of use. In most cases, ata_port_disable() can be used 87 port out of use. In most cases, ata_port_disable() can be used
89 as this hook. 88 as this hook.
90 </para> 89 </para>
91 <para> 90 <para>
92 Called from ata_bus_probe() on a failed probe. 91 Called from ata_bus_probe() on a failed probe.
93 Called from ata_bus_reset() on a failed bus reset.
94 Called from ata_scsi_release(). 92 Called from ata_scsi_release().
95 </para> 93 </para>
96 94
@@ -107,10 +105,6 @@ void (*dev_config) (struct ata_port *, struct ata_device *);
107 issue of SET FEATURES - XFER MODE, and prior to operation. 105 issue of SET FEATURES - XFER MODE, and prior to operation.
108 </para> 106 </para>
109 <para> 107 <para>
110 Called by ata_device_add() after ata_dev_identify() determines
111 a device is present.
112 </para>
113 <para>
114 This entry may be specified as NULL in ata_port_operations. 108 This entry may be specified as NULL in ata_port_operations.
115 </para> 109 </para>
116 110
@@ -154,8 +148,8 @@ unsigned int (*mode_filter) (struct ata_port *, struct ata_device *, unsigned in
154 148
155 <sect2><title>Taskfile read/write</title> 149 <sect2><title>Taskfile read/write</title>
156 <programlisting> 150 <programlisting>
157void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); 151void (*sff_tf_load) (struct ata_port *ap, struct ata_taskfile *tf);
158void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); 152void (*sff_tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
159 </programlisting> 153 </programlisting>
160 154
161 <para> 155 <para>
@@ -164,36 +158,35 @@ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
164 hardware registers / DMA buffers, to obtain the current set of 158 hardware registers / DMA buffers, to obtain the current set of
165 taskfile register values. 159 taskfile register values.
166 Most drivers for taskfile-based hardware (PIO or MMIO) use 160 Most drivers for taskfile-based hardware (PIO or MMIO) use
167 ata_tf_load() and ata_tf_read() for these hooks. 161 ata_sff_tf_load() and ata_sff_tf_read() for these hooks.
168 </para> 162 </para>
169 163
170 </sect2> 164 </sect2>
171 165
172 <sect2><title>PIO data read/write</title> 166 <sect2><title>PIO data read/write</title>
173 <programlisting> 167 <programlisting>
174void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); 168void (*sff_data_xfer) (struct ata_device *, unsigned char *, unsigned int, int);
175 </programlisting> 169 </programlisting>
176 170
177 <para> 171 <para>
178All bmdma-style drivers must implement this hook. This is the low-level 172All bmdma-style drivers must implement this hook. This is the low-level
179operation that actually copies the data bytes during a PIO data 173operation that actually copies the data bytes during a PIO data
180transfer. 174transfer.
181Typically the driver 175Typically the driver will choose one of ata_sff_data_xfer_noirq(),
182will choose one of ata_pio_data_xfer_noirq(), ata_pio_data_xfer(), or 176ata_sff_data_xfer(), or ata_sff_data_xfer32().
183ata_mmio_data_xfer().
184 </para> 177 </para>
185 178
186 </sect2> 179 </sect2>
187 180
188 <sect2><title>ATA command execute</title> 181 <sect2><title>ATA command execute</title>
189 <programlisting> 182 <programlisting>
190void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); 183void (*sff_exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
191 </programlisting> 184 </programlisting>
192 185
193 <para> 186 <para>
194 causes an ATA command, previously loaded with 187 causes an ATA command, previously loaded with
195 ->tf_load(), to be initiated in hardware. 188 ->tf_load(), to be initiated in hardware.
196 Most drivers for taskfile-based hardware use ata_exec_command() 189 Most drivers for taskfile-based hardware use ata_sff_exec_command()
197 for this hook. 190 for this hook.
198 </para> 191 </para>
199 192
@@ -218,8 +211,8 @@ command.
218 211
219 <sect2><title>Read specific ATA shadow registers</title> 212 <sect2><title>Read specific ATA shadow registers</title>
220 <programlisting> 213 <programlisting>
221u8 (*check_status)(struct ata_port *ap); 214u8 (*sff_check_status)(struct ata_port *ap);
222u8 (*check_altstatus)(struct ata_port *ap); 215u8 (*sff_check_altstatus)(struct ata_port *ap);
223 </programlisting> 216 </programlisting>
224 217
225 <para> 218 <para>
@@ -227,20 +220,26 @@ u8 (*check_altstatus)(struct ata_port *ap);
227 hardware. On some hardware, reading the Status register has 220 hardware. On some hardware, reading the Status register has
228 the side effect of clearing the interrupt condition. 221 the side effect of clearing the interrupt condition.
229 Most drivers for taskfile-based hardware use 222 Most drivers for taskfile-based hardware use
230 ata_check_status() for this hook. 223 ata_sff_check_status() for this hook.
231 </para> 224 </para>
225
226 </sect2>
227
228 <sect2><title>Write specific ATA shadow register</title>
229 <programlisting>
230void (*sff_set_devctl)(struct ata_port *ap, u8 ctl);
231 </programlisting>
232
232 <para> 233 <para>
233 Note that because this is called from ata_device_add(), at 234 Write the device control ATA shadow register to the hardware.
234 least a dummy function that clears device interrupts must be 235 Most drivers don't need to define this.
235 provided for all drivers, even if the controller doesn't
236 actually have a taskfile status register.
237 </para> 236 </para>
238 237
239 </sect2> 238 </sect2>
240 239
241 <sect2><title>Select ATA device on bus</title> 240 <sect2><title>Select ATA device on bus</title>
242 <programlisting> 241 <programlisting>
243void (*dev_select)(struct ata_port *ap, unsigned int device); 242void (*sff_dev_select)(struct ata_port *ap, unsigned int device);
244 </programlisting> 243 </programlisting>
245 244
246 <para> 245 <para>
@@ -251,9 +250,7 @@ void (*dev_select)(struct ata_port *ap, unsigned int device);
251 </para> 250 </para>
252 <para> 251 <para>
253 Most drivers for taskfile-based hardware use 252 Most drivers for taskfile-based hardware use
254 ata_std_dev_select() for this hook. Controllers which do not 253 ata_sff_dev_select() for this hook.
255 support second drives on a port (such as SATA contollers) will
256 use ata_noop_dev_select().
257 </para> 254 </para>
258 255
259 </sect2> 256 </sect2>
@@ -441,13 +438,13 @@ void (*irq_clear) (struct ata_port *);
441 to struct ata_host_set. 438 to struct ata_host_set.
442 </para> 439 </para>
443 <para> 440 <para>
444 Most legacy IDE drivers use ata_interrupt() for the 441 Most legacy IDE drivers use ata_sff_interrupt() for the
445 irq_handler hook, which scans all ports in the host_set, 442 irq_handler hook, which scans all ports in the host_set,
446 determines which queued command was active (if any), and calls 443 determines which queued command was active (if any), and calls
447 ata_host_intr(ap,qc). 444 ata_sff_host_intr(ap,qc).
448 </para> 445 </para>
449 <para> 446 <para>
450 Most legacy IDE drivers use ata_bmdma_irq_clear() for the 447 Most legacy IDE drivers use ata_sff_irq_clear() for the
451 irq_clear() hook, which simply clears the interrupt and error 448 irq_clear() hook, which simply clears the interrupt and error
452 flags in the DMA status register. 449 flags in the DMA status register.
453 </para> 450 </para>
@@ -490,16 +487,12 @@ void (*host_stop) (struct ata_host_set *host_set);
490 allocates space for a legacy IDE PRD table and returns. 487 allocates space for a legacy IDE PRD table and returns.
491 </para> 488 </para>
492 <para> 489 <para>
493 ->port_stop() is called after ->host_stop(). It's sole function 490 ->port_stop() is called after ->host_stop(). Its sole function
494 is to release DMA/memory resources, now that they are no longer 491 is to release DMA/memory resources, now that they are no longer
495 actively being used. Many drivers also free driver-private 492 actively being used. Many drivers also free driver-private
496 data from port at this time. 493 data from port at this time.
497 </para> 494 </para>
498 <para> 495 <para>
499 Many drivers use ata_port_stop() as this hook, which frees the
500 PRD table.
501 </para>
502 <para>
503 ->host_stop() is called after all ->port_stop() calls 496 ->host_stop() is called after all ->port_stop() calls
504have completed. The hook must finalize hardware shutdown, release DMA 497have completed. The hook must finalize hardware shutdown, release DMA
505and other resources, etc. 498and other resources, etc.
diff --git a/Documentation/DocBook/mac80211.tmpl b/Documentation/DocBook/mac80211.tmpl
index f3f37f141dbd..affb15a344a1 100644
--- a/Documentation/DocBook/mac80211.tmpl
+++ b/Documentation/DocBook/mac80211.tmpl
@@ -144,7 +144,7 @@ usage should require reading the full document.
144 this though and the recommendation to allow only a single 144 this though and the recommendation to allow only a single
145 interface in STA mode at first! 145 interface in STA mode at first!
146 </para> 146 </para>
147!Finclude/net/mac80211.h ieee80211_if_init_conf 147!Finclude/net/mac80211.h ieee80211_vif
148 </chapter> 148 </chapter>
149 149
150 <chapter id="rx-tx"> 150 <chapter id="rx-tx">
@@ -234,7 +234,6 @@ usage should require reading the full document.
234 <title>Multiple queues and QoS support</title> 234 <title>Multiple queues and QoS support</title>
235 <para>TBD</para> 235 <para>TBD</para>
236!Finclude/net/mac80211.h ieee80211_tx_queue_params 236!Finclude/net/mac80211.h ieee80211_tx_queue_params
237!Finclude/net/mac80211.h ieee80211_tx_queue_stats
238 </chapter> 237 </chapter>
239 238
240 <chapter id="AP"> 239 <chapter id="AP">
diff --git a/Documentation/DocBook/media-entities.tmpl b/Documentation/DocBook/media-entities.tmpl
index c725cb852c54..5d4d40f429a5 100644
--- a/Documentation/DocBook/media-entities.tmpl
+++ b/Documentation/DocBook/media-entities.tmpl
@@ -17,6 +17,7 @@
17<!ENTITY VIDIOC-DBG-G-REGISTER "<link linkend='vidioc-dbg-g-register'><constant>VIDIOC_DBG_G_REGISTER</constant></link>"> 17<!ENTITY VIDIOC-DBG-G-REGISTER "<link linkend='vidioc-dbg-g-register'><constant>VIDIOC_DBG_G_REGISTER</constant></link>">
18<!ENTITY VIDIOC-DBG-S-REGISTER "<link linkend='vidioc-dbg-g-register'><constant>VIDIOC_DBG_S_REGISTER</constant></link>"> 18<!ENTITY VIDIOC-DBG-S-REGISTER "<link linkend='vidioc-dbg-g-register'><constant>VIDIOC_DBG_S_REGISTER</constant></link>">
19<!ENTITY VIDIOC-DQBUF "<link linkend='vidioc-qbuf'><constant>VIDIOC_DQBUF</constant></link>"> 19<!ENTITY VIDIOC-DQBUF "<link linkend='vidioc-qbuf'><constant>VIDIOC_DQBUF</constant></link>">
20<!ENTITY VIDIOC-DQEVENT "<link linkend='vidioc-dqevent'><constant>VIDIOC_DQEVENT</constant></link>">
20<!ENTITY VIDIOC-ENCODER-CMD "<link linkend='vidioc-encoder-cmd'><constant>VIDIOC_ENCODER_CMD</constant></link>"> 21<!ENTITY VIDIOC-ENCODER-CMD "<link linkend='vidioc-encoder-cmd'><constant>VIDIOC_ENCODER_CMD</constant></link>">
21<!ENTITY VIDIOC-ENUMAUDIO "<link linkend='vidioc-enumaudio'><constant>VIDIOC_ENUMAUDIO</constant></link>"> 22<!ENTITY VIDIOC-ENUMAUDIO "<link linkend='vidioc-enumaudio'><constant>VIDIOC_ENUMAUDIO</constant></link>">
22<!ENTITY VIDIOC-ENUMAUDOUT "<link linkend='vidioc-enumaudioout'><constant>VIDIOC_ENUMAUDOUT</constant></link>"> 23<!ENTITY VIDIOC-ENUMAUDOUT "<link linkend='vidioc-enumaudioout'><constant>VIDIOC_ENUMAUDOUT</constant></link>">
@@ -60,6 +61,7 @@
60<!ENTITY VIDIOC-REQBUFS "<link linkend='vidioc-reqbufs'><constant>VIDIOC_REQBUFS</constant></link>"> 61<!ENTITY VIDIOC-REQBUFS "<link linkend='vidioc-reqbufs'><constant>VIDIOC_REQBUFS</constant></link>">
61<!ENTITY VIDIOC-STREAMOFF "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMOFF</constant></link>"> 62<!ENTITY VIDIOC-STREAMOFF "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMOFF</constant></link>">
62<!ENTITY VIDIOC-STREAMON "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMON</constant></link>"> 63<!ENTITY VIDIOC-STREAMON "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMON</constant></link>">
64<!ENTITY VIDIOC-SUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_SUBSCRIBE_EVENT</constant></link>">
63<!ENTITY VIDIOC-S-AUDIO "<link linkend='vidioc-g-audio'><constant>VIDIOC_S_AUDIO</constant></link>"> 65<!ENTITY VIDIOC-S-AUDIO "<link linkend='vidioc-g-audio'><constant>VIDIOC_S_AUDIO</constant></link>">
64<!ENTITY VIDIOC-S-AUDOUT "<link linkend='vidioc-g-audioout'><constant>VIDIOC_S_AUDOUT</constant></link>"> 66<!ENTITY VIDIOC-S-AUDOUT "<link linkend='vidioc-g-audioout'><constant>VIDIOC_S_AUDOUT</constant></link>">
65<!ENTITY VIDIOC-S-CROP "<link linkend='vidioc-g-crop'><constant>VIDIOC_S_CROP</constant></link>"> 67<!ENTITY VIDIOC-S-CROP "<link linkend='vidioc-g-crop'><constant>VIDIOC_S_CROP</constant></link>">
@@ -83,6 +85,7 @@
83<!ENTITY VIDIOC-TRY-ENCODER-CMD "<link linkend='vidioc-encoder-cmd'><constant>VIDIOC_TRY_ENCODER_CMD</constant></link>"> 85<!ENTITY VIDIOC-TRY-ENCODER-CMD "<link linkend='vidioc-encoder-cmd'><constant>VIDIOC_TRY_ENCODER_CMD</constant></link>">
84<!ENTITY VIDIOC-TRY-EXT-CTRLS "<link linkend='vidioc-g-ext-ctrls'><constant>VIDIOC_TRY_EXT_CTRLS</constant></link>"> 86<!ENTITY VIDIOC-TRY-EXT-CTRLS "<link linkend='vidioc-g-ext-ctrls'><constant>VIDIOC_TRY_EXT_CTRLS</constant></link>">
85<!ENTITY VIDIOC-TRY-FMT "<link linkend='vidioc-g-fmt'><constant>VIDIOC_TRY_FMT</constant></link>"> 87<!ENTITY VIDIOC-TRY-FMT "<link linkend='vidioc-g-fmt'><constant>VIDIOC_TRY_FMT</constant></link>">
88<!ENTITY VIDIOC-UNSUBSCRIBE-EVENT "<link linkend='vidioc-subscribe-event'><constant>VIDIOC_UNSUBSCRIBE_EVENT</constant></link>">
86 89
87<!-- Types --> 90<!-- Types -->
88<!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>"> 91<!ENTITY v4l2-std-id "<link linkend='v4l2-std-id'>v4l2_std_id</link>">
@@ -141,6 +144,9 @@
141<!ENTITY v4l2-enc-idx "struct&nbsp;<link linkend='v4l2-enc-idx'>v4l2_enc_idx</link>"> 144<!ENTITY v4l2-enc-idx "struct&nbsp;<link linkend='v4l2-enc-idx'>v4l2_enc_idx</link>">
142<!ENTITY v4l2-enc-idx-entry "struct&nbsp;<link linkend='v4l2-enc-idx-entry'>v4l2_enc_idx_entry</link>"> 145<!ENTITY v4l2-enc-idx-entry "struct&nbsp;<link linkend='v4l2-enc-idx-entry'>v4l2_enc_idx_entry</link>">
143<!ENTITY v4l2-encoder-cmd "struct&nbsp;<link linkend='v4l2-encoder-cmd'>v4l2_encoder_cmd</link>"> 146<!ENTITY v4l2-encoder-cmd "struct&nbsp;<link linkend='v4l2-encoder-cmd'>v4l2_encoder_cmd</link>">
147<!ENTITY v4l2-event "struct&nbsp;<link linkend='v4l2-event'>v4l2_event</link>">
148<!ENTITY v4l2-event-subscription "struct&nbsp;<link linkend='v4l2-event-subscription'>v4l2_event_subscription</link>">
149<!ENTITY v4l2-event-vsync "struct&nbsp;<link linkend='v4l2-event-vsync'>v4l2_event_vsync</link>">
144<!ENTITY v4l2-ext-control "struct&nbsp;<link linkend='v4l2-ext-control'>v4l2_ext_control</link>"> 150<!ENTITY v4l2-ext-control "struct&nbsp;<link linkend='v4l2-ext-control'>v4l2_ext_control</link>">
145<!ENTITY v4l2-ext-controls "struct&nbsp;<link linkend='v4l2-ext-controls'>v4l2_ext_controls</link>"> 151<!ENTITY v4l2-ext-controls "struct&nbsp;<link linkend='v4l2-ext-controls'>v4l2_ext_controls</link>">
146<!ENTITY v4l2-fmtdesc "struct&nbsp;<link linkend='v4l2-fmtdesc'>v4l2_fmtdesc</link>"> 152<!ENTITY v4l2-fmtdesc "struct&nbsp;<link linkend='v4l2-fmtdesc'>v4l2_fmtdesc</link>">
@@ -200,6 +206,7 @@
200<!ENTITY sub-controls SYSTEM "v4l/controls.xml"> 206<!ENTITY sub-controls SYSTEM "v4l/controls.xml">
201<!ENTITY sub-dev-capture SYSTEM "v4l/dev-capture.xml"> 207<!ENTITY sub-dev-capture SYSTEM "v4l/dev-capture.xml">
202<!ENTITY sub-dev-codec SYSTEM "v4l/dev-codec.xml"> 208<!ENTITY sub-dev-codec SYSTEM "v4l/dev-codec.xml">
209<!ENTITY sub-dev-event SYSTEM "v4l/dev-event.xml">
203<!ENTITY sub-dev-effect SYSTEM "v4l/dev-effect.xml"> 210<!ENTITY sub-dev-effect SYSTEM "v4l/dev-effect.xml">
204<!ENTITY sub-dev-osd SYSTEM "v4l/dev-osd.xml"> 211<!ENTITY sub-dev-osd SYSTEM "v4l/dev-osd.xml">
205<!ENTITY sub-dev-output SYSTEM "v4l/dev-output.xml"> 212<!ENTITY sub-dev-output SYSTEM "v4l/dev-output.xml">
@@ -292,6 +299,8 @@
292<!ENTITY sub-v4l2grab-c SYSTEM "v4l/v4l2grab.c.xml"> 299<!ENTITY sub-v4l2grab-c SYSTEM "v4l/v4l2grab.c.xml">
293<!ENTITY sub-videodev2-h SYSTEM "v4l/videodev2.h.xml"> 300<!ENTITY sub-videodev2-h SYSTEM "v4l/videodev2.h.xml">
294<!ENTITY sub-v4l2 SYSTEM "v4l/v4l2.xml"> 301<!ENTITY sub-v4l2 SYSTEM "v4l/v4l2.xml">
302<!ENTITY sub-dqevent SYSTEM "v4l/vidioc-dqevent.xml">
303<!ENTITY sub-subscribe-event SYSTEM "v4l/vidioc-subscribe-event.xml">
295<!ENTITY sub-intro SYSTEM "dvb/intro.xml"> 304<!ENTITY sub-intro SYSTEM "dvb/intro.xml">
296<!ENTITY sub-frontend SYSTEM "dvb/frontend.xml"> 305<!ENTITY sub-frontend SYSTEM "dvb/frontend.xml">
297<!ENTITY sub-dvbproperty SYSTEM "dvb/dvbproperty.xml"> 306<!ENTITY sub-dvbproperty SYSTEM "dvb/dvbproperty.xml">
@@ -381,3 +390,5 @@
381<!ENTITY reqbufs SYSTEM "v4l/vidioc-reqbufs.xml"> 390<!ENTITY reqbufs SYSTEM "v4l/vidioc-reqbufs.xml">
382<!ENTITY s-hw-freq-seek SYSTEM "v4l/vidioc-s-hw-freq-seek.xml"> 391<!ENTITY s-hw-freq-seek SYSTEM "v4l/vidioc-s-hw-freq-seek.xml">
383<!ENTITY streamon SYSTEM "v4l/vidioc-streamon.xml"> 392<!ENTITY streamon SYSTEM "v4l/vidioc-streamon.xml">
393<!ENTITY dqevent SYSTEM "v4l/vidioc-dqevent.xml">
394<!ENTITY subscribe_event SYSTEM "v4l/vidioc-subscribe-event.xml">
diff --git a/Documentation/DocBook/mtdnand.tmpl b/Documentation/DocBook/mtdnand.tmpl
index 5e7d84b48505..020ac80d4682 100644
--- a/Documentation/DocBook/mtdnand.tmpl
+++ b/Documentation/DocBook/mtdnand.tmpl
@@ -269,7 +269,7 @@ static void board_hwcontrol(struct mtd_info *mtd, int cmd)
269 information about the device. 269 information about the device.
270 </para> 270 </para>
271 <programlisting> 271 <programlisting>
272int __init board_init (void) 272static int __init board_init (void)
273{ 273{
274 struct nand_chip *this; 274 struct nand_chip *this;
275 int err = 0; 275 int err = 0;
@@ -488,7 +488,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip)
488 The ECC bytes must be placed immidiately after the data 488 The ECC bytes must be placed immidiately after the data
489 bytes in order to make the syndrome generator work. This 489 bytes in order to make the syndrome generator work. This
490 is contrary to the usual layout used by software ECC. The 490 is contrary to the usual layout used by software ECC. The
491 seperation of data and out of band area is not longer 491 separation of data and out of band area is not longer
492 possible. The nand driver code handles this layout and 492 possible. The nand driver code handles this layout and
493 the remaining free bytes in the oob area are managed by 493 the remaining free bytes in the oob area are managed by
494 the autoplacement code. Provide a matching oob-layout 494 the autoplacement code. Provide a matching oob-layout
@@ -560,7 +560,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip)
560 bad blocks. They have factory marked good blocks. The marker pattern 560 bad blocks. They have factory marked good blocks. The marker pattern
561 is erased when the block is erased to be reused. So in case of 561 is erased when the block is erased to be reused. So in case of
562 powerloss before writing the pattern back to the chip this block 562 powerloss before writing the pattern back to the chip this block
563 would be lost and added to the bad blocks. Therefor we scan the 563 would be lost and added to the bad blocks. Therefore we scan the
564 chip(s) when we detect them the first time for good blocks and 564 chip(s) when we detect them the first time for good blocks and
565 store this information in a bad block table before erasing any 565 store this information in a bad block table before erasing any
566 of the blocks. 566 of the blocks.
@@ -1094,7 +1094,7 @@ in this page</entry>
1094 manufacturers specifications. This applies similar to the spare area. 1094 manufacturers specifications. This applies similar to the spare area.
1095 </para> 1095 </para>
1096 <para> 1096 <para>
1097 Therefor NAND aware filesystems must either write in page size chunks 1097 Therefore NAND aware filesystems must either write in page size chunks
1098 or hold a writebuffer to collect smaller writes until they sum up to 1098 or hold a writebuffer to collect smaller writes until they sum up to
1099 pagesize. Available NAND aware filesystems: JFFS2, YAFFS. 1099 pagesize. Available NAND aware filesystems: JFFS2, YAFFS.
1100 </para> 1100 </para>
diff --git a/Documentation/DocBook/sh.tmpl b/Documentation/DocBook/sh.tmpl
index 0c3dc4c69dd1..d858d92cf6d9 100644
--- a/Documentation/DocBook/sh.tmpl
+++ b/Documentation/DocBook/sh.tmpl
@@ -19,13 +19,17 @@
19 </authorgroup> 19 </authorgroup>
20 20
21 <copyright> 21 <copyright>
22 <year>2008</year> 22 <year>2008-2010</year>
23 <holder>Paul Mundt</holder> 23 <holder>Paul Mundt</holder>
24 </copyright> 24 </copyright>
25 <copyright> 25 <copyright>
26 <year>2008</year> 26 <year>2008-2010</year>
27 <holder>Renesas Technology Corp.</holder> 27 <holder>Renesas Technology Corp.</holder>
28 </copyright> 28 </copyright>
29 <copyright>
30 <year>2010</year>
31 <holder>Renesas Electronics Corp.</holder>
32 </copyright>
29 33
30 <legalnotice> 34 <legalnotice>
31 <para> 35 <para>
@@ -77,7 +81,7 @@
77 </chapter> 81 </chapter>
78 <chapter id="clk"> 82 <chapter id="clk">
79 <title>Clock Framework Extensions</title> 83 <title>Clock Framework Extensions</title>
80!Iarch/sh/include/asm/clock.h 84!Iinclude/linux/sh_clk.h
81 </chapter> 85 </chapter>
82 <chapter id="mach"> 86 <chapter id="mach">
83 <title>Machine Specific Interfaces</title> 87 <title>Machine Specific Interfaces</title>
diff --git a/Documentation/DocBook/tracepoint.tmpl b/Documentation/DocBook/tracepoint.tmpl
index 8bca1d5cec09..e8473eae2a20 100644
--- a/Documentation/DocBook/tracepoint.tmpl
+++ b/Documentation/DocBook/tracepoint.tmpl
@@ -16,6 +16,15 @@
16 </address> 16 </address>
17 </affiliation> 17 </affiliation>
18 </author> 18 </author>
19 <author>
20 <firstname>William</firstname>
21 <surname>Cohen</surname>
22 <affiliation>
23 <address>
24 <email>wcohen@redhat.com</email>
25 </address>
26 </affiliation>
27 </author>
19 </authorgroup> 28 </authorgroup>
20 29
21 <legalnotice> 30 <legalnotice>
@@ -91,4 +100,8 @@
91!Iinclude/trace/events/signal.h 100!Iinclude/trace/events/signal.h
92 </chapter> 101 </chapter>
93 102
103 <chapter id="block">
104 <title>Block IO</title>
105!Iinclude/trace/events/block.h
106 </chapter>
94</book> 107</book>
diff --git a/Documentation/DocBook/v4l/common.xml b/Documentation/DocBook/v4l/common.xml
index c65f0ac9b6ee..cea23e1c4fc6 100644
--- a/Documentation/DocBook/v4l/common.xml
+++ b/Documentation/DocBook/v4l/common.xml
@@ -1170,7 +1170,7 @@ frames per second. If less than this number of frames is to be
1170captured or output, applications can request frame skipping or 1170captured or output, applications can request frame skipping or
1171duplicating on the driver side. This is especially useful when using 1171duplicating on the driver side. This is especially useful when using
1172the &func-read; or &func-write;, which are not augmented by timestamps 1172the &func-read; or &func-write;, which are not augmented by timestamps
1173or sequence counters, and to avoid unneccessary data copying.</para> 1173or sequence counters, and to avoid unnecessary data copying.</para>
1174 1174
1175 <para>Finally these ioctls can be used to determine the number of 1175 <para>Finally these ioctls can be used to determine the number of
1176buffers used internally by a driver in read/write mode. For 1176buffers used internally by a driver in read/write mode. For
diff --git a/Documentation/DocBook/v4l/compat.xml b/Documentation/DocBook/v4l/compat.xml
index b9dbdf9e6d29..b42b935913cd 100644
--- a/Documentation/DocBook/v4l/compat.xml
+++ b/Documentation/DocBook/v4l/compat.xml
@@ -2332,15 +2332,26 @@ more information.</para>
2332 </listitem> 2332 </listitem>
2333 </orderedlist> 2333 </orderedlist>
2334 </section> 2334 </section>
2335 </section> 2335 <section>
2336 <title>V4L2 in Linux 2.6.34</title>
2337 <orderedlist>
2338 <listitem>
2339 <para>Added
2340<constant>V4L2_CID_IRIS_ABSOLUTE</constant> and
2341<constant>V4L2_CID_IRIS_RELATIVE</constant> controls to the
2342 <link linkend="camera-controls">Camera controls class</link>.
2343 </para>
2344 </listitem>
2345 </orderedlist>
2346 </section>
2336 2347
2337 <section id="other"> 2348 <section id="other">
2338 <title>Relation of V4L2 to other Linux multimedia APIs</title> 2349 <title>Relation of V4L2 to other Linux multimedia APIs</title>
2339 2350
2340 <section id="xvideo"> 2351 <section id="xvideo">
2341 <title>X Video Extension</title> 2352 <title>X Video Extension</title>
2342 2353
2343 <para>The X Video Extension (abbreviated XVideo or just Xv) is 2354 <para>The X Video Extension (abbreviated XVideo or just Xv) is
2344an extension of the X Window system, implemented for example by the 2355an extension of the X Window system, implemented for example by the
2345XFree86 project. Its scope is similar to V4L2, an API to video capture 2356XFree86 project. Its scope is similar to V4L2, an API to video capture
2346and output devices for X clients. Xv allows applications to display 2357and output devices for X clients. Xv allows applications to display
@@ -2351,7 +2362,7 @@ capture or output still images in XPixmaps<footnote>
2351extension available across many operating systems and 2362extension available across many operating systems and
2352architectures.</para> 2363architectures.</para>
2353 2364
2354 <para>Because the driver is embedded into the X server Xv has a 2365 <para>Because the driver is embedded into the X server Xv has a
2355number of advantages over the V4L2 <link linkend="overlay">video 2366number of advantages over the V4L2 <link linkend="overlay">video
2356overlay interface</link>. The driver can easily determine the overlay 2367overlay interface</link>. The driver can easily determine the overlay
2357target, &ie; visible graphics memory or off-screen buffers for a 2368target, &ie; visible graphics memory or off-screen buffers for a
@@ -2360,16 +2371,16 @@ overlay, scaling or color-keying, or the clipping functions of the
2360video capture hardware, always in sync with drawing operations or 2371video capture hardware, always in sync with drawing operations or
2361windows moving or changing their stacking order.</para> 2372windows moving or changing their stacking order.</para>
2362 2373
2363 <para>To combine the advantages of Xv and V4L a special Xv 2374 <para>To combine the advantages of Xv and V4L a special Xv
2364driver exists in XFree86 and XOrg, just programming any overlay capable 2375driver exists in XFree86 and XOrg, just programming any overlay capable
2365Video4Linux device it finds. To enable it 2376Video4Linux device it finds. To enable it
2366<filename>/etc/X11/XF86Config</filename> must contain these lines:</para> 2377<filename>/etc/X11/XF86Config</filename> must contain these lines:</para>
2367 <para><screen> 2378 <para><screen>
2368Section "Module" 2379Section "Module"
2369 Load "v4l" 2380 Load "v4l"
2370EndSection</screen></para> 2381EndSection</screen></para>
2371 2382
2372 <para>As of XFree86 4.2 this driver still supports only V4L 2383 <para>As of XFree86 4.2 this driver still supports only V4L
2373ioctls, however it should work just fine with all V4L2 devices through 2384ioctls, however it should work just fine with all V4L2 devices through
2374the V4L2 backward-compatibility layer. Since V4L2 permits multiple 2385the V4L2 backward-compatibility layer. Since V4L2 permits multiple
2375opens it is possible (if supported by the V4L2 driver) to capture 2386opens it is possible (if supported by the V4L2 driver) to capture
@@ -2377,83 +2388,84 @@ video while an X client requested video overlay. Restrictions of
2377simultaneous capturing and overlay are discussed in <xref 2388simultaneous capturing and overlay are discussed in <xref
2378 linkend="overlay" /> apply.</para> 2389 linkend="overlay" /> apply.</para>
2379 2390
2380 <para>Only marginally related to V4L2, XFree86 extended Xv to 2391 <para>Only marginally related to V4L2, XFree86 extended Xv to
2381support hardware YUV to RGB conversion and scaling for faster video 2392support hardware YUV to RGB conversion and scaling for faster video
2382playback, and added an interface to MPEG-2 decoding hardware. This API 2393playback, and added an interface to MPEG-2 decoding hardware. This API
2383is useful to display images captured with V4L2 devices.</para> 2394is useful to display images captured with V4L2 devices.</para>
2384 </section> 2395 </section>
2385 2396
2386 <section> 2397 <section>
2387 <title>Digital Video</title> 2398 <title>Digital Video</title>
2388 2399
2389 <para>V4L2 does not support digital terrestrial, cable or 2400 <para>V4L2 does not support digital terrestrial, cable or
2390satellite broadcast. A separate project aiming at digital receivers 2401satellite broadcast. A separate project aiming at digital receivers
2391exists. You can find its homepage at <ulink 2402exists. You can find its homepage at <ulink
2392url="http://linuxtv.org">http://linuxtv.org</ulink>. The Linux DVB API 2403url="http://linuxtv.org">http://linuxtv.org</ulink>. The Linux DVB API
2393has no connection to the V4L2 API except that drivers for hybrid 2404has no connection to the V4L2 API except that drivers for hybrid
2394hardware may support both.</para> 2405hardware may support both.</para>
2395 </section> 2406 </section>
2396 2407
2397 <section> 2408 <section>
2398 <title>Audio Interfaces</title> 2409 <title>Audio Interfaces</title>
2399 2410
2400 <para>[to do - OSS/ALSA]</para> 2411 <para>[to do - OSS/ALSA]</para>
2412 </section>
2401 </section> 2413 </section>
2402 </section>
2403 2414
2404 <section id="experimental"> 2415 <section id="experimental">
2405 <title>Experimental API Elements</title> 2416 <title>Experimental API Elements</title>
2406 2417
2407 <para>The following V4L2 API elements are currently experimental 2418 <para>The following V4L2 API elements are currently experimental
2408and may change in the future.</para> 2419and may change in the future.</para>
2409 2420
2410 <itemizedlist> 2421 <itemizedlist>
2411 <listitem> 2422 <listitem>
2412 <para>Video Output Overlay (OSD) Interface, <xref 2423 <para>Video Output Overlay (OSD) Interface, <xref
2413 linkend="osd" />.</para> 2424 linkend="osd" />.</para>
2414 </listitem> 2425 </listitem>
2415 <listitem> 2426 <listitem>
2416 <para><constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</constant>, 2427 <para><constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</constant>,
2417 &v4l2-buf-type;, <xref linkend="v4l2-buf-type" />.</para> 2428 &v4l2-buf-type;, <xref linkend="v4l2-buf-type" />.</para>
2418 </listitem> 2429 </listitem>
2419 <listitem> 2430 <listitem>
2420 <para><constant>V4L2_CAP_VIDEO_OUTPUT_OVERLAY</constant>, 2431 <para><constant>V4L2_CAP_VIDEO_OUTPUT_OVERLAY</constant>,
2421&VIDIOC-QUERYCAP; ioctl, <xref linkend="device-capabilities" />.</para> 2432&VIDIOC-QUERYCAP; ioctl, <xref linkend="device-capabilities" />.</para>
2422 </listitem> 2433 </listitem>
2423 <listitem> 2434 <listitem>
2424 <para>&VIDIOC-ENUM-FRAMESIZES; and 2435 <para>&VIDIOC-ENUM-FRAMESIZES; and
2425&VIDIOC-ENUM-FRAMEINTERVALS; ioctls.</para> 2436&VIDIOC-ENUM-FRAMEINTERVALS; ioctls.</para>
2426 </listitem> 2437 </listitem>
2427 <listitem> 2438 <listitem>
2428 <para>&VIDIOC-G-ENC-INDEX; ioctl.</para> 2439 <para>&VIDIOC-G-ENC-INDEX; ioctl.</para>
2429 </listitem> 2440 </listitem>
2430 <listitem> 2441 <listitem>
2431 <para>&VIDIOC-ENCODER-CMD; and &VIDIOC-TRY-ENCODER-CMD; 2442 <para>&VIDIOC-ENCODER-CMD; and &VIDIOC-TRY-ENCODER-CMD;
2432ioctls.</para> 2443ioctls.</para>
2433 </listitem> 2444 </listitem>
2434 <listitem> 2445 <listitem>
2435 <para>&VIDIOC-DBG-G-REGISTER; and &VIDIOC-DBG-S-REGISTER; 2446 <para>&VIDIOC-DBG-G-REGISTER; and &VIDIOC-DBG-S-REGISTER;
2436ioctls.</para> 2447ioctls.</para>
2437 </listitem> 2448 </listitem>
2438 <listitem> 2449 <listitem>
2439 <para>&VIDIOC-DBG-G-CHIP-IDENT; ioctl.</para> 2450 <para>&VIDIOC-DBG-G-CHIP-IDENT; ioctl.</para>
2440 </listitem> 2451 </listitem>
2441 </itemizedlist> 2452 </itemizedlist>
2442 </section> 2453 </section>
2443 2454
2444 <section id="obsolete"> 2455 <section id="obsolete">
2445 <title>Obsolete API Elements</title> 2456 <title>Obsolete API Elements</title>
2446 2457
2447 <para>The following V4L2 API elements were superseded by new 2458 <para>The following V4L2 API elements were superseded by new
2448interfaces and should not be implemented in new drivers.</para> 2459interfaces and should not be implemented in new drivers.</para>
2449 2460
2450 <itemizedlist> 2461 <itemizedlist>
2451 <listitem> 2462 <listitem>
2452 <para><constant>VIDIOC_G_MPEGCOMP</constant> and 2463 <para><constant>VIDIOC_G_MPEGCOMP</constant> and
2453<constant>VIDIOC_S_MPEGCOMP</constant> ioctls. Use Extended Controls, 2464<constant>VIDIOC_S_MPEGCOMP</constant> ioctls. Use Extended Controls,
2454<xref linkend="extended-controls" />.</para> 2465<xref linkend="extended-controls" />.</para>
2455 </listitem> 2466 </listitem>
2456 </itemizedlist> 2467 </itemizedlist>
2468 </section>
2457 </section> 2469 </section>
2458 2470
2459 <!-- 2471 <!--
diff --git a/Documentation/DocBook/v4l/controls.xml b/Documentation/DocBook/v4l/controls.xml
index f46450610412..8408caaee276 100644
--- a/Documentation/DocBook/v4l/controls.xml
+++ b/Documentation/DocBook/v4l/controls.xml
@@ -267,6 +267,12 @@ minimum value disables backlight compensation.</entry>
267 <entry>Chroma automatic gain control.</entry> 267 <entry>Chroma automatic gain control.</entry>
268 </row> 268 </row>
269 <row> 269 <row>
270 <entry><constant>V4L2_CID_CHROMA_GAIN</constant></entry>
271 <entry>integer</entry>
272 <entry>Adjusts the Chroma gain control (for use when chroma AGC
273 is disabled).</entry>
274 </row>
275 <row>
270 <entry><constant>V4L2_CID_COLOR_KILLER</constant></entry> 276 <entry><constant>V4L2_CID_COLOR_KILLER</constant></entry>
271 <entry>boolean</entry> 277 <entry>boolean</entry>
272 <entry>Enable the color killer (&ie; force a black &amp; white image in case of a weak video signal).</entry> 278 <entry>Enable the color killer (&ie; force a black &amp; white image in case of a weak video signal).</entry>
@@ -277,8 +283,15 @@ minimum value disables backlight compensation.</entry>
277 <entry>Selects a color effect. Possible values for 283 <entry>Selects a color effect. Possible values for
278<constant>enum v4l2_colorfx</constant> are: 284<constant>enum v4l2_colorfx</constant> are:
279<constant>V4L2_COLORFX_NONE</constant> (0), 285<constant>V4L2_COLORFX_NONE</constant> (0),
280<constant>V4L2_COLORFX_BW</constant> (1) and 286<constant>V4L2_COLORFX_BW</constant> (1),
281<constant>V4L2_COLORFX_SEPIA</constant> (2).</entry> 287<constant>V4L2_COLORFX_SEPIA</constant> (2),
288<constant>V4L2_COLORFX_NEGATIVE</constant> (3),
289<constant>V4L2_COLORFX_EMBOSS</constant> (4),
290<constant>V4L2_COLORFX_SKETCH</constant> (5),
291<constant>V4L2_COLORFX_SKY_BLUE</constant> (6),
292<constant>V4L2_COLORFX_GRASS_GREEN</constant> (7),
293<constant>V4L2_COLORFX_SKIN_WHITEN</constant> (8) and
294<constant>V4L2_COLORFX_VIVID</constant> (9).</entry>
282 </row> 295 </row>
283 <row> 296 <row>
284 <entry><constant>V4L2_CID_ROTATE</constant></entry> 297 <entry><constant>V4L2_CID_ROTATE</constant></entry>
@@ -1825,6 +1838,25 @@ wide-angle direction. The zoom speed unit is driver-specific.</entry>
1825 <row><entry></entry></row> 1838 <row><entry></entry></row>
1826 1839
1827 <row> 1840 <row>
1841 <entry spanname="id"><constant>V4L2_CID_IRIS_ABSOLUTE</constant>&nbsp;</entry>
1842 <entry>integer</entry>
1843 </row><row><entry spanname="descr">This control sets the
1844camera's aperture to the specified value. The unit is undefined.
1845Larger values open the iris wider, smaller values close it.</entry>
1846 </row>
1847 <row><entry></entry></row>
1848
1849 <row>
1850 <entry spanname="id"><constant>V4L2_CID_IRIS_RELATIVE</constant>&nbsp;</entry>
1851 <entry>integer</entry>
1852 </row><row><entry spanname="descr">This control modifies the
1853camera's aperture by the specified amount. The unit is undefined.
1854Positive values open the iris one step further, negative values close
1855it one step further. This is a write-only control.</entry>
1856 </row>
1857 <row><entry></entry></row>
1858
1859 <row>
1828 <entry spanname="id"><constant>V4L2_CID_PRIVACY</constant>&nbsp;</entry> 1860 <entry spanname="id"><constant>V4L2_CID_PRIVACY</constant>&nbsp;</entry>
1829 <entry>boolean</entry> 1861 <entry>boolean</entry>
1830 </row><row><entry spanname="descr">Prevent video from being acquired 1862 </row><row><entry spanname="descr">Prevent video from being acquired
diff --git a/Documentation/DocBook/v4l/dev-event.xml b/Documentation/DocBook/v4l/dev-event.xml
new file mode 100644
index 000000000000..be5a98fb4fab
--- /dev/null
+++ b/Documentation/DocBook/v4l/dev-event.xml
@@ -0,0 +1,31 @@
1 <title>Event Interface</title>
2
3 <para>The V4L2 event interface provides means for user to get
4 immediately notified on certain conditions taking place on a device.
5 This might include start of frame or loss of signal events, for
6 example.
7 </para>
8
9 <para>To receive events, the events the user is interested in first must
10 be subscribed using the &VIDIOC-SUBSCRIBE-EVENT; ioctl. Once an event is
11 subscribed, the events of subscribed types are dequeueable using the
12 &VIDIOC-DQEVENT; ioctl. Events may be unsubscribed using
13 VIDIOC_UNSUBSCRIBE_EVENT ioctl. The special event type V4L2_EVENT_ALL may
14 be used to unsubscribe all the events the driver supports.</para>
15
16 <para>The event subscriptions and event queues are specific to file
17 handles. Subscribing an event on one file handle does not affect
18 other file handles.
19 </para>
20
21 <para>The information on dequeueable events is obtained by using select or
22 poll system calls on video devices. The V4L2 events use POLLPRI events on
23 poll system call and exceptions on select system call. </para>
24
25 <!--
26Local Variables:
27mode: sgml
28sgml-parent-document: "v4l2.sgml"
29indent-tabs-mode: nil
30End:
31 -->
diff --git a/Documentation/DocBook/v4l/io.xml b/Documentation/DocBook/v4l/io.xml
index f92f24323b2a..d424886beda0 100644
--- a/Documentation/DocBook/v4l/io.xml
+++ b/Documentation/DocBook/v4l/io.xml
@@ -589,7 +589,8 @@ number of a video input as in &v4l2-input; field
589 <entry></entry> 589 <entry></entry>
590 <entry>A place holder for future extensions and custom 590 <entry>A place holder for future extensions and custom
591(driver defined) buffer types 591(driver defined) buffer types
592<constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher.</entry> 592<constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher. Applications
593should set this to 0.</entry>
593 </row> 594 </row>
594 </tbody> 595 </tbody>
595 </tgroup> 596 </tgroup>
@@ -701,6 +702,16 @@ They can be both cleared however, then the buffer is in "dequeued"
701state, in the application domain to say so.</entry> 702state, in the application domain to say so.</entry>
702 </row> 703 </row>
703 <row> 704 <row>
705 <entry><constant>V4L2_BUF_FLAG_ERROR</constant></entry>
706 <entry>0x0040</entry>
707 <entry>When this flag is set, the buffer has been dequeued
708 successfully, although the data might have been corrupted.
709 This is recoverable, streaming may continue as normal and
710 the buffer may be reused normally.
711 Drivers set this flag when the <constant>VIDIOC_DQBUF</constant>
712 ioctl is called.</entry>
713 </row>
714 <row>
704 <entry><constant>V4L2_BUF_FLAG_KEYFRAME</constant></entry> 715 <entry><constant>V4L2_BUF_FLAG_KEYFRAME</constant></entry>
705 <entry>0x0008</entry> 716 <entry>0x0008</entry>
706 <entry>Drivers set or clear this flag when calling the 717 <entry>Drivers set or clear this flag when calling the
@@ -917,8 +928,8 @@ order</emphasis>.</para>
917 928
918 <para>When the driver provides or accepts images field by field 929 <para>When the driver provides or accepts images field by field
919rather than interleaved, it is also important applications understand 930rather than interleaved, it is also important applications understand
920how the fields combine to frames. We distinguish between top and 931how the fields combine to frames. We distinguish between top (aka odd) and
921bottom fields, the <emphasis>spatial order</emphasis>: The first line 932bottom (aka even) fields, the <emphasis>spatial order</emphasis>: The first line
922of the top field is the first line of an interlaced frame, the first 933of the top field is the first line of an interlaced frame, the first
923line of the bottom field is the second line of that frame.</para> 934line of the bottom field is the second line of that frame.</para>
924 935
@@ -971,12 +982,12 @@ between <constant>V4L2_FIELD_TOP</constant> and
971 <row> 982 <row>
972 <entry><constant>V4L2_FIELD_TOP</constant></entry> 983 <entry><constant>V4L2_FIELD_TOP</constant></entry>
973 <entry>2</entry> 984 <entry>2</entry>
974 <entry>Images consist of the top field only.</entry> 985 <entry>Images consist of the top (aka odd) field only.</entry>
975 </row> 986 </row>
976 <row> 987 <row>
977 <entry><constant>V4L2_FIELD_BOTTOM</constant></entry> 988 <entry><constant>V4L2_FIELD_BOTTOM</constant></entry>
978 <entry>3</entry> 989 <entry>3</entry>
979 <entry>Images consist of the bottom field only. 990 <entry>Images consist of the bottom (aka even) field only.
980Applications may wish to prevent a device from capturing interlaced 991Applications may wish to prevent a device from capturing interlaced
981images because they will have "comb" or "feathering" artefacts around 992images because they will have "comb" or "feathering" artefacts around
982moving objects.</entry> 993moving objects.</entry>
diff --git a/Documentation/DocBook/v4l/pixfmt.xml b/Documentation/DocBook/v4l/pixfmt.xml
index 885968d6a2fc..c4ad0a8e42dc 100644
--- a/Documentation/DocBook/v4l/pixfmt.xml
+++ b/Documentation/DocBook/v4l/pixfmt.xml
@@ -792,6 +792,18 @@ http://www.thedirks.org/winnov/</ulink></para></entry>
792 <entry>'YYUV'</entry> 792 <entry>'YYUV'</entry>
793 <entry>unknown</entry> 793 <entry>unknown</entry>
794 </row> 794 </row>
795 <row id="V4L2-PIX-FMT-Y4">
796 <entry><constant>V4L2_PIX_FMT_Y4</constant></entry>
797 <entry>'Y04 '</entry>
798 <entry>Old 4-bit greyscale format. Only the least significant 4 bits of each byte are used,
799the other bits are set to 0.</entry>
800 </row>
801 <row id="V4L2-PIX-FMT-Y6">
802 <entry><constant>V4L2_PIX_FMT_Y6</constant></entry>
803 <entry>'Y06 '</entry>
804 <entry>Old 6-bit greyscale format. Only the least significant 6 bits of each byte are used,
805the other bits are set to 0.</entry>
806 </row>
795 </tbody> 807 </tbody>
796 </tgroup> 808 </tgroup>
797 </table> 809 </table>
diff --git a/Documentation/DocBook/v4l/v4l2.xml b/Documentation/DocBook/v4l/v4l2.xml
index 060105af49e5..9737243377a3 100644
--- a/Documentation/DocBook/v4l/v4l2.xml
+++ b/Documentation/DocBook/v4l/v4l2.xml
@@ -401,6 +401,7 @@ and discussions on the V4L mailing list.</revremark>
401 <section id="ttx"> &sub-dev-teletext; </section> 401 <section id="ttx"> &sub-dev-teletext; </section>
402 <section id="radio"> &sub-dev-radio; </section> 402 <section id="radio"> &sub-dev-radio; </section>
403 <section id="rds"> &sub-dev-rds; </section> 403 <section id="rds"> &sub-dev-rds; </section>
404 <section id="event"> &sub-dev-event; </section>
404 </chapter> 405 </chapter>
405 406
406 <chapter id="driver"> 407 <chapter id="driver">
@@ -426,6 +427,7 @@ and discussions on the V4L mailing list.</revremark>
426 &sub-cropcap; 427 &sub-cropcap;
427 &sub-dbg-g-chip-ident; 428 &sub-dbg-g-chip-ident;
428 &sub-dbg-g-register; 429 &sub-dbg-g-register;
430 &sub-dqevent;
429 &sub-encoder-cmd; 431 &sub-encoder-cmd;
430 &sub-enumaudio; 432 &sub-enumaudio;
431 &sub-enumaudioout; 433 &sub-enumaudioout;
@@ -467,6 +469,7 @@ and discussions on the V4L mailing list.</revremark>
467 &sub-reqbufs; 469 &sub-reqbufs;
468 &sub-s-hw-freq-seek; 470 &sub-s-hw-freq-seek;
469 &sub-streamon; 471 &sub-streamon;
472 &sub-subscribe-event;
470 <!-- End of ioctls. --> 473 <!-- End of ioctls. -->
471 &sub-mmap; 474 &sub-mmap;
472 &sub-munmap; 475 &sub-munmap;
diff --git a/Documentation/DocBook/v4l/videodev2.h.xml b/Documentation/DocBook/v4l/videodev2.h.xml
index 068325940658..865b06d9e679 100644
--- a/Documentation/DocBook/v4l/videodev2.h.xml
+++ b/Documentation/DocBook/v4l/videodev2.h.xml
@@ -1018,6 +1018,13 @@ enum <link linkend="v4l2-colorfx">v4l2_colorfx</link> {
1018 V4L2_COLORFX_NONE = 0, 1018 V4L2_COLORFX_NONE = 0,
1019 V4L2_COLORFX_BW = 1, 1019 V4L2_COLORFX_BW = 1,
1020 V4L2_COLORFX_SEPIA = 2, 1020 V4L2_COLORFX_SEPIA = 2,
1021 V4L2_COLORFX_NEGATIVE = 3,
1022 V4L2_COLORFX_EMBOSS = 4,
1023 V4L2_COLORFX_SKETCH = 5,
1024 V4L2_COLORFX_SKY_BLUE = 6,
1025 V4L2_COLORFX_GRASS_GREEN = 7,
1026 V4L2_COLORFX_SKIN_WHITEN = 8,
1027 V4L2_COLORFX_VIVID = 9.
1021}; 1028};
1022#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32) 1029#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
1023#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33) 1030#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
@@ -1271,6 +1278,9 @@ enum <link linkend="v4l2-exposure-auto-type">v4l2_exposure_auto_type</link> {
1271 1278
1272#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) 1279#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
1273 1280
1281#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
1282#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18)
1283
1274/* FM Modulator class control IDs */ 1284/* FM Modulator class control IDs */
1275#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900) 1285#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
1276#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1) 1286#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
diff --git a/Documentation/DocBook/v4l/vidioc-dqevent.xml b/Documentation/DocBook/v4l/vidioc-dqevent.xml
new file mode 100644
index 000000000000..4e0a7cc30812
--- /dev/null
+++ b/Documentation/DocBook/v4l/vidioc-dqevent.xml
@@ -0,0 +1,131 @@
1<refentry id="vidioc-dqevent">
2 <refmeta>
3 <refentrytitle>ioctl VIDIOC_DQEVENT</refentrytitle>
4 &manvol;
5 </refmeta>
6
7 <refnamediv>
8 <refname>VIDIOC_DQEVENT</refname>
9 <refpurpose>Dequeue event</refpurpose>
10 </refnamediv>
11
12 <refsynopsisdiv>
13 <funcsynopsis>
14 <funcprototype>
15 <funcdef>int <function>ioctl</function></funcdef>
16 <paramdef>int <parameter>fd</parameter></paramdef>
17 <paramdef>int <parameter>request</parameter></paramdef>
18 <paramdef>struct v4l2_event
19*<parameter>argp</parameter></paramdef>
20 </funcprototype>
21 </funcsynopsis>
22 </refsynopsisdiv>
23
24 <refsect1>
25 <title>Arguments</title>
26
27 <variablelist>
28 <varlistentry>
29 <term><parameter>fd</parameter></term>
30 <listitem>
31 <para>&fd;</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term><parameter>request</parameter></term>
36 <listitem>
37 <para>VIDIOC_DQEVENT</para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><parameter>argp</parameter></term>
42 <listitem>
43 <para></para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsect1>
48
49 <refsect1>
50 <title>Description</title>
51
52 <para>Dequeue an event from a video device. No input is required
53 for this ioctl. All the fields of the &v4l2-event; structure are
54 filled by the driver. The file handle will also receive exceptions
55 which the application may get by e.g. using the select system
56 call.</para>
57
58 <table frame="none" pgwide="1" id="v4l2-event">
59 <title>struct <structname>v4l2_event</structname></title>
60 <tgroup cols="4">
61 &cs-str;
62 <tbody valign="top">
63 <row>
64 <entry>__u32</entry>
65 <entry><structfield>type</structfield></entry>
66 <entry></entry>
67 <entry>Type of the event.</entry>
68 </row>
69 <row>
70 <entry>union</entry>
71 <entry><structfield>u</structfield></entry>
72 <entry></entry>
73 <entry></entry>
74 </row>
75 <row>
76 <entry></entry>
77 <entry>&v4l2-event-vsync;</entry>
78 <entry><structfield>vsync</structfield></entry>
79 <entry>Event data for event V4L2_EVENT_VSYNC.
80 </entry>
81 </row>
82 <row>
83 <entry></entry>
84 <entry>__u8</entry>
85 <entry><structfield>data</structfield>[64]</entry>
86 <entry>Event data. Defined by the event type. The union
87 should be used to define easily accessible type for
88 events.</entry>
89 </row>
90 <row>
91 <entry>__u32</entry>
92 <entry><structfield>pending</structfield></entry>
93 <entry></entry>
94 <entry>Number of pending events excluding this one.</entry>
95 </row>
96 <row>
97 <entry>__u32</entry>
98 <entry><structfield>sequence</structfield></entry>
99 <entry></entry>
100 <entry>Event sequence number. The sequence number is
101 incremented for every subscribed event that takes place.
102 If sequence numbers are not contiguous it means that
103 events have been lost.
104 </entry>
105 </row>
106 <row>
107 <entry>struct timespec</entry>
108 <entry><structfield>timestamp</structfield></entry>
109 <entry></entry>
110 <entry>Event timestamp.</entry>
111 </row>
112 <row>
113 <entry>__u32</entry>
114 <entry><structfield>reserved</structfield>[9]</entry>
115 <entry></entry>
116 <entry>Reserved for future extensions. Drivers must set
117 the array to zero.</entry>
118 </row>
119 </tbody>
120 </tgroup>
121 </table>
122
123 </refsect1>
124</refentry>
125<!--
126Local Variables:
127mode: sgml
128sgml-parent-document: "v4l2.sgml"
129indent-tabs-mode: nil
130End:
131-->
diff --git a/Documentation/DocBook/v4l/vidioc-enuminput.xml b/Documentation/DocBook/v4l/vidioc-enuminput.xml
index 71b868e2fb8f..476fe1d2bba0 100644
--- a/Documentation/DocBook/v4l/vidioc-enuminput.xml
+++ b/Documentation/DocBook/v4l/vidioc-enuminput.xml
@@ -283,7 +283,7 @@ input/output interface to linux-media@vger.kernel.org on 19 Oct 2009.
283 <entry>This input supports setting DV presets by using VIDIOC_S_DV_PRESET.</entry> 283 <entry>This input supports setting DV presets by using VIDIOC_S_DV_PRESET.</entry>
284 </row> 284 </row>
285 <row> 285 <row>
286 <entry><constant>V4L2_OUT_CAP_CUSTOM_TIMINGS</constant></entry> 286 <entry><constant>V4L2_IN_CAP_CUSTOM_TIMINGS</constant></entry>
287 <entry>0x00000002</entry> 287 <entry>0x00000002</entry>
288 <entry>This input supports setting custom video timings by using VIDIOC_S_DV_TIMINGS.</entry> 288 <entry>This input supports setting custom video timings by using VIDIOC_S_DV_TIMINGS.</entry>
289 </row> 289 </row>
diff --git a/Documentation/DocBook/v4l/vidioc-g-parm.xml b/Documentation/DocBook/v4l/vidioc-g-parm.xml
index 78332d365ce9..392aa9e5571e 100644
--- a/Documentation/DocBook/v4l/vidioc-g-parm.xml
+++ b/Documentation/DocBook/v4l/vidioc-g-parm.xml
@@ -55,7 +55,7 @@ captured or output, applications can request frame skipping or
55duplicating on the driver side. This is especially useful when using 55duplicating on the driver side. This is especially useful when using
56the <function>read()</function> or <function>write()</function>, which 56the <function>read()</function> or <function>write()</function>, which
57are not augmented by timestamps or sequence counters, and to avoid 57are not augmented by timestamps or sequence counters, and to avoid
58unneccessary data copying.</para> 58unnecessary data copying.</para>
59 59
60 <para>Further these ioctls can be used to determine the number of 60 <para>Further these ioctls can be used to determine the number of
61buffers used internally by a driver in read/write mode. For 61buffers used internally by a driver in read/write mode. For
diff --git a/Documentation/DocBook/v4l/vidioc-qbuf.xml b/Documentation/DocBook/v4l/vidioc-qbuf.xml
index 187081778154..ab691ebf3b93 100644
--- a/Documentation/DocBook/v4l/vidioc-qbuf.xml
+++ b/Documentation/DocBook/v4l/vidioc-qbuf.xml
@@ -54,12 +54,10 @@ to enqueue an empty (capturing) or filled (output) buffer in the
54driver's incoming queue. The semantics depend on the selected I/O 54driver's incoming queue. The semantics depend on the selected I/O
55method.</para> 55method.</para>
56 56
57 <para>To enqueue a <link linkend="mmap">memory mapped</link> 57 <para>To enqueue a buffer applications set the <structfield>type</structfield>
58buffer applications set the <structfield>type</structfield> field of a 58field of a &v4l2-buffer; to the same buffer type as was previously used
59&v4l2-buffer; to the same buffer type as previously &v4l2-format; 59with &v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers;
60<structfield>type</structfield> and &v4l2-requestbuffers; 60<structfield>type</structfield>. Applications must also set the
61<structfield>type</structfield>, the <structfield>memory</structfield>
62field to <constant>V4L2_MEMORY_MMAP</constant> and the
63<structfield>index</structfield> field. Valid index numbers range from 61<structfield>index</structfield> field. Valid index numbers range from
64zero to the number of buffers allocated with &VIDIOC-REQBUFS; 62zero to the number of buffers allocated with &VIDIOC-REQBUFS;
65(&v4l2-requestbuffers; <structfield>count</structfield>) minus one. The 63(&v4l2-requestbuffers; <structfield>count</structfield>) minus one. The
@@ -70,8 +68,19 @@ intended for output (<structfield>type</structfield> is
70<constant>V4L2_BUF_TYPE_VBI_OUTPUT</constant>) applications must also 68<constant>V4L2_BUF_TYPE_VBI_OUTPUT</constant>) applications must also
71initialize the <structfield>bytesused</structfield>, 69initialize the <structfield>bytesused</structfield>,
72<structfield>field</structfield> and 70<structfield>field</structfield> and
73<structfield>timestamp</structfield> fields. See <xref 71<structfield>timestamp</structfield> fields, see <xref
74 linkend="buffer" /> for details. When 72linkend="buffer" /> for details.
73Applications must also set <structfield>flags</structfield> to 0. If a driver
74supports capturing from specific video inputs and you want to specify a video
75input, then <structfield>flags</structfield> should be set to
76<constant>V4L2_BUF_FLAG_INPUT</constant> and the field
77<structfield>input</structfield> must be initialized to the desired input.
78The <structfield>reserved</structfield> field must be set to 0.
79</para>
80
81 <para>To enqueue a <link linkend="mmap">memory mapped</link>
82buffer applications set the <structfield>memory</structfield>
83field to <constant>V4L2_MEMORY_MMAP</constant>. When
75<constant>VIDIOC_QBUF</constant> is called with a pointer to this 84<constant>VIDIOC_QBUF</constant> is called with a pointer to this
76structure the driver sets the 85structure the driver sets the
77<constant>V4L2_BUF_FLAG_MAPPED</constant> and 86<constant>V4L2_BUF_FLAG_MAPPED</constant> and
@@ -81,14 +90,10 @@ structure the driver sets the
81&EINVAL;.</para> 90&EINVAL;.</para>
82 91
83 <para>To enqueue a <link linkend="userp">user pointer</link> 92 <para>To enqueue a <link linkend="userp">user pointer</link>
84buffer applications set the <structfield>type</structfield> field of a 93buffer applications set the <structfield>memory</structfield>
85&v4l2-buffer; to the same buffer type as previously &v4l2-format; 94field to <constant>V4L2_MEMORY_USERPTR</constant>, the
86<structfield>type</structfield> and &v4l2-requestbuffers;
87<structfield>type</structfield>, the <structfield>memory</structfield>
88field to <constant>V4L2_MEMORY_USERPTR</constant> and the
89<structfield>m.userptr</structfield> field to the address of the 95<structfield>m.userptr</structfield> field to the address of the
90buffer and <structfield>length</structfield> to its size. When the 96buffer and <structfield>length</structfield> to its size.
91buffer is intended for output additional fields must be set as above.
92When <constant>VIDIOC_QBUF</constant> is called with a pointer to this 97When <constant>VIDIOC_QBUF</constant> is called with a pointer to this
93structure the driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant> 98structure the driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant>
94flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and 99flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and
@@ -96,16 +101,21 @@ flag and clears the <constant>V4L2_BUF_FLAG_MAPPED</constant> and
96<structfield>flags</structfield> field, or it returns an error code. 101<structfield>flags</structfield> field, or it returns an error code.
97This ioctl locks the memory pages of the buffer in physical memory, 102This ioctl locks the memory pages of the buffer in physical memory,
98they cannot be swapped out to disk. Buffers remain locked until 103they cannot be swapped out to disk. Buffers remain locked until
99dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl are 104dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is
100called, or until the device is closed.</para> 105called, or until the device is closed.</para>
101 106
102 <para>Applications call the <constant>VIDIOC_DQBUF</constant> 107 <para>Applications call the <constant>VIDIOC_DQBUF</constant>
103ioctl to dequeue a filled (capturing) or displayed (output) buffer 108ioctl to dequeue a filled (capturing) or displayed (output) buffer
104from the driver's outgoing queue. They just set the 109from the driver's outgoing queue. They just set the
105<structfield>type</structfield> and <structfield>memory</structfield> 110<structfield>type</structfield>, <structfield>memory</structfield>
111and <structfield>reserved</structfield>
106fields of a &v4l2-buffer; as above, when <constant>VIDIOC_DQBUF</constant> 112fields of a &v4l2-buffer; as above, when <constant>VIDIOC_DQBUF</constant>
107is called with a pointer to this structure the driver fills the 113is called with a pointer to this structure the driver fills the
108remaining fields or returns an error code.</para> 114remaining fields or returns an error code. The driver may also set
115<constant>V4L2_BUF_FLAG_ERROR</constant> in the <structfield>flags</structfield>
116field. It indicates a non-critical (recoverable) streaming error. In such case
117the application may continue as normal, but should be aware that data in the
118dequeued buffer might be corrupted.</para>
109 119
110 <para>By default <constant>VIDIOC_DQBUF</constant> blocks when no 120 <para>By default <constant>VIDIOC_DQBUF</constant> blocks when no
111buffer is in the outgoing queue. When the 121buffer is in the outgoing queue. When the
@@ -152,7 +162,13 @@ enqueue a user pointer buffer.</para>
152 <para><constant>VIDIOC_DQBUF</constant> failed due to an 162 <para><constant>VIDIOC_DQBUF</constant> failed due to an
153internal error. Can also indicate temporary problems like signal 163internal error. Can also indicate temporary problems like signal
154loss. Note the driver might dequeue an (empty) buffer despite 164loss. Note the driver might dequeue an (empty) buffer despite
155returning an error, or even stop capturing.</para> 165returning an error, or even stop capturing. Reusing such buffer may be unsafe
166though and its details (e.g. <structfield>index</structfield>) may not be
167returned either. It is recommended that drivers indicate recoverable errors
168by setting the <constant>V4L2_BUF_FLAG_ERROR</constant> and returning 0 instead.
169In that case the application should be able to safely reuse the buffer and
170continue streaming.
171 </para>
156 </listitem> 172 </listitem>
157 </varlistentry> 173 </varlistentry>
158 </variablelist> 174 </variablelist>
diff --git a/Documentation/DocBook/v4l/vidioc-querybuf.xml b/Documentation/DocBook/v4l/vidioc-querybuf.xml
index d834993e6191..e649805a4908 100644
--- a/Documentation/DocBook/v4l/vidioc-querybuf.xml
+++ b/Documentation/DocBook/v4l/vidioc-querybuf.xml
@@ -54,12 +54,13 @@ buffer at any time after buffers have been allocated with the
54&VIDIOC-REQBUFS; ioctl.</para> 54&VIDIOC-REQBUFS; ioctl.</para>
55 55
56 <para>Applications set the <structfield>type</structfield> field 56 <para>Applications set the <structfield>type</structfield> field
57 of a &v4l2-buffer; to the same buffer type as previously 57 of a &v4l2-buffer; to the same buffer type as was previously used with
58&v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers; 58&v4l2-format; <structfield>type</structfield> and &v4l2-requestbuffers;
59<structfield>type</structfield>, and the <structfield>index</structfield> 59<structfield>type</structfield>, and the <structfield>index</structfield>
60 field. Valid index numbers range from zero 60 field. Valid index numbers range from zero
61to the number of buffers allocated with &VIDIOC-REQBUFS; 61to the number of buffers allocated with &VIDIOC-REQBUFS;
62 (&v4l2-requestbuffers; <structfield>count</structfield>) minus one. 62 (&v4l2-requestbuffers; <structfield>count</structfield>) minus one.
63The <structfield>reserved</structfield> field should to set to 0.
63After calling <constant>VIDIOC_QUERYBUF</constant> with a pointer to 64After calling <constant>VIDIOC_QUERYBUF</constant> with a pointer to
64 this structure drivers return an error code or fill the rest of 65 this structure drivers return an error code or fill the rest of
65the structure.</para> 66the structure.</para>
@@ -68,8 +69,8 @@ the structure.</para>
68<constant>V4L2_BUF_FLAG_MAPPED</constant>, 69<constant>V4L2_BUF_FLAG_MAPPED</constant>,
69<constant>V4L2_BUF_FLAG_QUEUED</constant> and 70<constant>V4L2_BUF_FLAG_QUEUED</constant> and
70<constant>V4L2_BUF_FLAG_DONE</constant> flags will be valid. The 71<constant>V4L2_BUF_FLAG_DONE</constant> flags will be valid. The
71<structfield>memory</structfield> field will be set to 72<structfield>memory</structfield> field will be set to the current
72<constant>V4L2_MEMORY_MMAP</constant>, the <structfield>m.offset</structfield> 73I/O method, the <structfield>m.offset</structfield>
73contains the offset of the buffer from the start of the device memory, 74contains the offset of the buffer from the start of the device memory,
74the <structfield>length</structfield> field its size. The driver may 75the <structfield>length</structfield> field its size. The driver may
75or may not set the remaining fields and flags, they are meaningless in 76or may not set the remaining fields and flags, they are meaningless in
diff --git a/Documentation/DocBook/v4l/vidioc-queryctrl.xml b/Documentation/DocBook/v4l/vidioc-queryctrl.xml
index 4876ff1a1a04..8e0e055ac934 100644
--- a/Documentation/DocBook/v4l/vidioc-queryctrl.xml
+++ b/Documentation/DocBook/v4l/vidioc-queryctrl.xml
@@ -325,7 +325,7 @@ should be part of the control documentation.</entry>
325 <entry>n/a</entry> 325 <entry>n/a</entry>
326 <entry>This is not a control. When 326 <entry>This is not a control. When
327<constant>VIDIOC_QUERYCTRL</constant> is called with a control ID 327<constant>VIDIOC_QUERYCTRL</constant> is called with a control ID
328equal to a control class code (see <xref linkend="ctrl-class" />), the 328equal to a control class code (see <xref linkend="ctrl-class" />) + 1, the
329ioctl returns the name of the control class and this control type. 329ioctl returns the name of the control class and this control type.
330Older drivers which do not support this feature return an 330Older drivers which do not support this feature return an
331&EINVAL;.</entry> 331&EINVAL;.</entry>
diff --git a/Documentation/DocBook/v4l/vidioc-reqbufs.xml b/Documentation/DocBook/v4l/vidioc-reqbufs.xml
index bab38084454f..69800ae23348 100644
--- a/Documentation/DocBook/v4l/vidioc-reqbufs.xml
+++ b/Documentation/DocBook/v4l/vidioc-reqbufs.xml
@@ -54,23 +54,23 @@ I/O. Memory mapped buffers are located in device memory and must be
54allocated with this ioctl before they can be mapped into the 54allocated with this ioctl before they can be mapped into the
55application's address space. User buffers are allocated by 55application's address space. User buffers are allocated by
56applications themselves, and this ioctl is merely used to switch the 56applications themselves, and this ioctl is merely used to switch the
57driver into user pointer I/O mode.</para> 57driver into user pointer I/O mode and to setup some internal structures.</para>
58 58
59 <para>To allocate device buffers applications initialize three 59 <para>To allocate device buffers applications initialize all
60fields of a <structname>v4l2_requestbuffers</structname> structure. 60fields of the <structname>v4l2_requestbuffers</structname> structure.
61They set the <structfield>type</structfield> field to the respective 61They set the <structfield>type</structfield> field to the respective
62stream or buffer type, the <structfield>count</structfield> field to 62stream or buffer type, the <structfield>count</structfield> field to
63the desired number of buffers, and <structfield>memory</structfield> 63the desired number of buffers, <structfield>memory</structfield>
64must be set to <constant>V4L2_MEMORY_MMAP</constant>. When the ioctl 64must be set to the requested I/O method and the <structfield>reserved</structfield> array
65is called with a pointer to this structure the driver attempts to 65must be zeroed. When the ioctl
66allocate the requested number of buffers and stores the actual number 66is called with a pointer to this structure the driver will attempt to allocate
67the requested number of buffers and it stores the actual number
67allocated in the <structfield>count</structfield> field. It can be 68allocated in the <structfield>count</structfield> field. It can be
68smaller than the number requested, even zero, when the driver runs out 69smaller than the number requested, even zero, when the driver runs out
69of free memory. A larger number is possible when the driver requires 70of free memory. A larger number is also possible when the driver requires
70more buffers to function correctly.<footnote> 71more buffers to function correctly. For example video output requires at least two buffers,
71 <para>For example video output requires at least two buffers,
72one displayed and one filled by the application.</para> 72one displayed and one filled by the application.</para>
73 </footnote> When memory mapping I/O is not supported the ioctl 73 <para>When the I/O method is not supported the ioctl
74returns an &EINVAL;.</para> 74returns an &EINVAL;.</para>
75 75
76 <para>Applications can call <constant>VIDIOC_REQBUFS</constant> 76 <para>Applications can call <constant>VIDIOC_REQBUFS</constant>
@@ -81,14 +81,6 @@ in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no
81reason why munmap()ping one or even all buffers must imply 81reason why munmap()ping one or even all buffers must imply
82streamoff.--></para> 82streamoff.--></para>
83 83
84 <para>To negotiate user pointer I/O, applications initialize only
85the <structfield>type</structfield> field and set
86<structfield>memory</structfield> to
87<constant>V4L2_MEMORY_USERPTR</constant>. When the ioctl is called
88with a pointer to this structure the driver prepares for user pointer
89I/O, when this I/O method is not supported the ioctl returns an
90&EINVAL;.</para>
91
92 <table pgwide="1" frame="none" id="v4l2-requestbuffers"> 84 <table pgwide="1" frame="none" id="v4l2-requestbuffers">
93 <title>struct <structname>v4l2_requestbuffers</structname></title> 85 <title>struct <structname>v4l2_requestbuffers</structname></title>
94 <tgroup cols="3"> 86 <tgroup cols="3">
@@ -97,9 +89,7 @@ I/O, when this I/O method is not supported the ioctl returns an
97 <row> 89 <row>
98 <entry>__u32</entry> 90 <entry>__u32</entry>
99 <entry><structfield>count</structfield></entry> 91 <entry><structfield>count</structfield></entry>
100 <entry>The number of buffers requested or granted. This 92 <entry>The number of buffers requested or granted.</entry>
101field is only used when <structfield>memory</structfield> is set to
102<constant>V4L2_MEMORY_MMAP</constant>.</entry>
103 </row> 93 </row>
104 <row> 94 <row>
105 <entry>&v4l2-buf-type;</entry> 95 <entry>&v4l2-buf-type;</entry>
@@ -120,7 +110,7 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref
120 <entry><structfield>reserved</structfield>[2]</entry> 110 <entry><structfield>reserved</structfield>[2]</entry>
121 <entry>A place holder for future extensions and custom 111 <entry>A place holder for future extensions and custom
122(driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and 112(driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and
123higher.</entry> 113higher. This array should be zeroed by applications.</entry>
124 </row> 114 </row>
125 </tbody> 115 </tbody>
126 </tgroup> 116 </tgroup>
diff --git a/Documentation/DocBook/v4l/vidioc-subscribe-event.xml b/Documentation/DocBook/v4l/vidioc-subscribe-event.xml
new file mode 100644
index 000000000000..8b501791aa68
--- /dev/null
+++ b/Documentation/DocBook/v4l/vidioc-subscribe-event.xml
@@ -0,0 +1,133 @@
1<refentry id="vidioc-subscribe-event">
2 <refmeta>
3 <refentrytitle>ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</refentrytitle>
4 &manvol;
5 </refmeta>
6
7 <refnamediv>
8 <refname>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</refname>
9 <refpurpose>Subscribe or unsubscribe event</refpurpose>
10 </refnamediv>
11
12 <refsynopsisdiv>
13 <funcsynopsis>
14 <funcprototype>
15 <funcdef>int <function>ioctl</function></funcdef>
16 <paramdef>int <parameter>fd</parameter></paramdef>
17 <paramdef>int <parameter>request</parameter></paramdef>
18 <paramdef>struct v4l2_event_subscription
19*<parameter>argp</parameter></paramdef>
20 </funcprototype>
21 </funcsynopsis>
22 </refsynopsisdiv>
23
24 <refsect1>
25 <title>Arguments</title>
26
27 <variablelist>
28 <varlistentry>
29 <term><parameter>fd</parameter></term>
30 <listitem>
31 <para>&fd;</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term><parameter>request</parameter></term>
36 <listitem>
37 <para>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><parameter>argp</parameter></term>
42 <listitem>
43 <para></para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsect1>
48
49 <refsect1>
50 <title>Description</title>
51
52 <para>Subscribe or unsubscribe V4L2 event. Subscribed events are
53 dequeued by using the &VIDIOC-DQEVENT; ioctl.</para>
54
55 <table frame="none" pgwide="1" id="v4l2-event-subscription">
56 <title>struct <structname>v4l2_event_subscription</structname></title>
57 <tgroup cols="3">
58 &cs-str;
59 <tbody valign="top">
60 <row>
61 <entry>__u32</entry>
62 <entry><structfield>type</structfield></entry>
63 <entry>Type of the event.</entry>
64 </row>
65 <row>
66 <entry>__u32</entry>
67 <entry><structfield>reserved</structfield>[7]</entry>
68 <entry>Reserved for future extensions. Drivers and applications
69 must set the array to zero.</entry>
70 </row>
71 </tbody>
72 </tgroup>
73 </table>
74
75 <table frame="none" pgwide="1" id="event-type">
76 <title>Event Types</title>
77 <tgroup cols="3">
78 &cs-def;
79 <tbody valign="top">
80 <row>
81 <entry><constant>V4L2_EVENT_ALL</constant></entry>
82 <entry>0</entry>
83 <entry>All events. V4L2_EVENT_ALL is valid only for
84 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
85 </entry>
86 </row>
87 <row>
88 <entry><constant>V4L2_EVENT_VSYNC</constant></entry>
89 <entry>1</entry>
90 <entry>This event is triggered on the vertical sync.
91 This event has &v4l2-event-vsync; associated with it.
92 </entry>
93 </row>
94 <row>
95 <entry><constant>V4L2_EVENT_EOS</constant></entry>
96 <entry>2</entry>
97 <entry>This event is triggered when the end of a stream is reached.
98 This is typically used with MPEG decoders to report to the application
99 when the last of the MPEG stream has been decoded.
100 </entry>
101 </row>
102 <row>
103 <entry><constant>V4L2_EVENT_PRIVATE_START</constant></entry>
104 <entry>0x08000000</entry>
105 <entry>Base event number for driver-private events.</entry>
106 </row>
107 </tbody>
108 </tgroup>
109 </table>
110
111 <table frame="none" pgwide="1" id="v4l2-event-vsync">
112 <title>struct <structname>v4l2_event_vsync</structname></title>
113 <tgroup cols="3">
114 &cs-str;
115 <tbody valign="top">
116 <row>
117 <entry>__u8</entry>
118 <entry><structfield>field</structfield></entry>
119 <entry>The upcoming field. See &v4l2-field;.</entry>
120 </row>
121 </tbody>
122 </tgroup>
123 </table>
124
125 </refsect1>
126</refentry>
127<!--
128Local Variables:
129mode: sgml
130sgml-parent-document: "v4l2.sgml"
131indent-tabs-mode: nil
132End:
133-->
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl
index 0d0f7b4d4b1a..0ba149de2608 100644
--- a/Documentation/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl
@@ -5518,34 +5518,41 @@ struct _snd_pcm_runtime {
5518]]> 5518]]>
5519 </programlisting> 5519 </programlisting>
5520 </informalexample> 5520 </informalexample>
5521
5522 For the raw data, <structfield>size</structfield> field must be
5523 set properly. This specifies the maximum size of the proc file access.
5521 </para> 5524 </para>
5522 5525
5523 <para> 5526 <para>
5524 The callback is much more complicated than the text-file 5527 The read/write callbacks of raw mode are more direct than the text mode.
5525 version. You need to use a low-level I/O functions such as 5528 You need to use a low-level I/O functions such as
5526 <function>copy_from/to_user()</function> to transfer the 5529 <function>copy_from/to_user()</function> to transfer the
5527 data. 5530 data.
5528 5531
5529 <informalexample> 5532 <informalexample>
5530 <programlisting> 5533 <programlisting>
5531<![CDATA[ 5534<![CDATA[
5532 static long my_file_io_read(struct snd_info_entry *entry, 5535 static ssize_t my_file_io_read(struct snd_info_entry *entry,
5533 void *file_private_data, 5536 void *file_private_data,
5534 struct file *file, 5537 struct file *file,
5535 char *buf, 5538 char *buf,
5536 unsigned long count, 5539 size_t count,
5537 unsigned long pos) 5540 loff_t pos)
5538 { 5541 {
5539 long size = count; 5542 if (copy_to_user(buf, local_data + pos, count))
5540 if (pos + size > local_max_size)
5541 size = local_max_size - pos;
5542 if (copy_to_user(buf, local_data + pos, size))
5543 return -EFAULT; 5543 return -EFAULT;
5544 return size; 5544 return count;
5545 } 5545 }
5546]]> 5546]]>
5547 </programlisting> 5547 </programlisting>
5548 </informalexample> 5548 </informalexample>
5549
5550 If the size of the info entry has been set up properly,
5551 <structfield>count</structfield> and <structfield>pos</structfield> are
5552 guaranteed to fit within 0 and the given size.
5553 You don't have to check the range in the callbacks unless any
5554 other condition is required.
5555
5549 </para> 5556 </para>
5550 5557
5551 </chapter> 5558 </chapter>
diff --git a/Documentation/DocBook/writing_usb_driver.tmpl b/Documentation/DocBook/writing_usb_driver.tmpl
index eeff19ca831b..bd97a13fa5ae 100644
--- a/Documentation/DocBook/writing_usb_driver.tmpl
+++ b/Documentation/DocBook/writing_usb_driver.tmpl
@@ -342,7 +342,7 @@ static inline void skel_delete (struct usb_skel *dev)
342{ 342{
343 kfree (dev->bulk_in_buffer); 343 kfree (dev->bulk_in_buffer);
344 if (dev->bulk_out_buffer != NULL) 344 if (dev->bulk_out_buffer != NULL)
345 usb_buffer_free (dev->udev, dev->bulk_out_size, 345 usb_free_coherent (dev->udev, dev->bulk_out_size,
346 dev->bulk_out_buffer, 346 dev->bulk_out_buffer,
347 dev->write_urb->transfer_dma); 347 dev->write_urb->transfer_dma);
348 usb_free_urb (dev->write_urb); 348 usb_free_urb (dev->write_urb);