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