]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - Documentation/DocBook/gpu.tmpl
be06c9b8a0a78978d3cdcc4daa8a21e0f50a88d8
[mirror_ubuntu-focal-kernel.git] / Documentation / DocBook / gpu.tmpl
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="gpuDevelopersGuide">
6 <bookinfo>
7 <title>Linux GPU Driver Developer's Guide</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Jesse</firstname>
12 <surname>Barnes</surname>
13 <contrib>Initial version</contrib>
14 <affiliation>
15 <orgname>Intel Corporation</orgname>
16 <address>
17 <email>jesse.barnes@intel.com</email>
18 </address>
19 </affiliation>
20 </author>
21 <author>
22 <firstname>Laurent</firstname>
23 <surname>Pinchart</surname>
24 <contrib>Driver internals</contrib>
25 <affiliation>
26 <orgname>Ideas on board SPRL</orgname>
27 <address>
28 <email>laurent.pinchart@ideasonboard.com</email>
29 </address>
30 </affiliation>
31 </author>
32 <author>
33 <firstname>Daniel</firstname>
34 <surname>Vetter</surname>
35 <contrib>Contributions all over the place</contrib>
36 <affiliation>
37 <orgname>Intel Corporation</orgname>
38 <address>
39 <email>daniel.vetter@ffwll.ch</email>
40 </address>
41 </affiliation>
42 </author>
43 <author>
44 <firstname>Lukas</firstname>
45 <surname>Wunner</surname>
46 <contrib>vga_switcheroo documentation</contrib>
47 <affiliation>
48 <address>
49 <email>lukas@wunner.de</email>
50 </address>
51 </affiliation>
52 </author>
53 </authorgroup>
54
55 <copyright>
56 <year>2008-2009</year>
57 <year>2013-2014</year>
58 <holder>Intel Corporation</holder>
59 </copyright>
60 <copyright>
61 <year>2012</year>
62 <holder>Laurent Pinchart</holder>
63 </copyright>
64 <copyright>
65 <year>2015</year>
66 <holder>Lukas Wunner</holder>
67 </copyright>
68
69 <legalnotice>
70 <para>
71 The contents of this file may be used under the terms of the GNU
72 General Public License version 2 (the "GPL") as distributed in
73 the kernel source COPYING file.
74 </para>
75 </legalnotice>
76
77 <revhistory>
78 <!-- Put document revisions here, newest first. -->
79 <revision>
80 <revnumber>1.0</revnumber>
81 <date>2012-07-13</date>
82 <authorinitials>LP</authorinitials>
83 <revremark>Added extensive documentation about driver internals.
84 </revremark>
85 </revision>
86 <revision>
87 <revnumber>1.1</revnumber>
88 <date>2015-10-11</date>
89 <authorinitials>LW</authorinitials>
90 <revremark>Added vga_switcheroo documentation.
91 </revremark>
92 </revision>
93 </revhistory>
94 </bookinfo>
95
96 <toc></toc>
97
98 <part id="drmCore">
99 <title>DRM Core</title>
100 <partintro>
101 <para>
102 This first part of the GPU Driver Developer's Guide documents core DRM
103 code, helper libraries for writing drivers and generic userspace
104 interfaces exposed by DRM drivers.
105 </para>
106 </partintro>
107
108 <chapter id="drmIntroduction">
109 <title>Introduction</title>
110 <para>
111 The Linux DRM layer contains code intended to support the needs
112 of complex graphics devices, usually containing programmable
113 pipelines well suited to 3D graphics acceleration. Graphics
114 drivers in the kernel may make use of DRM functions to make
115 tasks like memory management, interrupt handling and DMA easier,
116 and provide a uniform interface to applications.
117 </para>
118 <para>
119 A note on versions: this guide covers features found in the DRM
120 tree, including the TTM memory manager, output configuration and
121 mode setting, and the new vblank internals, in addition to all
122 the regular features found in current kernels.
123 </para>
124 <para>
125 [Insert diagram of typical DRM stack here]
126 </para>
127 </chapter>
128
129 <!-- Internals -->
130
131 <chapter id="drmInternals">
132 <title>DRM Internals</title>
133 <para>
134 This chapter documents DRM internals relevant to driver authors
135 and developers working to add support for the latest features to
136 existing drivers.
137 </para>
138 <para>
139 First, we go over some typical driver initialization
140 requirements, like setting up command buffers, creating an
141 initial output configuration, and initializing core services.
142 Subsequent sections cover core internals in more detail,
143 providing implementation notes and examples.
144 </para>
145 <para>
146 The DRM layer provides several services to graphics drivers,
147 many of them driven by the application interfaces it provides
148 through libdrm, the library that wraps most of the DRM ioctls.
149 These include vblank event handling, memory
150 management, output management, framebuffer management, command
151 submission &amp; fencing, suspend/resume support, and DMA
152 services.
153 </para>
154
155 <!-- Internals: driver init -->
156
157 <sect1>
158 <title>Driver Initialization</title>
159 <para>
160 At the core of every DRM driver is a <structname>drm_driver</structname>
161 structure. Drivers typically statically initialize a drm_driver structure,
162 and then pass it to <function>drm_dev_alloc()</function> to allocate a
163 device instance. After the device instance is fully initialized it can be
164 registered (which makes it accessible from userspace) using
165 <function>drm_dev_register()</function>.
166 </para>
167 <para>
168 The <structname>drm_driver</structname> structure contains static
169 information that describes the driver and features it supports, and
170 pointers to methods that the DRM core will call to implement the DRM API.
171 We will first go through the <structname>drm_driver</structname> static
172 information fields, and will then describe individual operations in
173 details as they get used in later sections.
174 </para>
175 <sect2>
176 <title>Driver Information</title>
177 <sect3>
178 <title>Driver Features</title>
179 <para>
180 Drivers inform the DRM core about their requirements and supported
181 features by setting appropriate flags in the
182 <structfield>driver_features</structfield> field. Since those flags
183 influence the DRM core behaviour since registration time, most of them
184 must be set to registering the <structname>drm_driver</structname>
185 instance.
186 </para>
187 <synopsis>u32 driver_features;</synopsis>
188 <variablelist>
189 <title>Driver Feature Flags</title>
190 <varlistentry>
191 <term>DRIVER_USE_AGP</term>
192 <listitem><para>
193 Driver uses AGP interface, the DRM core will manage AGP resources.
194 </para></listitem>
195 </varlistentry>
196 <varlistentry>
197 <term>DRIVER_REQUIRE_AGP</term>
198 <listitem><para>
199 Driver needs AGP interface to function. AGP initialization failure
200 will become a fatal error.
201 </para></listitem>
202 </varlistentry>
203 <varlistentry>
204 <term>DRIVER_PCI_DMA</term>
205 <listitem><para>
206 Driver is capable of PCI DMA, mapping of PCI DMA buffers to
207 userspace will be enabled. Deprecated.
208 </para></listitem>
209 </varlistentry>
210 <varlistentry>
211 <term>DRIVER_SG</term>
212 <listitem><para>
213 Driver can perform scatter/gather DMA, allocation and mapping of
214 scatter/gather buffers will be enabled. Deprecated.
215 </para></listitem>
216 </varlistentry>
217 <varlistentry>
218 <term>DRIVER_HAVE_DMA</term>
219 <listitem><para>
220 Driver supports DMA, the userspace DMA API will be supported.
221 Deprecated.
222 </para></listitem>
223 </varlistentry>
224 <varlistentry>
225 <term>DRIVER_HAVE_IRQ</term><term>DRIVER_IRQ_SHARED</term>
226 <listitem><para>
227 DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler
228 managed by the DRM Core. The core will support simple IRQ handler
229 installation when the flag is set. The installation process is
230 described in <xref linkend="drm-irq-registration"/>.</para>
231 <para>DRIVER_IRQ_SHARED indicates whether the device &amp; handler
232 support shared IRQs (note that this is required of PCI drivers).
233 </para></listitem>
234 </varlistentry>
235 <varlistentry>
236 <term>DRIVER_GEM</term>
237 <listitem><para>
238 Driver use the GEM memory manager.
239 </para></listitem>
240 </varlistentry>
241 <varlistentry>
242 <term>DRIVER_MODESET</term>
243 <listitem><para>
244 Driver supports mode setting interfaces (KMS).
245 </para></listitem>
246 </varlistentry>
247 <varlistentry>
248 <term>DRIVER_PRIME</term>
249 <listitem><para>
250 Driver implements DRM PRIME buffer sharing.
251 </para></listitem>
252 </varlistentry>
253 <varlistentry>
254 <term>DRIVER_RENDER</term>
255 <listitem><para>
256 Driver supports dedicated render nodes.
257 </para></listitem>
258 </varlistentry>
259 <varlistentry>
260 <term>DRIVER_ATOMIC</term>
261 <listitem><para>
262 Driver supports atomic properties. In this case the driver
263 must implement appropriate obj->atomic_get_property() vfuncs
264 for any modeset objects with driver specific properties.
265 </para></listitem>
266 </varlistentry>
267 </variablelist>
268 </sect3>
269 <sect3>
270 <title>Major, Minor and Patchlevel</title>
271 <synopsis>int major;
272 int minor;
273 int patchlevel;</synopsis>
274 <para>
275 The DRM core identifies driver versions by a major, minor and patch
276 level triplet. The information is printed to the kernel log at
277 initialization time and passed to userspace through the
278 DRM_IOCTL_VERSION ioctl.
279 </para>
280 <para>
281 The major and minor numbers are also used to verify the requested driver
282 API version passed to DRM_IOCTL_SET_VERSION. When the driver API changes
283 between minor versions, applications can call DRM_IOCTL_SET_VERSION to
284 select a specific version of the API. If the requested major isn't equal
285 to the driver major, or the requested minor is larger than the driver
286 minor, the DRM_IOCTL_SET_VERSION call will return an error. Otherwise
287 the driver's set_version() method will be called with the requested
288 version.
289 </para>
290 </sect3>
291 <sect3>
292 <title>Name, Description and Date</title>
293 <synopsis>char *name;
294 char *desc;
295 char *date;</synopsis>
296 <para>
297 The driver name is printed to the kernel log at initialization time,
298 used for IRQ registration and passed to userspace through
299 DRM_IOCTL_VERSION.
300 </para>
301 <para>
302 The driver description is a purely informative string passed to
303 userspace through the DRM_IOCTL_VERSION ioctl and otherwise unused by
304 the kernel.
305 </para>
306 <para>
307 The driver date, formatted as YYYYMMDD, is meant to identify the date of
308 the latest modification to the driver. However, as most drivers fail to
309 update it, its value is mostly useless. The DRM core prints it to the
310 kernel log at initialization time and passes it to userspace through the
311 DRM_IOCTL_VERSION ioctl.
312 </para>
313 </sect3>
314 </sect2>
315 <sect2>
316 <title>Device Instance and Driver Handling</title>
317 !Pdrivers/gpu/drm/drm_drv.c driver instance overview
318 !Edrivers/gpu/drm/drm_drv.c
319 </sect2>
320 <sect2>
321 <title>Driver Load</title>
322 <sect3 id="drm-irq-registration">
323 <title>IRQ Registration</title>
324 <para>
325 The DRM core tries to facilitate IRQ handler registration and
326 unregistration by providing <function>drm_irq_install</function> and
327 <function>drm_irq_uninstall</function> functions. Those functions only
328 support a single interrupt per device, devices that use more than one
329 IRQs need to be handled manually.
330 </para>
331 <sect4>
332 <title>Managed IRQ Registration</title>
333 <para>
334 <function>drm_irq_install</function> starts by calling the
335 <methodname>irq_preinstall</methodname> driver operation. The operation
336 is optional and must make sure that the interrupt will not get fired by
337 clearing all pending interrupt flags or disabling the interrupt.
338 </para>
339 <para>
340 The passed-in IRQ will then be requested by a call to
341 <function>request_irq</function>. If the DRIVER_IRQ_SHARED driver
342 feature flag is set, a shared (IRQF_SHARED) IRQ handler will be
343 requested.
344 </para>
345 <para>
346 The IRQ handler function must be provided as the mandatory irq_handler
347 driver operation. It will get passed directly to
348 <function>request_irq</function> and thus has the same prototype as all
349 IRQ handlers. It will get called with a pointer to the DRM device as the
350 second argument.
351 </para>
352 <para>
353 Finally the function calls the optional
354 <methodname>irq_postinstall</methodname> driver operation. The operation
355 usually enables interrupts (excluding the vblank interrupt, which is
356 enabled separately), but drivers may choose to enable/disable interrupts
357 at a different time.
358 </para>
359 <para>
360 <function>drm_irq_uninstall</function> is similarly used to uninstall an
361 IRQ handler. It starts by waking up all processes waiting on a vblank
362 interrupt to make sure they don't hang, and then calls the optional
363 <methodname>irq_uninstall</methodname> driver operation. The operation
364 must disable all hardware interrupts. Finally the function frees the IRQ
365 by calling <function>free_irq</function>.
366 </para>
367 </sect4>
368 <sect4>
369 <title>Manual IRQ Registration</title>
370 <para>
371 Drivers that require multiple interrupt handlers can't use the managed
372 IRQ registration functions. In that case IRQs must be registered and
373 unregistered manually (usually with the <function>request_irq</function>
374 and <function>free_irq</function> functions, or their devm_* equivalent).
375 </para>
376 <para>
377 When manually registering IRQs, drivers must not set the DRIVER_HAVE_IRQ
378 driver feature flag, and must not provide the
379 <methodname>irq_handler</methodname> driver operation. They must set the
380 <structname>drm_device</structname> <structfield>irq_enabled</structfield>
381 field to 1 upon registration of the IRQs, and clear it to 0 after
382 unregistering the IRQs.
383 </para>
384 </sect4>
385 </sect3>
386 <sect3>
387 <title>Memory Manager Initialization</title>
388 <para>
389 Every DRM driver requires a memory manager which must be initialized at
390 load time. DRM currently contains two memory managers, the Translation
391 Table Manager (TTM) and the Graphics Execution Manager (GEM).
392 This document describes the use of the GEM memory manager only. See
393 <xref linkend="drm-memory-management"/> for details.
394 </para>
395 </sect3>
396 <sect3>
397 <title>Miscellaneous Device Configuration</title>
398 <para>
399 Another task that may be necessary for PCI devices during configuration
400 is mapping the video BIOS. On many devices, the VBIOS describes device
401 configuration, LCD panel timings (if any), and contains flags indicating
402 device state. Mapping the BIOS can be done using the pci_map_rom() call,
403 a convenience function that takes care of mapping the actual ROM,
404 whether it has been shadowed into memory (typically at address 0xc0000)
405 or exists on the PCI device in the ROM BAR. Note that after the ROM has
406 been mapped and any necessary information has been extracted, it should
407 be unmapped; on many devices, the ROM address decoder is shared with
408 other BARs, so leaving it mapped could cause undesired behaviour like
409 hangs or memory corruption.
410 <!--!Fdrivers/pci/rom.c pci_map_rom-->
411 </para>
412 </sect3>
413 </sect2>
414 <sect2>
415 <title>Bus-specific Device Registration and PCI Support</title>
416 <para>
417 A number of functions are provided to help with device registration.
418 The functions deal with PCI and platform devices respectively and are
419 only provided for historical reasons. These are all deprecated and
420 shouldn't be used in new drivers. Besides that there's a few
421 helpers for pci drivers.
422 </para>
423 !Edrivers/gpu/drm/drm_pci.c
424 !Edrivers/gpu/drm/drm_platform.c
425 </sect2>
426 </sect1>
427
428 <!-- Internals: memory management -->
429
430 <sect1 id="drm-memory-management">
431 <title>Memory management</title>
432 <para>
433 Modern Linux systems require large amount of graphics memory to store
434 frame buffers, textures, vertices and other graphics-related data. Given
435 the very dynamic nature of many of that data, managing graphics memory
436 efficiently is thus crucial for the graphics stack and plays a central
437 role in the DRM infrastructure.
438 </para>
439 <para>
440 The DRM core includes two memory managers, namely Translation Table Maps
441 (TTM) and Graphics Execution Manager (GEM). TTM was the first DRM memory
442 manager to be developed and tried to be a one-size-fits-them all
443 solution. It provides a single userspace API to accommodate the need of
444 all hardware, supporting both Unified Memory Architecture (UMA) devices
445 and devices with dedicated video RAM (i.e. most discrete video cards).
446 This resulted in a large, complex piece of code that turned out to be
447 hard to use for driver development.
448 </para>
449 <para>
450 GEM started as an Intel-sponsored project in reaction to TTM's
451 complexity. Its design philosophy is completely different: instead of
452 providing a solution to every graphics memory-related problems, GEM
453 identified common code between drivers and created a support library to
454 share it. GEM has simpler initialization and execution requirements than
455 TTM, but has no video RAM management capabilities and is thus limited to
456 UMA devices.
457 </para>
458 <sect2>
459 <title>The Translation Table Manager (TTM)</title>
460 <para>
461 TTM design background and information belongs here.
462 </para>
463 <sect3>
464 <title>TTM initialization</title>
465 <warning><para>This section is outdated.</para></warning>
466 <para>
467 Drivers wishing to support TTM must fill out a drm_bo_driver
468 structure. The structure contains several fields with function
469 pointers for initializing the TTM, allocating and freeing memory,
470 waiting for command completion and fence synchronization, and memory
471 migration. See the radeon_ttm.c file for an example of usage.
472 </para>
473 <para>
474 The ttm_global_reference structure is made up of several fields:
475 </para>
476 <programlisting>
477 struct ttm_global_reference {
478 enum ttm_global_types global_type;
479 size_t size;
480 void *object;
481 int (*init) (struct ttm_global_reference *);
482 void (*release) (struct ttm_global_reference *);
483 };
484 </programlisting>
485 <para>
486 There should be one global reference structure for your memory
487 manager as a whole, and there will be others for each object
488 created by the memory manager at runtime. Your global TTM should
489 have a type of TTM_GLOBAL_TTM_MEM. The size field for the global
490 object should be sizeof(struct ttm_mem_global), and the init and
491 release hooks should point at your driver-specific init and
492 release routines, which probably eventually call
493 ttm_mem_global_init and ttm_mem_global_release, respectively.
494 </para>
495 <para>
496 Once your global TTM accounting structure is set up and initialized
497 by calling ttm_global_item_ref() on it,
498 you need to create a buffer object TTM to
499 provide a pool for buffer object allocation by clients and the
500 kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO,
501 and its size should be sizeof(struct ttm_bo_global). Again,
502 driver-specific init and release functions may be provided,
503 likely eventually calling ttm_bo_global_init() and
504 ttm_bo_global_release(), respectively. Also, like the previous
505 object, ttm_global_item_ref() is used to create an initial reference
506 count for the TTM, which will call your initialization function.
507 </para>
508 </sect3>
509 </sect2>
510 <sect2 id="drm-gem">
511 <title>The Graphics Execution Manager (GEM)</title>
512 <para>
513 The GEM design approach has resulted in a memory manager that doesn't
514 provide full coverage of all (or even all common) use cases in its
515 userspace or kernel API. GEM exposes a set of standard memory-related
516 operations to userspace and a set of helper functions to drivers, and let
517 drivers implement hardware-specific operations with their own private API.
518 </para>
519 <para>
520 The GEM userspace API is described in the
521 <ulink url="http://lwn.net/Articles/283798/"><citetitle>GEM - the Graphics
522 Execution Manager</citetitle></ulink> article on LWN. While slightly
523 outdated, the document provides a good overview of the GEM API principles.
524 Buffer allocation and read and write operations, described as part of the
525 common GEM API, are currently implemented using driver-specific ioctls.
526 </para>
527 <para>
528 GEM is data-agnostic. It manages abstract buffer objects without knowing
529 what individual buffers contain. APIs that require knowledge of buffer
530 contents or purpose, such as buffer allocation or synchronization
531 primitives, are thus outside of the scope of GEM and must be implemented
532 using driver-specific ioctls.
533 </para>
534 <para>
535 On a fundamental level, GEM involves several operations:
536 <itemizedlist>
537 <listitem>Memory allocation and freeing</listitem>
538 <listitem>Command execution</listitem>
539 <listitem>Aperture management at command execution time</listitem>
540 </itemizedlist>
541 Buffer object allocation is relatively straightforward and largely
542 provided by Linux's shmem layer, which provides memory to back each
543 object.
544 </para>
545 <para>
546 Device-specific operations, such as command execution, pinning, buffer
547 read &amp; write, mapping, and domain ownership transfers are left to
548 driver-specific ioctls.
549 </para>
550 <sect3>
551 <title>GEM Initialization</title>
552 <para>
553 Drivers that use GEM must set the DRIVER_GEM bit in the struct
554 <structname>drm_driver</structname>
555 <structfield>driver_features</structfield> field. The DRM core will
556 then automatically initialize the GEM core before calling the
557 <methodname>load</methodname> operation. Behind the scene, this will
558 create a DRM Memory Manager object which provides an address space
559 pool for object allocation.
560 </para>
561 <para>
562 In a KMS configuration, drivers need to allocate and initialize a
563 command ring buffer following core GEM initialization if required by
564 the hardware. UMA devices usually have what is called a "stolen"
565 memory region, which provides space for the initial framebuffer and
566 large, contiguous memory regions required by the device. This space is
567 typically not managed by GEM, and must be initialized separately into
568 its own DRM MM object.
569 </para>
570 </sect3>
571 <sect3>
572 <title>GEM Objects Creation</title>
573 <para>
574 GEM splits creation of GEM objects and allocation of the memory that
575 backs them in two distinct operations.
576 </para>
577 <para>
578 GEM objects are represented by an instance of struct
579 <structname>drm_gem_object</structname>. Drivers usually need to extend
580 GEM objects with private information and thus create a driver-specific
581 GEM object structure type that embeds an instance of struct
582 <structname>drm_gem_object</structname>.
583 </para>
584 <para>
585 To create a GEM object, a driver allocates memory for an instance of its
586 specific GEM object type and initializes the embedded struct
587 <structname>drm_gem_object</structname> with a call to
588 <function>drm_gem_object_init</function>. The function takes a pointer to
589 the DRM device, a pointer to the GEM object and the buffer object size
590 in bytes.
591 </para>
592 <para>
593 GEM uses shmem to allocate anonymous pageable memory.
594 <function>drm_gem_object_init</function> will create an shmfs file of
595 the requested size and store it into the struct
596 <structname>drm_gem_object</structname> <structfield>filp</structfield>
597 field. The memory is used as either main storage for the object when the
598 graphics hardware uses system memory directly or as a backing store
599 otherwise.
600 </para>
601 <para>
602 Drivers are responsible for the actual physical pages allocation by
603 calling <function>shmem_read_mapping_page_gfp</function> for each page.
604 Note that they can decide to allocate pages when initializing the GEM
605 object, or to delay allocation until the memory is needed (for instance
606 when a page fault occurs as a result of a userspace memory access or
607 when the driver needs to start a DMA transfer involving the memory).
608 </para>
609 <para>
610 Anonymous pageable memory allocation is not always desired, for instance
611 when the hardware requires physically contiguous system memory as is
612 often the case in embedded devices. Drivers can create GEM objects with
613 no shmfs backing (called private GEM objects) by initializing them with
614 a call to <function>drm_gem_private_object_init</function> instead of
615 <function>drm_gem_object_init</function>. Storage for private GEM
616 objects must be managed by drivers.
617 </para>
618 </sect3>
619 <sect3>
620 <title>GEM Objects Lifetime</title>
621 <para>
622 All GEM objects are reference-counted by the GEM core. References can be
623 acquired and release by <function>calling drm_gem_object_reference</function>
624 and <function>drm_gem_object_unreference</function> respectively. The
625 caller must hold the <structname>drm_device</structname>
626 <structfield>struct_mutex</structfield> lock when calling
627 <function>drm_gem_object_reference</function>. As a convenience, GEM
628 provides <function>drm_gem_object_unreference_unlocked</function>
629 functions that can be called without holding the lock.
630 </para>
631 <para>
632 When the last reference to a GEM object is released the GEM core calls
633 the <structname>drm_driver</structname>
634 <methodname>gem_free_object</methodname> operation. That operation is
635 mandatory for GEM-enabled drivers and must free the GEM object and all
636 associated resources.
637 </para>
638 <para>
639 <synopsis>void (*gem_free_object) (struct drm_gem_object *obj);</synopsis>
640 Drivers are responsible for freeing all GEM object resources. This includes
641 the resources created by the GEM core, which need to be released with
642 <function>drm_gem_object_release</function>.
643 </para>
644 </sect3>
645 <sect3>
646 <title>GEM Objects Naming</title>
647 <para>
648 Communication between userspace and the kernel refers to GEM objects
649 using local handles, global names or, more recently, file descriptors.
650 All of those are 32-bit integer values; the usual Linux kernel limits
651 apply to the file descriptors.
652 </para>
653 <para>
654 GEM handles are local to a DRM file. Applications get a handle to a GEM
655 object through a driver-specific ioctl, and can use that handle to refer
656 to the GEM object in other standard or driver-specific ioctls. Closing a
657 DRM file handle frees all its GEM handles and dereferences the
658 associated GEM objects.
659 </para>
660 <para>
661 To create a handle for a GEM object drivers call
662 <function>drm_gem_handle_create</function>. The function takes a pointer
663 to the DRM file and the GEM object and returns a locally unique handle.
664 When the handle is no longer needed drivers delete it with a call to
665 <function>drm_gem_handle_delete</function>. Finally the GEM object
666 associated with a handle can be retrieved by a call to
667 <function>drm_gem_object_lookup</function>.
668 </para>
669 <para>
670 Handles don't take ownership of GEM objects, they only take a reference
671 to the object that will be dropped when the handle is destroyed. To
672 avoid leaking GEM objects, drivers must make sure they drop the
673 reference(s) they own (such as the initial reference taken at object
674 creation time) as appropriate, without any special consideration for the
675 handle. For example, in the particular case of combined GEM object and
676 handle creation in the implementation of the
677 <methodname>dumb_create</methodname> operation, drivers must drop the
678 initial reference to the GEM object before returning the handle.
679 </para>
680 <para>
681 GEM names are similar in purpose to handles but are not local to DRM
682 files. They can be passed between processes to reference a GEM object
683 globally. Names can't be used directly to refer to objects in the DRM
684 API, applications must convert handles to names and names to handles
685 using the DRM_IOCTL_GEM_FLINK and DRM_IOCTL_GEM_OPEN ioctls
686 respectively. The conversion is handled by the DRM core without any
687 driver-specific support.
688 </para>
689 <para>
690 GEM also supports buffer sharing with dma-buf file descriptors through
691 PRIME. GEM-based drivers must use the provided helpers functions to
692 implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />.
693 Since sharing file descriptors is inherently more secure than the
694 easily guessable and global GEM names it is the preferred buffer
695 sharing mechanism. Sharing buffers through GEM names is only supported
696 for legacy userspace. Furthermore PRIME also allows cross-device
697 buffer sharing since it is based on dma-bufs.
698 </para>
699 </sect3>
700 <sect3 id="drm-gem-objects-mapping">
701 <title>GEM Objects Mapping</title>
702 <para>
703 Because mapping operations are fairly heavyweight GEM favours
704 read/write-like access to buffers, implemented through driver-specific
705 ioctls, over mapping buffers to userspace. However, when random access
706 to the buffer is needed (to perform software rendering for instance),
707 direct access to the object can be more efficient.
708 </para>
709 <para>
710 The mmap system call can't be used directly to map GEM objects, as they
711 don't have their own file handle. Two alternative methods currently
712 co-exist to map GEM objects to userspace. The first method uses a
713 driver-specific ioctl to perform the mapping operation, calling
714 <function>do_mmap</function> under the hood. This is often considered
715 dubious, seems to be discouraged for new GEM-enabled drivers, and will
716 thus not be described here.
717 </para>
718 <para>
719 The second method uses the mmap system call on the DRM file handle.
720 <synopsis>void *mmap(void *addr, size_t length, int prot, int flags, int fd,
721 off_t offset);</synopsis>
722 DRM identifies the GEM object to be mapped by a fake offset passed
723 through the mmap offset argument. Prior to being mapped, a GEM object
724 must thus be associated with a fake offset. To do so, drivers must call
725 <function>drm_gem_create_mmap_offset</function> on the object.
726 </para>
727 <para>
728 Once allocated, the fake offset value
729 must be passed to the application in a driver-specific way and can then
730 be used as the mmap offset argument.
731 </para>
732 <para>
733 The GEM core provides a helper method <function>drm_gem_mmap</function>
734 to handle object mapping. The method can be set directly as the mmap
735 file operation handler. It will look up the GEM object based on the
736 offset value and set the VMA operations to the
737 <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
738 field. Note that <function>drm_gem_mmap</function> doesn't map memory to
739 userspace, but relies on the driver-provided fault handler to map pages
740 individually.
741 </para>
742 <para>
743 To use <function>drm_gem_mmap</function>, drivers must fill the struct
744 <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
745 field with a pointer to VM operations.
746 </para>
747 <para>
748 <synopsis>struct vm_operations_struct *gem_vm_ops
749
750 struct vm_operations_struct {
751 void (*open)(struct vm_area_struct * area);
752 void (*close)(struct vm_area_struct * area);
753 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
754 };</synopsis>
755 </para>
756 <para>
757 The <methodname>open</methodname> and <methodname>close</methodname>
758 operations must update the GEM object reference count. Drivers can use
759 the <function>drm_gem_vm_open</function> and
760 <function>drm_gem_vm_close</function> helper functions directly as open
761 and close handlers.
762 </para>
763 <para>
764 The fault operation handler is responsible for mapping individual pages
765 to userspace when a page fault occurs. Depending on the memory
766 allocation scheme, drivers can allocate pages at fault time, or can
767 decide to allocate memory for the GEM object at the time the object is
768 created.
769 </para>
770 <para>
771 Drivers that want to map the GEM object upfront instead of handling page
772 faults can implement their own mmap file operation handler.
773 </para>
774 </sect3>
775 <sect3>
776 <title>Memory Coherency</title>
777 <para>
778 When mapped to the device or used in a command buffer, backing pages
779 for an object are flushed to memory and marked write combined so as to
780 be coherent with the GPU. Likewise, if the CPU accesses an object
781 after the GPU has finished rendering to the object, then the object
782 must be made coherent with the CPU's view of memory, usually involving
783 GPU cache flushing of various kinds. This core CPU&lt;-&gt;GPU
784 coherency management is provided by a device-specific ioctl, which
785 evaluates an object's current domain and performs any necessary
786 flushing or synchronization to put the object into the desired
787 coherency domain (note that the object may be busy, i.e. an active
788 render target; in that case, setting the domain blocks the client and
789 waits for rendering to complete before performing any necessary
790 flushing operations).
791 </para>
792 </sect3>
793 <sect3>
794 <title>Command Execution</title>
795 <para>
796 Perhaps the most important GEM function for GPU devices is providing a
797 command execution interface to clients. Client programs construct
798 command buffers containing references to previously allocated memory
799 objects, and then submit them to GEM. At that point, GEM takes care to
800 bind all the objects into the GTT, execute the buffer, and provide
801 necessary synchronization between clients accessing the same buffers.
802 This often involves evicting some objects from the GTT and re-binding
803 others (a fairly expensive operation), and providing relocation
804 support which hides fixed GTT offsets from clients. Clients must take
805 care not to submit command buffers that reference more objects than
806 can fit in the GTT; otherwise, GEM will reject them and no rendering
807 will occur. Similarly, if several objects in the buffer require fence
808 registers to be allocated for correct rendering (e.g. 2D blits on
809 pre-965 chips), care must be taken not to require more fence registers
810 than are available to the client. Such resource management should be
811 abstracted from the client in libdrm.
812 </para>
813 </sect3>
814 </sect2>
815 <sect2>
816 <title>GEM Function Reference</title>
817 !Edrivers/gpu/drm/drm_gem.c
818 !Iinclude/drm/drm_gem.h
819 </sect2>
820 <sect2>
821 <title>VMA Offset Manager</title>
822 !Pdrivers/gpu/drm/drm_vma_manager.c vma offset manager
823 !Edrivers/gpu/drm/drm_vma_manager.c
824 !Iinclude/drm/drm_vma_manager.h
825 </sect2>
826 <sect2 id="drm-prime-support">
827 <title>PRIME Buffer Sharing</title>
828 <para>
829 PRIME is the cross device buffer sharing framework in drm, originally
830 created for the OPTIMUS range of multi-gpu platforms. To userspace
831 PRIME buffers are dma-buf based file descriptors.
832 </para>
833 <sect3>
834 <title>Overview and Driver Interface</title>
835 <para>
836 Similar to GEM global names, PRIME file descriptors are
837 also used to share buffer objects across processes. They offer
838 additional security: as file descriptors must be explicitly sent over
839 UNIX domain sockets to be shared between applications, they can't be
840 guessed like the globally unique GEM names.
841 </para>
842 <para>
843 Drivers that support the PRIME
844 API must set the DRIVER_PRIME bit in the struct
845 <structname>drm_driver</structname>
846 <structfield>driver_features</structfield> field, and implement the
847 <methodname>prime_handle_to_fd</methodname> and
848 <methodname>prime_fd_to_handle</methodname> operations.
849 </para>
850 <para>
851 <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev,
852 struct drm_file *file_priv, uint32_t handle,
853 uint32_t flags, int *prime_fd);
854 int (*prime_fd_to_handle)(struct drm_device *dev,
855 struct drm_file *file_priv, int prime_fd,
856 uint32_t *handle);</synopsis>
857 Those two operations convert a handle to a PRIME file descriptor and
858 vice versa. Drivers must use the kernel dma-buf buffer sharing framework
859 to manage the PRIME file descriptors. Similar to the mode setting
860 API PRIME is agnostic to the underlying buffer object manager, as
861 long as handles are 32bit unsigned integers.
862 </para>
863 <para>
864 While non-GEM drivers must implement the operations themselves, GEM
865 drivers must use the <function>drm_gem_prime_handle_to_fd</function>
866 and <function>drm_gem_prime_fd_to_handle</function> helper functions.
867 Those helpers rely on the driver
868 <methodname>gem_prime_export</methodname> and
869 <methodname>gem_prime_import</methodname> operations to create a dma-buf
870 instance from a GEM object (dma-buf exporter role) and to create a GEM
871 object from a dma-buf instance (dma-buf importer role).
872 </para>
873 <para>
874 <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
875 struct drm_gem_object *obj,
876 int flags);
877 struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
878 struct dma_buf *dma_buf);</synopsis>
879 These two operations are mandatory for GEM drivers that support
880 PRIME.
881 </para>
882 </sect3>
883 <sect3>
884 <title>PRIME Helper Functions</title>
885 !Pdrivers/gpu/drm/drm_prime.c PRIME Helpers
886 </sect3>
887 </sect2>
888 <sect2>
889 <title>PRIME Function References</title>
890 !Edrivers/gpu/drm/drm_prime.c
891 </sect2>
892 <sect2>
893 <title>DRM MM Range Allocator</title>
894 <sect3>
895 <title>Overview</title>
896 !Pdrivers/gpu/drm/drm_mm.c Overview
897 </sect3>
898 <sect3>
899 <title>LRU Scan/Eviction Support</title>
900 !Pdrivers/gpu/drm/drm_mm.c lru scan roaster
901 </sect3>
902 </sect2>
903 <sect2>
904 <title>DRM MM Range Allocator Function References</title>
905 !Edrivers/gpu/drm/drm_mm.c
906 !Iinclude/drm/drm_mm.h
907 </sect2>
908 <sect2>
909 <title>CMA Helper Functions Reference</title>
910 !Pdrivers/gpu/drm/drm_gem_cma_helper.c cma helpers
911 !Edrivers/gpu/drm/drm_gem_cma_helper.c
912 !Iinclude/drm/drm_gem_cma_helper.h
913 </sect2>
914 </sect1>
915
916 <!-- Internals: mode setting -->
917
918 <sect1 id="drm-mode-setting">
919 <title>Mode Setting</title>
920 <para>
921 Drivers must initialize the mode setting core by calling
922 <function>drm_mode_config_init</function> on the DRM device. The function
923 initializes the <structname>drm_device</structname>
924 <structfield>mode_config</structfield> field and never fails. Once done,
925 mode configuration must be setup by initializing the following fields.
926 </para>
927 <itemizedlist>
928 <listitem>
929 <synopsis>int min_width, min_height;
930 int max_width, max_height;</synopsis>
931 <para>
932 Minimum and maximum width and height of the frame buffers in pixel
933 units.
934 </para>
935 </listitem>
936 <listitem>
937 <synopsis>struct drm_mode_config_funcs *funcs;</synopsis>
938 <para>Mode setting functions.</para>
939 </listitem>
940 </itemizedlist>
941 <sect2>
942 <title>Display Modes Function Reference</title>
943 !Iinclude/drm/drm_modes.h
944 !Edrivers/gpu/drm/drm_modes.c
945 </sect2>
946 <sect2>
947 <title>Atomic Mode Setting Function Reference</title>
948 !Edrivers/gpu/drm/drm_atomic.c
949 !Idrivers/gpu/drm/drm_atomic.c
950 </sect2>
951 <sect2>
952 <title>Frame Buffer Creation</title>
953 <synopsis>struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
954 struct drm_file *file_priv,
955 struct drm_mode_fb_cmd2 *mode_cmd);</synopsis>
956 <para>
957 Frame buffers are abstract memory objects that provide a source of
958 pixels to scanout to a CRTC. Applications explicitly request the
959 creation of frame buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and
960 receive an opaque handle that can be passed to the KMS CRTC control,
961 plane configuration and page flip functions.
962 </para>
963 <para>
964 Frame buffers rely on the underneath memory manager for low-level memory
965 operations. When creating a frame buffer applications pass a memory
966 handle (or a list of memory handles for multi-planar formats) through
967 the <parameter>drm_mode_fb_cmd2</parameter> argument. For drivers using
968 GEM as their userspace buffer management interface this would be a GEM
969 handle. Drivers are however free to use their own backing storage object
970 handles, e.g. vmwgfx directly exposes special TTM handles to userspace
971 and so expects TTM handles in the create ioctl and not GEM handles.
972 </para>
973 <para>
974 Drivers must first validate the requested frame buffer parameters passed
975 through the mode_cmd argument. In particular this is where invalid
976 sizes, pixel formats or pitches can be caught.
977 </para>
978 <para>
979 If the parameters are deemed valid, drivers then create, initialize and
980 return an instance of struct <structname>drm_framebuffer</structname>.
981 If desired the instance can be embedded in a larger driver-specific
982 structure. Drivers must fill its <structfield>width</structfield>,
983 <structfield>height</structfield>, <structfield>pitches</structfield>,
984 <structfield>offsets</structfield>, <structfield>depth</structfield>,
985 <structfield>bits_per_pixel</structfield> and
986 <structfield>pixel_format</structfield> fields from the values passed
987 through the <parameter>drm_mode_fb_cmd2</parameter> argument. They
988 should call the <function>drm_helper_mode_fill_fb_struct</function>
989 helper function to do so.
990 </para>
991
992 <para>
993 The initialization of the new framebuffer instance is finalized with a
994 call to <function>drm_framebuffer_init</function> which takes a pointer
995 to DRM frame buffer operations (struct
996 <structname>drm_framebuffer_funcs</structname>). Note that this function
997 publishes the framebuffer and so from this point on it can be accessed
998 concurrently from other threads. Hence it must be the last step in the
999 driver's framebuffer initialization sequence. Frame buffer operations
1000 are
1001 <itemizedlist>
1002 <listitem>
1003 <synopsis>int (*create_handle)(struct drm_framebuffer *fb,
1004 struct drm_file *file_priv, unsigned int *handle);</synopsis>
1005 <para>
1006 Create a handle to the frame buffer underlying memory object. If
1007 the frame buffer uses a multi-plane format, the handle will
1008 reference the memory object associated with the first plane.
1009 </para>
1010 <para>
1011 Drivers call <function>drm_gem_handle_create</function> to create
1012 the handle.
1013 </para>
1014 </listitem>
1015 <listitem>
1016 <synopsis>void (*destroy)(struct drm_framebuffer *framebuffer);</synopsis>
1017 <para>
1018 Destroy the frame buffer object and frees all associated
1019 resources. Drivers must call
1020 <function>drm_framebuffer_cleanup</function> to free resources
1021 allocated by the DRM core for the frame buffer object, and must
1022 make sure to unreference all memory objects associated with the
1023 frame buffer. Handles created by the
1024 <methodname>create_handle</methodname> operation are released by
1025 the DRM core.
1026 </para>
1027 </listitem>
1028 <listitem>
1029 <synopsis>int (*dirty)(struct drm_framebuffer *framebuffer,
1030 struct drm_file *file_priv, unsigned flags, unsigned color,
1031 struct drm_clip_rect *clips, unsigned num_clips);</synopsis>
1032 <para>
1033 This optional operation notifies the driver that a region of the
1034 frame buffer has changed in response to a DRM_IOCTL_MODE_DIRTYFB
1035 ioctl call.
1036 </para>
1037 </listitem>
1038 </itemizedlist>
1039 </para>
1040 <para>
1041 The lifetime of a drm framebuffer is controlled with a reference count,
1042 drivers can grab additional references with
1043 <function>drm_framebuffer_reference</function>and drop them
1044 again with <function>drm_framebuffer_unreference</function>. For
1045 driver-private framebuffers for which the last reference is never
1046 dropped (e.g. for the fbdev framebuffer when the struct
1047 <structname>drm_framebuffer</structname> is embedded into the fbdev
1048 helper struct) drivers can manually clean up a framebuffer at module
1049 unload time with
1050 <function>drm_framebuffer_unregister_private</function>.
1051 </para>
1052 </sect2>
1053 <sect2>
1054 <title>Dumb Buffer Objects</title>
1055 <para>
1056 The KMS API doesn't standardize backing storage object creation and
1057 leaves it to driver-specific ioctls. Furthermore actually creating a
1058 buffer object even for GEM-based drivers is done through a
1059 driver-specific ioctl - GEM only has a common userspace interface for
1060 sharing and destroying objects. While not an issue for full-fledged
1061 graphics stacks that include device-specific userspace components (in
1062 libdrm for instance), this limit makes DRM-based early boot graphics
1063 unnecessarily complex.
1064 </para>
1065 <para>
1066 Dumb objects partly alleviate the problem by providing a standard
1067 API to create dumb buffers suitable for scanout, which can then be used
1068 to create KMS frame buffers.
1069 </para>
1070 <para>
1071 To support dumb objects drivers must implement the
1072 <methodname>dumb_create</methodname>,
1073 <methodname>dumb_destroy</methodname> and
1074 <methodname>dumb_map_offset</methodname> operations.
1075 </para>
1076 <itemizedlist>
1077 <listitem>
1078 <synopsis>int (*dumb_create)(struct drm_file *file_priv, struct drm_device *dev,
1079 struct drm_mode_create_dumb *args);</synopsis>
1080 <para>
1081 The <methodname>dumb_create</methodname> operation creates a driver
1082 object (GEM or TTM handle) suitable for scanout based on the
1083 width, height and depth from the struct
1084 <structname>drm_mode_create_dumb</structname> argument. It fills the
1085 argument's <structfield>handle</structfield>,
1086 <structfield>pitch</structfield> and <structfield>size</structfield>
1087 fields with a handle for the newly created object and its line
1088 pitch and size in bytes.
1089 </para>
1090 </listitem>
1091 <listitem>
1092 <synopsis>int (*dumb_destroy)(struct drm_file *file_priv, struct drm_device *dev,
1093 uint32_t handle);</synopsis>
1094 <para>
1095 The <methodname>dumb_destroy</methodname> operation destroys a dumb
1096 object created by <methodname>dumb_create</methodname>.
1097 </para>
1098 </listitem>
1099 <listitem>
1100 <synopsis>int (*dumb_map_offset)(struct drm_file *file_priv, struct drm_device *dev,
1101 uint32_t handle, uint64_t *offset);</synopsis>
1102 <para>
1103 The <methodname>dumb_map_offset</methodname> operation associates an
1104 mmap fake offset with the object given by the handle and returns
1105 it. Drivers must use the
1106 <function>drm_gem_create_mmap_offset</function> function to
1107 associate the fake offset as described in
1108 <xref linkend="drm-gem-objects-mapping"/>.
1109 </para>
1110 </listitem>
1111 </itemizedlist>
1112 <para>
1113 Note that dumb objects may not be used for gpu acceleration, as has been
1114 attempted on some ARM embedded platforms. Such drivers really must have
1115 a hardware-specific ioctl to allocate suitable buffer objects.
1116 </para>
1117 </sect2>
1118 <sect2>
1119 <title>Output Polling</title>
1120 <synopsis>void (*output_poll_changed)(struct drm_device *dev);</synopsis>
1121 <para>
1122 This operation notifies the driver that the status of one or more
1123 connectors has changed. Drivers that use the fb helper can just call the
1124 <function>drm_fb_helper_hotplug_event</function> function to handle this
1125 operation.
1126 </para>
1127 </sect2>
1128 <sect2>
1129 <title>Locking</title>
1130 <para>
1131 Beside some lookup structures with their own locking (which is hidden
1132 behind the interface functions) most of the modeset state is protected
1133 by the <code>dev-&lt;mode_config.lock</code> mutex and additionally
1134 per-crtc locks to allow cursor updates, pageflips and similar operations
1135 to occur concurrently with background tasks like output detection.
1136 Operations which cross domains like a full modeset always grab all
1137 locks. Drivers there need to protect resources shared between crtcs with
1138 additional locking. They also need to be careful to always grab the
1139 relevant crtc locks if a modset functions touches crtc state, e.g. for
1140 load detection (which does only grab the <code>mode_config.lock</code>
1141 to allow concurrent screen updates on live crtcs).
1142 </para>
1143 </sect2>
1144 </sect1>
1145
1146 <!-- Internals: kms initialization and cleanup -->
1147
1148 <sect1 id="drm-kms-init">
1149 <title>KMS Initialization and Cleanup</title>
1150 <para>
1151 A KMS device is abstracted and exposed as a set of planes, CRTCs, encoders
1152 and connectors. KMS drivers must thus create and initialize all those
1153 objects at load time after initializing mode setting.
1154 </para>
1155 <sect2>
1156 <title>CRTCs (struct <structname>drm_crtc</structname>)</title>
1157 <para>
1158 A CRTC is an abstraction representing a part of the chip that contains a
1159 pointer to a scanout buffer. Therefore, the number of CRTCs available
1160 determines how many independent scanout buffers can be active at any
1161 given time. The CRTC structure contains several fields to support this:
1162 a pointer to some video memory (abstracted as a frame buffer object), a
1163 display mode, and an (x, y) offset into the video memory to support
1164 panning or configurations where one piece of video memory spans multiple
1165 CRTCs.
1166 </para>
1167 <sect3>
1168 <title>CRTC Initialization</title>
1169 <para>
1170 A KMS device must create and register at least one struct
1171 <structname>drm_crtc</structname> instance. The instance is allocated
1172 and zeroed by the driver, possibly as part of a larger structure, and
1173 registered with a call to <function>drm_crtc_init</function> with a
1174 pointer to CRTC functions.
1175 </para>
1176 </sect3>
1177 <sect3 id="drm-kms-crtcops">
1178 <title>CRTC Operations</title>
1179 <sect4>
1180 <title>Set Configuration</title>
1181 <synopsis>int (*set_config)(struct drm_mode_set *set);</synopsis>
1182 <para>
1183 Apply a new CRTC configuration to the device. The configuration
1184 specifies a CRTC, a frame buffer to scan out from, a (x,y) position in
1185 the frame buffer, a display mode and an array of connectors to drive
1186 with the CRTC if possible.
1187 </para>
1188 <para>
1189 If the frame buffer specified in the configuration is NULL, the driver
1190 must detach all encoders connected to the CRTC and all connectors
1191 attached to those encoders and disable them.
1192 </para>
1193 <para>
1194 This operation is called with the mode config lock held.
1195 </para>
1196 <note><para>
1197 Note that the drm core has no notion of restoring the mode setting
1198 state after resume, since all resume handling is in the full
1199 responsibility of the driver. The common mode setting helper library
1200 though provides a helper which can be used for this:
1201 <function>drm_helper_resume_force_mode</function>.
1202 </para></note>
1203 </sect4>
1204 <sect4>
1205 <title>Page Flipping</title>
1206 <synopsis>int (*page_flip)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
1207 struct drm_pending_vblank_event *event);</synopsis>
1208 <para>
1209 Schedule a page flip to the given frame buffer for the CRTC. This
1210 operation is called with the mode config mutex held.
1211 </para>
1212 <para>
1213 Page flipping is a synchronization mechanism that replaces the frame
1214 buffer being scanned out by the CRTC with a new frame buffer during
1215 vertical blanking, avoiding tearing. When an application requests a page
1216 flip the DRM core verifies that the new frame buffer is large enough to
1217 be scanned out by the CRTC in the currently configured mode and then
1218 calls the CRTC <methodname>page_flip</methodname> operation with a
1219 pointer to the new frame buffer.
1220 </para>
1221 <para>
1222 The <methodname>page_flip</methodname> operation schedules a page flip.
1223 Once any pending rendering targeting the new frame buffer has
1224 completed, the CRTC will be reprogrammed to display that frame buffer
1225 after the next vertical refresh. The operation must return immediately
1226 without waiting for rendering or page flip to complete and must block
1227 any new rendering to the frame buffer until the page flip completes.
1228 </para>
1229 <para>
1230 If a page flip can be successfully scheduled the driver must set the
1231 <code>drm_crtc-&gt;fb</code> field to the new framebuffer pointed to
1232 by <code>fb</code>. This is important so that the reference counting
1233 on framebuffers stays balanced.
1234 </para>
1235 <para>
1236 If a page flip is already pending, the
1237 <methodname>page_flip</methodname> operation must return
1238 -<errorname>EBUSY</errorname>.
1239 </para>
1240 <para>
1241 To synchronize page flip to vertical blanking the driver will likely
1242 need to enable vertical blanking interrupts. It should call
1243 <function>drm_vblank_get</function> for that purpose, and call
1244 <function>drm_vblank_put</function> after the page flip completes.
1245 </para>
1246 <para>
1247 If the application has requested to be notified when page flip completes
1248 the <methodname>page_flip</methodname> operation will be called with a
1249 non-NULL <parameter>event</parameter> argument pointing to a
1250 <structname>drm_pending_vblank_event</structname> instance. Upon page
1251 flip completion the driver must call <methodname>drm_send_vblank_event</methodname>
1252 to fill in the event and send to wake up any waiting processes.
1253 This can be performed with
1254 <programlisting><![CDATA[
1255 spin_lock_irqsave(&dev->event_lock, flags);
1256 ...
1257 drm_send_vblank_event(dev, pipe, event);
1258 spin_unlock_irqrestore(&dev->event_lock, flags);
1259 ]]></programlisting>
1260 </para>
1261 <note><para>
1262 FIXME: Could drivers that don't need to wait for rendering to complete
1263 just add the event to <literal>dev-&gt;vblank_event_list</literal> and
1264 let the DRM core handle everything, as for "normal" vertical blanking
1265 events?
1266 </para></note>
1267 <para>
1268 While waiting for the page flip to complete, the
1269 <literal>event-&gt;base.link</literal> list head can be used freely by
1270 the driver to store the pending event in a driver-specific list.
1271 </para>
1272 <para>
1273 If the file handle is closed before the event is signaled, drivers must
1274 take care to destroy the event in their
1275 <methodname>preclose</methodname> operation (and, if needed, call
1276 <function>drm_vblank_put</function>).
1277 </para>
1278 </sect4>
1279 <sect4>
1280 <title>Miscellaneous</title>
1281 <itemizedlist>
1282 <listitem>
1283 <synopsis>void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
1284 uint32_t start, uint32_t size);</synopsis>
1285 <para>
1286 Apply a gamma table to the device. The operation is optional.
1287 </para>
1288 </listitem>
1289 </itemizedlist>
1290 </sect4>
1291 </sect3>
1292 </sect2>
1293 <sect2>
1294 <title>Planes (struct <structname>drm_plane</structname>)</title>
1295 <para>
1296 A plane represents an image source that can be blended with or overlayed
1297 on top of a CRTC during the scanout process. Planes are associated with
1298 a frame buffer to crop a portion of the image memory (source) and
1299 optionally scale it to a destination size. The result is then blended
1300 with or overlayed on top of a CRTC.
1301 </para>
1302 <para>
1303 The DRM core recognizes three types of planes:
1304 <itemizedlist>
1305 <listitem>
1306 DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary
1307 planes are the planes operated upon by CRTC modesetting and flipping
1308 operations described in <xref linkend="drm-kms-crtcops"/>.
1309 </listitem>
1310 <listitem>
1311 DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. Cursor
1312 planes are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
1313 DRM_IOCTL_MODE_CURSOR2 ioctls.
1314 </listitem>
1315 <listitem>
1316 DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor planes.
1317 Some drivers refer to these types of planes as "sprites" internally.
1318 </listitem>
1319 </itemizedlist>
1320 For compatibility with legacy userspace, only overlay planes are made
1321 available to userspace by default. Userspace clients may set the
1322 DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that
1323 they wish to receive a universal plane list containing all plane types.
1324 </para>
1325 <sect3>
1326 <title>Plane Initialization</title>
1327 <para>
1328 To create a plane, a KMS drivers allocates and
1329 zeroes an instances of struct <structname>drm_plane</structname>
1330 (possibly as part of a larger structure) and registers it with a call
1331 to <function>drm_universal_plane_init</function>. The function takes a bitmask
1332 of the CRTCs that can be associated with the plane, a pointer to the
1333 plane functions, a list of format supported formats, and the type of
1334 plane (primary, cursor, or overlay) being initialized.
1335 </para>
1336 <para>
1337 Cursor and overlay planes are optional. All drivers should provide
1338 one primary plane per CRTC (although this requirement may change in
1339 the future); drivers that do not wish to provide special handling for
1340 primary planes may make use of the helper functions described in
1341 <xref linkend="drm-kms-planehelpers"/> to create and register a
1342 primary plane with standard capabilities.
1343 </para>
1344 </sect3>
1345 </sect2>
1346 <sect2>
1347 <title>Encoders (struct <structname>drm_encoder</structname>)</title>
1348 <para>
1349 An encoder takes pixel data from a CRTC and converts it to a format
1350 suitable for any attached connectors. On some devices, it may be
1351 possible to have a CRTC send data to more than one encoder. In that
1352 case, both encoders would receive data from the same scanout buffer,
1353 resulting in a "cloned" display configuration across the connectors
1354 attached to each encoder.
1355 </para>
1356 <sect3>
1357 <title>Encoder Initialization</title>
1358 <para>
1359 As for CRTCs, a KMS driver must create, initialize and register at
1360 least one struct <structname>drm_encoder</structname> instance. The
1361 instance is allocated and zeroed by the driver, possibly as part of a
1362 larger structure.
1363 </para>
1364 <para>
1365 Drivers must initialize the struct <structname>drm_encoder</structname>
1366 <structfield>possible_crtcs</structfield> and
1367 <structfield>possible_clones</structfield> fields before registering the
1368 encoder. Both fields are bitmasks of respectively the CRTCs that the
1369 encoder can be connected to, and sibling encoders candidate for cloning.
1370 </para>
1371 <para>
1372 After being initialized, the encoder must be registered with a call to
1373 <function>drm_encoder_init</function>. The function takes a pointer to
1374 the encoder functions and an encoder type. Supported types are
1375 <itemizedlist>
1376 <listitem>
1377 DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A
1378 </listitem>
1379 <listitem>
1380 DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort
1381 </listitem>
1382 <listitem>
1383 DRM_MODE_ENCODER_LVDS for display panels
1384 </listitem>
1385 <listitem>
1386 DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, Component,
1387 SCART)
1388 </listitem>
1389 <listitem>
1390 DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
1391 </listitem>
1392 </itemizedlist>
1393 </para>
1394 <para>
1395 Encoders must be attached to a CRTC to be used. DRM drivers leave
1396 encoders unattached at initialization time. Applications (or the fbdev
1397 compatibility layer when implemented) are responsible for attaching the
1398 encoders they want to use to a CRTC.
1399 </para>
1400 </sect3>
1401 </sect2>
1402 <sect2>
1403 <title>Connectors (struct <structname>drm_connector</structname>)</title>
1404 <para>
1405 A connector is the final destination for pixel data on a device, and
1406 usually connects directly to an external display device like a monitor
1407 or laptop panel. A connector can only be attached to one encoder at a
1408 time. The connector is also the structure where information about the
1409 attached display is kept, so it contains fields for display data, EDID
1410 data, DPMS &amp; connection status, and information about modes
1411 supported on the attached displays.
1412 </para>
1413 <sect3>
1414 <title>Connector Initialization</title>
1415 <para>
1416 Finally a KMS driver must create, initialize, register and attach at
1417 least one struct <structname>drm_connector</structname> instance. The
1418 instance is created as other KMS objects and initialized by setting the
1419 following fields.
1420 </para>
1421 <variablelist>
1422 <varlistentry>
1423 <term><structfield>interlace_allowed</structfield></term>
1424 <listitem><para>
1425 Whether the connector can handle interlaced modes.
1426 </para></listitem>
1427 </varlistentry>
1428 <varlistentry>
1429 <term><structfield>doublescan_allowed</structfield></term>
1430 <listitem><para>
1431 Whether the connector can handle doublescan.
1432 </para></listitem>
1433 </varlistentry>
1434 <varlistentry>
1435 <term><structfield>display_info
1436 </structfield></term>
1437 <listitem><para>
1438 Display information is filled from EDID information when a display
1439 is detected. For non hot-pluggable displays such as flat panels in
1440 embedded systems, the driver should initialize the
1441 <structfield>display_info</structfield>.<structfield>width_mm</structfield>
1442 and
1443 <structfield>display_info</structfield>.<structfield>height_mm</structfield>
1444 fields with the physical size of the display.
1445 </para></listitem>
1446 </varlistentry>
1447 <varlistentry>
1448 <term id="drm-kms-connector-polled"><structfield>polled</structfield></term>
1449 <listitem><para>
1450 Connector polling mode, a combination of
1451 <variablelist>
1452 <varlistentry>
1453 <term>DRM_CONNECTOR_POLL_HPD</term>
1454 <listitem><para>
1455 The connector generates hotplug events and doesn't need to be
1456 periodically polled. The CONNECT and DISCONNECT flags must not
1457 be set together with the HPD flag.
1458 </para></listitem>
1459 </varlistentry>
1460 <varlistentry>
1461 <term>DRM_CONNECTOR_POLL_CONNECT</term>
1462 <listitem><para>
1463 Periodically poll the connector for connection.
1464 </para></listitem>
1465 </varlistentry>
1466 <varlistentry>
1467 <term>DRM_CONNECTOR_POLL_DISCONNECT</term>
1468 <listitem><para>
1469 Periodically poll the connector for disconnection.
1470 </para></listitem>
1471 </varlistentry>
1472 </variablelist>
1473 Set to 0 for connectors that don't support connection status
1474 discovery.
1475 </para></listitem>
1476 </varlistentry>
1477 </variablelist>
1478 <para>
1479 The connector is then registered with a call to
1480 <function>drm_connector_init</function> with a pointer to the connector
1481 functions and a connector type, and exposed through sysfs with a call to
1482 <function>drm_connector_register</function>.
1483 </para>
1484 <para>
1485 Supported connector types are
1486 <itemizedlist>
1487 <listitem>DRM_MODE_CONNECTOR_VGA</listitem>
1488 <listitem>DRM_MODE_CONNECTOR_DVII</listitem>
1489 <listitem>DRM_MODE_CONNECTOR_DVID</listitem>
1490 <listitem>DRM_MODE_CONNECTOR_DVIA</listitem>
1491 <listitem>DRM_MODE_CONNECTOR_Composite</listitem>
1492 <listitem>DRM_MODE_CONNECTOR_SVIDEO</listitem>
1493 <listitem>DRM_MODE_CONNECTOR_LVDS</listitem>
1494 <listitem>DRM_MODE_CONNECTOR_Component</listitem>
1495 <listitem>DRM_MODE_CONNECTOR_9PinDIN</listitem>
1496 <listitem>DRM_MODE_CONNECTOR_DisplayPort</listitem>
1497 <listitem>DRM_MODE_CONNECTOR_HDMIA</listitem>
1498 <listitem>DRM_MODE_CONNECTOR_HDMIB</listitem>
1499 <listitem>DRM_MODE_CONNECTOR_TV</listitem>
1500 <listitem>DRM_MODE_CONNECTOR_eDP</listitem>
1501 <listitem>DRM_MODE_CONNECTOR_VIRTUAL</listitem>
1502 </itemizedlist>
1503 </para>
1504 <para>
1505 Connectors must be attached to an encoder to be used. For devices that
1506 map connectors to encoders 1:1, the connector should be attached at
1507 initialization time with a call to
1508 <function>drm_mode_connector_attach_encoder</function>. The driver must
1509 also set the <structname>drm_connector</structname>
1510 <structfield>encoder</structfield> field to point to the attached
1511 encoder.
1512 </para>
1513 <para>
1514 Finally, drivers must initialize the connectors state change detection
1515 with a call to <function>drm_kms_helper_poll_init</function>. If at
1516 least one connector is pollable but can't generate hotplug interrupts
1517 (indicated by the DRM_CONNECTOR_POLL_CONNECT and
1518 DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will
1519 automatically be queued to periodically poll for changes. Connectors
1520 that can generate hotplug interrupts must be marked with the
1521 DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must
1522 call <function>drm_helper_hpd_irq_event</function>. The function will
1523 queue a delayed work to check the state of all connectors, but no
1524 periodic polling will be done.
1525 </para>
1526 </sect3>
1527 <sect3>
1528 <title>Connector Operations</title>
1529 <note><para>
1530 Unless otherwise state, all operations are mandatory.
1531 </para></note>
1532 <sect4>
1533 <title>DPMS</title>
1534 <synopsis>void (*dpms)(struct drm_connector *connector, int mode);</synopsis>
1535 <para>
1536 The DPMS operation sets the power state of a connector. The mode
1537 argument is one of
1538 <itemizedlist>
1539 <listitem><para>DRM_MODE_DPMS_ON</para></listitem>
1540 <listitem><para>DRM_MODE_DPMS_STANDBY</para></listitem>
1541 <listitem><para>DRM_MODE_DPMS_SUSPEND</para></listitem>
1542 <listitem><para>DRM_MODE_DPMS_OFF</para></listitem>
1543 </itemizedlist>
1544 </para>
1545 <para>
1546 In all but DPMS_ON mode the encoder to which the connector is attached
1547 should put the display in low-power mode by driving its signals
1548 appropriately. If more than one connector is attached to the encoder
1549 care should be taken not to change the power state of other displays as
1550 a side effect. Low-power mode should be propagated to the encoders and
1551 CRTCs when all related connectors are put in low-power mode.
1552 </para>
1553 </sect4>
1554 <sect4>
1555 <title>Modes</title>
1556 <synopsis>int (*fill_modes)(struct drm_connector *connector, uint32_t max_width,
1557 uint32_t max_height);</synopsis>
1558 <para>
1559 Fill the mode list with all supported modes for the connector. If the
1560 <parameter>max_width</parameter> and <parameter>max_height</parameter>
1561 arguments are non-zero, the implementation must ignore all modes wider
1562 than <parameter>max_width</parameter> or higher than
1563 <parameter>max_height</parameter>.
1564 </para>
1565 <para>
1566 The connector must also fill in this operation its
1567 <structfield>display_info</structfield>
1568 <structfield>width_mm</structfield> and
1569 <structfield>height_mm</structfield> fields with the connected display
1570 physical size in millimeters. The fields should be set to 0 if the value
1571 isn't known or is not applicable (for instance for projector devices).
1572 </para>
1573 </sect4>
1574 <sect4>
1575 <title>Connection Status</title>
1576 <para>
1577 The connection status is updated through polling or hotplug events when
1578 supported (see <xref linkend="drm-kms-connector-polled"/>). The status
1579 value is reported to userspace through ioctls and must not be used
1580 inside the driver, as it only gets initialized by a call to
1581 <function>drm_mode_getconnector</function> from userspace.
1582 </para>
1583 <synopsis>enum drm_connector_status (*detect)(struct drm_connector *connector,
1584 bool force);</synopsis>
1585 <para>
1586 Check to see if anything is attached to the connector. The
1587 <parameter>force</parameter> parameter is set to false whilst polling or
1588 to true when checking the connector due to user request.
1589 <parameter>force</parameter> can be used by the driver to avoid
1590 expensive, destructive operations during automated probing.
1591 </para>
1592 <para>
1593 Return connector_status_connected if something is connected to the
1594 connector, connector_status_disconnected if nothing is connected and
1595 connector_status_unknown if the connection state isn't known.
1596 </para>
1597 <para>
1598 Drivers should only return connector_status_connected if the connection
1599 status has really been probed as connected. Connectors that can't detect
1600 the connection status, or failed connection status probes, should return
1601 connector_status_unknown.
1602 </para>
1603 </sect4>
1604 </sect3>
1605 </sect2>
1606 <sect2>
1607 <title>Cleanup</title>
1608 <para>
1609 The DRM core manages its objects' lifetime. When an object is not needed
1610 anymore the core calls its destroy function, which must clean up and
1611 free every resource allocated for the object. Every
1612 <function>drm_*_init</function> call must be matched with a
1613 corresponding <function>drm_*_cleanup</function> call to cleanup CRTCs
1614 (<function>drm_crtc_cleanup</function>), planes
1615 (<function>drm_plane_cleanup</function>), encoders
1616 (<function>drm_encoder_cleanup</function>) and connectors
1617 (<function>drm_connector_cleanup</function>). Furthermore, connectors
1618 that have been added to sysfs must be removed by a call to
1619 <function>drm_connector_unregister</function> before calling
1620 <function>drm_connector_cleanup</function>.
1621 </para>
1622 <para>
1623 Connectors state change detection must be cleanup up with a call to
1624 <function>drm_kms_helper_poll_fini</function>.
1625 </para>
1626 </sect2>
1627 <sect2>
1628 <title>Output discovery and initialization example</title>
1629 <programlisting><![CDATA[
1630 void intel_crt_init(struct drm_device *dev)
1631 {
1632 struct drm_connector *connector;
1633 struct intel_output *intel_output;
1634
1635 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
1636 if (!intel_output)
1637 return;
1638
1639 connector = &intel_output->base;
1640 drm_connector_init(dev, &intel_output->base,
1641 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
1642
1643 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
1644 DRM_MODE_ENCODER_DAC);
1645
1646 drm_mode_connector_attach_encoder(&intel_output->base,
1647 &intel_output->enc);
1648
1649 /* Set up the DDC bus. */
1650 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
1651 if (!intel_output->ddc_bus) {
1652 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
1653 "failed.\n");
1654 return;
1655 }
1656
1657 intel_output->type = INTEL_OUTPUT_ANALOG;
1658 connector->interlace_allowed = 0;
1659 connector->doublescan_allowed = 0;
1660
1661 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
1662 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
1663
1664 drm_connector_register(connector);
1665 }]]></programlisting>
1666 <para>
1667 In the example above (taken from the i915 driver), a CRTC, connector and
1668 encoder combination is created. A device-specific i2c bus is also
1669 created for fetching EDID data and performing monitor detection. Once
1670 the process is complete, the new connector is registered with sysfs to
1671 make its properties available to applications.
1672 </para>
1673 </sect2>
1674 <sect2>
1675 <title>KMS API Functions</title>
1676 !Edrivers/gpu/drm/drm_crtc.c
1677 </sect2>
1678 <sect2>
1679 <title>KMS Data Structures</title>
1680 !Iinclude/drm/drm_crtc.h
1681 </sect2>
1682 <sect2>
1683 <title>KMS Locking</title>
1684 !Pdrivers/gpu/drm/drm_modeset_lock.c kms locking
1685 !Iinclude/drm/drm_modeset_lock.h
1686 !Edrivers/gpu/drm/drm_modeset_lock.c
1687 </sect2>
1688 </sect1>
1689
1690 <!-- Internals: kms helper functions -->
1691
1692 <sect1>
1693 <title>Mode Setting Helper Functions</title>
1694 <para>
1695 The plane, CRTC, encoder and connector functions provided by the drivers
1696 implement the DRM API. They're called by the DRM core and ioctl handlers
1697 to handle device state changes and configuration request. As implementing
1698 those functions often requires logic not specific to drivers, mid-layer
1699 helper functions are available to avoid duplicating boilerplate code.
1700 </para>
1701 <para>
1702 The DRM core contains one mid-layer implementation. The mid-layer provides
1703 implementations of several plane, CRTC, encoder and connector functions
1704 (called from the top of the mid-layer) that pre-process requests and call
1705 lower-level functions provided by the driver (at the bottom of the
1706 mid-layer). For instance, the
1707 <function>drm_crtc_helper_set_config</function> function can be used to
1708 fill the struct <structname>drm_crtc_funcs</structname>
1709 <structfield>set_config</structfield> field. When called, it will split
1710 the <methodname>set_config</methodname> operation in smaller, simpler
1711 operations and call the driver to handle them.
1712 </para>
1713 <para>
1714 To use the mid-layer, drivers call <function>drm_crtc_helper_add</function>,
1715 <function>drm_encoder_helper_add</function> and
1716 <function>drm_connector_helper_add</function> functions to install their
1717 mid-layer bottom operations handlers, and fill the
1718 <structname>drm_crtc_funcs</structname>,
1719 <structname>drm_encoder_funcs</structname> and
1720 <structname>drm_connector_funcs</structname> structures with pointers to
1721 the mid-layer top API functions. Installing the mid-layer bottom operation
1722 handlers is best done right after registering the corresponding KMS object.
1723 </para>
1724 <para>
1725 The mid-layer is not split between CRTC, encoder and connector operations.
1726 To use it, a driver must provide bottom functions for all of the three KMS
1727 entities.
1728 </para>
1729 <sect2>
1730 <title>Legacy CRTC Helper Operations</title>
1731 <itemizedlist>
1732 <listitem id="drm-helper-crtc-mode-fixup">
1733 <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc,
1734 const struct drm_display_mode *mode,
1735 struct drm_display_mode *adjusted_mode);</synopsis>
1736 <para>
1737 Let CRTCs adjust the requested mode or reject it completely. This
1738 operation returns true if the mode is accepted (possibly after being
1739 adjusted) or false if it is rejected.
1740 </para>
1741 <para>
1742 The <methodname>mode_fixup</methodname> operation should reject the
1743 mode if it can't reasonably use it. The definition of "reasonable"
1744 is currently fuzzy in this context. One possible behaviour would be
1745 to set the adjusted mode to the panel timings when a fixed-mode
1746 panel is used with hardware capable of scaling. Another behaviour
1747 would be to accept any input mode and adjust it to the closest mode
1748 supported by the hardware (FIXME: This needs to be clarified).
1749 </para>
1750 </listitem>
1751 <listitem>
1752 <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
1753 struct drm_framebuffer *old_fb)</synopsis>
1754 <para>
1755 Move the CRTC on the current frame buffer (stored in
1756 <literal>crtc-&gt;fb</literal>) to position (x,y). Any of the frame
1757 buffer, x position or y position may have been modified.
1758 </para>
1759 <para>
1760 This helper operation is optional. If not provided, the
1761 <function>drm_crtc_helper_set_config</function> function will fall
1762 back to the <methodname>mode_set</methodname> helper operation.
1763 </para>
1764 <note><para>
1765 FIXME: Why are x and y passed as arguments, as they can be accessed
1766 through <literal>crtc-&gt;x</literal> and
1767 <literal>crtc-&gt;y</literal>?
1768 </para></note>
1769 </listitem>
1770 <listitem>
1771 <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis>
1772 <para>
1773 Prepare the CRTC for mode setting. This operation is called after
1774 validating the requested mode. Drivers use it to perform
1775 device-specific operations required before setting the new mode.
1776 </para>
1777 </listitem>
1778 <listitem>
1779 <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
1780 struct drm_display_mode *adjusted_mode, int x, int y,
1781 struct drm_framebuffer *old_fb);</synopsis>
1782 <para>
1783 Set a new mode, position and frame buffer. Depending on the device
1784 requirements, the mode can be stored internally by the driver and
1785 applied in the <methodname>commit</methodname> operation, or
1786 programmed to the hardware immediately.
1787 </para>
1788 <para>
1789 The <methodname>mode_set</methodname> operation returns 0 on success
1790 or a negative error code if an error occurs.
1791 </para>
1792 </listitem>
1793 <listitem>
1794 <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis>
1795 <para>
1796 Commit a mode. This operation is called after setting the new mode.
1797 Upon return the device must use the new mode and be fully
1798 operational.
1799 </para>
1800 </listitem>
1801 </itemizedlist>
1802 </sect2>
1803 <sect2>
1804 <title>Encoder Helper Operations</title>
1805 <itemizedlist>
1806 <listitem>
1807 <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder,
1808 const struct drm_display_mode *mode,
1809 struct drm_display_mode *adjusted_mode);</synopsis>
1810 <para>
1811 Let encoders adjust the requested mode or reject it completely. This
1812 operation returns true if the mode is accepted (possibly after being
1813 adjusted) or false if it is rejected. See the
1814 <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper
1815 operation</link> for an explanation of the allowed adjustments.
1816 </para>
1817 </listitem>
1818 <listitem>
1819 <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis>
1820 <para>
1821 Prepare the encoder for mode setting. This operation is called after
1822 validating the requested mode. Drivers use it to perform
1823 device-specific operations required before setting the new mode.
1824 </para>
1825 </listitem>
1826 <listitem>
1827 <synopsis>void (*mode_set)(struct drm_encoder *encoder,
1828 struct drm_display_mode *mode,
1829 struct drm_display_mode *adjusted_mode);</synopsis>
1830 <para>
1831 Set a new mode. Depending on the device requirements, the mode can
1832 be stored internally by the driver and applied in the
1833 <methodname>commit</methodname> operation, or programmed to the
1834 hardware immediately.
1835 </para>
1836 </listitem>
1837 <listitem>
1838 <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis>
1839 <para>
1840 Commit a mode. This operation is called after setting the new mode.
1841 Upon return the device must use the new mode and be fully
1842 operational.
1843 </para>
1844 </listitem>
1845 </itemizedlist>
1846 </sect2>
1847 <sect2>
1848 <title>Connector Helper Operations</title>
1849 <itemizedlist>
1850 <listitem>
1851 <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis>
1852 <para>
1853 Return a pointer to the best encoder for the connecter. Device that
1854 map connectors to encoders 1:1 simply return the pointer to the
1855 associated encoder. This operation is mandatory.
1856 </para>
1857 </listitem>
1858 <listitem>
1859 <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis>
1860 <para>
1861 Fill the connector's <structfield>probed_modes</structfield> list
1862 by parsing EDID data with <function>drm_add_edid_modes</function>,
1863 adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>,
1864 or calling <function>drm_mode_probed_add</function> directly for every
1865 supported mode and return the number of modes it has detected. This
1866 operation is mandatory.
1867 </para>
1868 <para>
1869 Note that the caller function will automatically add standard VESA
1870 DMT modes up to 1024x768 if the <methodname>get_modes</methodname>
1871 helper operation returns no mode and if the connector status is
1872 connector_status_connected. There is no need to call
1873 <function>drm_add_edid_modes</function> manually in that case.
1874 </para>
1875 <para>
1876 When adding modes manually the driver creates each mode with a call to
1877 <function>drm_mode_create</function> and must fill the following fields.
1878 <itemizedlist>
1879 <listitem>
1880 <synopsis>__u32 type;</synopsis>
1881 <para>
1882 Mode type bitmask, a combination of
1883 <variablelist>
1884 <varlistentry>
1885 <term>DRM_MODE_TYPE_BUILTIN</term>
1886 <listitem><para>not used?</para></listitem>
1887 </varlistentry>
1888 <varlistentry>
1889 <term>DRM_MODE_TYPE_CLOCK_C</term>
1890 <listitem><para>not used?</para></listitem>
1891 </varlistentry>
1892 <varlistentry>
1893 <term>DRM_MODE_TYPE_CRTC_C</term>
1894 <listitem><para>not used?</para></listitem>
1895 </varlistentry>
1896 <varlistentry>
1897 <term>
1898 DRM_MODE_TYPE_PREFERRED - The preferred mode for the connector
1899 </term>
1900 <listitem>
1901 <para>not used?</para>
1902 </listitem>
1903 </varlistentry>
1904 <varlistentry>
1905 <term>DRM_MODE_TYPE_DEFAULT</term>
1906 <listitem><para>not used?</para></listitem>
1907 </varlistentry>
1908 <varlistentry>
1909 <term>DRM_MODE_TYPE_USERDEF</term>
1910 <listitem><para>not used?</para></listitem>
1911 </varlistentry>
1912 <varlistentry>
1913 <term>DRM_MODE_TYPE_DRIVER</term>
1914 <listitem>
1915 <para>
1916 The mode has been created by the driver (as opposed to
1917 to user-created modes).
1918 </para>
1919 </listitem>
1920 </varlistentry>
1921 </variablelist>
1922 Drivers must set the DRM_MODE_TYPE_DRIVER bit for all modes they
1923 create, and set the DRM_MODE_TYPE_PREFERRED bit for the preferred
1924 mode.
1925 </para>
1926 </listitem>
1927 <listitem>
1928 <synopsis>__u32 clock;</synopsis>
1929 <para>Pixel clock frequency in kHz unit</para>
1930 </listitem>
1931 <listitem>
1932 <synopsis>__u16 hdisplay, hsync_start, hsync_end, htotal;
1933 __u16 vdisplay, vsync_start, vsync_end, vtotal;</synopsis>
1934 <para>Horizontal and vertical timing information</para>
1935 <screen><![CDATA[
1936 Active Front Sync Back
1937 Region Porch Porch
1938 <-----------------------><----------------><-------------><-------------->
1939
1940 //////////////////////|
1941 ////////////////////// |
1942 ////////////////////// |.................. ................
1943 _______________
1944
1945 <----- [hv]display ----->
1946 <------------- [hv]sync_start ------------>
1947 <--------------------- [hv]sync_end --------------------->
1948 <-------------------------------- [hv]total ----------------------------->
1949 ]]></screen>
1950 </listitem>
1951 <listitem>
1952 <synopsis>__u16 hskew;
1953 __u16 vscan;</synopsis>
1954 <para>Unknown</para>
1955 </listitem>
1956 <listitem>
1957 <synopsis>__u32 flags;</synopsis>
1958 <para>
1959 Mode flags, a combination of
1960 <variablelist>
1961 <varlistentry>
1962 <term>DRM_MODE_FLAG_PHSYNC</term>
1963 <listitem><para>
1964 Horizontal sync is active high
1965 </para></listitem>
1966 </varlistentry>
1967 <varlistentry>
1968 <term>DRM_MODE_FLAG_NHSYNC</term>
1969 <listitem><para>
1970 Horizontal sync is active low
1971 </para></listitem>
1972 </varlistentry>
1973 <varlistentry>
1974 <term>DRM_MODE_FLAG_PVSYNC</term>
1975 <listitem><para>
1976 Vertical sync is active high
1977 </para></listitem>
1978 </varlistentry>
1979 <varlistentry>
1980 <term>DRM_MODE_FLAG_NVSYNC</term>
1981 <listitem><para>
1982 Vertical sync is active low
1983 </para></listitem>
1984 </varlistentry>
1985 <varlistentry>
1986 <term>DRM_MODE_FLAG_INTERLACE</term>
1987 <listitem><para>
1988 Mode is interlaced
1989 </para></listitem>
1990 </varlistentry>
1991 <varlistentry>
1992 <term>DRM_MODE_FLAG_DBLSCAN</term>
1993 <listitem><para>
1994 Mode uses doublescan
1995 </para></listitem>
1996 </varlistentry>
1997 <varlistentry>
1998 <term>DRM_MODE_FLAG_CSYNC</term>
1999 <listitem><para>
2000 Mode uses composite sync
2001 </para></listitem>
2002 </varlistentry>
2003 <varlistentry>
2004 <term>DRM_MODE_FLAG_PCSYNC</term>
2005 <listitem><para>
2006 Composite sync is active high
2007 </para></listitem>
2008 </varlistentry>
2009 <varlistentry>
2010 <term>DRM_MODE_FLAG_NCSYNC</term>
2011 <listitem><para>
2012 Composite sync is active low
2013 </para></listitem>
2014 </varlistentry>
2015 <varlistentry>
2016 <term>DRM_MODE_FLAG_HSKEW</term>
2017 <listitem><para>
2018 hskew provided (not used?)
2019 </para></listitem>
2020 </varlistentry>
2021 <varlistentry>
2022 <term>DRM_MODE_FLAG_BCAST</term>
2023 <listitem><para>
2024 not used?
2025 </para></listitem>
2026 </varlistentry>
2027 <varlistentry>
2028 <term>DRM_MODE_FLAG_PIXMUX</term>
2029 <listitem><para>
2030 not used?
2031 </para></listitem>
2032 </varlistentry>
2033 <varlistentry>
2034 <term>DRM_MODE_FLAG_DBLCLK</term>
2035 <listitem><para>
2036 not used?
2037 </para></listitem>
2038 </varlistentry>
2039 <varlistentry>
2040 <term>DRM_MODE_FLAG_CLKDIV2</term>
2041 <listitem><para>
2042 ?
2043 </para></listitem>
2044 </varlistentry>
2045 </variablelist>
2046 </para>
2047 <para>
2048 Note that modes marked with the INTERLACE or DBLSCAN flags will be
2049 filtered out by
2050 <function>drm_helper_probe_single_connector_modes</function> if
2051 the connector's <structfield>interlace_allowed</structfield> or
2052 <structfield>doublescan_allowed</structfield> field is set to 0.
2053 </para>
2054 </listitem>
2055 <listitem>
2056 <synopsis>char name[DRM_DISPLAY_MODE_LEN];</synopsis>
2057 <para>
2058 Mode name. The driver must call
2059 <function>drm_mode_set_name</function> to fill the mode name from
2060 <structfield>hdisplay</structfield>,
2061 <structfield>vdisplay</structfield> and interlace flag after
2062 filling the corresponding fields.
2063 </para>
2064 </listitem>
2065 </itemizedlist>
2066 </para>
2067 <para>
2068 The <structfield>vrefresh</structfield> value is computed by
2069 <function>drm_helper_probe_single_connector_modes</function>.
2070 </para>
2071 <para>
2072 When parsing EDID data, <function>drm_add_edid_modes</function> fills the
2073 connector <structfield>display_info</structfield>
2074 <structfield>width_mm</structfield> and
2075 <structfield>height_mm</structfield> fields. When creating modes
2076 manually the <methodname>get_modes</methodname> helper operation must
2077 set the <structfield>display_info</structfield>
2078 <structfield>width_mm</structfield> and
2079 <structfield>height_mm</structfield> fields if they haven't been set
2080 already (for instance at initialization time when a fixed-size panel is
2081 attached to the connector). The mode <structfield>width_mm</structfield>
2082 and <structfield>height_mm</structfield> fields are only used internally
2083 during EDID parsing and should not be set when creating modes manually.
2084 </para>
2085 </listitem>
2086 <listitem>
2087 <synopsis>int (*mode_valid)(struct drm_connector *connector,
2088 struct drm_display_mode *mode);</synopsis>
2089 <para>
2090 Verify whether a mode is valid for the connector. Return MODE_OK for
2091 supported modes and one of the enum drm_mode_status values (MODE_*)
2092 for unsupported modes. This operation is optional.
2093 </para>
2094 <para>
2095 As the mode rejection reason is currently not used beside for
2096 immediately removing the unsupported mode, an implementation can
2097 return MODE_BAD regardless of the exact reason why the mode is not
2098 valid.
2099 </para>
2100 <note><para>
2101 Note that the <methodname>mode_valid</methodname> helper operation is
2102 only called for modes detected by the device, and
2103 <emphasis>not</emphasis> for modes set by the user through the CRTC
2104 <methodname>set_config</methodname> operation.
2105 </para></note>
2106 </listitem>
2107 </itemizedlist>
2108 </sect2>
2109 <sect2>
2110 <title>Atomic Modeset Helper Functions Reference</title>
2111 <sect3>
2112 <title>Overview</title>
2113 !Pdrivers/gpu/drm/drm_atomic_helper.c overview
2114 </sect3>
2115 <sect3>
2116 <title>Implementing Asynchronous Atomic Commit</title>
2117 !Pdrivers/gpu/drm/drm_atomic_helper.c implementing async commit
2118 </sect3>
2119 <sect3>
2120 <title>Atomic State Reset and Initialization</title>
2121 !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
2122 </sect3>
2123 !Iinclude/drm/drm_atomic_helper.h
2124 !Edrivers/gpu/drm/drm_atomic_helper.c
2125 </sect2>
2126 <sect2>
2127 <title>Modeset Helper Reference for Common Vtables</title>
2128 !Iinclude/drm/drm_modeset_helper_vtables.h
2129 !Pinclude/drm/drm_modeset_helper_vtables.h overview
2130 </sect2>
2131 <sect2>
2132 <title>Legacy CRTC/Modeset Helper Functions Reference</title>
2133 !Edrivers/gpu/drm/drm_crtc_helper.c
2134 !Pdrivers/gpu/drm/drm_crtc_helper.c overview
2135 </sect2>
2136 <sect2>
2137 <title>Output Probing Helper Functions Reference</title>
2138 !Pdrivers/gpu/drm/drm_probe_helper.c output probing helper overview
2139 !Edrivers/gpu/drm/drm_probe_helper.c
2140 </sect2>
2141 <sect2>
2142 <title>fbdev Helper Functions Reference</title>
2143 !Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers
2144 !Edrivers/gpu/drm/drm_fb_helper.c
2145 !Iinclude/drm/drm_fb_helper.h
2146 </sect2>
2147 <sect2>
2148 <title>Display Port Helper Functions Reference</title>
2149 !Pdrivers/gpu/drm/drm_dp_helper.c dp helpers
2150 !Iinclude/drm/drm_dp_helper.h
2151 !Edrivers/gpu/drm/drm_dp_helper.c
2152 </sect2>
2153 <sect2>
2154 <title>Display Port MST Helper Functions Reference</title>
2155 !Pdrivers/gpu/drm/drm_dp_mst_topology.c dp mst helper
2156 !Iinclude/drm/drm_dp_mst_helper.h
2157 !Edrivers/gpu/drm/drm_dp_mst_topology.c
2158 </sect2>
2159 <sect2>
2160 <title>MIPI DSI Helper Functions Reference</title>
2161 !Pdrivers/gpu/drm/drm_mipi_dsi.c dsi helpers
2162 !Iinclude/drm/drm_mipi_dsi.h
2163 !Edrivers/gpu/drm/drm_mipi_dsi.c
2164 </sect2>
2165 <sect2>
2166 <title>EDID Helper Functions Reference</title>
2167 !Edrivers/gpu/drm/drm_edid.c
2168 </sect2>
2169 <sect2>
2170 <title>Rectangle Utilities Reference</title>
2171 !Pinclude/drm/drm_rect.h rect utils
2172 !Iinclude/drm/drm_rect.h
2173 !Edrivers/gpu/drm/drm_rect.c
2174 </sect2>
2175 <sect2>
2176 <title>Flip-work Helper Reference</title>
2177 !Pinclude/drm/drm_flip_work.h flip utils
2178 !Iinclude/drm/drm_flip_work.h
2179 !Edrivers/gpu/drm/drm_flip_work.c
2180 </sect2>
2181 <sect2>
2182 <title>HDMI Infoframes Helper Reference</title>
2183 <para>
2184 Strictly speaking this is not a DRM helper library but generally useable
2185 by any driver interfacing with HDMI outputs like v4l or alsa drivers.
2186 But it nicely fits into the overall topic of mode setting helper
2187 libraries and hence is also included here.
2188 </para>
2189 !Iinclude/linux/hdmi.h
2190 !Edrivers/video/hdmi.c
2191 </sect2>
2192 <sect2>
2193 <title id="drm-kms-planehelpers">Plane Helper Reference</title>
2194 !Edrivers/gpu/drm/drm_plane_helper.c
2195 !Pdrivers/gpu/drm/drm_plane_helper.c overview
2196 </sect2>
2197 <sect2>
2198 <title>Tile group</title>
2199 !Pdrivers/gpu/drm/drm_crtc.c Tile group
2200 </sect2>
2201 <sect2>
2202 <title>Bridges</title>
2203 <sect3>
2204 <title>Overview</title>
2205 !Pdrivers/gpu/drm/drm_bridge.c overview
2206 </sect3>
2207 <sect3>
2208 <title>Default bridge callback sequence</title>
2209 !Pdrivers/gpu/drm/drm_bridge.c bridge callbacks
2210 </sect3>
2211 !Edrivers/gpu/drm/drm_bridge.c
2212 </sect2>
2213 </sect1>
2214
2215 <!-- Internals: kms properties -->
2216
2217 <sect1 id="drm-kms-properties">
2218 <title>KMS Properties</title>
2219 <para>
2220 Drivers may need to expose additional parameters to applications than
2221 those described in the previous sections. KMS supports attaching
2222 properties to CRTCs, connectors and planes and offers a userspace API to
2223 list, get and set the property values.
2224 </para>
2225 <para>
2226 Properties are identified by a name that uniquely defines the property
2227 purpose, and store an associated value. For all property types except blob
2228 properties the value is a 64-bit unsigned integer.
2229 </para>
2230 <para>
2231 KMS differentiates between properties and property instances. Drivers
2232 first create properties and then create and associate individual instances
2233 of those properties to objects. A property can be instantiated multiple
2234 times and associated with different objects. Values are stored in property
2235 instances, and all other property information are stored in the property
2236 and shared between all instances of the property.
2237 </para>
2238 <para>
2239 Every property is created with a type that influences how the KMS core
2240 handles the property. Supported property types are
2241 <variablelist>
2242 <varlistentry>
2243 <term>DRM_MODE_PROP_RANGE</term>
2244 <listitem><para>Range properties report their minimum and maximum
2245 admissible values. The KMS core verifies that values set by
2246 application fit in that range.</para></listitem>
2247 </varlistentry>
2248 <varlistentry>
2249 <term>DRM_MODE_PROP_ENUM</term>
2250 <listitem><para>Enumerated properties take a numerical value that
2251 ranges from 0 to the number of enumerated values defined by the
2252 property minus one, and associate a free-formed string name to each
2253 value. Applications can retrieve the list of defined value-name pairs
2254 and use the numerical value to get and set property instance values.
2255 </para></listitem>
2256 </varlistentry>
2257 <varlistentry>
2258 <term>DRM_MODE_PROP_BITMASK</term>
2259 <listitem><para>Bitmask properties are enumeration properties that
2260 additionally restrict all enumerated values to the 0..63 range.
2261 Bitmask property instance values combine one or more of the
2262 enumerated bits defined by the property.</para></listitem>
2263 </varlistentry>
2264 <varlistentry>
2265 <term>DRM_MODE_PROP_BLOB</term>
2266 <listitem><para>Blob properties store a binary blob without any format
2267 restriction. The binary blobs are created as KMS standalone objects,
2268 and blob property instance values store the ID of their associated
2269 blob object.</para>
2270 <para>Blob properties are only used for the connector EDID property
2271 and cannot be created by drivers.</para></listitem>
2272 </varlistentry>
2273 </variablelist>
2274 </para>
2275 <para>
2276 To create a property drivers call one of the following functions depending
2277 on the property type. All property creation functions take property flags
2278 and name, as well as type-specific arguments.
2279 <itemizedlist>
2280 <listitem>
2281 <synopsis>struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
2282 const char *name,
2283 uint64_t min, uint64_t max);</synopsis>
2284 <para>Create a range property with the given minimum and maximum
2285 values.</para>
2286 </listitem>
2287 <listitem>
2288 <synopsis>struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
2289 const char *name,
2290 const struct drm_prop_enum_list *props,
2291 int num_values);</synopsis>
2292 <para>Create an enumerated property. The <parameter>props</parameter>
2293 argument points to an array of <parameter>num_values</parameter>
2294 value-name pairs.</para>
2295 </listitem>
2296 <listitem>
2297 <synopsis>struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
2298 int flags, const char *name,
2299 const struct drm_prop_enum_list *props,
2300 int num_values);</synopsis>
2301 <para>Create a bitmask property. The <parameter>props</parameter>
2302 argument points to an array of <parameter>num_values</parameter>
2303 value-name pairs.</para>
2304 </listitem>
2305 </itemizedlist>
2306 </para>
2307 <para>
2308 Properties can additionally be created as immutable, in which case they
2309 will be read-only for applications but can be modified by the driver. To
2310 create an immutable property drivers must set the DRM_MODE_PROP_IMMUTABLE
2311 flag at property creation time.
2312 </para>
2313 <para>
2314 When no array of value-name pairs is readily available at property
2315 creation time for enumerated or range properties, drivers can create
2316 the property using the <function>drm_property_create</function> function
2317 and manually add enumeration value-name pairs by calling the
2318 <function>drm_property_add_enum</function> function. Care must be taken to
2319 properly specify the property type through the <parameter>flags</parameter>
2320 argument.
2321 </para>
2322 <para>
2323 After creating properties drivers can attach property instances to CRTC,
2324 connector and plane objects by calling the
2325 <function>drm_object_attach_property</function>. The function takes a
2326 pointer to the target object, a pointer to the previously created property
2327 and an initial instance value.
2328 </para>
2329 <sect2>
2330 <title>Existing KMS Properties</title>
2331 <para>
2332 The following table gives description of drm properties exposed by various
2333 modules/drivers.
2334 </para>
2335 <table border="1" cellpadding="0" cellspacing="0">
2336 <tbody>
2337 <tr style="font-weight: bold;">
2338 <td valign="top" >Owner Module/Drivers</td>
2339 <td valign="top" >Group</td>
2340 <td valign="top" >Property Name</td>
2341 <td valign="top" >Type</td>
2342 <td valign="top" >Property Values</td>
2343 <td valign="top" >Object attached</td>
2344 <td valign="top" >Description/Restrictions</td>
2345 </tr>
2346 <tr>
2347 <td rowspan="37" valign="top" >DRM</td>
2348 <td valign="top" >Generic</td>
2349 <td valign="top" >“rotation”</td>
2350 <td valign="top" >BITMASK</td>
2351 <td valign="top" >{ 0, "rotate-0" },
2352 { 1, "rotate-90" },
2353 { 2, "rotate-180" },
2354 { 3, "rotate-270" },
2355 { 4, "reflect-x" },
2356 { 5, "reflect-y" }</td>
2357 <td valign="top" >CRTC, Plane</td>
2358 <td valign="top" >rotate-(degrees) rotates the image by the specified amount in degrees
2359 in counter clockwise direction. reflect-x and reflect-y reflects the
2360 image along the specified axis prior to rotation</td>
2361 </tr>
2362 <tr>
2363 <td rowspan="5" valign="top" >Connector</td>
2364 <td valign="top" >“EDID”</td>
2365 <td valign="top" >BLOB | IMMUTABLE</td>
2366 <td valign="top" >0</td>
2367 <td valign="top" >Connector</td>
2368 <td valign="top" >Contains id of edid blob ptr object.</td>
2369 </tr>
2370 <tr>
2371 <td valign="top" >“DPMS”</td>
2372 <td valign="top" >ENUM</td>
2373 <td valign="top" >{ “On”, “Standby”, “Suspend”, “Off” }</td>
2374 <td valign="top" >Connector</td>
2375 <td valign="top" >Contains DPMS operation mode value.</td>
2376 </tr>
2377 <tr>
2378 <td valign="top" >“PATH”</td>
2379 <td valign="top" >BLOB | IMMUTABLE</td>
2380 <td valign="top" >0</td>
2381 <td valign="top" >Connector</td>
2382 <td valign="top" >Contains topology path to a connector.</td>
2383 </tr>
2384 <tr>
2385 <td valign="top" >“TILE”</td>
2386 <td valign="top" >BLOB | IMMUTABLE</td>
2387 <td valign="top" >0</td>
2388 <td valign="top" >Connector</td>
2389 <td valign="top" >Contains tiling information for a connector.</td>
2390 </tr>
2391 <tr>
2392 <td valign="top" >“CRTC_ID”</td>
2393 <td valign="top" >OBJECT</td>
2394 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2395 <td valign="top" >Connector</td>
2396 <td valign="top" >CRTC that connector is attached to (atomic)</td>
2397 </tr>
2398 <tr>
2399 <td rowspan="11" valign="top" >Plane</td>
2400 <td valign="top" >“type”</td>
2401 <td valign="top" >ENUM | IMMUTABLE</td>
2402 <td valign="top" >{ "Overlay", "Primary", "Cursor" }</td>
2403 <td valign="top" >Plane</td>
2404 <td valign="top" >Plane type</td>
2405 </tr>
2406 <tr>
2407 <td valign="top" >“SRC_X”</td>
2408 <td valign="top" >RANGE</td>
2409 <td valign="top" >Min=0, Max=UINT_MAX</td>
2410 <td valign="top" >Plane</td>
2411 <td valign="top" >Scanout source x coordinate in 16.16 fixed point (atomic)</td>
2412 </tr>
2413 <tr>
2414 <td valign="top" >“SRC_Y”</td>
2415 <td valign="top" >RANGE</td>
2416 <td valign="top" >Min=0, Max=UINT_MAX</td>
2417 <td valign="top" >Plane</td>
2418 <td valign="top" >Scanout source y coordinate in 16.16 fixed point (atomic)</td>
2419 </tr>
2420 <tr>
2421 <td valign="top" >“SRC_W”</td>
2422 <td valign="top" >RANGE</td>
2423 <td valign="top" >Min=0, Max=UINT_MAX</td>
2424 <td valign="top" >Plane</td>
2425 <td valign="top" >Scanout source width in 16.16 fixed point (atomic)</td>
2426 </tr>
2427 <tr>
2428 <td valign="top" >“SRC_H”</td>
2429 <td valign="top" >RANGE</td>
2430 <td valign="top" >Min=0, Max=UINT_MAX</td>
2431 <td valign="top" >Plane</td>
2432 <td valign="top" >Scanout source height in 16.16 fixed point (atomic)</td>
2433 </tr>
2434 <tr>
2435 <td valign="top" >“CRTC_X”</td>
2436 <td valign="top" >SIGNED_RANGE</td>
2437 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2438 <td valign="top" >Plane</td>
2439 <td valign="top" >Scanout CRTC (destination) x coordinate (atomic)</td>
2440 </tr>
2441 <tr>
2442 <td valign="top" >“CRTC_Y”</td>
2443 <td valign="top" >SIGNED_RANGE</td>
2444 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2445 <td valign="top" >Plane</td>
2446 <td valign="top" >Scanout CRTC (destination) y coordinate (atomic)</td>
2447 </tr>
2448 <tr>
2449 <td valign="top" >“CRTC_W”</td>
2450 <td valign="top" >RANGE</td>
2451 <td valign="top" >Min=0, Max=UINT_MAX</td>
2452 <td valign="top" >Plane</td>
2453 <td valign="top" >Scanout CRTC (destination) width (atomic)</td>
2454 </tr>
2455 <tr>
2456 <td valign="top" >“CRTC_H”</td>
2457 <td valign="top" >RANGE</td>
2458 <td valign="top" >Min=0, Max=UINT_MAX</td>
2459 <td valign="top" >Plane</td>
2460 <td valign="top" >Scanout CRTC (destination) height (atomic)</td>
2461 </tr>
2462 <tr>
2463 <td valign="top" >“FB_ID”</td>
2464 <td valign="top" >OBJECT</td>
2465 <td valign="top" >DRM_MODE_OBJECT_FB</td>
2466 <td valign="top" >Plane</td>
2467 <td valign="top" >Scanout framebuffer (atomic)</td>
2468 </tr>
2469 <tr>
2470 <td valign="top" >“CRTC_ID”</td>
2471 <td valign="top" >OBJECT</td>
2472 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2473 <td valign="top" >Plane</td>
2474 <td valign="top" >CRTC that plane is attached to (atomic)</td>
2475 </tr>
2476 <tr>
2477 <td rowspan="2" valign="top" >DVI-I</td>
2478 <td valign="top" >“subconnector”</td>
2479 <td valign="top" >ENUM</td>
2480 <td valign="top" >{ “Unknown”, “DVI-D”, “DVI-A” }</td>
2481 <td valign="top" >Connector</td>
2482 <td valign="top" >TBD</td>
2483 </tr>
2484 <tr>
2485 <td valign="top" >“select subconnector”</td>
2486 <td valign="top" >ENUM</td>
2487 <td valign="top" >{ “Automatic”, “DVI-D”, “DVI-A” }</td>
2488 <td valign="top" >Connector</td>
2489 <td valign="top" >TBD</td>
2490 </tr>
2491 <tr>
2492 <td rowspan="13" valign="top" >TV</td>
2493 <td valign="top" >“subconnector”</td>
2494 <td valign="top" >ENUM</td>
2495 <td valign="top" >{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" }</td>
2496 <td valign="top" >Connector</td>
2497 <td valign="top" >TBD</td>
2498 </tr>
2499 <tr>
2500 <td valign="top" >“select subconnector”</td>
2501 <td valign="top" >ENUM</td>
2502 <td valign="top" >{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" }</td>
2503 <td valign="top" >Connector</td>
2504 <td valign="top" >TBD</td>
2505 </tr>
2506 <tr>
2507 <td valign="top" >“mode”</td>
2508 <td valign="top" >ENUM</td>
2509 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2510 <td valign="top" >Connector</td>
2511 <td valign="top" >TBD</td>
2512 </tr>
2513 <tr>
2514 <td valign="top" >“left margin”</td>
2515 <td valign="top" >RANGE</td>
2516 <td valign="top" >Min=0, Max=100</td>
2517 <td valign="top" >Connector</td>
2518 <td valign="top" >TBD</td>
2519 </tr>
2520 <tr>
2521 <td valign="top" >“right margin”</td>
2522 <td valign="top" >RANGE</td>
2523 <td valign="top" >Min=0, Max=100</td>
2524 <td valign="top" >Connector</td>
2525 <td valign="top" >TBD</td>
2526 </tr>
2527 <tr>
2528 <td valign="top" >“top margin”</td>
2529 <td valign="top" >RANGE</td>
2530 <td valign="top" >Min=0, Max=100</td>
2531 <td valign="top" >Connector</td>
2532 <td valign="top" >TBD</td>
2533 </tr>
2534 <tr>
2535 <td valign="top" >“bottom margin”</td>
2536 <td valign="top" >RANGE</td>
2537 <td valign="top" >Min=0, Max=100</td>
2538 <td valign="top" >Connector</td>
2539 <td valign="top" >TBD</td>
2540 </tr>
2541 <tr>
2542 <td valign="top" >“brightness”</td>
2543 <td valign="top" >RANGE</td>
2544 <td valign="top" >Min=0, Max=100</td>
2545 <td valign="top" >Connector</td>
2546 <td valign="top" >TBD</td>
2547 </tr>
2548 <tr>
2549 <td valign="top" >“contrast”</td>
2550 <td valign="top" >RANGE</td>
2551 <td valign="top" >Min=0, Max=100</td>
2552 <td valign="top" >Connector</td>
2553 <td valign="top" >TBD</td>
2554 </tr>
2555 <tr>
2556 <td valign="top" >“flicker reduction”</td>
2557 <td valign="top" >RANGE</td>
2558 <td valign="top" >Min=0, Max=100</td>
2559 <td valign="top" >Connector</td>
2560 <td valign="top" >TBD</td>
2561 </tr>
2562 <tr>
2563 <td valign="top" >“overscan”</td>
2564 <td valign="top" >RANGE</td>
2565 <td valign="top" >Min=0, Max=100</td>
2566 <td valign="top" >Connector</td>
2567 <td valign="top" >TBD</td>
2568 </tr>
2569 <tr>
2570 <td valign="top" >“saturation”</td>
2571 <td valign="top" >RANGE</td>
2572 <td valign="top" >Min=0, Max=100</td>
2573 <td valign="top" >Connector</td>
2574 <td valign="top" >TBD</td>
2575 </tr>
2576 <tr>
2577 <td valign="top" >“hue”</td>
2578 <td valign="top" >RANGE</td>
2579 <td valign="top" >Min=0, Max=100</td>
2580 <td valign="top" >Connector</td>
2581 <td valign="top" >TBD</td>
2582 </tr>
2583 <tr>
2584 <td rowspan="2" valign="top" >Virtual GPU</td>
2585 <td valign="top" >“suggested X”</td>
2586 <td valign="top" >RANGE</td>
2587 <td valign="top" >Min=0, Max=0xffffffff</td>
2588 <td valign="top" >Connector</td>
2589 <td valign="top" >property to suggest an X offset for a connector</td>
2590 </tr>
2591 <tr>
2592 <td valign="top" >“suggested Y”</td>
2593 <td valign="top" >RANGE</td>
2594 <td valign="top" >Min=0, Max=0xffffffff</td>
2595 <td valign="top" >Connector</td>
2596 <td valign="top" >property to suggest an Y offset for a connector</td>
2597 </tr>
2598 <tr>
2599 <td rowspan="3" valign="top" >Optional</td>
2600 <td valign="top" >“scaling mode”</td>
2601 <td valign="top" >ENUM</td>
2602 <td valign="top" >{ "None", "Full", "Center", "Full aspect" }</td>
2603 <td valign="top" >Connector</td>
2604 <td valign="top" >TBD</td>
2605 </tr>
2606 <tr>
2607 <td valign="top" >"aspect ratio"</td>
2608 <td valign="top" >ENUM</td>
2609 <td valign="top" >{ "None", "4:3", "16:9" }</td>
2610 <td valign="top" >Connector</td>
2611 <td valign="top" >DRM property to set aspect ratio from user space app.
2612 This enum is made generic to allow addition of custom aspect
2613 ratios.</td>
2614 </tr>
2615 <tr>
2616 <td valign="top" >“dirty”</td>
2617 <td valign="top" >ENUM | IMMUTABLE</td>
2618 <td valign="top" >{ "Off", "On", "Annotate" }</td>
2619 <td valign="top" >Connector</td>
2620 <td valign="top" >TBD</td>
2621 </tr>
2622 <tr>
2623 <td rowspan="20" valign="top" >i915</td>
2624 <td rowspan="2" valign="top" >Generic</td>
2625 <td valign="top" >"Broadcast RGB"</td>
2626 <td valign="top" >ENUM</td>
2627 <td valign="top" >{ "Automatic", "Full", "Limited 16:235" }</td>
2628 <td valign="top" >Connector</td>
2629 <td valign="top" >TBD</td>
2630 </tr>
2631 <tr>
2632 <td valign="top" >“audio”</td>
2633 <td valign="top" >ENUM</td>
2634 <td valign="top" >{ "force-dvi", "off", "auto", "on" }</td>
2635 <td valign="top" >Connector</td>
2636 <td valign="top" >TBD</td>
2637 </tr>
2638 <tr>
2639 <td rowspan="17" valign="top" >SDVO-TV</td>
2640 <td valign="top" >“mode”</td>
2641 <td valign="top" >ENUM</td>
2642 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2643 <td valign="top" >Connector</td>
2644 <td valign="top" >TBD</td>
2645 </tr>
2646 <tr>
2647 <td valign="top" >"left_margin"</td>
2648 <td valign="top" >RANGE</td>
2649 <td valign="top" >Min=0, Max= SDVO dependent</td>
2650 <td valign="top" >Connector</td>
2651 <td valign="top" >TBD</td>
2652 </tr>
2653 <tr>
2654 <td valign="top" >"right_margin"</td>
2655 <td valign="top" >RANGE</td>
2656 <td valign="top" >Min=0, Max= SDVO dependent</td>
2657 <td valign="top" >Connector</td>
2658 <td valign="top" >TBD</td>
2659 </tr>
2660 <tr>
2661 <td valign="top" >"top_margin"</td>
2662 <td valign="top" >RANGE</td>
2663 <td valign="top" >Min=0, Max= SDVO dependent</td>
2664 <td valign="top" >Connector</td>
2665 <td valign="top" >TBD</td>
2666 </tr>
2667 <tr>
2668 <td valign="top" >"bottom_margin"</td>
2669 <td valign="top" >RANGE</td>
2670 <td valign="top" >Min=0, Max= SDVO dependent</td>
2671 <td valign="top" >Connector</td>
2672 <td valign="top" >TBD</td>
2673 </tr>
2674 <tr>
2675 <td valign="top" >“hpos”</td>
2676 <td valign="top" >RANGE</td>
2677 <td valign="top" >Min=0, Max= SDVO dependent</td>
2678 <td valign="top" >Connector</td>
2679 <td valign="top" >TBD</td>
2680 </tr>
2681 <tr>
2682 <td valign="top" >“vpos”</td>
2683 <td valign="top" >RANGE</td>
2684 <td valign="top" >Min=0, Max= SDVO dependent</td>
2685 <td valign="top" >Connector</td>
2686 <td valign="top" >TBD</td>
2687 </tr>
2688 <tr>
2689 <td valign="top" >“contrast”</td>
2690 <td valign="top" >RANGE</td>
2691 <td valign="top" >Min=0, Max= SDVO dependent</td>
2692 <td valign="top" >Connector</td>
2693 <td valign="top" >TBD</td>
2694 </tr>
2695 <tr>
2696 <td valign="top" >“saturation”</td>
2697 <td valign="top" >RANGE</td>
2698 <td valign="top" >Min=0, Max= SDVO dependent</td>
2699 <td valign="top" >Connector</td>
2700 <td valign="top" >TBD</td>
2701 </tr>
2702 <tr>
2703 <td valign="top" >“hue”</td>
2704 <td valign="top" >RANGE</td>
2705 <td valign="top" >Min=0, Max= SDVO dependent</td>
2706 <td valign="top" >Connector</td>
2707 <td valign="top" >TBD</td>
2708 </tr>
2709 <tr>
2710 <td valign="top" >“sharpness”</td>
2711 <td valign="top" >RANGE</td>
2712 <td valign="top" >Min=0, Max= SDVO dependent</td>
2713 <td valign="top" >Connector</td>
2714 <td valign="top" >TBD</td>
2715 </tr>
2716 <tr>
2717 <td valign="top" >“flicker_filter”</td>
2718 <td valign="top" >RANGE</td>
2719 <td valign="top" >Min=0, Max= SDVO dependent</td>
2720 <td valign="top" >Connector</td>
2721 <td valign="top" >TBD</td>
2722 </tr>
2723 <tr>
2724 <td valign="top" >“flicker_filter_adaptive”</td>
2725 <td valign="top" >RANGE</td>
2726 <td valign="top" >Min=0, Max= SDVO dependent</td>
2727 <td valign="top" >Connector</td>
2728 <td valign="top" >TBD</td>
2729 </tr>
2730 <tr>
2731 <td valign="top" >“flicker_filter_2d”</td>
2732 <td valign="top" >RANGE</td>
2733 <td valign="top" >Min=0, Max= SDVO dependent</td>
2734 <td valign="top" >Connector</td>
2735 <td valign="top" >TBD</td>
2736 </tr>
2737 <tr>
2738 <td valign="top" >“tv_chroma_filter”</td>
2739 <td valign="top" >RANGE</td>
2740 <td valign="top" >Min=0, Max= SDVO dependent</td>
2741 <td valign="top" >Connector</td>
2742 <td valign="top" >TBD</td>
2743 </tr>
2744 <tr>
2745 <td valign="top" >“tv_luma_filter”</td>
2746 <td valign="top" >RANGE</td>
2747 <td valign="top" >Min=0, Max= SDVO dependent</td>
2748 <td valign="top" >Connector</td>
2749 <td valign="top" >TBD</td>
2750 </tr>
2751 <tr>
2752 <td valign="top" >“dot_crawl”</td>
2753 <td valign="top" >RANGE</td>
2754 <td valign="top" >Min=0, Max=1</td>
2755 <td valign="top" >Connector</td>
2756 <td valign="top" >TBD</td>
2757 </tr>
2758 <tr>
2759 <td valign="top" >SDVO-TV/LVDS</td>
2760 <td valign="top" >“brightness”</td>
2761 <td valign="top" >RANGE</td>
2762 <td valign="top" >Min=0, Max= SDVO dependent</td>
2763 <td valign="top" >Connector</td>
2764 <td valign="top" >TBD</td>
2765 </tr>
2766 <tr>
2767 <td rowspan="2" valign="top" >CDV gma-500</td>
2768 <td rowspan="2" valign="top" >Generic</td>
2769 <td valign="top" >"Broadcast RGB"</td>
2770 <td valign="top" >ENUM</td>
2771 <td valign="top" >{ “Full”, “Limited 16:235” }</td>
2772 <td valign="top" >Connector</td>
2773 <td valign="top" >TBD</td>
2774 </tr>
2775 <tr>
2776 <td valign="top" >"Broadcast RGB"</td>
2777 <td valign="top" >ENUM</td>
2778 <td valign="top" >{ “off”, “auto”, “on” }</td>
2779 <td valign="top" >Connector</td>
2780 <td valign="top" >TBD</td>
2781 </tr>
2782 <tr>
2783 <td rowspan="19" valign="top" >Poulsbo</td>
2784 <td rowspan="1" valign="top" >Generic</td>
2785 <td valign="top" >“backlight”</td>
2786 <td valign="top" >RANGE</td>
2787 <td valign="top" >Min=0, Max=100</td>
2788 <td valign="top" >Connector</td>
2789 <td valign="top" >TBD</td>
2790 </tr>
2791 <tr>
2792 <td rowspan="17" valign="top" >SDVO-TV</td>
2793 <td valign="top" >“mode”</td>
2794 <td valign="top" >ENUM</td>
2795 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2796 <td valign="top" >Connector</td>
2797 <td valign="top" >TBD</td>
2798 </tr>
2799 <tr>
2800 <td valign="top" >"left_margin"</td>
2801 <td valign="top" >RANGE</td>
2802 <td valign="top" >Min=0, Max= SDVO dependent</td>
2803 <td valign="top" >Connector</td>
2804 <td valign="top" >TBD</td>
2805 </tr>
2806 <tr>
2807 <td valign="top" >"right_margin"</td>
2808 <td valign="top" >RANGE</td>
2809 <td valign="top" >Min=0, Max= SDVO dependent</td>
2810 <td valign="top" >Connector</td>
2811 <td valign="top" >TBD</td>
2812 </tr>
2813 <tr>
2814 <td valign="top" >"top_margin"</td>
2815 <td valign="top" >RANGE</td>
2816 <td valign="top" >Min=0, Max= SDVO dependent</td>
2817 <td valign="top" >Connector</td>
2818 <td valign="top" >TBD</td>
2819 </tr>
2820 <tr>
2821 <td valign="top" >"bottom_margin"</td>
2822 <td valign="top" >RANGE</td>
2823 <td valign="top" >Min=0, Max= SDVO dependent</td>
2824 <td valign="top" >Connector</td>
2825 <td valign="top" >TBD</td>
2826 </tr>
2827 <tr>
2828 <td valign="top" >“hpos”</td>
2829 <td valign="top" >RANGE</td>
2830 <td valign="top" >Min=0, Max= SDVO dependent</td>
2831 <td valign="top" >Connector</td>
2832 <td valign="top" >TBD</td>
2833 </tr>
2834 <tr>
2835 <td valign="top" >“vpos”</td>
2836 <td valign="top" >RANGE</td>
2837 <td valign="top" >Min=0, Max= SDVO dependent</td>
2838 <td valign="top" >Connector</td>
2839 <td valign="top" >TBD</td>
2840 </tr>
2841 <tr>
2842 <td valign="top" >“contrast”</td>
2843 <td valign="top" >RANGE</td>
2844 <td valign="top" >Min=0, Max= SDVO dependent</td>
2845 <td valign="top" >Connector</td>
2846 <td valign="top" >TBD</td>
2847 </tr>
2848 <tr>
2849 <td valign="top" >“saturation”</td>
2850 <td valign="top" >RANGE</td>
2851 <td valign="top" >Min=0, Max= SDVO dependent</td>
2852 <td valign="top" >Connector</td>
2853 <td valign="top" >TBD</td>
2854 </tr>
2855 <tr>
2856 <td valign="top" >“hue”</td>
2857 <td valign="top" >RANGE</td>
2858 <td valign="top" >Min=0, Max= SDVO dependent</td>
2859 <td valign="top" >Connector</td>
2860 <td valign="top" >TBD</td>
2861 </tr>
2862 <tr>
2863 <td valign="top" >“sharpness”</td>
2864 <td valign="top" >RANGE</td>
2865 <td valign="top" >Min=0, Max= SDVO dependent</td>
2866 <td valign="top" >Connector</td>
2867 <td valign="top" >TBD</td>
2868 </tr>
2869 <tr>
2870 <td valign="top" >“flicker_filter”</td>
2871 <td valign="top" >RANGE</td>
2872 <td valign="top" >Min=0, Max= SDVO dependent</td>
2873 <td valign="top" >Connector</td>
2874 <td valign="top" >TBD</td>
2875 </tr>
2876 <tr>
2877 <td valign="top" >“flicker_filter_adaptive”</td>
2878 <td valign="top" >RANGE</td>
2879 <td valign="top" >Min=0, Max= SDVO dependent</td>
2880 <td valign="top" >Connector</td>
2881 <td valign="top" >TBD</td>
2882 </tr>
2883 <tr>
2884 <td valign="top" >“flicker_filter_2d”</td>
2885 <td valign="top" >RANGE</td>
2886 <td valign="top" >Min=0, Max= SDVO dependent</td>
2887 <td valign="top" >Connector</td>
2888 <td valign="top" >TBD</td>
2889 </tr>
2890 <tr>
2891 <td valign="top" >“tv_chroma_filter”</td>
2892 <td valign="top" >RANGE</td>
2893 <td valign="top" >Min=0, Max= SDVO dependent</td>
2894 <td valign="top" >Connector</td>
2895 <td valign="top" >TBD</td>
2896 </tr>
2897 <tr>
2898 <td valign="top" >“tv_luma_filter”</td>
2899 <td valign="top" >RANGE</td>
2900 <td valign="top" >Min=0, Max= SDVO dependent</td>
2901 <td valign="top" >Connector</td>
2902 <td valign="top" >TBD</td>
2903 </tr>
2904 <tr>
2905 <td valign="top" >“dot_crawl”</td>
2906 <td valign="top" >RANGE</td>
2907 <td valign="top" >Min=0, Max=1</td>
2908 <td valign="top" >Connector</td>
2909 <td valign="top" >TBD</td>
2910 </tr>
2911 <tr>
2912 <td valign="top" >SDVO-TV/LVDS</td>
2913 <td valign="top" >“brightness”</td>
2914 <td valign="top" >RANGE</td>
2915 <td valign="top" >Min=0, Max= SDVO dependent</td>
2916 <td valign="top" >Connector</td>
2917 <td valign="top" >TBD</td>
2918 </tr>
2919 <tr>
2920 <td rowspan="11" valign="top" >armada</td>
2921 <td rowspan="2" valign="top" >CRTC</td>
2922 <td valign="top" >"CSC_YUV"</td>
2923 <td valign="top" >ENUM</td>
2924 <td valign="top" >{ "Auto" , "CCIR601", "CCIR709" }</td>
2925 <td valign="top" >CRTC</td>
2926 <td valign="top" >TBD</td>
2927 </tr>
2928 <tr>
2929 <td valign="top" >"CSC_RGB"</td>
2930 <td valign="top" >ENUM</td>
2931 <td valign="top" >{ "Auto", "Computer system", "Studio" }</td>
2932 <td valign="top" >CRTC</td>
2933 <td valign="top" >TBD</td>
2934 </tr>
2935 <tr>
2936 <td rowspan="9" valign="top" >Overlay</td>
2937 <td valign="top" >"colorkey"</td>
2938 <td valign="top" >RANGE</td>
2939 <td valign="top" >Min=0, Max=0xffffff</td>
2940 <td valign="top" >Plane</td>
2941 <td valign="top" >TBD</td>
2942 </tr>
2943 <tr>
2944 <td valign="top" >"colorkey_min"</td>
2945 <td valign="top" >RANGE</td>
2946 <td valign="top" >Min=0, Max=0xffffff</td>
2947 <td valign="top" >Plane</td>
2948 <td valign="top" >TBD</td>
2949 </tr>
2950 <tr>
2951 <td valign="top" >"colorkey_max"</td>
2952 <td valign="top" >RANGE</td>
2953 <td valign="top" >Min=0, Max=0xffffff</td>
2954 <td valign="top" >Plane</td>
2955 <td valign="top" >TBD</td>
2956 </tr>
2957 <tr>
2958 <td valign="top" >"colorkey_val"</td>
2959 <td valign="top" >RANGE</td>
2960 <td valign="top" >Min=0, Max=0xffffff</td>
2961 <td valign="top" >Plane</td>
2962 <td valign="top" >TBD</td>
2963 </tr>
2964 <tr>
2965 <td valign="top" >"colorkey_alpha"</td>
2966 <td valign="top" >RANGE</td>
2967 <td valign="top" >Min=0, Max=0xffffff</td>
2968 <td valign="top" >Plane</td>
2969 <td valign="top" >TBD</td>
2970 </tr>
2971 <tr>
2972 <td valign="top" >"colorkey_mode"</td>
2973 <td valign="top" >ENUM</td>
2974 <td valign="top" >{ "disabled", "Y component", "U component"
2975 , "V component", "RGB", “R component", "G component", "B component" }</td>
2976 <td valign="top" >Plane</td>
2977 <td valign="top" >TBD</td>
2978 </tr>
2979 <tr>
2980 <td valign="top" >"brightness"</td>
2981 <td valign="top" >RANGE</td>
2982 <td valign="top" >Min=0, Max=256 + 255</td>
2983 <td valign="top" >Plane</td>
2984 <td valign="top" >TBD</td>
2985 </tr>
2986 <tr>
2987 <td valign="top" >"contrast"</td>
2988 <td valign="top" >RANGE</td>
2989 <td valign="top" >Min=0, Max=0x7fff</td>
2990 <td valign="top" >Plane</td>
2991 <td valign="top" >TBD</td>
2992 </tr>
2993 <tr>
2994 <td valign="top" >"saturation"</td>
2995 <td valign="top" >RANGE</td>
2996 <td valign="top" >Min=0, Max=0x7fff</td>
2997 <td valign="top" >Plane</td>
2998 <td valign="top" >TBD</td>
2999 </tr>
3000 <tr>
3001 <td rowspan="2" valign="top" >exynos</td>
3002 <td valign="top" >CRTC</td>
3003 <td valign="top" >“mode”</td>
3004 <td valign="top" >ENUM</td>
3005 <td valign="top" >{ "normal", "blank" }</td>
3006 <td valign="top" >CRTC</td>
3007 <td valign="top" >TBD</td>
3008 </tr>
3009 <tr>
3010 <td valign="top" >Overlay</td>
3011 <td valign="top" >“zpos”</td>
3012 <td valign="top" >RANGE</td>
3013 <td valign="top" >Min=0, Max=MAX_PLANE-1</td>
3014 <td valign="top" >Plane</td>
3015 <td valign="top" >TBD</td>
3016 </tr>
3017 <tr>
3018 <td rowspan="2" valign="top" >i2c/ch7006_drv</td>
3019 <td valign="top" >Generic</td>
3020 <td valign="top" >“scale”</td>
3021 <td valign="top" >RANGE</td>
3022 <td valign="top" >Min=0, Max=2</td>
3023 <td valign="top" >Connector</td>
3024 <td valign="top" >TBD</td>
3025 </tr>
3026 <tr>
3027 <td rowspan="1" valign="top" >TV</td>
3028 <td valign="top" >“mode”</td>
3029 <td valign="top" >ENUM</td>
3030 <td valign="top" >{ "PAL", "PAL-M","PAL-N"}, ”PAL-Nc"
3031 , "PAL-60", "NTSC-M", "NTSC-J" }</td>
3032 <td valign="top" >Connector</td>
3033 <td valign="top" >TBD</td>
3034 </tr>
3035 <tr>
3036 <td rowspan="15" valign="top" >nouveau</td>
3037 <td rowspan="6" valign="top" >NV10 Overlay</td>
3038 <td valign="top" >"colorkey"</td>
3039 <td valign="top" >RANGE</td>
3040 <td valign="top" >Min=0, Max=0x01ffffff</td>
3041 <td valign="top" >Plane</td>
3042 <td valign="top" >TBD</td>
3043 </tr>
3044 <tr>
3045 <td valign="top" >“contrast”</td>
3046 <td valign="top" >RANGE</td>
3047 <td valign="top" >Min=0, Max=8192-1</td>
3048 <td valign="top" >Plane</td>
3049 <td valign="top" >TBD</td>
3050 </tr>
3051 <tr>
3052 <td valign="top" >“brightness”</td>
3053 <td valign="top" >RANGE</td>
3054 <td valign="top" >Min=0, Max=1024</td>
3055 <td valign="top" >Plane</td>
3056 <td valign="top" >TBD</td>
3057 </tr>
3058 <tr>
3059 <td valign="top" >“hue”</td>
3060 <td valign="top" >RANGE</td>
3061 <td valign="top" >Min=0, Max=359</td>
3062 <td valign="top" >Plane</td>
3063 <td valign="top" >TBD</td>
3064 </tr>
3065 <tr>
3066 <td valign="top" >“saturation”</td>
3067 <td valign="top" >RANGE</td>
3068 <td valign="top" >Min=0, Max=8192-1</td>
3069 <td valign="top" >Plane</td>
3070 <td valign="top" >TBD</td>
3071 </tr>
3072 <tr>
3073 <td valign="top" >“iturbt_709”</td>
3074 <td valign="top" >RANGE</td>
3075 <td valign="top" >Min=0, Max=1</td>
3076 <td valign="top" >Plane</td>
3077 <td valign="top" >TBD</td>
3078 </tr>
3079 <tr>
3080 <td rowspan="2" valign="top" >Nv04 Overlay</td>
3081 <td valign="top" >“colorkey”</td>
3082 <td valign="top" >RANGE</td>
3083 <td valign="top" >Min=0, Max=0x01ffffff</td>
3084 <td valign="top" >Plane</td>
3085 <td valign="top" >TBD</td>
3086 </tr>
3087 <tr>
3088 <td valign="top" >“brightness”</td>
3089 <td valign="top" >RANGE</td>
3090 <td valign="top" >Min=0, Max=1024</td>
3091 <td valign="top" >Plane</td>
3092 <td valign="top" >TBD</td>
3093 </tr>
3094 <tr>
3095 <td rowspan="7" valign="top" >Display</td>
3096 <td valign="top" >“dithering mode”</td>
3097 <td valign="top" >ENUM</td>
3098 <td valign="top" >{ "auto", "off", "on" }</td>
3099 <td valign="top" >Connector</td>
3100 <td valign="top" >TBD</td>
3101 </tr>
3102 <tr>
3103 <td valign="top" >“dithering depth”</td>
3104 <td valign="top" >ENUM</td>
3105 <td valign="top" >{ "auto", "off", "on", "static 2x2", "dynamic 2x2", "temporal" }</td>
3106 <td valign="top" >Connector</td>
3107 <td valign="top" >TBD</td>
3108 </tr>
3109 <tr>
3110 <td valign="top" >“underscan”</td>
3111 <td valign="top" >ENUM</td>
3112 <td valign="top" >{ "auto", "6 bpc", "8 bpc" }</td>
3113 <td valign="top" >Connector</td>
3114 <td valign="top" >TBD</td>
3115 </tr>
3116 <tr>
3117 <td valign="top" >“underscan hborder”</td>
3118 <td valign="top" >RANGE</td>
3119 <td valign="top" >Min=0, Max=128</td>
3120 <td valign="top" >Connector</td>
3121 <td valign="top" >TBD</td>
3122 </tr>
3123 <tr>
3124 <td valign="top" >“underscan vborder”</td>
3125 <td valign="top" >RANGE</td>
3126 <td valign="top" >Min=0, Max=128</td>
3127 <td valign="top" >Connector</td>
3128 <td valign="top" >TBD</td>
3129 </tr>
3130 <tr>
3131 <td valign="top" >“vibrant hue”</td>
3132 <td valign="top" >RANGE</td>
3133 <td valign="top" >Min=0, Max=180</td>
3134 <td valign="top" >Connector</td>
3135 <td valign="top" >TBD</td>
3136 </tr>
3137 <tr>
3138 <td valign="top" >“color vibrance”</td>
3139 <td valign="top" >RANGE</td>
3140 <td valign="top" >Min=0, Max=200</td>
3141 <td valign="top" >Connector</td>
3142 <td valign="top" >TBD</td>
3143 </tr>
3144 <tr>
3145 <td valign="top" >omap</td>
3146 <td valign="top" >Generic</td>
3147 <td valign="top" >“zorder”</td>
3148 <td valign="top" >RANGE</td>
3149 <td valign="top" >Min=0, Max=3</td>
3150 <td valign="top" >CRTC, Plane</td>
3151 <td valign="top" >TBD</td>
3152 </tr>
3153 <tr>
3154 <td valign="top" >qxl</td>
3155 <td valign="top" >Generic</td>
3156 <td valign="top" >“hotplug_mode_update"</td>
3157 <td valign="top" >RANGE</td>
3158 <td valign="top" >Min=0, Max=1</td>
3159 <td valign="top" >Connector</td>
3160 <td valign="top" >TBD</td>
3161 </tr>
3162 <tr>
3163 <td rowspan="9" valign="top" >radeon</td>
3164 <td valign="top" >DVI-I</td>
3165 <td valign="top" >“coherent”</td>
3166 <td valign="top" >RANGE</td>
3167 <td valign="top" >Min=0, Max=1</td>
3168 <td valign="top" >Connector</td>
3169 <td valign="top" >TBD</td>
3170 </tr>
3171 <tr>
3172 <td valign="top" >DAC enable load detect</td>
3173 <td valign="top" >“load detection”</td>
3174 <td valign="top" >RANGE</td>
3175 <td valign="top" >Min=0, Max=1</td>
3176 <td valign="top" >Connector</td>
3177 <td valign="top" >TBD</td>
3178 </tr>
3179 <tr>
3180 <td valign="top" >TV Standard</td>
3181 <td valign="top" >"tv standard"</td>
3182 <td valign="top" >ENUM</td>
3183 <td valign="top" >{ "ntsc", "pal", "pal-m", "pal-60", "ntsc-j"
3184 , "scart-pal", "pal-cn", "secam" }</td>
3185 <td valign="top" >Connector</td>
3186 <td valign="top" >TBD</td>
3187 </tr>
3188 <tr>
3189 <td valign="top" >legacy TMDS PLL detect</td>
3190 <td valign="top" >"tmds_pll"</td>
3191 <td valign="top" >ENUM</td>
3192 <td valign="top" >{ "driver", "bios" }</td>
3193 <td valign="top" >-</td>
3194 <td valign="top" >TBD</td>
3195 </tr>
3196 <tr>
3197 <td rowspan="3" valign="top" >Underscan</td>
3198 <td valign="top" >"underscan"</td>
3199 <td valign="top" >ENUM</td>
3200 <td valign="top" >{ "off", "on", "auto" }</td>
3201 <td valign="top" >Connector</td>
3202 <td valign="top" >TBD</td>
3203 </tr>
3204 <tr>
3205 <td valign="top" >"underscan hborder"</td>
3206 <td valign="top" >RANGE</td>
3207 <td valign="top" >Min=0, Max=128</td>
3208 <td valign="top" >Connector</td>
3209 <td valign="top" >TBD</td>
3210 </tr>
3211 <tr>
3212 <td valign="top" >"underscan vborder"</td>
3213 <td valign="top" >RANGE</td>
3214 <td valign="top" >Min=0, Max=128</td>
3215 <td valign="top" >Connector</td>
3216 <td valign="top" >TBD</td>
3217 </tr>
3218 <tr>
3219 <td valign="top" >Audio</td>
3220 <td valign="top" >“audio”</td>
3221 <td valign="top" >ENUM</td>
3222 <td valign="top" >{ "off", "on", "auto" }</td>
3223 <td valign="top" >Connector</td>
3224 <td valign="top" >TBD</td>
3225 </tr>
3226 <tr>
3227 <td valign="top" >FMT Dithering</td>
3228 <td valign="top" >“dither”</td>
3229 <td valign="top" >ENUM</td>
3230 <td valign="top" >{ "off", "on" }</td>
3231 <td valign="top" >Connector</td>
3232 <td valign="top" >TBD</td>
3233 </tr>
3234 <tr>
3235 <td rowspan="3" valign="top" >rcar-du</td>
3236 <td rowspan="3" valign="top" >Generic</td>
3237 <td valign="top" >"alpha"</td>
3238 <td valign="top" >RANGE</td>
3239 <td valign="top" >Min=0, Max=255</td>
3240 <td valign="top" >Plane</td>
3241 <td valign="top" >TBD</td>
3242 </tr>
3243 <tr>
3244 <td valign="top" >"colorkey"</td>
3245 <td valign="top" >RANGE</td>
3246 <td valign="top" >Min=0, Max=0x01ffffff</td>
3247 <td valign="top" >Plane</td>
3248 <td valign="top" >TBD</td>
3249 </tr>
3250 <tr>
3251 <td valign="top" >"zpos"</td>
3252 <td valign="top" >RANGE</td>
3253 <td valign="top" >Min=1, Max=7</td>
3254 <td valign="top" >Plane</td>
3255 <td valign="top" >TBD</td>
3256 </tr>
3257 </tbody>
3258 </table>
3259 </sect2>
3260 </sect1>
3261
3262 <!-- Internals: vertical blanking -->
3263
3264 <sect1 id="drm-vertical-blank">
3265 <title>Vertical Blanking</title>
3266 <para>
3267 Vertical blanking plays a major role in graphics rendering. To achieve
3268 tear-free display, users must synchronize page flips and/or rendering to
3269 vertical blanking. The DRM API offers ioctls to perform page flips
3270 synchronized to vertical blanking and wait for vertical blanking.
3271 </para>
3272 <para>
3273 The DRM core handles most of the vertical blanking management logic, which
3274 involves filtering out spurious interrupts, keeping race-free blanking
3275 counters, coping with counter wrap-around and resets and keeping use
3276 counts. It relies on the driver to generate vertical blanking interrupts
3277 and optionally provide a hardware vertical blanking counter. Drivers must
3278 implement the following operations.
3279 </para>
3280 <itemizedlist>
3281 <listitem>
3282 <synopsis>int (*enable_vblank) (struct drm_device *dev, int crtc);
3283 void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
3284 <para>
3285 Enable or disable vertical blanking interrupts for the given CRTC.
3286 </para>
3287 </listitem>
3288 <listitem>
3289 <synopsis>u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);</synopsis>
3290 <para>
3291 Retrieve the value of the vertical blanking counter for the given
3292 CRTC. If the hardware maintains a vertical blanking counter its value
3293 should be returned. Otherwise drivers can use the
3294 <function>drm_vblank_count</function> helper function to handle this
3295 operation.
3296 </para>
3297 </listitem>
3298 </itemizedlist>
3299 <para>
3300 Drivers must initialize the vertical blanking handling core with a call to
3301 <function>drm_vblank_init</function> in their
3302 <methodname>load</methodname> operation. The function will set the struct
3303 <structname>drm_device</structname>
3304 <structfield>vblank_disable_allowed</structfield> field to 0. This will
3305 keep vertical blanking interrupts enabled permanently until the first mode
3306 set operation, where <structfield>vblank_disable_allowed</structfield> is
3307 set to 1. The reason behind this is not clear. Drivers can set the field
3308 to 1 after <function>calling drm_vblank_init</function> to make vertical
3309 blanking interrupts dynamically managed from the beginning.
3310 </para>
3311 <para>
3312 Vertical blanking interrupts can be enabled by the DRM core or by drivers
3313 themselves (for instance to handle page flipping operations). The DRM core
3314 maintains a vertical blanking use count to ensure that the interrupts are
3315 not disabled while a user still needs them. To increment the use count,
3316 drivers call <function>drm_vblank_get</function>. Upon return vertical
3317 blanking interrupts are guaranteed to be enabled.
3318 </para>
3319 <para>
3320 To decrement the use count drivers call
3321 <function>drm_vblank_put</function>. Only when the use count drops to zero
3322 will the DRM core disable the vertical blanking interrupts after a delay
3323 by scheduling a timer. The delay is accessible through the vblankoffdelay
3324 module parameter or the <varname>drm_vblank_offdelay</varname> global
3325 variable and expressed in milliseconds. Its default value is 5000 ms.
3326 Zero means never disable, and a negative value means disable immediately.
3327 Drivers may override the behaviour by setting the
3328 <structname>drm_device</structname>
3329 <structfield>vblank_disable_immediate</structfield> flag, which when set
3330 causes vblank interrupts to be disabled immediately regardless of the
3331 drm_vblank_offdelay value. The flag should only be set if there's a
3332 properly working hardware vblank counter present.
3333 </para>
3334 <para>
3335 When a vertical blanking interrupt occurs drivers only need to call the
3336 <function>drm_handle_vblank</function> function to account for the
3337 interrupt.
3338 </para>
3339 <para>
3340 Resources allocated by <function>drm_vblank_init</function> must be freed
3341 with a call to <function>drm_vblank_cleanup</function> in the driver
3342 <methodname>unload</methodname> operation handler.
3343 </para>
3344 <sect2>
3345 <title>Vertical Blanking and Interrupt Handling Functions Reference</title>
3346 !Edrivers/gpu/drm/drm_irq.c
3347 !Finclude/drm/drmP.h drm_crtc_vblank_waitqueue
3348 </sect2>
3349 </sect1>
3350
3351 <!-- Internals: open/close, file operations and ioctls -->
3352
3353 <sect1>
3354 <title>Open/Close, File Operations and IOCTLs</title>
3355 <sect2>
3356 <title>Open and Close</title>
3357 <synopsis>int (*firstopen) (struct drm_device *);
3358 void (*lastclose) (struct drm_device *);
3359 int (*open) (struct drm_device *, struct drm_file *);
3360 void (*preclose) (struct drm_device *, struct drm_file *);
3361 void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
3362 <abstract>Open and close handlers. None of those methods are mandatory.
3363 </abstract>
3364 <para>
3365 The <methodname>firstopen</methodname> method is called by the DRM core
3366 for legacy UMS (User Mode Setting) drivers only when an application
3367 opens a device that has no other opened file handle. UMS drivers can
3368 implement it to acquire device resources. KMS drivers can't use the
3369 method and must acquire resources in the <methodname>load</methodname>
3370 method instead.
3371 </para>
3372 <para>
3373 Similarly the <methodname>lastclose</methodname> method is called when
3374 the last application holding a file handle opened on the device closes
3375 it, for both UMS and KMS drivers. Additionally, the method is also
3376 called at module unload time or, for hot-pluggable devices, when the
3377 device is unplugged. The <methodname>firstopen</methodname> and
3378 <methodname>lastclose</methodname> calls can thus be unbalanced.
3379 </para>
3380 <para>
3381 The <methodname>open</methodname> method is called every time the device
3382 is opened by an application. Drivers can allocate per-file private data
3383 in this method and store them in the struct
3384 <structname>drm_file</structname> <structfield>driver_priv</structfield>
3385 field. Note that the <methodname>open</methodname> method is called
3386 before <methodname>firstopen</methodname>.
3387 </para>
3388 <para>
3389 The close operation is split into <methodname>preclose</methodname> and
3390 <methodname>postclose</methodname> methods. Drivers must stop and
3391 cleanup all per-file operations in the <methodname>preclose</methodname>
3392 method. For instance pending vertical blanking and page flip events must
3393 be cancelled. No per-file operation is allowed on the file handle after
3394 returning from the <methodname>preclose</methodname> method.
3395 </para>
3396 <para>
3397 Finally the <methodname>postclose</methodname> method is called as the
3398 last step of the close operation, right before calling the
3399 <methodname>lastclose</methodname> method if no other open file handle
3400 exists for the device. Drivers that have allocated per-file private data
3401 in the <methodname>open</methodname> method should free it here.
3402 </para>
3403 <para>
3404 The <methodname>lastclose</methodname> method should restore CRTC and
3405 plane properties to default value, so that a subsequent open of the
3406 device will not inherit state from the previous user. It can also be
3407 used to execute delayed power switching state changes, e.g. in
3408 conjunction with the vga_switcheroo infrastructure (see
3409 <xref linkend="vga_switcheroo"/>). Beyond that KMS drivers should not
3410 do any further cleanup. Only legacy UMS drivers might need to clean up
3411 device state so that the vga console or an independent fbdev driver
3412 could take over.
3413 </para>
3414 </sect2>
3415 <sect2>
3416 <title>File Operations</title>
3417 <synopsis>const struct file_operations *fops</synopsis>
3418 <abstract>File operations for the DRM device node.</abstract>
3419 <para>
3420 Drivers must define the file operations structure that forms the DRM
3421 userspace API entry point, even though most of those operations are
3422 implemented in the DRM core. The <methodname>open</methodname>,
3423 <methodname>release</methodname> and <methodname>ioctl</methodname>
3424 operations are handled by
3425 <programlisting>
3426 .owner = THIS_MODULE,
3427 .open = drm_open,
3428 .release = drm_release,
3429 .unlocked_ioctl = drm_ioctl,
3430 #ifdef CONFIG_COMPAT
3431 .compat_ioctl = drm_compat_ioctl,
3432 #endif
3433 </programlisting>
3434 </para>
3435 <para>
3436 Drivers that implement private ioctls that requires 32/64bit
3437 compatibility support must provide their own
3438 <methodname>compat_ioctl</methodname> handler that processes private
3439 ioctls and calls <function>drm_compat_ioctl</function> for core ioctls.
3440 </para>
3441 <para>
3442 The <methodname>read</methodname> and <methodname>poll</methodname>
3443 operations provide support for reading DRM events and polling them. They
3444 are implemented by
3445 <programlisting>
3446 .poll = drm_poll,
3447 .read = drm_read,
3448 .llseek = no_llseek,
3449 </programlisting>
3450 </para>
3451 <para>
3452 The memory mapping implementation varies depending on how the driver
3453 manages memory. Pre-GEM drivers will use <function>drm_mmap</function>,
3454 while GEM-aware drivers will use <function>drm_gem_mmap</function>. See
3455 <xref linkend="drm-gem"/>.
3456 <programlisting>
3457 .mmap = drm_gem_mmap,
3458 </programlisting>
3459 </para>
3460 <para>
3461 No other file operation is supported by the DRM API.
3462 </para>
3463 </sect2>
3464 <sect2>
3465 <title>IOCTLs</title>
3466 <synopsis>struct drm_ioctl_desc *ioctls;
3467 int num_ioctls;</synopsis>
3468 <abstract>Driver-specific ioctls descriptors table.</abstract>
3469 <para>
3470 Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
3471 descriptors table is indexed by the ioctl number offset from the base
3472 value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize the
3473 table entries.
3474 </para>
3475 <para>
3476 <programlisting>DRM_IOCTL_DEF_DRV(ioctl, func, flags)</programlisting>
3477 <para>
3478 <parameter>ioctl</parameter> is the ioctl name. Drivers must define
3479 the DRM_##ioctl and DRM_IOCTL_##ioctl macros to the ioctl number
3480 offset from DRM_COMMAND_BASE and the ioctl number respectively. The
3481 first macro is private to the device while the second must be exposed
3482 to userspace in a public header.
3483 </para>
3484 <para>
3485 <parameter>func</parameter> is a pointer to the ioctl handler function
3486 compatible with the <type>drm_ioctl_t</type> type.
3487 <programlisting>typedef int drm_ioctl_t(struct drm_device *dev, void *data,
3488 struct drm_file *file_priv);</programlisting>
3489 </para>
3490 <para>
3491 <parameter>flags</parameter> is a bitmask combination of the following
3492 values. It restricts how the ioctl is allowed to be called.
3493 <itemizedlist>
3494 <listitem><para>
3495 DRM_AUTH - Only authenticated callers allowed
3496 </para></listitem>
3497 <listitem><para>
3498 DRM_MASTER - The ioctl can only be called on the master file
3499 handle
3500 </para></listitem>
3501 <listitem><para>
3502 DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
3503 </para></listitem>
3504 <listitem><para>
3505 DRM_CONTROL_ALLOW - The ioctl can only be called on a control
3506 device
3507 </para></listitem>
3508 <listitem><para>
3509 DRM_UNLOCKED - The ioctl handler will be called without locking
3510 the DRM global mutex. This is the enforced default for kms drivers
3511 (i.e. using the DRIVER_MODESET flag) and hence shouldn't be used
3512 any more for new drivers.
3513 </para></listitem>
3514 </itemizedlist>
3515 </para>
3516 </para>
3517 !Edrivers/gpu/drm/drm_ioctl.c
3518 </sect2>
3519 </sect1>
3520 <sect1>
3521 <title>Legacy Support Code</title>
3522 <para>
3523 The section very briefly covers some of the old legacy support code which
3524 is only used by old DRM drivers which have done a so-called shadow-attach
3525 to the underlying device instead of registering as a real driver. This
3526 also includes some of the old generic buffer management and command
3527 submission code. Do not use any of this in new and modern drivers.
3528 </para>
3529
3530 <sect2>
3531 <title>Legacy Suspend/Resume</title>
3532 <para>
3533 The DRM core provides some suspend/resume code, but drivers wanting full
3534 suspend/resume support should provide save() and restore() functions.
3535 These are called at suspend, hibernate, or resume time, and should perform
3536 any state save or restore required by your device across suspend or
3537 hibernate states.
3538 </para>
3539 <synopsis>int (*suspend) (struct drm_device *, pm_message_t state);
3540 int (*resume) (struct drm_device *);</synopsis>
3541 <para>
3542 Those are legacy suspend and resume methods which
3543 <emphasis>only</emphasis> work with the legacy shadow-attach driver
3544 registration functions. New driver should use the power management
3545 interface provided by their bus type (usually through
3546 the struct <structname>device_driver</structname> dev_pm_ops) and set
3547 these methods to NULL.
3548 </para>
3549 </sect2>
3550
3551 <sect2>
3552 <title>Legacy DMA Services</title>
3553 <para>
3554 This should cover how DMA mapping etc. is supported by the core.
3555 These functions are deprecated and should not be used.
3556 </para>
3557 </sect2>
3558 </sect1>
3559 </chapter>
3560
3561 <!-- TODO
3562
3563 - Add a glossary
3564 - Document the struct_mutex catch-all lock
3565 - Document connector properties
3566
3567 - Why is the load method optional?
3568 - What are drivers supposed to set the initial display state to, and how?
3569 Connector's DPMS states are not initialized and are thus equal to
3570 DRM_MODE_DPMS_ON. The fbcon compatibility layer calls
3571 drm_helper_disable_unused_functions(), which disables unused encoders and
3572 CRTCs, but doesn't touch the connectors' DPMS state, and
3573 drm_helper_connector_dpms() in reaction to fbdev blanking events. Do drivers
3574 that don't implement (or just don't use) fbcon compatibility need to call
3575 those functions themselves?
3576 - KMS drivers must call drm_vblank_pre_modeset() and drm_vblank_post_modeset()
3577 around mode setting. Should this be done in the DRM core?
3578 - vblank_disable_allowed is set to 1 in the first drm_vblank_post_modeset()
3579 call and never set back to 0. It seems to be safe to permanently set it to 1
3580 in drm_vblank_init() for KMS driver, and it might be safe for UMS drivers as
3581 well. This should be investigated.
3582 - crtc and connector .save and .restore operations are only used internally in
3583 drivers, should they be removed from the core?
3584 - encoder mid-layer .save and .restore operations are only used internally in
3585 drivers, should they be removed from the core?
3586 - encoder mid-layer .detect operation is only used internally in drivers,
3587 should it be removed from the core?
3588 -->
3589
3590 <!-- External interfaces -->
3591
3592 <chapter id="drmExternals">
3593 <title>Userland interfaces</title>
3594 <para>
3595 The DRM core exports several interfaces to applications,
3596 generally intended to be used through corresponding libdrm
3597 wrapper functions. In addition, drivers export device-specific
3598 interfaces for use by userspace drivers &amp; device-aware
3599 applications through ioctls and sysfs files.
3600 </para>
3601 <para>
3602 External interfaces include: memory mapping, context management,
3603 DMA operations, AGP management, vblank control, fence
3604 management, memory management, and output management.
3605 </para>
3606 <para>
3607 Cover generic ioctls and sysfs layout here. We only need high-level
3608 info, since man pages should cover the rest.
3609 </para>
3610
3611 <!-- External: render nodes -->
3612
3613 <sect1>
3614 <title>Render nodes</title>
3615 <para>
3616 DRM core provides multiple character-devices for user-space to use.
3617 Depending on which device is opened, user-space can perform a different
3618 set of operations (mainly ioctls). The primary node is always created
3619 and called card&lt;num&gt;. Additionally, a currently
3620 unused control node, called controlD&lt;num&gt; is also
3621 created. The primary node provides all legacy operations and
3622 historically was the only interface used by userspace. With KMS, the
3623 control node was introduced. However, the planned KMS control interface
3624 has never been written and so the control node stays unused to date.
3625 </para>
3626 <para>
3627 With the increased use of offscreen renderers and GPGPU applications,
3628 clients no longer require running compositors or graphics servers to
3629 make use of a GPU. But the DRM API required unprivileged clients to
3630 authenticate to a DRM-Master prior to getting GPU access. To avoid this
3631 step and to grant clients GPU access without authenticating, render
3632 nodes were introduced. Render nodes solely serve render clients, that
3633 is, no modesetting or privileged ioctls can be issued on render nodes.
3634 Only non-global rendering commands are allowed. If a driver supports
3635 render nodes, it must advertise it via the DRIVER_RENDER
3636 DRM driver capability. If not supported, the primary node must be used
3637 for render clients together with the legacy drmAuth authentication
3638 procedure.
3639 </para>
3640 <para>
3641 If a driver advertises render node support, DRM core will create a
3642 separate render node called renderD&lt;num&gt;. There will
3643 be one render node per device. No ioctls except PRIME-related ioctls
3644 will be allowed on this node. Especially GEM_OPEN will be
3645 explicitly prohibited. Render nodes are designed to avoid the
3646 buffer-leaks, which occur if clients guess the flink names or mmap
3647 offsets on the legacy interface. Additionally to this basic interface,
3648 drivers must mark their driver-dependent render-only ioctls as
3649 DRM_RENDER_ALLOW so render clients can use them. Driver
3650 authors must be careful not to allow any privileged ioctls on render
3651 nodes.
3652 </para>
3653 <para>
3654 With render nodes, user-space can now control access to the render node
3655 via basic file-system access-modes. A running graphics server which
3656 authenticates clients on the privileged primary/legacy node is no longer
3657 required. Instead, a client can open the render node and is immediately
3658 granted GPU access. Communication between clients (or servers) is done
3659 via PRIME. FLINK from render node to legacy node is not supported. New
3660 clients must not use the insecure FLINK interface.
3661 </para>
3662 <para>
3663 Besides dropping all modeset/global ioctls, render nodes also drop the
3664 DRM-Master concept. There is no reason to associate render clients with
3665 a DRM-Master as they are independent of any graphics server. Besides,
3666 they must work without any running master, anyway.
3667 Drivers must be able to run without a master object if they support
3668 render nodes. If, on the other hand, a driver requires shared state
3669 between clients which is visible to user-space and accessible beyond
3670 open-file boundaries, they cannot support render nodes.
3671 </para>
3672 </sect1>
3673
3674 <!-- External: vblank handling -->
3675
3676 <sect1>
3677 <title>VBlank event handling</title>
3678 <para>
3679 The DRM core exposes two vertical blank related ioctls:
3680 <variablelist>
3681 <varlistentry>
3682 <term>DRM_IOCTL_WAIT_VBLANK</term>
3683 <listitem>
3684 <para>
3685 This takes a struct drm_wait_vblank structure as its argument,
3686 and it is used to block or request a signal when a specified
3687 vblank event occurs.
3688 </para>
3689 </listitem>
3690 </varlistentry>
3691 <varlistentry>
3692 <term>DRM_IOCTL_MODESET_CTL</term>
3693 <listitem>
3694 <para>
3695 This was only used for user-mode-settind drivers around
3696 modesetting changes to allow the kernel to update the vblank
3697 interrupt after mode setting, since on many devices the vertical
3698 blank counter is reset to 0 at some point during modeset. Modern
3699 drivers should not call this any more since with kernel mode
3700 setting it is a no-op.
3701 </para>
3702 </listitem>
3703 </varlistentry>
3704 </variablelist>
3705 </para>
3706 </sect1>
3707
3708 </chapter>
3709 </part>
3710 <part id="drmDrivers">
3711 <title>DRM Drivers</title>
3712
3713 <partintro>
3714 <para>
3715 This second part of the GPU Driver Developer's Guide documents driver
3716 code, implementation details and also all the driver-specific userspace
3717 interfaces. Especially since all hardware-acceleration interfaces to
3718 userspace are driver specific for efficiency and other reasons these
3719 interfaces can be rather substantial. Hence every driver has its own
3720 chapter.
3721 </para>
3722 </partintro>
3723
3724 <chapter id="drmI915">
3725 <title>drm/i915 Intel GFX Driver</title>
3726 <para>
3727 The drm/i915 driver supports all (with the exception of some very early
3728 models) integrated GFX chipsets with both Intel display and rendering
3729 blocks. This excludes a set of SoC platforms with an SGX rendering unit,
3730 those have basic support through the gma500 drm driver.
3731 </para>
3732 <sect1>
3733 <title>Core Driver Infrastructure</title>
3734 <para>
3735 This section covers core driver infrastructure used by both the display
3736 and the GEM parts of the driver.
3737 </para>
3738 <sect2>
3739 <title>Runtime Power Management</title>
3740 !Pdrivers/gpu/drm/i915/intel_runtime_pm.c runtime pm
3741 !Idrivers/gpu/drm/i915/intel_runtime_pm.c
3742 !Idrivers/gpu/drm/i915/intel_uncore.c
3743 </sect2>
3744 <sect2>
3745 <title>Interrupt Handling</title>
3746 !Pdrivers/gpu/drm/i915/i915_irq.c interrupt handling
3747 !Fdrivers/gpu/drm/i915/i915_irq.c intel_irq_init intel_irq_init_hw intel_hpd_init
3748 !Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_disable_interrupts
3749 !Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_enable_interrupts
3750 </sect2>
3751 <sect2>
3752 <title>Intel GVT-g Guest Support(vGPU)</title>
3753 !Pdrivers/gpu/drm/i915/i915_vgpu.c Intel GVT-g guest support
3754 !Idrivers/gpu/drm/i915/i915_vgpu.c
3755 </sect2>
3756 </sect1>
3757 <sect1>
3758 <title>Display Hardware Handling</title>
3759 <para>
3760 This section covers everything related to the display hardware including
3761 the mode setting infrastructure, plane, sprite and cursor handling and
3762 display, output probing and related topics.
3763 </para>
3764 <sect2>
3765 <title>Mode Setting Infrastructure</title>
3766 <para>
3767 The i915 driver is thus far the only DRM driver which doesn't use the
3768 common DRM helper code to implement mode setting sequences. Thus it
3769 has its own tailor-made infrastructure for executing a display
3770 configuration change.
3771 </para>
3772 </sect2>
3773 <sect2>
3774 <title>Frontbuffer Tracking</title>
3775 !Pdrivers/gpu/drm/i915/intel_frontbuffer.c frontbuffer tracking
3776 !Idrivers/gpu/drm/i915/intel_frontbuffer.c
3777 !Fdrivers/gpu/drm/i915/i915_gem.c i915_gem_track_fb
3778 </sect2>
3779 <sect2>
3780 <title>Display FIFO Underrun Reporting</title>
3781 !Pdrivers/gpu/drm/i915/intel_fifo_underrun.c fifo underrun handling
3782 !Idrivers/gpu/drm/i915/intel_fifo_underrun.c
3783 </sect2>
3784 <sect2>
3785 <title>Plane Configuration</title>
3786 <para>
3787 This section covers plane configuration and composition with the
3788 primary plane, sprites, cursors and overlays. This includes the
3789 infrastructure to do atomic vsync'ed updates of all this state and
3790 also tightly coupled topics like watermark setup and computation,
3791 framebuffer compression and panel self refresh.
3792 </para>
3793 </sect2>
3794 <sect2>
3795 <title>Atomic Plane Helpers</title>
3796 !Pdrivers/gpu/drm/i915/intel_atomic_plane.c atomic plane helpers
3797 !Idrivers/gpu/drm/i915/intel_atomic_plane.c
3798 </sect2>
3799 <sect2>
3800 <title>Output Probing</title>
3801 <para>
3802 This section covers output probing and related infrastructure like the
3803 hotplug interrupt storm detection and mitigation code. Note that the
3804 i915 driver still uses most of the common DRM helper code for output
3805 probing, so those sections fully apply.
3806 </para>
3807 </sect2>
3808 <sect2>
3809 <title>Hotplug</title>
3810 !Pdrivers/gpu/drm/i915/intel_hotplug.c Hotplug
3811 !Idrivers/gpu/drm/i915/intel_hotplug.c
3812 </sect2>
3813 <sect2>
3814 <title>High Definition Audio</title>
3815 !Pdrivers/gpu/drm/i915/intel_audio.c High Definition Audio over HDMI and Display Port
3816 !Idrivers/gpu/drm/i915/intel_audio.c
3817 !Iinclude/drm/i915_component.h
3818 </sect2>
3819 <sect2>
3820 <title>Panel Self Refresh PSR (PSR/SRD)</title>
3821 !Pdrivers/gpu/drm/i915/intel_psr.c Panel Self Refresh (PSR/SRD)
3822 !Idrivers/gpu/drm/i915/intel_psr.c
3823 </sect2>
3824 <sect2>
3825 <title>Frame Buffer Compression (FBC)</title>
3826 !Pdrivers/gpu/drm/i915/intel_fbc.c Frame Buffer Compression (FBC)
3827 !Idrivers/gpu/drm/i915/intel_fbc.c
3828 </sect2>
3829 <sect2>
3830 <title>Display Refresh Rate Switching (DRRS)</title>
3831 !Pdrivers/gpu/drm/i915/intel_dp.c Display Refresh Rate Switching (DRRS)
3832 !Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_set_drrs_state
3833 !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_enable
3834 !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_disable
3835 !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_invalidate
3836 !Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_flush
3837 !Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_drrs_init
3838
3839 </sect2>
3840 <sect2>
3841 <title>DPIO</title>
3842 !Pdrivers/gpu/drm/i915/i915_reg.h DPIO
3843 <table id="dpiox2">
3844 <title>Dual channel PHY (VLV/CHV/BXT)</title>
3845 <tgroup cols="8">
3846 <colspec colname="c0" />
3847 <colspec colname="c1" />
3848 <colspec colname="c2" />
3849 <colspec colname="c3" />
3850 <colspec colname="c4" />
3851 <colspec colname="c5" />
3852 <colspec colname="c6" />
3853 <colspec colname="c7" />
3854 <spanspec spanname="ch0" namest="c0" nameend="c3" />
3855 <spanspec spanname="ch1" namest="c4" nameend="c7" />
3856 <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
3857 <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
3858 <spanspec spanname="ch1pcs01" namest="c4" nameend="c5" />
3859 <spanspec spanname="ch1pcs23" namest="c6" nameend="c7" />
3860 <thead>
3861 <row>
3862 <entry spanname="ch0">CH0</entry>
3863 <entry spanname="ch1">CH1</entry>
3864 </row>
3865 </thead>
3866 <tbody valign="top" align="center">
3867 <row>
3868 <entry spanname="ch0">CMN/PLL/REF</entry>
3869 <entry spanname="ch1">CMN/PLL/REF</entry>
3870 </row>
3871 <row>
3872 <entry spanname="ch0pcs01">PCS01</entry>
3873 <entry spanname="ch0pcs23">PCS23</entry>
3874 <entry spanname="ch1pcs01">PCS01</entry>
3875 <entry spanname="ch1pcs23">PCS23</entry>
3876 </row>
3877 <row>
3878 <entry>TX0</entry>
3879 <entry>TX1</entry>
3880 <entry>TX2</entry>
3881 <entry>TX3</entry>
3882 <entry>TX0</entry>
3883 <entry>TX1</entry>
3884 <entry>TX2</entry>
3885 <entry>TX3</entry>
3886 </row>
3887 <row>
3888 <entry spanname="ch0">DDI0</entry>
3889 <entry spanname="ch1">DDI1</entry>
3890 </row>
3891 </tbody>
3892 </tgroup>
3893 </table>
3894 <table id="dpiox1">
3895 <title>Single channel PHY (CHV/BXT)</title>
3896 <tgroup cols="4">
3897 <colspec colname="c0" />
3898 <colspec colname="c1" />
3899 <colspec colname="c2" />
3900 <colspec colname="c3" />
3901 <spanspec spanname="ch0" namest="c0" nameend="c3" />
3902 <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
3903 <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
3904 <thead>
3905 <row>
3906 <entry spanname="ch0">CH0</entry>
3907 </row>
3908 </thead>
3909 <tbody valign="top" align="center">
3910 <row>
3911 <entry spanname="ch0">CMN/PLL/REF</entry>
3912 </row>
3913 <row>
3914 <entry spanname="ch0pcs01">PCS01</entry>
3915 <entry spanname="ch0pcs23">PCS23</entry>
3916 </row>
3917 <row>
3918 <entry>TX0</entry>
3919 <entry>TX1</entry>
3920 <entry>TX2</entry>
3921 <entry>TX3</entry>
3922 </row>
3923 <row>
3924 <entry spanname="ch0">DDI2</entry>
3925 </row>
3926 </tbody>
3927 </tgroup>
3928 </table>
3929 </sect2>
3930
3931 <sect2>
3932 <title>CSR firmware support for DMC</title>
3933 !Pdrivers/gpu/drm/i915/intel_csr.c csr support for dmc
3934 !Idrivers/gpu/drm/i915/intel_csr.c
3935 </sect2>
3936 </sect1>
3937
3938 <sect1>
3939 <title>Memory Management and Command Submission</title>
3940 <para>
3941 This sections covers all things related to the GEM implementation in the
3942 i915 driver.
3943 </para>
3944 <sect2>
3945 <title>Batchbuffer Parsing</title>
3946 !Pdrivers/gpu/drm/i915/i915_cmd_parser.c batch buffer command parser
3947 !Idrivers/gpu/drm/i915/i915_cmd_parser.c
3948 </sect2>
3949 <sect2>
3950 <title>Batchbuffer Pools</title>
3951 !Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool
3952 !Idrivers/gpu/drm/i915/i915_gem_batch_pool.c
3953 </sect2>
3954 <sect2>
3955 <title>Logical Rings, Logical Ring Contexts and Execlists</title>
3956 !Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists
3957 !Idrivers/gpu/drm/i915/intel_lrc.c
3958 </sect2>
3959 <sect2>
3960 <title>Global GTT views</title>
3961 !Pdrivers/gpu/drm/i915/i915_gem_gtt.c Global GTT views
3962 !Idrivers/gpu/drm/i915/i915_gem_gtt.c
3963 </sect2>
3964 <sect2>
3965 <title>GTT Fences and Swizzling</title>
3966 !Idrivers/gpu/drm/i915/i915_gem_fence.c
3967 <sect3>
3968 <title>Global GTT Fence Handling</title>
3969 !Pdrivers/gpu/drm/i915/i915_gem_fence.c fence register handling
3970 </sect3>
3971 <sect3>
3972 <title>Hardware Tiling and Swizzling Details</title>
3973 !Pdrivers/gpu/drm/i915/i915_gem_fence.c tiling swizzling details
3974 </sect3>
3975 </sect2>
3976 <sect2>
3977 <title>Object Tiling IOCTLs</title>
3978 !Idrivers/gpu/drm/i915/i915_gem_tiling.c
3979 !Pdrivers/gpu/drm/i915/i915_gem_tiling.c buffer object tiling
3980 </sect2>
3981 <sect2>
3982 <title>Buffer Object Eviction</title>
3983 <para>
3984 This section documents the interface functions for evicting buffer
3985 objects to make space available in the virtual gpu address spaces.
3986 Note that this is mostly orthogonal to shrinking buffer objects
3987 caches, which has the goal to make main memory (shared with the gpu
3988 through the unified memory architecture) available.
3989 </para>
3990 !Idrivers/gpu/drm/i915/i915_gem_evict.c
3991 </sect2>
3992 <sect2>
3993 <title>Buffer Object Memory Shrinking</title>
3994 <para>
3995 This section documents the interface function for shrinking memory
3996 usage of buffer object caches. Shrinking is used to make main memory
3997 available. Note that this is mostly orthogonal to evicting buffer
3998 objects, which has the goal to make space in gpu virtual address
3999 spaces.
4000 </para>
4001 !Idrivers/gpu/drm/i915/i915_gem_shrinker.c
4002 </sect2>
4003 </sect1>
4004 <sect1>
4005 <title>GuC</title>
4006 <sect2>
4007 <title>GuC-specific firmware loader</title>
4008 !Pdrivers/gpu/drm/i915/intel_guc_loader.c GuC-specific firmware loader
4009 !Idrivers/gpu/drm/i915/intel_guc_loader.c
4010 </sect2>
4011 <sect2>
4012 <title>GuC-based command submission</title>
4013 !Pdrivers/gpu/drm/i915/i915_guc_submission.c GuC-based command submission
4014 !Idrivers/gpu/drm/i915/i915_guc_submission.c
4015 </sect2>
4016 <sect2>
4017 <title>GuC Firmware Layout</title>
4018 !Pdrivers/gpu/drm/i915/intel_guc_fwif.h GuC Firmware Layout
4019 </sect2>
4020 </sect1>
4021
4022 <sect1>
4023 <title> Tracing </title>
4024 <para>
4025 This sections covers all things related to the tracepoints implemented in
4026 the i915 driver.
4027 </para>
4028 <sect2>
4029 <title> i915_ppgtt_create and i915_ppgtt_release </title>
4030 !Pdrivers/gpu/drm/i915/i915_trace.h i915_ppgtt_create and i915_ppgtt_release tracepoints
4031 </sect2>
4032 <sect2>
4033 <title> i915_context_create and i915_context_free </title>
4034 !Pdrivers/gpu/drm/i915/i915_trace.h i915_context_create and i915_context_free tracepoints
4035 </sect2>
4036 <sect2>
4037 <title> switch_mm </title>
4038 !Pdrivers/gpu/drm/i915/i915_trace.h switch_mm tracepoint
4039 </sect2>
4040 </sect1>
4041
4042 </chapter>
4043 !Cdrivers/gpu/drm/i915/i915_irq.c
4044 </part>
4045
4046 <part id="vga_switcheroo">
4047 <title>vga_switcheroo</title>
4048 <partintro>
4049 !Pdrivers/gpu/vga/vga_switcheroo.c Overview
4050 </partintro>
4051
4052 <chapter id="modes_of_use">
4053 <title>Modes of Use</title>
4054 <sect1>
4055 <title>Manual switching and manual power control</title>
4056 !Pdrivers/gpu/vga/vga_switcheroo.c Manual switching and manual power control
4057 </sect1>
4058 <sect1>
4059 <title>Driver power control</title>
4060 !Pdrivers/gpu/vga/vga_switcheroo.c Driver power control
4061 </sect1>
4062 </chapter>
4063
4064 <chapter id="pubfunctions">
4065 <title>Public functions</title>
4066 !Edrivers/gpu/vga/vga_switcheroo.c
4067 </chapter>
4068
4069 <chapter id="pubstructures">
4070 <title>Public structures</title>
4071 !Finclude/linux/vga_switcheroo.h vga_switcheroo_handler
4072 !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_ops
4073 </chapter>
4074
4075 <chapter id="pubconstants">
4076 <title>Public constants</title>
4077 !Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id
4078 !Finclude/linux/vga_switcheroo.h vga_switcheroo_state
4079 </chapter>
4080
4081 <chapter id="privstructures">
4082 <title>Private structures</title>
4083 !Fdrivers/gpu/vga/vga_switcheroo.c vgasr_priv
4084 !Fdrivers/gpu/vga/vga_switcheroo.c vga_switcheroo_client
4085 </chapter>
4086
4087 !Cdrivers/gpu/vga/vga_switcheroo.c
4088 !Cinclude/linux/vga_switcheroo.h
4089 </part>
4090
4091 </book>