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