1 ========================= 1 ========================= 2 Kernel Mode Setting (KMS) 2 Kernel Mode Setting (KMS) 3 ========================= 3 ========================= 4 4 5 Drivers must initialize the mode setting core 5 Drivers must initialize the mode setting core by calling 6 drmm_mode_config_init() on the DRM device. The !! 6 :c:func:`drm_mode_config_init()` on the DRM device. The function 7 initializes the :c:type:`struct drm_device <dr 7 initializes the :c:type:`struct drm_device <drm_device>` 8 mode_config field and never fails. Once done, 8 mode_config field and never fails. Once done, mode configuration must 9 be setup by initializing the following fields. 9 be setup by initializing the following fields. 10 10 11 - int min_width, min_height; int max_width, m 11 - int min_width, min_height; int max_width, max_height; 12 Minimum and maximum width and height of the 12 Minimum and maximum width and height of the frame buffers in pixel 13 units. 13 units. 14 14 15 - struct drm_mode_config_funcs \*funcs; 15 - struct drm_mode_config_funcs \*funcs; 16 Mode setting functions. 16 Mode setting functions. 17 17 18 Overview 18 Overview 19 ======== 19 ======== 20 20 21 .. kernel-render:: DOT 21 .. kernel-render:: DOT 22 :alt: KMS Display Pipeline 22 :alt: KMS Display Pipeline 23 :caption: KMS Display Pipeline Overview 23 :caption: KMS Display Pipeline Overview 24 24 25 digraph "KMS" { 25 digraph "KMS" { 26 node [shape=box] 26 node [shape=box] 27 27 28 subgraph cluster_static { 28 subgraph cluster_static { 29 style=dashed 29 style=dashed 30 label="Static Objects" 30 label="Static Objects" 31 31 32 node [bgcolor=grey style=filled] 32 node [bgcolor=grey style=filled] 33 "drm_plane A" -> "drm_crtc" 33 "drm_plane A" -> "drm_crtc" 34 "drm_plane B" -> "drm_crtc" 34 "drm_plane B" -> "drm_crtc" 35 "drm_crtc" -> "drm_encoder A" 35 "drm_crtc" -> "drm_encoder A" 36 "drm_crtc" -> "drm_encoder B" 36 "drm_crtc" -> "drm_encoder B" 37 } 37 } 38 38 39 subgraph cluster_user_created { 39 subgraph cluster_user_created { 40 style=dashed 40 style=dashed 41 label="Userspace-Created" 41 label="Userspace-Created" 42 42 43 node [shape=oval] 43 node [shape=oval] 44 "drm_framebuffer 1" -> "drm_plane A" 44 "drm_framebuffer 1" -> "drm_plane A" 45 "drm_framebuffer 2" -> "drm_plane B" 45 "drm_framebuffer 2" -> "drm_plane B" 46 } 46 } 47 47 48 subgraph cluster_connector { 48 subgraph cluster_connector { 49 style=dashed 49 style=dashed 50 label="Hotpluggable" 50 label="Hotpluggable" 51 51 52 "drm_encoder A" -> "drm_connector A" 52 "drm_encoder A" -> "drm_connector A" 53 "drm_encoder B" -> "drm_connector B" 53 "drm_encoder B" -> "drm_connector B" 54 } 54 } 55 } 55 } 56 56 57 The basic object structure KMS presents to use 57 The basic object structure KMS presents to userspace is fairly simple. 58 Framebuffers (represented by :c:type:`struct d 58 Framebuffers (represented by :c:type:`struct drm_framebuffer <drm_framebuffer>`, 59 see `Frame Buffer Abstraction`_) feed into pla !! 59 see `Frame Buffer Abstraction`_) feed into planes. One or more (or even no) 60 :c:type:`struct drm_plane <drm_plane>`, see `P !! 60 planes feed their pixel data into a CRTC (represented by :c:type:`struct 61 details. One or more (or even no) planes feed !! 61 drm_crtc <drm_crtc>`, see `CRTC Abstraction`_) for blending. The precise 62 (represented by :c:type:`struct drm_crtc <drm_ !! 62 blending step is explained in more detail in `Plane Composition Properties`_ and 63 for blending. The precise blending step is exp !! 63 related chapters. 64 Composition Properties`_ and related chapters. << 65 64 66 For the output routing the first step is encod 65 For the output routing the first step is encoders (represented by 67 :c:type:`struct drm_encoder <drm_encoder>`, se 66 :c:type:`struct drm_encoder <drm_encoder>`, see `Encoder Abstraction`_). Those 68 are really just internal artifacts of the help 67 are really just internal artifacts of the helper libraries used to implement KMS 69 drivers. Besides that they make it unnecessari !! 68 drivers. Besides that they make it unecessarily more complicated for userspace 70 to figure out which connections between a CRTC 69 to figure out which connections between a CRTC and a connector are possible, and 71 what kind of cloning is supported, they serve 70 what kind of cloning is supported, they serve no purpose in the userspace API. 72 Unfortunately encoders have been exposed to us 71 Unfortunately encoders have been exposed to userspace, hence can't remove them 73 at this point. Furthermore the exposed restri !! 72 at this point. Futhermore the exposed restrictions are often wrongly set by 74 drivers, and in many cases not powerful enough 73 drivers, and in many cases not powerful enough to express the real restrictions. 75 A CRTC can be connected to multiple encoders, 74 A CRTC can be connected to multiple encoders, and for an active CRTC there must 76 be at least one encoder. 75 be at least one encoder. 77 76 78 The final, and real, endpoint in the display c 77 The final, and real, endpoint in the display chain is the connector (represented 79 by :c:type:`struct drm_connector <drm_connecto 78 by :c:type:`struct drm_connector <drm_connector>`, see `Connector 80 Abstraction`_). Connectors can have different 79 Abstraction`_). Connectors can have different possible encoders, but the kernel 81 driver selects which encoder to use for each c 80 driver selects which encoder to use for each connector. The use case is DVI, 82 which could switch between an analog and a dig 81 which could switch between an analog and a digital encoder. Encoders can also 83 drive multiple different connectors. There is 82 drive multiple different connectors. There is exactly one active connector for 84 every active encoder. 83 every active encoder. 85 84 86 Internally the output pipeline is a bit more c 85 Internally the output pipeline is a bit more complex and matches today's 87 hardware more closely: 86 hardware more closely: 88 87 89 .. kernel-render:: DOT 88 .. kernel-render:: DOT 90 :alt: KMS Output Pipeline 89 :alt: KMS Output Pipeline 91 :caption: KMS Output Pipeline 90 :caption: KMS Output Pipeline 92 91 93 digraph "Output Pipeline" { 92 digraph "Output Pipeline" { 94 node [shape=box] 93 node [shape=box] 95 94 96 subgraph { 95 subgraph { 97 "drm_crtc" [bgcolor=grey style=fille 96 "drm_crtc" [bgcolor=grey style=filled] 98 } 97 } 99 98 100 subgraph cluster_internal { 99 subgraph cluster_internal { 101 style=dashed 100 style=dashed 102 label="Internal Pipeline" 101 label="Internal Pipeline" 103 { 102 { 104 node [bgcolor=grey style=filled] 103 node [bgcolor=grey style=filled] 105 "drm_encoder A"; 104 "drm_encoder A"; 106 "drm_encoder B"; 105 "drm_encoder B"; 107 "drm_encoder C"; 106 "drm_encoder C"; 108 } 107 } 109 108 110 { 109 { 111 node [bgcolor=grey style=filled] 110 node [bgcolor=grey style=filled] 112 "drm_encoder B" -> "drm_bridge B 111 "drm_encoder B" -> "drm_bridge B" 113 "drm_encoder C" -> "drm_bridge C 112 "drm_encoder C" -> "drm_bridge C1" 114 "drm_bridge C1" -> "drm_bridge C 113 "drm_bridge C1" -> "drm_bridge C2"; 115 } 114 } 116 } 115 } 117 116 118 "drm_crtc" -> "drm_encoder A" 117 "drm_crtc" -> "drm_encoder A" 119 "drm_crtc" -> "drm_encoder B" 118 "drm_crtc" -> "drm_encoder B" 120 "drm_crtc" -> "drm_encoder C" 119 "drm_crtc" -> "drm_encoder C" 121 120 122 121 123 subgraph cluster_output { 122 subgraph cluster_output { 124 style=dashed 123 style=dashed 125 label="Outputs" 124 label="Outputs" 126 125 127 "drm_encoder A" -> "drm_connector A" 126 "drm_encoder A" -> "drm_connector A"; 128 "drm_bridge B" -> "drm_connector B"; 127 "drm_bridge B" -> "drm_connector B"; 129 "drm_bridge C2" -> "drm_connector C" 128 "drm_bridge C2" -> "drm_connector C"; 130 129 131 "drm_panel" 130 "drm_panel" 132 } 131 } 133 } 132 } 134 133 135 Internally two additional helper objects come 134 Internally two additional helper objects come into play. First, to be able to 136 share code for encoders (sometimes on the same 135 share code for encoders (sometimes on the same SoC, sometimes off-chip) one or 137 more :ref:`drm_bridges` (represented by :c:typ 136 more :ref:`drm_bridges` (represented by :c:type:`struct drm_bridge 138 <drm_bridge>`) can be linked to an encoder. Th 137 <drm_bridge>`) can be linked to an encoder. This link is static and cannot be 139 changed, which means the cross-bar (if there i 138 changed, which means the cross-bar (if there is any) needs to be mapped between 140 the CRTC and any encoders. Often for drivers w 139 the CRTC and any encoders. Often for drivers with bridges there's no code left 141 at the encoder level. Atomic drivers can leave 140 at the encoder level. Atomic drivers can leave out all the encoder callbacks to 142 essentially only leave a dummy routing object 141 essentially only leave a dummy routing object behind, which is needed for 143 backwards compatibility since encoders are exp 142 backwards compatibility since encoders are exposed to userspace. 144 143 145 The second object is for panels, represented b 144 The second object is for panels, represented by :c:type:`struct drm_panel 146 <drm_panel>`, see :ref:`drm_panel_helper`. Pan 145 <drm_panel>`, see :ref:`drm_panel_helper`. Panels do not have a fixed binding 147 point, but are generally linked to the driver 146 point, but are generally linked to the driver private structure that embeds 148 :c:type:`struct drm_connector <drm_connector>` 147 :c:type:`struct drm_connector <drm_connector>`. 149 148 150 Note that currently the bridge chaining and in 149 Note that currently the bridge chaining and interactions with connectors and 151 panels are still in-flux and not really fully 150 panels are still in-flux and not really fully sorted out yet. 152 151 153 KMS Core Structures and Functions 152 KMS Core Structures and Functions 154 ================================= 153 ================================= 155 154 156 .. kernel-doc:: include/drm/drm_mode_config.h 155 .. kernel-doc:: include/drm/drm_mode_config.h 157 :internal: 156 :internal: 158 157 159 .. kernel-doc:: drivers/gpu/drm/drm_mode_confi 158 .. kernel-doc:: drivers/gpu/drm/drm_mode_config.c 160 :export: 159 :export: 161 160 162 .. _kms_base_object_abstraction: << 163 << 164 Modeset Base Object Abstraction 161 Modeset Base Object Abstraction 165 =============================== 162 =============================== 166 163 167 .. kernel-render:: DOT 164 .. kernel-render:: DOT 168 :alt: Mode Objects and Properties 165 :alt: Mode Objects and Properties 169 :caption: Mode Objects and Properties 166 :caption: Mode Objects and Properties 170 167 171 digraph { 168 digraph { 172 node [shape=box] 169 node [shape=box] 173 170 174 "drm_property A" -> "drm_mode_object A" 171 "drm_property A" -> "drm_mode_object A" 175 "drm_property A" -> "drm_mode_object B" 172 "drm_property A" -> "drm_mode_object B" 176 "drm_property B" -> "drm_mode_object A" 173 "drm_property B" -> "drm_mode_object A" 177 } 174 } 178 175 179 The base structure for all KMS objects is :c:t 176 The base structure for all KMS objects is :c:type:`struct drm_mode_object 180 <drm_mode_object>`. One of the base services i 177 <drm_mode_object>`. One of the base services it provides is tracking properties, 181 which are especially important for the atomic 178 which are especially important for the atomic IOCTL (see `Atomic Mode 182 Setting`_). The somewhat surprising part here 179 Setting`_). The somewhat surprising part here is that properties are not 183 directly instantiated on each object, but free 180 directly instantiated on each object, but free-standing mode objects themselves, 184 represented by :c:type:`struct drm_property <d 181 represented by :c:type:`struct drm_property <drm_property>`, which only specify 185 the type and value range of a property. Any gi 182 the type and value range of a property. Any given property can be attached 186 multiple times to different objects using drm_ !! 183 multiple times to different objects using :c:func:`drm_object_attach_property() >> 184 <drm_object_attach_property>`. 187 185 188 .. kernel-doc:: include/drm/drm_mode_object.h 186 .. kernel-doc:: include/drm/drm_mode_object.h 189 :internal: 187 :internal: 190 188 191 .. kernel-doc:: drivers/gpu/drm/drm_mode_objec 189 .. kernel-doc:: drivers/gpu/drm/drm_mode_object.c 192 :export: 190 :export: 193 191 194 Atomic Mode Setting 192 Atomic Mode Setting 195 =================== 193 =================== 196 194 197 195 198 .. kernel-render:: DOT 196 .. kernel-render:: DOT 199 :alt: Mode Objects and Properties 197 :alt: Mode Objects and Properties 200 :caption: Mode Objects and Properties 198 :caption: Mode Objects and Properties 201 199 202 digraph { 200 digraph { 203 node [shape=box] 201 node [shape=box] 204 202 205 subgraph cluster_state { 203 subgraph cluster_state { 206 style=dashed 204 style=dashed 207 label="Free-standing state" 205 label="Free-standing state" 208 206 209 "drm_atomic_state" -> "duplicated dr 207 "drm_atomic_state" -> "duplicated drm_plane_state A" 210 "drm_atomic_state" -> "duplicated dr 208 "drm_atomic_state" -> "duplicated drm_plane_state B" 211 "drm_atomic_state" -> "duplicated dr 209 "drm_atomic_state" -> "duplicated drm_crtc_state" 212 "drm_atomic_state" -> "duplicated dr 210 "drm_atomic_state" -> "duplicated drm_connector_state" 213 "drm_atomic_state" -> "duplicated dr 211 "drm_atomic_state" -> "duplicated driver private state" 214 } 212 } 215 213 216 subgraph cluster_current { 214 subgraph cluster_current { 217 style=dashed 215 style=dashed 218 label="Current state" 216 label="Current state" 219 217 220 "drm_device" -> "drm_plane A" 218 "drm_device" -> "drm_plane A" 221 "drm_device" -> "drm_plane B" 219 "drm_device" -> "drm_plane B" 222 "drm_device" -> "drm_crtc" 220 "drm_device" -> "drm_crtc" 223 "drm_device" -> "drm_connector" 221 "drm_device" -> "drm_connector" 224 "drm_device" -> "driver private obje 222 "drm_device" -> "driver private object" 225 223 226 "drm_plane A" -> "drm_plane_state A" 224 "drm_plane A" -> "drm_plane_state A" 227 "drm_plane B" -> "drm_plane_state B" 225 "drm_plane B" -> "drm_plane_state B" 228 "drm_crtc" -> "drm_crtc_state" 226 "drm_crtc" -> "drm_crtc_state" 229 "drm_connector" -> "drm_connector_st 227 "drm_connector" -> "drm_connector_state" 230 "driver private object" -> "driver p 228 "driver private object" -> "driver private state" 231 } 229 } 232 230 233 "drm_atomic_state" -> "drm_device" [labe 231 "drm_atomic_state" -> "drm_device" [label="atomic_commit"] 234 "duplicated drm_plane_state A" -> "drm_d 232 "duplicated drm_plane_state A" -> "drm_device"[style=invis] 235 } 233 } 236 234 237 Atomic provides transactional modeset (includi 235 Atomic provides transactional modeset (including planes) updates, but a 238 bit differently from the usual transactional a 236 bit differently from the usual transactional approach of try-commit and 239 rollback: 237 rollback: 240 238 241 - Firstly, no hardware changes are allowed whe 239 - Firstly, no hardware changes are allowed when the commit would fail. This 242 allows us to implement the DRM_MODE_ATOMIC_T 240 allows us to implement the DRM_MODE_ATOMIC_TEST_ONLY mode, which allows 243 userspace to explore whether certain configu 241 userspace to explore whether certain configurations would work or not. 244 242 245 - This would still allow setting and rollback 243 - This would still allow setting and rollback of just the software state, 246 simplifying conversion of existing drivers. 244 simplifying conversion of existing drivers. But auditing drivers for 247 correctness of the atomic_check code becomes 245 correctness of the atomic_check code becomes really hard with that: Rolling 248 back changes in data structures all over the 246 back changes in data structures all over the place is hard to get right. 249 247 250 - Lastly, for backwards compatibility and to s 248 - Lastly, for backwards compatibility and to support all use-cases, atomic 251 updates need to be incremental and be able t 249 updates need to be incremental and be able to execute in parallel. Hardware 252 doesn't always allow it, but where possible 250 doesn't always allow it, but where possible plane updates on different CRTCs 253 should not interfere, and not get stalled du 251 should not interfere, and not get stalled due to output routing changing on 254 different CRTCs. 252 different CRTCs. 255 253 256 Taken all together there's two consequences fo 254 Taken all together there's two consequences for the atomic design: 257 255 258 - The overall state is split up into per-objec 256 - The overall state is split up into per-object state structures: 259 :c:type:`struct drm_plane_state <drm_plane_s 257 :c:type:`struct drm_plane_state <drm_plane_state>` for planes, :c:type:`struct 260 drm_crtc_state <drm_crtc_state>` for CRTCs a 258 drm_crtc_state <drm_crtc_state>` for CRTCs and :c:type:`struct 261 drm_connector_state <drm_connector_state>` f 259 drm_connector_state <drm_connector_state>` for connectors. These are the only 262 objects with userspace-visible and settable 260 objects with userspace-visible and settable state. For internal state drivers 263 can subclass these structures through embedd !! 261 can subclass these structures through embeddeding, or add entirely new state 264 structures for their globally shared hardwar !! 262 structures for their globally shared hardware functions. 265 drm_private_state<drm_private_state>`. << 266 263 267 - An atomic update is assembled and validated 264 - An atomic update is assembled and validated as an entirely free-standing pile 268 of structures within the :c:type:`drm_atomic 265 of structures within the :c:type:`drm_atomic_state <drm_atomic_state>` 269 container. Driver private state structures a 266 container. Driver private state structures are also tracked in the same 270 structure; see the next chapter. Only when 267 structure; see the next chapter. Only when a state is committed is it applied 271 to the driver and modeset objects. This way 268 to the driver and modeset objects. This way rolling back an update boils down 272 to releasing memory and unreferencing object 269 to releasing memory and unreferencing objects like framebuffers. 273 270 274 Locking of atomic state structures is internal << 275 drm_modeset_lock <drm_modeset_lock>`. As a gen << 276 exposed to drivers, instead the right locks sh << 277 any function that duplicates or peeks into a s << 278 drm_atomic_get_crtc_state(). Locking only pro << 279 structure, ordering of committing state change << 280 :c:type:`struct drm_crtc_commit <drm_crtc_comm << 281 << 282 Read on in this chapter, and also in :ref:`drm 271 Read on in this chapter, and also in :ref:`drm_atomic_helper` for more detailed 283 coverage of specific topics. 272 coverage of specific topics. 284 273 285 Handling Driver Private State 274 Handling Driver Private State 286 ----------------------------- 275 ----------------------------- 287 276 288 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 277 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 289 :doc: handling driver private state 278 :doc: handling driver private state 290 279 291 Atomic Mode Setting Function Reference 280 Atomic Mode Setting Function Reference 292 -------------------------------------- 281 -------------------------------------- 293 282 294 .. kernel-doc:: include/drm/drm_atomic.h 283 .. kernel-doc:: include/drm/drm_atomic.h 295 :internal: 284 :internal: 296 285 297 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 286 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 298 :export: 287 :export: 299 288 300 Atomic Mode Setting IOCTL and UAPI Functions !! 289 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 301 -------------------------------------------- !! 290 :internal: 302 << 303 .. kernel-doc:: drivers/gpu/drm/drm_atomic_uap << 304 :doc: overview << 305 << 306 .. kernel-doc:: drivers/gpu/drm/drm_atomic_uap << 307 :export: << 308 291 309 CRTC Abstraction 292 CRTC Abstraction 310 ================ 293 ================ 311 294 312 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 295 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 313 :doc: overview 296 :doc: overview 314 297 315 CRTC Functions Reference 298 CRTC Functions Reference 316 -------------------------------- 299 -------------------------------- 317 300 318 .. kernel-doc:: include/drm/drm_crtc.h 301 .. kernel-doc:: include/drm/drm_crtc.h 319 :internal: 302 :internal: 320 303 321 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 304 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 322 :export: 305 :export: 323 306 324 Color Management Functions Reference << 325 ------------------------------------ << 326 << 327 .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt << 328 :export: << 329 << 330 .. kernel-doc:: include/drm/drm_color_mgmt.h << 331 :internal: << 332 << 333 Frame Buffer Abstraction 307 Frame Buffer Abstraction 334 ======================== 308 ======================== 335 309 336 .. kernel-doc:: drivers/gpu/drm/drm_framebuffe 310 .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 337 :doc: overview 311 :doc: overview 338 312 339 Frame Buffer Functions Reference 313 Frame Buffer Functions Reference 340 -------------------------------- 314 -------------------------------- 341 315 342 .. kernel-doc:: include/drm/drm_framebuffer.h 316 .. kernel-doc:: include/drm/drm_framebuffer.h 343 :internal: 317 :internal: 344 318 345 .. kernel-doc:: drivers/gpu/drm/drm_framebuffe 319 .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 346 :export: 320 :export: 347 321 348 DRM Format Handling 322 DRM Format Handling 349 =================== 323 =================== 350 324 351 .. kernel-doc:: include/uapi/drm/drm_fourcc.h << 352 :doc: overview << 353 << 354 Format Functions Reference << 355 -------------------------- << 356 << 357 .. kernel-doc:: include/drm/drm_fourcc.h 325 .. kernel-doc:: include/drm/drm_fourcc.h 358 :internal: 326 :internal: 359 327 360 .. kernel-doc:: drivers/gpu/drm/drm_fourcc.c 328 .. kernel-doc:: drivers/gpu/drm/drm_fourcc.c 361 :export: 329 :export: 362 330 363 .. _kms_dumb_buffer_objects: << 364 << 365 Dumb Buffer Objects 331 Dumb Buffer Objects 366 =================== 332 =================== 367 333 368 .. kernel-doc:: drivers/gpu/drm/drm_dumb_buffe 334 .. kernel-doc:: drivers/gpu/drm/drm_dumb_buffers.c 369 :doc: overview 335 :doc: overview 370 336 371 Plane Abstraction 337 Plane Abstraction 372 ================= 338 ================= 373 339 374 .. kernel-doc:: drivers/gpu/drm/drm_plane.c 340 .. kernel-doc:: drivers/gpu/drm/drm_plane.c 375 :doc: overview 341 :doc: overview 376 342 377 Plane Functions Reference 343 Plane Functions Reference 378 ------------------------- 344 ------------------------- 379 345 380 .. kernel-doc:: include/drm/drm_plane.h 346 .. kernel-doc:: include/drm/drm_plane.h 381 :internal: 347 :internal: 382 348 383 .. kernel-doc:: drivers/gpu/drm/drm_plane.c 349 .. kernel-doc:: drivers/gpu/drm/drm_plane.c 384 :export: 350 :export: 385 351 386 Plane Composition Functions Reference << 387 ------------------------------------- << 388 << 389 .. kernel-doc:: drivers/gpu/drm/drm_blend.c << 390 :export: << 391 << 392 Plane Damage Tracking Functions Reference << 393 ----------------------------------------- << 394 << 395 .. kernel-doc:: drivers/gpu/drm/drm_damage_hel << 396 :export: << 397 << 398 .. kernel-doc:: include/drm/drm_damage_helper. << 399 :internal: << 400 << 401 Plane Panic Feature << 402 ------------------- << 403 << 404 .. kernel-doc:: drivers/gpu/drm/drm_panic.c << 405 :doc: overview << 406 << 407 Plane Panic Functions Reference << 408 ------------------------------- << 409 << 410 .. kernel-doc:: include/drm/drm_panic.h << 411 :internal: << 412 << 413 .. kernel-doc:: drivers/gpu/drm/drm_panic.c << 414 :export: << 415 << 416 Display Modes Function Reference 352 Display Modes Function Reference 417 ================================ 353 ================================ 418 354 419 .. kernel-doc:: include/drm/drm_modes.h 355 .. kernel-doc:: include/drm/drm_modes.h 420 :internal: 356 :internal: 421 357 422 .. kernel-doc:: drivers/gpu/drm/drm_modes.c 358 .. kernel-doc:: drivers/gpu/drm/drm_modes.c 423 :export: 359 :export: 424 360 425 Connector Abstraction 361 Connector Abstraction 426 ===================== 362 ===================== 427 363 428 .. kernel-doc:: drivers/gpu/drm/drm_connector. 364 .. kernel-doc:: drivers/gpu/drm/drm_connector.c 429 :doc: overview 365 :doc: overview 430 366 431 Connector Functions Reference 367 Connector Functions Reference 432 ----------------------------- 368 ----------------------------- 433 369 434 .. kernel-doc:: include/drm/drm_connector.h 370 .. kernel-doc:: include/drm/drm_connector.h 435 :internal: 371 :internal: 436 372 437 .. kernel-doc:: drivers/gpu/drm/drm_connector. 373 .. kernel-doc:: drivers/gpu/drm/drm_connector.c 438 :export: 374 :export: 439 375 440 Writeback Connectors << 441 -------------------- << 442 << 443 .. kernel-doc:: drivers/gpu/drm/drm_writeback. << 444 :doc: overview << 445 << 446 .. kernel-doc:: include/drm/drm_writeback.h << 447 :internal: << 448 << 449 .. kernel-doc:: drivers/gpu/drm/drm_writeback. << 450 :export: << 451 << 452 Encoder Abstraction 376 Encoder Abstraction 453 =================== 377 =================== 454 378 455 .. kernel-doc:: drivers/gpu/drm/drm_encoder.c 379 .. kernel-doc:: drivers/gpu/drm/drm_encoder.c 456 :doc: overview 380 :doc: overview 457 381 458 Encoder Functions Reference 382 Encoder Functions Reference 459 --------------------------- 383 --------------------------- 460 384 461 .. kernel-doc:: include/drm/drm_encoder.h 385 .. kernel-doc:: include/drm/drm_encoder.h 462 :internal: 386 :internal: 463 387 464 .. kernel-doc:: drivers/gpu/drm/drm_encoder.c 388 .. kernel-doc:: drivers/gpu/drm/drm_encoder.c 465 :export: 389 :export: 466 390 >> 391 KMS Initialization and Cleanup >> 392 ============================== >> 393 >> 394 A KMS device is abstracted and exposed as a set of planes, CRTCs, >> 395 encoders and connectors. KMS drivers must thus create and initialize all >> 396 those objects at load time after initializing mode setting. >> 397 >> 398 CRTCs (:c:type:`struct drm_crtc <drm_crtc>`) >> 399 -------------------------------------------- >> 400 >> 401 A CRTC is an abstraction representing a part of the chip that contains a >> 402 pointer to a scanout buffer. Therefore, the number of CRTCs available >> 403 determines how many independent scanout buffers can be active at any >> 404 given time. The CRTC structure contains several fields to support this: >> 405 a pointer to some video memory (abstracted as a frame buffer object), a >> 406 display mode, and an (x, y) offset into the video memory to support >> 407 panning or configurations where one piece of video memory spans multiple >> 408 CRTCs. >> 409 >> 410 CRTC Initialization >> 411 ~~~~~~~~~~~~~~~~~~~ >> 412 >> 413 A KMS device must create and register at least one struct >> 414 :c:type:`struct drm_crtc <drm_crtc>` instance. The instance is >> 415 allocated and zeroed by the driver, possibly as part of a larger >> 416 structure, and registered with a call to :c:func:`drm_crtc_init()` >> 417 with a pointer to CRTC functions. >> 418 >> 419 >> 420 Cleanup >> 421 ------- >> 422 >> 423 The DRM core manages its objects' lifetime. When an object is not needed >> 424 anymore the core calls its destroy function, which must clean up and >> 425 free every resource allocated for the object. Every >> 426 :c:func:`drm_\*_init()` call must be matched with a corresponding >> 427 :c:func:`drm_\*_cleanup()` call to cleanup CRTCs >> 428 (:c:func:`drm_crtc_cleanup()`), planes >> 429 (:c:func:`drm_plane_cleanup()`), encoders >> 430 (:c:func:`drm_encoder_cleanup()`) and connectors >> 431 (:c:func:`drm_connector_cleanup()`). Furthermore, connectors that >> 432 have been added to sysfs must be removed by a call to >> 433 :c:func:`drm_connector_unregister()` before calling >> 434 :c:func:`drm_connector_cleanup()`. >> 435 >> 436 Connectors state change detection must be cleanup up with a call to >> 437 :c:func:`drm_kms_helper_poll_fini()`. >> 438 >> 439 Output discovery and initialization example >> 440 ------------------------------------------- >> 441 >> 442 .. code-block:: c >> 443 >> 444 void intel_crt_init(struct drm_device *dev) >> 445 { >> 446 struct drm_connector *connector; >> 447 struct intel_output *intel_output; >> 448 >> 449 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); >> 450 if (!intel_output) >> 451 return; >> 452 >> 453 connector = &intel_output->base; >> 454 drm_connector_init(dev, &intel_output->base, >> 455 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); >> 456 >> 457 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, >> 458 DRM_MODE_ENCODER_DAC); >> 459 >> 460 drm_mode_connector_attach_encoder(&intel_output->base, >> 461 &intel_output->enc); >> 462 >> 463 /* Set up the DDC bus. */ >> 464 intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); >> 465 if (!intel_output->ddc_bus) { >> 466 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " >> 467 "failed.\n"); >> 468 return; >> 469 } >> 470 >> 471 intel_output->type = INTEL_OUTPUT_ANALOG; >> 472 connector->interlace_allowed = 0; >> 473 connector->doublescan_allowed = 0; >> 474 >> 475 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); >> 476 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); >> 477 >> 478 drm_connector_register(connector); >> 479 } >> 480 >> 481 In the example above (taken from the i915 driver), a CRTC, connector and >> 482 encoder combination is created. A device-specific i2c bus is also >> 483 created for fetching EDID data and performing monitor detection. Once >> 484 the process is complete, the new connector is registered with sysfs to >> 485 make its properties available to applications. >> 486 467 KMS Locking 487 KMS Locking 468 =========== 488 =========== 469 489 470 .. kernel-doc:: drivers/gpu/drm/drm_modeset_lo 490 .. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c 471 :doc: kms locking 491 :doc: kms locking 472 492 473 .. kernel-doc:: include/drm/drm_modeset_lock.h 493 .. kernel-doc:: include/drm/drm_modeset_lock.h 474 :internal: 494 :internal: 475 495 476 .. kernel-doc:: drivers/gpu/drm/drm_modeset_lo 496 .. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c 477 :export: 497 :export: 478 498 479 KMS Properties 499 KMS Properties 480 ============== 500 ============== 481 501 482 This section of the documentation is primarily << 483 For the driver APIs, see the other sections. << 484 << 485 Requirements << 486 ------------ << 487 << 488 KMS drivers might need to add extra properties << 489 new property introduced in a driver needs to m << 490 addition to the one mentioned above: << 491 << 492 * It must be standardized, documenting: << 493 << 494 * The full, exact, name string; << 495 * If the property is an enum, all the valid << 496 * What values are accepted, and what these v << 497 * What the property does and how it can be u << 498 * How the property might interact with other << 499 << 500 * It must provide a generic helper in the core << 501 property on the object it attaches to. << 502 << 503 * Its content must be decoded by the core and << 504 associated state structure. That includes an << 505 to precompute, like struct drm_clip_rect for << 506 << 507 * Its initial state must match the behavior pr << 508 introduction. This might be a fixed value ma << 509 does, or it may be inherited from the state << 510 system in during boot. << 511 << 512 * An IGT test must be submitted where reasonab << 513 << 514 For historical reasons, non-standard, driver-s << 515 driver wants to add support for one of those p << 516 new properties apply where possible. Additiona << 517 match the de facto semantics of the existing p << 518 Developers of the driver that first added the << 519 tasks and must ACK the documented behavior if << 520 << 521 Property Types and Blob Property Support 502 Property Types and Blob Property Support 522 ---------------------------------------- 503 ---------------------------------------- 523 504 524 .. kernel-doc:: drivers/gpu/drm/drm_property.c 505 .. kernel-doc:: drivers/gpu/drm/drm_property.c 525 :doc: overview 506 :doc: overview 526 507 527 .. kernel-doc:: include/drm/drm_property.h 508 .. kernel-doc:: include/drm/drm_property.h 528 :internal: 509 :internal: 529 510 530 .. kernel-doc:: drivers/gpu/drm/drm_property.c 511 .. kernel-doc:: drivers/gpu/drm/drm_property.c 531 :export: 512 :export: 532 513 533 .. _standard_connector_properties: << 534 << 535 Standard Connector Properties 514 Standard Connector Properties 536 ----------------------------- 515 ----------------------------- 537 516 538 .. kernel-doc:: drivers/gpu/drm/drm_connector. 517 .. kernel-doc:: drivers/gpu/drm/drm_connector.c 539 :doc: standard connector properties 518 :doc: standard connector properties 540 519 541 HDMI Specific Connector Properties << 542 ---------------------------------- << 543 << 544 .. kernel-doc:: drivers/gpu/drm/drm_connector. << 545 :doc: HDMI connector properties << 546 << 547 Analog TV Specific Connector Properties << 548 --------------------------------------- << 549 << 550 .. kernel-doc:: drivers/gpu/drm/drm_connector. << 551 :doc: Analog TV Connector Properties << 552 << 553 Standard CRTC Properties << 554 ------------------------ << 555 << 556 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c << 557 :doc: standard CRTC properties << 558 << 559 Standard Plane Properties << 560 ------------------------- << 561 << 562 .. kernel-doc:: drivers/gpu/drm/drm_plane.c << 563 :doc: standard plane properties << 564 << 565 .. _plane_composition_properties: << 566 << 567 Plane Composition Properties 520 Plane Composition Properties 568 ---------------------------- 521 ---------------------------- 569 522 570 .. kernel-doc:: drivers/gpu/drm/drm_blend.c 523 .. kernel-doc:: drivers/gpu/drm/drm_blend.c 571 :doc: overview 524 :doc: overview 572 525 573 .. _damage_tracking_properties: !! 526 .. kernel-doc:: drivers/gpu/drm/drm_blend.c 574 !! 527 :export: 575 Damage Tracking Properties << 576 -------------------------- << 577 << 578 .. kernel-doc:: drivers/gpu/drm/drm_plane.c << 579 :doc: damage tracking << 580 528 581 Color Management Properties 529 Color Management Properties 582 --------------------------- 530 --------------------------- 583 531 584 .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt 532 .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c 585 :doc: overview 533 :doc: overview 586 534 >> 535 .. kernel-doc:: drivers/gpu/drm/drm_color_mgmt.c >> 536 :export: >> 537 587 Tile Group Property 538 Tile Group Property 588 ------------------- 539 ------------------- 589 540 590 .. kernel-doc:: drivers/gpu/drm/drm_connector. 541 .. kernel-doc:: drivers/gpu/drm/drm_connector.c 591 :doc: Tile group 542 :doc: Tile group 592 543 593 Explicit Fencing Properties 544 Explicit Fencing Properties 594 --------------------------- 545 --------------------------- 595 546 596 .. kernel-doc:: drivers/gpu/drm/drm_atomic_uap !! 547 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 597 :doc: explicit fencing properties 548 :doc: explicit fencing properties 598 549 599 << 600 Variable Refresh Properties << 601 --------------------------- << 602 << 603 .. kernel-doc:: drivers/gpu/drm/drm_connector. << 604 :doc: Variable refresh properties << 605 << 606 Cursor Hotspot Properties << 607 --------------------------- << 608 << 609 .. kernel-doc:: drivers/gpu/drm/drm_plane.c << 610 :doc: hotspot properties << 611 << 612 Existing KMS Properties 550 Existing KMS Properties 613 ----------------------- 551 ----------------------- 614 552 615 The following table gives description of drm p 553 The following table gives description of drm properties exposed by various 616 modules/drivers. Because this table is very un 554 modules/drivers. Because this table is very unwieldy, do not add any new 617 properties here. Instead document them in a se 555 properties here. Instead document them in a section above. 618 556 619 .. csv-table:: 557 .. csv-table:: 620 :header-rows: 1 558 :header-rows: 1 621 :file: kms-properties.csv 559 :file: kms-properties.csv 622 560 623 Vertical Blanking 561 Vertical Blanking 624 ================= 562 ================= 625 563 626 .. kernel-doc:: drivers/gpu/drm/drm_vblank.c 564 .. kernel-doc:: drivers/gpu/drm/drm_vblank.c 627 :doc: vblank handling 565 :doc: vblank handling 628 566 629 Vertical Blanking and Interrupt Handling Funct 567 Vertical Blanking and Interrupt Handling Functions Reference 630 ---------------------------------------------- 568 ------------------------------------------------------------ 631 569 632 .. kernel-doc:: include/drm/drm_vblank.h 570 .. kernel-doc:: include/drm/drm_vblank.h 633 :internal: 571 :internal: 634 572 635 .. kernel-doc:: drivers/gpu/drm/drm_vblank.c 573 .. kernel-doc:: drivers/gpu/drm/drm_vblank.c 636 :export: << 637 << 638 Vertical Blank Work << 639 =================== << 640 << 641 .. kernel-doc:: drivers/gpu/drm/drm_vblank_wor << 642 :doc: vblank works << 643 << 644 Vertical Blank Work Functions Reference << 645 --------------------------------------- << 646 << 647 .. kernel-doc:: include/drm/drm_vblank_work.h << 648 :internal: << 649 << 650 .. kernel-doc:: drivers/gpu/drm/drm_vblank_wor << 651 :export: 574 :export:
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.