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