]>
Commit | Line | Data |
---|---|---|
2fa91d15 JN |
1 | ========================= |
2 | Kernel Mode Setting (KMS) | |
3 | ========================= | |
4 | ||
2fa91d15 JN |
5 | Drivers must initialize the mode setting core by calling |
6 | :c:func:`drm_mode_config_init()` on the DRM device. The function | |
7 | initializes the :c:type:`struct drm_device <drm_device>` | |
8 | mode_config field and never fails. Once done, mode configuration must | |
9 | be setup by initializing the following fields. | |
10 | ||
11 | - int min_width, min_height; int max_width, max_height; | |
12 | Minimum and maximum width and height of the frame buffers in pixel | |
13 | units. | |
14 | ||
15 | - struct drm_mode_config_funcs \*funcs; | |
16 | Mode setting functions. | |
17 | ||
311b62d9 DV |
18 | KMS Data Structures |
19 | =================== | |
2fa91d15 | 20 | |
311b62d9 | 21 | .. kernel-doc:: include/drm/drm_crtc.h |
2fa91d15 JN |
22 | :internal: |
23 | ||
311b62d9 DV |
24 | KMS API Functions |
25 | ================= | |
26 | ||
27 | .. kernel-doc:: drivers/gpu/drm/drm_crtc.c | |
2fa91d15 JN |
28 | :export: |
29 | ||
30 | Atomic Mode Setting Function Reference | |
311b62d9 | 31 | ====================================== |
2fa91d15 JN |
32 | |
33 | .. kernel-doc:: drivers/gpu/drm/drm_atomic.c | |
34 | :export: | |
35 | ||
5d070be6 | 36 | .. kernel-doc:: include/drm/drm_atomic.h |
2fa91d15 JN |
37 | :internal: |
38 | ||
39 | Frame Buffer Abstraction | |
311b62d9 | 40 | ======================== |
2fa91d15 | 41 | |
750fb8c4 DV |
42 | .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c |
43 | :doc: overview | |
2fa91d15 | 44 | |
7520a277 DV |
45 | Frame Buffer Functions Reference |
46 | -------------------------------- | |
47 | ||
48 | .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c | |
49 | :export: | |
50 | ||
51 | .. kernel-doc:: include/drm/drm_framebuffer.h | |
52 | :internal: | |
53 | ||
2fa91d15 | 54 | DRM Format Handling |
311b62d9 | 55 | =================== |
2fa91d15 | 56 | |
2fa91d15 JN |
57 | .. kernel-doc:: drivers/gpu/drm/drm_fourcc.c |
58 | :export: | |
59 | ||
60 | Dumb Buffer Objects | |
311b62d9 | 61 | =================== |
2fa91d15 JN |
62 | |
63 | The KMS API doesn't standardize backing storage object creation and | |
64 | leaves it to driver-specific ioctls. Furthermore actually creating a | |
65 | buffer object even for GEM-based drivers is done through a | |
66 | driver-specific ioctl - GEM only has a common userspace interface for | |
67 | sharing and destroying objects. While not an issue for full-fledged | |
68 | graphics stacks that include device-specific userspace components (in | |
69 | libdrm for instance), this limit makes DRM-based early boot graphics | |
70 | unnecessarily complex. | |
71 | ||
72 | Dumb objects partly alleviate the problem by providing a standard API to | |
73 | create dumb buffers suitable for scanout, which can then be used to | |
74 | create KMS frame buffers. | |
75 | ||
76 | To support dumb objects drivers must implement the dumb_create, | |
77 | dumb_destroy and dumb_map_offset operations. | |
78 | ||
79 | - int (\*dumb_create)(struct drm_file \*file_priv, struct | |
80 | drm_device \*dev, struct drm_mode_create_dumb \*args); | |
81 | The dumb_create operation creates a driver object (GEM or TTM | |
82 | handle) suitable for scanout based on the width, height and depth | |
83 | from the struct :c:type:`struct drm_mode_create_dumb | |
84 | <drm_mode_create_dumb>` argument. It fills the argument's | |
85 | handle, pitch and size fields with a handle for the newly created | |
86 | object and its line pitch and size in bytes. | |
87 | ||
88 | - int (\*dumb_destroy)(struct drm_file \*file_priv, struct | |
89 | drm_device \*dev, uint32_t handle); | |
90 | The dumb_destroy operation destroys a dumb object created by | |
91 | dumb_create. | |
92 | ||
93 | - int (\*dumb_map_offset)(struct drm_file \*file_priv, struct | |
94 | drm_device \*dev, uint32_t handle, uint64_t \*offset); | |
95 | The dumb_map_offset operation associates an mmap fake offset with | |
96 | the object given by the handle and returns it. Drivers must use the | |
97 | :c:func:`drm_gem_create_mmap_offset()` function to associate | |
98 | the fake offset as described in ?. | |
99 | ||
100 | Note that dumb objects may not be used for gpu acceleration, as has been | |
101 | attempted on some ARM embedded platforms. Such drivers really must have | |
102 | a hardware-specific ioctl to allocate suitable buffer objects. | |
103 | ||
311b62d9 DV |
104 | Display Modes Function Reference |
105 | ================================ | |
2fa91d15 | 106 | |
311b62d9 DV |
107 | .. kernel-doc:: include/drm/drm_modes.h |
108 | :internal: | |
109 | ||
110 | .. kernel-doc:: drivers/gpu/drm/drm_modes.c | |
111 | :export: | |
2fa91d15 | 112 | |
52217195 DV |
113 | Connector Display Sink Abstraction |
114 | ================================== | |
115 | ||
116 | .. kernel-doc:: include/drm/drm_connector.h | |
117 | :internal: | |
118 | ||
119 | .. kernel-doc:: drivers/gpu/drm/drm_connector.c | |
120 | :export: | |
121 | ||
2fa91d15 JN |
122 | KMS Initialization and Cleanup |
123 | ============================== | |
124 | ||
125 | A KMS device is abstracted and exposed as a set of planes, CRTCs, | |
126 | encoders and connectors. KMS drivers must thus create and initialize all | |
127 | those objects at load time after initializing mode setting. | |
128 | ||
129 | CRTCs (:c:type:`struct drm_crtc <drm_crtc>`) | |
130 | -------------------------------------------- | |
131 | ||
132 | A CRTC is an abstraction representing a part of the chip that contains a | |
133 | pointer to a scanout buffer. Therefore, the number of CRTCs available | |
134 | determines how many independent scanout buffers can be active at any | |
135 | given time. The CRTC structure contains several fields to support this: | |
136 | a pointer to some video memory (abstracted as a frame buffer object), a | |
137 | display mode, and an (x, y) offset into the video memory to support | |
138 | panning or configurations where one piece of video memory spans multiple | |
139 | CRTCs. | |
140 | ||
141 | CRTC Initialization | |
142 | ~~~~~~~~~~~~~~~~~~~ | |
143 | ||
144 | A KMS device must create and register at least one struct | |
145 | :c:type:`struct drm_crtc <drm_crtc>` instance. The instance is | |
146 | allocated and zeroed by the driver, possibly as part of a larger | |
147 | structure, and registered with a call to :c:func:`drm_crtc_init()` | |
148 | with a pointer to CRTC functions. | |
149 | ||
150 | Planes (:c:type:`struct drm_plane <drm_plane>`) | |
151 | ----------------------------------------------- | |
152 | ||
153 | A plane represents an image source that can be blended with or overlayed | |
154 | on top of a CRTC during the scanout process. Planes are associated with | |
155 | a frame buffer to crop a portion of the image memory (source) and | |
156 | optionally scale it to a destination size. The result is then blended | |
157 | with or overlayed on top of a CRTC. | |
158 | ||
159 | The DRM core recognizes three types of planes: | |
160 | ||
161 | - DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. | |
162 | Primary planes are the planes operated upon by CRTC modesetting and | |
163 | flipping operations described in the page_flip hook in | |
164 | :c:type:`struct drm_crtc_funcs <drm_crtc_funcs>`. | |
165 | - DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. | |
166 | Cursor planes are the planes operated upon by the | |
167 | DRM_IOCTL_MODE_CURSOR and DRM_IOCTL_MODE_CURSOR2 ioctls. | |
168 | - DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor | |
169 | planes. Some drivers refer to these types of planes as "sprites" | |
170 | internally. | |
171 | ||
172 | For compatibility with legacy userspace, only overlay planes are made | |
173 | available to userspace by default. Userspace clients may set the | |
174 | DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate | |
175 | that they wish to receive a universal plane list containing all plane | |
176 | types. | |
177 | ||
178 | Plane Initialization | |
179 | ~~~~~~~~~~~~~~~~~~~~ | |
180 | ||
181 | To create a plane, a KMS drivers allocates and zeroes an instances of | |
182 | :c:type:`struct drm_plane <drm_plane>` (possibly as part of a | |
183 | larger structure) and registers it with a call to | |
184 | :c:func:`drm_universal_plane_init()`. The function takes a | |
185 | bitmask of the CRTCs that can be associated with the plane, a pointer to | |
186 | the plane functions, a list of format supported formats, and the type of | |
187 | plane (primary, cursor, or overlay) being initialized. | |
188 | ||
189 | Cursor and overlay planes are optional. All drivers should provide one | |
190 | primary plane per CRTC (although this requirement may change in the | |
191 | future); drivers that do not wish to provide special handling for | |
192 | primary planes may make use of the helper functions described in ? to | |
193 | create and register a primary plane with standard capabilities. | |
194 | ||
195 | Encoders (:c:type:`struct drm_encoder <drm_encoder>`) | |
196 | ----------------------------------------------------- | |
197 | ||
198 | An encoder takes pixel data from a CRTC and converts it to a format | |
199 | suitable for any attached connectors. On some devices, it may be | |
200 | possible to have a CRTC send data to more than one encoder. In that | |
201 | case, both encoders would receive data from the same scanout buffer, | |
202 | resulting in a "cloned" display configuration across the connectors | |
203 | attached to each encoder. | |
204 | ||
205 | Encoder Initialization | |
206 | ~~~~~~~~~~~~~~~~~~~~~~ | |
207 | ||
208 | As for CRTCs, a KMS driver must create, initialize and register at least | |
209 | one :c:type:`struct drm_encoder <drm_encoder>` instance. The | |
210 | instance is allocated and zeroed by the driver, possibly as part of a | |
211 | larger structure. | |
212 | ||
213 | Drivers must initialize the :c:type:`struct drm_encoder | |
214 | <drm_encoder>` possible_crtcs and possible_clones fields before | |
215 | registering the encoder. Both fields are bitmasks of respectively the | |
216 | CRTCs that the encoder can be connected to, and sibling encoders | |
217 | candidate for cloning. | |
218 | ||
219 | After being initialized, the encoder must be registered with a call to | |
220 | :c:func:`drm_encoder_init()`. The function takes a pointer to the | |
221 | encoder functions and an encoder type. Supported types are | |
222 | ||
223 | - DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A | |
224 | - DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort | |
225 | - DRM_MODE_ENCODER_LVDS for display panels | |
226 | - DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, | |
227 | Component, SCART) | |
228 | - DRM_MODE_ENCODER_VIRTUAL for virtual machine displays | |
229 | ||
230 | Encoders must be attached to a CRTC to be used. DRM drivers leave | |
231 | encoders unattached at initialization time. Applications (or the fbdev | |
232 | compatibility layer when implemented) are responsible for attaching the | |
233 | encoders they want to use to a CRTC. | |
234 | ||
235 | Connectors (:c:type:`struct drm_connector <drm_connector>`) | |
236 | ----------------------------------------------------------- | |
237 | ||
238 | A connector is the final destination for pixel data on a device, and | |
239 | usually connects directly to an external display device like a monitor | |
240 | or laptop panel. A connector can only be attached to one encoder at a | |
241 | time. The connector is also the structure where information about the | |
242 | attached display is kept, so it contains fields for display data, EDID | |
243 | data, DPMS & connection status, and information about modes supported on | |
244 | the attached displays. | |
245 | ||
246 | Connector Initialization | |
247 | ~~~~~~~~~~~~~~~~~~~~~~~~ | |
248 | ||
249 | Finally a KMS driver must create, initialize, register and attach at | |
250 | least one :c:type:`struct drm_connector <drm_connector>` | |
251 | instance. The instance is created as other KMS objects and initialized | |
252 | by setting the following fields. | |
253 | ||
254 | interlace_allowed | |
255 | Whether the connector can handle interlaced modes. | |
256 | ||
257 | doublescan_allowed | |
258 | Whether the connector can handle doublescan. | |
259 | ||
260 | display_info | |
261 | Display information is filled from EDID information when a display | |
262 | is detected. For non hot-pluggable displays such as flat panels in | |
263 | embedded systems, the driver should initialize the | |
264 | display_info.width_mm and display_info.height_mm fields with the | |
265 | physical size of the display. | |
266 | ||
267 | polled | |
268 | Connector polling mode, a combination of | |
269 | ||
270 | DRM_CONNECTOR_POLL_HPD | |
271 | The connector generates hotplug events and doesn't need to be | |
272 | periodically polled. The CONNECT and DISCONNECT flags must not | |
273 | be set together with the HPD flag. | |
274 | ||
275 | DRM_CONNECTOR_POLL_CONNECT | |
276 | Periodically poll the connector for connection. | |
277 | ||
278 | DRM_CONNECTOR_POLL_DISCONNECT | |
279 | Periodically poll the connector for disconnection. | |
280 | ||
281 | Set to 0 for connectors that don't support connection status | |
282 | discovery. | |
283 | ||
284 | The connector is then registered with a call to | |
285 | :c:func:`drm_connector_init()` with a pointer to the connector | |
286 | functions and a connector type, and exposed through sysfs with a call to | |
287 | :c:func:`drm_connector_register()`. | |
288 | ||
289 | Supported connector types are | |
290 | ||
291 | - DRM_MODE_CONNECTOR_VGA | |
292 | - DRM_MODE_CONNECTOR_DVII | |
293 | - DRM_MODE_CONNECTOR_DVID | |
294 | - DRM_MODE_CONNECTOR_DVIA | |
295 | - DRM_MODE_CONNECTOR_Composite | |
296 | - DRM_MODE_CONNECTOR_SVIDEO | |
297 | - DRM_MODE_CONNECTOR_LVDS | |
298 | - DRM_MODE_CONNECTOR_Component | |
299 | - DRM_MODE_CONNECTOR_9PinDIN | |
300 | - DRM_MODE_CONNECTOR_DisplayPort | |
301 | - DRM_MODE_CONNECTOR_HDMIA | |
302 | - DRM_MODE_CONNECTOR_HDMIB | |
303 | - DRM_MODE_CONNECTOR_TV | |
304 | - DRM_MODE_CONNECTOR_eDP | |
305 | - DRM_MODE_CONNECTOR_VIRTUAL | |
306 | ||
307 | Connectors must be attached to an encoder to be used. For devices that | |
308 | map connectors to encoders 1:1, the connector should be attached at | |
309 | initialization time with a call to | |
310 | :c:func:`drm_mode_connector_attach_encoder()`. The driver must | |
311 | also set the :c:type:`struct drm_connector <drm_connector>` | |
312 | encoder field to point to the attached encoder. | |
313 | ||
314 | Finally, drivers must initialize the connectors state change detection | |
315 | with a call to :c:func:`drm_kms_helper_poll_init()`. If at least | |
316 | one connector is pollable but can't generate hotplug interrupts | |
317 | (indicated by the DRM_CONNECTOR_POLL_CONNECT and | |
318 | DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will | |
319 | automatically be queued to periodically poll for changes. Connectors | |
320 | that can generate hotplug interrupts must be marked with the | |
321 | DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must | |
322 | call :c:func:`drm_helper_hpd_irq_event()`. The function will | |
323 | queue a delayed work to check the state of all connectors, but no | |
324 | periodic polling will be done. | |
325 | ||
326 | Connector Operations | |
327 | ~~~~~~~~~~~~~~~~~~~~ | |
328 | ||
329 | **Note** | |
330 | ||
331 | Unless otherwise state, all operations are mandatory. | |
332 | ||
333 | DPMS | |
334 | '''' | |
335 | ||
336 | void (\*dpms)(struct drm_connector \*connector, int mode); | |
337 | The DPMS operation sets the power state of a connector. The mode | |
338 | argument is one of | |
339 | ||
340 | - DRM_MODE_DPMS_ON | |
341 | ||
342 | - DRM_MODE_DPMS_STANDBY | |
343 | ||
344 | - DRM_MODE_DPMS_SUSPEND | |
345 | ||
346 | - DRM_MODE_DPMS_OFF | |
347 | ||
348 | In all but DPMS_ON mode the encoder to which the connector is attached | |
349 | should put the display in low-power mode by driving its signals | |
350 | appropriately. If more than one connector is attached to the encoder | |
351 | care should be taken not to change the power state of other displays as | |
352 | a side effect. Low-power mode should be propagated to the encoders and | |
353 | CRTCs when all related connectors are put in low-power mode. | |
354 | ||
355 | Modes | |
356 | ''''' | |
357 | ||
358 | int (\*fill_modes)(struct drm_connector \*connector, uint32_t | |
359 | max_width, uint32_t max_height); | |
360 | Fill the mode list with all supported modes for the connector. If the | |
361 | ``max_width`` and ``max_height`` arguments are non-zero, the | |
362 | implementation must ignore all modes wider than ``max_width`` or higher | |
363 | than ``max_height``. | |
364 | ||
365 | The connector must also fill in this operation its display_info | |
366 | width_mm and height_mm fields with the connected display physical size | |
367 | in millimeters. The fields should be set to 0 if the value isn't known | |
368 | or is not applicable (for instance for projector devices). | |
369 | ||
370 | Connection Status | |
371 | ''''''''''''''''' | |
372 | ||
373 | The connection status is updated through polling or hotplug events when | |
374 | supported (see ?). The status value is reported to userspace through | |
375 | ioctls and must not be used inside the driver, as it only gets | |
376 | initialized by a call to :c:func:`drm_mode_getconnector()` from | |
377 | userspace. | |
378 | ||
379 | enum drm_connector_status (\*detect)(struct drm_connector | |
380 | \*connector, bool force); | |
381 | Check to see if anything is attached to the connector. The ``force`` | |
382 | parameter is set to false whilst polling or to true when checking the | |
383 | connector due to user request. ``force`` can be used by the driver to | |
384 | avoid expensive, destructive operations during automated probing. | |
385 | ||
386 | Return connector_status_connected if something is connected to the | |
387 | connector, connector_status_disconnected if nothing is connected and | |
388 | connector_status_unknown if the connection state isn't known. | |
389 | ||
390 | Drivers should only return connector_status_connected if the | |
391 | connection status has really been probed as connected. Connectors that | |
392 | can't detect the connection status, or failed connection status probes, | |
393 | should return connector_status_unknown. | |
394 | ||
395 | Cleanup | |
396 | ------- | |
397 | ||
398 | The DRM core manages its objects' lifetime. When an object is not needed | |
399 | anymore the core calls its destroy function, which must clean up and | |
400 | free every resource allocated for the object. Every | |
401 | :c:func:`drm_\*_init()` call must be matched with a corresponding | |
402 | :c:func:`drm_\*_cleanup()` call to cleanup CRTCs | |
403 | (:c:func:`drm_crtc_cleanup()`), planes | |
404 | (:c:func:`drm_plane_cleanup()`), encoders | |
405 | (:c:func:`drm_encoder_cleanup()`) and connectors | |
406 | (:c:func:`drm_connector_cleanup()`). Furthermore, connectors that | |
407 | have been added to sysfs must be removed by a call to | |
408 | :c:func:`drm_connector_unregister()` before calling | |
409 | :c:func:`drm_connector_cleanup()`. | |
410 | ||
411 | Connectors state change detection must be cleanup up with a call to | |
412 | :c:func:`drm_kms_helper_poll_fini()`. | |
413 | ||
414 | Output discovery and initialization example | |
415 | ------------------------------------------- | |
416 | ||
417 | :: | |
418 | ||
419 | void intel_crt_init(struct drm_device *dev) | |
420 | { | |
421 | struct drm_connector *connector; | |
422 | struct intel_output *intel_output; | |
423 | ||
424 | intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); | |
425 | if (!intel_output) | |
426 | return; | |
427 | ||
428 | connector = &intel_output->base; | |
429 | drm_connector_init(dev, &intel_output->base, | |
430 | &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); | |
431 | ||
432 | drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, | |
433 | DRM_MODE_ENCODER_DAC); | |
434 | ||
435 | drm_mode_connector_attach_encoder(&intel_output->base, | |
436 | &intel_output->enc); | |
437 | ||
438 | /* Set up the DDC bus. */ | |
439 | intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); | |
440 | if (!intel_output->ddc_bus) { | |
441 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " | |
442 | "failed.\n"); | |
443 | return; | |
444 | } | |
445 | ||
446 | intel_output->type = INTEL_OUTPUT_ANALOG; | |
447 | connector->interlace_allowed = 0; | |
448 | connector->doublescan_allowed = 0; | |
449 | ||
450 | drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); | |
451 | drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); | |
452 | ||
453 | drm_connector_register(connector); | |
454 | } | |
455 | ||
456 | In the example above (taken from the i915 driver), a CRTC, connector and | |
457 | encoder combination is created. A device-specific i2c bus is also | |
458 | created for fetching EDID data and performing monitor detection. Once | |
459 | the process is complete, the new connector is registered with sysfs to | |
460 | make its properties available to applications. | |
461 | ||
2fa91d15 | 462 | KMS Locking |
311b62d9 | 463 | =========== |
2fa91d15 JN |
464 | |
465 | .. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c | |
466 | :doc: kms locking | |
467 | ||
468 | .. kernel-doc:: include/drm/drm_modeset_lock.h | |
469 | :internal: | |
470 | ||
471 | .. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c | |
472 | :export: | |
473 | ||
474 | KMS Properties | |
475 | ============== | |
476 | ||
477 | Drivers may need to expose additional parameters to applications than | |
478 | those described in the previous sections. KMS supports attaching | |
479 | properties to CRTCs, connectors and planes and offers a userspace API to | |
480 | list, get and set the property values. | |
481 | ||
482 | Properties are identified by a name that uniquely defines the property | |
483 | purpose, and store an associated value. For all property types except | |
484 | blob properties the value is a 64-bit unsigned integer. | |
485 | ||
486 | KMS differentiates between properties and property instances. Drivers | |
487 | first create properties and then create and associate individual | |
488 | instances of those properties to objects. A property can be instantiated | |
489 | multiple times and associated with different objects. Values are stored | |
490 | in property instances, and all other property information are stored in | |
491 | the property and shared between all instances of the property. | |
492 | ||
493 | Every property is created with a type that influences how the KMS core | |
494 | handles the property. Supported property types are | |
495 | ||
496 | DRM_MODE_PROP_RANGE | |
497 | Range properties report their minimum and maximum admissible values. | |
498 | The KMS core verifies that values set by application fit in that | |
499 | range. | |
500 | ||
501 | DRM_MODE_PROP_ENUM | |
502 | Enumerated properties take a numerical value that ranges from 0 to | |
503 | the number of enumerated values defined by the property minus one, | |
504 | and associate a free-formed string name to each value. Applications | |
505 | can retrieve the list of defined value-name pairs and use the | |
506 | numerical value to get and set property instance values. | |
507 | ||
508 | DRM_MODE_PROP_BITMASK | |
509 | Bitmask properties are enumeration properties that additionally | |
510 | restrict all enumerated values to the 0..63 range. Bitmask property | |
511 | instance values combine one or more of the enumerated bits defined | |
512 | by the property. | |
513 | ||
514 | DRM_MODE_PROP_BLOB | |
515 | Blob properties store a binary blob without any format restriction. | |
516 | The binary blobs are created as KMS standalone objects, and blob | |
517 | property instance values store the ID of their associated blob | |
518 | object. | |
519 | ||
520 | Blob properties are only used for the connector EDID property and | |
521 | cannot be created by drivers. | |
522 | ||
523 | To create a property drivers call one of the following functions | |
524 | depending on the property type. All property creation functions take | |
525 | property flags and name, as well as type-specific arguments. | |
526 | ||
527 | - struct drm_property \*drm_property_create_range(struct | |
528 | drm_device \*dev, int flags, const char \*name, uint64_t min, | |
529 | uint64_t max); | |
530 | Create a range property with the given minimum and maximum values. | |
531 | ||
532 | - struct drm_property \*drm_property_create_enum(struct drm_device | |
533 | \*dev, int flags, const char \*name, const struct | |
534 | drm_prop_enum_list \*props, int num_values); | |
535 | Create an enumerated property. The ``props`` argument points to an | |
536 | array of ``num_values`` value-name pairs. | |
537 | ||
538 | - struct drm_property \*drm_property_create_bitmask(struct | |
539 | drm_device \*dev, int flags, const char \*name, const struct | |
540 | drm_prop_enum_list \*props, int num_values); | |
541 | Create a bitmask property. The ``props`` argument points to an array | |
542 | of ``num_values`` value-name pairs. | |
543 | ||
544 | Properties can additionally be created as immutable, in which case they | |
545 | will be read-only for applications but can be modified by the driver. To | |
546 | create an immutable property drivers must set the | |
547 | DRM_MODE_PROP_IMMUTABLE flag at property creation time. | |
548 | ||
549 | When no array of value-name pairs is readily available at property | |
550 | creation time for enumerated or range properties, drivers can create the | |
551 | property using the :c:func:`drm_property_create()` function and | |
552 | manually add enumeration value-name pairs by calling the | |
553 | :c:func:`drm_property_add_enum()` function. Care must be taken to | |
554 | properly specify the property type through the ``flags`` argument. | |
555 | ||
556 | After creating properties drivers can attach property instances to CRTC, | |
557 | connector and plane objects by calling the | |
558 | :c:func:`drm_object_attach_property()`. The function takes a | |
559 | pointer to the target object, a pointer to the previously created | |
560 | property and an initial instance value. | |
561 | ||
52a9fcda DV |
562 | Blending and Z-Position properties |
563 | ---------------------------------- | |
564 | ||
565 | .. kernel-doc:: drivers/gpu/drm/drm_blend.c | |
566 | :export: | |
567 | ||
2fa91d15 JN |
568 | Existing KMS Properties |
569 | ----------------------- | |
570 | ||
571 | The following table gives description of drm properties exposed by | |
572 | various modules/drivers. | |
573 | ||
574 | .. csv-table:: | |
575 | :header-rows: 1 | |
576 | :file: kms-properties.csv | |
577 | ||
578 | Vertical Blanking | |
579 | ================= | |
580 | ||
581 | Vertical blanking plays a major role in graphics rendering. To achieve | |
582 | tear-free display, users must synchronize page flips and/or rendering to | |
583 | vertical blanking. The DRM API offers ioctls to perform page flips | |
584 | synchronized to vertical blanking and wait for vertical blanking. | |
585 | ||
586 | The DRM core handles most of the vertical blanking management logic, | |
587 | which involves filtering out spurious interrupts, keeping race-free | |
588 | blanking counters, coping with counter wrap-around and resets and | |
589 | keeping use counts. It relies on the driver to generate vertical | |
590 | blanking interrupts and optionally provide a hardware vertical blanking | |
591 | counter. Drivers must implement the following operations. | |
592 | ||
593 | - int (\*enable_vblank) (struct drm_device \*dev, int crtc); void | |
594 | (\*disable_vblank) (struct drm_device \*dev, int crtc); | |
595 | Enable or disable vertical blanking interrupts for the given CRTC. | |
596 | ||
597 | - u32 (\*get_vblank_counter) (struct drm_device \*dev, int crtc); | |
598 | Retrieve the value of the vertical blanking counter for the given | |
599 | CRTC. If the hardware maintains a vertical blanking counter its value | |
600 | should be returned. Otherwise drivers can use the | |
601 | :c:func:`drm_vblank_count()` helper function to handle this | |
602 | operation. | |
603 | ||
604 | Drivers must initialize the vertical blanking handling core with a call | |
605 | to :c:func:`drm_vblank_init()` in their load operation. | |
606 | ||
607 | Vertical blanking interrupts can be enabled by the DRM core or by | |
608 | drivers themselves (for instance to handle page flipping operations). | |
609 | The DRM core maintains a vertical blanking use count to ensure that the | |
610 | interrupts are not disabled while a user still needs them. To increment | |
611 | the use count, drivers call :c:func:`drm_vblank_get()`. Upon | |
612 | return vertical blanking interrupts are guaranteed to be enabled. | |
613 | ||
614 | To decrement the use count drivers call | |
615 | :c:func:`drm_vblank_put()`. Only when the use count drops to zero | |
616 | will the DRM core disable the vertical blanking interrupts after a delay | |
617 | by scheduling a timer. The delay is accessible through the | |
618 | vblankoffdelay module parameter or the ``drm_vblank_offdelay`` global | |
619 | variable and expressed in milliseconds. Its default value is 5000 ms. | |
620 | Zero means never disable, and a negative value means disable | |
621 | immediately. Drivers may override the behaviour by setting the | |
622 | :c:type:`struct drm_device <drm_device>` | |
623 | vblank_disable_immediate flag, which when set causes vblank interrupts | |
624 | to be disabled immediately regardless of the drm_vblank_offdelay | |
625 | value. The flag should only be set if there's a properly working | |
626 | hardware vblank counter present. | |
627 | ||
628 | When a vertical blanking interrupt occurs drivers only need to call the | |
629 | :c:func:`drm_handle_vblank()` function to account for the | |
630 | interrupt. | |
631 | ||
632 | Resources allocated by :c:func:`drm_vblank_init()` must be freed | |
633 | with a call to :c:func:`drm_vblank_cleanup()` in the driver unload | |
634 | operation handler. | |
635 | ||
636 | Vertical Blanking and Interrupt Handling Functions Reference | |
637 | ------------------------------------------------------------ | |
638 | ||
639 | .. kernel-doc:: drivers/gpu/drm/drm_irq.c | |
640 | :export: | |
641 | ||
34a67dd7 DV |
642 | .. kernel-doc:: include/drm/drm_irq.h |
643 | :internal: |