0001 =======================
0002 Display Core Next (DCN)
0003 =======================
0004
0005 To equip our readers with the basic knowledge of how AMD Display Core Next
0006 (DCN) works, we need to start with an overview of the hardware pipeline. Below
0007 you can see a picture that provides a DCN overview, keep in mind that this is a
0008 generic diagram, and we have variations per ASIC.
0009
0010 .. kernel-figure:: dc_pipeline_overview.svg
0011
0012 Based on this diagram, we can pass through each block and briefly describe
0013 them:
0014
0015 * **Display Controller Hub (DCHUB)**: This is the gateway between the Scalable
0016 Data Port (SDP) and DCN. This component has multiple features, such as memory
0017 arbitration, rotation, and cursor manipulation.
0018
0019 * **Display Pipe and Plane (DPP)**: This block provides pre-blend pixel
0020 processing such as color space conversion, linearization of pixel data, tone
0021 mapping, and gamut mapping.
0022
0023 * **Multiple Pipe/Plane Combined (MPC)**: This component performs blending of
0024 multiple planes, using global or per-pixel alpha.
0025
0026 * **Output Pixel Processing (OPP)**: Process and format pixels to be sent to
0027 the display.
0028
0029 * **Output Pipe Timing Combiner (OPTC)**: It generates time output to combine
0030 streams or divide capabilities. CRC values are generated in this block.
0031
0032 * **Display Output (DIO)**: Codify the output to the display connected to our
0033 GPU.
0034
0035 * **Display Writeback (DWB)**: It provides the ability to write the output of
0036 the display pipe back to memory as video frames.
0037
0038 * **Multi-Media HUB (MMHUBBUB)**: Memory controller interface for DMCUB and DWB
0039 (Note that DWB is not hooked yet).
0040
0041 * **DCN Management Unit (DMU)**: It provides registers with access control and
0042 interrupts the controller to the SOC host interrupt unit. This block includes
0043 the Display Micro-Controller Unit - version B (DMCUB), which is handled via
0044 firmware.
0045
0046 * **DCN Clock Generator Block (DCCG)**: It provides the clocks and resets
0047 for all of the display controller clock domains.
0048
0049 * **Azalia (AZ)**: Audio engine.
0050
0051 The above diagram is an architecture generalization of DCN, which means that
0052 every ASIC has variations around this base model. Notice that the display
0053 pipeline is connected to the Scalable Data Port (SDP) via DCHUB; you can see
0054 the SDP as the element from our Data Fabric that feeds the display pipe.
0055
0056 Always approach the DCN architecture as something flexible that can be
0057 configured and reconfigured in multiple ways; in other words, each block can be
0058 setup or ignored accordingly with userspace demands. For example, if we
0059 want to drive an 8k@60Hz with a DSC enabled, our DCN may require 4 DPP and 2
0060 OPP. It is DC's responsibility to drive the best configuration for each
0061 specific scenario. Orchestrate all of these components together requires a
0062 sophisticated communication interface which is highlighted in the diagram by
0063 the edges that connect each block; from the chart, each connection between
0064 these blocks represents:
0065
0066 1. Pixel data interface (red): Represents the pixel data flow;
0067 2. Global sync signals (green): It is a set of synchronization signals composed
0068 by VStartup, VUpdate, and VReady;
0069 3. Config interface: Responsible to configure blocks;
0070 4. Sideband signals: All other signals that do not fit the previous one.
0071
0072 These signals are essential and play an important role in DCN. Nevertheless,
0073 the Global Sync deserves an extra level of detail described in the next
0074 section.
0075
0076 All of these components are represented by a data structure named dc_state.
0077 From DCHUB to MPC, we have a representation called dc_plane; from MPC to OPTC,
0078 we have dc_stream, and the output (DIO) is handled by dc_link. Keep in mind
0079 that HUBP accesses a surface using a specific format read from memory, and our
0080 dc_plane should work to convert all pixels in the plane to something that can
0081 be sent to the display via dc_stream and dc_link.
0082
0083 Front End and Back End
0084 ----------------------
0085
0086 Display pipeline can be broken down into two components that are usually
0087 referred as **Front End (FE)** and **Back End (BE)**, where FE consists of:
0088
0089 * DCHUB (Mainly referring to a subcomponent named HUBP)
0090 * DPP
0091 * MPC
0092
0093 On the other hand, BE consist of
0094
0095 * OPP
0096 * OPTC
0097 * DIO (DP/HDMI stream encoder and link encoder)
0098
0099 OPP and OPTC are two joining blocks between FE and BE. On a side note, this is
0100 a one-to-one mapping of the link encoder to PHY, but we can configure the DCN
0101 to choose which link encoder to connect to which PHY. FE's main responsibility
0102 is to change, blend and compose pixel data, while BE's job is to frame a
0103 generic pixel stream to a specific display's pixel stream.
0104
0105 Data Flow
0106 ---------
0107
0108 Initially, data is passed in from VRAM through Data Fabric (DF) in native pixel
0109 formats. Such data format stays through till HUBP in DCHUB, where HUBP unpacks
0110 different pixel formats and outputs them to DPP in uniform streams through 4
0111 channels (1 for alpha + 3 for colors).
0112
0113 The Converter and Cursor (CNVC) in DPP would then normalize the data
0114 representation and convert them to a DCN specific floating-point format (i.e.,
0115 different from the IEEE floating-point format). In the process, CNVC also
0116 applies a degamma function to transform the data from non-linear to linear
0117 space to relax the floating-point calculations following. Data would stay in
0118 this floating-point format from DPP to OPP.
0119
0120 Starting OPP, because color transformation and blending have been completed
0121 (i.e alpha can be dropped), and the end sinks do not require the precision and
0122 dynamic range that floating points provide (i.e. all displays are in integer
0123 depth format), bit-depth reduction/dithering would kick in. In OPP, we would
0124 also apply a regamma function to introduce the gamma removed earlier back.
0125 Eventually, we output data in integer format at DIO.
0126
0127 Global Sync
0128 -----------
0129
0130 Many DCN registers are double buffered, most importantly the surface address.
0131 This allows us to update DCN hardware atomically for page flips, as well as
0132 for most other updates that don't require enabling or disabling of new pipes.
0133
0134 (Note: There are many scenarios when DC will decide to reserve extra pipes
0135 in order to support outputs that need a very high pixel clock, or for
0136 power saving purposes.)
0137
0138 These atomic register updates are driven by global sync signals in DCN. In
0139 order to understand how atomic updates interact with DCN hardware, and how DCN
0140 signals page flip and vblank events it is helpful to understand how global sync
0141 is programmed.
0142
0143 Global sync consists of three signals, VSTARTUP, VUPDATE, and VREADY. These are
0144 calculated by the Display Mode Library - DML (drivers/gpu/drm/amd/display/dc/dml)
0145 based on a large number of parameters and ensure our hardware is able to feed
0146 the DCN pipeline without underflows or hangs in any given system configuration.
0147 The global sync signals always happen during VBlank, are independent from the
0148 VSync signal, and do not overlap each other.
0149
0150 VUPDATE is the only signal that is of interest to the rest of the driver stack
0151 or userspace clients as it signals the point at which hardware latches to
0152 atomically programmed (i.e. double buffered) registers. Even though it is
0153 independent of the VSync signal we use VUPDATE to signal the VSync event as it
0154 provides the best indication of how atomic commits and hardware interact.
0155
0156 Since DCN hardware is double-buffered the DC driver is able to program the
0157 hardware at any point during the frame.
0158
0159 The below picture illustrates the global sync signals:
0160
0161 .. kernel-figure:: global_sync_vblank.svg
0162
0163 These signals affect core DCN behavior. Programming them incorrectly will lead
0164 to a number of negative consequences, most of them quite catastrophic.
0165
0166 The following picture shows how global sync allows for a mailbox style of
0167 updates, i.e. it allows for multiple re-configurations between VUpdate
0168 events where only the last configuration programmed before the VUpdate signal
0169 becomes effective.
0170
0171 .. kernel-figure:: config_example.svg