drm/i915: Unbreak check_digital_port_conflicts()
[deliverable/linux.git] / Documentation / DocBook / gpu.tmpl
CommitLineData
2d2ef822
JB
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
7f817074 5<book id="gpuDevelopersGuide">
2d2ef822 6 <bookinfo>
3a4579b4 7 <title>Linux GPU Driver Developer's Guide</title>
2d2ef822 8
9cad9c95
LP
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>
3a05700d
DV
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>
6648f487
LW
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>
9cad9c95
LP
53 </authorgroup>
54
2d2ef822
JB
55 <copyright>
56 <year>2008-2009</year>
3a05700d 57 <year>2013-2014</year>
9cad9c95 58 <holder>Intel Corporation</holder>
3a05700d
DV
59 </copyright>
60 <copyright>
61 <year>2012</year>
9cad9c95 62 <holder>Laurent Pinchart</holder>
2d2ef822 63 </copyright>
6648f487
LW
64 <copyright>
65 <year>2015</year>
66 <holder>Lukas Wunner</holder>
67 </copyright>
2d2ef822
JB
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>
9cad9c95
LP
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>
6648f487
LW
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>
9cad9c95 93 </revhistory>
2d2ef822
JB
94 </bookinfo>
95
96<toc></toc>
97
3519f70e
DV
98<part id="drmCore">
99 <title>DRM Core</title>
100 <partintro>
101 <para>
7f817074
LW
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.
3519f70e
DV
105 </para>
106 </partintro>
2d2ef822
JB
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
f11aca04 114 drivers in the kernel may make use of DRM functions to make
2d2ef822
JB
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>
a78f6787 139 First, we go over some typical driver initialization
2d2ef822
JB
140 requirements, like setting up command buffers, creating an
141 initial output configuration, and initializing core services.
a78f6787 142 Subsequent sections cover core internals in more detail,
2d2ef822
JB
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>
2d2ef822
JB
154
155 <!-- Internals: driver init -->
156
157 <sect1>
9cad9c95
LP
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,
6e3f797c
DV
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>.
b528ae71 166 </para>
9cad9c95
LP
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.
2d2ef822 174 </para>
2d2ef822 175 <sect2>
9cad9c95
LP
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>
9cad9c95
LP
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>
02b62985
LP
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).
9cad9c95
LP
233 </para></listitem>
234 </varlistentry>
9cad9c95
LP
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>
1793126f
DH
253 <varlistentry>
254 <term>DRIVER_RENDER</term>
255 <listitem><para>
256 Driver supports dedicated render nodes.
257 </para></listitem>
258 </varlistentry>
88a48e29
RC
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>
9cad9c95
LP
267 </variablelist>
268 </sect3>
269 <sect3>
270 <title>Major, Minor and Patchlevel</title>
271 <synopsis>int major;
272int minor;
273int 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;
294char *desc;
295char *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>
c6a1af8a 315 <sect2>
6e3f797c
DV
316 <title>Device Instance and Driver Handling</title>
317!Pdrivers/gpu/drm/drm_drv.c driver instance overview
25196484 318!Edrivers/gpu/drm/drm_drv.c
c6a1af8a 319 </sect2>
9cad9c95
LP
320 <sect2>
321 <title>Driver Load</title>
9cad9c95
LP
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
02b62985
LP
328 support a single interrupt per device, devices that use more than one
329 IRQs need to be handled manually.
9cad9c95 330 </para>
02b62985
LP
331 <sect4>
332 <title>Managed IRQ Registration</title>
02b62985
LP
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>
bb0f1b5c 340 The passed-in IRQ will then be requested by a call to
02b62985
LP
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>
9cad9c95
LP
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>
2d2ef822 413 </sect2>
6e3f797c
DV
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>
9cad9c95 426 </sect1>
2d2ef822 427
9cad9c95 428 <!-- Internals: memory management -->
2d2ef822 429
9cad9c95
LP
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
f884ab15 443 solution. It provides a single userspace API to accommodate the need of
9cad9c95
LP
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
9a6594fc 455 TTM, but has no video RAM management capabilities and is thus limited to
9cad9c95
LP
456 UMA devices.
457 </para>
2d2ef822 458 <sect2>
9cad9c95 459 <title>The Translation Table Manager (TTM)</title>
2d2ef822 460 <para>
79058100 461 TTM design background and information belongs here.
2d2ef822
JB
462 </para>
463 <sect3>
79058100 464 <title>TTM initialization</title>
9cad9c95
LP
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.
79058100
TR
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>
2d2ef822 508 </sect3>
9cad9c95
LP
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>
79058100
TR
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
9cad9c95
LP
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
79058100 547 read &amp; write, mapping, and domain ownership transfers are left to
9cad9c95
LP
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>
2d2ef822 571 <sect3>
9cad9c95
LP
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>
9cad9c95
LP
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>
decc60bf
DV
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.
9cad9c95
LP
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>
df2e0900
DV
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>.
9cad9c95
LP
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>
79058100
TR
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>
9cad9c95
LP
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
df2e0900 725 <function>drm_gem_create_mmap_offset</function> on the object.
9cad9c95
LP
726 </para>
727 <para>
728 Once allocated, the fake offset value
9cad9c95
LP
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>
9cad9c95
LP
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>
79058100 796 Perhaps the most important GEM function for GPU devices is providing a
9cad9c95
LP
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>
2d2ef822 813 </sect3>
decc60bf
DV
814 </sect2>
815 <sect2>
816 <title>GEM Function Reference</title>
89d61fc0 817!Edrivers/gpu/drm/drm_gem.c
decc60bf 818!Iinclude/drm/drm_gem.h
79058100
TR
819 </sect2>
820 <sect2>
821 <title>VMA Offset Manager</title>
4c5acf3c
DV
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
79058100
TR
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);
251261db 854int (*prime_fd_to_handle)(struct drm_device *dev,
79058100
TR
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);
251261db 877struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
79058100
TR
878 struct dma_buf *dma_buf);</synopsis>
879 These two operations are mandatory for GEM drivers that support
880 PRIME.
881 </para>
251261db 882 </sect3>
79058100
TR
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>
39cc344a 890!Edrivers/gpu/drm/drm_prime.c
79058100
TR
891 </sect2>
892 <sect2>
893 <title>DRM MM Range Allocator</title>
894 <sect3>
895 <title>Overview</title>
93110be6 896!Pdrivers/gpu/drm/drm_mm.c Overview
79058100
TR
897 </sect3>
898 <sect3>
899 <title>LRU Scan/Eviction Support</title>
93110be6 900!Pdrivers/gpu/drm/drm_mm.c lru scan roaster
79058100 901 </sect3>
93110be6 902 </sect2>
79058100
TR
903 <sect2>
904 <title>DRM MM Range Allocator Function References</title>
e18c0412
DV
905!Edrivers/gpu/drm/drm_mm.c
906!Iinclude/drm/drm_mm.h
79058100 907 </sect2>
d7883f87
TR
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>
9cad9c95
LP
914 </sect1>
915
916 <!-- Internals: mode setting -->
2d2ef822 917
9cad9c95
LP
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;
930int 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>
3ec0db81
DV
941 <sect2>
942 <title>Display Modes Function Reference</title>
f5aabb97 943!Iinclude/drm/drm_modes.h
3ec0db81 944!Edrivers/gpu/drm/drm_modes.c
cc4ceb48
DV
945 </sect2>
946 <sect2>
947 <title>Atomic Mode Setting Function Reference</title>
948!Edrivers/gpu/drm/drm_atomic.c
3ec0db81 949 </sect2>
2d2ef822 950 <sect2>
9cad9c95
LP
951 <title>Frame Buffer Creation</title>
952 <synopsis>struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
953 struct drm_file *file_priv,
954 struct drm_mode_fb_cmd2 *mode_cmd);</synopsis>
2d2ef822 955 <para>
9cad9c95
LP
956 Frame buffers are abstract memory objects that provide a source of
957 pixels to scanout to a CRTC. Applications explicitly request the
958 creation of frame buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and
959 receive an opaque handle that can be passed to the KMS CRTC control,
960 plane configuration and page flip functions.
961 </para>
962 <para>
963 Frame buffers rely on the underneath memory manager for low-level memory
964 operations. When creating a frame buffer applications pass a memory
965 handle (or a list of memory handles for multi-planar formats) through
065a5027
DV
966 the <parameter>drm_mode_fb_cmd2</parameter> argument. For drivers using
967 GEM as their userspace buffer management interface this would be a GEM
968 handle. Drivers are however free to use their own backing storage object
969 handles, e.g. vmwgfx directly exposes special TTM handles to userspace
970 and so expects TTM handles in the create ioctl and not GEM handles.
9cad9c95
LP
971 </para>
972 <para>
973 Drivers must first validate the requested frame buffer parameters passed
974 through the mode_cmd argument. In particular this is where invalid
975 sizes, pixel formats or pitches can be caught.
976 </para>
977 <para>
978 If the parameters are deemed valid, drivers then create, initialize and
979 return an instance of struct <structname>drm_framebuffer</structname>.
980 If desired the instance can be embedded in a larger driver-specific
5d7a9515
DV
981 structure. Drivers must fill its <structfield>width</structfield>,
982 <structfield>height</structfield>, <structfield>pitches</structfield>,
983 <structfield>offsets</structfield>, <structfield>depth</structfield>,
984 <structfield>bits_per_pixel</structfield> and
985 <structfield>pixel_format</structfield> fields from the values passed
986 through the <parameter>drm_mode_fb_cmd2</parameter> argument. They
987 should call the <function>drm_helper_mode_fill_fb_struct</function>
988 helper function to do so.
989 </para>
990
991 <para>
065a5027 992 The initialization of the new framebuffer instance is finalized with a
5d7a9515
DV
993 call to <function>drm_framebuffer_init</function> which takes a pointer
994 to DRM frame buffer operations (struct
995 <structname>drm_framebuffer_funcs</structname>). Note that this function
996 publishes the framebuffer and so from this point on it can be accessed
997 concurrently from other threads. Hence it must be the last step in the
998 driver's framebuffer initialization sequence. Frame buffer operations
999 are
9cad9c95
LP
1000 <itemizedlist>
1001 <listitem>
1002 <synopsis>int (*create_handle)(struct drm_framebuffer *fb,
1003 struct drm_file *file_priv, unsigned int *handle);</synopsis>
1004 <para>
1005 Create a handle to the frame buffer underlying memory object. If
1006 the frame buffer uses a multi-plane format, the handle will
1007 reference the memory object associated with the first plane.
1008 </para>
1009 <para>
1010 Drivers call <function>drm_gem_handle_create</function> to create
1011 the handle.
1012 </para>
1013 </listitem>
1014 <listitem>
1015 <synopsis>void (*destroy)(struct drm_framebuffer *framebuffer);</synopsis>
1016 <para>
1017 Destroy the frame buffer object and frees all associated
1018 resources. Drivers must call
1019 <function>drm_framebuffer_cleanup</function> to free resources
1020 allocated by the DRM core for the frame buffer object, and must
1021 make sure to unreference all memory objects associated with the
1022 frame buffer. Handles created by the
1023 <methodname>create_handle</methodname> operation are released by
1024 the DRM core.
1025 </para>
1026 </listitem>
1027 <listitem>
1028 <synopsis>int (*dirty)(struct drm_framebuffer *framebuffer,
1029 struct drm_file *file_priv, unsigned flags, unsigned color,
1030 struct drm_clip_rect *clips, unsigned num_clips);</synopsis>
1031 <para>
1032 This optional operation notifies the driver that a region of the
1033 frame buffer has changed in response to a DRM_IOCTL_MODE_DIRTYFB
1034 ioctl call.
1035 </para>
1036 </listitem>
1037 </itemizedlist>
1038 </para>
1039 <para>
5d7a9515
DV
1040 The lifetime of a drm framebuffer is controlled with a reference count,
1041 drivers can grab additional references with
9ee984a5 1042 <function>drm_framebuffer_reference</function>and drop them
5d7a9515
DV
1043 again with <function>drm_framebuffer_unreference</function>. For
1044 driver-private framebuffers for which the last reference is never
1045 dropped (e.g. for the fbdev framebuffer when the struct
1046 <structname>drm_framebuffer</structname> is embedded into the fbdev
1047 helper struct) drivers can manually clean up a framebuffer at module
1048 unload time with
1049 <function>drm_framebuffer_unregister_private</function>.
9ee984a5 1050 </para>
9cad9c95 1051 </sect2>
065a5027
DV
1052 <sect2>
1053 <title>Dumb Buffer Objects</title>
1054 <para>
1055 The KMS API doesn't standardize backing storage object creation and
1056 leaves it to driver-specific ioctls. Furthermore actually creating a
1057 buffer object even for GEM-based drivers is done through a
1058 driver-specific ioctl - GEM only has a common userspace interface for
1059 sharing and destroying objects. While not an issue for full-fledged
1060 graphics stacks that include device-specific userspace components (in
1061 libdrm for instance), this limit makes DRM-based early boot graphics
1062 unnecessarily complex.
1063 </para>
1064 <para>
1065 Dumb objects partly alleviate the problem by providing a standard
1066 API to create dumb buffers suitable for scanout, which can then be used
1067 to create KMS frame buffers.
1068 </para>
1069 <para>
1070 To support dumb objects drivers must implement the
1071 <methodname>dumb_create</methodname>,
1072 <methodname>dumb_destroy</methodname> and
1073 <methodname>dumb_map_offset</methodname> operations.
1074 </para>
1075 <itemizedlist>
1076 <listitem>
1077 <synopsis>int (*dumb_create)(struct drm_file *file_priv, struct drm_device *dev,
1078 struct drm_mode_create_dumb *args);</synopsis>
1079 <para>
1080 The <methodname>dumb_create</methodname> operation creates a driver
1081 object (GEM or TTM handle) suitable for scanout based on the
1082 width, height and depth from the struct
1083 <structname>drm_mode_create_dumb</structname> argument. It fills the
1084 argument's <structfield>handle</structfield>,
1085 <structfield>pitch</structfield> and <structfield>size</structfield>
1086 fields with a handle for the newly created object and its line
1087 pitch and size in bytes.
1088 </para>
1089 </listitem>
1090 <listitem>
1091 <synopsis>int (*dumb_destroy)(struct drm_file *file_priv, struct drm_device *dev,
1092 uint32_t handle);</synopsis>
1093 <para>
1094 The <methodname>dumb_destroy</methodname> operation destroys a dumb
1095 object created by <methodname>dumb_create</methodname>.
1096 </para>
1097 </listitem>
1098 <listitem>
1099 <synopsis>int (*dumb_map_offset)(struct drm_file *file_priv, struct drm_device *dev,
1100 uint32_t handle, uint64_t *offset);</synopsis>
1101 <para>
1102 The <methodname>dumb_map_offset</methodname> operation associates an
1103 mmap fake offset with the object given by the handle and returns
1104 it. Drivers must use the
1105 <function>drm_gem_create_mmap_offset</function> function to
1106 associate the fake offset as described in
1107 <xref linkend="drm-gem-objects-mapping"/>.
1108 </para>
1109 </listitem>
1110 </itemizedlist>
1111 <para>
1112 Note that dumb objects may not be used for gpu acceleration, as has been
1113 attempted on some ARM embedded platforms. Such drivers really must have
1114 a hardware-specific ioctl to allocate suitable buffer objects.
1115 </para>
1116 </sect2>
9cad9c95
LP
1117 <sect2>
1118 <title>Output Polling</title>
1119 <synopsis>void (*output_poll_changed)(struct drm_device *dev);</synopsis>
1120 <para>
1121 This operation notifies the driver that the status of one or more
1122 connectors has changed. Drivers that use the fb helper can just call the
1123 <function>drm_fb_helper_hotplug_event</function> function to handle this
1124 operation.
1125 </para>
1126 </sect2>
5d7a9515
DV
1127 <sect2>
1128 <title>Locking</title>
1129 <para>
1130 Beside some lookup structures with their own locking (which is hidden
1131 behind the interface functions) most of the modeset state is protected
1132 by the <code>dev-&lt;mode_config.lock</code> mutex and additionally
1133 per-crtc locks to allow cursor updates, pageflips and similar operations
1134 to occur concurrently with background tasks like output detection.
1135 Operations which cross domains like a full modeset always grab all
1136 locks. Drivers there need to protect resources shared between crtcs with
1137 additional locking. They also need to be careful to always grab the
1138 relevant crtc locks if a modset functions touches crtc state, e.g. for
1139 load detection (which does only grab the <code>mode_config.lock</code>
1140 to allow concurrent screen updates on live crtcs).
1141 </para>
1142 </sect2>
9cad9c95
LP
1143 </sect1>
1144
1145 <!-- Internals: kms initialization and cleanup -->
1146
1147 <sect1 id="drm-kms-init">
1148 <title>KMS Initialization and Cleanup</title>
1149 <para>
1150 A KMS device is abstracted and exposed as a set of planes, CRTCs, encoders
1151 and connectors. KMS drivers must thus create and initialize all those
1152 objects at load time after initializing mode setting.
1153 </para>
1154 <sect2>
1155 <title>CRTCs (struct <structname>drm_crtc</structname>)</title>
1156 <para>
1157 A CRTC is an abstraction representing a part of the chip that contains a
1158 pointer to a scanout buffer. Therefore, the number of CRTCs available
1159 determines how many independent scanout buffers can be active at any
1160 given time. The CRTC structure contains several fields to support this:
1161 a pointer to some video memory (abstracted as a frame buffer object), a
1162 display mode, and an (x, y) offset into the video memory to support
1163 panning or configurations where one piece of video memory spans multiple
1164 CRTCs.
2d2ef822
JB
1165 </para>
1166 <sect3>
9cad9c95
LP
1167 <title>CRTC Initialization</title>
1168 <para>
1169 A KMS device must create and register at least one struct
1170 <structname>drm_crtc</structname> instance. The instance is allocated
1171 and zeroed by the driver, possibly as part of a larger structure, and
1172 registered with a call to <function>drm_crtc_init</function> with a
1173 pointer to CRTC functions.
1174 </para>
1175 </sect3>
6efa1f2f 1176 <sect3 id="drm-kms-crtcops">
9cad9c95
LP
1177 <title>CRTC Operations</title>
1178 <sect4>
1179 <title>Set Configuration</title>
1180 <synopsis>int (*set_config)(struct drm_mode_set *set);</synopsis>
1181 <para>
1182 Apply a new CRTC configuration to the device. The configuration
1183 specifies a CRTC, a frame buffer to scan out from, a (x,y) position in
1184 the frame buffer, a display mode and an array of connectors to drive
1185 with the CRTC if possible.
1186 </para>
1187 <para>
1188 If the frame buffer specified in the configuration is NULL, the driver
1189 must detach all encoders connected to the CRTC and all connectors
1190 attached to those encoders and disable them.
1191 </para>
1192 <para>
1193 This operation is called with the mode config lock held.
1194 </para>
1195 <note><para>
aa4cd910
DV
1196 Note that the drm core has no notion of restoring the mode setting
1197 state after resume, since all resume handling is in the full
1198 responsibility of the driver. The common mode setting helper library
1199 though provides a helper which can be used for this:
1200 <function>drm_helper_resume_force_mode</function>.
9cad9c95
LP
1201 </para></note>
1202 </sect4>
1203 <sect4>
1204 <title>Page Flipping</title>
1205 <synopsis>int (*page_flip)(struct drm_crtc *crtc, struct drm_framebuffer *fb,
1206 struct drm_pending_vblank_event *event);</synopsis>
1207 <para>
1208 Schedule a page flip to the given frame buffer for the CRTC. This
1209 operation is called with the mode config mutex held.
1210 </para>
1211 <para>
1212 Page flipping is a synchronization mechanism that replaces the frame
1213 buffer being scanned out by the CRTC with a new frame buffer during
1214 vertical blanking, avoiding tearing. When an application requests a page
1215 flip the DRM core verifies that the new frame buffer is large enough to
1216 be scanned out by the CRTC in the currently configured mode and then
1217 calls the CRTC <methodname>page_flip</methodname> operation with a
1218 pointer to the new frame buffer.
1219 </para>
1220 <para>
1221 The <methodname>page_flip</methodname> operation schedules a page flip.
f884ab15 1222 Once any pending rendering targeting the new frame buffer has
9cad9c95
LP
1223 completed, the CRTC will be reprogrammed to display that frame buffer
1224 after the next vertical refresh. The operation must return immediately
1225 without waiting for rendering or page flip to complete and must block
1226 any new rendering to the frame buffer until the page flip completes.
1227 </para>
8cf1e981
TR
1228 <para>
1229 If a page flip can be successfully scheduled the driver must set the
9ceae1da 1230 <code>drm_crtc-&gt;fb</code> field to the new framebuffer pointed to
8cf1e981
TR
1231 by <code>fb</code>. This is important so that the reference counting
1232 on framebuffers stays balanced.
1233 </para>
9cad9c95
LP
1234 <para>
1235 If a page flip is already pending, the
1236 <methodname>page_flip</methodname> operation must return
1237 -<errorname>EBUSY</errorname>.
1238 </para>
1239 <para>
1240 To synchronize page flip to vertical blanking the driver will likely
1241 need to enable vertical blanking interrupts. It should call
1242 <function>drm_vblank_get</function> for that purpose, and call
1243 <function>drm_vblank_put</function> after the page flip completes.
1244 </para>
1245 <para>
1246 If the application has requested to be notified when page flip completes
1247 the <methodname>page_flip</methodname> operation will be called with a
1248 non-NULL <parameter>event</parameter> argument pointing to a
1249 <structname>drm_pending_vblank_event</structname> instance. Upon page
c6eefa17
RC
1250 flip completion the driver must call <methodname>drm_send_vblank_event</methodname>
1251 to fill in the event and send to wake up any waiting processes.
1252 This can be performed with
9cad9c95 1253 <programlisting><![CDATA[
9cad9c95 1254 spin_lock_irqsave(&dev->event_lock, flags);
c6eefa17
RC
1255 ...
1256 drm_send_vblank_event(dev, pipe, event);
9cad9c95
LP
1257 spin_unlock_irqrestore(&dev->event_lock, flags);
1258 ]]></programlisting>
1259 </para>
1260 <note><para>
1261 FIXME: Could drivers that don't need to wait for rendering to complete
1262 just add the event to <literal>dev-&gt;vblank_event_list</literal> and
1263 let the DRM core handle everything, as for "normal" vertical blanking
1264 events?
1265 </para></note>
1266 <para>
1267 While waiting for the page flip to complete, the
1268 <literal>event-&gt;base.link</literal> list head can be used freely by
1269 the driver to store the pending event in a driver-specific list.
1270 </para>
1271 <para>
1272 If the file handle is closed before the event is signaled, drivers must
1273 take care to destroy the event in their
1274 <methodname>preclose</methodname> operation (and, if needed, call
1275 <function>drm_vblank_put</function>).
1276 </para>
1277 </sect4>
1278 <sect4>
1279 <title>Miscellaneous</title>
1280 <itemizedlist>
421cda3e
LP
1281 <listitem>
1282 <synopsis>void (*set_property)(struct drm_crtc *crtc,
1283 struct drm_property *property, uint64_t value);</synopsis>
1284 <para>
1285 Set the value of the given CRTC property to
1286 <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
1287 for more information about properties.
1288 </para>
1289 </listitem>
9cad9c95
LP
1290 <listitem>
1291 <synopsis>void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
1292 uint32_t start, uint32_t size);</synopsis>
1293 <para>
1294 Apply a gamma table to the device. The operation is optional.
1295 </para>
1296 </listitem>
1297 <listitem>
1298 <synopsis>void (*destroy)(struct drm_crtc *crtc);</synopsis>
1299 <para>
1300 Destroy the CRTC when not needed anymore. See
1301 <xref linkend="drm-kms-init"/>.
1302 </para>
1303 </listitem>
1304 </itemizedlist>
1305 </sect4>
1306 </sect3>
1307 </sect2>
1308 <sect2>
1309 <title>Planes (struct <structname>drm_plane</structname>)</title>
1310 <para>
1311 A plane represents an image source that can be blended with or overlayed
1312 on top of a CRTC during the scanout process. Planes are associated with
1313 a frame buffer to crop a portion of the image memory (source) and
1314 optionally scale it to a destination size. The result is then blended
1315 with or overlayed on top of a CRTC.
1316 </para>
6efa1f2f
MR
1317 <para>
1318 The DRM core recognizes three types of planes:
1319 <itemizedlist>
1320 <listitem>
1321 DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary
ef21bf73 1322 planes are the planes operated upon by CRTC modesetting and flipping
6efa1f2f
MR
1323 operations described in <xref linkend="drm-kms-crtcops"/>.
1324 </listitem>
1325 <listitem>
1326 DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. Cursor
1327 planes are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
1328 DRM_IOCTL_MODE_CURSOR2 ioctls.
1329 </listitem>
1330 <listitem>
1331 DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor planes.
1332 Some drivers refer to these types of planes as "sprites" internally.
1333 </listitem>
1334 </itemizedlist>
1335 For compatibility with legacy userspace, only overlay planes are made
1336 available to userspace by default. Userspace clients may set the
1337 DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that
1338 they wish to receive a universal plane list containing all plane types.
1339 </para>
9cad9c95
LP
1340 <sect3>
1341 <title>Plane Initialization</title>
1342 <para>
6efa1f2f 1343 To create a plane, a KMS drivers allocates and
9cad9c95
LP
1344 zeroes an instances of struct <structname>drm_plane</structname>
1345 (possibly as part of a larger structure) and registers it with a call
6efa1f2f 1346 to <function>drm_universal_plane_init</function>. The function takes a bitmask
9cad9c95 1347 of the CRTCs that can be associated with the plane, a pointer to the
6efa1f2f
MR
1348 plane functions, a list of format supported formats, and the type of
1349 plane (primary, cursor, or overlay) being initialized.
1350 </para>
1351 <para>
1352 Cursor and overlay planes are optional. All drivers should provide
1353 one primary plane per CRTC (although this requirement may change in
1354 the future); drivers that do not wish to provide special handling for
1355 primary planes may make use of the helper functions described in
1356 <xref linkend="drm-kms-planehelpers"/> to create and register a
1357 primary plane with standard capabilities.
9cad9c95
LP
1358 </para>
1359 </sect3>
1360 <sect3>
1361 <title>Plane Operations</title>
1362 <itemizedlist>
1363 <listitem>
1364 <synopsis>int (*update_plane)(struct drm_plane *plane, struct drm_crtc *crtc,
1365 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
1366 unsigned int crtc_w, unsigned int crtc_h,
1367 uint32_t src_x, uint32_t src_y,
1368 uint32_t src_w, uint32_t src_h);</synopsis>
1369 <para>
1370 Enable and configure the plane to use the given CRTC and frame buffer.
1371 </para>
1372 <para>
1373 The source rectangle in frame buffer memory coordinates is given by
1374 the <parameter>src_x</parameter>, <parameter>src_y</parameter>,
1375 <parameter>src_w</parameter> and <parameter>src_h</parameter>
1376 parameters (as 16.16 fixed point values). Devices that don't support
1377 subpixel plane coordinates can ignore the fractional part.
1378 </para>
1379 <para>
1380 The destination rectangle in CRTC coordinates is given by the
1381 <parameter>crtc_x</parameter>, <parameter>crtc_y</parameter>,
1382 <parameter>crtc_w</parameter> and <parameter>crtc_h</parameter>
1383 parameters (as integer values). Devices scale the source rectangle to
1384 the destination rectangle. If scaling is not supported, and the source
1385 rectangle size doesn't match the destination rectangle size, the
1386 driver must return a -<errorname>EINVAL</errorname> error.
1387 </para>
1388 </listitem>
1389 <listitem>
1390 <synopsis>int (*disable_plane)(struct drm_plane *plane);</synopsis>
1391 <para>
1392 Disable the plane. The DRM core calls this method in response to a
1393 DRM_IOCTL_MODE_SETPLANE ioctl call with the frame buffer ID set to 0.
1394 Disabled planes must not be processed by the CRTC.
1395 </para>
1396 </listitem>
1397 <listitem>
1398 <synopsis>void (*destroy)(struct drm_plane *plane);</synopsis>
1399 <para>
1400 Destroy the plane when not needed anymore. See
1401 <xref linkend="drm-kms-init"/>.
1402 </para>
1403 </listitem>
1404 </itemizedlist>
1405 </sect3>
1406 </sect2>
1407 <sect2>
1408 <title>Encoders (struct <structname>drm_encoder</structname>)</title>
1409 <para>
1410 An encoder takes pixel data from a CRTC and converts it to a format
1411 suitable for any attached connectors. On some devices, it may be
1412 possible to have a CRTC send data to more than one encoder. In that
1413 case, both encoders would receive data from the same scanout buffer,
1414 resulting in a "cloned" display configuration across the connectors
1415 attached to each encoder.
1416 </para>
1417 <sect3>
1418 <title>Encoder Initialization</title>
1419 <para>
1420 As for CRTCs, a KMS driver must create, initialize and register at
1421 least one struct <structname>drm_encoder</structname> instance. The
1422 instance is allocated and zeroed by the driver, possibly as part of a
1423 larger structure.
1424 </para>
1425 <para>
1426 Drivers must initialize the struct <structname>drm_encoder</structname>
1427 <structfield>possible_crtcs</structfield> and
1428 <structfield>possible_clones</structfield> fields before registering the
1429 encoder. Both fields are bitmasks of respectively the CRTCs that the
1430 encoder can be connected to, and sibling encoders candidate for cloning.
1431 </para>
1432 <para>
1433 After being initialized, the encoder must be registered with a call to
1434 <function>drm_encoder_init</function>. The function takes a pointer to
1435 the encoder functions and an encoder type. Supported types are
1436 <itemizedlist>
1437 <listitem>
1438 DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A
1439 </listitem>
1440 <listitem>
1441 DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort
1442 </listitem>
1443 <listitem>
1444 DRM_MODE_ENCODER_LVDS for display panels
1445 </listitem>
1446 <listitem>
1447 DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, Component,
1448 SCART)
1449 </listitem>
1450 <listitem>
1451 DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
1452 </listitem>
1453 </itemizedlist>
1454 </para>
1455 <para>
1456 Encoders must be attached to a CRTC to be used. DRM drivers leave
1457 encoders unattached at initialization time. Applications (or the fbdev
1458 compatibility layer when implemented) are responsible for attaching the
1459 encoders they want to use to a CRTC.
1460 </para>
1461 </sect3>
1462 <sect3>
1463 <title>Encoder Operations</title>
1464 <itemizedlist>
1465 <listitem>
1466 <synopsis>void (*destroy)(struct drm_encoder *encoder);</synopsis>
1467 <para>
1468 Called to destroy the encoder when not needed anymore. See
1469 <xref linkend="drm-kms-init"/>.
1470 </para>
1471 </listitem>
421cda3e
LP
1472 <listitem>
1473 <synopsis>void (*set_property)(struct drm_plane *plane,
1474 struct drm_property *property, uint64_t value);</synopsis>
1475 <para>
1476 Set the value of the given plane property to
1477 <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
1478 for more information about properties.
1479 </para>
1480 </listitem>
9cad9c95
LP
1481 </itemizedlist>
1482 </sect3>
1483 </sect2>
1484 <sect2>
1485 <title>Connectors (struct <structname>drm_connector</structname>)</title>
1486 <para>
1487 A connector is the final destination for pixel data on a device, and
1488 usually connects directly to an external display device like a monitor
1489 or laptop panel. A connector can only be attached to one encoder at a
1490 time. The connector is also the structure where information about the
1491 attached display is kept, so it contains fields for display data, EDID
1492 data, DPMS &amp; connection status, and information about modes
1493 supported on the attached displays.
1494 </para>
1495 <sect3>
1496 <title>Connector Initialization</title>
1497 <para>
1498 Finally a KMS driver must create, initialize, register and attach at
1499 least one struct <structname>drm_connector</structname> instance. The
1500 instance is created as other KMS objects and initialized by setting the
1501 following fields.
1502 </para>
1503 <variablelist>
1504 <varlistentry>
1505 <term><structfield>interlace_allowed</structfield></term>
1506 <listitem><para>
1507 Whether the connector can handle interlaced modes.
1508 </para></listitem>
1509 </varlistentry>
1510 <varlistentry>
1511 <term><structfield>doublescan_allowed</structfield></term>
1512 <listitem><para>
1513 Whether the connector can handle doublescan.
1514 </para></listitem>
1515 </varlistentry>
1516 <varlistentry>
1517 <term><structfield>display_info
1518 </structfield></term>
1519 <listitem><para>
1520 Display information is filled from EDID information when a display
1521 is detected. For non hot-pluggable displays such as flat panels in
1522 embedded systems, the driver should initialize the
1523 <structfield>display_info</structfield>.<structfield>width_mm</structfield>
1524 and
1525 <structfield>display_info</structfield>.<structfield>height_mm</structfield>
1526 fields with the physical size of the display.
1527 </para></listitem>
1528 </varlistentry>
1529 <varlistentry>
1530 <term id="drm-kms-connector-polled"><structfield>polled</structfield></term>
1531 <listitem><para>
1532 Connector polling mode, a combination of
1533 <variablelist>
1534 <varlistentry>
1535 <term>DRM_CONNECTOR_POLL_HPD</term>
1536 <listitem><para>
1537 The connector generates hotplug events and doesn't need to be
1538 periodically polled. The CONNECT and DISCONNECT flags must not
1539 be set together with the HPD flag.
1540 </para></listitem>
1541 </varlistentry>
1542 <varlistentry>
1543 <term>DRM_CONNECTOR_POLL_CONNECT</term>
1544 <listitem><para>
1545 Periodically poll the connector for connection.
1546 </para></listitem>
1547 </varlistentry>
1548 <varlistentry>
1549 <term>DRM_CONNECTOR_POLL_DISCONNECT</term>
1550 <listitem><para>
1551 Periodically poll the connector for disconnection.
1552 </para></listitem>
1553 </varlistentry>
1554 </variablelist>
1555 Set to 0 for connectors that don't support connection status
1556 discovery.
1557 </para></listitem>
1558 </varlistentry>
1559 </variablelist>
1560 <para>
1561 The connector is then registered with a call to
1562 <function>drm_connector_init</function> with a pointer to the connector
1563 functions and a connector type, and exposed through sysfs with a call to
34ea3d38 1564 <function>drm_connector_register</function>.
9cad9c95
LP
1565 </para>
1566 <para>
1567 Supported connector types are
1568 <itemizedlist>
1569 <listitem>DRM_MODE_CONNECTOR_VGA</listitem>
1570 <listitem>DRM_MODE_CONNECTOR_DVII</listitem>
1571 <listitem>DRM_MODE_CONNECTOR_DVID</listitem>
1572 <listitem>DRM_MODE_CONNECTOR_DVIA</listitem>
1573 <listitem>DRM_MODE_CONNECTOR_Composite</listitem>
1574 <listitem>DRM_MODE_CONNECTOR_SVIDEO</listitem>
1575 <listitem>DRM_MODE_CONNECTOR_LVDS</listitem>
1576 <listitem>DRM_MODE_CONNECTOR_Component</listitem>
1577 <listitem>DRM_MODE_CONNECTOR_9PinDIN</listitem>
1578 <listitem>DRM_MODE_CONNECTOR_DisplayPort</listitem>
1579 <listitem>DRM_MODE_CONNECTOR_HDMIA</listitem>
1580 <listitem>DRM_MODE_CONNECTOR_HDMIB</listitem>
1581 <listitem>DRM_MODE_CONNECTOR_TV</listitem>
1582 <listitem>DRM_MODE_CONNECTOR_eDP</listitem>
1583 <listitem>DRM_MODE_CONNECTOR_VIRTUAL</listitem>
1584 </itemizedlist>
1585 </para>
1586 <para>
1587 Connectors must be attached to an encoder to be used. For devices that
1588 map connectors to encoders 1:1, the connector should be attached at
1589 initialization time with a call to
1590 <function>drm_mode_connector_attach_encoder</function>. The driver must
1591 also set the <structname>drm_connector</structname>
1592 <structfield>encoder</structfield> field to point to the attached
1593 encoder.
1594 </para>
1595 <para>
1596 Finally, drivers must initialize the connectors state change detection
1597 with a call to <function>drm_kms_helper_poll_init</function>. If at
1598 least one connector is pollable but can't generate hotplug interrupts
1599 (indicated by the DRM_CONNECTOR_POLL_CONNECT and
1600 DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will
1601 automatically be queued to periodically poll for changes. Connectors
1602 that can generate hotplug interrupts must be marked with the
1603 DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must
1604 call <function>drm_helper_hpd_irq_event</function>. The function will
1605 queue a delayed work to check the state of all connectors, but no
1606 periodic polling will be done.
1607 </para>
1608 </sect3>
1609 <sect3>
1610 <title>Connector Operations</title>
1611 <note><para>
1612 Unless otherwise state, all operations are mandatory.
1613 </para></note>
1614 <sect4>
1615 <title>DPMS</title>
1616 <synopsis>void (*dpms)(struct drm_connector *connector, int mode);</synopsis>
1617 <para>
1618 The DPMS operation sets the power state of a connector. The mode
1619 argument is one of
1620 <itemizedlist>
1621 <listitem><para>DRM_MODE_DPMS_ON</para></listitem>
1622 <listitem><para>DRM_MODE_DPMS_STANDBY</para></listitem>
1623 <listitem><para>DRM_MODE_DPMS_SUSPEND</para></listitem>
1624 <listitem><para>DRM_MODE_DPMS_OFF</para></listitem>
1625 </itemizedlist>
1626 </para>
1627 <para>
1628 In all but DPMS_ON mode the encoder to which the connector is attached
1629 should put the display in low-power mode by driving its signals
1630 appropriately. If more than one connector is attached to the encoder
1631 care should be taken not to change the power state of other displays as
1632 a side effect. Low-power mode should be propagated to the encoders and
1633 CRTCs when all related connectors are put in low-power mode.
1634 </para>
1635 </sect4>
1636 <sect4>
1637 <title>Modes</title>
1638 <synopsis>int (*fill_modes)(struct drm_connector *connector, uint32_t max_width,
1639 uint32_t max_height);</synopsis>
1640 <para>
1641 Fill the mode list with all supported modes for the connector. If the
1642 <parameter>max_width</parameter> and <parameter>max_height</parameter>
1643 arguments are non-zero, the implementation must ignore all modes wider
1644 than <parameter>max_width</parameter> or higher than
1645 <parameter>max_height</parameter>.
1646 </para>
1647 <para>
1648 The connector must also fill in this operation its
1649 <structfield>display_info</structfield>
1650 <structfield>width_mm</structfield> and
1651 <structfield>height_mm</structfield> fields with the connected display
1652 physical size in millimeters. The fields should be set to 0 if the value
1653 isn't known or is not applicable (for instance for projector devices).
1654 </para>
1655 </sect4>
1656 <sect4>
1657 <title>Connection Status</title>
1658 <para>
1659 The connection status is updated through polling or hotplug events when
1660 supported (see <xref linkend="drm-kms-connector-polled"/>). The status
1661 value is reported to userspace through ioctls and must not be used
1662 inside the driver, as it only gets initialized by a call to
1663 <function>drm_mode_getconnector</function> from userspace.
1664 </para>
1665 <synopsis>enum drm_connector_status (*detect)(struct drm_connector *connector,
1666 bool force);</synopsis>
1667 <para>
1668 Check to see if anything is attached to the connector. The
1669 <parameter>force</parameter> parameter is set to false whilst polling or
1670 to true when checking the connector due to user request.
1671 <parameter>force</parameter> can be used by the driver to avoid
1672 expensive, destructive operations during automated probing.
1673 </para>
1674 <para>
1675 Return connector_status_connected if something is connected to the
1676 connector, connector_status_disconnected if nothing is connected and
1677 connector_status_unknown if the connection state isn't known.
1678 </para>
1679 <para>
1680 Drivers should only return connector_status_connected if the connection
1681 status has really been probed as connected. Connectors that can't detect
1682 the connection status, or failed connection status probes, should return
1683 connector_status_unknown.
1684 </para>
1685 </sect4>
1686 <sect4>
1687 <title>Miscellaneous</title>
1688 <itemizedlist>
421cda3e
LP
1689 <listitem>
1690 <synopsis>void (*set_property)(struct drm_connector *connector,
1691 struct drm_property *property, uint64_t value);</synopsis>
1692 <para>
1693 Set the value of the given connector property to
1694 <parameter>value</parameter>. See <xref linkend="drm-kms-properties"/>
1695 for more information about properties.
1696 </para>
1697 </listitem>
9cad9c95
LP
1698 <listitem>
1699 <synopsis>void (*destroy)(struct drm_connector *connector);</synopsis>
1700 <para>
1701 Destroy the connector when not needed anymore. See
1702 <xref linkend="drm-kms-init"/>.
1703 </para>
1704 </listitem>
1705 </itemizedlist>
1706 </sect4>
1707 </sect3>
1708 </sect2>
1709 <sect2>
1710 <title>Cleanup</title>
1711 <para>
1712 The DRM core manages its objects' lifetime. When an object is not needed
1713 anymore the core calls its destroy function, which must clean up and
1714 free every resource allocated for the object. Every
1715 <function>drm_*_init</function> call must be matched with a
1716 corresponding <function>drm_*_cleanup</function> call to cleanup CRTCs
1717 (<function>drm_crtc_cleanup</function>), planes
1718 (<function>drm_plane_cleanup</function>), encoders
1719 (<function>drm_encoder_cleanup</function>) and connectors
1720 (<function>drm_connector_cleanup</function>). Furthermore, connectors
1721 that have been added to sysfs must be removed by a call to
34ea3d38 1722 <function>drm_connector_unregister</function> before calling
9cad9c95
LP
1723 <function>drm_connector_cleanup</function>.
1724 </para>
1725 <para>
1726 Connectors state change detection must be cleanup up with a call to
1727 <function>drm_kms_helper_poll_fini</function>.
1728 </para>
1729 </sect2>
1730 <sect2>
1731 <title>Output discovery and initialization example</title>
1732 <programlisting><![CDATA[
2d2ef822
JB
1733void intel_crt_init(struct drm_device *dev)
1734{
1735 struct drm_connector *connector;
1736 struct intel_output *intel_output;
1737
1738 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
1739 if (!intel_output)
1740 return;
1741
1742 connector = &intel_output->base;
1743 drm_connector_init(dev, &intel_output->base,
1744 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
1745
1746 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
1747 DRM_MODE_ENCODER_DAC);
1748
1749 drm_mode_connector_attach_encoder(&intel_output->base,
1750 &intel_output->enc);
1751
1752 /* Set up the DDC bus. */
1753 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
1754 if (!intel_output->ddc_bus) {
1755 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
1756 "failed.\n");
1757 return;
1758 }
1759
1760 intel_output->type = INTEL_OUTPUT_ANALOG;
1761 connector->interlace_allowed = 0;
1762 connector->doublescan_allowed = 0;
1763
1764 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
1765 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
1766
34ea3d38 1767 drm_connector_register(connector);
9cad9c95
LP
1768}]]></programlisting>
1769 <para>
1770 In the example above (taken from the i915 driver), a CRTC, connector and
1771 encoder combination is created. A device-specific i2c bus is also
1772 created for fetching EDID data and performing monitor detection. Once
1773 the process is complete, the new connector is registered with sysfs to
1774 make its properties available to applications.
1775 </para>
2d2ef822 1776 </sect2>
065a50ed
DV
1777 <sect2>
1778 <title>KMS API Functions</title>
1779!Edrivers/gpu/drm/drm_crtc.c
3bf0401c
DV
1780 </sect2>
1781 <sect2>
1782 <title>KMS Data Structures</title>
1783!Iinclude/drm/drm_crtc.h
065a50ed 1784 </sect2>
51fd371b
RC
1785 <sect2>
1786 <title>KMS Locking</title>
1787!Pdrivers/gpu/drm/drm_modeset_lock.c kms locking
1788!Iinclude/drm/drm_modeset_lock.h
1789!Edrivers/gpu/drm/drm_modeset_lock.c
1790 </sect2>
2d2ef822
JB
1791 </sect1>
1792
e4949f29 1793 <!-- Internals: kms helper functions -->
2d2ef822
JB
1794
1795 <sect1>
e4949f29 1796 <title>Mode Setting Helper Functions</title>
2d2ef822 1797 <para>
6efa1f2f 1798 The plane, CRTC, encoder and connector functions provided by the drivers
9cad9c95
LP
1799 implement the DRM API. They're called by the DRM core and ioctl handlers
1800 to handle device state changes and configuration request. As implementing
1801 those functions often requires logic not specific to drivers, mid-layer
1802 helper functions are available to avoid duplicating boilerplate code.
1803 </para>
1804 <para>
1805 The DRM core contains one mid-layer implementation. The mid-layer provides
6efa1f2f
MR
1806 implementations of several plane, CRTC, encoder and connector functions
1807 (called from the top of the mid-layer) that pre-process requests and call
9cad9c95
LP
1808 lower-level functions provided by the driver (at the bottom of the
1809 mid-layer). For instance, the
1810 <function>drm_crtc_helper_set_config</function> function can be used to
1811 fill the struct <structname>drm_crtc_funcs</structname>
1812 <structfield>set_config</structfield> field. When called, it will split
1813 the <methodname>set_config</methodname> operation in smaller, simpler
1814 operations and call the driver to handle them.
2d2ef822 1815 </para>
2d2ef822 1816 <para>
9cad9c95
LP
1817 To use the mid-layer, drivers call <function>drm_crtc_helper_add</function>,
1818 <function>drm_encoder_helper_add</function> and
1819 <function>drm_connector_helper_add</function> functions to install their
1820 mid-layer bottom operations handlers, and fill the
1821 <structname>drm_crtc_funcs</structname>,
1822 <structname>drm_encoder_funcs</structname> and
1823 <structname>drm_connector_funcs</structname> structures with pointers to
1824 the mid-layer top API functions. Installing the mid-layer bottom operation
1825 handlers is best done right after registering the corresponding KMS object.
2d2ef822
JB
1826 </para>
1827 <para>
9cad9c95
LP
1828 The mid-layer is not split between CRTC, encoder and connector operations.
1829 To use it, a driver must provide bottom functions for all of the three KMS
1830 entities.
2d2ef822 1831 </para>
9cad9c95
LP
1832 <sect2>
1833 <title>Helper Functions</title>
1834 <itemizedlist>
1835 <listitem>
1836 <synopsis>int drm_crtc_helper_set_config(struct drm_mode_set *set);</synopsis>
1837 <para>
1838 The <function>drm_crtc_helper_set_config</function> helper function
1839 is a CRTC <methodname>set_config</methodname> implementation. It
1840 first tries to locate the best encoder for each connector by calling
1841 the connector <methodname>best_encoder</methodname> helper
1842 operation.
1843 </para>
1844 <para>
1845 After locating the appropriate encoders, the helper function will
1846 call the <methodname>mode_fixup</methodname> encoder and CRTC helper
1847 operations to adjust the requested mode, or reject it completely in
1848 which case an error will be returned to the application. If the new
1849 configuration after mode adjustment is identical to the current
1850 configuration the helper function will return without performing any
1851 other operation.
1852 </para>
1853 <para>
1854 If the adjusted mode is identical to the current mode but changes to
1855 the frame buffer need to be applied, the
1856 <function>drm_crtc_helper_set_config</function> function will call
1857 the CRTC <methodname>mode_set_base</methodname> helper operation. If
1858 the adjusted mode differs from the current mode, or if the
1859 <methodname>mode_set_base</methodname> helper operation is not
1860 provided, the helper function performs a full mode set sequence by
1861 calling the <methodname>prepare</methodname>,
1862 <methodname>mode_set</methodname> and
1863 <methodname>commit</methodname> CRTC and encoder helper operations,
1864 in that order.
1865 </para>
1866 </listitem>
1867 <listitem>
1868 <synopsis>void drm_helper_connector_dpms(struct drm_connector *connector, int mode);</synopsis>
1869 <para>
1870 The <function>drm_helper_connector_dpms</function> helper function
1871 is a connector <methodname>dpms</methodname> implementation that
1872 tracks power state of connectors. To use the function, drivers must
1873 provide <methodname>dpms</methodname> helper operations for CRTCs
1874 and encoders to apply the DPMS state to the device.
1875 </para>
1876 <para>
1877 The mid-layer doesn't track the power state of CRTCs and encoders.
1878 The <methodname>dpms</methodname> helper operations can thus be
1879 called with a mode identical to the currently active mode.
1880 </para>
1881 </listitem>
1882 <listitem>
1883 <synopsis>int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
1884 uint32_t maxX, uint32_t maxY);</synopsis>
1885 <para>
1886 The <function>drm_helper_probe_single_connector_modes</function> helper
1887 function is a connector <methodname>fill_modes</methodname>
1888 implementation that updates the connection status for the connector
1889 and then retrieves a list of modes by calling the connector
1890 <methodname>get_modes</methodname> helper operation.
1891 </para>
f41c2581
LP
1892 <para>
1893 If the helper operation returns no mode, and if the connector status
1894 is connector_status_connected, standard VESA DMT modes up to
1895 1024x768 are automatically added to the modes list by a call to
1896 <function>drm_add_modes_noedid</function>.
1897 </para>
9cad9c95 1898 <para>
f41c2581 1899 The function then filters out modes larger than
9cad9c95 1900 <parameter>max_width</parameter> and <parameter>max_height</parameter>
f41c2581 1901 if specified. It finally calls the optional connector
f9b0e251 1902 <methodname>mode_valid</methodname> helper operation for each mode in
9cad9c95
LP
1903 the probed list to check whether the mode is valid for the connector.
1904 </para>
1905 </listitem>
1906 </itemizedlist>
1907 </sect2>
1908 <sect2>
1909 <title>CRTC Helper Operations</title>
1910 <itemizedlist>
1911 <listitem id="drm-helper-crtc-mode-fixup">
1912 <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc,
1913 const struct drm_display_mode *mode,
1914 struct drm_display_mode *adjusted_mode);</synopsis>
1915 <para>
1916 Let CRTCs adjust the requested mode or reject it completely. This
1917 operation returns true if the mode is accepted (possibly after being
1918 adjusted) or false if it is rejected.
1919 </para>
1920 <para>
1921 The <methodname>mode_fixup</methodname> operation should reject the
1922 mode if it can't reasonably use it. The definition of "reasonable"
1923 is currently fuzzy in this context. One possible behaviour would be
1924 to set the adjusted mode to the panel timings when a fixed-mode
1925 panel is used with hardware capable of scaling. Another behaviour
1926 would be to accept any input mode and adjust it to the closest mode
1927 supported by the hardware (FIXME: This needs to be clarified).
1928 </para>
1929 </listitem>
1930 <listitem>
1931 <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
1932 struct drm_framebuffer *old_fb)</synopsis>
1933 <para>
1934 Move the CRTC on the current frame buffer (stored in
1935 <literal>crtc-&gt;fb</literal>) to position (x,y). Any of the frame
1936 buffer, x position or y position may have been modified.
1937 </para>
1938 <para>
1939 This helper operation is optional. If not provided, the
1940 <function>drm_crtc_helper_set_config</function> function will fall
1941 back to the <methodname>mode_set</methodname> helper operation.
1942 </para>
1943 <note><para>
1944 FIXME: Why are x and y passed as arguments, as they can be accessed
1945 through <literal>crtc-&gt;x</literal> and
1946 <literal>crtc-&gt;y</literal>?
1947 </para></note>
1948 </listitem>
1949 <listitem>
1950 <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis>
1951 <para>
1952 Prepare the CRTC for mode setting. This operation is called after
1953 validating the requested mode. Drivers use it to perform
1954 device-specific operations required before setting the new mode.
1955 </para>
1956 </listitem>
1957 <listitem>
1958 <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
1959 struct drm_display_mode *adjusted_mode, int x, int y,
1960 struct drm_framebuffer *old_fb);</synopsis>
1961 <para>
1962 Set a new mode, position and frame buffer. Depending on the device
1963 requirements, the mode can be stored internally by the driver and
1964 applied in the <methodname>commit</methodname> operation, or
1965 programmed to the hardware immediately.
1966 </para>
1967 <para>
1968 The <methodname>mode_set</methodname> operation returns 0 on success
1969 or a negative error code if an error occurs.
1970 </para>
1971 </listitem>
1972 <listitem>
1973 <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis>
1974 <para>
1975 Commit a mode. This operation is called after setting the new mode.
1976 Upon return the device must use the new mode and be fully
1977 operational.
1978 </para>
1979 </listitem>
1980 </itemizedlist>
1981 </sect2>
1982 <sect2>
1983 <title>Encoder Helper Operations</title>
1984 <itemizedlist>
1985 <listitem>
1986 <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder,
1987 const struct drm_display_mode *mode,
1988 struct drm_display_mode *adjusted_mode);</synopsis>
9cad9c95
LP
1989 <para>
1990 Let encoders adjust the requested mode or reject it completely. This
1991 operation returns true if the mode is accepted (possibly after being
1992 adjusted) or false if it is rejected. See the
1993 <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper
1994 operation</link> for an explanation of the allowed adjustments.
1995 </para>
1996 </listitem>
1997 <listitem>
1998 <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis>
1999 <para>
2000 Prepare the encoder for mode setting. This operation is called after
2001 validating the requested mode. Drivers use it to perform
2002 device-specific operations required before setting the new mode.
2003 </para>
2004 </listitem>
2005 <listitem>
2006 <synopsis>void (*mode_set)(struct drm_encoder *encoder,
2007 struct drm_display_mode *mode,
2008 struct drm_display_mode *adjusted_mode);</synopsis>
2009 <para>
2010 Set a new mode. Depending on the device requirements, the mode can
2011 be stored internally by the driver and applied in the
2012 <methodname>commit</methodname> operation, or programmed to the
2013 hardware immediately.
2014 </para>
2015 </listitem>
2016 <listitem>
2017 <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis>
2018 <para>
2019 Commit a mode. This operation is called after setting the new mode.
2020 Upon return the device must use the new mode and be fully
2021 operational.
2022 </para>
2023 </listitem>
2024 </itemizedlist>
2025 </sect2>
2026 <sect2>
2027 <title>Connector Helper Operations</title>
2028 <itemizedlist>
2029 <listitem>
2030 <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis>
2031 <para>
2032 Return a pointer to the best encoder for the connecter. Device that
2033 map connectors to encoders 1:1 simply return the pointer to the
2034 associated encoder. This operation is mandatory.
2035 </para>
2036 </listitem>
2037 <listitem>
2038 <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis>
2039 <para>
2040 Fill the connector's <structfield>probed_modes</structfield> list
f41c2581
LP
2041 by parsing EDID data with <function>drm_add_edid_modes</function>,
2042 adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>,
2043 or calling <function>drm_mode_probed_add</function> directly for every
9cad9c95
LP
2044 supported mode and return the number of modes it has detected. This
2045 operation is mandatory.
2046 </para>
f41c2581
LP
2047 <para>
2048 Note that the caller function will automatically add standard VESA
2049 DMT modes up to 1024x768 if the <methodname>get_modes</methodname>
2050 helper operation returns no mode and if the connector status is
2051 connector_status_connected. There is no need to call
2052 <function>drm_add_edid_modes</function> manually in that case.
2053 </para>
9cad9c95
LP
2054 <para>
2055 When adding modes manually the driver creates each mode with a call to
2056 <function>drm_mode_create</function> and must fill the following fields.
2057 <itemizedlist>
2058 <listitem>
2059 <synopsis>__u32 type;</synopsis>
2060 <para>
2061 Mode type bitmask, a combination of
2062 <variablelist>
2063 <varlistentry>
2064 <term>DRM_MODE_TYPE_BUILTIN</term>
2065 <listitem><para>not used?</para></listitem>
2066 </varlistentry>
2067 <varlistentry>
2068 <term>DRM_MODE_TYPE_CLOCK_C</term>
2069 <listitem><para>not used?</para></listitem>
2070 </varlistentry>
2071 <varlistentry>
2072 <term>DRM_MODE_TYPE_CRTC_C</term>
2073 <listitem><para>not used?</para></listitem>
2074 </varlistentry>
2075 <varlistentry>
2076 <term>
2077 DRM_MODE_TYPE_PREFERRED - The preferred mode for the connector
2078 </term>
2079 <listitem>
2080 <para>not used?</para>
2081 </listitem>
2082 </varlistentry>
2083 <varlistentry>
2084 <term>DRM_MODE_TYPE_DEFAULT</term>
2085 <listitem><para>not used?</para></listitem>
2086 </varlistentry>
2087 <varlistentry>
2088 <term>DRM_MODE_TYPE_USERDEF</term>
2089 <listitem><para>not used?</para></listitem>
2090 </varlistentry>
2091 <varlistentry>
2092 <term>DRM_MODE_TYPE_DRIVER</term>
2093 <listitem>
2094 <para>
2095 The mode has been created by the driver (as opposed to
2096 to user-created modes).
2097 </para>
2098 </listitem>
2099 </varlistentry>
2100 </variablelist>
2101 Drivers must set the DRM_MODE_TYPE_DRIVER bit for all modes they
2102 create, and set the DRM_MODE_TYPE_PREFERRED bit for the preferred
2103 mode.
2104 </para>
2105 </listitem>
2106 <listitem>
2107 <synopsis>__u32 clock;</synopsis>
2108 <para>Pixel clock frequency in kHz unit</para>
2109 </listitem>
2110 <listitem>
2111 <synopsis>__u16 hdisplay, hsync_start, hsync_end, htotal;
2112 __u16 vdisplay, vsync_start, vsync_end, vtotal;</synopsis>
2113 <para>Horizontal and vertical timing information</para>
2114 <screen><![CDATA[
2115 Active Front Sync Back
2116 Region Porch Porch
2117 <-----------------------><----------------><-------------><-------------->
2118
2119 //////////////////////|
2120 ////////////////////// |
2121 ////////////////////// |.................. ................
2122 _______________
2123
2124 <----- [hv]display ----->
2125 <------------- [hv]sync_start ------------>
2126 <--------------------- [hv]sync_end --------------------->
2127 <-------------------------------- [hv]total ----------------------------->
2128]]></screen>
2129 </listitem>
2130 <listitem>
2131 <synopsis>__u16 hskew;
2132 __u16 vscan;</synopsis>
2133 <para>Unknown</para>
2134 </listitem>
2135 <listitem>
2136 <synopsis>__u32 flags;</synopsis>
2137 <para>
2138 Mode flags, a combination of
2139 <variablelist>
2140 <varlistentry>
2141 <term>DRM_MODE_FLAG_PHSYNC</term>
2142 <listitem><para>
2143 Horizontal sync is active high
2144 </para></listitem>
2145 </varlistentry>
2146 <varlistentry>
2147 <term>DRM_MODE_FLAG_NHSYNC</term>
2148 <listitem><para>
2149 Horizontal sync is active low
2150 </para></listitem>
2151 </varlistentry>
2152 <varlistentry>
2153 <term>DRM_MODE_FLAG_PVSYNC</term>
2154 <listitem><para>
2155 Vertical sync is active high
2156 </para></listitem>
2157 </varlistentry>
2158 <varlistentry>
2159 <term>DRM_MODE_FLAG_NVSYNC</term>
2160 <listitem><para>
2161 Vertical sync is active low
2162 </para></listitem>
2163 </varlistentry>
2164 <varlistentry>
2165 <term>DRM_MODE_FLAG_INTERLACE</term>
2166 <listitem><para>
2167 Mode is interlaced
2168 </para></listitem>
2169 </varlistentry>
2170 <varlistentry>
2171 <term>DRM_MODE_FLAG_DBLSCAN</term>
2172 <listitem><para>
2173 Mode uses doublescan
2174 </para></listitem>
2175 </varlistentry>
2176 <varlistentry>
2177 <term>DRM_MODE_FLAG_CSYNC</term>
2178 <listitem><para>
2179 Mode uses composite sync
2180 </para></listitem>
2181 </varlistentry>
2182 <varlistentry>
2183 <term>DRM_MODE_FLAG_PCSYNC</term>
2184 <listitem><para>
2185 Composite sync is active high
2186 </para></listitem>
2187 </varlistentry>
2188 <varlistentry>
2189 <term>DRM_MODE_FLAG_NCSYNC</term>
2190 <listitem><para>
2191 Composite sync is active low
2192 </para></listitem>
2193 </varlistentry>
2194 <varlistentry>
2195 <term>DRM_MODE_FLAG_HSKEW</term>
2196 <listitem><para>
2197 hskew provided (not used?)
2198 </para></listitem>
2199 </varlistentry>
2200 <varlistentry>
2201 <term>DRM_MODE_FLAG_BCAST</term>
2202 <listitem><para>
2203 not used?
2204 </para></listitem>
2205 </varlistentry>
2206 <varlistentry>
2207 <term>DRM_MODE_FLAG_PIXMUX</term>
2208 <listitem><para>
2209 not used?
2210 </para></listitem>
2211 </varlistentry>
2212 <varlistentry>
2213 <term>DRM_MODE_FLAG_DBLCLK</term>
2214 <listitem><para>
2215 not used?
2216 </para></listitem>
2217 </varlistentry>
2218 <varlistentry>
2219 <term>DRM_MODE_FLAG_CLKDIV2</term>
2220 <listitem><para>
2221 ?
2222 </para></listitem>
2223 </varlistentry>
2224 </variablelist>
2225 </para>
2226 <para>
2227 Note that modes marked with the INTERLACE or DBLSCAN flags will be
2228 filtered out by
2229 <function>drm_helper_probe_single_connector_modes</function> if
2230 the connector's <structfield>interlace_allowed</structfield> or
2231 <structfield>doublescan_allowed</structfield> field is set to 0.
2232 </para>
2233 </listitem>
2234 <listitem>
2235 <synopsis>char name[DRM_DISPLAY_MODE_LEN];</synopsis>
2236 <para>
2237 Mode name. The driver must call
2238 <function>drm_mode_set_name</function> to fill the mode name from
2239 <structfield>hdisplay</structfield>,
2240 <structfield>vdisplay</structfield> and interlace flag after
2241 filling the corresponding fields.
2242 </para>
2243 </listitem>
2244 </itemizedlist>
2245 </para>
2246 <para>
2247 The <structfield>vrefresh</structfield> value is computed by
2248 <function>drm_helper_probe_single_connector_modes</function>.
2249 </para>
2250 <para>
f41c2581 2251 When parsing EDID data, <function>drm_add_edid_modes</function> fills the
9cad9c95
LP
2252 connector <structfield>display_info</structfield>
2253 <structfield>width_mm</structfield> and
2254 <structfield>height_mm</structfield> fields. When creating modes
2255 manually the <methodname>get_modes</methodname> helper operation must
2256 set the <structfield>display_info</structfield>
2257 <structfield>width_mm</structfield> and
2258 <structfield>height_mm</structfield> fields if they haven't been set
065a5027 2259 already (for instance at initialization time when a fixed-size panel is
9cad9c95
LP
2260 attached to the connector). The mode <structfield>width_mm</structfield>
2261 and <structfield>height_mm</structfield> fields are only used internally
2262 during EDID parsing and should not be set when creating modes manually.
2263 </para>
2264 </listitem>
2265 <listitem>
2266 <synopsis>int (*mode_valid)(struct drm_connector *connector,
2267 struct drm_display_mode *mode);</synopsis>
2268 <para>
2269 Verify whether a mode is valid for the connector. Return MODE_OK for
2270 supported modes and one of the enum drm_mode_status values (MODE_*)
f9b0e251 2271 for unsupported modes. This operation is optional.
9cad9c95
LP
2272 </para>
2273 <para>
2274 As the mode rejection reason is currently not used beside for
2275 immediately removing the unsupported mode, an implementation can
2276 return MODE_BAD regardless of the exact reason why the mode is not
2277 valid.
2278 </para>
2279 <note><para>
2280 Note that the <methodname>mode_valid</methodname> helper operation is
2281 only called for modes detected by the device, and
2282 <emphasis>not</emphasis> for modes set by the user through the CRTC
2283 <methodname>set_config</methodname> operation.
2284 </para></note>
2285 </listitem>
2286 </itemizedlist>
2287 </sect2>
3150c7d0
DV
2288 <sect2>
2289 <title>Atomic Modeset Helper Functions Reference</title>
2290 <sect3>
2291 <title>Overview</title>
2292!Pdrivers/gpu/drm/drm_atomic_helper.c overview
2293 </sect3>
2294 <sect3>
2295 <title>Implementing Asynchronous Atomic Commit</title>
2296!Pdrivers/gpu/drm/drm_atomic_helper.c implementing async commit
2297 </sect3>
2298 <sect3>
2299 <title>Atomic State Reset and Initialization</title>
2300!Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
2301 </sect3>
dd275956 2302!Iinclude/drm/drm_atomic_helper.h
3150c7d0
DV
2303!Edrivers/gpu/drm/drm_atomic_helper.c
2304 </sect2>
0d4ed4c8
DV
2305 <sect2>
2306 <title>Modeset Helper Functions Reference</title>
7552e7dd 2307!Iinclude/drm/drm_crtc_helper.h
0d4ed4c8 2308!Edrivers/gpu/drm/drm_crtc_helper.c
3150c7d0 2309!Pdrivers/gpu/drm/drm_crtc_helper.c overview
8d754544
DV
2310 </sect2>
2311 <sect2>
2312 <title>Output Probing Helper Functions Reference</title>
2313!Pdrivers/gpu/drm/drm_probe_helper.c output probing helper overview
2314!Edrivers/gpu/drm/drm_probe_helper.c
0d4ed4c8 2315 </sect2>
d0ddc033
DV
2316 <sect2>
2317 <title>fbdev Helper Functions Reference</title>
2318!Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers
2319!Edrivers/gpu/drm/drm_fb_helper.c
207fd329 2320!Iinclude/drm/drm_fb_helper.h
d0ddc033 2321 </sect2>
28164fda
DV
2322 <sect2>
2323 <title>Display Port Helper Functions Reference</title>
2324!Pdrivers/gpu/drm/drm_dp_helper.c dp helpers
2325!Iinclude/drm/drm_dp_helper.h
2326!Edrivers/gpu/drm/drm_dp_helper.c
ad7f8a1f
DA
2327 </sect2>
2328 <sect2>
2329 <title>Display Port MST Helper Functions Reference</title>
2330!Pdrivers/gpu/drm/drm_dp_mst_topology.c dp mst helper
2331!Iinclude/drm/drm_dp_mst_helper.h
2332!Edrivers/gpu/drm/drm_dp_mst_topology.c
009081e0
TR
2333 </sect2>
2334 <sect2>
2335 <title>MIPI DSI Helper Functions Reference</title>
2336!Pdrivers/gpu/drm/drm_mipi_dsi.c dsi helpers
2337!Iinclude/drm/drm_mipi_dsi.h
2338!Edrivers/gpu/drm/drm_mipi_dsi.c
28164fda 2339 </sect2>
5e308591
TR
2340 <sect2>
2341 <title>EDID Helper Functions Reference</title>
2342!Edrivers/gpu/drm/drm_edid.c
2343 </sect2>
03973536
VS
2344 <sect2>
2345 <title>Rectangle Utilities Reference</title>
2346!Pinclude/drm/drm_rect.h rect utils
2347!Iinclude/drm/drm_rect.h
2348!Edrivers/gpu/drm/drm_rect.c
cabaafc7
RC
2349 </sect2>
2350 <sect2>
2351 <title>Flip-work Helper Reference</title>
2352!Pinclude/drm/drm_flip_work.h flip utils
2353!Iinclude/drm/drm_flip_work.h
2354!Edrivers/gpu/drm/drm_flip_work.c
03973536 2355 </sect2>
2d123f46
DV
2356 <sect2>
2357 <title>HDMI Infoframes Helper Reference</title>
2358 <para>
2359 Strictly speaking this is not a DRM helper library but generally useable
2360 by any driver interfacing with HDMI outputs like v4l or alsa drivers.
2361 But it nicely fits into the overall topic of mode setting helper
2362 libraries and hence is also included here.
2363 </para>
2364!Iinclude/linux/hdmi.h
2365!Edrivers/video/hdmi.c
2366 </sect2>
6efa1f2f
MR
2367 <sect2>
2368 <title id="drm-kms-planehelpers">Plane Helper Reference</title>
3150c7d0
DV
2369!Edrivers/gpu/drm/drm_plane_helper.c
2370!Pdrivers/gpu/drm/drm_plane_helper.c overview
6efa1f2f 2371 </sect2>
138f9ebb
DA
2372 <sect2>
2373 <title>Tile group</title>
2374!Pdrivers/gpu/drm/drm_crtc.c Tile group
2375 </sect2>
2331b4e4
AT
2376 <sect2>
2377 <title>Bridges</title>
2378 <sect3>
2379 <title>Overview</title>
2380!Pdrivers/gpu/drm/drm_bridge.c overview
2381 </sect3>
2382 <sect3>
2383 <title>Default bridge callback sequence</title>
2384!Pdrivers/gpu/drm/drm_bridge.c bridge callbacks
2385 </sect3>
2386!Edrivers/gpu/drm/drm_bridge.c
2387 </sect2>
2d2ef822
JB
2388 </sect1>
2389
421cda3e
LP
2390 <!-- Internals: kms properties -->
2391
2392 <sect1 id="drm-kms-properties">
2393 <title>KMS Properties</title>
2394 <para>
2395 Drivers may need to expose additional parameters to applications than
2396 those described in the previous sections. KMS supports attaching
2397 properties to CRTCs, connectors and planes and offers a userspace API to
2398 list, get and set the property values.
2399 </para>
2400 <para>
2401 Properties are identified by a name that uniquely defines the property
2402 purpose, and store an associated value. For all property types except blob
2403 properties the value is a 64-bit unsigned integer.
2404 </para>
2405 <para>
2406 KMS differentiates between properties and property instances. Drivers
2407 first create properties and then create and associate individual instances
2408 of those properties to objects. A property can be instantiated multiple
2409 times and associated with different objects. Values are stored in property
9a6594fc 2410 instances, and all other property information are stored in the property
421cda3e
LP
2411 and shared between all instances of the property.
2412 </para>
2413 <para>
2414 Every property is created with a type that influences how the KMS core
2415 handles the property. Supported property types are
2416 <variablelist>
2417 <varlistentry>
2418 <term>DRM_MODE_PROP_RANGE</term>
2419 <listitem><para>Range properties report their minimum and maximum
2420 admissible values. The KMS core verifies that values set by
2421 application fit in that range.</para></listitem>
2422 </varlistentry>
2423 <varlistentry>
2424 <term>DRM_MODE_PROP_ENUM</term>
2425 <listitem><para>Enumerated properties take a numerical value that
2426 ranges from 0 to the number of enumerated values defined by the
2427 property minus one, and associate a free-formed string name to each
2428 value. Applications can retrieve the list of defined value-name pairs
2429 and use the numerical value to get and set property instance values.
2430 </para></listitem>
2431 </varlistentry>
2432 <varlistentry>
2433 <term>DRM_MODE_PROP_BITMASK</term>
2434 <listitem><para>Bitmask properties are enumeration properties that
2435 additionally restrict all enumerated values to the 0..63 range.
2436 Bitmask property instance values combine one or more of the
2437 enumerated bits defined by the property.</para></listitem>
2438 </varlistentry>
2439 <varlistentry>
2440 <term>DRM_MODE_PROP_BLOB</term>
2441 <listitem><para>Blob properties store a binary blob without any format
2442 restriction. The binary blobs are created as KMS standalone objects,
2443 and blob property instance values store the ID of their associated
2444 blob object.</para>
2445 <para>Blob properties are only used for the connector EDID property
2446 and cannot be created by drivers.</para></listitem>
2447 </varlistentry>
2448 </variablelist>
2449 </para>
2450 <para>
2451 To create a property drivers call one of the following functions depending
2452 on the property type. All property creation functions take property flags
2453 and name, as well as type-specific arguments.
2454 <itemizedlist>
2455 <listitem>
2456 <synopsis>struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
2457 const char *name,
2458 uint64_t min, uint64_t max);</synopsis>
2459 <para>Create a range property with the given minimum and maximum
2460 values.</para>
2461 </listitem>
2462 <listitem>
2463 <synopsis>struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
2464 const char *name,
2465 const struct drm_prop_enum_list *props,
2466 int num_values);</synopsis>
2467 <para>Create an enumerated property. The <parameter>props</parameter>
2468 argument points to an array of <parameter>num_values</parameter>
2469 value-name pairs.</para>
2470 </listitem>
2471 <listitem>
2472 <synopsis>struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
2473 int flags, const char *name,
2474 const struct drm_prop_enum_list *props,
2475 int num_values);</synopsis>
2476 <para>Create a bitmask property. The <parameter>props</parameter>
2477 argument points to an array of <parameter>num_values</parameter>
2478 value-name pairs.</para>
2479 </listitem>
2480 </itemizedlist>
2481 </para>
2482 <para>
2483 Properties can additionally be created as immutable, in which case they
2484 will be read-only for applications but can be modified by the driver. To
2485 create an immutable property drivers must set the DRM_MODE_PROP_IMMUTABLE
2486 flag at property creation time.
2487 </para>
2488 <para>
2489 When no array of value-name pairs is readily available at property
2490 creation time for enumerated or range properties, drivers can create
2491 the property using the <function>drm_property_create</function> function
2492 and manually add enumeration value-name pairs by calling the
2493 <function>drm_property_add_enum</function> function. Care must be taken to
2494 properly specify the property type through the <parameter>flags</parameter>
2495 argument.
2496 </para>
2497 <para>
2498 After creating properties drivers can attach property instances to CRTC,
2499 connector and plane objects by calling the
2500 <function>drm_object_attach_property</function>. The function takes a
2501 pointer to the target object, a pointer to the previously created property
2502 and an initial instance value.
2503 </para>
6c6a3996
SK
2504 <sect2>
2505 <title>Existing KMS Properties</title>
2506 <para>
2507 The following table gives description of drm properties exposed by various
2508 modules/drivers.
2509 </para>
2510 <table border="1" cellpadding="0" cellspacing="0">
2511 <tbody>
2512 <tr style="font-weight: bold;">
2513 <td valign="top" >Owner Module/Drivers</td>
2514 <td valign="top" >Group</td>
2515 <td valign="top" >Property Name</td>
2516 <td valign="top" >Type</td>
2517 <td valign="top" >Property Values</td>
2518 <td valign="top" >Object attached</td>
2519 <td valign="top" >Description/Restrictions</td>
2520 </tr>
2521 <tr>
712a0dd9
SJ
2522 <td rowspan="37" valign="top" >DRM</td>
2523 <td valign="top" >Generic</td>
2524 <td valign="top" >“rotation”</td>
2525 <td valign="top" >BITMASK</td>
2526 <td valign="top" >{ 0, "rotate-0" },
2527 { 1, "rotate-90" },
2528 { 2, "rotate-180" },
2529 { 3, "rotate-270" },
2530 { 4, "reflect-x" },
2531 { 5, "reflect-y" }</td>
2532 <td valign="top" >CRTC, Plane</td>
2533 <td valign="top" >rotate-(degrees) rotates the image by the specified amount in degrees
2534 in counter clockwise direction. reflect-x and reflect-y reflects the
2535 image along the specified axis prior to rotation</td>
2536 </tr>
2537 <tr>
ae16c597 2538 <td rowspan="5" valign="top" >Connector</td>
6c6a3996
SK
2539 <td valign="top" >“EDID”</td>
2540 <td valign="top" >BLOB | IMMUTABLE</td>
2541 <td valign="top" >0</td>
2542 <td valign="top" >Connector</td>
2543 <td valign="top" >Contains id of edid blob ptr object.</td>
2544 </tr>
2545 <tr>
2546 <td valign="top" >“DPMS”</td>
2547 <td valign="top" >ENUM</td>
2548 <td valign="top" >{ “On”, “Standby”, “Suspend”, “Off” }</td>
2549 <td valign="top" >Connector</td>
2550 <td valign="top" >Contains DPMS operation mode value.</td>
2551 </tr>
2552 <tr>
cc7096fb
DA
2553 <td valign="top" >“PATH”</td>
2554 <td valign="top" >BLOB | IMMUTABLE</td>
2555 <td valign="top" >0</td>
2556 <td valign="top" >Connector</td>
2557 <td valign="top" >Contains topology path to a connector.</td>
2558 </tr>
2559 <tr>
6f134d7b
DA
2560 <td valign="top" >“TILE”</td>
2561 <td valign="top" >BLOB | IMMUTABLE</td>
2562 <td valign="top" >0</td>
2563 <td valign="top" >Connector</td>
2564 <td valign="top" >Contains tiling information for a connector.</td>
2565 </tr>
2566 <tr>
ae16c597
RC
2567 <td valign="top" >“CRTC_ID”</td>
2568 <td valign="top" >OBJECT</td>
2569 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2570 <td valign="top" >Connector</td>
2571 <td valign="top" >CRTC that connector is attached to (atomic)</td>
2572 </tr>
2573 <tr>
6b4959f4 2574 <td rowspan="11" valign="top" >Plane</td>
59748616
DL
2575 <td valign="top" >“type”</td>
2576 <td valign="top" >ENUM | IMMUTABLE</td>
2577 <td valign="top" >{ "Overlay", "Primary", "Cursor" }</td>
2578 <td valign="top" >Plane</td>
2579 <td valign="top" >Plane type</td>
2580 </tr>
2581 <tr>
6b4959f4
RC
2582 <td valign="top" >“SRC_X”</td>
2583 <td valign="top" >RANGE</td>
2584 <td valign="top" >Min=0, Max=UINT_MAX</td>
2585 <td valign="top" >Plane</td>
2586 <td valign="top" >Scanout source x coordinate in 16.16 fixed point (atomic)</td>
2587 </tr>
2588 <tr>
2589 <td valign="top" >“SRC_Y”</td>
2590 <td valign="top" >RANGE</td>
2591 <td valign="top" >Min=0, Max=UINT_MAX</td>
2592 <td valign="top" >Plane</td>
2593 <td valign="top" >Scanout source y coordinate in 16.16 fixed point (atomic)</td>
2594 </tr>
2595 <tr>
2596 <td valign="top" >“SRC_W”</td>
2597 <td valign="top" >RANGE</td>
2598 <td valign="top" >Min=0, Max=UINT_MAX</td>
2599 <td valign="top" >Plane</td>
2600 <td valign="top" >Scanout source width in 16.16 fixed point (atomic)</td>
2601 </tr>
2602 <tr>
2603 <td valign="top" >“SRC_H”</td>
2604 <td valign="top" >RANGE</td>
2605 <td valign="top" >Min=0, Max=UINT_MAX</td>
2606 <td valign="top" >Plane</td>
2607 <td valign="top" >Scanout source height in 16.16 fixed point (atomic)</td>
2608 </tr>
2609 <tr>
2610 <td valign="top" >“CRTC_X”</td>
2611 <td valign="top" >SIGNED_RANGE</td>
2612 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2613 <td valign="top" >Plane</td>
2614 <td valign="top" >Scanout CRTC (destination) x coordinate (atomic)</td>
2615 </tr>
2616 <tr>
2617 <td valign="top" >“CRTC_Y”</td>
2618 <td valign="top" >SIGNED_RANGE</td>
2619 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2620 <td valign="top" >Plane</td>
2621 <td valign="top" >Scanout CRTC (destination) y coordinate (atomic)</td>
2622 </tr>
2623 <tr>
2624 <td valign="top" >“CRTC_W”</td>
2625 <td valign="top" >RANGE</td>
2626 <td valign="top" >Min=0, Max=UINT_MAX</td>
2627 <td valign="top" >Plane</td>
2628 <td valign="top" >Scanout CRTC (destination) width (atomic)</td>
2629 </tr>
2630 <tr>
2631 <td valign="top" >“CRTC_H”</td>
2632 <td valign="top" >RANGE</td>
2633 <td valign="top" >Min=0, Max=UINT_MAX</td>
2634 <td valign="top" >Plane</td>
2635 <td valign="top" >Scanout CRTC (destination) height (atomic)</td>
2636 </tr>
2637 <tr>
2638 <td valign="top" >“FB_ID”</td>
2639 <td valign="top" >OBJECT</td>
2640 <td valign="top" >DRM_MODE_OBJECT_FB</td>
2641 <td valign="top" >Plane</td>
2642 <td valign="top" >Scanout framebuffer (atomic)</td>
2643 </tr>
2644 <tr>
2645 <td valign="top" >“CRTC_ID”</td>
2646 <td valign="top" >OBJECT</td>
2647 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2648 <td valign="top" >Plane</td>
2649 <td valign="top" >CRTC that plane is attached to (atomic)</td>
2650 </tr>
2651 <tr>
6c6a3996
SK
2652 <td rowspan="2" valign="top" >DVI-I</td>
2653 <td valign="top" >“subconnector”</td>
2654 <td valign="top" >ENUM</td>
2655 <td valign="top" >{ “Unknown”, “DVI-D”, “DVI-A” }</td>
2656 <td valign="top" >Connector</td>
2657 <td valign="top" >TBD</td>
2658 </tr>
2659 <tr>
2660 <td valign="top" >“select subconnector”</td>
2661 <td valign="top" >ENUM</td>
2662 <td valign="top" >{ “Automatic”, “DVI-D”, “DVI-A” }</td>
2663 <td valign="top" >Connector</td>
2664 <td valign="top" >TBD</td>
2665 </tr>
2666 <tr>
2667 <td rowspan="13" valign="top" >TV</td>
2668 <td valign="top" >“subconnector”</td>
2669 <td valign="top" >ENUM</td>
2670 <td valign="top" >{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" }</td>
2671 <td valign="top" >Connector</td>
2672 <td valign="top" >TBD</td>
2673 </tr>
2674 <tr>
2675 <td valign="top" >“select subconnector”</td>
2676 <td valign="top" >ENUM</td>
2677 <td valign="top" >{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" }</td>
2678 <td valign="top" >Connector</td>
2679 <td valign="top" >TBD</td>
2680 </tr>
2681 <tr>
2682 <td valign="top" >“mode”</td>
2683 <td valign="top" >ENUM</td>
2684 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2685 <td valign="top" >Connector</td>
2686 <td valign="top" >TBD</td>
2687 </tr>
2688 <tr>
2689 <td valign="top" >“left margin”</td>
2690 <td valign="top" >RANGE</td>
2691 <td valign="top" >Min=0, Max=100</td>
2692 <td valign="top" >Connector</td>
2693 <td valign="top" >TBD</td>
2694 </tr>
2695 <tr>
2696 <td valign="top" >“right margin”</td>
2697 <td valign="top" >RANGE</td>
2698 <td valign="top" >Min=0, Max=100</td>
2699 <td valign="top" >Connector</td>
2700 <td valign="top" >TBD</td>
2701 </tr>
2702 <tr>
2703 <td valign="top" >“top margin”</td>
2704 <td valign="top" >RANGE</td>
2705 <td valign="top" >Min=0, Max=100</td>
2706 <td valign="top" >Connector</td>
2707 <td valign="top" >TBD</td>
2708 </tr>
2709 <tr>
2710 <td valign="top" >“bottom margin”</td>
2711 <td valign="top" >RANGE</td>
2712 <td valign="top" >Min=0, Max=100</td>
2713 <td valign="top" >Connector</td>
2714 <td valign="top" >TBD</td>
2715 </tr>
2716 <tr>
2717 <td valign="top" >“brightness”</td>
2718 <td valign="top" >RANGE</td>
2719 <td valign="top" >Min=0, Max=100</td>
2720 <td valign="top" >Connector</td>
2721 <td valign="top" >TBD</td>
2722 </tr>
2723 <tr>
2724 <td valign="top" >“contrast”</td>
2725 <td valign="top" >RANGE</td>
2726 <td valign="top" >Min=0, Max=100</td>
2727 <td valign="top" >Connector</td>
2728 <td valign="top" >TBD</td>
2729 </tr>
2730 <tr>
2731 <td valign="top" >“flicker reduction”</td>
2732 <td valign="top" >RANGE</td>
2733 <td valign="top" >Min=0, Max=100</td>
2734 <td valign="top" >Connector</td>
2735 <td valign="top" >TBD</td>
2736 </tr>
2737 <tr>
2738 <td valign="top" >“overscan”</td>
2739 <td valign="top" >RANGE</td>
2740 <td valign="top" >Min=0, Max=100</td>
2741 <td valign="top" >Connector</td>
2742 <td valign="top" >TBD</td>
2743 </tr>
2744 <tr>
2745 <td valign="top" >“saturation”</td>
2746 <td valign="top" >RANGE</td>
2747 <td valign="top" >Min=0, Max=100</td>
2748 <td valign="top" >Connector</td>
2749 <td valign="top" >TBD</td>
2750 </tr>
2751 <tr>
2752 <td valign="top" >“hue”</td>
2753 <td valign="top" >RANGE</td>
2754 <td valign="top" >Min=0, Max=100</td>
2755 <td valign="top" >Connector</td>
2756 <td valign="top" >TBD</td>
2757 </tr>
2758 <tr>
5bb2bbf5
DA
2759 <td rowspan="2" valign="top" >Virtual GPU</td>
2760 <td valign="top" >“suggested X”</td>
2761 <td valign="top" >RANGE</td>
2762 <td valign="top" >Min=0, Max=0xffffffff</td>
2763 <td valign="top" >Connector</td>
2764 <td valign="top" >property to suggest an X offset for a connector</td>
2765 </tr>
2766 <tr>
2767 <td valign="top" >“suggested Y”</td>
2768 <td valign="top" >RANGE</td>
2769 <td valign="top" >Min=0, Max=0xffffffff</td>
2770 <td valign="top" >Connector</td>
2771 <td valign="top" >property to suggest an Y offset for a connector</td>
2772 </tr>
2773 <tr>
726a280d 2774 <td rowspan="3" valign="top" >Optional</td>
6c6a3996
SK
2775 <td valign="top" >“scaling mode”</td>
2776 <td valign="top" >ENUM</td>
2777 <td valign="top" >{ "None", "Full", "Center", "Full aspect" }</td>
2778 <td valign="top" >Connector</td>
2779 <td valign="top" >TBD</td>
2780 </tr>
2781 <tr>
726a280d
VK
2782 <td valign="top" >"aspect ratio"</td>
2783 <td valign="top" >ENUM</td>
2784 <td valign="top" >{ "None", "4:3", "16:9" }</td>
2785 <td valign="top" >Connector</td>
2786 <td valign="top" >DRM property to set aspect ratio from user space app.
2787 This enum is made generic to allow addition of custom aspect
2788 ratios.</td>
2789 </tr>
2790 <tr>
6c6a3996
SK
2791 <td valign="top" >“dirty”</td>
2792 <td valign="top" >ENUM | IMMUTABLE</td>
2793 <td valign="top" >{ "Off", "On", "Annotate" }</td>
2794 <td valign="top" >Connector</td>
2795 <td valign="top" >TBD</td>
2796 </tr>
2797 <tr>
712a0dd9 2798 <td rowspan="20" valign="top" >i915</td>
4ba08faa 2799 <td rowspan="2" valign="top" >Generic</td>
6c6a3996
SK
2800 <td valign="top" >"Broadcast RGB"</td>
2801 <td valign="top" >ENUM</td>
2802 <td valign="top" >{ "Automatic", "Full", "Limited 16:235" }</td>
2803 <td valign="top" >Connector</td>
2804 <td valign="top" >TBD</td>
2805 </tr>
2806 <tr>
2807 <td valign="top" >“audio”</td>
2808 <td valign="top" >ENUM</td>
2809 <td valign="top" >{ "force-dvi", "off", "auto", "on" }</td>
2810 <td valign="top" >Connector</td>
2811 <td valign="top" >TBD</td>
2812 </tr>
2813 <tr>
6c6a3996
SK
2814 <td rowspan="17" valign="top" >SDVO-TV</td>
2815 <td valign="top" >“mode”</td>
2816 <td valign="top" >ENUM</td>
2817 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2818 <td valign="top" >Connector</td>
2819 <td valign="top" >TBD</td>
2820 </tr>
2821 <tr>
2822 <td valign="top" >"left_margin"</td>
2823 <td valign="top" >RANGE</td>
2824 <td valign="top" >Min=0, Max= SDVO dependent</td>
2825 <td valign="top" >Connector</td>
2826 <td valign="top" >TBD</td>
2827 </tr>
2828 <tr>
2829 <td valign="top" >"right_margin"</td>
2830 <td valign="top" >RANGE</td>
2831 <td valign="top" >Min=0, Max= SDVO dependent</td>
2832 <td valign="top" >Connector</td>
2833 <td valign="top" >TBD</td>
2834 </tr>
2835 <tr>
2836 <td valign="top" >"top_margin"</td>
2837 <td valign="top" >RANGE</td>
2838 <td valign="top" >Min=0, Max= SDVO dependent</td>
2839 <td valign="top" >Connector</td>
2840 <td valign="top" >TBD</td>
2841 </tr>
2842 <tr>
2843 <td valign="top" >"bottom_margin"</td>
2844 <td valign="top" >RANGE</td>
2845 <td valign="top" >Min=0, Max= SDVO dependent</td>
2846 <td valign="top" >Connector</td>
2847 <td valign="top" >TBD</td>
2848 </tr>
2849 <tr>
2850 <td valign="top" >“hpos”</td>
2851 <td valign="top" >RANGE</td>
2852 <td valign="top" >Min=0, Max= SDVO dependent</td>
2853 <td valign="top" >Connector</td>
2854 <td valign="top" >TBD</td>
2855 </tr>
2856 <tr>
2857 <td valign="top" >“vpos”</td>
2858 <td valign="top" >RANGE</td>
2859 <td valign="top" >Min=0, Max= SDVO dependent</td>
2860 <td valign="top" >Connector</td>
2861 <td valign="top" >TBD</td>
2862 </tr>
2863 <tr>
2864 <td valign="top" >“contrast”</td>
2865 <td valign="top" >RANGE</td>
2866 <td valign="top" >Min=0, Max= SDVO dependent</td>
2867 <td valign="top" >Connector</td>
2868 <td valign="top" >TBD</td>
2869 </tr>
2870 <tr>
2871 <td valign="top" >“saturation”</td>
2872 <td valign="top" >RANGE</td>
2873 <td valign="top" >Min=0, Max= SDVO dependent</td>
2874 <td valign="top" >Connector</td>
2875 <td valign="top" >TBD</td>
2876 </tr>
2877 <tr>
2878 <td valign="top" >“hue”</td>
2879 <td valign="top" >RANGE</td>
2880 <td valign="top" >Min=0, Max= SDVO dependent</td>
2881 <td valign="top" >Connector</td>
2882 <td valign="top" >TBD</td>
2883 </tr>
2884 <tr>
2885 <td valign="top" >“sharpness”</td>
2886 <td valign="top" >RANGE</td>
2887 <td valign="top" >Min=0, Max= SDVO dependent</td>
2888 <td valign="top" >Connector</td>
2889 <td valign="top" >TBD</td>
2890 </tr>
2891 <tr>
2892 <td valign="top" >“flicker_filter”</td>
2893 <td valign="top" >RANGE</td>
2894 <td valign="top" >Min=0, Max= SDVO dependent</td>
2895 <td valign="top" >Connector</td>
2896 <td valign="top" >TBD</td>
2897 </tr>
2898 <tr>
2899 <td valign="top" >“flicker_filter_adaptive”</td>
2900 <td valign="top" >RANGE</td>
2901 <td valign="top" >Min=0, Max= SDVO dependent</td>
2902 <td valign="top" >Connector</td>
2903 <td valign="top" >TBD</td>
2904 </tr>
2905 <tr>
2906 <td valign="top" >“flicker_filter_2d”</td>
2907 <td valign="top" >RANGE</td>
2908 <td valign="top" >Min=0, Max= SDVO dependent</td>
2909 <td valign="top" >Connector</td>
2910 <td valign="top" >TBD</td>
2911 </tr>
2912 <tr>
2913 <td valign="top" >“tv_chroma_filter”</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 valign="top" >“tv_luma_filter”</td>
2921 <td valign="top" >RANGE</td>
2922 <td valign="top" >Min=0, Max= SDVO dependent</td>
2923 <td valign="top" >Connector</td>
2924 <td valign="top" >TBD</td>
2925 </tr>
2926 <tr>
2927 <td valign="top" >“dot_crawl”</td>
2928 <td valign="top" >RANGE</td>
2929 <td valign="top" >Min=0, Max=1</td>
2930 <td valign="top" >Connector</td>
2931 <td valign="top" >TBD</td>
2932 </tr>
2933 <tr>
2934 <td valign="top" >SDVO-TV/LVDS</td>
2935 <td valign="top" >“brightness”</td>
2936 <td valign="top" >RANGE</td>
2937 <td valign="top" >Min=0, Max= SDVO dependent</td>
2938 <td valign="top" >Connector</td>
2939 <td valign="top" >TBD</td>
2940 </tr>
2941 <tr>
4ba08faa
SK
2942 <td rowspan="2" valign="top" >CDV gma-500</td>
2943 <td rowspan="2" valign="top" >Generic</td>
6c6a3996
SK
2944 <td valign="top" >"Broadcast RGB"</td>
2945 <td valign="top" >ENUM</td>
2946 <td valign="top" >{ “Full”, “Limited 16:235” }</td>
2947 <td valign="top" >Connector</td>
2948 <td valign="top" >TBD</td>
2949 </tr>
2950 <tr>
2951 <td valign="top" >"Broadcast RGB"</td>
2952 <td valign="top" >ENUM</td>
2953 <td valign="top" >{ “off”, “auto”, “on” }</td>
2954 <td valign="top" >Connector</td>
2955 <td valign="top" >TBD</td>
2956 </tr>
2957 <tr>
4ba08faa
SK
2958 <td rowspan="19" valign="top" >Poulsbo</td>
2959 <td rowspan="1" valign="top" >Generic</td>
6c6a3996
SK
2960 <td valign="top" >“backlight”</td>
2961 <td valign="top" >RANGE</td>
2962 <td valign="top" >Min=0, Max=100</td>
2963 <td valign="top" >Connector</td>
2964 <td valign="top" >TBD</td>
2965 </tr>
2966 <tr>
6c6a3996
SK
2967 <td rowspan="17" valign="top" >SDVO-TV</td>
2968 <td valign="top" >“mode”</td>
2969 <td valign="top" >ENUM</td>
2970 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2971 <td valign="top" >Connector</td>
2972 <td valign="top" >TBD</td>
2973 </tr>
2974 <tr>
2975 <td valign="top" >"left_margin"</td>
2976 <td valign="top" >RANGE</td>
2977 <td valign="top" >Min=0, Max= SDVO dependent</td>
2978 <td valign="top" >Connector</td>
2979 <td valign="top" >TBD</td>
2980 </tr>
2981 <tr>
2982 <td valign="top" >"right_margin"</td>
2983 <td valign="top" >RANGE</td>
2984 <td valign="top" >Min=0, Max= SDVO dependent</td>
2985 <td valign="top" >Connector</td>
2986 <td valign="top" >TBD</td>
2987 </tr>
2988 <tr>
2989 <td valign="top" >"top_margin"</td>
2990 <td valign="top" >RANGE</td>
2991 <td valign="top" >Min=0, Max= SDVO dependent</td>
2992 <td valign="top" >Connector</td>
2993 <td valign="top" >TBD</td>
2994 </tr>
2995 <tr>
2996 <td valign="top" >"bottom_margin"</td>
2997 <td valign="top" >RANGE</td>
2998 <td valign="top" >Min=0, Max= SDVO dependent</td>
2999 <td valign="top" >Connector</td>
3000 <td valign="top" >TBD</td>
3001 </tr>
3002 <tr>
3003 <td valign="top" >“hpos”</td>
3004 <td valign="top" >RANGE</td>
3005 <td valign="top" >Min=0, Max= SDVO dependent</td>
3006 <td valign="top" >Connector</td>
3007 <td valign="top" >TBD</td>
3008 </tr>
3009 <tr>
3010 <td valign="top" >“vpos”</td>
3011 <td valign="top" >RANGE</td>
3012 <td valign="top" >Min=0, Max= SDVO dependent</td>
3013 <td valign="top" >Connector</td>
3014 <td valign="top" >TBD</td>
3015 </tr>
3016 <tr>
3017 <td valign="top" >“contrast”</td>
3018 <td valign="top" >RANGE</td>
3019 <td valign="top" >Min=0, Max= SDVO dependent</td>
3020 <td valign="top" >Connector</td>
3021 <td valign="top" >TBD</td>
3022 </tr>
3023 <tr>
3024 <td valign="top" >“saturation”</td>
3025 <td valign="top" >RANGE</td>
3026 <td valign="top" >Min=0, Max= SDVO dependent</td>
3027 <td valign="top" >Connector</td>
3028 <td valign="top" >TBD</td>
3029 </tr>
3030 <tr>
3031 <td valign="top" >“hue”</td>
3032 <td valign="top" >RANGE</td>
3033 <td valign="top" >Min=0, Max= SDVO dependent</td>
3034 <td valign="top" >Connector</td>
3035 <td valign="top" >TBD</td>
3036 </tr>
3037 <tr>
3038 <td valign="top" >“sharpness”</td>
3039 <td valign="top" >RANGE</td>
3040 <td valign="top" >Min=0, Max= SDVO dependent</td>
3041 <td valign="top" >Connector</td>
3042 <td valign="top" >TBD</td>
3043 </tr>
3044 <tr>
3045 <td valign="top" >“flicker_filter”</td>
3046 <td valign="top" >RANGE</td>
3047 <td valign="top" >Min=0, Max= SDVO dependent</td>
3048 <td valign="top" >Connector</td>
3049 <td valign="top" >TBD</td>
3050 </tr>
3051 <tr>
3052 <td valign="top" >“flicker_filter_adaptive”</td>
3053 <td valign="top" >RANGE</td>
3054 <td valign="top" >Min=0, Max= SDVO dependent</td>
3055 <td valign="top" >Connector</td>
3056 <td valign="top" >TBD</td>
3057 </tr>
3058 <tr>
3059 <td valign="top" >“flicker_filter_2d”</td>
3060 <td valign="top" >RANGE</td>
3061 <td valign="top" >Min=0, Max= SDVO dependent</td>
3062 <td valign="top" >Connector</td>
3063 <td valign="top" >TBD</td>
3064 </tr>
3065 <tr>
3066 <td valign="top" >“tv_chroma_filter”</td>
3067 <td valign="top" >RANGE</td>
3068 <td valign="top" >Min=0, Max= SDVO dependent</td>
3069 <td valign="top" >Connector</td>
3070 <td valign="top" >TBD</td>
3071 </tr>
3072 <tr>
3073 <td valign="top" >“tv_luma_filter”</td>
3074 <td valign="top" >RANGE</td>
3075 <td valign="top" >Min=0, Max= SDVO dependent</td>
3076 <td valign="top" >Connector</td>
3077 <td valign="top" >TBD</td>
3078 </tr>
3079 <tr>
3080 <td valign="top" >“dot_crawl”</td>
3081 <td valign="top" >RANGE</td>
3082 <td valign="top" >Min=0, Max=1</td>
3083 <td valign="top" >Connector</td>
3084 <td valign="top" >TBD</td>
3085 </tr>
3086 <tr>
3087 <td valign="top" >SDVO-TV/LVDS</td>
3088 <td valign="top" >“brightness”</td>
3089 <td valign="top" >RANGE</td>
3090 <td valign="top" >Min=0, Max= SDVO dependent</td>
3091 <td valign="top" >Connector</td>
3092 <td valign="top" >TBD</td>
3093 </tr>
3094 <tr>
3095 <td rowspan="11" valign="top" >armada</td>
3096 <td rowspan="2" valign="top" >CRTC</td>
3097 <td valign="top" >"CSC_YUV"</td>
3098 <td valign="top" >ENUM</td>
3099 <td valign="top" >{ "Auto" , "CCIR601", "CCIR709" }</td>
3100 <td valign="top" >CRTC</td>
3101 <td valign="top" >TBD</td>
3102 </tr>
3103 <tr>
3104 <td valign="top" >"CSC_RGB"</td>
3105 <td valign="top" >ENUM</td>
3106 <td valign="top" >{ "Auto", "Computer system", "Studio" }</td>
3107 <td valign="top" >CRTC</td>
3108 <td valign="top" >TBD</td>
3109 </tr>
3110 <tr>
3111 <td rowspan="9" valign="top" >Overlay</td>
3112 <td valign="top" >"colorkey"</td>
3113 <td valign="top" >RANGE</td>
3114 <td valign="top" >Min=0, Max=0xffffff</td>
3115 <td valign="top" >Plane</td>
3116 <td valign="top" >TBD</td>
3117 </tr>
3118 <tr>
3119 <td valign="top" >"colorkey_min"</td>
3120 <td valign="top" >RANGE</td>
3121 <td valign="top" >Min=0, Max=0xffffff</td>
3122 <td valign="top" >Plane</td>
3123 <td valign="top" >TBD</td>
3124 </tr>
3125 <tr>
3126 <td valign="top" >"colorkey_max"</td>
3127 <td valign="top" >RANGE</td>
3128 <td valign="top" >Min=0, Max=0xffffff</td>
3129 <td valign="top" >Plane</td>
3130 <td valign="top" >TBD</td>
3131 </tr>
3132 <tr>
3133 <td valign="top" >"colorkey_val"</td>
3134 <td valign="top" >RANGE</td>
3135 <td valign="top" >Min=0, Max=0xffffff</td>
3136 <td valign="top" >Plane</td>
3137 <td valign="top" >TBD</td>
3138 </tr>
3139 <tr>
3140 <td valign="top" >"colorkey_alpha"</td>
3141 <td valign="top" >RANGE</td>
3142 <td valign="top" >Min=0, Max=0xffffff</td>
3143 <td valign="top" >Plane</td>
3144 <td valign="top" >TBD</td>
3145 </tr>
3146 <tr>
3147 <td valign="top" >"colorkey_mode"</td>
3148 <td valign="top" >ENUM</td>
3149 <td valign="top" >{ "disabled", "Y component", "U component"
3150 , "V component", "RGB", “R component", "G component", "B component" }</td>
3151 <td valign="top" >Plane</td>
3152 <td valign="top" >TBD</td>
3153 </tr>
3154 <tr>
3155 <td valign="top" >"brightness"</td>
3156 <td valign="top" >RANGE</td>
3157 <td valign="top" >Min=0, Max=256 + 255</td>
3158 <td valign="top" >Plane</td>
3159 <td valign="top" >TBD</td>
3160 </tr>
3161 <tr>
3162 <td valign="top" >"contrast"</td>
3163 <td valign="top" >RANGE</td>
3164 <td valign="top" >Min=0, Max=0x7fff</td>
3165 <td valign="top" >Plane</td>
3166 <td valign="top" >TBD</td>
3167 </tr>
3168 <tr>
3169 <td valign="top" >"saturation"</td>
3170 <td valign="top" >RANGE</td>
3171 <td valign="top" >Min=0, Max=0x7fff</td>
3172 <td valign="top" >Plane</td>
3173 <td valign="top" >TBD</td>
3174 </tr>
3175 <tr>
3176 <td rowspan="2" valign="top" >exynos</td>
3177 <td valign="top" >CRTC</td>
3178 <td valign="top" >“mode”</td>
3179 <td valign="top" >ENUM</td>
3180 <td valign="top" >{ "normal", "blank" }</td>
3181 <td valign="top" >CRTC</td>
3182 <td valign="top" >TBD</td>
3183 </tr>
3184 <tr>
3185 <td valign="top" >Overlay</td>
3186 <td valign="top" >“zpos”</td>
3187 <td valign="top" >RANGE</td>
3188 <td valign="top" >Min=0, Max=MAX_PLANE-1</td>
3189 <td valign="top" >Plane</td>
3190 <td valign="top" >TBD</td>
3191 </tr>
3192 <tr>
4ba08faa 3193 <td rowspan="2" valign="top" >i2c/ch7006_drv</td>
6c6a3996
SK
3194 <td valign="top" >Generic</td>
3195 <td valign="top" >“scale”</td>
3196 <td valign="top" >RANGE</td>
3197 <td valign="top" >Min=0, Max=2</td>
3198 <td valign="top" >Connector</td>
3199 <td valign="top" >TBD</td>
3200 </tr>
3201 <tr>
4ba08faa 3202 <td rowspan="1" valign="top" >TV</td>
6c6a3996
SK
3203 <td valign="top" >“mode”</td>
3204 <td valign="top" >ENUM</td>
3205 <td valign="top" >{ "PAL", "PAL-M","PAL-N"}, ”PAL-Nc"
3206 , "PAL-60", "NTSC-M", "NTSC-J" }</td>
3207 <td valign="top" >Connector</td>
3208 <td valign="top" >TBD</td>
3209 </tr>
3210 <tr>
4ba08faa 3211 <td rowspan="15" valign="top" >nouveau</td>
6c6a3996
SK
3212 <td rowspan="6" valign="top" >NV10 Overlay</td>
3213 <td valign="top" >"colorkey"</td>
3214 <td valign="top" >RANGE</td>
3215 <td valign="top" >Min=0, Max=0x01ffffff</td>
3216 <td valign="top" >Plane</td>
3217 <td valign="top" >TBD</td>
3218 </tr>
3219 <tr>
3220 <td valign="top" >“contrast”</td>
3221 <td valign="top" >RANGE</td>
3222 <td valign="top" >Min=0, Max=8192-1</td>
3223 <td valign="top" >Plane</td>
3224 <td valign="top" >TBD</td>
3225 </tr>
3226 <tr>
3227 <td valign="top" >“brightness”</td>
3228 <td valign="top" >RANGE</td>
3229 <td valign="top" >Min=0, Max=1024</td>
3230 <td valign="top" >Plane</td>
3231 <td valign="top" >TBD</td>
3232 </tr>
3233 <tr>
3234 <td valign="top" >“hue”</td>
3235 <td valign="top" >RANGE</td>
3236 <td valign="top" >Min=0, Max=359</td>
3237 <td valign="top" >Plane</td>
3238 <td valign="top" >TBD</td>
3239 </tr>
3240 <tr>
3241 <td valign="top" >“saturation”</td>
3242 <td valign="top" >RANGE</td>
3243 <td valign="top" >Min=0, Max=8192-1</td>
3244 <td valign="top" >Plane</td>
3245 <td valign="top" >TBD</td>
3246 </tr>
3247 <tr>
3248 <td valign="top" >“iturbt_709”</td>
3249 <td valign="top" >RANGE</td>
3250 <td valign="top" >Min=0, Max=1</td>
3251 <td valign="top" >Plane</td>
3252 <td valign="top" >TBD</td>
3253 </tr>
3254 <tr>
3255 <td rowspan="2" valign="top" >Nv04 Overlay</td>
3256 <td valign="top" >“colorkey”</td>
3257 <td valign="top" >RANGE</td>
3258 <td valign="top" >Min=0, Max=0x01ffffff</td>
3259 <td valign="top" >Plane</td>
3260 <td valign="top" >TBD</td>
3261 </tr>
3262 <tr>
3263 <td valign="top" >“brightness”</td>
3264 <td valign="top" >RANGE</td>
3265 <td valign="top" >Min=0, Max=1024</td>
3266 <td valign="top" >Plane</td>
3267 <td valign="top" >TBD</td>
3268 </tr>
3269 <tr>
3270 <td rowspan="7" valign="top" >Display</td>
3271 <td valign="top" >“dithering mode”</td>
3272 <td valign="top" >ENUM</td>
3273 <td valign="top" >{ "auto", "off", "on" }</td>
3274 <td valign="top" >Connector</td>
3275 <td valign="top" >TBD</td>
3276 </tr>
3277 <tr>
3278 <td valign="top" >“dithering depth”</td>
3279 <td valign="top" >ENUM</td>
3280 <td valign="top" >{ "auto", "off", "on", "static 2x2", "dynamic 2x2", "temporal" }</td>
3281 <td valign="top" >Connector</td>
3282 <td valign="top" >TBD</td>
3283 </tr>
3284 <tr>
3285 <td valign="top" >“underscan”</td>
3286 <td valign="top" >ENUM</td>
3287 <td valign="top" >{ "auto", "6 bpc", "8 bpc" }</td>
3288 <td valign="top" >Connector</td>
3289 <td valign="top" >TBD</td>
3290 </tr>
3291 <tr>
3292 <td valign="top" >“underscan hborder”</td>
3293 <td valign="top" >RANGE</td>
3294 <td valign="top" >Min=0, Max=128</td>
3295 <td valign="top" >Connector</td>
3296 <td valign="top" >TBD</td>
3297 </tr>
3298 <tr>
3299 <td valign="top" >“underscan vborder”</td>
3300 <td valign="top" >RANGE</td>
3301 <td valign="top" >Min=0, Max=128</td>
3302 <td valign="top" >Connector</td>
3303 <td valign="top" >TBD</td>
3304 </tr>
3305 <tr>
3306 <td valign="top" >“vibrant hue”</td>
3307 <td valign="top" >RANGE</td>
3308 <td valign="top" >Min=0, Max=180</td>
3309 <td valign="top" >Connector</td>
3310 <td valign="top" >TBD</td>
3311 </tr>
3312 <tr>
3313 <td valign="top" >“color vibrance”</td>
3314 <td valign="top" >RANGE</td>
3315 <td valign="top" >Min=0, Max=200</td>
3316 <td valign="top" >Connector</td>
3317 <td valign="top" >TBD</td>
3318 </tr>
3319 <tr>
d4acc165 3320 <td valign="top" >omap</td>
712a0dd9 3321 <td valign="top" >Generic</td>
6c6a3996
SK
3322 <td valign="top" >“zorder”</td>
3323 <td valign="top" >RANGE</td>
3324 <td valign="top" >Min=0, Max=3</td>
3325 <td valign="top" >CRTC, Plane</td>
3326 <td valign="top" >TBD</td>
3327 </tr>
3328 <tr>
3329 <td valign="top" >qxl</td>
3330 <td valign="top" >Generic</td>
3331 <td valign="top" >“hotplug_mode_update"</td>
3332 <td valign="top" >RANGE</td>
3333 <td valign="top" >Min=0, Max=1</td>
3334 <td valign="top" >Connector</td>
3335 <td valign="top" >TBD</td>
3336 </tr>
3337 <tr>
4ba08faa 3338 <td rowspan="9" valign="top" >radeon</td>
6c6a3996
SK
3339 <td valign="top" >DVI-I</td>
3340 <td valign="top" >“coherent”</td>
3341 <td valign="top" >RANGE</td>
3342 <td valign="top" >Min=0, Max=1</td>
3343 <td valign="top" >Connector</td>
3344 <td valign="top" >TBD</td>
3345 </tr>
3346 <tr>
3347 <td valign="top" >DAC enable load detect</td>
3348 <td valign="top" >“load detection”</td>
3349 <td valign="top" >RANGE</td>
3350 <td valign="top" >Min=0, Max=1</td>
3351 <td valign="top" >Connector</td>
3352 <td valign="top" >TBD</td>
3353 </tr>
3354 <tr>
3355 <td valign="top" >TV Standard</td>
3356 <td valign="top" >"tv standard"</td>
3357 <td valign="top" >ENUM</td>
3358 <td valign="top" >{ "ntsc", "pal", "pal-m", "pal-60", "ntsc-j"
3359 , "scart-pal", "pal-cn", "secam" }</td>
3360 <td valign="top" >Connector</td>
3361 <td valign="top" >TBD</td>
3362 </tr>
3363 <tr>
3364 <td valign="top" >legacy TMDS PLL detect</td>
3365 <td valign="top" >"tmds_pll"</td>
3366 <td valign="top" >ENUM</td>
3367 <td valign="top" >{ "driver", "bios" }</td>
3368 <td valign="top" >-</td>
3369 <td valign="top" >TBD</td>
3370 </tr>
3371 <tr>
3372 <td rowspan="3" valign="top" >Underscan</td>
3373 <td valign="top" >"underscan"</td>
3374 <td valign="top" >ENUM</td>
3375 <td valign="top" >{ "off", "on", "auto" }</td>
3376 <td valign="top" >Connector</td>
3377 <td valign="top" >TBD</td>
3378 </tr>
3379 <tr>
3380 <td valign="top" >"underscan hborder"</td>
3381 <td valign="top" >RANGE</td>
3382 <td valign="top" >Min=0, Max=128</td>
3383 <td valign="top" >Connector</td>
3384 <td valign="top" >TBD</td>
3385 </tr>
3386 <tr>
3387 <td valign="top" >"underscan vborder"</td>
3388 <td valign="top" >RANGE</td>
3389 <td valign="top" >Min=0, Max=128</td>
3390 <td valign="top" >Connector</td>
3391 <td valign="top" >TBD</td>
3392 </tr>
3393 <tr>
3394 <td valign="top" >Audio</td>
3395 <td valign="top" >“audio”</td>
3396 <td valign="top" >ENUM</td>
3397 <td valign="top" >{ "off", "on", "auto" }</td>
3398 <td valign="top" >Connector</td>
3399 <td valign="top" >TBD</td>
3400 </tr>
3401 <tr>
3402 <td valign="top" >FMT Dithering</td>
3403 <td valign="top" >“dither”</td>
3404 <td valign="top" >ENUM</td>
3405 <td valign="top" >{ "off", "on" }</td>
3406 <td valign="top" >Connector</td>
3407 <td valign="top" >TBD</td>
3408 </tr>
3409 <tr>
6c6a3996
SK
3410 <td rowspan="3" valign="top" >rcar-du</td>
3411 <td rowspan="3" valign="top" >Generic</td>
3412 <td valign="top" >"alpha"</td>
3413 <td valign="top" >RANGE</td>
3414 <td valign="top" >Min=0, Max=255</td>
3415 <td valign="top" >Plane</td>
3416 <td valign="top" >TBD</td>
3417 </tr>
3418 <tr>
3419 <td valign="top" >"colorkey"</td>
3420 <td valign="top" >RANGE</td>
3421 <td valign="top" >Min=0, Max=0x01ffffff</td>
3422 <td valign="top" >Plane</td>
3423 <td valign="top" >TBD</td>
3424 </tr>
3425 <tr>
3426 <td valign="top" >"zpos"</td>
3427 <td valign="top" >RANGE</td>
3428 <td valign="top" >Min=1, Max=7</td>
3429 <td valign="top" >Plane</td>
3430 <td valign="top" >TBD</td>
3431 </tr>
3432 </tbody>
3433 </table>
3434 </sect2>
2d2ef822
JB
3435 </sect1>
3436
9cad9c95
LP
3437 <!-- Internals: vertical blanking -->
3438
3439 <sect1 id="drm-vertical-blank">
3440 <title>Vertical Blanking</title>
3441 <para>
3442 Vertical blanking plays a major role in graphics rendering. To achieve
3443 tear-free display, users must synchronize page flips and/or rendering to
3444 vertical blanking. The DRM API offers ioctls to perform page flips
3445 synchronized to vertical blanking and wait for vertical blanking.
3446 </para>
3447 <para>
3448 The DRM core handles most of the vertical blanking management logic, which
3449 involves filtering out spurious interrupts, keeping race-free blanking
3450 counters, coping with counter wrap-around and resets and keeping use
3451 counts. It relies on the driver to generate vertical blanking interrupts
3452 and optionally provide a hardware vertical blanking counter. Drivers must
3453 implement the following operations.
3454 </para>
3455 <itemizedlist>
3456 <listitem>
3457 <synopsis>int (*enable_vblank) (struct drm_device *dev, int crtc);
3458void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
3459 <para>
3460 Enable or disable vertical blanking interrupts for the given CRTC.
3461 </para>
3462 </listitem>
3463 <listitem>
3464 <synopsis>u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);</synopsis>
3465 <para>
3466 Retrieve the value of the vertical blanking counter for the given
3467 CRTC. If the hardware maintains a vertical blanking counter its value
3468 should be returned. Otherwise drivers can use the
3469 <function>drm_vblank_count</function> helper function to handle this
3470 operation.
3471 </para>
3472 </listitem>
3473 </itemizedlist>
2d2ef822 3474 <para>
9cad9c95
LP
3475 Drivers must initialize the vertical blanking handling core with a call to
3476 <function>drm_vblank_init</function> in their
3477 <methodname>load</methodname> operation. The function will set the struct
3478 <structname>drm_device</structname>
3479 <structfield>vblank_disable_allowed</structfield> field to 0. This will
3480 keep vertical blanking interrupts enabled permanently until the first mode
3481 set operation, where <structfield>vblank_disable_allowed</structfield> is
3482 set to 1. The reason behind this is not clear. Drivers can set the field
3483 to 1 after <function>calling drm_vblank_init</function> to make vertical
3484 blanking interrupts dynamically managed from the beginning.
2d2ef822 3485 </para>
9cad9c95
LP
3486 <para>
3487 Vertical blanking interrupts can be enabled by the DRM core or by drivers
3488 themselves (for instance to handle page flipping operations). The DRM core
3489 maintains a vertical blanking use count to ensure that the interrupts are
3490 not disabled while a user still needs them. To increment the use count,
3491 drivers call <function>drm_vblank_get</function>. Upon return vertical
3492 blanking interrupts are guaranteed to be enabled.
3493 </para>
3494 <para>
3495 To decrement the use count drivers call
3496 <function>drm_vblank_put</function>. Only when the use count drops to zero
3497 will the DRM core disable the vertical blanking interrupts after a delay
3498 by scheduling a timer. The delay is accessible through the vblankoffdelay
3499 module parameter or the <varname>drm_vblank_offdelay</varname> global
3500 variable and expressed in milliseconds. Its default value is 5000 ms.
4ed0ce3d 3501 Zero means never disable, and a negative value means disable immediately.
00185e66
VS
3502 Drivers may override the behaviour by setting the
3503 <structname>drm_device</structname>
3504 <structfield>vblank_disable_immediate</structfield> flag, which when set
3505 causes vblank interrupts to be disabled immediately regardless of the
3506 drm_vblank_offdelay value. The flag should only be set if there's a
3507 properly working hardware vblank counter present.
9cad9c95
LP
3508 </para>
3509 <para>
3510 When a vertical blanking interrupt occurs drivers only need to call the
3511 <function>drm_handle_vblank</function> function to account for the
3512 interrupt.
3513 </para>
3514 <para>
3515 Resources allocated by <function>drm_vblank_init</function> must be freed
3516 with a call to <function>drm_vblank_cleanup</function> in the driver
3517 <methodname>unload</methodname> operation handler.
3518 </para>
f5752b38
DV
3519 <sect2>
3520 <title>Vertical Blanking and Interrupt Handling Functions Reference</title>
3521!Edrivers/gpu/drm/drm_irq.c
d743ecf3 3522!Finclude/drm/drmP.h drm_crtc_vblank_waitqueue
f5752b38 3523 </sect2>
9cad9c95
LP
3524 </sect1>
3525
3526 <!-- Internals: open/close, file operations and ioctls -->
2d2ef822 3527
9cad9c95
LP
3528 <sect1>
3529 <title>Open/Close, File Operations and IOCTLs</title>
2d2ef822 3530 <sect2>
9cad9c95
LP
3531 <title>Open and Close</title>
3532 <synopsis>int (*firstopen) (struct drm_device *);
3533void (*lastclose) (struct drm_device *);
3534int (*open) (struct drm_device *, struct drm_file *);
3535void (*preclose) (struct drm_device *, struct drm_file *);
3536void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
3537 <abstract>Open and close handlers. None of those methods are mandatory.
3538 </abstract>
2d2ef822 3539 <para>
9cad9c95 3540 The <methodname>firstopen</methodname> method is called by the DRM core
7d14bb6b
DV
3541 for legacy UMS (User Mode Setting) drivers only when an application
3542 opens a device that has no other opened file handle. UMS drivers can
3543 implement it to acquire device resources. KMS drivers can't use the
3544 method and must acquire resources in the <methodname>load</methodname>
3545 method instead.
2d2ef822
JB
3546 </para>
3547 <para>
7d14bb6b
DV
3548 Similarly the <methodname>lastclose</methodname> method is called when
3549 the last application holding a file handle opened on the device closes
3550 it, for both UMS and KMS drivers. Additionally, the method is also
3551 called at module unload time or, for hot-pluggable devices, when the
3552 device is unplugged. The <methodname>firstopen</methodname> and
9cad9c95 3553 <methodname>lastclose</methodname> calls can thus be unbalanced.
2d2ef822
JB
3554 </para>
3555 <para>
9cad9c95
LP
3556 The <methodname>open</methodname> method is called every time the device
3557 is opened by an application. Drivers can allocate per-file private data
3558 in this method and store them in the struct
3559 <structname>drm_file</structname> <structfield>driver_priv</structfield>
3560 field. Note that the <methodname>open</methodname> method is called
3561 before <methodname>firstopen</methodname>.
3562 </para>
3563 <para>
3564 The close operation is split into <methodname>preclose</methodname> and
3565 <methodname>postclose</methodname> methods. Drivers must stop and
3566 cleanup all per-file operations in the <methodname>preclose</methodname>
3567 method. For instance pending vertical blanking and page flip events must
3568 be cancelled. No per-file operation is allowed on the file handle after
3569 returning from the <methodname>preclose</methodname> method.
3570 </para>
3571 <para>
3572 Finally the <methodname>postclose</methodname> method is called as the
3573 last step of the close operation, right before calling the
3574 <methodname>lastclose</methodname> method if no other open file handle
3575 exists for the device. Drivers that have allocated per-file private data
3576 in the <methodname>open</methodname> method should free it here.
3577 </para>
3578 <para>
3579 The <methodname>lastclose</methodname> method should restore CRTC and
3580 plane properties to default value, so that a subsequent open of the
7d14bb6b
DV
3581 device will not inherit state from the previous user. It can also be
3582 used to execute delayed power switching state changes, e.g. in
6648f487
LW
3583 conjunction with the vga_switcheroo infrastructure (see
3584 <xref linkend="vga_switcheroo"/>). Beyond that KMS drivers should not
3585 do any further cleanup. Only legacy UMS drivers might need to clean up
3586 device state so that the vga console or an independent fbdev driver
3587 could take over.
2d2ef822
JB
3588 </para>
3589 </sect2>
2d2ef822 3590 <sect2>
9cad9c95
LP
3591 <title>File Operations</title>
3592 <synopsis>const struct file_operations *fops</synopsis>
3593 <abstract>File operations for the DRM device node.</abstract>
2d2ef822 3594 <para>
9cad9c95
LP
3595 Drivers must define the file operations structure that forms the DRM
3596 userspace API entry point, even though most of those operations are
3597 implemented in the DRM core. The <methodname>open</methodname>,
3598 <methodname>release</methodname> and <methodname>ioctl</methodname>
3599 operations are handled by
3600 <programlisting>
3601 .owner = THIS_MODULE,
3602 .open = drm_open,
3603 .release = drm_release,
3604 .unlocked_ioctl = drm_ioctl,
3605 #ifdef CONFIG_COMPAT
3606 .compat_ioctl = drm_compat_ioctl,
3607 #endif
3608 </programlisting>
2d2ef822
JB
3609 </para>
3610 <para>
9cad9c95
LP
3611 Drivers that implement private ioctls that requires 32/64bit
3612 compatibility support must provide their own
3613 <methodname>compat_ioctl</methodname> handler that processes private
3614 ioctls and calls <function>drm_compat_ioctl</function> for core ioctls.
2d2ef822
JB
3615 </para>
3616 <para>
9cad9c95
LP
3617 The <methodname>read</methodname> and <methodname>poll</methodname>
3618 operations provide support for reading DRM events and polling them. They
3619 are implemented by
3620 <programlisting>
3621 .poll = drm_poll,
3622 .read = drm_read,
9cad9c95
LP
3623 .llseek = no_llseek,
3624 </programlisting>
3625 </para>
3626 <para>
3627 The memory mapping implementation varies depending on how the driver
3628 manages memory. Pre-GEM drivers will use <function>drm_mmap</function>,
3629 while GEM-aware drivers will use <function>drm_gem_mmap</function>. See
3630 <xref linkend="drm-gem"/>.
3631 <programlisting>
3632 .mmap = drm_gem_mmap,
3633 </programlisting>
3634 </para>
3635 <para>
3636 No other file operation is supported by the DRM API.
3637 </para>
3638 </sect2>
3639 <sect2>
3640 <title>IOCTLs</title>
3641 <synopsis>struct drm_ioctl_desc *ioctls;
3642int num_ioctls;</synopsis>
3643 <abstract>Driver-specific ioctls descriptors table.</abstract>
3644 <para>
3645 Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
3646 descriptors table is indexed by the ioctl number offset from the base
3647 value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize the
3648 table entries.
3649 </para>
3650 <para>
3651 <programlisting>DRM_IOCTL_DEF_DRV(ioctl, func, flags)</programlisting>
3652 <para>
3653 <parameter>ioctl</parameter> is the ioctl name. Drivers must define
3654 the DRM_##ioctl and DRM_IOCTL_##ioctl macros to the ioctl number
3655 offset from DRM_COMMAND_BASE and the ioctl number respectively. The
3656 first macro is private to the device while the second must be exposed
3657 to userspace in a public header.
3658 </para>
3659 <para>
3660 <parameter>func</parameter> is a pointer to the ioctl handler function
3661 compatible with the <type>drm_ioctl_t</type> type.
3662 <programlisting>typedef int drm_ioctl_t(struct drm_device *dev, void *data,
3663 struct drm_file *file_priv);</programlisting>
3664 </para>
3665 <para>
3666 <parameter>flags</parameter> is a bitmask combination of the following
3667 values. It restricts how the ioctl is allowed to be called.
3668 <itemizedlist>
3669 <listitem><para>
3670 DRM_AUTH - Only authenticated callers allowed
3671 </para></listitem>
3672 <listitem><para>
3673 DRM_MASTER - The ioctl can only be called on the master file
3674 handle
3675 </para></listitem>
3676 <listitem><para>
3677 DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
3678 </para></listitem>
3679 <listitem><para>
3680 DRM_CONTROL_ALLOW - The ioctl can only be called on a control
3681 device
3682 </para></listitem>
3683 <listitem><para>
3684 DRM_UNLOCKED - The ioctl handler will be called without locking
ea487835
DV
3685 the DRM global mutex. This is the enforced default for kms drivers
3686 (i.e. using the DRIVER_MODESET flag) and hence shouldn't be used
3687 any more for new drivers.
9cad9c95
LP
3688 </para></listitem>
3689 </itemizedlist>
3690 </para>
2d2ef822 3691 </para>
0aaf20cf 3692!Edrivers/gpu/drm/drm_ioctl.c
2d2ef822 3693 </sect2>
2d2ef822 3694 </sect1>
2d2ef822 3695 <sect1>
4c6e2dfe 3696 <title>Legacy Support Code</title>
2d2ef822 3697 <para>
9a6594fc 3698 The section very briefly covers some of the old legacy support code which
4c6e2dfe
DV
3699 is only used by old DRM drivers which have done a so-called shadow-attach
3700 to the underlying device instead of registering as a real driver. This
9a6594fc 3701 also includes some of the old generic buffer management and command
4c6e2dfe 3702 submission code. Do not use any of this in new and modern drivers.
2d2ef822 3703 </para>
2d2ef822 3704
4c6e2dfe
DV
3705 <sect2>
3706 <title>Legacy Suspend/Resume</title>
3707 <para>
3708 The DRM core provides some suspend/resume code, but drivers wanting full
3709 suspend/resume support should provide save() and restore() functions.
3710 These are called at suspend, hibernate, or resume time, and should perform
3711 any state save or restore required by your device across suspend or
3712 hibernate states.
3713 </para>
3714 <synopsis>int (*suspend) (struct drm_device *, pm_message_t state);
3715 int (*resume) (struct drm_device *);</synopsis>
3716 <para>
3717 Those are legacy suspend and resume methods which
3718 <emphasis>only</emphasis> work with the legacy shadow-attach driver
3719 registration functions. New driver should use the power management
3720 interface provided by their bus type (usually through
3721 the struct <structname>device_driver</structname> dev_pm_ops) and set
3722 these methods to NULL.
3723 </para>
3724 </sect2>
3725
3726 <sect2>
3727 <title>Legacy DMA Services</title>
3728 <para>
3729 This should cover how DMA mapping etc. is supported by the core.
3730 These functions are deprecated and should not be used.
3731 </para>
3732 </sect2>
2d2ef822
JB
3733 </sect1>
3734 </chapter>
3735
9cad9c95
LP
3736<!-- TODO
3737
3738- Add a glossary
3739- Document the struct_mutex catch-all lock
3740- Document connector properties
3741
3742- Why is the load method optional?
3743- What are drivers supposed to set the initial display state to, and how?
3744 Connector's DPMS states are not initialized and are thus equal to
3745 DRM_MODE_DPMS_ON. The fbcon compatibility layer calls
3746 drm_helper_disable_unused_functions(), which disables unused encoders and
3747 CRTCs, but doesn't touch the connectors' DPMS state, and
3748 drm_helper_connector_dpms() in reaction to fbdev blanking events. Do drivers
3749 that don't implement (or just don't use) fbcon compatibility need to call
3750 those functions themselves?
3751- KMS drivers must call drm_vblank_pre_modeset() and drm_vblank_post_modeset()
3752 around mode setting. Should this be done in the DRM core?
3753- vblank_disable_allowed is set to 1 in the first drm_vblank_post_modeset()
3754 call and never set back to 0. It seems to be safe to permanently set it to 1
3755 in drm_vblank_init() for KMS driver, and it might be safe for UMS drivers as
3756 well. This should be investigated.
3757- crtc and connector .save and .restore operations are only used internally in
3758 drivers, should they be removed from the core?
3759- encoder mid-layer .save and .restore operations are only used internally in
3760 drivers, should they be removed from the core?
3761- encoder mid-layer .detect operation is only used internally in drivers,
3762 should it be removed from the core?
3763-->
3764
2d2ef822
JB
3765 <!-- External interfaces -->
3766
3767 <chapter id="drmExternals">
3768 <title>Userland interfaces</title>
3769 <para>
3770 The DRM core exports several interfaces to applications,
3771 generally intended to be used through corresponding libdrm
a5294e01 3772 wrapper functions. In addition, drivers export device-specific
7f0925ac 3773 interfaces for use by userspace drivers &amp; device-aware
2d2ef822
JB
3774 applications through ioctls and sysfs files.
3775 </para>
3776 <para>
3777 External interfaces include: memory mapping, context management,
3778 DMA operations, AGP management, vblank control, fence
3779 management, memory management, and output management.
3780 </para>
3781 <para>
bcd3cfc1
MW
3782 Cover generic ioctls and sysfs layout here. We only need high-level
3783 info, since man pages should cover the rest.
2d2ef822 3784 </para>
9cad9c95 3785
1793126f
DH
3786 <!-- External: render nodes -->
3787
3788 <sect1>
3789 <title>Render nodes</title>
3790 <para>
3791 DRM core provides multiple character-devices for user-space to use.
3792 Depending on which device is opened, user-space can perform a different
3793 set of operations (mainly ioctls). The primary node is always created
00153aeb
DV
3794 and called card&lt;num&gt;. Additionally, a currently
3795 unused control node, called controlD&lt;num&gt; is also
1793126f
DH
3796 created. The primary node provides all legacy operations and
3797 historically was the only interface used by userspace. With KMS, the
3798 control node was introduced. However, the planned KMS control interface
3799 has never been written and so the control node stays unused to date.
3800 </para>
3801 <para>
3802 With the increased use of offscreen renderers and GPGPU applications,
3803 clients no longer require running compositors or graphics servers to
3804 make use of a GPU. But the DRM API required unprivileged clients to
3805 authenticate to a DRM-Master prior to getting GPU access. To avoid this
3806 step and to grant clients GPU access without authenticating, render
3807 nodes were introduced. Render nodes solely serve render clients, that
3808 is, no modesetting or privileged ioctls can be issued on render nodes.
3809 Only non-global rendering commands are allowed. If a driver supports
00153aeb 3810 render nodes, it must advertise it via the DRIVER_RENDER
1793126f
DH
3811 DRM driver capability. If not supported, the primary node must be used
3812 for render clients together with the legacy drmAuth authentication
3813 procedure.
3814 </para>
3815 <para>
3816 If a driver advertises render node support, DRM core will create a
00153aeb 3817 separate render node called renderD&lt;num&gt;. There will
1793126f 3818 be one render node per device. No ioctls except PRIME-related ioctls
00153aeb 3819 will be allowed on this node. Especially GEM_OPEN will be
1793126f
DH
3820 explicitly prohibited. Render nodes are designed to avoid the
3821 buffer-leaks, which occur if clients guess the flink names or mmap
3822 offsets on the legacy interface. Additionally to this basic interface,
3823 drivers must mark their driver-dependent render-only ioctls as
00153aeb 3824 DRM_RENDER_ALLOW so render clients can use them. Driver
1793126f
DH
3825 authors must be careful not to allow any privileged ioctls on render
3826 nodes.
3827 </para>
3828 <para>
3829 With render nodes, user-space can now control access to the render node
3830 via basic file-system access-modes. A running graphics server which
3831 authenticates clients on the privileged primary/legacy node is no longer
3832 required. Instead, a client can open the render node and is immediately
3833 granted GPU access. Communication between clients (or servers) is done
3834 via PRIME. FLINK from render node to legacy node is not supported. New
3835 clients must not use the insecure FLINK interface.
3836 </para>
3837 <para>
3838 Besides dropping all modeset/global ioctls, render nodes also drop the
3839 DRM-Master concept. There is no reason to associate render clients with
3840 a DRM-Master as they are independent of any graphics server. Besides,
3841 they must work without any running master, anyway.
3842 Drivers must be able to run without a master object if they support
3843 render nodes. If, on the other hand, a driver requires shared state
3844 between clients which is visible to user-space and accessible beyond
3845 open-file boundaries, they cannot support render nodes.
3846 </para>
3847 </sect1>
3848
9cad9c95
LP
3849 <!-- External: vblank handling -->
3850
3851 <sect1>
3852 <title>VBlank event handling</title>
3853 <para>
3854 The DRM core exposes two vertical blank related ioctls:
3855 <variablelist>
3856 <varlistentry>
3857 <term>DRM_IOCTL_WAIT_VBLANK</term>
3858 <listitem>
3859 <para>
3860 This takes a struct drm_wait_vblank structure as its argument,
3861 and it is used to block or request a signal when a specified
3862 vblank event occurs.
3863 </para>
3864 </listitem>
3865 </varlistentry>
3866 <varlistentry>
3867 <term>DRM_IOCTL_MODESET_CTL</term>
3868 <listitem>
3869 <para>
8edffbb9
DV
3870 This was only used for user-mode-settind drivers around
3871 modesetting changes to allow the kernel to update the vblank
3872 interrupt after mode setting, since on many devices the vertical
3873 blank counter is reset to 0 at some point during modeset. Modern
3874 drivers should not call this any more since with kernel mode
3875 setting it is a no-op.
9cad9c95
LP
3876 </para>
3877 </listitem>
3878 </varlistentry>
3879 </variablelist>
9cad9c95
LP
3880 </para>
3881 </sect1>
3882
2d2ef822 3883 </chapter>
3519f70e
DV
3884</part>
3885<part id="drmDrivers">
3886 <title>DRM Drivers</title>
2d2ef822 3887
3519f70e
DV
3888 <partintro>
3889 <para>
7f817074
LW
3890 This second part of the GPU Driver Developer's Guide documents driver
3891 code, implementation details and also all the driver-specific userspace
3519f70e
DV
3892 interfaces. Especially since all hardware-acceleration interfaces to
3893 userspace are driver specific for efficiency and other reasons these
3894 interfaces can be rather substantial. Hence every driver has its own
3895 chapter.
3896 </para>
3897 </partintro>
2d2ef822 3898
3519f70e
DV
3899 <chapter id="drmI915">
3900 <title>drm/i915 Intel GFX Driver</title>
2d2ef822 3901 <para>
3519f70e
DV
3902 The drm/i915 driver supports all (with the exception of some very early
3903 models) integrated GFX chipsets with both Intel display and rendering
3904 blocks. This excludes a set of SoC platforms with an SGX rendering unit,
3905 those have basic support through the gma500 drm driver.
2d2ef822 3906 </para>
e4e7684f
DV
3907 <sect1>
3908 <title>Core Driver Infrastructure</title>
3909 <para>
3910 This section covers core driver infrastructure used by both the display
3911 and the GEM parts of the driver.
3912 </para>
3913 <sect2>
3914 <title>Runtime Power Management</title>
3915!Pdrivers/gpu/drm/i915/intel_runtime_pm.c runtime pm
3916!Idrivers/gpu/drm/i915/intel_runtime_pm.c
397f6fa6 3917!Idrivers/gpu/drm/i915/intel_uncore.c
e4e7684f 3918 </sect2>
fca52a55
DV
3919 <sect2>
3920 <title>Interrupt Handling</title>
3921!Pdrivers/gpu/drm/i915/i915_irq.c interrupt handling
3922!Fdrivers/gpu/drm/i915/i915_irq.c intel_irq_init intel_irq_init_hw intel_hpd_init
fca52a55
DV
3923!Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_disable_interrupts
3924!Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_enable_interrupts
3925 </sect2>
cf9d2890
YZ
3926 <sect2>
3927 <title>Intel GVT-g Guest Support(vGPU)</title>
3928!Pdrivers/gpu/drm/i915/i915_vgpu.c Intel GVT-g guest support
3929!Idrivers/gpu/drm/i915/i915_vgpu.c
3930 </sect2>
e4e7684f 3931 </sect1>
3519f70e
DV
3932 <sect1>
3933 <title>Display Hardware Handling</title>
3934 <para>
3935 This section covers everything related to the display hardware including
3936 the mode setting infrastructure, plane, sprite and cursor handling and
3937 display, output probing and related topics.
3938 </para>
3939 <sect2>
3940 <title>Mode Setting Infrastructure</title>
3941 <para>
3942 The i915 driver is thus far the only DRM driver which doesn't use the
3943 common DRM helper code to implement mode setting sequences. Thus it
3944 has its own tailor-made infrastructure for executing a display
3945 configuration change.
3946 </para>
3947 </sect2>
b680c37a
DV
3948 <sect2>
3949 <title>Frontbuffer Tracking</title>
3950!Pdrivers/gpu/drm/i915/intel_frontbuffer.c frontbuffer tracking
3951!Idrivers/gpu/drm/i915/intel_frontbuffer.c
b680c37a 3952!Fdrivers/gpu/drm/i915/i915_gem.c i915_gem_track_fb
ef07388e
DV
3953 </sect2>
3954 <sect2>
3955 <title>Display FIFO Underrun Reporting</title>
3956!Pdrivers/gpu/drm/i915/intel_fifo_underrun.c fifo underrun handling
3957!Idrivers/gpu/drm/i915/intel_fifo_underrun.c
b680c37a 3958 </sect2>
3519f70e
DV
3959 <sect2>
3960 <title>Plane Configuration</title>
3961 <para>
3962 This section covers plane configuration and composition with the
3963 primary plane, sprites, cursors and overlays. This includes the
3964 infrastructure to do atomic vsync'ed updates of all this state and
3965 also tightly coupled topics like watermark setup and computation,
3966 framebuffer compression and panel self refresh.
3967 </para>
3968 </sect2>
ea2c67bb
MR
3969 <sect2>
3970 <title>Atomic Plane Helpers</title>
3971!Pdrivers/gpu/drm/i915/intel_atomic_plane.c atomic plane helpers
3972!Idrivers/gpu/drm/i915/intel_atomic_plane.c
3973 </sect2>
3519f70e
DV
3974 <sect2>
3975 <title>Output Probing</title>
3976 <para>
3977 This section covers output probing and related infrastructure like the
3978 hotplug interrupt storm detection and mitigation code. Note that the
3979 i915 driver still uses most of the common DRM helper code for output
3980 probing, so those sections fully apply.
3981 </para>
3982 </sect2>
856974a4
JN
3983 <sect2>
3984 <title>Hotplug</title>
3985!Pdrivers/gpu/drm/i915/intel_hotplug.c Hotplug
3986!Idrivers/gpu/drm/i915/intel_hotplug.c
3987 </sect2>
28855d2a
JN
3988 <sect2>
3989 <title>High Definition Audio</title>
3990!Pdrivers/gpu/drm/i915/intel_audio.c High Definition Audio over HDMI and Display Port
3991!Idrivers/gpu/drm/i915/intel_audio.c
cb422619 3992!Iinclude/drm/i915_component.h
b2b89f55
RV
3993 </sect2>
3994 <sect2>
3995 <title>Panel Self Refresh PSR (PSR/SRD)</title>
3996!Pdrivers/gpu/drm/i915/intel_psr.c Panel Self Refresh (PSR/SRD)
3997!Idrivers/gpu/drm/i915/intel_psr.c
94b83957
RV
3998 </sect2>
3999 <sect2>
4000 <title>Frame Buffer Compression (FBC)</title>
4001!Pdrivers/gpu/drm/i915/intel_fbc.c Frame Buffer Compression (FBC)
4002!Idrivers/gpu/drm/i915/intel_fbc.c
b33a2815
VK
4003 </sect2>
4004 <sect2>
4005 <title>Display Refresh Rate Switching (DRRS)</title>
4006!Pdrivers/gpu/drm/i915/intel_dp.c Display Refresh Rate Switching (DRRS)
4007!Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_set_drrs_state
4008!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_enable
4009!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_disable
4010!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_invalidate
4011!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_flush
4012!Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_drrs_init
4013
28855d2a 4014 </sect2>
0e767189
VS
4015 <sect2>
4016 <title>DPIO</title>
4017!Pdrivers/gpu/drm/i915/i915_reg.h DPIO
111a9c14 4018 <table id="dpiox2">
eee21566 4019 <title>Dual channel PHY (VLV/CHV/BXT)</title>
111a9c14
VS
4020 <tgroup cols="8">
4021 <colspec colname="c0" />
4022 <colspec colname="c1" />
4023 <colspec colname="c2" />
4024 <colspec colname="c3" />
4025 <colspec colname="c4" />
4026 <colspec colname="c5" />
4027 <colspec colname="c6" />
4028 <colspec colname="c7" />
4029 <spanspec spanname="ch0" namest="c0" nameend="c3" />
4030 <spanspec spanname="ch1" namest="c4" nameend="c7" />
4031 <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
4032 <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
4033 <spanspec spanname="ch1pcs01" namest="c4" nameend="c5" />
4034 <spanspec spanname="ch1pcs23" namest="c6" nameend="c7" />
4035 <thead>
4036 <row>
4037 <entry spanname="ch0">CH0</entry>
4038 <entry spanname="ch1">CH1</entry>
4039 </row>
4040 </thead>
4041 <tbody valign="top" align="center">
4042 <row>
4043 <entry spanname="ch0">CMN/PLL/REF</entry>
4044 <entry spanname="ch1">CMN/PLL/REF</entry>
4045 </row>
4046 <row>
4047 <entry spanname="ch0pcs01">PCS01</entry>
4048 <entry spanname="ch0pcs23">PCS23</entry>
4049 <entry spanname="ch1pcs01">PCS01</entry>
4050 <entry spanname="ch1pcs23">PCS23</entry>
4051 </row>
4052 <row>
4053 <entry>TX0</entry>
4054 <entry>TX1</entry>
4055 <entry>TX2</entry>
4056 <entry>TX3</entry>
4057 <entry>TX0</entry>
4058 <entry>TX1</entry>
4059 <entry>TX2</entry>
4060 <entry>TX3</entry>
4061 </row>
4062 <row>
4063 <entry spanname="ch0">DDI0</entry>
4064 <entry spanname="ch1">DDI1</entry>
4065 </row>
4066 </tbody>
4067 </tgroup>
4068 </table>
4069 <table id="dpiox1">
eee21566 4070 <title>Single channel PHY (CHV/BXT)</title>
111a9c14
VS
4071 <tgroup cols="4">
4072 <colspec colname="c0" />
4073 <colspec colname="c1" />
4074 <colspec colname="c2" />
4075 <colspec colname="c3" />
4076 <spanspec spanname="ch0" namest="c0" nameend="c3" />
4077 <spanspec spanname="ch0pcs01" namest="c0" nameend="c1" />
4078 <spanspec spanname="ch0pcs23" namest="c2" nameend="c3" />
4079 <thead>
4080 <row>
4081 <entry spanname="ch0">CH0</entry>
4082 </row>
4083 </thead>
4084 <tbody valign="top" align="center">
4085 <row>
4086 <entry spanname="ch0">CMN/PLL/REF</entry>
4087 </row>
4088 <row>
4089 <entry spanname="ch0pcs01">PCS01</entry>
4090 <entry spanname="ch0pcs23">PCS23</entry>
4091 </row>
4092 <row>
4093 <entry>TX0</entry>
4094 <entry>TX1</entry>
4095 <entry>TX2</entry>
4096 <entry>TX3</entry>
4097 </row>
4098 <row>
4099 <entry spanname="ch0">DDI2</entry>
4100 </row>
4101 </tbody>
4102 </tgroup>
4103 </table>
0e767189 4104 </sect2>
aa9145c4
AM
4105
4106 <sect2>
4107 <title>CSR firmware support for DMC</title>
4108!Pdrivers/gpu/drm/i915/intel_csr.c csr support for dmc
4109!Idrivers/gpu/drm/i915/intel_csr.c
4110 </sect2>
3519f70e 4111 </sect1>
2d2ef822 4112
3519f70e
DV
4113 <sect1>
4114 <title>Memory Management and Command Submission</title>
4115 <para>
4116 This sections covers all things related to the GEM implementation in the
4117 i915 driver.
4118 </para>
122b2505
DV
4119 <sect2>
4120 <title>Batchbuffer Parsing</title>
4121!Pdrivers/gpu/drm/i915/i915_cmd_parser.c batch buffer command parser
4122!Idrivers/gpu/drm/i915/i915_cmd_parser.c
493018dc
BV
4123 </sect2>
4124 <sect2>
4125 <title>Batchbuffer Pools</title>
4126!Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool
4127!Idrivers/gpu/drm/i915/i915_gem_batch_pool.c
122b2505 4128 </sect2>
73e4d07f
OM
4129 <sect2>
4130 <title>Logical Rings, Logical Ring Contexts and Execlists</title>
4131!Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists
4132!Idrivers/gpu/drm/i915/intel_lrc.c
4133 </sect2>
45f8f69a
TU
4134 <sect2>
4135 <title>Global GTT views</title>
4136!Pdrivers/gpu/drm/i915/i915_gem_gtt.c Global GTT views
4137!Idrivers/gpu/drm/i915/i915_gem_gtt.c
a794f62a
DV
4138 </sect2>
4139 <sect2>
3271dca4 4140 <title>GTT Fences and Swizzling</title>
a794f62a 4141!Idrivers/gpu/drm/i915/i915_gem_fence.c
3271dca4
DV
4142 <sect3>
4143 <title>Global GTT Fence Handling</title>
4144!Pdrivers/gpu/drm/i915/i915_gem_fence.c fence register handling
4145 </sect3>
4146 <sect3>
4147 <title>Hardware Tiling and Swizzling Details</title>
4148!Pdrivers/gpu/drm/i915/i915_gem_fence.c tiling swizzling details
4149 </sect3>
4150 </sect2>
4151 <sect2>
4152 <title>Object Tiling IOCTLs</title>
4153!Idrivers/gpu/drm/i915/i915_gem_tiling.c
4154!Pdrivers/gpu/drm/i915/i915_gem_tiling.c buffer object tiling
45f8f69a 4155 </sect2>
7838a63a
DV
4156 <sect2>
4157 <title>Buffer Object Eviction</title>
4158 <para>
eb0b44ad 4159 This section documents the interface functions for evicting buffer
7838a63a
DV
4160 objects to make space available in the virtual gpu address spaces.
4161 Note that this is mostly orthogonal to shrinking buffer objects
4162 caches, which has the goal to make main memory (shared with the gpu
4163 through the unified memory architecture) available.
4164 </para>
4165!Idrivers/gpu/drm/i915/i915_gem_evict.c
4166 </sect2>
eb0b44ad
DV
4167 <sect2>
4168 <title>Buffer Object Memory Shrinking</title>
4169 <para>
4170 This section documents the interface function for shrinking memory
4171 usage of buffer object caches. Shrinking is used to make main memory
4172 available. Note that this is mostly orthogonal to evicting buffer
4173 objects, which has the goal to make space in gpu virtual address
4174 spaces.
4175 </para>
4176!Idrivers/gpu/drm/i915/i915_gem_shrinker.c
4177 </sect2>
3519f70e 4178 </sect1>
d1675198 4179 <sect1>
feda33ef 4180 <title>GuC</title>
d1675198 4181 <sect2>
feda33ef 4182 <title>GuC-specific firmware loader</title>
d1675198
AD
4183!Pdrivers/gpu/drm/i915/intel_guc_loader.c GuC-specific firmware loader
4184!Idrivers/gpu/drm/i915/intel_guc_loader.c
4185 </sect2>
4186 <sect2>
feda33ef
AD
4187 <title>GuC-based command submission</title>
4188!Pdrivers/gpu/drm/i915/i915_guc_submission.c GuC-based command submission
cff4f55b 4189!Idrivers/gpu/drm/i915/i915_guc_submission.c
d1675198 4190 </sect2>
feda33ef
AD
4191 <sect2>
4192 <title>GuC Firmware Layout</title>
4193!Pdrivers/gpu/drm/i915/intel_guc_fwif.h GuC Firmware Layout
4194 </sect2>
d1675198
AD
4195 </sect1>
4196
198c974d
DCS
4197 <sect1>
4198 <title> Tracing </title>
4199 <para>
4200 This sections covers all things related to the tracepoints implemented in
4201 the i915 driver.
4202 </para>
4203 <sect2>
4204 <title> i915_ppgtt_create and i915_ppgtt_release </title>
4205!Pdrivers/gpu/drm/i915/i915_trace.h i915_ppgtt_create and i915_ppgtt_release tracepoints
4206 </sect2>
4207 <sect2>
4208 <title> i915_context_create and i915_context_free </title>
4209!Pdrivers/gpu/drm/i915/i915_trace.h i915_context_create and i915_context_free tracepoints
4210 </sect2>
4211 <sect2>
4212 <title> switch_mm </title>
4213!Pdrivers/gpu/drm/i915/i915_trace.h switch_mm tracepoint
4214 </sect2>
4215 </sect1>
4216
3519f70e 4217 </chapter>
fca52a55 4218!Cdrivers/gpu/drm/i915/i915_irq.c
3519f70e 4219</part>
6648f487
LW
4220
4221<part id="vga_switcheroo">
4222 <title>vga_switcheroo</title>
4223 <partintro>
4224!Pdrivers/gpu/vga/vga_switcheroo.c Overview
4225 </partintro>
4226
4227 <chapter id="modes_of_use">
4228 <title>Modes of Use</title>
4229 <sect1>
4230 <title>Manual switching and manual power control</title>
4231!Pdrivers/gpu/vga/vga_switcheroo.c Manual switching and manual power control
4232 </sect1>
4233 <sect1>
4234 <title>Driver power control</title>
4235!Pdrivers/gpu/vga/vga_switcheroo.c Driver power control
4236 </sect1>
4237 </chapter>
4238
4239 <chapter id="pubfunctions">
4240 <title>Public functions</title>
4241!Edrivers/gpu/vga/vga_switcheroo.c
4242 </chapter>
4243
4244 <chapter id="pubstructures">
4245 <title>Public structures</title>
4246!Finclude/linux/vga_switcheroo.h vga_switcheroo_handler
4247!Finclude/linux/vga_switcheroo.h vga_switcheroo_client_ops
4248 </chapter>
4249
4250 <chapter id="pubconstants">
4251 <title>Public constants</title>
4252!Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id
4253!Finclude/linux/vga_switcheroo.h vga_switcheroo_state
4254 </chapter>
4255
4256 <chapter id="privstructures">
4257 <title>Private structures</title>
4258!Fdrivers/gpu/vga/vga_switcheroo.c vgasr_priv
4259!Fdrivers/gpu/vga/vga_switcheroo.c vga_switcheroo_client
4260 </chapter>
4261
4262!Cdrivers/gpu/vga/vga_switcheroo.c
4263!Cinclude/linux/vga_switcheroo.h
4264</part>
4265
2d2ef822 4266</book>
This page took 0.525897 seconds and 5 git commands to generate.