display-manager.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ======================
  2. AMDgpu Display Manager
  3. ======================
  4. .. contents:: Table of Contents
  5. :depth: 3
  6. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  7. :doc: overview
  8. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
  9. :internal:
  10. Lifecycle
  11. =========
  12. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  13. :doc: DM Lifecycle
  14. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  15. :functions: dm_hw_init dm_hw_fini
  16. Interrupts
  17. ==========
  18. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
  19. :doc: overview
  20. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
  21. :internal:
  22. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  23. :functions: register_hpd_handlers dm_crtc_high_irq dm_pflip_high_irq
  24. Atomic Implementation
  25. =====================
  26. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  27. :doc: atomic
  28. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
  29. :functions: amdgpu_dm_atomic_check amdgpu_dm_atomic_commit_tail
  30. Color Management Properties
  31. ===========================
  32. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
  33. :doc: overview
  34. .. kernel-doc:: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
  35. :internal:
  36. DC Color Capabilities between DCN generations
  37. ---------------------------------------------
  38. DRM/KMS framework defines three CRTC color correction properties: degamma,
  39. color transformation matrix (CTM) and gamma, and two properties for degamma and
  40. gamma LUT sizes. AMD DC programs some of the color correction features
  41. pre-blending but DRM/KMS has not per-plane color correction properties.
  42. In general, the DRM CRTC color properties are programmed to DC, as follows:
  43. CRTC gamma after blending, and CRTC degamma pre-blending. Although CTM is
  44. programmed after blending, it is mapped to DPP hw blocks (pre-blending). Other
  45. color caps available in the hw is not currently exposed by DRM interface and
  46. are bypassed.
  47. .. kernel-doc:: drivers/gpu/drm/amd/display/dc/dc.h
  48. :doc: color-management-caps
  49. .. kernel-doc:: drivers/gpu/drm/amd/display/dc/dc.h
  50. :internal:
  51. The color pipeline has undergone major changes between DCN hardware
  52. generations. What's possible to do before and after blending depends on
  53. hardware capabilities, as illustrated below by the DCN 2.0 and DCN 3.0 families
  54. schemas.
  55. **DCN 2.0 family color caps and mapping**
  56. .. kernel-figure:: dcn2_cm_drm_current.svg
  57. **DCN 3.0 family color caps and mapping**
  58. .. kernel-figure:: dcn3_cm_drm_current.svg
  59. Blend Mode Properties
  60. =====================
  61. Pixel blend mode is a DRM plane composition property of :c:type:`drm_plane` used to
  62. describes how pixels from a foreground plane (fg) are composited with the
  63. background plane (bg). Here, we present main concepts of DRM blend mode to help
  64. to understand how this property is mapped to AMD DC interface. See more about
  65. this DRM property and the alpha blending equations in :ref:`DRM Plane
  66. Composition Properties <plane_composition_properties>`.
  67. Basically, a blend mode sets the alpha blending equation for plane
  68. composition that fits the mode in which the alpha channel affects the state of
  69. pixel color values and, therefore, the resulted pixel color. For
  70. example, consider the following elements of the alpha blending equation:
  71. - *fg.rgb*: Each of the RGB component values from the foreground's pixel.
  72. - *fg.alpha*: Alpha component value from the foreground's pixel.
  73. - *bg.rgb*: Each of the RGB component values from the background.
  74. - *plane_alpha*: Plane alpha value set by the **plane "alpha" property**, see
  75. more in :ref:`DRM Plane Composition Properties <plane_composition_properties>`.
  76. in the basic alpha blending equation::
  77. out.rgb = alpha * fg.rgb + (1 - alpha) * bg.rgb
  78. the alpha channel value of each pixel in a plane is ignored and only the plane
  79. alpha affects the resulted pixel color values.
  80. DRM has three blend mode to define the blend formula in the plane composition:
  81. * **None**: Blend formula that ignores the pixel alpha.
  82. * **Pre-multiplied**: Blend formula that assumes the pixel color values in a
  83. plane was already pre-multiplied by its own alpha channel before storage.
  84. * **Coverage**: Blend formula that assumes the pixel color values were not
  85. pre-multiplied with the alpha channel values.
  86. and pre-multiplied is the default pixel blend mode, that means, when no blend
  87. mode property is created or defined, DRM considers the plane's pixels has
  88. pre-multiplied color values. On IGT GPU tools, the kms_plane_alpha_blend test
  89. provides a set of subtests to verify plane alpha and blend mode properties.
  90. The DRM blend mode and its elements are then mapped by AMDGPU display manager
  91. (DM) to program the blending configuration of the Multiple Pipe/Plane Combined
  92. (MPC), as follows:
  93. .. kernel-doc:: drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
  94. :doc: mpc-overview
  95. .. kernel-doc:: drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
  96. :functions: mpcc_blnd_cfg
  97. Therefore, the blending configuration for a single MPCC instance on the MPC
  98. tree is defined by :c:type:`mpcc_blnd_cfg`, where
  99. :c:type:`pre_multiplied_alpha` is the alpha pre-multiplied mode flag used to
  100. set :c:type:`MPCC_ALPHA_MULTIPLIED_MODE`. It controls whether alpha is
  101. multiplied (true/false), being only true for DRM pre-multiplied blend mode.
  102. :c:type:`mpcc_alpha_blend_mode` defines the alpha blend mode regarding pixel
  103. alpha and plane alpha values. It sets one of the three modes for
  104. :c:type:`MPCC_ALPHA_BLND_MODE`, as described below.
  105. .. kernel-doc:: drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h
  106. :functions: mpcc_alpha_blend_mode
  107. DM then maps the elements of `enum mpcc_alpha_blend_mode` to those in the DRM
  108. blend formula, as follows:
  109. * *MPC pixel alpha* matches *DRM fg.alpha* as the alpha component value
  110. from the plane's pixel
  111. * *MPC global alpha* matches *DRM plane_alpha* when the pixel alpha should
  112. be ignored and, therefore, pixel values are not pre-multiplied
  113. * *MPC global gain* assumes *MPC global alpha* value when both *DRM
  114. fg.alpha* and *DRM plane_alpha* participate in the blend equation
  115. In short, *fg.alpha* is ignored by selecting
  116. :c:type:`MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA`. On the other hand, (plane_alpha *
  117. fg.alpha) component becomes available by selecting
  118. :c:type:`MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN`. And the
  119. :c:type:`MPCC_ALPHA_MULTIPLIED_MODE` defines if the pixel color values are
  120. pre-multiplied by alpha or not.
  121. Blend configuration flow
  122. ------------------------
  123. The alpha blending equation is configured from DRM to DC interface by the
  124. following path:
  125. 1. When updating a :c:type:`drm_plane_state <drm_plane_state>`, DM calls
  126. :c:type:`fill_blending_from_plane_state()` that maps
  127. :c:type:`drm_plane_state <drm_plane_state>` attributes to
  128. :c:type:`dc_plane_info <dc_plane_info>` struct to be handled in the
  129. OS-agnostic component (DC).
  130. 2. On DC interface, :c:type:`struct mpcc_blnd_cfg <mpcc_blnd_cfg>` programs the
  131. MPCC blend configuration considering the :c:type:`dc_plane_info
  132. <dc_plane_info>` input from DPP.