drm/vkms: fix 32bit compilation error by replacing macros
[linux-2.6-block.git] / Documentation / gpu / amdgpu / display / dcn-overview.rst
1 =======================
2 Display Core Next (DCN)
3 =======================
4
5 To equip our readers with the basic knowledge of how AMD Display Core Next
6 (DCN) works, we need to start with an overview of the hardware pipeline. Below
7 you can see a picture that provides a DCN overview, keep in mind that this is a
8 generic diagram, and we have variations per ASIC.
9
10 .. kernel-figure:: dc_pipeline_overview.svg
11
12 Based on this diagram, we can pass through each block and briefly describe
13 them:
14
15 * **Display Controller Hub (DCHUB)**: This is the gateway between the Scalable
16   Data Port (SDP) and DCN. This component has multiple features, such as memory
17   arbitration, rotation, and cursor manipulation.
18
19 * **Display Pipe and Plane (DPP)**: This block provides pre-blend pixel
20   processing such as color space conversion, linearization of pixel data, tone
21   mapping, and gamut mapping.
22
23 * **Multiple Pipe/Plane Combined (MPC)**: This component performs blending of
24   multiple planes, using global or per-pixel alpha.
25
26 * **Output Pixel Processing (OPP)**: Process and format pixels to be sent to
27   the display.
28
29 * **Output Pipe Timing Combiner (OPTC)**: It generates time output to combine
30   streams or divide capabilities. CRC values are generated in this block.
31
32 * **Display Output (DIO)**: Codify the output to the display connected to our
33   GPU.
34
35 * **Display Writeback (DWB)**: It provides the ability to write the output of
36   the display pipe back to memory as video frames.
37
38 * **Multi-Media HUB (MMHUBBUB)**: Memory controller interface for DMCUB and DWB
39   (Note that DWB is not hooked yet).
40
41 * **DCN Management Unit (DMU)**: It provides registers with access control and
42   interrupts the controller to the SOC host interrupt unit. This block includes
43   the Display Micro-Controller Unit - version B (DMCUB), which is handled via
44   firmware.
45
46 * **DCN Clock Generator Block (DCCG)**: It provides the clocks and resets
47   for all of the display controller clock domains.
48
49 * **Azalia (AZ)**: Audio engine.
50
51 The above diagram is an architecture generalization of DCN, which means that
52 every ASIC has variations around this base model. Notice that the display
53 pipeline is connected to the Scalable Data Port (SDP) via DCHUB; you can see
54 the SDP as the element from our Data Fabric that feeds the display pipe.
55
56 Always approach the DCN architecture as something flexible that can be
57 configured and reconfigured in multiple ways; in other words, each block can be
58 setup or ignored accordingly with userspace demands. For example, if we
59 want to drive an 8k@60Hz with a DSC enabled, our DCN may require 4 DPP and 2
60 OPP. It is DC's responsibility to drive the best configuration for each
61 specific scenario. Orchestrate all of these components together requires a
62 sophisticated communication interface which is highlighted in the diagram by
63 the edges that connect each block; from the chart, each connection between
64 these blocks represents:
65
66 1. Pixel data interface (red): Represents the pixel data flow;
67 2. Global sync signals (green): It is a set of synchronization signals composed
68    by VStartup, VUpdate, and VReady;
69 3. Config interface: Responsible to configure blocks;
70 4. Sideband signals: All other signals that do not fit the previous one.
71
72 These signals are essential and play an important role in DCN. Nevertheless,
73 the Global Sync deserves an extra level of detail described in the next
74 section.
75
76 All of these components are represented by a data structure named dc_state.
77 From DCHUB to MPC, we have a representation called dc_plane; from MPC to OPTC,
78 we have dc_stream, and the output (DIO) is handled by dc_link. Keep in mind
79 that HUBP accesses a surface using a specific format read from memory, and our
80 dc_plane should work to convert all pixels in the plane to something that can
81 be sent to the display via dc_stream and dc_link.
82
83 Front End and Back End
84 ----------------------
85
86 Display pipeline can be broken down into two components that are usually
87 referred as **Front End (FE)** and **Back End (BE)**, where FE consists of:
88
89 * DCHUB (Mainly referring to a subcomponent named HUBP)
90 * DPP
91 * MPC
92
93 On the other hand, BE consist of
94
95 * OPP
96 * OPTC
97 * DIO (DP/HDMI stream encoder and link encoder)
98
99 OPP and OPTC are two joining blocks between FE and BE. On a side note, this is
100 a one-to-one mapping of the link encoder to PHY, but we can configure the DCN
101 to choose which link encoder to connect to which PHY. FE's main responsibility
102 is to change, blend and compose pixel data, while BE's job is to frame a
103 generic pixel stream to a specific display's pixel stream.
104
105 Data Flow
106 ---------
107
108 Initially, data is passed in from VRAM through Data Fabric (DF) in native pixel
109 formats. Such data format stays through till HUBP in DCHUB, where HUBP unpacks
110 different pixel formats and outputs them to DPP in uniform streams through 4
111 channels (1 for alpha + 3 for colors).
112
113 The Converter and Cursor (CNVC) in DPP would then normalize the data
114 representation and convert them to a DCN specific floating-point format (i.e.,
115 different from the IEEE floating-point format). In the process, CNVC also
116 applies a degamma function to transform the data from non-linear to linear
117 space to relax the floating-point calculations following. Data would stay in
118 this floating-point format from DPP to OPP.
119
120 Starting OPP, because color transformation and blending have been completed
121 (i.e alpha can be dropped), and the end sinks do not require the precision and
122 dynamic range that floating points provide (i.e. all displays are in integer
123 depth format), bit-depth reduction/dithering would kick in. In OPP, we would
124 also apply a regamma function to introduce the gamma removed earlier back.
125 Eventually, we output data in integer format at DIO.
126
127 Global Sync
128 -----------
129
130 Many DCN registers are double buffered, most importantly the surface address.
131 This allows us to update DCN hardware atomically for page flips, as well as
132 for most other updates that don't require enabling or disabling of new pipes.
133
134 (Note: There are many scenarios when DC will decide to reserve extra pipes
135 in order to support outputs that need a very high pixel clock, or for
136 power saving purposes.)
137
138 These atomic register updates are driven by global sync signals in DCN. In
139 order to understand how atomic updates interact with DCN hardware, and how DCN
140 signals page flip and vblank events it is helpful to understand how global sync
141 is programmed.
142
143 Global sync consists of three signals, VSTARTUP, VUPDATE, and VREADY. These are
144 calculated by the Display Mode Library - DML (drivers/gpu/drm/amd/display/dc/dml)
145 based on a large number of parameters and ensure our hardware is able to feed
146 the DCN pipeline without underflows or hangs in any given system configuration.
147 The global sync signals always happen during VBlank, are independent from the
148 VSync signal, and do not overlap each other.
149
150 VUPDATE is the only signal that is of interest to the rest of the driver stack
151 or userspace clients as it signals the point at which hardware latches to
152 atomically programmed (i.e. double buffered) registers. Even though it is
153 independent of the VSync signal we use VUPDATE to signal the VSync event as it
154 provides the best indication of how atomic commits and hardware interact.
155
156 Since DCN hardware is double-buffered the DC driver is able to program the
157 hardware at any point during the frame.
158
159 The below picture illustrates the global sync signals:
160
161 .. kernel-figure:: global_sync_vblank.svg
162
163 These signals affect core DCN behavior. Programming them incorrectly will lead
164 to a number of negative consequences, most of them quite catastrophic.
165
166 The following picture shows how global sync allows for a mailbox style of
167 updates, i.e. it allows for multiple re-configurations between VUpdate
168 events where only the last configuration programmed before the VUpdate signal
169 becomes effective.
170
171 .. kernel-figure:: config_example.svg