Xilinx ZynqMP Ultrascale+ DisplayPort Subsystem
This subsystem handles DisplayPort video and audio output on the ZynqMP. It supports in-memory framebuffers with the DisplayPort DMA controller (xilinx-dpdma), as well as "live" video and audio from the programmable logic (PL). This subsystem can perform several transformations, including color space conversion, alpha blending, and audio mixing, although not all features are currently supported.
debugfs #
To support debugging and compliance testing, several test modes can be enabled though debugfs. The following files in /sys/kernel/debug/dri/X/DP-1/test/ control the DisplayPort test modes:
-
active:
Writing a 1 to this file will activate test mode, and writing a 0 will deactivate test mode. Writing a 1 or 0 when the test mode is already active/inactive will re-activate/re-deactivate test mode. When test mode is inactive, changes made to other files will have no (immediate) effect, although the settings will be saved for when test mode is activated. When test mode is active, changes made to other files will apply immediately.
-
custom:
Custom test pattern value
-
downspread:
Enable/disable clock downspreading (spread-spectrum clocking) by writing 1/0
-
enhanced:
Enable/disable enhanced framing
-
ignore_aux_errors:
Ignore AUX errors when set to 1. Writes to this file take effect immediately (regardless of whether test mode is active) and affect all AUX transfers.
-
ignore_hpd:
Ignore hotplug events (such as cable removals or monitor link retraining requests) when set to 1. Writes to this file take effect immediately (regardless of whether test mode is active).
-
laneX_preemphasis:
Preemphasis from 0 (lowest) to 2 (highest) for lane X
-
laneX_swing:
Voltage swing from 0 (lowest) to 3 (highest) for lane X
-
lanes:
Number of lanes to use (1, 2, or 4)
-
pattern:
Test pattern. May be one of:
-
video
Use regular video input
-
symbol-error
Symbol error measurement pattern
-
prbs7
Output of the PRBS7 (x^7 + x^6 + 1) polynomial
-
80bit-custom
A custom 80-bit pattern
-
cp2520
HBR2 compliance eye pattern
-
tps1
Link training symbol pattern TPS1 (/D10.2/)
-
tps2
Link training symbol pattern TPS2
-
tps3
Link training symbol pattern TPS3 (for HBR2)
-
-
rate:
Rate in hertz. One of
-
5400000000 (HBR2)
-
2700000000 (HBR)
-
1620000000 (RBR)
-
You can dump the displayport test settings with the following command:
for prop in /sys/kernel/debug/dri/1/DP-1/test/*; do
printf '%-17s ' ${prop##*/}
if [ ${prop##*/} = custom ]; then
hexdump -C $prop | head -1
else
cat $prop
fi
done
The output could look something like:
active 1
custom 00000000 00 00 00 00 00 00 00 00 00 00 |..........|
downspread 0
enhanced 1
ignore_aux_errors 1
ignore_hpd 1
lane0_preemphasis 0
lane0_swing 3
lane1_preemphasis 0
lane1_swing 3
lanes 2
pattern prbs7
rate 1620000000
The recommended test procedure is to connect the board to a monitor, configure test mode, activate test mode, and then disconnect the cable and connect it to your test equipment of choice. For example, one sequence of commands could be:
echo 1 > /sys/kernel/debug/dri/1/DP-1/test/enhanced
echo tps1 > /sys/kernel/debug/dri/1/DP-1/test/pattern
echo 1620000000 > /sys/kernel/debug/dri/1/DP-1/test/rate
echo 1 > /sys/kernel/debug/dri/1/DP-1/test/ignore_aux_errors
echo 1 > /sys/kernel/debug/dri/1/DP-1/test/ignore_hpd
echo 1 > /sys/kernel/debug/dri/1/DP-1/test/active
at which point the cable could be disconnected from the monitor.
Internals #
enum zynqmp_dpsub_layer_id #
Layer identifier
Constants
ZYNQMP_DPSUB_LAYER_VID: Video layerZYNQMP_DPSUB_LAYER_GFX: Graphics layer
struct zynqmp_dpsub #
ZynqMP DisplayPort Subsystem
Definition
;
Members
dev: The physical deviceapb_clk: The APB clockvid_clk: Video clockvid_clk_from_ps: True of the video clock comes from PS, false from PLaud_clk: Audio clockaud_clk_from_ps: True of the audio clock comes from PS, false from PLconnected_ports: Bitmask of connected ports in the device treedma_enabled: True if the DMA interface is enabled, false if the DPSUB is driven by the live inputdrm: The DRM/KMS device databridge: The DP encoder bridgedisp: The display controllerlayers: Video and graphics layersdp: The DisplayPort controllerdma_align: DMA alignment constraint (must be a power of 2)audio: DP audio data
struct zynqmp_dpsub_drm #
ZynqMP DisplayPort Subsystem DRM/KMS data
Definition
;
Members
dpsub: Backpointer to the DisplayPort subsystemdev: The DRM/KMS deviceplanes: The DRM planescrtc: The DRM CRTCencoder: The dummy DRM encoder
enum zynqmp_dpsub_layer_mode #
Layer mode
Constants
ZYNQMP_DPSUB_LAYER_NONLIVE: non-live (memory) modeZYNQMP_DPSUB_LAYER_LIVE: live (stream) mode
struct zynqmp_disp_format #
Display subsystem format information
Definition
;
Members
drm_fmt: DRM format (4CC)bus_fmt: Media bus formatbuf_fmt: AV buffer formatswap: Flag to swap R & B for RGB formats, and U & V for YUV formatssf: Scaling factors for color components
struct zynqmp_disp_layer_dma #
DMA channel for one data plane of a layer
Definition
;
Members
chan: DMA channelxt: Interleaved DMA descriptor templatesgl: Data chunk for dma_interleaved_template
struct zynqmp_disp_layer_info #
Static layer information
Definition
;
Members
formats: Array of supported formatsnum_formats: Number of formats in formats arraynum_channels: Number of DMA channels
struct zynqmp_disp_layer #
Display layer
Definition
;
Members
id: Layer IDdisp: Back pointer to struct zynqmp_dispinfo: Static layer informationdmas: DMA channelsdisp_fmt: Current format informationdrm_fmt: Current DRM format informationmode: Current operation mode
struct zynqmp_disp #
Display controller
Definition
;
Members
dev: Device structuredpsub: Display subsystemblend: Register I/O base address for the blenderavbuf: Register I/O base address for the audio/video buffer managerlayers: Layers (planes)
zynqmp_disp_avbuf_set_format() #
void Set the input format for a layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layerconst struct zynqmp_disp_format *fmt: The format information
Description
Set the video buffer manager format for layer to fmt.
zynqmp_disp_avbuf_set_clocks_sources() #
void Set the clocks sources
Parameters
struct zynqmp_disp *disp: Display controllerbool video_from_ps: True if the video clock originates from the PSbool audio_from_ps: True if the audio clock originates from the PSbool timings_internal: True if video timings are generated internally
Description
Set the source for the video and audio clocks, as well as for the video timings. Clocks can originate from the PS or PL, and timings can be generated internally or externally.
zynqmp_disp_avbuf_enable_channels() #
void Enable buffer channels
Parameters
struct zynqmp_disp *disp: Display controller
Description
Enable all (video and audio) buffer channels.
zynqmp_disp_avbuf_disable_channels() #
void Disable buffer channels
Parameters
struct zynqmp_disp *disp: Display controller
Description
Disable all (video and audio) buffer channels.
zynqmp_disp_avbuf_enable_audio() #
void Enable audio
Parameters
struct zynqmp_disp *disp: Display controller
Description
Enable all audio buffers with a non-live (memory) source.
zynqmp_disp_avbuf_disable_audio() #
void Disable audio
Parameters
struct zynqmp_disp *disp: Display controller
Description
Disable all audio buffers.
zynqmp_disp_avbuf_enable_video() #
void Enable a video layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
Description
Enable the video/graphics buffer for layer.
zynqmp_disp_avbuf_disable_video() #
void Disable a video layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
Description
Disable the video/graphics buffer for layer.
zynqmp_disp_avbuf_enable() #
void Enable the video pipe
Parameters
struct zynqmp_disp *disp: Display controller
Description
De-assert the video pipe reset.
zynqmp_disp_avbuf_disable() #
void Disable the video pipe
Parameters
struct zynqmp_disp *disp: Display controller
Description
Assert the video pipe reset.
zynqmp_disp_blend_set_output_format() #
void Set the output format of the blender
Parameters
struct zynqmp_disp *disp: Display controllerenum zynqmp_dpsub_format format: Output format
Description
Set the output format of the blender to format.
zynqmp_disp_blend_set_bg_color() #
void Set the background color
Parameters
struct zynqmp_disp *disp: Display controlleru32 rcr: Red/Cr color componentu32 gy: Green/Y color componentu32 bcb: Blue/Cb color component
Description
Set the background color to (rcr, gy, bcb), corresponding to the R, G and B or Cr, Y and Cb components respectively depending on the selected output format.
zynqmp_disp_blend_set_global_alpha() #
void Configure global alpha blending
Parameters
struct zynqmp_disp *disp: Display controllerbool enable: True to enable global alpha blendingu32 alpha: Global alpha value (ignored if enabled is false)
zynqmp_disp_blend_layer_set_csc() #
void Configure colorspace conversion for layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layerconst u16 *coeffs: Colorspace conversion matrixconst u32 *offsets: Colorspace conversion offsets
Description
Configure the input colorspace conversion matrix and offsets for the layer. Columns of the matrix are automatically swapped based on the input format to handle RGB and YCrCb components permutations.
zynqmp_disp_blend_layer_enable() #
void Enable a layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
zynqmp_disp_blend_layer_disable() #
void Disable a layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
zynqmp_disp_layer_find_format() #
const struct zynqmp_disp_format * Find format information for a DRM format
Parameters
struct zynqmp_disp_layer *layer: The layeru32 drm_fmt: DRM format to search
Description
Search display subsystem format information corresponding to the given DRM format drm_fmt for the layer, and return a pointer to the format descriptor.
Return
A pointer to the format descriptor if found, NULL otherwise
zynqmp_disp_layer_find_live_format() #
const struct zynqmp_disp_format * Find format information for given media bus format
Parameters
struct zynqmp_disp_layer *layer: The layeru32 media_bus_format: Media bus format to search
Description
Search display subsystem format information corresponding to the given media bus format media_bus_format for the layer, and return a pointer to the format descriptor.
Return
A pointer to the format descriptor if found, NULL otherwise
zynqmp_disp_layer_drm_formats() #
u32 * Return the DRM formats supported by the layer
Parameters
struct zynqmp_disp_layer *layer: The layerunsigned int *num_formats: Pointer to the returned number of formats
NOTE
This function doesn't make sense for live video layers and will
always return an empty list in such cases. zynqmp_disp_live_layer_formats()
should be used to query a list of media bus formats supported by the live
video input layer.
Return
A newly allocated u32 array that stores all the DRM formats supported by the layer. The number of formats in the array is returned through the num_formats argument.
zynqmp_disp_live_layer_formats() #
u32 * Return the media bus formats supported by the live video layer
Parameters
struct zynqmp_disp_layer *layer: The layerunsigned int *num_formats: Pointer to the returned number of formats
NOTE
This function should be used only for live video input layers.
Return
A newly allocated u32 array of media bus formats supported by the layer. The number of formats in the array is returned through the num_formats argument.
zynqmp_disp_layer_enable() #
void Enable a layer
Parameters
struct zynqmp_disp_layer *layer: The layer
Description
Enable the layer in the audio/video buffer manager and the blender. DMA
channels are started separately by zynqmp_disp_layer_update().
zynqmp_disp_layer_disable() #
void Disable the layer
Parameters
struct zynqmp_disp_layer *layer: The layer
Description
Disable the layer by stopping its DMA channels and disabling it in the audio/video buffer manager and the blender.
zynqmp_disp_layer_set_format() #
void Set the layer format
Parameters
struct zynqmp_disp_layer *layer: The layerconst struct drm_format_info *info: The format info
NOTE
Use zynqmp_disp_layer_set_live_format() to set media bus format for
live video layers.
Set the format for layer to info. The layer must be disabled.
zynqmp_disp_layer_set_live_format() #
void Set the live video layer format
Parameters
struct zynqmp_disp_layer *layer: The layeru32 media_bus_format: Media bus format to set
NOTE
This function should not be used to set format for non-live video
layer. Use zynqmp_disp_layer_set_format() instead.
Set the display format for the live layer. The layer must be disabled.
zynqmp_disp_layer_update() #
int Update the layer framebuffer
Parameters
struct zynqmp_disp_layer *layer: The layerstruct drm_plane_state *state: The plane state
Description
Update the framebuffer for the layer by issuing a new DMA engine transaction for the new framebuffer.
Return
0 on success, or the DMA descriptor failure error otherwise
zynqmp_disp_layer_release_dma() #
void Release DMA channels for a layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
Description
Release the DMA channels associated with layer.
zynqmp_disp_destroy_layers() #
void Destroy all layers
Parameters
struct zynqmp_disp *disp: Display controller
zynqmp_disp_layer_request_dma() #
int Request DMA channels for a layer
Parameters
struct zynqmp_disp *disp: Display controllerstruct zynqmp_disp_layer *layer: The layer
Description
Request all DMA engine channels needed by layer.
Return
0 on success, or the DMA channel request error otherwise
zynqmp_disp_create_layers() #
int Create and initialize all layers
Parameters
struct zynqmp_disp *disp: Display controller
Return
0 on success, or the DMA channel request error otherwise
zynqmp_disp_enable() #
void Enable the display controller
Parameters
struct zynqmp_disp *disp: Display controller
zynqmp_disp_disable() #
void Disable the display controller
Parameters
struct zynqmp_disp *disp: Display controller
zynqmp_disp_setup_clock() #
int Configure the display controller pixel clock rate
Parameters
struct zynqmp_disp *disp: Display controllerunsigned long mode_clock: The pixel clock rate, in Hz
Return
0 on success, or a negative error clock otherwise
struct zynqmp_dp_link_config #
Common link config between source and sink
Definition
;
Members
max_rate: maximum link ratemax_lanes: maximum number of lanes
struct zynqmp_dp_mode #
Configured mode of DisplayPort
Definition
;
Members
fmt: format identifier stringpclock: pixel clock frequency of current modebw_code: code for bandwidth(link rate)lane_cnt: number of lanes
struct zynqmp_dp_config #
Configuration of DisplayPort from DTS
Definition
;
Members
misc0: misc0 configuration (per DP v1.2 spec)misc1: misc1 configuration (per DP v1.2 spec)bpp: bits per pixel
enum test_pattern #
Test patterns for test testing
Constants
TEST_VIDEO: Use regular video inputTEST_TPS1: Link training symbol pattern TPS1 (/D10.2/)TEST_TPS2: Link training symbol pattern TPS2TEST_TPS3: Link training symbol pattern TPS3 (for HBR2)TEST_SYMBOL_ERROR: Symbol error measurement patternTEST_PRBS7: Output of the PRBS7 (x^7 + x^6 + 1) polynomialTEST_80BIT_CUSTOM: A custom 80-bit patternTEST_CP2520: HBR2 compliance eye pattern
struct zynqmp_dp_test #
Configuration for test mode
Definition
;
Members
pattern: The test patternenhanced: Use enhanced framingdownspread: Use SSCactive: Whether test mode is activecustom: Custom pattern forTEST_80BIT_CUSTOMtrain_set: Voltage/preemphasis settingsbw_code: Bandwidth code for the linklink_cnt: Number of lanes
struct zynqmp_dp_train_set_priv #
Private data for train_set debugfs files
Definition
;
Members
dp: DisplayPort IP core structurelane: The lane for this file
struct zynqmp_dp #
Xilinx DisplayPort core
Definition
;
Members
aux: aux channelbridge: DRM bridge for the DP encoderhpd_work: hot plug detection workerhpd_irq_work: hot plug detection IRQ workeraux_done: Completed when we get an AUX reply or timeoutlock: Mutex protecting this struct and register access (but not AUX)next_bridge: The downstream bridgedev: device structuredpsub: Display subsystemiomem: device I/O memory for register accessreset: reset controllerphy: PHY handles for DP lanesstatus: connection statusirq: irqenabled: flag to indicate if the device is enabledignore_aux_errors: If set, AUX errors are suppressedignore_hpd: If set, HPD events and IRQs are ignoreddebugfs_train_set: Debugfs private data for train_setmode: current mode between IP core and sink devicelink_config: common link configuration between IP core and sink devicetest: Configuration for test modeconfig: IP core configuration from DTSdpcd: DP configuration data from currently connected sink devicetrain_set: set of training datanum_lanes: number of enabled phy lanes
Description
lock covers the link configuration in this struct and the device's registers. It does not cover aux or ignore_aux_errors. It is not strictly required for any of the members which are only modified at probe/remove time (e.g. dev).
zynqmp_dp_phy_init() #
int Initialize the phy
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Initialize the phy.
Return
0 if the phy instances are initialized correctly, or the error code returned from the callee functions.
zynqmp_dp_phy_exit() #
void Exit the phy
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Exit the phy.
zynqmp_dp_phy_probe() #
int Probe the PHYs
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Probe PHYs for all lanes. Less PHYs may be available than the number of lanes, which is not considered an error as long as at least one PHY is found. The caller can check dp->num_lanes to check how many PHYs were found.
Return
- 0 - Success
- -ENXIO - No PHY found
- -EPROBE_DEFER - Probe deferral requested
- Other negative value - PHY retrieval failure
zynqmp_dp_phy_ready() #
int Check if PHY is ready
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Check if PHY is ready. If PHY is not ready, wait 1ms to check for 100 times. This amount of delay was suggested by IP designer.
Return
0 if PHY is ready, or -ENODEV if PHY is not ready.
zynqmp_dp_max_rate() #
int Calculate and return available max pixel clock
Parameters
int link_rate: link rate (Kilo-bytes / sec)u8 lane_num: number of lanesu8 bpp: bits per pixel
Return
max pixel clock (KHz) supported by current link config.
zynqmp_dp_mode_configure() #
int Configure the link values
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureint pclock: pixel clock for requested display modeu8 current_bw: current link rate
Description
Find the link configuration values, rate and lane count for requested pixel clock pclock. The pclock is stored in the mode to be used in other functions later. The returned rate is downshifted from the current rate current_bw.
Return
Current link rate code, or -EINVAL.
zynqmp_dp_adjust_train() #
void Adjust train values
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureu8 link_status[DP_LINK_STATUS_SIZE]: link status from sink which contains requested training values
zynqmp_dp_update_vs_emph() #
int Update the training values
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureu8 *train_set: A set of training values
Description
Update the training values based on the request from sink. The mapped values are predefined, and values(vs, pe, pc) are from the device manual.
Return
0 if vs and emph are updated successfully, or the error code returned
by drm_dp_dpcd_write().
zynqmp_dp_link_train_cr() #
int Train clock recovery
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Return
0 if clock recovery train is done successfully, or corresponding error code.
zynqmp_dp_link_train_ce() #
int Train channel equalization
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Return
0 if channel equalization train is done successfully, or corresponding error code.
zynqmp_dp_setup() #
int Set up major link parameters
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureu8 bw_code: The link bandwidth as a multiple of 270 MHzu8 lane_cnt: The number of lanes to usebool enhanced: Use enhanced framingbool downspread: Enable spread-spectrum clocking
Return
0 on success, or -errno on failure
zynqmp_dp_train() #
int Train the link
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Return
0 if all trains are done successfully, or corresponding error code.
zynqmp_dp_train_loop() #
void Downshift the link rate during training
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Train the link by downshifting the link rate if training is not successful.
zynqmp_dp_aux_cmd_submit() #
int Submit aux command
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureu32 cmd: aux commandu16 addr: aux addressu8 *buf: buffer for command datau8 bytes: number of bytes for bufu8 *reply: reply code to be returned
Description
Submit an aux command. All aux related commands, native or i2c aux read/write, are submitted through this function. The function is mapped to the transfer function of struct drm_dp_aux. This function involves in multiple register reads/writes, thus synchronization is needed, and it is done by drm_dp_helper using hw_mutex. The calling thread goes into sleep if there's no immediate reply to the command submission. The reply code is returned at reply if reply != NULL.
Return
0 if the command is submitted properly, or corresponding error code: -EBUSY when there is any request already being processed -ETIMEDOUT when receiving reply is timed out -EIO when received bytes are less than requested
zynqmp_dp_aux_init() #
int Initialize and register the DP AUX
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Program the AUX clock divider and filter and register the DP AUX adapter.
Return
0 on success, error value otherwise
zynqmp_dp_aux_cleanup() #
void Cleanup the DP AUX
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Unregister the DP AUX adapter.
zynqmp_dp_update_misc() #
void Write the misc registers
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
The misc register values are stored in the structure, and this function applies the values into the registers.
zynqmp_dp_set_format() #
int Set the input format
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureconst struct drm_display_info *info: Display infoenum zynqmp_dpsub_format format: input formatunsigned int bpc: bits per component
Description
Update misc register values based on input format and bpc.
Return
0 on success, or -EINVAL.
zynqmp_dp_encoder_mode_set_transfer_unit() #
void Set the transfer unit values
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureconst struct drm_display_mode *mode: requested display mode
Description
Set the transfer unit, and calculate all transfer unit size related values. Calculation is based on DP and IP core specification.
zynqmp_dp_encoder_mode_set_stream() #
void Configure the main stream
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureconst struct drm_display_mode *mode: requested display mode
Description
Configure the main stream based on the requested mode mode. Calculation is based on IP core specification.
zynqmp_dp_disp_connected_live_layer() #
struct zynqmp_disp_layer * Return the first connected live layer
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Return
The first connected live display layer or NULL if none of the live layers are connected.
zynqmp_dp_set_test_pattern() #
int Configure the link for a test pattern
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structureenum test_pattern pattern: The test pattern to configureu8 *const custom: The custom pattern to use if pattern isTEST_80BIT_CUSTOM
Return
0 on success, or negative errno on (DPCD) failure
zynqmp_dp_enable_vblank() #
void Enable vblank
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Enable vblank interrupt
zynqmp_dp_disable_vblank() #
void Disable vblank
Parameters
struct zynqmp_dp *dp: DisplayPort IP core structure
Description
Disable vblank interrupt
zynqmp_dpsub_drm_handle_vblank() #
void Handle the vblank event
Parameters
struct zynqmp_dpsub *dpsub: DisplayPort subsystem
Description
This function handles the vblank interrupt, and sends an event to CRTC object. This will be called by the DP vblank interrupt handler.