@@ -410,102 +410,6 @@ Encoder Functions Reference
410
410
.. kernel-doc :: drivers/gpu/drm/drm_encoder.c
411
411
:export:
412
412
413
- KMS Initialization and Cleanup
414
- ==============================
415
-
416
- A KMS device is abstracted and exposed as a set of planes, CRTCs,
417
- encoders and connectors. KMS drivers must thus create and initialize all
418
- those objects at load time after initializing mode setting.
419
-
420
- CRTCs (:c:type: `struct drm_crtc <drm_crtc> `)
421
- --------------------------------------------
422
-
423
- A CRTC is an abstraction representing a part of the chip that contains a
424
- pointer to a scanout buffer. Therefore, the number of CRTCs available
425
- determines how many independent scanout buffers can be active at any
426
- given time. The CRTC structure contains several fields to support this:
427
- a pointer to some video memory (abstracted as a frame buffer object), a
428
- display mode, and an (x, y) offset into the video memory to support
429
- panning or configurations where one piece of video memory spans multiple
430
- CRTCs.
431
-
432
- CRTC Initialization
433
- ~~~~~~~~~~~~~~~~~~~
434
-
435
- A KMS device must create and register at least one struct
436
- :c:type: `struct drm_crtc <drm_crtc> ` instance. The instance is
437
- allocated and zeroed by the driver, possibly as part of a larger
438
- structure, and registered with a call to :c:func: `drm_crtc_init() `
439
- with a pointer to CRTC functions.
440
-
441
-
442
- Cleanup
443
- -------
444
-
445
- The DRM core manages its objects' lifetime. When an object is not needed
446
- anymore the core calls its destroy function, which must clean up and
447
- free every resource allocated for the object. Every
448
- :c:func: `drm_\* _init() ` call must be matched with a corresponding
449
- :c:func: `drm_\* _cleanup() ` call to cleanup CRTCs
450
- (:c:func: `drm_crtc_cleanup() `), planes
451
- (:c:func: `drm_plane_cleanup() `), encoders
452
- (:c:func: `drm_encoder_cleanup() `) and connectors
453
- (:c:func: `drm_connector_cleanup() `). Furthermore, connectors that
454
- have been added to sysfs must be removed by a call to
455
- :c:func: `drm_connector_unregister() ` before calling
456
- :c:func: `drm_connector_cleanup() `.
457
-
458
- Connectors state change detection must be cleanup up with a call to
459
- :c:func: `drm_kms_helper_poll_fini() `.
460
-
461
- Output discovery and initialization example
462
- -------------------------------------------
463
-
464
- .. code-block :: c
465
-
466
- void intel_crt_init(struct drm_device *dev)
467
- {
468
- struct drm_connector *connector;
469
- struct intel_output *intel_output;
470
-
471
- intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
472
- if (!intel_output)
473
- return;
474
-
475
- connector = &intel_output->base;
476
- drm_connector_init(dev, &intel_output->base,
477
- &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
478
-
479
- drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs,
480
- DRM_MODE_ENCODER_DAC);
481
-
482
- drm_connector_attach_encoder(&intel_output->base,
483
- &intel_output->enc);
484
-
485
- /* Set up the DDC bus. */
486
- intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
487
- if (!intel_output->ddc_bus) {
488
- dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
489
- "failed.\n");
490
- return;
491
- }
492
-
493
- intel_output->type = INTEL_OUTPUT_ANALOG;
494
- connector->interlace_allowed = 0;
495
- connector->doublescan_allowed = 0;
496
-
497
- drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs);
498
- drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
499
-
500
- drm_connector_register(connector);
501
- }
502
-
503
- In the example above (taken from the i915 driver), a CRTC, connector and
504
- encoder combination is created. A device-specific i2c bus is also
505
- created for fetching EDID data and performing monitor detection. Once
506
- the process is complete, the new connector is registered with sysfs to
507
- make its properties available to applications.
508
-
509
413
KMS Locking
510
414
===========
511
415
0 commit comments