blob: 225a246c5f53daa731cec158805fddb785959982 [file] [log] [blame]
Jesse Barnes2d2ef822009-10-26 13:06:31 -07001<?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
Lukas Wunner7f817072015-10-11 11:26:26 +02005<book id="gpuDevelopersGuide">
Jesse Barnes2d2ef822009-10-26 13:06:31 -07006 <bookinfo>
Daniel Vetter3a4579b2015-10-07 09:55:28 +02007 <title>Linux GPU Driver Developer's Guide</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07008
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02009 <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>
Daniel Vetter3a057002014-01-22 22:38:57 +010032 <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>
Lukas Wunner6648f482015-10-11 11:55:00 +020043 <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>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +020053 </authorgroup>
54
Jesse Barnes2d2ef822009-10-26 13:06:31 -070055 <copyright>
56 <year>2008-2009</year>
Daniel Vetter3a057002014-01-22 22:38:57 +010057 <year>2013-2014</year>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +020058 <holder>Intel Corporation</holder>
Daniel Vetter3a057002014-01-22 22:38:57 +010059 </copyright>
60 <copyright>
61 <year>2012</year>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +020062 <holder>Laurent Pinchart</holder>
Jesse Barnes2d2ef822009-10-26 13:06:31 -070063 </copyright>
Lukas Wunner6648f482015-10-11 11:55:00 +020064 <copyright>
65 <year>2015</year>
66 <holder>Lukas Wunner</holder>
67 </copyright>
Jesse Barnes2d2ef822009-10-26 13:06:31 -070068
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>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +020076
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>
Lukas Wunner6648f482015-10-11 11:55:00 +020086 <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>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +020093 </revhistory>
Jesse Barnes2d2ef822009-10-26 13:06:31 -070094 </bookinfo>
95
96<toc></toc>
97
Daniel Vetter3519f702014-01-22 12:21:16 +010098<part id="drmCore">
99 <title>DRM Core</title>
100 <partintro>
101 <para>
Lukas Wunner7f817072015-10-11 11:26:26 +0200102 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.
Daniel Vetter3519f702014-01-22 12:21:16 +0100105 </para>
106 </partintro>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700107
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
Michael Wittenf11aca02011-08-25 17:21:31 +0000114 drivers in the kernel may make use of DRM functions to make
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700115 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>
Daniel Vetterfb9f7a62015-12-08 09:49:17 +0100127 <sect1>
128 <title>Style Guidelines</title>
129 <para>
130 For consistency this documentation uses American English. Abbreviations
131 are written as all-uppercase, for example: DRM, KMS, IOCTL, CRTC, and so
132 on. To aid in reading, documentations make full use of the markup
133 characters kerneldoc provides: @parameter for function parameters, @member
134 for structure members, &amp;structure to reference structures and
135 function() for functions. These all get automatically hyperlinked if
136 kerneldoc for the referenced objects exists. When referencing entries in
137 function vtables please use -&gt;vfunc(). Note that kerneldoc does
138 not support referencing struct members directly, so please add a reference
139 to the vtable struct somewhere in the same paragraph or at least section.
140 </para>
141 <para>
142 Except in special situations (to separate locked from unlocked variants)
143 locking requirements for functions aren't documented in the kerneldoc.
144 Instead locking should be check at runtime using e.g.
145 <code>WARN_ON(!mutex_is_locked(...));</code>. Since it's much easier to
146 ignore documentation than runtime noise this provides more value. And on
147 top of that runtime checks do need to be updated when the locking rules
148 change, increasing the chances that they're correct. Within the
149 documentation the locking rules should be explained in the relevant
150 structures: Either in the comment for the lock explaining what it
151 protects, or data fields need a note about which lock protects them, or
152 both.
153 </para>
154 <para>
155 Functions which have a non-<code>void</code> return value should have a
156 section called "Returns" explaining the expected return values in
157 different cases and their meanings. Currently there's no consensus whether
158 that section name should be all upper-case or not, and whether it should
159 end in a colon or not. Go with the file-local style. Other common section
160 names are "Notes" with information for dangerous or tricky corner cases,
161 and "FIXME" where the interface could be cleaned up.
162 </para>
163 </sect1>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700164 </chapter>
165
166 <!-- Internals -->
167
168 <chapter id="drmInternals">
169 <title>DRM Internals</title>
170 <para>
171 This chapter documents DRM internals relevant to driver authors
172 and developers working to add support for the latest features to
173 existing drivers.
174 </para>
175 <para>
Michael Wittena78f6782011-08-25 17:18:08 +0000176 First, we go over some typical driver initialization
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700177 requirements, like setting up command buffers, creating an
178 initial output configuration, and initializing core services.
Michael Wittena78f6782011-08-25 17:18:08 +0000179 Subsequent sections cover core internals in more detail,
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700180 providing implementation notes and examples.
181 </para>
182 <para>
183 The DRM layer provides several services to graphics drivers,
184 many of them driven by the application interfaces it provides
185 through libdrm, the library that wraps most of the DRM ioctls.
186 These include vblank event handling, memory
187 management, output management, framebuffer management, command
188 submission &amp; fencing, suspend/resume support, and DMA
189 services.
190 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700191
192 <!-- Internals: driver init -->
193
194 <sect1>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200195 <title>Driver Initialization</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700196 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200197 At the core of every DRM driver is a <structname>drm_driver</structname>
198 structure. Drivers typically statically initialize a drm_driver structure,
Daniel Vetter6e3f7972015-09-28 21:46:35 +0200199 and then pass it to <function>drm_dev_alloc()</function> to allocate a
200 device instance. After the device instance is fully initialized it can be
201 registered (which makes it accessible from userspace) using
202 <function>drm_dev_register()</function>.
Thierry Redingb528ae72014-04-23 11:52:10 +0200203 </para>
204 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200205 The <structname>drm_driver</structname> structure contains static
206 information that describes the driver and features it supports, and
207 pointers to methods that the DRM core will call to implement the DRM API.
208 We will first go through the <structname>drm_driver</structname> static
209 information fields, and will then describe individual operations in
210 details as they get used in later sections.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700211 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200212 <sect2>
213 <title>Driver Information</title>
214 <sect3>
215 <title>Driver Features</title>
216 <para>
217 Drivers inform the DRM core about their requirements and supported
218 features by setting appropriate flags in the
219 <structfield>driver_features</structfield> field. Since those flags
220 influence the DRM core behaviour since registration time, most of them
221 must be set to registering the <structname>drm_driver</structname>
222 instance.
223 </para>
224 <synopsis>u32 driver_features;</synopsis>
225 <variablelist>
226 <title>Driver Feature Flags</title>
227 <varlistentry>
228 <term>DRIVER_USE_AGP</term>
229 <listitem><para>
230 Driver uses AGP interface, the DRM core will manage AGP resources.
231 </para></listitem>
232 </varlistentry>
233 <varlistentry>
234 <term>DRIVER_REQUIRE_AGP</term>
235 <listitem><para>
236 Driver needs AGP interface to function. AGP initialization failure
237 will become a fatal error.
238 </para></listitem>
239 </varlistentry>
240 <varlistentry>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200241 <term>DRIVER_PCI_DMA</term>
242 <listitem><para>
243 Driver is capable of PCI DMA, mapping of PCI DMA buffers to
244 userspace will be enabled. Deprecated.
245 </para></listitem>
246 </varlistentry>
247 <varlistentry>
248 <term>DRIVER_SG</term>
249 <listitem><para>
250 Driver can perform scatter/gather DMA, allocation and mapping of
251 scatter/gather buffers will be enabled. Deprecated.
252 </para></listitem>
253 </varlistentry>
254 <varlistentry>
255 <term>DRIVER_HAVE_DMA</term>
256 <listitem><para>
257 Driver supports DMA, the userspace DMA API will be supported.
258 Deprecated.
259 </para></listitem>
260 </varlistentry>
261 <varlistentry>
262 <term>DRIVER_HAVE_IRQ</term><term>DRIVER_IRQ_SHARED</term>
263 <listitem><para>
Laurent Pinchart02b62982013-06-22 14:10:59 +0200264 DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler
265 managed by the DRM Core. The core will support simple IRQ handler
266 installation when the flag is set. The installation process is
267 described in <xref linkend="drm-irq-registration"/>.</para>
268 <para>DRIVER_IRQ_SHARED indicates whether the device &amp; handler
269 support shared IRQs (note that this is required of PCI drivers).
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200270 </para></listitem>
271 </varlistentry>
272 <varlistentry>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200273 <term>DRIVER_GEM</term>
274 <listitem><para>
275 Driver use the GEM memory manager.
276 </para></listitem>
277 </varlistentry>
278 <varlistentry>
279 <term>DRIVER_MODESET</term>
280 <listitem><para>
281 Driver supports mode setting interfaces (KMS).
282 </para></listitem>
283 </varlistentry>
284 <varlistentry>
285 <term>DRIVER_PRIME</term>
286 <listitem><para>
287 Driver implements DRM PRIME buffer sharing.
288 </para></listitem>
289 </varlistentry>
David Herrmann17931262013-08-25 18:29:00 +0200290 <varlistentry>
291 <term>DRIVER_RENDER</term>
292 <listitem><para>
293 Driver supports dedicated render nodes.
294 </para></listitem>
295 </varlistentry>
Rob Clark88a48e22014-12-18 16:01:50 -0500296 <varlistentry>
297 <term>DRIVER_ATOMIC</term>
298 <listitem><para>
299 Driver supports atomic properties. In this case the driver
300 must implement appropriate obj->atomic_get_property() vfuncs
301 for any modeset objects with driver specific properties.
302 </para></listitem>
303 </varlistentry>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200304 </variablelist>
305 </sect3>
306 <sect3>
307 <title>Major, Minor and Patchlevel</title>
308 <synopsis>int major;
309int minor;
310int patchlevel;</synopsis>
311 <para>
312 The DRM core identifies driver versions by a major, minor and patch
313 level triplet. The information is printed to the kernel log at
314 initialization time and passed to userspace through the
315 DRM_IOCTL_VERSION ioctl.
316 </para>
317 <para>
318 The major and minor numbers are also used to verify the requested driver
319 API version passed to DRM_IOCTL_SET_VERSION. When the driver API changes
320 between minor versions, applications can call DRM_IOCTL_SET_VERSION to
321 select a specific version of the API. If the requested major isn't equal
322 to the driver major, or the requested minor is larger than the driver
323 minor, the DRM_IOCTL_SET_VERSION call will return an error. Otherwise
324 the driver's set_version() method will be called with the requested
325 version.
326 </para>
327 </sect3>
328 <sect3>
329 <title>Name, Description and Date</title>
330 <synopsis>char *name;
331char *desc;
332char *date;</synopsis>
333 <para>
334 The driver name is printed to the kernel log at initialization time,
335 used for IRQ registration and passed to userspace through
336 DRM_IOCTL_VERSION.
337 </para>
338 <para>
339 The driver description is a purely informative string passed to
340 userspace through the DRM_IOCTL_VERSION ioctl and otherwise unused by
341 the kernel.
342 </para>
343 <para>
344 The driver date, formatted as YYYYMMDD, is meant to identify the date of
345 the latest modification to the driver. However, as most drivers fail to
346 update it, its value is mostly useless. The DRM core prints it to the
347 kernel log at initialization time and passes it to userspace through the
348 DRM_IOCTL_VERSION ioctl.
349 </para>
350 </sect3>
351 </sect2>
352 <sect2>
Daniel Vetter6e3f7972015-09-28 21:46:35 +0200353 <title>Device Instance and Driver Handling</title>
354!Pdrivers/gpu/drm/drm_drv.c driver instance overview
Thierry Reding25196482014-08-08 11:33:12 +0200355!Edrivers/gpu/drm/drm_drv.c
Thierry Redingc6a1af8a2014-05-19 13:39:07 +0200356 </sect2>
357 <sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200358 <title>Driver Load</title>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200359 <sect3 id="drm-irq-registration">
360 <title>IRQ Registration</title>
361 <para>
362 The DRM core tries to facilitate IRQ handler registration and
363 unregistration by providing <function>drm_irq_install</function> and
364 <function>drm_irq_uninstall</function> functions. Those functions only
Laurent Pinchart02b62982013-06-22 14:10:59 +0200365 support a single interrupt per device, devices that use more than one
366 IRQs need to be handled manually.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200367 </para>
Laurent Pinchart02b62982013-06-22 14:10:59 +0200368 <sect4>
369 <title>Managed IRQ Registration</title>
370 <para>
Laurent Pinchart02b62982013-06-22 14:10:59 +0200371 <function>drm_irq_install</function> starts by calling the
372 <methodname>irq_preinstall</methodname> driver operation. The operation
373 is optional and must make sure that the interrupt will not get fired by
374 clearing all pending interrupt flags or disabling the interrupt.
375 </para>
376 <para>
Daniel Vetterbb0f1b52013-11-03 21:09:27 +0100377 The passed-in IRQ will then be requested by a call to
Laurent Pinchart02b62982013-06-22 14:10:59 +0200378 <function>request_irq</function>. If the DRIVER_IRQ_SHARED driver
379 feature flag is set, a shared (IRQF_SHARED) IRQ handler will be
380 requested.
381 </para>
382 <para>
383 The IRQ handler function must be provided as the mandatory irq_handler
384 driver operation. It will get passed directly to
385 <function>request_irq</function> and thus has the same prototype as all
386 IRQ handlers. It will get called with a pointer to the DRM device as the
387 second argument.
388 </para>
389 <para>
390 Finally the function calls the optional
391 <methodname>irq_postinstall</methodname> driver operation. The operation
392 usually enables interrupts (excluding the vblank interrupt, which is
393 enabled separately), but drivers may choose to enable/disable interrupts
394 at a different time.
395 </para>
396 <para>
397 <function>drm_irq_uninstall</function> is similarly used to uninstall an
398 IRQ handler. It starts by waking up all processes waiting on a vblank
399 interrupt to make sure they don't hang, and then calls the optional
400 <methodname>irq_uninstall</methodname> driver operation. The operation
401 must disable all hardware interrupts. Finally the function frees the IRQ
402 by calling <function>free_irq</function>.
403 </para>
404 </sect4>
405 <sect4>
406 <title>Manual IRQ Registration</title>
407 <para>
408 Drivers that require multiple interrupt handlers can't use the managed
409 IRQ registration functions. In that case IRQs must be registered and
410 unregistered manually (usually with the <function>request_irq</function>
411 and <function>free_irq</function> functions, or their devm_* equivalent).
412 </para>
413 <para>
414 When manually registering IRQs, drivers must not set the DRIVER_HAVE_IRQ
415 driver feature flag, and must not provide the
416 <methodname>irq_handler</methodname> driver operation. They must set the
417 <structname>drm_device</structname> <structfield>irq_enabled</structfield>
418 field to 1 upon registration of the IRQs, and clear it to 0 after
419 unregistering the IRQs.
420 </para>
421 </sect4>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200422 </sect3>
423 <sect3>
424 <title>Memory Manager Initialization</title>
425 <para>
426 Every DRM driver requires a memory manager which must be initialized at
427 load time. DRM currently contains two memory managers, the Translation
428 Table Manager (TTM) and the Graphics Execution Manager (GEM).
429 This document describes the use of the GEM memory manager only. See
430 <xref linkend="drm-memory-management"/> for details.
431 </para>
432 </sect3>
433 <sect3>
434 <title>Miscellaneous Device Configuration</title>
435 <para>
436 Another task that may be necessary for PCI devices during configuration
437 is mapping the video BIOS. On many devices, the VBIOS describes device
438 configuration, LCD panel timings (if any), and contains flags indicating
439 device state. Mapping the BIOS can be done using the pci_map_rom() call,
440 a convenience function that takes care of mapping the actual ROM,
441 whether it has been shadowed into memory (typically at address 0xc0000)
442 or exists on the PCI device in the ROM BAR. Note that after the ROM has
443 been mapped and any necessary information has been extracted, it should
444 be unmapped; on many devices, the ROM address decoder is shared with
445 other BARs, so leaving it mapped could cause undesired behaviour like
446 hangs or memory corruption.
447 <!--!Fdrivers/pci/rom.c pci_map_rom-->
448 </para>
449 </sect3>
450 </sect2>
Daniel Vetter6e3f7972015-09-28 21:46:35 +0200451 <sect2>
452 <title>Bus-specific Device Registration and PCI Support</title>
453 <para>
454 A number of functions are provided to help with device registration.
455 The functions deal with PCI and platform devices respectively and are
456 only provided for historical reasons. These are all deprecated and
457 shouldn't be used in new drivers. Besides that there's a few
458 helpers for pci drivers.
459 </para>
460!Edrivers/gpu/drm/drm_pci.c
461!Edrivers/gpu/drm/drm_platform.c
462 </sect2>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700463 </sect1>
464
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200465 <!-- Internals: memory management -->
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700466
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200467 <sect1 id="drm-memory-management">
468 <title>Memory management</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700469 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200470 Modern Linux systems require large amount of graphics memory to store
471 frame buffers, textures, vertices and other graphics-related data. Given
472 the very dynamic nature of many of that data, managing graphics memory
473 efficiently is thus crucial for the graphics stack and plays a central
474 role in the DRM infrastructure.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700475 </para>
476 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200477 The DRM core includes two memory managers, namely Translation Table Maps
478 (TTM) and Graphics Execution Manager (GEM). TTM was the first DRM memory
479 manager to be developed and tried to be a one-size-fits-them all
Anatol Pomozovf884ab12013-05-08 16:56:16 -0700480 solution. It provides a single userspace API to accommodate the need of
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200481 all hardware, supporting both Unified Memory Architecture (UMA) devices
482 and devices with dedicated video RAM (i.e. most discrete video cards).
483 This resulted in a large, complex piece of code that turned out to be
484 hard to use for driver development.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700485 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200486 <para>
487 GEM started as an Intel-sponsored project in reaction to TTM's
488 complexity. Its design philosophy is completely different: instead of
489 providing a solution to every graphics memory-related problems, GEM
490 identified common code between drivers and created a support library to
491 share it. GEM has simpler initialization and execution requirements than
Masanari Iida9a6594f2014-05-15 13:54:06 -0700492 TTM, but has no video RAM management capabilities and is thus limited to
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200493 UMA devices.
494 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700495 <sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200496 <title>The Translation Table Manager (TTM)</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700497 <para>
Thierry Reding79058102014-11-03 14:45:44 +0100498 TTM design background and information belongs here.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700499 </para>
500 <sect3>
Thierry Reding79058102014-11-03 14:45:44 +0100501 <title>TTM initialization</title>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200502 <warning><para>This section is outdated.</para></warning>
503 <para>
504 Drivers wishing to support TTM must fill out a drm_bo_driver
505 structure. The structure contains several fields with function
506 pointers for initializing the TTM, allocating and freeing memory,
507 waiting for command completion and fence synchronization, and memory
508 migration. See the radeon_ttm.c file for an example of usage.
Thierry Reding79058102014-11-03 14:45:44 +0100509 </para>
510 <para>
511 The ttm_global_reference structure is made up of several fields:
512 </para>
513 <programlisting>
514 struct ttm_global_reference {
515 enum ttm_global_types global_type;
516 size_t size;
517 void *object;
518 int (*init) (struct ttm_global_reference *);
519 void (*release) (struct ttm_global_reference *);
520 };
521 </programlisting>
522 <para>
523 There should be one global reference structure for your memory
524 manager as a whole, and there will be others for each object
525 created by the memory manager at runtime. Your global TTM should
526 have a type of TTM_GLOBAL_TTM_MEM. The size field for the global
527 object should be sizeof(struct ttm_mem_global), and the init and
528 release hooks should point at your driver-specific init and
529 release routines, which probably eventually call
530 ttm_mem_global_init and ttm_mem_global_release, respectively.
531 </para>
532 <para>
533 Once your global TTM accounting structure is set up and initialized
534 by calling ttm_global_item_ref() on it,
535 you need to create a buffer object TTM to
536 provide a pool for buffer object allocation by clients and the
537 kernel itself. The type of this object should be TTM_GLOBAL_TTM_BO,
538 and its size should be sizeof(struct ttm_bo_global). Again,
539 driver-specific init and release functions may be provided,
540 likely eventually calling ttm_bo_global_init() and
541 ttm_bo_global_release(), respectively. Also, like the previous
542 object, ttm_global_item_ref() is used to create an initial reference
543 count for the TTM, which will call your initialization function.
544 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700545 </sect3>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700546 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200547 <sect2 id="drm-gem">
548 <title>The Graphics Execution Manager (GEM)</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700549 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200550 The GEM design approach has resulted in a memory manager that doesn't
551 provide full coverage of all (or even all common) use cases in its
552 userspace or kernel API. GEM exposes a set of standard memory-related
553 operations to userspace and a set of helper functions to drivers, and let
554 drivers implement hardware-specific operations with their own private API.
555 </para>
556 <para>
557 The GEM userspace API is described in the
558 <ulink url="http://lwn.net/Articles/283798/"><citetitle>GEM - the Graphics
559 Execution Manager</citetitle></ulink> article on LWN. While slightly
560 outdated, the document provides a good overview of the GEM API principles.
561 Buffer allocation and read and write operations, described as part of the
562 common GEM API, are currently implemented using driver-specific ioctls.
563 </para>
564 <para>
565 GEM is data-agnostic. It manages abstract buffer objects without knowing
566 what individual buffers contain. APIs that require knowledge of buffer
567 contents or purpose, such as buffer allocation or synchronization
568 primitives, are thus outside of the scope of GEM and must be implemented
569 using driver-specific ioctls.
570 </para>
571 <para>
Thierry Reding79058102014-11-03 14:45:44 +0100572 On a fundamental level, GEM involves several operations:
573 <itemizedlist>
574 <listitem>Memory allocation and freeing</listitem>
575 <listitem>Command execution</listitem>
576 <listitem>Aperture management at command execution time</listitem>
577 </itemizedlist>
578 Buffer object allocation is relatively straightforward and largely
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200579 provided by Linux's shmem layer, which provides memory to back each
580 object.
581 </para>
582 <para>
583 Device-specific operations, such as command execution, pinning, buffer
Thierry Reding79058102014-11-03 14:45:44 +0100584 read &amp; write, mapping, and domain ownership transfers are left to
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200585 driver-specific ioctls.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700586 </para>
587 <sect3>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200588 <title>GEM Initialization</title>
589 <para>
590 Drivers that use GEM must set the DRIVER_GEM bit in the struct
591 <structname>drm_driver</structname>
592 <structfield>driver_features</structfield> field. The DRM core will
593 then automatically initialize the GEM core before calling the
594 <methodname>load</methodname> operation. Behind the scene, this will
595 create a DRM Memory Manager object which provides an address space
596 pool for object allocation.
597 </para>
598 <para>
599 In a KMS configuration, drivers need to allocate and initialize a
600 command ring buffer following core GEM initialization if required by
601 the hardware. UMA devices usually have what is called a "stolen"
602 memory region, which provides space for the initial framebuffer and
603 large, contiguous memory regions required by the device. This space is
604 typically not managed by GEM, and must be initialized separately into
605 its own DRM MM object.
606 </para>
607 </sect3>
608 <sect3>
609 <title>GEM Objects Creation</title>
610 <para>
611 GEM splits creation of GEM objects and allocation of the memory that
612 backs them in two distinct operations.
613 </para>
614 <para>
615 GEM objects are represented by an instance of struct
616 <structname>drm_gem_object</structname>. Drivers usually need to extend
617 GEM objects with private information and thus create a driver-specific
618 GEM object structure type that embeds an instance of struct
619 <structname>drm_gem_object</structname>.
620 </para>
621 <para>
622 To create a GEM object, a driver allocates memory for an instance of its
623 specific GEM object type and initializes the embedded struct
624 <structname>drm_gem_object</structname> with a call to
625 <function>drm_gem_object_init</function>. The function takes a pointer to
626 the DRM device, a pointer to the GEM object and the buffer object size
627 in bytes.
628 </para>
629 <para>
630 GEM uses shmem to allocate anonymous pageable memory.
631 <function>drm_gem_object_init</function> will create an shmfs file of
632 the requested size and store it into the struct
633 <structname>drm_gem_object</structname> <structfield>filp</structfield>
634 field. The memory is used as either main storage for the object when the
635 graphics hardware uses system memory directly or as a backing store
636 otherwise.
637 </para>
638 <para>
639 Drivers are responsible for the actual physical pages allocation by
640 calling <function>shmem_read_mapping_page_gfp</function> for each page.
641 Note that they can decide to allocate pages when initializing the GEM
642 object, or to delay allocation until the memory is needed (for instance
643 when a page fault occurs as a result of a userspace memory access or
644 when the driver needs to start a DMA transfer involving the memory).
645 </para>
646 <para>
647 Anonymous pageable memory allocation is not always desired, for instance
648 when the hardware requires physically contiguous system memory as is
649 often the case in embedded devices. Drivers can create GEM objects with
650 no shmfs backing (called private GEM objects) by initializing them with
651 a call to <function>drm_gem_private_object_init</function> instead of
652 <function>drm_gem_object_init</function>. Storage for private GEM
653 objects must be managed by drivers.
654 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200655 </sect3>
656 <sect3>
657 <title>GEM Objects Lifetime</title>
658 <para>
659 All GEM objects are reference-counted by the GEM core. References can be
660 acquired and release by <function>calling drm_gem_object_reference</function>
661 and <function>drm_gem_object_unreference</function> respectively. The
662 caller must hold the <structname>drm_device</structname>
Daniel Vetterdecc60b2015-10-22 19:11:27 +0200663 <structfield>struct_mutex</structfield> lock when calling
664 <function>drm_gem_object_reference</function>. As a convenience, GEM
665 provides <function>drm_gem_object_unreference_unlocked</function>
666 functions that can be called without holding the lock.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200667 </para>
668 <para>
669 When the last reference to a GEM object is released the GEM core calls
670 the <structname>drm_driver</structname>
671 <methodname>gem_free_object</methodname> operation. That operation is
672 mandatory for GEM-enabled drivers and must free the GEM object and all
673 associated resources.
674 </para>
675 <para>
676 <synopsis>void (*gem_free_object) (struct drm_gem_object *obj);</synopsis>
Daniel Vetterdf2e0902015-10-22 19:11:29 +0200677 Drivers are responsible for freeing all GEM object resources. This includes
678 the resources created by the GEM core, which need to be released with
679 <function>drm_gem_object_release</function>.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200680 </para>
681 </sect3>
682 <sect3>
683 <title>GEM Objects Naming</title>
684 <para>
685 Communication between userspace and the kernel refers to GEM objects
686 using local handles, global names or, more recently, file descriptors.
687 All of those are 32-bit integer values; the usual Linux kernel limits
688 apply to the file descriptors.
689 </para>
690 <para>
691 GEM handles are local to a DRM file. Applications get a handle to a GEM
692 object through a driver-specific ioctl, and can use that handle to refer
693 to the GEM object in other standard or driver-specific ioctls. Closing a
694 DRM file handle frees all its GEM handles and dereferences the
695 associated GEM objects.
696 </para>
697 <para>
698 To create a handle for a GEM object drivers call
699 <function>drm_gem_handle_create</function>. The function takes a pointer
700 to the DRM file and the GEM object and returns a locally unique handle.
701 When the handle is no longer needed drivers delete it with a call to
702 <function>drm_gem_handle_delete</function>. Finally the GEM object
703 associated with a handle can be retrieved by a call to
704 <function>drm_gem_object_lookup</function>.
705 </para>
706 <para>
707 Handles don't take ownership of GEM objects, they only take a reference
708 to the object that will be dropped when the handle is destroyed. To
709 avoid leaking GEM objects, drivers must make sure they drop the
710 reference(s) they own (such as the initial reference taken at object
711 creation time) as appropriate, without any special consideration for the
712 handle. For example, in the particular case of combined GEM object and
713 handle creation in the implementation of the
714 <methodname>dumb_create</methodname> operation, drivers must drop the
715 initial reference to the GEM object before returning the handle.
716 </para>
717 <para>
718 GEM names are similar in purpose to handles but are not local to DRM
719 files. They can be passed between processes to reference a GEM object
720 globally. Names can't be used directly to refer to objects in the DRM
721 API, applications must convert handles to names and names to handles
722 using the DRM_IOCTL_GEM_FLINK and DRM_IOCTL_GEM_OPEN ioctls
723 respectively. The conversion is handled by the DRM core without any
724 driver-specific support.
725 </para>
Thierry Reding79058102014-11-03 14:45:44 +0100726 <para>
727 GEM also supports buffer sharing with dma-buf file descriptors through
728 PRIME. GEM-based drivers must use the provided helpers functions to
729 implement the exporting and importing correctly. See <xref linkend="drm-prime-support" />.
730 Since sharing file descriptors is inherently more secure than the
731 easily guessable and global GEM names it is the preferred buffer
732 sharing mechanism. Sharing buffers through GEM names is only supported
733 for legacy userspace. Furthermore PRIME also allows cross-device
734 buffer sharing since it is based on dma-bufs.
735 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200736 </sect3>
737 <sect3 id="drm-gem-objects-mapping">
738 <title>GEM Objects Mapping</title>
739 <para>
740 Because mapping operations are fairly heavyweight GEM favours
741 read/write-like access to buffers, implemented through driver-specific
742 ioctls, over mapping buffers to userspace. However, when random access
743 to the buffer is needed (to perform software rendering for instance),
744 direct access to the object can be more efficient.
745 </para>
746 <para>
747 The mmap system call can't be used directly to map GEM objects, as they
748 don't have their own file handle. Two alternative methods currently
749 co-exist to map GEM objects to userspace. The first method uses a
750 driver-specific ioctl to perform the mapping operation, calling
751 <function>do_mmap</function> under the hood. This is often considered
752 dubious, seems to be discouraged for new GEM-enabled drivers, and will
753 thus not be described here.
754 </para>
755 <para>
756 The second method uses the mmap system call on the DRM file handle.
757 <synopsis>void *mmap(void *addr, size_t length, int prot, int flags, int fd,
758 off_t offset);</synopsis>
759 DRM identifies the GEM object to be mapped by a fake offset passed
760 through the mmap offset argument. Prior to being mapped, a GEM object
761 must thus be associated with a fake offset. To do so, drivers must call
Daniel Vetterdf2e0902015-10-22 19:11:29 +0200762 <function>drm_gem_create_mmap_offset</function> on the object.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200763 </para>
764 <para>
765 Once allocated, the fake offset value
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200766 must be passed to the application in a driver-specific way and can then
767 be used as the mmap offset argument.
768 </para>
769 <para>
770 The GEM core provides a helper method <function>drm_gem_mmap</function>
771 to handle object mapping. The method can be set directly as the mmap
772 file operation handler. It will look up the GEM object based on the
773 offset value and set the VMA operations to the
774 <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
775 field. Note that <function>drm_gem_mmap</function> doesn't map memory to
776 userspace, but relies on the driver-provided fault handler to map pages
777 individually.
778 </para>
779 <para>
780 To use <function>drm_gem_mmap</function>, drivers must fill the struct
781 <structname>drm_driver</structname> <structfield>gem_vm_ops</structfield>
782 field with a pointer to VM operations.
783 </para>
784 <para>
785 <synopsis>struct vm_operations_struct *gem_vm_ops
786
787 struct vm_operations_struct {
788 void (*open)(struct vm_area_struct * area);
789 void (*close)(struct vm_area_struct * area);
790 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
791 };</synopsis>
792 </para>
793 <para>
794 The <methodname>open</methodname> and <methodname>close</methodname>
795 operations must update the GEM object reference count. Drivers can use
796 the <function>drm_gem_vm_open</function> and
797 <function>drm_gem_vm_close</function> helper functions directly as open
798 and close handlers.
799 </para>
800 <para>
801 The fault operation handler is responsible for mapping individual pages
802 to userspace when a page fault occurs. Depending on the memory
803 allocation scheme, drivers can allocate pages at fault time, or can
804 decide to allocate memory for the GEM object at the time the object is
805 created.
806 </para>
807 <para>
808 Drivers that want to map the GEM object upfront instead of handling page
809 faults can implement their own mmap file operation handler.
810 </para>
811 </sect3>
812 <sect3>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200813 <title>Memory Coherency</title>
814 <para>
815 When mapped to the device or used in a command buffer, backing pages
816 for an object are flushed to memory and marked write combined so as to
817 be coherent with the GPU. Likewise, if the CPU accesses an object
818 after the GPU has finished rendering to the object, then the object
819 must be made coherent with the CPU's view of memory, usually involving
820 GPU cache flushing of various kinds. This core CPU&lt;-&gt;GPU
821 coherency management is provided by a device-specific ioctl, which
822 evaluates an object's current domain and performs any necessary
823 flushing or synchronization to put the object into the desired
824 coherency domain (note that the object may be busy, i.e. an active
825 render target; in that case, setting the domain blocks the client and
826 waits for rendering to complete before performing any necessary
827 flushing operations).
828 </para>
829 </sect3>
830 <sect3>
831 <title>Command Execution</title>
832 <para>
Thierry Reding79058102014-11-03 14:45:44 +0100833 Perhaps the most important GEM function for GPU devices is providing a
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200834 command execution interface to clients. Client programs construct
835 command buffers containing references to previously allocated memory
836 objects, and then submit them to GEM. At that point, GEM takes care to
837 bind all the objects into the GTT, execute the buffer, and provide
838 necessary synchronization between clients accessing the same buffers.
839 This often involves evicting some objects from the GTT and re-binding
840 others (a fairly expensive operation), and providing relocation
841 support which hides fixed GTT offsets from clients. Clients must take
842 care not to submit command buffers that reference more objects than
843 can fit in the GTT; otherwise, GEM will reject them and no rendering
844 will occur. Similarly, if several objects in the buffer require fence
845 registers to be allocated for correct rendering (e.g. 2D blits on
846 pre-965 chips), care must be taken not to require more fence registers
847 than are available to the client. Such resource management should be
848 abstracted from the client in libdrm.
849 </para>
850 </sect3>
Daniel Vetterdecc60b2015-10-22 19:11:27 +0200851 </sect2>
852 <sect2>
853 <title>GEM Function Reference</title>
Daniel Vetter89d61fc2014-01-21 12:39:00 +0100854!Edrivers/gpu/drm/drm_gem.c
Daniel Vetterdecc60b2015-10-22 19:11:27 +0200855!Iinclude/drm/drm_gem.h
Thierry Reding79058102014-11-03 14:45:44 +0100856 </sect2>
857 <sect2>
858 <title>VMA Offset Manager</title>
Daniel Vetter4c5acf32014-01-22 12:28:42 +0100859!Pdrivers/gpu/drm/drm_vma_manager.c vma offset manager
860!Edrivers/gpu/drm/drm_vma_manager.c
861!Iinclude/drm/drm_vma_manager.h
Thierry Reding79058102014-11-03 14:45:44 +0100862 </sect2>
863 <sect2 id="drm-prime-support">
864 <title>PRIME Buffer Sharing</title>
865 <para>
866 PRIME is the cross device buffer sharing framework in drm, originally
867 created for the OPTIMUS range of multi-gpu platforms. To userspace
868 PRIME buffers are dma-buf based file descriptors.
869 </para>
870 <sect3>
871 <title>Overview and Driver Interface</title>
872 <para>
873 Similar to GEM global names, PRIME file descriptors are
874 also used to share buffer objects across processes. They offer
875 additional security: as file descriptors must be explicitly sent over
876 UNIX domain sockets to be shared between applications, they can't be
877 guessed like the globally unique GEM names.
878 </para>
879 <para>
880 Drivers that support the PRIME
881 API must set the DRIVER_PRIME bit in the struct
882 <structname>drm_driver</structname>
883 <structfield>driver_features</structfield> field, and implement the
884 <methodname>prime_handle_to_fd</methodname> and
885 <methodname>prime_fd_to_handle</methodname> operations.
886 </para>
887 <para>
888 <synopsis>int (*prime_handle_to_fd)(struct drm_device *dev,
889 struct drm_file *file_priv, uint32_t handle,
890 uint32_t flags, int *prime_fd);
Daniel Vetter251261d2014-01-22 18:46:33 +0100891int (*prime_fd_to_handle)(struct drm_device *dev,
Thierry Reding79058102014-11-03 14:45:44 +0100892 struct drm_file *file_priv, int prime_fd,
893 uint32_t *handle);</synopsis>
894 Those two operations convert a handle to a PRIME file descriptor and
895 vice versa. Drivers must use the kernel dma-buf buffer sharing framework
896 to manage the PRIME file descriptors. Similar to the mode setting
897 API PRIME is agnostic to the underlying buffer object manager, as
898 long as handles are 32bit unsigned integers.
899 </para>
900 <para>
901 While non-GEM drivers must implement the operations themselves, GEM
902 drivers must use the <function>drm_gem_prime_handle_to_fd</function>
903 and <function>drm_gem_prime_fd_to_handle</function> helper functions.
904 Those helpers rely on the driver
905 <methodname>gem_prime_export</methodname> and
906 <methodname>gem_prime_import</methodname> operations to create a dma-buf
907 instance from a GEM object (dma-buf exporter role) and to create a GEM
908 object from a dma-buf instance (dma-buf importer role).
909 </para>
910 <para>
911 <synopsis>struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
912 struct drm_gem_object *obj,
913 int flags);
Daniel Vetter251261d2014-01-22 18:46:33 +0100914struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
Thierry Reding79058102014-11-03 14:45:44 +0100915 struct dma_buf *dma_buf);</synopsis>
916 These two operations are mandatory for GEM drivers that support
917 PRIME.
918 </para>
Daniel Vetter251261d2014-01-22 18:46:33 +0100919 </sect3>
Thierry Reding79058102014-11-03 14:45:44 +0100920 <sect3>
921 <title>PRIME Helper Functions</title>
922!Pdrivers/gpu/drm/drm_prime.c PRIME Helpers
923 </sect3>
924 </sect2>
925 <sect2>
926 <title>PRIME Function References</title>
Daniel Vetter39cc3442014-01-22 19:16:30 +0100927!Edrivers/gpu/drm/drm_prime.c
Thierry Reding79058102014-11-03 14:45:44 +0100928 </sect2>
929 <sect2>
930 <title>DRM MM Range Allocator</title>
931 <sect3>
932 <title>Overview</title>
Daniel Vetter93110be2014-01-23 00:31:48 +0100933!Pdrivers/gpu/drm/drm_mm.c Overview
Thierry Reding79058102014-11-03 14:45:44 +0100934 </sect3>
935 <sect3>
936 <title>LRU Scan/Eviction Support</title>
Daniel Vetter93110be2014-01-23 00:31:48 +0100937!Pdrivers/gpu/drm/drm_mm.c lru scan roaster
Thierry Reding79058102014-11-03 14:45:44 +0100938 </sect3>
Daniel Vetter93110be2014-01-23 00:31:48 +0100939 </sect2>
Thierry Reding79058102014-11-03 14:45:44 +0100940 <sect2>
941 <title>DRM MM Range Allocator Function References</title>
Daniel Vettere18c0412014-01-23 00:39:13 +0100942!Edrivers/gpu/drm/drm_mm.c
943!Iinclude/drm/drm_mm.h
Thierry Reding79058102014-11-03 14:45:44 +0100944 </sect2>
Thierry Redingd7883f82014-11-03 13:56:55 +0100945 <sect2>
946 <title>CMA Helper Functions Reference</title>
947!Pdrivers/gpu/drm/drm_gem_cma_helper.c cma helpers
948!Edrivers/gpu/drm/drm_gem_cma_helper.c
949!Iinclude/drm/drm_gem_cma_helper.h
950 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200951 </sect1>
952
953 <!-- Internals: mode setting -->
954
955 <sect1 id="drm-mode-setting">
956 <title>Mode Setting</title>
957 <para>
958 Drivers must initialize the mode setting core by calling
959 <function>drm_mode_config_init</function> on the DRM device. The function
960 initializes the <structname>drm_device</structname>
961 <structfield>mode_config</structfield> field and never fails. Once done,
962 mode configuration must be setup by initializing the following fields.
963 </para>
964 <itemizedlist>
965 <listitem>
966 <synopsis>int min_width, min_height;
967int max_width, max_height;</synopsis>
968 <para>
969 Minimum and maximum width and height of the frame buffers in pixel
970 units.
Jesse Barnes2d2ef822009-10-26 13:06:31 -0700971 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200972 </listitem>
973 <listitem>
974 <synopsis>struct drm_mode_config_funcs *funcs;</synopsis>
975 <para>Mode setting functions.</para>
976 </listitem>
977 </itemizedlist>
978 <sect2>
Daniel Vetter3ec0db82014-01-23 15:06:15 +0100979 <title>Display Modes Function Reference</title>
Daniel Vetterf5aabb92014-01-23 20:05:00 +0100980!Iinclude/drm/drm_modes.h
Daniel Vetter3ec0db82014-01-23 15:06:15 +0100981!Edrivers/gpu/drm/drm_modes.c
982 </sect2>
983 <sect2>
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200984 <title>Atomic Mode Setting Function Reference</title>
985!Edrivers/gpu/drm/drm_atomic.c
Daniel Vetterc0714fc2015-12-04 09:45:57 +0100986!Idrivers/gpu/drm/drm_atomic.c
Daniel Vettercc4ceb42014-07-25 21:30:38 +0200987 </sect2>
988 <sect2>
Daniel Vetterd55f5322015-12-08 09:49:19 +0100989 <title>Frame Buffer Abstraction</title>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +0200990 <para>
991 Frame buffers are abstract memory objects that provide a source of
992 pixels to scanout to a CRTC. Applications explicitly request the
993 creation of frame buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and
994 receive an opaque handle that can be passed to the KMS CRTC control,
995 plane configuration and page flip functions.
996 </para>
997 <para>
998 Frame buffers rely on the underneath memory manager for low-level memory
999 operations. When creating a frame buffer applications pass a memory
1000 handle (or a list of memory handles for multi-planar formats) through
Daniel Vetter065a5022014-01-21 12:01:41 +01001001 the <parameter>drm_mode_fb_cmd2</parameter> argument. For drivers using
1002 GEM as their userspace buffer management interface this would be a GEM
1003 handle. Drivers are however free to use their own backing storage object
1004 handles, e.g. vmwgfx directly exposes special TTM handles to userspace
1005 and so expects TTM handles in the create ioctl and not GEM handles.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001006 </para>
1007 <para>
Daniel Vetter5d7a9512013-01-04 22:31:20 +01001008 The lifetime of a drm framebuffer is controlled with a reference count,
1009 drivers can grab additional references with
Daniel Vetter9ee984a2014-01-23 21:57:37 +01001010 <function>drm_framebuffer_reference</function>and drop them
Daniel Vetter5d7a9512013-01-04 22:31:20 +01001011 again with <function>drm_framebuffer_unreference</function>. For
1012 driver-private framebuffers for which the last reference is never
1013 dropped (e.g. for the fbdev framebuffer when the struct
1014 <structname>drm_framebuffer</structname> is embedded into the fbdev
1015 helper struct) drivers can manually clean up a framebuffer at module
1016 unload time with
1017 <function>drm_framebuffer_unregister_private</function>.
Daniel Vetter9ee984a2014-01-23 21:57:37 +01001018 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001019 </sect2>
1020 <sect2>
Daniel Vetter065a5022014-01-21 12:01:41 +01001021 <title>Dumb Buffer Objects</title>
1022 <para>
1023 The KMS API doesn't standardize backing storage object creation and
1024 leaves it to driver-specific ioctls. Furthermore actually creating a
1025 buffer object even for GEM-based drivers is done through a
1026 driver-specific ioctl - GEM only has a common userspace interface for
1027 sharing and destroying objects. While not an issue for full-fledged
1028 graphics stacks that include device-specific userspace components (in
1029 libdrm for instance), this limit makes DRM-based early boot graphics
1030 unnecessarily complex.
1031 </para>
1032 <para>
1033 Dumb objects partly alleviate the problem by providing a standard
1034 API to create dumb buffers suitable for scanout, which can then be used
1035 to create KMS frame buffers.
1036 </para>
1037 <para>
1038 To support dumb objects drivers must implement the
1039 <methodname>dumb_create</methodname>,
1040 <methodname>dumb_destroy</methodname> and
1041 <methodname>dumb_map_offset</methodname> operations.
1042 </para>
1043 <itemizedlist>
1044 <listitem>
1045 <synopsis>int (*dumb_create)(struct drm_file *file_priv, struct drm_device *dev,
1046 struct drm_mode_create_dumb *args);</synopsis>
1047 <para>
1048 The <methodname>dumb_create</methodname> operation creates a driver
1049 object (GEM or TTM handle) suitable for scanout based on the
1050 width, height and depth from the struct
1051 <structname>drm_mode_create_dumb</structname> argument. It fills the
1052 argument's <structfield>handle</structfield>,
1053 <structfield>pitch</structfield> and <structfield>size</structfield>
1054 fields with a handle for the newly created object and its line
1055 pitch and size in bytes.
1056 </para>
1057 </listitem>
1058 <listitem>
1059 <synopsis>int (*dumb_destroy)(struct drm_file *file_priv, struct drm_device *dev,
1060 uint32_t handle);</synopsis>
1061 <para>
1062 The <methodname>dumb_destroy</methodname> operation destroys a dumb
1063 object created by <methodname>dumb_create</methodname>.
1064 </para>
1065 </listitem>
1066 <listitem>
1067 <synopsis>int (*dumb_map_offset)(struct drm_file *file_priv, struct drm_device *dev,
1068 uint32_t handle, uint64_t *offset);</synopsis>
1069 <para>
1070 The <methodname>dumb_map_offset</methodname> operation associates an
1071 mmap fake offset with the object given by the handle and returns
1072 it. Drivers must use the
1073 <function>drm_gem_create_mmap_offset</function> function to
1074 associate the fake offset as described in
1075 <xref linkend="drm-gem-objects-mapping"/>.
1076 </para>
1077 </listitem>
1078 </itemizedlist>
1079 <para>
1080 Note that dumb objects may not be used for gpu acceleration, as has been
1081 attempted on some ARM embedded platforms. Such drivers really must have
1082 a hardware-specific ioctl to allocate suitable buffer objects.
1083 </para>
1084 </sect2>
1085 <sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001086 <title>Output Polling</title>
1087 <synopsis>void (*output_poll_changed)(struct drm_device *dev);</synopsis>
1088 <para>
1089 This operation notifies the driver that the status of one or more
1090 connectors has changed. Drivers that use the fb helper can just call the
1091 <function>drm_fb_helper_hotplug_event</function> function to handle this
1092 operation.
1093 </para>
1094 </sect2>
Daniel Vetter5d7a9512013-01-04 22:31:20 +01001095 <sect2>
1096 <title>Locking</title>
1097 <para>
1098 Beside some lookup structures with their own locking (which is hidden
1099 behind the interface functions) most of the modeset state is protected
1100 by the <code>dev-&lt;mode_config.lock</code> mutex and additionally
1101 per-crtc locks to allow cursor updates, pageflips and similar operations
1102 to occur concurrently with background tasks like output detection.
1103 Operations which cross domains like a full modeset always grab all
1104 locks. Drivers there need to protect resources shared between crtcs with
1105 additional locking. They also need to be careful to always grab the
1106 relevant crtc locks if a modset functions touches crtc state, e.g. for
1107 load detection (which does only grab the <code>mode_config.lock</code>
1108 to allow concurrent screen updates on live crtcs).
1109 </para>
1110 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001111 </sect1>
1112
1113 <!-- Internals: kms initialization and cleanup -->
1114
1115 <sect1 id="drm-kms-init">
1116 <title>KMS Initialization and Cleanup</title>
1117 <para>
1118 A KMS device is abstracted and exposed as a set of planes, CRTCs, encoders
1119 and connectors. KMS drivers must thus create and initialize all those
1120 objects at load time after initializing mode setting.
1121 </para>
1122 <sect2>
1123 <title>CRTCs (struct <structname>drm_crtc</structname>)</title>
1124 <para>
1125 A CRTC is an abstraction representing a part of the chip that contains a
1126 pointer to a scanout buffer. Therefore, the number of CRTCs available
1127 determines how many independent scanout buffers can be active at any
1128 given time. The CRTC structure contains several fields to support this:
1129 a pointer to some video memory (abstracted as a frame buffer object), a
1130 display mode, and an (x, y) offset into the video memory to support
1131 panning or configurations where one piece of video memory spans multiple
1132 CRTCs.
1133 </para>
1134 <sect3>
1135 <title>CRTC Initialization</title>
1136 <para>
1137 A KMS device must create and register at least one struct
1138 <structname>drm_crtc</structname> instance. The instance is allocated
1139 and zeroed by the driver, possibly as part of a larger structure, and
1140 registered with a call to <function>drm_crtc_init</function> with a
1141 pointer to CRTC functions.
1142 </para>
1143 </sect3>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001144 </sect2>
1145 <sect2>
1146 <title>Planes (struct <structname>drm_plane</structname>)</title>
1147 <para>
1148 A plane represents an image source that can be blended with or overlayed
1149 on top of a CRTC during the scanout process. Planes are associated with
1150 a frame buffer to crop a portion of the image memory (source) and
1151 optionally scale it to a destination size. The result is then blended
1152 with or overlayed on top of a CRTC.
1153 </para>
Matt Roper6efa1f22014-04-01 15:22:43 -07001154 <para>
1155 The DRM core recognizes three types of planes:
1156 <itemizedlist>
1157 <listitem>
1158 DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary
Thierry Redingef21bf72014-12-17 16:13:17 +01001159 planes are the planes operated upon by CRTC modesetting and flipping
Daniel Vetterf6da8c62015-12-04 09:46:00 +01001160 operations described in the page_flip hook in <structname>drm_crtc_funcs</structname>.
Matt Roper6efa1f22014-04-01 15:22:43 -07001161 </listitem>
1162 <listitem>
1163 DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. Cursor
1164 planes are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
1165 DRM_IOCTL_MODE_CURSOR2 ioctls.
1166 </listitem>
1167 <listitem>
1168 DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor planes.
1169 Some drivers refer to these types of planes as "sprites" internally.
1170 </listitem>
1171 </itemizedlist>
1172 For compatibility with legacy userspace, only overlay planes are made
1173 available to userspace by default. Userspace clients may set the
1174 DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that
1175 they wish to receive a universal plane list containing all plane types.
1176 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001177 <sect3>
1178 <title>Plane Initialization</title>
1179 <para>
Matt Roper6efa1f22014-04-01 15:22:43 -07001180 To create a plane, a KMS drivers allocates and
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001181 zeroes an instances of struct <structname>drm_plane</structname>
1182 (possibly as part of a larger structure) and registers it with a call
Matt Roper6efa1f22014-04-01 15:22:43 -07001183 to <function>drm_universal_plane_init</function>. The function takes a bitmask
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001184 of the CRTCs that can be associated with the plane, a pointer to the
Matt Roper6efa1f22014-04-01 15:22:43 -07001185 plane functions, a list of format supported formats, and the type of
1186 plane (primary, cursor, or overlay) being initialized.
1187 </para>
1188 <para>
1189 Cursor and overlay planes are optional. All drivers should provide
1190 one primary plane per CRTC (although this requirement may change in
1191 the future); drivers that do not wish to provide special handling for
1192 primary planes may make use of the helper functions described in
1193 <xref linkend="drm-kms-planehelpers"/> to create and register a
1194 primary plane with standard capabilities.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001195 </para>
1196 </sect3>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001197 </sect2>
1198 <sect2>
1199 <title>Encoders (struct <structname>drm_encoder</structname>)</title>
1200 <para>
1201 An encoder takes pixel data from a CRTC and converts it to a format
1202 suitable for any attached connectors. On some devices, it may be
1203 possible to have a CRTC send data to more than one encoder. In that
1204 case, both encoders would receive data from the same scanout buffer,
1205 resulting in a "cloned" display configuration across the connectors
1206 attached to each encoder.
1207 </para>
1208 <sect3>
1209 <title>Encoder Initialization</title>
1210 <para>
1211 As for CRTCs, a KMS driver must create, initialize and register at
1212 least one struct <structname>drm_encoder</structname> instance. The
1213 instance is allocated and zeroed by the driver, possibly as part of a
1214 larger structure.
1215 </para>
1216 <para>
1217 Drivers must initialize the struct <structname>drm_encoder</structname>
1218 <structfield>possible_crtcs</structfield> and
1219 <structfield>possible_clones</structfield> fields before registering the
1220 encoder. Both fields are bitmasks of respectively the CRTCs that the
1221 encoder can be connected to, and sibling encoders candidate for cloning.
1222 </para>
1223 <para>
1224 After being initialized, the encoder must be registered with a call to
1225 <function>drm_encoder_init</function>. The function takes a pointer to
1226 the encoder functions and an encoder type. Supported types are
1227 <itemizedlist>
1228 <listitem>
1229 DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A
1230 </listitem>
1231 <listitem>
1232 DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort
1233 </listitem>
1234 <listitem>
1235 DRM_MODE_ENCODER_LVDS for display panels
1236 </listitem>
1237 <listitem>
1238 DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, Component,
1239 SCART)
1240 </listitem>
1241 <listitem>
1242 DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
1243 </listitem>
1244 </itemizedlist>
1245 </para>
1246 <para>
1247 Encoders must be attached to a CRTC to be used. DRM drivers leave
1248 encoders unattached at initialization time. Applications (or the fbdev
1249 compatibility layer when implemented) are responsible for attaching the
1250 encoders they want to use to a CRTC.
1251 </para>
1252 </sect3>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001253 </sect2>
1254 <sect2>
1255 <title>Connectors (struct <structname>drm_connector</structname>)</title>
1256 <para>
1257 A connector is the final destination for pixel data on a device, and
1258 usually connects directly to an external display device like a monitor
1259 or laptop panel. A connector can only be attached to one encoder at a
1260 time. The connector is also the structure where information about the
1261 attached display is kept, so it contains fields for display data, EDID
1262 data, DPMS &amp; connection status, and information about modes
1263 supported on the attached displays.
1264 </para>
1265 <sect3>
1266 <title>Connector Initialization</title>
1267 <para>
1268 Finally a KMS driver must create, initialize, register and attach at
1269 least one struct <structname>drm_connector</structname> instance. The
1270 instance is created as other KMS objects and initialized by setting the
1271 following fields.
1272 </para>
1273 <variablelist>
1274 <varlistentry>
1275 <term><structfield>interlace_allowed</structfield></term>
1276 <listitem><para>
1277 Whether the connector can handle interlaced modes.
1278 </para></listitem>
1279 </varlistentry>
1280 <varlistentry>
1281 <term><structfield>doublescan_allowed</structfield></term>
1282 <listitem><para>
1283 Whether the connector can handle doublescan.
1284 </para></listitem>
1285 </varlistentry>
1286 <varlistentry>
1287 <term><structfield>display_info
1288 </structfield></term>
1289 <listitem><para>
1290 Display information is filled from EDID information when a display
1291 is detected. For non hot-pluggable displays such as flat panels in
1292 embedded systems, the driver should initialize the
1293 <structfield>display_info</structfield>.<structfield>width_mm</structfield>
1294 and
1295 <structfield>display_info</structfield>.<structfield>height_mm</structfield>
1296 fields with the physical size of the display.
1297 </para></listitem>
1298 </varlistentry>
1299 <varlistentry>
1300 <term id="drm-kms-connector-polled"><structfield>polled</structfield></term>
1301 <listitem><para>
1302 Connector polling mode, a combination of
1303 <variablelist>
1304 <varlistentry>
1305 <term>DRM_CONNECTOR_POLL_HPD</term>
1306 <listitem><para>
1307 The connector generates hotplug events and doesn't need to be
1308 periodically polled. The CONNECT and DISCONNECT flags must not
1309 be set together with the HPD flag.
1310 </para></listitem>
1311 </varlistentry>
1312 <varlistentry>
1313 <term>DRM_CONNECTOR_POLL_CONNECT</term>
1314 <listitem><para>
1315 Periodically poll the connector for connection.
1316 </para></listitem>
1317 </varlistentry>
1318 <varlistentry>
1319 <term>DRM_CONNECTOR_POLL_DISCONNECT</term>
1320 <listitem><para>
1321 Periodically poll the connector for disconnection.
1322 </para></listitem>
1323 </varlistentry>
1324 </variablelist>
1325 Set to 0 for connectors that don't support connection status
1326 discovery.
1327 </para></listitem>
1328 </varlistentry>
1329 </variablelist>
1330 <para>
1331 The connector is then registered with a call to
1332 <function>drm_connector_init</function> with a pointer to the connector
1333 functions and a connector type, and exposed through sysfs with a call to
Thomas Wood34ea3d32014-05-29 16:57:41 +01001334 <function>drm_connector_register</function>.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001335 </para>
1336 <para>
1337 Supported connector types are
1338 <itemizedlist>
1339 <listitem>DRM_MODE_CONNECTOR_VGA</listitem>
1340 <listitem>DRM_MODE_CONNECTOR_DVII</listitem>
1341 <listitem>DRM_MODE_CONNECTOR_DVID</listitem>
1342 <listitem>DRM_MODE_CONNECTOR_DVIA</listitem>
1343 <listitem>DRM_MODE_CONNECTOR_Composite</listitem>
1344 <listitem>DRM_MODE_CONNECTOR_SVIDEO</listitem>
1345 <listitem>DRM_MODE_CONNECTOR_LVDS</listitem>
1346 <listitem>DRM_MODE_CONNECTOR_Component</listitem>
1347 <listitem>DRM_MODE_CONNECTOR_9PinDIN</listitem>
1348 <listitem>DRM_MODE_CONNECTOR_DisplayPort</listitem>
1349 <listitem>DRM_MODE_CONNECTOR_HDMIA</listitem>
1350 <listitem>DRM_MODE_CONNECTOR_HDMIB</listitem>
1351 <listitem>DRM_MODE_CONNECTOR_TV</listitem>
1352 <listitem>DRM_MODE_CONNECTOR_eDP</listitem>
1353 <listitem>DRM_MODE_CONNECTOR_VIRTUAL</listitem>
1354 </itemizedlist>
1355 </para>
1356 <para>
1357 Connectors must be attached to an encoder to be used. For devices that
1358 map connectors to encoders 1:1, the connector should be attached at
1359 initialization time with a call to
1360 <function>drm_mode_connector_attach_encoder</function>. The driver must
1361 also set the <structname>drm_connector</structname>
1362 <structfield>encoder</structfield> field to point to the attached
1363 encoder.
1364 </para>
1365 <para>
1366 Finally, drivers must initialize the connectors state change detection
1367 with a call to <function>drm_kms_helper_poll_init</function>. If at
1368 least one connector is pollable but can't generate hotplug interrupts
1369 (indicated by the DRM_CONNECTOR_POLL_CONNECT and
1370 DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will
1371 automatically be queued to periodically poll for changes. Connectors
1372 that can generate hotplug interrupts must be marked with the
1373 DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must
1374 call <function>drm_helper_hpd_irq_event</function>. The function will
1375 queue a delayed work to check the state of all connectors, but no
1376 periodic polling will be done.
1377 </para>
1378 </sect3>
1379 <sect3>
1380 <title>Connector Operations</title>
1381 <note><para>
1382 Unless otherwise state, all operations are mandatory.
1383 </para></note>
1384 <sect4>
1385 <title>DPMS</title>
1386 <synopsis>void (*dpms)(struct drm_connector *connector, int mode);</synopsis>
1387 <para>
1388 The DPMS operation sets the power state of a connector. The mode
1389 argument is one of
1390 <itemizedlist>
1391 <listitem><para>DRM_MODE_DPMS_ON</para></listitem>
1392 <listitem><para>DRM_MODE_DPMS_STANDBY</para></listitem>
1393 <listitem><para>DRM_MODE_DPMS_SUSPEND</para></listitem>
1394 <listitem><para>DRM_MODE_DPMS_OFF</para></listitem>
1395 </itemizedlist>
1396 </para>
1397 <para>
1398 In all but DPMS_ON mode the encoder to which the connector is attached
1399 should put the display in low-power mode by driving its signals
1400 appropriately. If more than one connector is attached to the encoder
1401 care should be taken not to change the power state of other displays as
1402 a side effect. Low-power mode should be propagated to the encoders and
1403 CRTCs when all related connectors are put in low-power mode.
1404 </para>
1405 </sect4>
1406 <sect4>
1407 <title>Modes</title>
1408 <synopsis>int (*fill_modes)(struct drm_connector *connector, uint32_t max_width,
1409 uint32_t max_height);</synopsis>
1410 <para>
1411 Fill the mode list with all supported modes for the connector. If the
1412 <parameter>max_width</parameter> and <parameter>max_height</parameter>
1413 arguments are non-zero, the implementation must ignore all modes wider
1414 than <parameter>max_width</parameter> or higher than
1415 <parameter>max_height</parameter>.
1416 </para>
1417 <para>
1418 The connector must also fill in this operation its
1419 <structfield>display_info</structfield>
1420 <structfield>width_mm</structfield> and
1421 <structfield>height_mm</structfield> fields with the connected display
1422 physical size in millimeters. The fields should be set to 0 if the value
1423 isn't known or is not applicable (for instance for projector devices).
1424 </para>
1425 </sect4>
1426 <sect4>
1427 <title>Connection Status</title>
1428 <para>
1429 The connection status is updated through polling or hotplug events when
1430 supported (see <xref linkend="drm-kms-connector-polled"/>). The status
1431 value is reported to userspace through ioctls and must not be used
1432 inside the driver, as it only gets initialized by a call to
1433 <function>drm_mode_getconnector</function> from userspace.
1434 </para>
1435 <synopsis>enum drm_connector_status (*detect)(struct drm_connector *connector,
1436 bool force);</synopsis>
1437 <para>
1438 Check to see if anything is attached to the connector. The
1439 <parameter>force</parameter> parameter is set to false whilst polling or
1440 to true when checking the connector due to user request.
1441 <parameter>force</parameter> can be used by the driver to avoid
1442 expensive, destructive operations during automated probing.
1443 </para>
1444 <para>
1445 Return connector_status_connected if something is connected to the
1446 connector, connector_status_disconnected if nothing is connected and
1447 connector_status_unknown if the connection state isn't known.
1448 </para>
1449 <para>
1450 Drivers should only return connector_status_connected if the connection
1451 status has really been probed as connected. Connectors that can't detect
1452 the connection status, or failed connection status probes, should return
1453 connector_status_unknown.
1454 </para>
1455 </sect4>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001456 </sect3>
1457 </sect2>
1458 <sect2>
1459 <title>Cleanup</title>
1460 <para>
1461 The DRM core manages its objects' lifetime. When an object is not needed
1462 anymore the core calls its destroy function, which must clean up and
1463 free every resource allocated for the object. Every
1464 <function>drm_*_init</function> call must be matched with a
1465 corresponding <function>drm_*_cleanup</function> call to cleanup CRTCs
1466 (<function>drm_crtc_cleanup</function>), planes
1467 (<function>drm_plane_cleanup</function>), encoders
1468 (<function>drm_encoder_cleanup</function>) and connectors
1469 (<function>drm_connector_cleanup</function>). Furthermore, connectors
1470 that have been added to sysfs must be removed by a call to
Thomas Wood34ea3d32014-05-29 16:57:41 +01001471 <function>drm_connector_unregister</function> before calling
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001472 <function>drm_connector_cleanup</function>.
1473 </para>
1474 <para>
1475 Connectors state change detection must be cleanup up with a call to
1476 <function>drm_kms_helper_poll_fini</function>.
1477 </para>
1478 </sect2>
1479 <sect2>
1480 <title>Output discovery and initialization example</title>
1481 <programlisting><![CDATA[
Jesse Barnes2d2ef822009-10-26 13:06:31 -07001482void intel_crt_init(struct drm_device *dev)
1483{
1484 struct drm_connector *connector;
1485 struct intel_output *intel_output;
1486
1487 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
1488 if (!intel_output)
1489 return;
1490
1491 connector = &intel_output->base;
1492 drm_connector_init(dev, &intel_output->base,
1493 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
1494
1495 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
1496 DRM_MODE_ENCODER_DAC);
1497
1498 drm_mode_connector_attach_encoder(&intel_output->base,
1499 &intel_output->enc);
1500
1501 /* Set up the DDC bus. */
1502 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
1503 if (!intel_output->ddc_bus) {
1504 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
1505 "failed.\n");
1506 return;
1507 }
1508
1509 intel_output->type = INTEL_OUTPUT_ANALOG;
1510 connector->interlace_allowed = 0;
1511 connector->doublescan_allowed = 0;
1512
1513 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
1514 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
1515
Thomas Wood34ea3d32014-05-29 16:57:41 +01001516 drm_connector_register(connector);
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001517}]]></programlisting>
1518 <para>
1519 In the example above (taken from the i915 driver), a CRTC, connector and
1520 encoder combination is created. A device-specific i2c bus is also
1521 created for fetching EDID data and performing monitor detection. Once
1522 the process is complete, the new connector is registered with sysfs to
1523 make its properties available to applications.
1524 </para>
1525 </sect2>
Daniel Vetter065a50ed2012-12-02 00:09:18 +01001526 <sect2>
1527 <title>KMS API Functions</title>
1528!Edrivers/gpu/drm/drm_crtc.c
1529 </sect2>
Rob Clark51fd3712013-11-19 12:10:12 -05001530 <sect2>
Daniel Vetter3bf04012014-10-27 16:54:27 +01001531 <title>KMS Data Structures</title>
1532!Iinclude/drm/drm_crtc.h
1533 </sect2>
1534 <sect2>
Rob Clark51fd3712013-11-19 12:10:12 -05001535 <title>KMS Locking</title>
1536!Pdrivers/gpu/drm/drm_modeset_lock.c kms locking
1537!Iinclude/drm/drm_modeset_lock.h
1538!Edrivers/gpu/drm/drm_modeset_lock.c
1539 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001540 </sect1>
1541
Daniel Vettere4949f22012-11-01 14:45:15 +01001542 <!-- Internals: kms helper functions -->
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001543
1544 <sect1>
Daniel Vettere4949f22012-11-01 14:45:15 +01001545 <title>Mode Setting Helper Functions</title>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001546 <para>
Matt Roper6efa1f22014-04-01 15:22:43 -07001547 The plane, CRTC, encoder and connector functions provided by the drivers
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001548 implement the DRM API. They're called by the DRM core and ioctl handlers
1549 to handle device state changes and configuration request. As implementing
1550 those functions often requires logic not specific to drivers, mid-layer
1551 helper functions are available to avoid duplicating boilerplate code.
1552 </para>
1553 <para>
1554 The DRM core contains one mid-layer implementation. The mid-layer provides
Matt Roper6efa1f22014-04-01 15:22:43 -07001555 implementations of several plane, CRTC, encoder and connector functions
1556 (called from the top of the mid-layer) that pre-process requests and call
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001557 lower-level functions provided by the driver (at the bottom of the
1558 mid-layer). For instance, the
1559 <function>drm_crtc_helper_set_config</function> function can be used to
1560 fill the struct <structname>drm_crtc_funcs</structname>
1561 <structfield>set_config</structfield> field. When called, it will split
1562 the <methodname>set_config</methodname> operation in smaller, simpler
1563 operations and call the driver to handle them.
1564 </para>
1565 <para>
1566 To use the mid-layer, drivers call <function>drm_crtc_helper_add</function>,
1567 <function>drm_encoder_helper_add</function> and
1568 <function>drm_connector_helper_add</function> functions to install their
1569 mid-layer bottom operations handlers, and fill the
1570 <structname>drm_crtc_funcs</structname>,
1571 <structname>drm_encoder_funcs</structname> and
1572 <structname>drm_connector_funcs</structname> structures with pointers to
1573 the mid-layer top API functions. Installing the mid-layer bottom operation
1574 handlers is best done right after registering the corresponding KMS object.
1575 </para>
1576 <para>
1577 The mid-layer is not split between CRTC, encoder and connector operations.
1578 To use it, a driver must provide bottom functions for all of the three KMS
1579 entities.
1580 </para>
1581 <sect2>
Daniel Vetter2be94972015-12-04 09:45:46 +01001582 <title>Legacy CRTC Helper Operations</title>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001583 <itemizedlist>
1584 <listitem id="drm-helper-crtc-mode-fixup">
1585 <synopsis>bool (*mode_fixup)(struct drm_crtc *crtc,
1586 const struct drm_display_mode *mode,
1587 struct drm_display_mode *adjusted_mode);</synopsis>
1588 <para>
1589 Let CRTCs adjust the requested mode or reject it completely. This
1590 operation returns true if the mode is accepted (possibly after being
1591 adjusted) or false if it is rejected.
1592 </para>
1593 <para>
1594 The <methodname>mode_fixup</methodname> operation should reject the
1595 mode if it can't reasonably use it. The definition of "reasonable"
1596 is currently fuzzy in this context. One possible behaviour would be
1597 to set the adjusted mode to the panel timings when a fixed-mode
1598 panel is used with hardware capable of scaling. Another behaviour
1599 would be to accept any input mode and adjust it to the closest mode
1600 supported by the hardware (FIXME: This needs to be clarified).
1601 </para>
1602 </listitem>
1603 <listitem>
1604 <synopsis>int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
1605 struct drm_framebuffer *old_fb)</synopsis>
1606 <para>
1607 Move the CRTC on the current frame buffer (stored in
1608 <literal>crtc-&gt;fb</literal>) to position (x,y). Any of the frame
1609 buffer, x position or y position may have been modified.
1610 </para>
1611 <para>
1612 This helper operation is optional. If not provided, the
1613 <function>drm_crtc_helper_set_config</function> function will fall
1614 back to the <methodname>mode_set</methodname> helper operation.
1615 </para>
1616 <note><para>
1617 FIXME: Why are x and y passed as arguments, as they can be accessed
1618 through <literal>crtc-&gt;x</literal> and
1619 <literal>crtc-&gt;y</literal>?
1620 </para></note>
1621 </listitem>
1622 <listitem>
1623 <synopsis>void (*prepare)(struct drm_crtc *crtc);</synopsis>
1624 <para>
1625 Prepare the CRTC for mode setting. This operation is called after
1626 validating the requested mode. Drivers use it to perform
1627 device-specific operations required before setting the new mode.
1628 </para>
1629 </listitem>
1630 <listitem>
1631 <synopsis>int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
1632 struct drm_display_mode *adjusted_mode, int x, int y,
1633 struct drm_framebuffer *old_fb);</synopsis>
1634 <para>
1635 Set a new mode, position and frame buffer. Depending on the device
1636 requirements, the mode can be stored internally by the driver and
1637 applied in the <methodname>commit</methodname> operation, or
1638 programmed to the hardware immediately.
1639 </para>
1640 <para>
1641 The <methodname>mode_set</methodname> operation returns 0 on success
1642 or a negative error code if an error occurs.
1643 </para>
1644 </listitem>
1645 <listitem>
1646 <synopsis>void (*commit)(struct drm_crtc *crtc);</synopsis>
1647 <para>
1648 Commit a mode. This operation is called after setting the new mode.
1649 Upon return the device must use the new mode and be fully
1650 operational.
1651 </para>
1652 </listitem>
1653 </itemizedlist>
1654 </sect2>
1655 <sect2>
1656 <title>Encoder Helper Operations</title>
1657 <itemizedlist>
1658 <listitem>
1659 <synopsis>bool (*mode_fixup)(struct drm_encoder *encoder,
1660 const struct drm_display_mode *mode,
1661 struct drm_display_mode *adjusted_mode);</synopsis>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001662 <para>
1663 Let encoders adjust the requested mode or reject it completely. This
1664 operation returns true if the mode is accepted (possibly after being
1665 adjusted) or false if it is rejected. See the
1666 <link linkend="drm-helper-crtc-mode-fixup">mode_fixup CRTC helper
1667 operation</link> for an explanation of the allowed adjustments.
1668 </para>
1669 </listitem>
1670 <listitem>
1671 <synopsis>void (*prepare)(struct drm_encoder *encoder);</synopsis>
1672 <para>
1673 Prepare the encoder for mode setting. This operation is called after
1674 validating the requested mode. Drivers use it to perform
1675 device-specific operations required before setting the new mode.
1676 </para>
1677 </listitem>
1678 <listitem>
1679 <synopsis>void (*mode_set)(struct drm_encoder *encoder,
1680 struct drm_display_mode *mode,
1681 struct drm_display_mode *adjusted_mode);</synopsis>
1682 <para>
1683 Set a new mode. Depending on the device requirements, the mode can
1684 be stored internally by the driver and applied in the
1685 <methodname>commit</methodname> operation, or programmed to the
1686 hardware immediately.
1687 </para>
1688 </listitem>
1689 <listitem>
1690 <synopsis>void (*commit)(struct drm_encoder *encoder);</synopsis>
1691 <para>
1692 Commit a mode. This operation is called after setting the new mode.
1693 Upon return the device must use the new mode and be fully
1694 operational.
1695 </para>
1696 </listitem>
1697 </itemizedlist>
1698 </sect2>
1699 <sect2>
1700 <title>Connector Helper Operations</title>
1701 <itemizedlist>
1702 <listitem>
1703 <synopsis>struct drm_encoder *(*best_encoder)(struct drm_connector *connector);</synopsis>
1704 <para>
1705 Return a pointer to the best encoder for the connecter. Device that
1706 map connectors to encoders 1:1 simply return the pointer to the
1707 associated encoder. This operation is mandatory.
1708 </para>
1709 </listitem>
1710 <listitem>
1711 <synopsis>int (*get_modes)(struct drm_connector *connector);</synopsis>
1712 <para>
1713 Fill the connector's <structfield>probed_modes</structfield> list
Laurent Pinchartf41c2582014-12-10 21:11:31 +02001714 by parsing EDID data with <function>drm_add_edid_modes</function>,
1715 adding standard VESA DMT modes with <function>drm_add_modes_noedid</function>,
1716 or calling <function>drm_mode_probed_add</function> directly for every
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001717 supported mode and return the number of modes it has detected. This
1718 operation is mandatory.
1719 </para>
1720 <para>
Laurent Pinchartf41c2582014-12-10 21:11:31 +02001721 Note that the caller function will automatically add standard VESA
1722 DMT modes up to 1024x768 if the <methodname>get_modes</methodname>
1723 helper operation returns no mode and if the connector status is
1724 connector_status_connected. There is no need to call
1725 <function>drm_add_edid_modes</function> manually in that case.
1726 </para>
1727 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001728 The <structfield>vrefresh</structfield> value is computed by
1729 <function>drm_helper_probe_single_connector_modes</function>.
1730 </para>
1731 <para>
Laurent Pinchartf41c2582014-12-10 21:11:31 +02001732 When parsing EDID data, <function>drm_add_edid_modes</function> fills the
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001733 connector <structfield>display_info</structfield>
1734 <structfield>width_mm</structfield> and
1735 <structfield>height_mm</structfield> fields. When creating modes
1736 manually the <methodname>get_modes</methodname> helper operation must
1737 set the <structfield>display_info</structfield>
1738 <structfield>width_mm</structfield> and
1739 <structfield>height_mm</structfield> fields if they haven't been set
Daniel Vetter065a5022014-01-21 12:01:41 +01001740 already (for instance at initialization time when a fixed-size panel is
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001741 attached to the connector). The mode <structfield>width_mm</structfield>
1742 and <structfield>height_mm</structfield> fields are only used internally
1743 during EDID parsing and should not be set when creating modes manually.
1744 </para>
1745 </listitem>
1746 <listitem>
1747 <synopsis>int (*mode_valid)(struct drm_connector *connector,
1748 struct drm_display_mode *mode);</synopsis>
1749 <para>
1750 Verify whether a mode is valid for the connector. Return MODE_OK for
1751 supported modes and one of the enum drm_mode_status values (MODE_*)
Andrzej Hajdaf9b0e252014-04-02 12:29:46 +02001752 for unsupported modes. This operation is optional.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001753 </para>
1754 <para>
1755 As the mode rejection reason is currently not used beside for
1756 immediately removing the unsupported mode, an implementation can
1757 return MODE_BAD regardless of the exact reason why the mode is not
1758 valid.
1759 </para>
1760 <note><para>
1761 Note that the <methodname>mode_valid</methodname> helper operation is
1762 only called for modes detected by the device, and
1763 <emphasis>not</emphasis> for modes set by the user through the CRTC
1764 <methodname>set_config</methodname> operation.
1765 </para></note>
1766 </listitem>
1767 </itemizedlist>
1768 </sect2>
Daniel Vetter0d4ed4c2012-11-01 14:45:16 +01001769 <sect2>
Daniel Vetter3150c7d2014-11-06 20:53:29 +01001770 <title>Atomic Modeset Helper Functions Reference</title>
1771 <sect3>
1772 <title>Overview</title>
1773!Pdrivers/gpu/drm/drm_atomic_helper.c overview
1774 </sect3>
1775 <sect3>
1776 <title>Implementing Asynchronous Atomic Commit</title>
1777!Pdrivers/gpu/drm/drm_atomic_helper.c implementing async commit
1778 </sect3>
1779 <sect3>
1780 <title>Atomic State Reset and Initialization</title>
1781!Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
1782 </sect3>
Rob Clarkdd275952014-11-25 20:29:46 -05001783!Iinclude/drm/drm_atomic_helper.h
Daniel Vetter3150c7d2014-11-06 20:53:29 +01001784!Edrivers/gpu/drm/drm_atomic_helper.c
1785 </sect2>
1786 <sect2>
Daniel Vetter092d01d2015-12-04 09:45:44 +01001787 <title>Modeset Helper Reference for Common Vtables</title>
1788!Iinclude/drm/drm_modeset_helper_vtables.h
1789!Pinclude/drm/drm_modeset_helper_vtables.h overview
1790 </sect2>
1791 <sect2>
Daniel Vetter2be94972015-12-04 09:45:46 +01001792 <title>Legacy CRTC/Modeset Helper Functions Reference</title>
Daniel Vetter0d4ed4c2012-11-01 14:45:16 +01001793!Edrivers/gpu/drm/drm_crtc_helper.c
Daniel Vetter3150c7d2014-11-06 20:53:29 +01001794!Pdrivers/gpu/drm/drm_crtc_helper.c overview
Daniel Vetter0d4ed4c2012-11-01 14:45:16 +01001795 </sect2>
Daniel Vetterd0ddc0332012-11-01 14:45:17 +01001796 <sect2>
Daniel Vetter8d754542014-04-10 10:51:11 +02001797 <title>Output Probing Helper Functions Reference</title>
1798!Pdrivers/gpu/drm/drm_probe_helper.c output probing helper overview
1799!Edrivers/gpu/drm/drm_probe_helper.c
1800 </sect2>
1801 <sect2>
Daniel Vetterd0ddc0332012-11-01 14:45:17 +01001802 <title>fbdev Helper Functions Reference</title>
1803!Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers
1804!Edrivers/gpu/drm/drm_fb_helper.c
Daniel Vetter207fd322013-01-20 22:13:14 +01001805!Iinclude/drm/drm_fb_helper.h
Daniel Vetterd0ddc0332012-11-01 14:45:17 +01001806 </sect2>
Daniel Vetter28164fd2012-11-01 14:45:18 +01001807 <sect2>
1808 <title>Display Port Helper Functions Reference</title>
1809!Pdrivers/gpu/drm/drm_dp_helper.c dp helpers
1810!Iinclude/drm/drm_dp_helper.h
1811!Edrivers/gpu/drm/drm_dp_helper.c
1812 </sect2>
Thierry Reding5e308592013-01-14 09:00:31 +01001813 <sect2>
Dave Airliead7f8a12014-06-05 14:01:32 +10001814 <title>Display Port MST Helper Functions Reference</title>
1815!Pdrivers/gpu/drm/drm_dp_mst_topology.c dp mst helper
1816!Iinclude/drm/drm_dp_mst_helper.h
1817!Edrivers/gpu/drm/drm_dp_mst_topology.c
1818 </sect2>
1819 <sect2>
Thierry Reding009081e2014-08-05 10:41:13 +02001820 <title>MIPI DSI Helper Functions Reference</title>
1821!Pdrivers/gpu/drm/drm_mipi_dsi.c dsi helpers
1822!Iinclude/drm/drm_mipi_dsi.h
1823!Edrivers/gpu/drm/drm_mipi_dsi.c
1824 </sect2>
1825 <sect2>
Thierry Reding5e308592013-01-14 09:00:31 +01001826 <title>EDID Helper Functions Reference</title>
1827!Edrivers/gpu/drm/drm_edid.c
1828 </sect2>
Ville Syrjälä03973532013-05-08 17:16:45 +03001829 <sect2>
1830 <title>Rectangle Utilities Reference</title>
1831!Pinclude/drm/drm_rect.h rect utils
1832!Iinclude/drm/drm_rect.h
1833!Edrivers/gpu/drm/drm_rect.c
1834 </sect2>
David Herrmannfe3078f2013-07-24 21:06:15 +02001835 <sect2>
Rob Clarkcabaafc2013-08-07 14:41:54 -04001836 <title>Flip-work Helper Reference</title>
1837!Pinclude/drm/drm_flip_work.h flip utils
1838!Iinclude/drm/drm_flip_work.h
1839!Edrivers/gpu/drm/drm_flip_work.c
1840 </sect2>
Daniel Vetter2d123f42014-01-22 18:26:16 +01001841 <sect2>
1842 <title>HDMI Infoframes Helper Reference</title>
1843 <para>
1844 Strictly speaking this is not a DRM helper library but generally useable
1845 by any driver interfacing with HDMI outputs like v4l or alsa drivers.
1846 But it nicely fits into the overall topic of mode setting helper
1847 libraries and hence is also included here.
1848 </para>
1849!Iinclude/linux/hdmi.h
1850!Edrivers/video/hdmi.c
1851 </sect2>
Matt Roper6efa1f22014-04-01 15:22:43 -07001852 <sect2>
1853 <title id="drm-kms-planehelpers">Plane Helper Reference</title>
Daniel Vetter3150c7d2014-11-06 20:53:29 +01001854!Edrivers/gpu/drm/drm_plane_helper.c
1855!Pdrivers/gpu/drm/drm_plane_helper.c overview
Matt Roper6efa1f22014-04-01 15:22:43 -07001856 </sect2>
Dave Airlie138f9eb2014-10-20 16:17:17 +10001857 <sect2>
1858 <title>Tile group</title>
1859!Pdrivers/gpu/drm/drm_crtc.c Tile group
1860 </sect2>
Archit Taneja2331b4e2015-05-21 11:03:17 +05301861 <sect2>
1862 <title>Bridges</title>
1863 <sect3>
1864 <title>Overview</title>
1865!Pdrivers/gpu/drm/drm_bridge.c overview
1866 </sect3>
1867 <sect3>
1868 <title>Default bridge callback sequence</title>
1869!Pdrivers/gpu/drm/drm_bridge.c bridge callbacks
1870 </sect3>
1871!Edrivers/gpu/drm/drm_bridge.c
1872 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02001873 </sect1>
1874
Laurent Pinchart421cda32013-06-22 16:10:30 +02001875 <!-- Internals: kms properties -->
1876
1877 <sect1 id="drm-kms-properties">
1878 <title>KMS Properties</title>
1879 <para>
1880 Drivers may need to expose additional parameters to applications than
1881 those described in the previous sections. KMS supports attaching
1882 properties to CRTCs, connectors and planes and offers a userspace API to
1883 list, get and set the property values.
1884 </para>
1885 <para>
1886 Properties are identified by a name that uniquely defines the property
1887 purpose, and store an associated value. For all property types except blob
1888 properties the value is a 64-bit unsigned integer.
1889 </para>
1890 <para>
1891 KMS differentiates between properties and property instances. Drivers
1892 first create properties and then create and associate individual instances
1893 of those properties to objects. A property can be instantiated multiple
1894 times and associated with different objects. Values are stored in property
Masanari Iida9a6594f2014-05-15 13:54:06 -07001895 instances, and all other property information are stored in the property
Laurent Pinchart421cda32013-06-22 16:10:30 +02001896 and shared between all instances of the property.
1897 </para>
1898 <para>
1899 Every property is created with a type that influences how the KMS core
1900 handles the property. Supported property types are
1901 <variablelist>
1902 <varlistentry>
1903 <term>DRM_MODE_PROP_RANGE</term>
1904 <listitem><para>Range properties report their minimum and maximum
1905 admissible values. The KMS core verifies that values set by
1906 application fit in that range.</para></listitem>
1907 </varlistentry>
1908 <varlistentry>
1909 <term>DRM_MODE_PROP_ENUM</term>
1910 <listitem><para>Enumerated properties take a numerical value that
1911 ranges from 0 to the number of enumerated values defined by the
1912 property minus one, and associate a free-formed string name to each
1913 value. Applications can retrieve the list of defined value-name pairs
1914 and use the numerical value to get and set property instance values.
1915 </para></listitem>
1916 </varlistentry>
1917 <varlistentry>
1918 <term>DRM_MODE_PROP_BITMASK</term>
1919 <listitem><para>Bitmask properties are enumeration properties that
1920 additionally restrict all enumerated values to the 0..63 range.
1921 Bitmask property instance values combine one or more of the
1922 enumerated bits defined by the property.</para></listitem>
1923 </varlistentry>
1924 <varlistentry>
1925 <term>DRM_MODE_PROP_BLOB</term>
1926 <listitem><para>Blob properties store a binary blob without any format
1927 restriction. The binary blobs are created as KMS standalone objects,
1928 and blob property instance values store the ID of their associated
1929 blob object.</para>
1930 <para>Blob properties are only used for the connector EDID property
1931 and cannot be created by drivers.</para></listitem>
1932 </varlistentry>
1933 </variablelist>
1934 </para>
1935 <para>
1936 To create a property drivers call one of the following functions depending
1937 on the property type. All property creation functions take property flags
1938 and name, as well as type-specific arguments.
1939 <itemizedlist>
1940 <listitem>
1941 <synopsis>struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
1942 const char *name,
1943 uint64_t min, uint64_t max);</synopsis>
1944 <para>Create a range property with the given minimum and maximum
1945 values.</para>
1946 </listitem>
1947 <listitem>
1948 <synopsis>struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
1949 const char *name,
1950 const struct drm_prop_enum_list *props,
1951 int num_values);</synopsis>
1952 <para>Create an enumerated property. The <parameter>props</parameter>
1953 argument points to an array of <parameter>num_values</parameter>
1954 value-name pairs.</para>
1955 </listitem>
1956 <listitem>
1957 <synopsis>struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
1958 int flags, const char *name,
1959 const struct drm_prop_enum_list *props,
1960 int num_values);</synopsis>
1961 <para>Create a bitmask property. The <parameter>props</parameter>
1962 argument points to an array of <parameter>num_values</parameter>
1963 value-name pairs.</para>
1964 </listitem>
1965 </itemizedlist>
1966 </para>
1967 <para>
1968 Properties can additionally be created as immutable, in which case they
1969 will be read-only for applications but can be modified by the driver. To
1970 create an immutable property drivers must set the DRM_MODE_PROP_IMMUTABLE
1971 flag at property creation time.
1972 </para>
1973 <para>
1974 When no array of value-name pairs is readily available at property
1975 creation time for enumerated or range properties, drivers can create
1976 the property using the <function>drm_property_create</function> function
1977 and manually add enumeration value-name pairs by calling the
1978 <function>drm_property_add_enum</function> function. Care must be taken to
1979 properly specify the property type through the <parameter>flags</parameter>
1980 argument.
1981 </para>
1982 <para>
1983 After creating properties drivers can attach property instances to CRTC,
1984 connector and plane objects by calling the
1985 <function>drm_object_attach_property</function>. The function takes a
1986 pointer to the target object, a pointer to the previously created property
1987 and an initial instance value.
1988 </para>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05301989 <sect2>
1990 <title>Existing KMS Properties</title>
1991 <para>
1992 The following table gives description of drm properties exposed by various
1993 modules/drivers.
1994 </para>
1995 <table border="1" cellpadding="0" cellspacing="0">
1996 <tbody>
1997 <tr style="font-weight: bold;">
1998 <td valign="top" >Owner Module/Drivers</td>
1999 <td valign="top" >Group</td>
2000 <td valign="top" >Property Name</td>
2001 <td valign="top" >Type</td>
2002 <td valign="top" >Property Values</td>
2003 <td valign="top" >Object attached</td>
2004 <td valign="top" >Description/Restrictions</td>
2005 </tr>
2006 <tr>
Sonika Jindal712a0dd2015-05-28 16:35:07 +05302007 <td rowspan="37" valign="top" >DRM</td>
2008 <td valign="top" >Generic</td>
2009 <td valign="top" >“rotation”</td>
2010 <td valign="top" >BITMASK</td>
2011 <td valign="top" >{ 0, "rotate-0" },
2012 { 1, "rotate-90" },
2013 { 2, "rotate-180" },
2014 { 3, "rotate-270" },
2015 { 4, "reflect-x" },
2016 { 5, "reflect-y" }</td>
2017 <td valign="top" >CRTC, Plane</td>
2018 <td valign="top" >rotate-(degrees) rotates the image by the specified amount in degrees
2019 in counter clockwise direction. reflect-x and reflect-y reflects the
2020 image along the specified axis prior to rotation</td>
2021 </tr>
2022 <tr>
Rob Clarkae16c592014-12-18 16:01:54 -05002023 <td rowspan="5" valign="top" >Connector</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302024 <td valign="top" >“EDID”</td>
2025 <td valign="top" >BLOB | IMMUTABLE</td>
2026 <td valign="top" >0</td>
2027 <td valign="top" >Connector</td>
2028 <td valign="top" >Contains id of edid blob ptr object.</td>
2029 </tr>
2030 <tr>
2031 <td valign="top" >“DPMS”</td>
2032 <td valign="top" >ENUM</td>
2033 <td valign="top" >{ “On”, “Standby”, “Suspend”, “Off” }</td>
2034 <td valign="top" >Connector</td>
2035 <td valign="top" >Contains DPMS operation mode value.</td>
2036 </tr>
2037 <tr>
Dave Airliecc7096f2014-10-22 12:03:04 +10002038 <td valign="top" >“PATH”</td>
2039 <td valign="top" >BLOB | IMMUTABLE</td>
2040 <td valign="top" >0</td>
2041 <td valign="top" >Connector</td>
2042 <td valign="top" >Contains topology path to a connector.</td>
2043 </tr>
2044 <tr>
Dave Airlie6f134d72014-10-20 16:30:50 +10002045 <td valign="top" >“TILE”</td>
2046 <td valign="top" >BLOB | IMMUTABLE</td>
2047 <td valign="top" >0</td>
2048 <td valign="top" >Connector</td>
2049 <td valign="top" >Contains tiling information for a connector.</td>
2050 </tr>
2051 <tr>
Rob Clarkae16c592014-12-18 16:01:54 -05002052 <td valign="top" >“CRTC_ID”</td>
2053 <td valign="top" >OBJECT</td>
2054 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2055 <td valign="top" >Connector</td>
2056 <td valign="top" >CRTC that connector is attached to (atomic)</td>
2057 </tr>
2058 <tr>
Rob Clark6b4959f2014-12-18 16:01:53 -05002059 <td rowspan="11" valign="top" >Plane</td>
Damien Lespiau59748612014-06-09 14:20:22 +01002060 <td valign="top" >“type”</td>
2061 <td valign="top" >ENUM | IMMUTABLE</td>
2062 <td valign="top" >{ "Overlay", "Primary", "Cursor" }</td>
2063 <td valign="top" >Plane</td>
2064 <td valign="top" >Plane type</td>
2065 </tr>
2066 <tr>
Rob Clark6b4959f2014-12-18 16:01:53 -05002067 <td valign="top" >“SRC_X”</td>
2068 <td valign="top" >RANGE</td>
2069 <td valign="top" >Min=0, Max=UINT_MAX</td>
2070 <td valign="top" >Plane</td>
2071 <td valign="top" >Scanout source x coordinate in 16.16 fixed point (atomic)</td>
2072 </tr>
2073 <tr>
2074 <td valign="top" >“SRC_Y”</td>
2075 <td valign="top" >RANGE</td>
2076 <td valign="top" >Min=0, Max=UINT_MAX</td>
2077 <td valign="top" >Plane</td>
2078 <td valign="top" >Scanout source y coordinate in 16.16 fixed point (atomic)</td>
2079 </tr>
2080 <tr>
2081 <td valign="top" >“SRC_W”</td>
2082 <td valign="top" >RANGE</td>
2083 <td valign="top" >Min=0, Max=UINT_MAX</td>
2084 <td valign="top" >Plane</td>
2085 <td valign="top" >Scanout source width in 16.16 fixed point (atomic)</td>
2086 </tr>
2087 <tr>
2088 <td valign="top" >“SRC_H”</td>
2089 <td valign="top" >RANGE</td>
2090 <td valign="top" >Min=0, Max=UINT_MAX</td>
2091 <td valign="top" >Plane</td>
2092 <td valign="top" >Scanout source height in 16.16 fixed point (atomic)</td>
2093 </tr>
2094 <tr>
2095 <td valign="top" >“CRTC_X”</td>
2096 <td valign="top" >SIGNED_RANGE</td>
2097 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2098 <td valign="top" >Plane</td>
2099 <td valign="top" >Scanout CRTC (destination) x coordinate (atomic)</td>
2100 </tr>
2101 <tr>
2102 <td valign="top" >“CRTC_Y”</td>
2103 <td valign="top" >SIGNED_RANGE</td>
2104 <td valign="top" >Min=INT_MIN, Max=INT_MAX</td>
2105 <td valign="top" >Plane</td>
2106 <td valign="top" >Scanout CRTC (destination) y coordinate (atomic)</td>
2107 </tr>
2108 <tr>
2109 <td valign="top" >“CRTC_W”</td>
2110 <td valign="top" >RANGE</td>
2111 <td valign="top" >Min=0, Max=UINT_MAX</td>
2112 <td valign="top" >Plane</td>
2113 <td valign="top" >Scanout CRTC (destination) width (atomic)</td>
2114 </tr>
2115 <tr>
2116 <td valign="top" >“CRTC_H”</td>
2117 <td valign="top" >RANGE</td>
2118 <td valign="top" >Min=0, Max=UINT_MAX</td>
2119 <td valign="top" >Plane</td>
2120 <td valign="top" >Scanout CRTC (destination) height (atomic)</td>
2121 </tr>
2122 <tr>
2123 <td valign="top" >“FB_ID”</td>
2124 <td valign="top" >OBJECT</td>
2125 <td valign="top" >DRM_MODE_OBJECT_FB</td>
2126 <td valign="top" >Plane</td>
2127 <td valign="top" >Scanout framebuffer (atomic)</td>
2128 </tr>
2129 <tr>
2130 <td valign="top" >“CRTC_ID”</td>
2131 <td valign="top" >OBJECT</td>
2132 <td valign="top" >DRM_MODE_OBJECT_CRTC</td>
2133 <td valign="top" >Plane</td>
2134 <td valign="top" >CRTC that plane is attached to (atomic)</td>
2135 </tr>
2136 <tr>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302137 <td rowspan="2" valign="top" >DVI-I</td>
2138 <td valign="top" >“subconnector”</td>
2139 <td valign="top" >ENUM</td>
2140 <td valign="top" >{ “Unknown”, “DVI-D”, “DVI-A” }</td>
2141 <td valign="top" >Connector</td>
2142 <td valign="top" >TBD</td>
2143 </tr>
2144 <tr>
2145 <td valign="top" >“select subconnector”</td>
2146 <td valign="top" >ENUM</td>
2147 <td valign="top" >{ “Automatic”, “DVI-D”, “DVI-A” }</td>
2148 <td valign="top" >Connector</td>
2149 <td valign="top" >TBD</td>
2150 </tr>
2151 <tr>
2152 <td rowspan="13" valign="top" >TV</td>
2153 <td valign="top" >“subconnector”</td>
2154 <td valign="top" >ENUM</td>
2155 <td valign="top" >{ "Unknown", "Composite", "SVIDEO", "Component", "SCART" }</td>
2156 <td valign="top" >Connector</td>
2157 <td valign="top" >TBD</td>
2158 </tr>
2159 <tr>
2160 <td valign="top" >“select subconnector”</td>
2161 <td valign="top" >ENUM</td>
2162 <td valign="top" >{ "Automatic", "Composite", "SVIDEO", "Component", "SCART" }</td>
2163 <td valign="top" >Connector</td>
2164 <td valign="top" >TBD</td>
2165 </tr>
2166 <tr>
2167 <td valign="top" >“mode”</td>
2168 <td valign="top" >ENUM</td>
2169 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2170 <td valign="top" >Connector</td>
2171 <td valign="top" >TBD</td>
2172 </tr>
2173 <tr>
2174 <td valign="top" >“left margin”</td>
2175 <td valign="top" >RANGE</td>
2176 <td valign="top" >Min=0, Max=100</td>
2177 <td valign="top" >Connector</td>
2178 <td valign="top" >TBD</td>
2179 </tr>
2180 <tr>
2181 <td valign="top" >“right margin”</td>
2182 <td valign="top" >RANGE</td>
2183 <td valign="top" >Min=0, Max=100</td>
2184 <td valign="top" >Connector</td>
2185 <td valign="top" >TBD</td>
2186 </tr>
2187 <tr>
2188 <td valign="top" >“top margin”</td>
2189 <td valign="top" >RANGE</td>
2190 <td valign="top" >Min=0, Max=100</td>
2191 <td valign="top" >Connector</td>
2192 <td valign="top" >TBD</td>
2193 </tr>
2194 <tr>
2195 <td valign="top" >“bottom margin”</td>
2196 <td valign="top" >RANGE</td>
2197 <td valign="top" >Min=0, Max=100</td>
2198 <td valign="top" >Connector</td>
2199 <td valign="top" >TBD</td>
2200 </tr>
2201 <tr>
2202 <td valign="top" >“brightness”</td>
2203 <td valign="top" >RANGE</td>
2204 <td valign="top" >Min=0, Max=100</td>
2205 <td valign="top" >Connector</td>
2206 <td valign="top" >TBD</td>
2207 </tr>
2208 <tr>
2209 <td valign="top" >“contrast”</td>
2210 <td valign="top" >RANGE</td>
2211 <td valign="top" >Min=0, Max=100</td>
2212 <td valign="top" >Connector</td>
2213 <td valign="top" >TBD</td>
2214 </tr>
2215 <tr>
2216 <td valign="top" >“flicker reduction”</td>
2217 <td valign="top" >RANGE</td>
2218 <td valign="top" >Min=0, Max=100</td>
2219 <td valign="top" >Connector</td>
2220 <td valign="top" >TBD</td>
2221 </tr>
2222 <tr>
2223 <td valign="top" >“overscan”</td>
2224 <td valign="top" >RANGE</td>
2225 <td valign="top" >Min=0, Max=100</td>
2226 <td valign="top" >Connector</td>
2227 <td valign="top" >TBD</td>
2228 </tr>
2229 <tr>
2230 <td valign="top" >“saturation”</td>
2231 <td valign="top" >RANGE</td>
2232 <td valign="top" >Min=0, Max=100</td>
2233 <td valign="top" >Connector</td>
2234 <td valign="top" >TBD</td>
2235 </tr>
2236 <tr>
2237 <td valign="top" >“hue”</td>
2238 <td valign="top" >RANGE</td>
2239 <td valign="top" >Min=0, Max=100</td>
2240 <td valign="top" >Connector</td>
2241 <td valign="top" >TBD</td>
2242 </tr>
2243 <tr>
Dave Airlie5bb2bbf2014-11-10 10:18:15 +10002244 <td rowspan="2" valign="top" >Virtual GPU</td>
2245 <td valign="top" >“suggested X”</td>
2246 <td valign="top" >RANGE</td>
2247 <td valign="top" >Min=0, Max=0xffffffff</td>
2248 <td valign="top" >Connector</td>
2249 <td valign="top" >property to suggest an X offset for a connector</td>
2250 </tr>
2251 <tr>
2252 <td valign="top" >“suggested Y”</td>
2253 <td valign="top" >RANGE</td>
2254 <td valign="top" >Min=0, Max=0xffffffff</td>
2255 <td valign="top" >Connector</td>
2256 <td valign="top" >property to suggest an Y offset for a connector</td>
2257 </tr>
2258 <tr>
Vandana Kannan726a2802014-06-11 14:33:05 +05302259 <td rowspan="3" valign="top" >Optional</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302260 <td valign="top" >“scaling mode”</td>
2261 <td valign="top" >ENUM</td>
2262 <td valign="top" >{ "None", "Full", "Center", "Full aspect" }</td>
2263 <td valign="top" >Connector</td>
2264 <td valign="top" >TBD</td>
2265 </tr>
2266 <tr>
Vandana Kannan726a2802014-06-11 14:33:05 +05302267 <td valign="top" >"aspect ratio"</td>
2268 <td valign="top" >ENUM</td>
2269 <td valign="top" >{ "None", "4:3", "16:9" }</td>
2270 <td valign="top" >Connector</td>
2271 <td valign="top" >DRM property to set aspect ratio from user space app.
2272 This enum is made generic to allow addition of custom aspect
2273 ratios.</td>
2274 </tr>
2275 <tr>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302276 <td valign="top" >“dirty”</td>
2277 <td valign="top" >ENUM | IMMUTABLE</td>
2278 <td valign="top" >{ "Off", "On", "Annotate" }</td>
2279 <td valign="top" >Connector</td>
2280 <td valign="top" >TBD</td>
2281 </tr>
2282 <tr>
Sonika Jindal712a0dd2015-05-28 16:35:07 +05302283 <td rowspan="20" valign="top" >i915</td>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302284 <td rowspan="2" valign="top" >Generic</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302285 <td valign="top" >"Broadcast RGB"</td>
2286 <td valign="top" >ENUM</td>
2287 <td valign="top" >{ "Automatic", "Full", "Limited 16:235" }</td>
2288 <td valign="top" >Connector</td>
2289 <td valign="top" >TBD</td>
2290 </tr>
2291 <tr>
2292 <td valign="top" >“audio”</td>
2293 <td valign="top" >ENUM</td>
2294 <td valign="top" >{ "force-dvi", "off", "auto", "on" }</td>
2295 <td valign="top" >Connector</td>
2296 <td valign="top" >TBD</td>
2297 </tr>
2298 <tr>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302299 <td rowspan="17" valign="top" >SDVO-TV</td>
2300 <td valign="top" >“mode”</td>
2301 <td valign="top" >ENUM</td>
2302 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2303 <td valign="top" >Connector</td>
2304 <td valign="top" >TBD</td>
2305 </tr>
2306 <tr>
2307 <td valign="top" >"left_margin"</td>
2308 <td valign="top" >RANGE</td>
2309 <td valign="top" >Min=0, Max= SDVO dependent</td>
2310 <td valign="top" >Connector</td>
2311 <td valign="top" >TBD</td>
2312 </tr>
2313 <tr>
2314 <td valign="top" >"right_margin"</td>
2315 <td valign="top" >RANGE</td>
2316 <td valign="top" >Min=0, Max= SDVO dependent</td>
2317 <td valign="top" >Connector</td>
2318 <td valign="top" >TBD</td>
2319 </tr>
2320 <tr>
2321 <td valign="top" >"top_margin"</td>
2322 <td valign="top" >RANGE</td>
2323 <td valign="top" >Min=0, Max= SDVO dependent</td>
2324 <td valign="top" >Connector</td>
2325 <td valign="top" >TBD</td>
2326 </tr>
2327 <tr>
2328 <td valign="top" >"bottom_margin"</td>
2329 <td valign="top" >RANGE</td>
2330 <td valign="top" >Min=0, Max= SDVO dependent</td>
2331 <td valign="top" >Connector</td>
2332 <td valign="top" >TBD</td>
2333 </tr>
2334 <tr>
2335 <td valign="top" >“hpos”</td>
2336 <td valign="top" >RANGE</td>
2337 <td valign="top" >Min=0, Max= SDVO dependent</td>
2338 <td valign="top" >Connector</td>
2339 <td valign="top" >TBD</td>
2340 </tr>
2341 <tr>
2342 <td valign="top" >“vpos”</td>
2343 <td valign="top" >RANGE</td>
2344 <td valign="top" >Min=0, Max= SDVO dependent</td>
2345 <td valign="top" >Connector</td>
2346 <td valign="top" >TBD</td>
2347 </tr>
2348 <tr>
2349 <td valign="top" >“contrast”</td>
2350 <td valign="top" >RANGE</td>
2351 <td valign="top" >Min=0, Max= SDVO dependent</td>
2352 <td valign="top" >Connector</td>
2353 <td valign="top" >TBD</td>
2354 </tr>
2355 <tr>
2356 <td valign="top" >“saturation”</td>
2357 <td valign="top" >RANGE</td>
2358 <td valign="top" >Min=0, Max= SDVO dependent</td>
2359 <td valign="top" >Connector</td>
2360 <td valign="top" >TBD</td>
2361 </tr>
2362 <tr>
2363 <td valign="top" >“hue”</td>
2364 <td valign="top" >RANGE</td>
2365 <td valign="top" >Min=0, Max= SDVO dependent</td>
2366 <td valign="top" >Connector</td>
2367 <td valign="top" >TBD</td>
2368 </tr>
2369 <tr>
2370 <td valign="top" >“sharpness”</td>
2371 <td valign="top" >RANGE</td>
2372 <td valign="top" >Min=0, Max= SDVO dependent</td>
2373 <td valign="top" >Connector</td>
2374 <td valign="top" >TBD</td>
2375 </tr>
2376 <tr>
2377 <td valign="top" >“flicker_filter”</td>
2378 <td valign="top" >RANGE</td>
2379 <td valign="top" >Min=0, Max= SDVO dependent</td>
2380 <td valign="top" >Connector</td>
2381 <td valign="top" >TBD</td>
2382 </tr>
2383 <tr>
2384 <td valign="top" >“flicker_filter_adaptive”</td>
2385 <td valign="top" >RANGE</td>
2386 <td valign="top" >Min=0, Max= SDVO dependent</td>
2387 <td valign="top" >Connector</td>
2388 <td valign="top" >TBD</td>
2389 </tr>
2390 <tr>
2391 <td valign="top" >“flicker_filter_2d”</td>
2392 <td valign="top" >RANGE</td>
2393 <td valign="top" >Min=0, Max= SDVO dependent</td>
2394 <td valign="top" >Connector</td>
2395 <td valign="top" >TBD</td>
2396 </tr>
2397 <tr>
2398 <td valign="top" >“tv_chroma_filter”</td>
2399 <td valign="top" >RANGE</td>
2400 <td valign="top" >Min=0, Max= SDVO dependent</td>
2401 <td valign="top" >Connector</td>
2402 <td valign="top" >TBD</td>
2403 </tr>
2404 <tr>
2405 <td valign="top" >“tv_luma_filter”</td>
2406 <td valign="top" >RANGE</td>
2407 <td valign="top" >Min=0, Max= SDVO dependent</td>
2408 <td valign="top" >Connector</td>
2409 <td valign="top" >TBD</td>
2410 </tr>
2411 <tr>
2412 <td valign="top" >“dot_crawl”</td>
2413 <td valign="top" >RANGE</td>
2414 <td valign="top" >Min=0, Max=1</td>
2415 <td valign="top" >Connector</td>
2416 <td valign="top" >TBD</td>
2417 </tr>
2418 <tr>
2419 <td valign="top" >SDVO-TV/LVDS</td>
2420 <td valign="top" >“brightness”</td>
2421 <td valign="top" >RANGE</td>
2422 <td valign="top" >Min=0, Max= SDVO dependent</td>
2423 <td valign="top" >Connector</td>
2424 <td valign="top" >TBD</td>
2425 </tr>
2426 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302427 <td rowspan="2" valign="top" >CDV gma-500</td>
2428 <td rowspan="2" valign="top" >Generic</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302429 <td valign="top" >"Broadcast RGB"</td>
2430 <td valign="top" >ENUM</td>
2431 <td valign="top" >{ “Full”, “Limited 16:235” }</td>
2432 <td valign="top" >Connector</td>
2433 <td valign="top" >TBD</td>
2434 </tr>
2435 <tr>
2436 <td valign="top" >"Broadcast RGB"</td>
2437 <td valign="top" >ENUM</td>
2438 <td valign="top" >{ “off”, “auto”, “on” }</td>
2439 <td valign="top" >Connector</td>
2440 <td valign="top" >TBD</td>
2441 </tr>
2442 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302443 <td rowspan="19" valign="top" >Poulsbo</td>
2444 <td rowspan="1" valign="top" >Generic</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302445 <td valign="top" >“backlight”</td>
2446 <td valign="top" >RANGE</td>
2447 <td valign="top" >Min=0, Max=100</td>
2448 <td valign="top" >Connector</td>
2449 <td valign="top" >TBD</td>
2450 </tr>
2451 <tr>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302452 <td rowspan="17" valign="top" >SDVO-TV</td>
2453 <td valign="top" >“mode”</td>
2454 <td valign="top" >ENUM</td>
2455 <td valign="top" >{ "NTSC_M", "NTSC_J", "NTSC_443", "PAL_B" } etc.</td>
2456 <td valign="top" >Connector</td>
2457 <td valign="top" >TBD</td>
2458 </tr>
2459 <tr>
2460 <td valign="top" >"left_margin"</td>
2461 <td valign="top" >RANGE</td>
2462 <td valign="top" >Min=0, Max= SDVO dependent</td>
2463 <td valign="top" >Connector</td>
2464 <td valign="top" >TBD</td>
2465 </tr>
2466 <tr>
2467 <td valign="top" >"right_margin"</td>
2468 <td valign="top" >RANGE</td>
2469 <td valign="top" >Min=0, Max= SDVO dependent</td>
2470 <td valign="top" >Connector</td>
2471 <td valign="top" >TBD</td>
2472 </tr>
2473 <tr>
2474 <td valign="top" >"top_margin"</td>
2475 <td valign="top" >RANGE</td>
2476 <td valign="top" >Min=0, Max= SDVO dependent</td>
2477 <td valign="top" >Connector</td>
2478 <td valign="top" >TBD</td>
2479 </tr>
2480 <tr>
2481 <td valign="top" >"bottom_margin"</td>
2482 <td valign="top" >RANGE</td>
2483 <td valign="top" >Min=0, Max= SDVO dependent</td>
2484 <td valign="top" >Connector</td>
2485 <td valign="top" >TBD</td>
2486 </tr>
2487 <tr>
2488 <td valign="top" >“hpos”</td>
2489 <td valign="top" >RANGE</td>
2490 <td valign="top" >Min=0, Max= SDVO dependent</td>
2491 <td valign="top" >Connector</td>
2492 <td valign="top" >TBD</td>
2493 </tr>
2494 <tr>
2495 <td valign="top" >“vpos”</td>
2496 <td valign="top" >RANGE</td>
2497 <td valign="top" >Min=0, Max= SDVO dependent</td>
2498 <td valign="top" >Connector</td>
2499 <td valign="top" >TBD</td>
2500 </tr>
2501 <tr>
2502 <td valign="top" >“contrast”</td>
2503 <td valign="top" >RANGE</td>
2504 <td valign="top" >Min=0, Max= SDVO dependent</td>
2505 <td valign="top" >Connector</td>
2506 <td valign="top" >TBD</td>
2507 </tr>
2508 <tr>
2509 <td valign="top" >“saturation”</td>
2510 <td valign="top" >RANGE</td>
2511 <td valign="top" >Min=0, Max= SDVO dependent</td>
2512 <td valign="top" >Connector</td>
2513 <td valign="top" >TBD</td>
2514 </tr>
2515 <tr>
2516 <td valign="top" >“hue”</td>
2517 <td valign="top" >RANGE</td>
2518 <td valign="top" >Min=0, Max= SDVO dependent</td>
2519 <td valign="top" >Connector</td>
2520 <td valign="top" >TBD</td>
2521 </tr>
2522 <tr>
2523 <td valign="top" >“sharpness”</td>
2524 <td valign="top" >RANGE</td>
2525 <td valign="top" >Min=0, Max= SDVO dependent</td>
2526 <td valign="top" >Connector</td>
2527 <td valign="top" >TBD</td>
2528 </tr>
2529 <tr>
2530 <td valign="top" >“flicker_filter”</td>
2531 <td valign="top" >RANGE</td>
2532 <td valign="top" >Min=0, Max= SDVO dependent</td>
2533 <td valign="top" >Connector</td>
2534 <td valign="top" >TBD</td>
2535 </tr>
2536 <tr>
2537 <td valign="top" >“flicker_filter_adaptive”</td>
2538 <td valign="top" >RANGE</td>
2539 <td valign="top" >Min=0, Max= SDVO dependent</td>
2540 <td valign="top" >Connector</td>
2541 <td valign="top" >TBD</td>
2542 </tr>
2543 <tr>
2544 <td valign="top" >“flicker_filter_2d”</td>
2545 <td valign="top" >RANGE</td>
2546 <td valign="top" >Min=0, Max= SDVO dependent</td>
2547 <td valign="top" >Connector</td>
2548 <td valign="top" >TBD</td>
2549 </tr>
2550 <tr>
2551 <td valign="top" >“tv_chroma_filter”</td>
2552 <td valign="top" >RANGE</td>
2553 <td valign="top" >Min=0, Max= SDVO dependent</td>
2554 <td valign="top" >Connector</td>
2555 <td valign="top" >TBD</td>
2556 </tr>
2557 <tr>
2558 <td valign="top" >“tv_luma_filter”</td>
2559 <td valign="top" >RANGE</td>
2560 <td valign="top" >Min=0, Max= SDVO dependent</td>
2561 <td valign="top" >Connector</td>
2562 <td valign="top" >TBD</td>
2563 </tr>
2564 <tr>
2565 <td valign="top" >“dot_crawl”</td>
2566 <td valign="top" >RANGE</td>
2567 <td valign="top" >Min=0, Max=1</td>
2568 <td valign="top" >Connector</td>
2569 <td valign="top" >TBD</td>
2570 </tr>
2571 <tr>
2572 <td valign="top" >SDVO-TV/LVDS</td>
2573 <td valign="top" >“brightness”</td>
2574 <td valign="top" >RANGE</td>
2575 <td valign="top" >Min=0, Max= SDVO dependent</td>
2576 <td valign="top" >Connector</td>
2577 <td valign="top" >TBD</td>
2578 </tr>
2579 <tr>
2580 <td rowspan="11" valign="top" >armada</td>
2581 <td rowspan="2" valign="top" >CRTC</td>
2582 <td valign="top" >"CSC_YUV"</td>
2583 <td valign="top" >ENUM</td>
2584 <td valign="top" >{ "Auto" , "CCIR601", "CCIR709" }</td>
2585 <td valign="top" >CRTC</td>
2586 <td valign="top" >TBD</td>
2587 </tr>
2588 <tr>
2589 <td valign="top" >"CSC_RGB"</td>
2590 <td valign="top" >ENUM</td>
2591 <td valign="top" >{ "Auto", "Computer system", "Studio" }</td>
2592 <td valign="top" >CRTC</td>
2593 <td valign="top" >TBD</td>
2594 </tr>
2595 <tr>
2596 <td rowspan="9" valign="top" >Overlay</td>
2597 <td valign="top" >"colorkey"</td>
2598 <td valign="top" >RANGE</td>
2599 <td valign="top" >Min=0, Max=0xffffff</td>
2600 <td valign="top" >Plane</td>
2601 <td valign="top" >TBD</td>
2602 </tr>
2603 <tr>
2604 <td valign="top" >"colorkey_min"</td>
2605 <td valign="top" >RANGE</td>
2606 <td valign="top" >Min=0, Max=0xffffff</td>
2607 <td valign="top" >Plane</td>
2608 <td valign="top" >TBD</td>
2609 </tr>
2610 <tr>
2611 <td valign="top" >"colorkey_max"</td>
2612 <td valign="top" >RANGE</td>
2613 <td valign="top" >Min=0, Max=0xffffff</td>
2614 <td valign="top" >Plane</td>
2615 <td valign="top" >TBD</td>
2616 </tr>
2617 <tr>
2618 <td valign="top" >"colorkey_val"</td>
2619 <td valign="top" >RANGE</td>
2620 <td valign="top" >Min=0, Max=0xffffff</td>
2621 <td valign="top" >Plane</td>
2622 <td valign="top" >TBD</td>
2623 </tr>
2624 <tr>
2625 <td valign="top" >"colorkey_alpha"</td>
2626 <td valign="top" >RANGE</td>
2627 <td valign="top" >Min=0, Max=0xffffff</td>
2628 <td valign="top" >Plane</td>
2629 <td valign="top" >TBD</td>
2630 </tr>
2631 <tr>
2632 <td valign="top" >"colorkey_mode"</td>
2633 <td valign="top" >ENUM</td>
2634 <td valign="top" >{ "disabled", "Y component", "U component"
2635 , "V component", "RGB", “R component", "G component", "B component" }</td>
2636 <td valign="top" >Plane</td>
2637 <td valign="top" >TBD</td>
2638 </tr>
2639 <tr>
2640 <td valign="top" >"brightness"</td>
2641 <td valign="top" >RANGE</td>
2642 <td valign="top" >Min=0, Max=256 + 255</td>
2643 <td valign="top" >Plane</td>
2644 <td valign="top" >TBD</td>
2645 </tr>
2646 <tr>
2647 <td valign="top" >"contrast"</td>
2648 <td valign="top" >RANGE</td>
2649 <td valign="top" >Min=0, Max=0x7fff</td>
2650 <td valign="top" >Plane</td>
2651 <td valign="top" >TBD</td>
2652 </tr>
2653 <tr>
2654 <td valign="top" >"saturation"</td>
2655 <td valign="top" >RANGE</td>
2656 <td valign="top" >Min=0, Max=0x7fff</td>
2657 <td valign="top" >Plane</td>
2658 <td valign="top" >TBD</td>
2659 </tr>
2660 <tr>
2661 <td rowspan="2" valign="top" >exynos</td>
2662 <td valign="top" >CRTC</td>
2663 <td valign="top" >“mode”</td>
2664 <td valign="top" >ENUM</td>
2665 <td valign="top" >{ "normal", "blank" }</td>
2666 <td valign="top" >CRTC</td>
2667 <td valign="top" >TBD</td>
2668 </tr>
2669 <tr>
2670 <td valign="top" >Overlay</td>
2671 <td valign="top" >“zpos”</td>
2672 <td valign="top" >RANGE</td>
2673 <td valign="top" >Min=0, Max=MAX_PLANE-1</td>
2674 <td valign="top" >Plane</td>
2675 <td valign="top" >TBD</td>
2676 </tr>
2677 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302678 <td rowspan="2" valign="top" >i2c/ch7006_drv</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302679 <td valign="top" >Generic</td>
2680 <td valign="top" >“scale”</td>
2681 <td valign="top" >RANGE</td>
2682 <td valign="top" >Min=0, Max=2</td>
2683 <td valign="top" >Connector</td>
2684 <td valign="top" >TBD</td>
2685 </tr>
2686 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302687 <td rowspan="1" valign="top" >TV</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302688 <td valign="top" >“mode”</td>
2689 <td valign="top" >ENUM</td>
2690 <td valign="top" >{ "PAL", "PAL-M","PAL-N"}, ”PAL-Nc"
2691 , "PAL-60", "NTSC-M", "NTSC-J" }</td>
2692 <td valign="top" >Connector</td>
2693 <td valign="top" >TBD</td>
2694 </tr>
2695 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302696 <td rowspan="15" valign="top" >nouveau</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302697 <td rowspan="6" valign="top" >NV10 Overlay</td>
2698 <td valign="top" >"colorkey"</td>
2699 <td valign="top" >RANGE</td>
2700 <td valign="top" >Min=0, Max=0x01ffffff</td>
2701 <td valign="top" >Plane</td>
2702 <td valign="top" >TBD</td>
2703 </tr>
2704 <tr>
2705 <td valign="top" >“contrast”</td>
2706 <td valign="top" >RANGE</td>
2707 <td valign="top" >Min=0, Max=8192-1</td>
2708 <td valign="top" >Plane</td>
2709 <td valign="top" >TBD</td>
2710 </tr>
2711 <tr>
2712 <td valign="top" >“brightness”</td>
2713 <td valign="top" >RANGE</td>
2714 <td valign="top" >Min=0, Max=1024</td>
2715 <td valign="top" >Plane</td>
2716 <td valign="top" >TBD</td>
2717 </tr>
2718 <tr>
2719 <td valign="top" >“hue”</td>
2720 <td valign="top" >RANGE</td>
2721 <td valign="top" >Min=0, Max=359</td>
2722 <td valign="top" >Plane</td>
2723 <td valign="top" >TBD</td>
2724 </tr>
2725 <tr>
2726 <td valign="top" >“saturation”</td>
2727 <td valign="top" >RANGE</td>
2728 <td valign="top" >Min=0, Max=8192-1</td>
2729 <td valign="top" >Plane</td>
2730 <td valign="top" >TBD</td>
2731 </tr>
2732 <tr>
2733 <td valign="top" >“iturbt_709”</td>
2734 <td valign="top" >RANGE</td>
2735 <td valign="top" >Min=0, Max=1</td>
2736 <td valign="top" >Plane</td>
2737 <td valign="top" >TBD</td>
2738 </tr>
2739 <tr>
2740 <td rowspan="2" valign="top" >Nv04 Overlay</td>
2741 <td valign="top" >“colorkey”</td>
2742 <td valign="top" >RANGE</td>
2743 <td valign="top" >Min=0, Max=0x01ffffff</td>
2744 <td valign="top" >Plane</td>
2745 <td valign="top" >TBD</td>
2746 </tr>
2747 <tr>
2748 <td valign="top" >“brightness”</td>
2749 <td valign="top" >RANGE</td>
2750 <td valign="top" >Min=0, Max=1024</td>
2751 <td valign="top" >Plane</td>
2752 <td valign="top" >TBD</td>
2753 </tr>
2754 <tr>
2755 <td rowspan="7" valign="top" >Display</td>
2756 <td valign="top" >“dithering mode”</td>
2757 <td valign="top" >ENUM</td>
2758 <td valign="top" >{ "auto", "off", "on" }</td>
2759 <td valign="top" >Connector</td>
2760 <td valign="top" >TBD</td>
2761 </tr>
2762 <tr>
2763 <td valign="top" >“dithering depth”</td>
2764 <td valign="top" >ENUM</td>
2765 <td valign="top" >{ "auto", "off", "on", "static 2x2", "dynamic 2x2", "temporal" }</td>
2766 <td valign="top" >Connector</td>
2767 <td valign="top" >TBD</td>
2768 </tr>
2769 <tr>
2770 <td valign="top" >“underscan”</td>
2771 <td valign="top" >ENUM</td>
2772 <td valign="top" >{ "auto", "6 bpc", "8 bpc" }</td>
2773 <td valign="top" >Connector</td>
2774 <td valign="top" >TBD</td>
2775 </tr>
2776 <tr>
2777 <td valign="top" >“underscan hborder”</td>
2778 <td valign="top" >RANGE</td>
2779 <td valign="top" >Min=0, Max=128</td>
2780 <td valign="top" >Connector</td>
2781 <td valign="top" >TBD</td>
2782 </tr>
2783 <tr>
2784 <td valign="top" >“underscan vborder”</td>
2785 <td valign="top" >RANGE</td>
2786 <td valign="top" >Min=0, Max=128</td>
2787 <td valign="top" >Connector</td>
2788 <td valign="top" >TBD</td>
2789 </tr>
2790 <tr>
2791 <td valign="top" >“vibrant hue”</td>
2792 <td valign="top" >RANGE</td>
2793 <td valign="top" >Min=0, Max=180</td>
2794 <td valign="top" >Connector</td>
2795 <td valign="top" >TBD</td>
2796 </tr>
2797 <tr>
2798 <td valign="top" >“color vibrance”</td>
2799 <td valign="top" >RANGE</td>
2800 <td valign="top" >Min=0, Max=200</td>
2801 <td valign="top" >Connector</td>
2802 <td valign="top" >TBD</td>
2803 </tr>
2804 <tr>
Graham Whaleyd4acc162015-07-07 19:13:37 +01002805 <td valign="top" >omap</td>
Sonika Jindal712a0dd2015-05-28 16:35:07 +05302806 <td valign="top" >Generic</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302807 <td valign="top" >“zorder”</td>
2808 <td valign="top" >RANGE</td>
2809 <td valign="top" >Min=0, Max=3</td>
2810 <td valign="top" >CRTC, Plane</td>
2811 <td valign="top" >TBD</td>
2812 </tr>
2813 <tr>
2814 <td valign="top" >qxl</td>
2815 <td valign="top" >Generic</td>
2816 <td valign="top" >“hotplug_mode_update"</td>
2817 <td valign="top" >RANGE</td>
2818 <td valign="top" >Min=0, Max=1</td>
2819 <td valign="top" >Connector</td>
2820 <td valign="top" >TBD</td>
2821 </tr>
2822 <tr>
Sagar Kamble4ba08fa2014-07-08 10:32:02 +05302823 <td rowspan="9" valign="top" >radeon</td>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302824 <td valign="top" >DVI-I</td>
2825 <td valign="top" >“coherent”</td>
2826 <td valign="top" >RANGE</td>
2827 <td valign="top" >Min=0, Max=1</td>
2828 <td valign="top" >Connector</td>
2829 <td valign="top" >TBD</td>
2830 </tr>
2831 <tr>
2832 <td valign="top" >DAC enable load detect</td>
2833 <td valign="top" >“load detection”</td>
2834 <td valign="top" >RANGE</td>
2835 <td valign="top" >Min=0, Max=1</td>
2836 <td valign="top" >Connector</td>
2837 <td valign="top" >TBD</td>
2838 </tr>
2839 <tr>
2840 <td valign="top" >TV Standard</td>
2841 <td valign="top" >"tv standard"</td>
2842 <td valign="top" >ENUM</td>
2843 <td valign="top" >{ "ntsc", "pal", "pal-m", "pal-60", "ntsc-j"
2844 , "scart-pal", "pal-cn", "secam" }</td>
2845 <td valign="top" >Connector</td>
2846 <td valign="top" >TBD</td>
2847 </tr>
2848 <tr>
2849 <td valign="top" >legacy TMDS PLL detect</td>
2850 <td valign="top" >"tmds_pll"</td>
2851 <td valign="top" >ENUM</td>
2852 <td valign="top" >{ "driver", "bios" }</td>
2853 <td valign="top" >-</td>
2854 <td valign="top" >TBD</td>
2855 </tr>
2856 <tr>
2857 <td rowspan="3" valign="top" >Underscan</td>
2858 <td valign="top" >"underscan"</td>
2859 <td valign="top" >ENUM</td>
2860 <td valign="top" >{ "off", "on", "auto" }</td>
2861 <td valign="top" >Connector</td>
2862 <td valign="top" >TBD</td>
2863 </tr>
2864 <tr>
2865 <td valign="top" >"underscan hborder"</td>
2866 <td valign="top" >RANGE</td>
2867 <td valign="top" >Min=0, Max=128</td>
2868 <td valign="top" >Connector</td>
2869 <td valign="top" >TBD</td>
2870 </tr>
2871 <tr>
2872 <td valign="top" >"underscan vborder"</td>
2873 <td valign="top" >RANGE</td>
2874 <td valign="top" >Min=0, Max=128</td>
2875 <td valign="top" >Connector</td>
2876 <td valign="top" >TBD</td>
2877 </tr>
2878 <tr>
2879 <td valign="top" >Audio</td>
2880 <td valign="top" >“audio”</td>
2881 <td valign="top" >ENUM</td>
2882 <td valign="top" >{ "off", "on", "auto" }</td>
2883 <td valign="top" >Connector</td>
2884 <td valign="top" >TBD</td>
2885 </tr>
2886 <tr>
2887 <td valign="top" >FMT Dithering</td>
2888 <td valign="top" >“dither”</td>
2889 <td valign="top" >ENUM</td>
2890 <td valign="top" >{ "off", "on" }</td>
2891 <td valign="top" >Connector</td>
2892 <td valign="top" >TBD</td>
2893 </tr>
2894 <tr>
Sagar Kamble6c6a3992014-03-11 19:55:29 +05302895 <td rowspan="3" valign="top" >rcar-du</td>
2896 <td rowspan="3" valign="top" >Generic</td>
2897 <td valign="top" >"alpha"</td>
2898 <td valign="top" >RANGE</td>
2899 <td valign="top" >Min=0, Max=255</td>
2900 <td valign="top" >Plane</td>
2901 <td valign="top" >TBD</td>
2902 </tr>
2903 <tr>
2904 <td valign="top" >"colorkey"</td>
2905 <td valign="top" >RANGE</td>
2906 <td valign="top" >Min=0, Max=0x01ffffff</td>
2907 <td valign="top" >Plane</td>
2908 <td valign="top" >TBD</td>
2909 </tr>
2910 <tr>
2911 <td valign="top" >"zpos"</td>
2912 <td valign="top" >RANGE</td>
2913 <td valign="top" >Min=1, Max=7</td>
2914 <td valign="top" >Plane</td>
2915 <td valign="top" >TBD</td>
2916 </tr>
2917 </tbody>
2918 </table>
2919 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02002920 </sect1>
2921
2922 <!-- Internals: vertical blanking -->
2923
2924 <sect1 id="drm-vertical-blank">
2925 <title>Vertical Blanking</title>
2926 <para>
2927 Vertical blanking plays a major role in graphics rendering. To achieve
2928 tear-free display, users must synchronize page flips and/or rendering to
2929 vertical blanking. The DRM API offers ioctls to perform page flips
2930 synchronized to vertical blanking and wait for vertical blanking.
2931 </para>
2932 <para>
2933 The DRM core handles most of the vertical blanking management logic, which
2934 involves filtering out spurious interrupts, keeping race-free blanking
2935 counters, coping with counter wrap-around and resets and keeping use
2936 counts. It relies on the driver to generate vertical blanking interrupts
2937 and optionally provide a hardware vertical blanking counter. Drivers must
2938 implement the following operations.
2939 </para>
2940 <itemizedlist>
2941 <listitem>
2942 <synopsis>int (*enable_vblank) (struct drm_device *dev, int crtc);
2943void (*disable_vblank) (struct drm_device *dev, int crtc);</synopsis>
2944 <para>
2945 Enable or disable vertical blanking interrupts for the given CRTC.
2946 </para>
2947 </listitem>
2948 <listitem>
2949 <synopsis>u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);</synopsis>
2950 <para>
2951 Retrieve the value of the vertical blanking counter for the given
2952 CRTC. If the hardware maintains a vertical blanking counter its value
2953 should be returned. Otherwise drivers can use the
2954 <function>drm_vblank_count</function> helper function to handle this
2955 operation.
2956 </para>
2957 </listitem>
2958 </itemizedlist>
2959 <para>
2960 Drivers must initialize the vertical blanking handling core with a call to
2961 <function>drm_vblank_init</function> in their
2962 <methodname>load</methodname> operation. The function will set the struct
2963 <structname>drm_device</structname>
2964 <structfield>vblank_disable_allowed</structfield> field to 0. This will
2965 keep vertical blanking interrupts enabled permanently until the first mode
2966 set operation, where <structfield>vblank_disable_allowed</structfield> is
2967 set to 1. The reason behind this is not clear. Drivers can set the field
2968 to 1 after <function>calling drm_vblank_init</function> to make vertical
2969 blanking interrupts dynamically managed from the beginning.
2970 </para>
2971 <para>
2972 Vertical blanking interrupts can be enabled by the DRM core or by drivers
2973 themselves (for instance to handle page flipping operations). The DRM core
2974 maintains a vertical blanking use count to ensure that the interrupts are
2975 not disabled while a user still needs them. To increment the use count,
2976 drivers call <function>drm_vblank_get</function>. Upon return vertical
2977 blanking interrupts are guaranteed to be enabled.
2978 </para>
2979 <para>
2980 To decrement the use count drivers call
2981 <function>drm_vblank_put</function>. Only when the use count drops to zero
2982 will the DRM core disable the vertical blanking interrupts after a delay
2983 by scheduling a timer. The delay is accessible through the vblankoffdelay
2984 module parameter or the <varname>drm_vblank_offdelay</varname> global
2985 variable and expressed in milliseconds. Its default value is 5000 ms.
Ville Syrjälä4ed0ce32014-08-06 14:49:53 +03002986 Zero means never disable, and a negative value means disable immediately.
Ville Syrjälä00185e62014-08-06 14:49:54 +03002987 Drivers may override the behaviour by setting the
2988 <structname>drm_device</structname>
2989 <structfield>vblank_disable_immediate</structfield> flag, which when set
2990 causes vblank interrupts to be disabled immediately regardless of the
2991 drm_vblank_offdelay value. The flag should only be set if there's a
2992 properly working hardware vblank counter present.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02002993 </para>
2994 <para>
2995 When a vertical blanking interrupt occurs drivers only need to call the
2996 <function>drm_handle_vblank</function> function to account for the
2997 interrupt.
2998 </para>
2999 <para>
3000 Resources allocated by <function>drm_vblank_init</function> must be freed
3001 with a call to <function>drm_vblank_cleanup</function> in the driver
3002 <methodname>unload</methodname> operation handler.
3003 </para>
Daniel Vetterf5752b32014-05-08 16:41:51 +02003004 <sect2>
3005 <title>Vertical Blanking and Interrupt Handling Functions Reference</title>
3006!Edrivers/gpu/drm/drm_irq.c
Daniel Vetterd743ecf2014-09-23 15:46:54 +02003007!Finclude/drm/drmP.h drm_crtc_vblank_waitqueue
Daniel Vetterf5752b32014-05-08 16:41:51 +02003008 </sect2>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003009 </sect1>
3010
3011 <!-- Internals: open/close, file operations and ioctls -->
3012
3013 <sect1>
3014 <title>Open/Close, File Operations and IOCTLs</title>
3015 <sect2>
3016 <title>Open and Close</title>
3017 <synopsis>int (*firstopen) (struct drm_device *);
3018void (*lastclose) (struct drm_device *);
3019int (*open) (struct drm_device *, struct drm_file *);
3020void (*preclose) (struct drm_device *, struct drm_file *);
3021void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
3022 <abstract>Open and close handlers. None of those methods are mandatory.
3023 </abstract>
3024 <para>
3025 The <methodname>firstopen</methodname> method is called by the DRM core
Daniel Vetter7d14bb6b2013-08-08 15:41:15 +02003026 for legacy UMS (User Mode Setting) drivers only when an application
3027 opens a device that has no other opened file handle. UMS drivers can
3028 implement it to acquire device resources. KMS drivers can't use the
3029 method and must acquire resources in the <methodname>load</methodname>
3030 method instead.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003031 </para>
3032 <para>
Daniel Vetter7d14bb6b2013-08-08 15:41:15 +02003033 Similarly the <methodname>lastclose</methodname> method is called when
3034 the last application holding a file handle opened on the device closes
3035 it, for both UMS and KMS drivers. Additionally, the method is also
3036 called at module unload time or, for hot-pluggable devices, when the
3037 device is unplugged. The <methodname>firstopen</methodname> and
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003038 <methodname>lastclose</methodname> calls can thus be unbalanced.
3039 </para>
3040 <para>
3041 The <methodname>open</methodname> method is called every time the device
3042 is opened by an application. Drivers can allocate per-file private data
3043 in this method and store them in the struct
3044 <structname>drm_file</structname> <structfield>driver_priv</structfield>
3045 field. Note that the <methodname>open</methodname> method is called
3046 before <methodname>firstopen</methodname>.
3047 </para>
3048 <para>
3049 The close operation is split into <methodname>preclose</methodname> and
3050 <methodname>postclose</methodname> methods. Drivers must stop and
3051 cleanup all per-file operations in the <methodname>preclose</methodname>
3052 method. For instance pending vertical blanking and page flip events must
3053 be cancelled. No per-file operation is allowed on the file handle after
3054 returning from the <methodname>preclose</methodname> method.
3055 </para>
3056 <para>
3057 Finally the <methodname>postclose</methodname> method is called as the
3058 last step of the close operation, right before calling the
3059 <methodname>lastclose</methodname> method if no other open file handle
3060 exists for the device. Drivers that have allocated per-file private data
3061 in the <methodname>open</methodname> method should free it here.
3062 </para>
3063 <para>
3064 The <methodname>lastclose</methodname> method should restore CRTC and
3065 plane properties to default value, so that a subsequent open of the
Daniel Vetter7d14bb6b2013-08-08 15:41:15 +02003066 device will not inherit state from the previous user. It can also be
3067 used to execute delayed power switching state changes, e.g. in
Lukas Wunner6648f482015-10-11 11:55:00 +02003068 conjunction with the vga_switcheroo infrastructure (see
3069 <xref linkend="vga_switcheroo"/>). Beyond that KMS drivers should not
3070 do any further cleanup. Only legacy UMS drivers might need to clean up
3071 device state so that the vga console or an independent fbdev driver
3072 could take over.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003073 </para>
3074 </sect2>
3075 <sect2>
3076 <title>File Operations</title>
3077 <synopsis>const struct file_operations *fops</synopsis>
3078 <abstract>File operations for the DRM device node.</abstract>
3079 <para>
3080 Drivers must define the file operations structure that forms the DRM
3081 userspace API entry point, even though most of those operations are
3082 implemented in the DRM core. The <methodname>open</methodname>,
3083 <methodname>release</methodname> and <methodname>ioctl</methodname>
3084 operations are handled by
3085 <programlisting>
3086 .owner = THIS_MODULE,
3087 .open = drm_open,
3088 .release = drm_release,
3089 .unlocked_ioctl = drm_ioctl,
3090 #ifdef CONFIG_COMPAT
3091 .compat_ioctl = drm_compat_ioctl,
3092 #endif
3093 </programlisting>
3094 </para>
3095 <para>
3096 Drivers that implement private ioctls that requires 32/64bit
3097 compatibility support must provide their own
3098 <methodname>compat_ioctl</methodname> handler that processes private
3099 ioctls and calls <function>drm_compat_ioctl</function> for core ioctls.
3100 </para>
3101 <para>
3102 The <methodname>read</methodname> and <methodname>poll</methodname>
3103 operations provide support for reading DRM events and polling them. They
3104 are implemented by
3105 <programlisting>
3106 .poll = drm_poll,
3107 .read = drm_read,
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003108 .llseek = no_llseek,
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003109 </programlisting>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003110 </para>
3111 <para>
3112 The memory mapping implementation varies depending on how the driver
3113 manages memory. Pre-GEM drivers will use <function>drm_mmap</function>,
3114 while GEM-aware drivers will use <function>drm_gem_mmap</function>. See
3115 <xref linkend="drm-gem"/>.
3116 <programlisting>
3117 .mmap = drm_gem_mmap,
3118 </programlisting>
3119 </para>
3120 <para>
3121 No other file operation is supported by the DRM API.
3122 </para>
3123 </sect2>
3124 <sect2>
3125 <title>IOCTLs</title>
3126 <synopsis>struct drm_ioctl_desc *ioctls;
3127int num_ioctls;</synopsis>
3128 <abstract>Driver-specific ioctls descriptors table.</abstract>
3129 <para>
3130 Driver-specific ioctls numbers start at DRM_COMMAND_BASE. The ioctls
3131 descriptors table is indexed by the ioctl number offset from the base
3132 value. Drivers can use the DRM_IOCTL_DEF_DRV() macro to initialize the
3133 table entries.
3134 </para>
3135 <para>
3136 <programlisting>DRM_IOCTL_DEF_DRV(ioctl, func, flags)</programlisting>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003137 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003138 <parameter>ioctl</parameter> is the ioctl name. Drivers must define
3139 the DRM_##ioctl and DRM_IOCTL_##ioctl macros to the ioctl number
3140 offset from DRM_COMMAND_BASE and the ioctl number respectively. The
3141 first macro is private to the device while the second must be exposed
3142 to userspace in a public header.
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003143 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003144 <para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003145 <parameter>func</parameter> is a pointer to the ioctl handler function
3146 compatible with the <type>drm_ioctl_t</type> type.
3147 <programlisting>typedef int drm_ioctl_t(struct drm_device *dev, void *data,
3148 struct drm_file *file_priv);</programlisting>
3149 </para>
3150 <para>
3151 <parameter>flags</parameter> is a bitmask combination of the following
3152 values. It restricts how the ioctl is allowed to be called.
Michael Witten65ffef52011-08-25 20:55:58 +00003153 <itemizedlist>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003154 <listitem><para>
3155 DRM_AUTH - Only authenticated callers allowed
3156 </para></listitem>
3157 <listitem><para>
3158 DRM_MASTER - The ioctl can only be called on the master file
3159 handle
3160 </para></listitem>
3161 <listitem><para>
3162 DRM_ROOT_ONLY - Only callers with the SYSADMIN capability allowed
3163 </para></listitem>
3164 <listitem><para>
3165 DRM_CONTROL_ALLOW - The ioctl can only be called on a control
3166 device
3167 </para></listitem>
3168 <listitem><para>
3169 DRM_UNLOCKED - The ioctl handler will be called without locking
Daniel Vetterea487832015-09-28 21:42:40 +02003170 the DRM global mutex. This is the enforced default for kms drivers
3171 (i.e. using the DRIVER_MODESET flag) and hence shouldn't be used
3172 any more for new drivers.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003173 </para></listitem>
Michael Witten65ffef52011-08-25 20:55:58 +00003174 </itemizedlist>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003175 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003176 </para>
Daniel Vetter0aaf20c2015-09-08 13:56:27 +02003177!Edrivers/gpu/drm/drm_ioctl.c
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003178 </sect2>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003179 </sect1>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003180 <sect1>
Daniel Vetter4c6e2df2014-01-22 16:46:44 +01003181 <title>Legacy Support Code</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003182 <para>
Masanari Iida9a6594f2014-05-15 13:54:06 -07003183 The section very briefly covers some of the old legacy support code which
Daniel Vetter4c6e2df2014-01-22 16:46:44 +01003184 is only used by old DRM drivers which have done a so-called shadow-attach
3185 to the underlying device instead of registering as a real driver. This
Masanari Iida9a6594f2014-05-15 13:54:06 -07003186 also includes some of the old generic buffer management and command
Daniel Vetter4c6e2df2014-01-22 16:46:44 +01003187 submission code. Do not use any of this in new and modern drivers.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003188 </para>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003189
Daniel Vetter4c6e2df2014-01-22 16:46:44 +01003190 <sect2>
3191 <title>Legacy Suspend/Resume</title>
3192 <para>
3193 The DRM core provides some suspend/resume code, but drivers wanting full
3194 suspend/resume support should provide save() and restore() functions.
3195 These are called at suspend, hibernate, or resume time, and should perform
3196 any state save or restore required by your device across suspend or
3197 hibernate states.
3198 </para>
3199 <synopsis>int (*suspend) (struct drm_device *, pm_message_t state);
3200 int (*resume) (struct drm_device *);</synopsis>
3201 <para>
3202 Those are legacy suspend and resume methods which
3203 <emphasis>only</emphasis> work with the legacy shadow-attach driver
3204 registration functions. New driver should use the power management
3205 interface provided by their bus type (usually through
3206 the struct <structname>device_driver</structname> dev_pm_ops) and set
3207 these methods to NULL.
3208 </para>
3209 </sect2>
3210
3211 <sect2>
3212 <title>Legacy DMA Services</title>
3213 <para>
3214 This should cover how DMA mapping etc. is supported by the core.
3215 These functions are deprecated and should not be used.
3216 </para>
3217 </sect2>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003218 </sect1>
3219 </chapter>
3220
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003221<!-- TODO
3222
3223- Add a glossary
3224- Document the struct_mutex catch-all lock
3225- Document connector properties
3226
3227- Why is the load method optional?
3228- What are drivers supposed to set the initial display state to, and how?
3229 Connector's DPMS states are not initialized and are thus equal to
3230 DRM_MODE_DPMS_ON. The fbcon compatibility layer calls
3231 drm_helper_disable_unused_functions(), which disables unused encoders and
3232 CRTCs, but doesn't touch the connectors' DPMS state, and
3233 drm_helper_connector_dpms() in reaction to fbdev blanking events. Do drivers
3234 that don't implement (or just don't use) fbcon compatibility need to call
3235 those functions themselves?
3236- KMS drivers must call drm_vblank_pre_modeset() and drm_vblank_post_modeset()
3237 around mode setting. Should this be done in the DRM core?
3238- vblank_disable_allowed is set to 1 in the first drm_vblank_post_modeset()
3239 call and never set back to 0. It seems to be safe to permanently set it to 1
3240 in drm_vblank_init() for KMS driver, and it might be safe for UMS drivers as
3241 well. This should be investigated.
3242- crtc and connector .save and .restore operations are only used internally in
3243 drivers, should they be removed from the core?
3244- encoder mid-layer .save and .restore operations are only used internally in
3245 drivers, should they be removed from the core?
3246- encoder mid-layer .detect operation is only used internally in drivers,
3247 should it be removed from the core?
3248-->
3249
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003250 <!-- External interfaces -->
3251
3252 <chapter id="drmExternals">
3253 <title>Userland interfaces</title>
3254 <para>
3255 The DRM core exports several interfaces to applications,
3256 generally intended to be used through corresponding libdrm
Michael Wittena5294e02011-08-29 18:05:52 +00003257 wrapper functions. In addition, drivers export device-specific
Michael Witten7f0925a2011-08-29 18:07:13 +00003258 interfaces for use by userspace drivers &amp; device-aware
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003259 applications through ioctls and sysfs files.
3260 </para>
3261 <para>
3262 External interfaces include: memory mapping, context management,
3263 DMA operations, AGP management, vblank control, fence
3264 management, memory management, and output management.
3265 </para>
3266 <para>
Michael Wittenbcd3cfc2011-08-29 19:29:16 +00003267 Cover generic ioctls and sysfs layout here. We only need high-level
3268 info, since man pages should cover the rest.
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003269 </para>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003270
David Herrmann17931262013-08-25 18:29:00 +02003271 <!-- External: render nodes -->
3272
3273 <sect1>
3274 <title>Render nodes</title>
3275 <para>
3276 DRM core provides multiple character-devices for user-space to use.
3277 Depending on which device is opened, user-space can perform a different
3278 set of operations (mainly ioctls). The primary node is always created
Daniel Vetter00153ae2014-01-21 12:51:43 +01003279 and called card&lt;num&gt;. Additionally, a currently
3280 unused control node, called controlD&lt;num&gt; is also
David Herrmann17931262013-08-25 18:29:00 +02003281 created. The primary node provides all legacy operations and
3282 historically was the only interface used by userspace. With KMS, the
3283 control node was introduced. However, the planned KMS control interface
3284 has never been written and so the control node stays unused to date.
3285 </para>
3286 <para>
3287 With the increased use of offscreen renderers and GPGPU applications,
3288 clients no longer require running compositors or graphics servers to
3289 make use of a GPU. But the DRM API required unprivileged clients to
3290 authenticate to a DRM-Master prior to getting GPU access. To avoid this
3291 step and to grant clients GPU access without authenticating, render
3292 nodes were introduced. Render nodes solely serve render clients, that
3293 is, no modesetting or privileged ioctls can be issued on render nodes.
3294 Only non-global rendering commands are allowed. If a driver supports
Daniel Vetter00153ae2014-01-21 12:51:43 +01003295 render nodes, it must advertise it via the DRIVER_RENDER
David Herrmann17931262013-08-25 18:29:00 +02003296 DRM driver capability. If not supported, the primary node must be used
3297 for render clients together with the legacy drmAuth authentication
3298 procedure.
3299 </para>
3300 <para>
3301 If a driver advertises render node support, DRM core will create a
Daniel Vetter00153ae2014-01-21 12:51:43 +01003302 separate render node called renderD&lt;num&gt;. There will
David Herrmann17931262013-08-25 18:29:00 +02003303 be one render node per device. No ioctls except PRIME-related ioctls
Daniel Vetter00153ae2014-01-21 12:51:43 +01003304 will be allowed on this node. Especially GEM_OPEN will be
David Herrmann17931262013-08-25 18:29:00 +02003305 explicitly prohibited. Render nodes are designed to avoid the
3306 buffer-leaks, which occur if clients guess the flink names or mmap
3307 offsets on the legacy interface. Additionally to this basic interface,
3308 drivers must mark their driver-dependent render-only ioctls as
Daniel Vetter00153ae2014-01-21 12:51:43 +01003309 DRM_RENDER_ALLOW so render clients can use them. Driver
David Herrmann17931262013-08-25 18:29:00 +02003310 authors must be careful not to allow any privileged ioctls on render
3311 nodes.
3312 </para>
3313 <para>
3314 With render nodes, user-space can now control access to the render node
3315 via basic file-system access-modes. A running graphics server which
3316 authenticates clients on the privileged primary/legacy node is no longer
3317 required. Instead, a client can open the render node and is immediately
3318 granted GPU access. Communication between clients (or servers) is done
3319 via PRIME. FLINK from render node to legacy node is not supported. New
3320 clients must not use the insecure FLINK interface.
3321 </para>
3322 <para>
3323 Besides dropping all modeset/global ioctls, render nodes also drop the
3324 DRM-Master concept. There is no reason to associate render clients with
3325 a DRM-Master as they are independent of any graphics server. Besides,
3326 they must work without any running master, anyway.
3327 Drivers must be able to run without a master object if they support
3328 render nodes. If, on the other hand, a driver requires shared state
3329 between clients which is visible to user-space and accessible beyond
3330 open-file boundaries, they cannot support render nodes.
3331 </para>
3332 </sect1>
3333
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003334 <!-- External: vblank handling -->
3335
3336 <sect1>
3337 <title>VBlank event handling</title>
3338 <para>
3339 The DRM core exposes two vertical blank related ioctls:
3340 <variablelist>
3341 <varlistentry>
3342 <term>DRM_IOCTL_WAIT_VBLANK</term>
3343 <listitem>
3344 <para>
3345 This takes a struct drm_wait_vblank structure as its argument,
3346 and it is used to block or request a signal when a specified
3347 vblank event occurs.
3348 </para>
3349 </listitem>
3350 </varlistentry>
3351 <varlistentry>
3352 <term>DRM_IOCTL_MODESET_CTL</term>
3353 <listitem>
3354 <para>
Daniel Vetter8edffbb2014-05-08 15:39:19 +02003355 This was only used for user-mode-settind drivers around
3356 modesetting changes to allow the kernel to update the vblank
3357 interrupt after mode setting, since on many devices the vertical
3358 blank counter is reset to 0 at some point during modeset. Modern
3359 drivers should not call this any more since with kernel mode
3360 setting it is a no-op.
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003361 </para>
3362 </listitem>
3363 </varlistentry>
3364 </variablelist>
Laurent Pinchart9cad9c92012-07-13 00:57:26 +02003365 </para>
3366 </sect1>
3367
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003368 </chapter>
Daniel Vetter3519f702014-01-22 12:21:16 +01003369</part>
3370<part id="drmDrivers">
3371 <title>DRM Drivers</title>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003372
Daniel Vetter3519f702014-01-22 12:21:16 +01003373 <partintro>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003374 <para>
Lukas Wunner7f817072015-10-11 11:26:26 +02003375 This second part of the GPU Driver Developer's Guide documents driver
3376 code, implementation details and also all the driver-specific userspace
Daniel Vetter3519f702014-01-22 12:21:16 +01003377 interfaces. Especially since all hardware-acceleration interfaces to
3378 userspace are driver specific for efficiency and other reasons these
3379 interfaces can be rather substantial. Hence every driver has its own
3380 chapter.
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003381 </para>
Daniel Vetter3519f702014-01-22 12:21:16 +01003382 </partintro>
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003383
Daniel Vetter3519f702014-01-22 12:21:16 +01003384 <chapter id="drmI915">
3385 <title>drm/i915 Intel GFX Driver</title>
3386 <para>
3387 The drm/i915 driver supports all (with the exception of some very early
3388 models) integrated GFX chipsets with both Intel display and rendering
3389 blocks. This excludes a set of SoC platforms with an SGX rendering unit,
3390 those have basic support through the gma500 drm driver.
3391 </para>
3392 <sect1>
Daniel Vettere4e76842014-09-30 10:56:42 +02003393 <title>Core Driver Infrastructure</title>
3394 <para>
3395 This section covers core driver infrastructure used by both the display
3396 and the GEM parts of the driver.
3397 </para>
3398 <sect2>
3399 <title>Runtime Power Management</title>
3400!Pdrivers/gpu/drm/i915/intel_runtime_pm.c runtime pm
3401!Idrivers/gpu/drm/i915/intel_runtime_pm.c
Mika Kuoppala397f6fa2015-01-28 17:47:58 +02003402!Idrivers/gpu/drm/i915/intel_uncore.c
Daniel Vettere4e76842014-09-30 10:56:42 +02003403 </sect2>
Daniel Vetterfca52a52014-09-30 10:56:45 +02003404 <sect2>
3405 <title>Interrupt Handling</title>
3406!Pdrivers/gpu/drm/i915/i915_irq.c interrupt handling
3407!Fdrivers/gpu/drm/i915/i915_irq.c intel_irq_init intel_irq_init_hw intel_hpd_init
Daniel Vetterfca52a52014-09-30 10:56:45 +02003408!Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_disable_interrupts
3409!Fdrivers/gpu/drm/i915/i915_irq.c intel_runtime_pm_enable_interrupts
3410 </sect2>
Yu Zhangcf9d2892015-02-10 19:05:47 +08003411 <sect2>
3412 <title>Intel GVT-g Guest Support(vGPU)</title>
3413!Pdrivers/gpu/drm/i915/i915_vgpu.c Intel GVT-g guest support
3414!Idrivers/gpu/drm/i915/i915_vgpu.c
3415 </sect2>
Daniel Vettere4e76842014-09-30 10:56:42 +02003416 </sect1>
3417 <sect1>
Daniel Vetter3519f702014-01-22 12:21:16 +01003418 <title>Display Hardware Handling</title>
3419 <para>
3420 This section covers everything related to the display hardware including
3421 the mode setting infrastructure, plane, sprite and cursor handling and
3422 display, output probing and related topics.
3423 </para>
3424 <sect2>
3425 <title>Mode Setting Infrastructure</title>
3426 <para>
3427 The i915 driver is thus far the only DRM driver which doesn't use the
3428 common DRM helper code to implement mode setting sequences. Thus it
3429 has its own tailor-made infrastructure for executing a display
3430 configuration change.
3431 </para>
3432 </sect2>
3433 <sect2>
Daniel Vetterb680c372014-09-19 18:27:27 +02003434 <title>Frontbuffer Tracking</title>
3435!Pdrivers/gpu/drm/i915/intel_frontbuffer.c frontbuffer tracking
3436!Idrivers/gpu/drm/i915/intel_frontbuffer.c
Daniel Vetterb680c372014-09-19 18:27:27 +02003437!Fdrivers/gpu/drm/i915/i915_gem.c i915_gem_track_fb
3438 </sect2>
3439 <sect2>
Daniel Vetteref073882014-09-30 10:56:50 +02003440 <title>Display FIFO Underrun Reporting</title>
3441!Pdrivers/gpu/drm/i915/intel_fifo_underrun.c fifo underrun handling
3442!Idrivers/gpu/drm/i915/intel_fifo_underrun.c
3443 </sect2>
3444 <sect2>
Daniel Vetter3519f702014-01-22 12:21:16 +01003445 <title>Plane Configuration</title>
3446 <para>
3447 This section covers plane configuration and composition with the
3448 primary plane, sprites, cursors and overlays. This includes the
3449 infrastructure to do atomic vsync'ed updates of all this state and
3450 also tightly coupled topics like watermark setup and computation,
3451 framebuffer compression and panel self refresh.
3452 </para>
3453 </sect2>
3454 <sect2>
Matt Roperea2c67b2014-12-23 10:41:52 -08003455 <title>Atomic Plane Helpers</title>
3456!Pdrivers/gpu/drm/i915/intel_atomic_plane.c atomic plane helpers
3457!Idrivers/gpu/drm/i915/intel_atomic_plane.c
3458 </sect2>
3459 <sect2>
Daniel Vetter3519f702014-01-22 12:21:16 +01003460 <title>Output Probing</title>
3461 <para>
3462 This section covers output probing and related infrastructure like the
3463 hotplug interrupt storm detection and mitigation code. Note that the
3464 i915 driver still uses most of the common DRM helper code for output
3465 probing, so those sections fully apply.
3466 </para>
3467 </sect2>
Ville Syrjälä0e767182014-04-25 20:14:31 +03003468 <sect2>
Jani Nikula856974a2015-07-02 16:05:28 +03003469 <title>Hotplug</title>
3470!Pdrivers/gpu/drm/i915/intel_hotplug.c Hotplug
3471!Idrivers/gpu/drm/i915/intel_hotplug.c
3472 </sect2>
3473 <sect2>
Jani Nikula28855d22014-10-27 16:27:00 +02003474 <title>High Definition Audio</title>
3475!Pdrivers/gpu/drm/i915/intel_audio.c High Definition Audio over HDMI and Display Port
3476!Idrivers/gpu/drm/i915/intel_audio.c
Libin Yangcb422612015-10-01 17:01:09 +08003477!Iinclude/drm/i915_component.h
Jani Nikula28855d22014-10-27 16:27:00 +02003478 </sect2>
3479 <sect2>
Rodrigo Vivib2b89f52014-11-14 08:52:29 -08003480 <title>Panel Self Refresh PSR (PSR/SRD)</title>
3481!Pdrivers/gpu/drm/i915/intel_psr.c Panel Self Refresh (PSR/SRD)
3482!Idrivers/gpu/drm/i915/intel_psr.c
3483 </sect2>
3484 <sect2>
Rodrigo Vivi94b839572014-12-08 06:46:31 -08003485 <title>Frame Buffer Compression (FBC)</title>
3486!Pdrivers/gpu/drm/i915/intel_fbc.c Frame Buffer Compression (FBC)
3487!Idrivers/gpu/drm/i915/intel_fbc.c
3488 </sect2>
3489 <sect2>
Vandana Kannanb33a2812015-02-13 15:33:03 +05303490 <title>Display Refresh Rate Switching (DRRS)</title>
3491!Pdrivers/gpu/drm/i915/intel_dp.c Display Refresh Rate Switching (DRRS)
3492!Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_set_drrs_state
3493!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_enable
3494!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_disable
3495!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_invalidate
3496!Fdrivers/gpu/drm/i915/intel_dp.c intel_edp_drrs_flush
3497!Fdrivers/gpu/drm/i915/intel_dp.c intel_dp_drrs_init
3498
3499 </sect2>
3500 <sect2>
Ville Syrjälä0e767182014-04-25 20:14:31 +03003501 <title>DPIO</title>
3502!Pdrivers/gpu/drm/i915/i915_reg.h DPIO
3503 </sect2>
Animesh Mannaaa9145c2015-05-13 22:13:29 +05303504
3505 <sect2>
3506 <title>CSR firmware support for DMC</title>
3507!Pdrivers/gpu/drm/i915/intel_csr.c csr support for dmc
3508!Idrivers/gpu/drm/i915/intel_csr.c
3509 </sect2>
Daniel Vetter3519f702014-01-22 12:21:16 +01003510 </sect1>
3511
3512 <sect1>
3513 <title>Memory Management and Command Submission</title>
3514 <para>
3515 This sections covers all things related to the GEM implementation in the
3516 i915 driver.
3517 </para>
Daniel Vetter122b2502014-04-25 16:59:00 +02003518 <sect2>
3519 <title>Batchbuffer Parsing</title>
3520!Pdrivers/gpu/drm/i915/i915_cmd_parser.c batch buffer command parser
3521!Idrivers/gpu/drm/i915/i915_cmd_parser.c
3522 </sect2>
Oscar Mateo73e4d072014-07-24 17:04:48 +01003523 <sect2>
Brad Volkin493018d2014-12-11 12:13:08 -08003524 <title>Batchbuffer Pools</title>
3525!Pdrivers/gpu/drm/i915/i915_gem_batch_pool.c batch pool
3526!Idrivers/gpu/drm/i915/i915_gem_batch_pool.c
3527 </sect2>
3528 <sect2>
Oscar Mateo73e4d072014-07-24 17:04:48 +01003529 <title>Logical Rings, Logical Ring Contexts and Execlists</title>
3530!Pdrivers/gpu/drm/i915/intel_lrc.c Logical Rings, Logical Ring Contexts and Execlists
3531!Idrivers/gpu/drm/i915/intel_lrc.c
3532 </sect2>
Tvrtko Ursulin45f8f692014-12-10 17:27:59 +00003533 <sect2>
3534 <title>Global GTT views</title>
3535!Pdrivers/gpu/drm/i915/i915_gem_gtt.c Global GTT views
3536!Idrivers/gpu/drm/i915/i915_gem_gtt.c
3537 </sect2>
Daniel Vetter7838a632015-01-05 14:36:59 +01003538 <sect2>
Daniel Vetter3271dca2015-07-24 17:40:15 +02003539 <title>GTT Fences and Swizzling</title>
Daniel Vettera794f622015-07-24 17:40:12 +02003540!Idrivers/gpu/drm/i915/i915_gem_fence.c
Daniel Vetter3271dca2015-07-24 17:40:15 +02003541 <sect3>
3542 <title>Global GTT Fence Handling</title>
3543!Pdrivers/gpu/drm/i915/i915_gem_fence.c fence register handling
3544 </sect3>
3545 <sect3>
3546 <title>Hardware Tiling and Swizzling Details</title>
3547!Pdrivers/gpu/drm/i915/i915_gem_fence.c tiling swizzling details
3548 </sect3>
3549 </sect2>
3550 <sect2>
3551 <title>Object Tiling IOCTLs</title>
3552!Idrivers/gpu/drm/i915/i915_gem_tiling.c
3553!Pdrivers/gpu/drm/i915/i915_gem_tiling.c buffer object tiling
Daniel Vettera794f622015-07-24 17:40:12 +02003554 </sect2>
3555 <sect2>
Daniel Vetter7838a632015-01-05 14:36:59 +01003556 <title>Buffer Object Eviction</title>
3557 <para>
Daniel Vettereb0b44a2015-03-18 14:47:59 +01003558 This section documents the interface functions for evicting buffer
Daniel Vetter7838a632015-01-05 14:36:59 +01003559 objects to make space available in the virtual gpu address spaces.
3560 Note that this is mostly orthogonal to shrinking buffer objects
3561 caches, which has the goal to make main memory (shared with the gpu
3562 through the unified memory architecture) available.
3563 </para>
3564!Idrivers/gpu/drm/i915/i915_gem_evict.c
3565 </sect2>
Daniel Vettereb0b44a2015-03-18 14:47:59 +01003566 <sect2>
3567 <title>Buffer Object Memory Shrinking</title>
3568 <para>
3569 This section documents the interface function for shrinking memory
3570 usage of buffer object caches. Shrinking is used to make main memory
3571 available. Note that this is mostly orthogonal to evicting buffer
3572 objects, which has the goal to make space in gpu virtual address
3573 spaces.
3574 </para>
3575!Idrivers/gpu/drm/i915/i915_gem_shrinker.c
3576 </sect2>
Daniel Vetter3519f702014-01-22 12:21:16 +01003577 </sect1>
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +00003578 <sect1>
Daniel Vetter92907cb2015-11-23 09:04:05 +01003579 <title>GuC</title>
Alex Daid1675192015-08-12 15:43:43 +01003580 <sect2>
Daniel Vetter92907cb2015-11-23 09:04:05 +01003581 <title>GuC-specific firmware loader</title>
Alex Daid1675192015-08-12 15:43:43 +01003582!Pdrivers/gpu/drm/i915/intel_guc_loader.c GuC-specific firmware loader
3583!Idrivers/gpu/drm/i915/intel_guc_loader.c
3584 </sect2>
3585 <sect2>
Daniel Vetter92907cb2015-11-23 09:04:05 +01003586 <title>GuC-based command submission</title>
3587!Pdrivers/gpu/drm/i915/i915_guc_submission.c GuC-based command submission
Graham Whaleycff4f552015-08-24 14:41:21 +01003588!Idrivers/gpu/drm/i915/i915_guc_submission.c
Alex Daid1675192015-08-12 15:43:43 +01003589 </sect2>
Daniel Vetter92907cb2015-11-23 09:04:05 +01003590 <sect2>
3591 <title>GuC Firmware Layout</title>
3592!Pdrivers/gpu/drm/i915/intel_guc_fwif.h GuC Firmware Layout
3593 </sect2>
Alex Daid1675192015-08-12 15:43:43 +01003594 </sect1>
3595
3596 <sect1>
Daniele Ceraolo Spurio198c9742014-11-10 13:44:31 +00003597 <title> Tracing </title>
3598 <para>
3599 This sections covers all things related to the tracepoints implemented in
3600 the i915 driver.
3601 </para>
3602 <sect2>
3603 <title> i915_ppgtt_create and i915_ppgtt_release </title>
3604!Pdrivers/gpu/drm/i915/i915_trace.h i915_ppgtt_create and i915_ppgtt_release tracepoints
3605 </sect2>
3606 <sect2>
3607 <title> i915_context_create and i915_context_free </title>
3608!Pdrivers/gpu/drm/i915/i915_trace.h i915_context_create and i915_context_free tracepoints
3609 </sect2>
3610 <sect2>
3611 <title> switch_mm </title>
3612!Pdrivers/gpu/drm/i915/i915_trace.h switch_mm tracepoint
3613 </sect2>
3614 </sect1>
3615
Daniel Vetter3519f702014-01-22 12:21:16 +01003616 </chapter>
Daniel Vetterfca52a52014-09-30 10:56:45 +02003617!Cdrivers/gpu/drm/i915/i915_irq.c
Daniel Vetter3519f702014-01-22 12:21:16 +01003618</part>
Lukas Wunner6648f482015-10-11 11:55:00 +02003619
3620<part id="vga_switcheroo">
3621 <title>vga_switcheroo</title>
3622 <partintro>
3623!Pdrivers/gpu/vga/vga_switcheroo.c Overview
3624 </partintro>
3625
3626 <chapter id="modes_of_use">
3627 <title>Modes of Use</title>
Lukas Wunner3a848662016-01-02 18:47:17 +01003628 <sect1>
3629 <title>Manual switching and manual power control</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003630!Pdrivers/gpu/vga/vga_switcheroo.c Manual switching and manual power control
Lukas Wunner3a848662016-01-02 18:47:17 +01003631 </sect1>
3632 <sect1>
3633 <title>Driver power control</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003634!Pdrivers/gpu/vga/vga_switcheroo.c Driver power control
Lukas Wunner3a848662016-01-02 18:47:17 +01003635 </sect1>
Lukas Wunner6648f482015-10-11 11:55:00 +02003636 </chapter>
3637
Lukas Wunner3a848662016-01-02 18:47:17 +01003638 <chapter id="api">
3639 <title>API</title>
3640 <sect1>
3641 <title>Public functions</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003642!Edrivers/gpu/vga/vga_switcheroo.c
Lukas Wunner3a848662016-01-02 18:47:17 +01003643 </sect1>
3644 <sect1>
3645 <title>Public structures</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003646!Finclude/linux/vga_switcheroo.h vga_switcheroo_handler
3647!Finclude/linux/vga_switcheroo.h vga_switcheroo_client_ops
Lukas Wunner3a848662016-01-02 18:47:17 +01003648 </sect1>
3649 <sect1>
3650 <title>Public constants</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003651!Finclude/linux/vga_switcheroo.h vga_switcheroo_client_id
3652!Finclude/linux/vga_switcheroo.h vga_switcheroo_state
Lukas Wunner3a848662016-01-02 18:47:17 +01003653 </sect1>
3654 <sect1>
3655 <title>Private structures</title>
Lukas Wunner6648f482015-10-11 11:55:00 +02003656!Fdrivers/gpu/vga/vga_switcheroo.c vgasr_priv
3657!Fdrivers/gpu/vga/vga_switcheroo.c vga_switcheroo_client
Lukas Wunner3a848662016-01-02 18:47:17 +01003658 </sect1>
Lukas Wunner6648f482015-10-11 11:55:00 +02003659 </chapter>
3660
3661!Cdrivers/gpu/vga/vga_switcheroo.c
3662!Cinclude/linux/vga_switcheroo.h
3663</part>
3664
Jesse Barnes2d2ef822009-10-26 13:06:31 -07003665</book>