blob: f19757b1736a4b721f5dcdc82e0ae89cc8febe9f [file] [log] [blame]
Jani Nikula2fa91d12016-06-21 14:49:02 +03001=========================
2Kernel Mode Setting (KMS)
3=========================
4
Jani Nikula2fa91d12016-06-21 14:49:02 +03005Drivers must initialize the mode setting core by calling
6:c:func:`drm_mode_config_init()` on the DRM device. The function
7initializes the :c:type:`struct drm_device <drm_device>`
8mode_config field and never fails. Once done, mode configuration must
9be 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
Daniel Vetter28575f12016-11-14 12:58:23 +010018Mode Configuration
19
20KMS Core Structures and Functions
21=================================
22
23.. kernel-doc:: drivers/gpu/drm/drm_mode_config.c
24 :export:
25
26.. kernel-doc:: include/drm/drm_mode_config.h
27 :internal:
28
Daniel Vetter949619f2016-08-29 10:27:51 +020029Modeset Base Object Abstraction
30===============================
31
32.. kernel-doc:: include/drm/drm_mode_object.h
33 :internal:
34
35.. kernel-doc:: drivers/gpu/drm/drm_mode_object.c
36 :export:
37
Jani Nikula2fa91d12016-06-21 14:49:02 +030038Atomic Mode Setting Function Reference
Daniel Vetter311b62d2016-08-12 22:48:41 +020039======================================
Jani Nikula2fa91d12016-06-21 14:49:02 +030040
41.. kernel-doc:: drivers/gpu/drm/drm_atomic.c
42 :export:
43
Daniel Vetter5d070be2016-08-12 22:48:46 +020044.. kernel-doc:: include/drm/drm_atomic.h
Jani Nikula2fa91d12016-06-21 14:49:02 +030045 :internal:
46
Daniel Vetter28575f12016-11-14 12:58:23 +010047CRTC Abstraction
48================
49
50.. kernel-doc:: drivers/gpu/drm/drm_crtc.c
51 :export:
52
53.. kernel-doc:: include/drm/drm_crtc.h
54 :internal:
55
Jani Nikula2fa91d12016-06-21 14:49:02 +030056Frame Buffer Abstraction
Daniel Vetter311b62d2016-08-12 22:48:41 +020057========================
Jani Nikula2fa91d12016-06-21 14:49:02 +030058
Daniel Vetter750fb8c2016-08-12 22:48:48 +020059.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c
60 :doc: overview
Jani Nikula2fa91d12016-06-21 14:49:02 +030061
Daniel Vetter7520a272016-08-15 16:07:02 +020062Frame Buffer Functions Reference
63--------------------------------
64
65.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c
66 :export:
67
68.. kernel-doc:: include/drm/drm_framebuffer.h
69 :internal:
70
Jani Nikula2fa91d12016-06-21 14:49:02 +030071DRM Format Handling
Daniel Vetter311b62d2016-08-12 22:48:41 +020072===================
Jani Nikula2fa91d12016-06-21 14:49:02 +030073
Laurent Pinchart84770cc2016-10-18 01:41:09 +030074.. kernel-doc:: include/drm/drm_fourcc.h
75 :internal:
76
Jani Nikula2fa91d12016-06-21 14:49:02 +030077.. kernel-doc:: drivers/gpu/drm/drm_fourcc.c
78 :export:
79
80Dumb Buffer Objects
Daniel Vetter311b62d2016-08-12 22:48:41 +020081===================
Jani Nikula2fa91d12016-06-21 14:49:02 +030082
Daniel Vetter4f936242016-11-14 12:58:21 +010083.. kernel-doc:: drivers/gpu/drm/drm_dumb_buffers.c
84 :doc: overview
Jani Nikula2fa91d12016-06-21 14:49:02 +030085
Daniel Vetter43968d72016-09-21 10:59:24 +020086Plane Abstraction
87=================
88
Daniel Vetter532b3672016-09-21 10:59:25 +020089.. kernel-doc:: drivers/gpu/drm/drm_plane.c
90 :doc: overview
91
Daniel Vetter43968d72016-09-21 10:59:24 +020092Plane Functions Reference
93-------------------------
94
95.. kernel-doc:: include/drm/drm_plane.h
96 :internal:
97
98.. kernel-doc:: drivers/gpu/drm/drm_plane.c
99 :export:
100
Daniel Vetter311b62d2016-08-12 22:48:41 +0200101Display Modes Function Reference
102================================
Jani Nikula2fa91d12016-06-21 14:49:02 +0300103
Daniel Vetter311b62d2016-08-12 22:48:41 +0200104.. kernel-doc:: include/drm/drm_modes.h
105 :internal:
106
107.. kernel-doc:: drivers/gpu/drm/drm_modes.c
108 :export:
Jani Nikula2fa91d12016-06-21 14:49:02 +0300109
Daniel Vetterae2a6da2016-08-12 22:48:53 +0200110Connector Abstraction
111=====================
112
113.. kernel-doc:: drivers/gpu/drm/drm_connector.c
114 :doc: overview
115
116Connector Functions Reference
117-----------------------------
Daniel Vetter52217192016-08-12 22:48:50 +0200118
119.. kernel-doc:: include/drm/drm_connector.h
120 :internal:
121
122.. kernel-doc:: drivers/gpu/drm/drm_connector.c
123 :export:
124
Daniel Vetter321a95a2016-08-29 10:27:49 +0200125Encoder Abstraction
126===================
127
Daniel Vettere03e6de2016-08-29 10:27:50 +0200128.. kernel-doc:: drivers/gpu/drm/drm_encoder.c
129 :doc: overview
130
131Encoder Functions Reference
132---------------------------
133
Daniel Vetter321a95a2016-08-29 10:27:49 +0200134.. kernel-doc:: include/drm/drm_encoder.h
135 :internal:
136
137.. kernel-doc:: drivers/gpu/drm/drm_encoder.c
138 :export:
139
Jani Nikula2fa91d12016-06-21 14:49:02 +0300140KMS Initialization and Cleanup
141==============================
142
143A KMS device is abstracted and exposed as a set of planes, CRTCs,
144encoders and connectors. KMS drivers must thus create and initialize all
145those objects at load time after initializing mode setting.
146
147CRTCs (:c:type:`struct drm_crtc <drm_crtc>`)
148--------------------------------------------
149
150A CRTC is an abstraction representing a part of the chip that contains a
151pointer to a scanout buffer. Therefore, the number of CRTCs available
152determines how many independent scanout buffers can be active at any
153given time. The CRTC structure contains several fields to support this:
154a pointer to some video memory (abstracted as a frame buffer object), a
155display mode, and an (x, y) offset into the video memory to support
156panning or configurations where one piece of video memory spans multiple
157CRTCs.
158
159CRTC Initialization
160~~~~~~~~~~~~~~~~~~~
161
162A KMS device must create and register at least one struct
163:c:type:`struct drm_crtc <drm_crtc>` instance. The instance is
164allocated and zeroed by the driver, possibly as part of a larger
165structure, and registered with a call to :c:func:`drm_crtc_init()`
166with a pointer to CRTC functions.
167
Jani Nikula2fa91d12016-06-21 14:49:02 +0300168
Jani Nikula2fa91d12016-06-21 14:49:02 +0300169Cleanup
170-------
171
172The DRM core manages its objects' lifetime. When an object is not needed
173anymore the core calls its destroy function, which must clean up and
174free every resource allocated for the object. Every
175:c:func:`drm_\*_init()` call must be matched with a corresponding
176:c:func:`drm_\*_cleanup()` call to cleanup CRTCs
177(:c:func:`drm_crtc_cleanup()`), planes
178(:c:func:`drm_plane_cleanup()`), encoders
179(:c:func:`drm_encoder_cleanup()`) and connectors
180(:c:func:`drm_connector_cleanup()`). Furthermore, connectors that
181have been added to sysfs must be removed by a call to
182:c:func:`drm_connector_unregister()` before calling
183:c:func:`drm_connector_cleanup()`.
184
185Connectors state change detection must be cleanup up with a call to
186:c:func:`drm_kms_helper_poll_fini()`.
187
188Output discovery and initialization example
189-------------------------------------------
190
191::
192
193 void intel_crt_init(struct drm_device *dev)
194 {
195 struct drm_connector *connector;
196 struct intel_output *intel_output;
197
198 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
199 if (!intel_output)
200 return;
201
202 connector = &intel_output->base;
203 drm_connector_init(dev, &intel_output->base,
204 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
205
206 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
207 DRM_MODE_ENCODER_DAC);
208
209 drm_mode_connector_attach_encoder(&intel_output->base,
210 &intel_output->enc);
211
212 /* Set up the DDC bus. */
213 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
214 if (!intel_output->ddc_bus) {
215 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
216 "failed.\n");
217 return;
218 }
219
220 intel_output->type = INTEL_OUTPUT_ANALOG;
221 connector->interlace_allowed = 0;
222 connector->doublescan_allowed = 0;
223
224 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
225 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
226
227 drm_connector_register(connector);
228 }
229
230In the example above (taken from the i915 driver), a CRTC, connector and
231encoder combination is created. A device-specific i2c bus is also
232created for fetching EDID data and performing monitor detection. Once
233the process is complete, the new connector is registered with sysfs to
234make its properties available to applications.
235
Jani Nikula2fa91d12016-06-21 14:49:02 +0300236KMS Locking
Daniel Vetter311b62d2016-08-12 22:48:41 +0200237===========
Jani Nikula2fa91d12016-06-21 14:49:02 +0300238
239.. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c
240 :doc: kms locking
241
242.. kernel-doc:: include/drm/drm_modeset_lock.h
243 :internal:
244
245.. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c
246 :export:
247
248KMS Properties
249==============
250
Daniel Vetter59e71ee2016-08-29 10:27:55 +0200251Property Types and Blob Property Support
252----------------------------------------
253
Daniel Vetterc8458c72016-08-29 10:27:57 +0200254.. kernel-doc:: drivers/gpu/drm/drm_property.c
255 :doc: overview
256
Daniel Vetter59e71ee2016-08-29 10:27:55 +0200257.. kernel-doc:: include/drm/drm_property.h
258 :internal:
259
260.. kernel-doc:: drivers/gpu/drm/drm_property.c
261 :export:
262
Daniel Vetter4ada6f22016-11-17 09:56:48 +0100263Standard Connector Properties
264-----------------------------
265
266.. kernel-doc:: drivers/gpu/drm/drm_connector.c
267 :doc: standard connector properties
268
Daniel Vetter1e4d84c2016-09-21 10:59:27 +0200269Plane Composition Properties
270----------------------------
271
272.. kernel-doc:: drivers/gpu/drm/drm_blend.c
273 :doc: overview
Daniel Vetter52a9fcd2016-08-12 22:48:51 +0200274
275.. kernel-doc:: drivers/gpu/drm/drm_blend.c
276 :export:
277
Daniel Vettera6acccf2016-09-21 10:59:29 +0200278Color Management Properties
279---------------------------
280
281.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c
282 :doc: overview
283
284.. kernel-doc:: include/drm/drm_color_mgmt.h
285 :internal:
286
287.. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c
288 :export:
289
Daniel Vetter9498c192016-11-14 12:58:24 +0100290Tile Group Property
291-------------------
292
293.. kernel-doc:: drivers/gpu/drm/drm_connector.c
294 :doc: Tile group
295
Jani Nikula2fa91d12016-06-21 14:49:02 +0300296Existing KMS Properties
297-----------------------
298
299The following table gives description of drm properties exposed by
300various modules/drivers.
301
302.. csv-table::
303 :header-rows: 1
304 :file: kms-properties.csv
305
306Vertical Blanking
307=================
308
309Vertical blanking plays a major role in graphics rendering. To achieve
310tear-free display, users must synchronize page flips and/or rendering to
311vertical blanking. The DRM API offers ioctls to perform page flips
312synchronized to vertical blanking and wait for vertical blanking.
313
314The DRM core handles most of the vertical blanking management logic,
315which involves filtering out spurious interrupts, keeping race-free
316blanking counters, coping with counter wrap-around and resets and
317keeping use counts. It relies on the driver to generate vertical
318blanking interrupts and optionally provide a hardware vertical blanking
319counter. Drivers must implement the following operations.
320
321- int (\*enable_vblank) (struct drm_device \*dev, int crtc); void
322 (\*disable_vblank) (struct drm_device \*dev, int crtc);
323 Enable or disable vertical blanking interrupts for the given CRTC.
324
325- u32 (\*get_vblank_counter) (struct drm_device \*dev, int crtc);
326 Retrieve the value of the vertical blanking counter for the given
327 CRTC. If the hardware maintains a vertical blanking counter its value
328 should be returned. Otherwise drivers can use the
329 :c:func:`drm_vblank_count()` helper function to handle this
330 operation.
331
332Drivers must initialize the vertical blanking handling core with a call
333to :c:func:`drm_vblank_init()` in their load operation.
334
335Vertical blanking interrupts can be enabled by the DRM core or by
336drivers themselves (for instance to handle page flipping operations).
337The DRM core maintains a vertical blanking use count to ensure that the
338interrupts are not disabled while a user still needs them. To increment
339the use count, drivers call :c:func:`drm_vblank_get()`. Upon
340return vertical blanking interrupts are guaranteed to be enabled.
341
342To decrement the use count drivers call
343:c:func:`drm_vblank_put()`. Only when the use count drops to zero
344will the DRM core disable the vertical blanking interrupts after a delay
345by scheduling a timer. The delay is accessible through the
346vblankoffdelay module parameter or the ``drm_vblank_offdelay`` global
347variable and expressed in milliseconds. Its default value is 5000 ms.
348Zero means never disable, and a negative value means disable
349immediately. Drivers may override the behaviour by setting the
350:c:type:`struct drm_device <drm_device>`
351vblank_disable_immediate flag, which when set causes vblank interrupts
352to be disabled immediately regardless of the drm_vblank_offdelay
353value. The flag should only be set if there's a properly working
354hardware vblank counter present.
355
356When a vertical blanking interrupt occurs drivers only need to call the
357:c:func:`drm_handle_vblank()` function to account for the
358interrupt.
359
360Resources allocated by :c:func:`drm_vblank_init()` must be freed
361with a call to :c:func:`drm_vblank_cleanup()` in the driver unload
362operation handler.
363
364Vertical Blanking and Interrupt Handling Functions Reference
365------------------------------------------------------------
366
367.. kernel-doc:: drivers/gpu/drm/drm_irq.c
368 :export:
369
Daniel Vetter34a67dd2016-07-15 21:48:01 +0200370.. kernel-doc:: include/drm/drm_irq.h
371 :internal: