Driver
The DisplayPort IP requires a processor to setup the core. This can be any processor. A DisplayPort driver (prt_dp_drv) is provided for this task. It is plain C with no operating system or vendor library behind it, so it ports to whatever core sits next to the IP.
Each IP-core carries its own policy maker, and that policy maker runs the firmware for the DisplayPort protocol itself: hot plug detect, EDID, DPCD, link training and the link. This is what makes the core autonomous, and it is the main reason for having it. The protocol keeps running on the policy maker's own timers and interrupts, so the application processor is free of the low level DisplayPort work. It decides what it wants, such as starting a video stream, and hears what came of it through the callbacks.
The application processor loads that firmware into the policy maker at start up, and from then on the two communicate through a mailbox, exchanging the tokens defined in prt_dp_tokens.h. Most API functions are such an exchange: they send a token to the policy maker and wait for its answer. For the same reason a few are asynchronous: prt_dp_sta returns right away and its values arrive a moment later, in the status callback.
One prt_dp_ds_struct describes one IP-core, so either the transmitter or the receiver. A design with both keeps two of them and passes the right one to every call, which is also how the API is split: shared functions, transmitter functions and receiver functions.
The IP-core raises an interrupt when the policy maker has sent mail. prt_dp_irq_handler belongs in that interrupt. It decodes the message and calls the matching callback straight away, so a callback runs in interrupt context and should be kept short.
An IP-core is brought up in this order. The reference design shows it in full.
prt_dp_set_base (&dptx, DPTX_BASE_ADDR); // find the IP-core
// hook prt_dp_irq_handler to its interrupt
prt_dp_rom_init (&dptx, rom_len, rom); // load the policy maker firmware
prt_dp_ram_init (&dptx, ram_len, ram);
prt_dp_init (&dptx, PRT_DPTX_ID);
prt_dp_set_cb (&dptx, PRT_DP_CB_HPD, &dptx_hpd_cb);
prt_dp_set_cb (&dptx, PRT_DP_CB_LNK, &dp_lnk_cb);
/* ... the other callbacks ... */
prt_dp_lic (&dptx, lic); // license key
prt_dp_ping (&dptx); // is the policy maker alive?
prt_dp_cfg (&dptx); // apply the configuration
API
This section provides information about the driver API. The functions are grouped the same way as in prt_dp_drv.h: shared functions that apply to both IP-cores, followed by the transmitter and receiver functions.
Shared
prt_dp_set_base
- description: Sets the DisplayPort IP-core base address and checks that the core responds.
- syntax: uint8_t prt_dp_set_base (prt_dp_ds_struct *dp, uint32_t base);
- parameters:
- dppointer to DisplayPort IP-core
- basebase address
- returns: none
prt_dp_set_cb
- description: Sets the DisplayPort call back handlers.
- syntax: void prt_dp_set_cb (prt_dp_ds_struct *dp, prt_dp_cb_type cb_type, void *cb_handler);
- parameters:
- dppointer to DisplayPort IP-core
- cb_typecall back type
- PRT_DP_CB_HPDHot Plug Detect
- PRT_DP_CB_STAStatus
- PRT_DP_CB_TRNLink training
- PRT_DP_CB_PHY_CTLPHY control (DPRX)
- PRT_DP_CB_PHY_RSTPHY reset during link training (DPRX)
- PRT_DP_CB_PHY_RATELink rate change
- PRT_DP_CB_PHY_VAPLink voltage and pre-emphasis change
- PRT_DP_CB_LNKLink
- PRT_DP_CB_VIDVideo
- PRT_DP_CB_MSAMain stream attributes (DPRX)
- PRT_DP_CB_DPCDDPCD (DPRX)
- PRT_DP_CB_DBGDebug
- cb_handlerpointer to call back handler
- returns: none
prt_dp_rom_init
- description: Loads the DisplayPort IP ROM code.
- syntax: void prt_dp_rom_init (prt_dp_ds_struct *dp, uint32_t len, uint8_t *rom);
- parameters:
- dppointer to DisplayPort IP-core
- lenlength of ROM code
- rompointer to ROM code
- returns: none
prt_dp_ram_init
- description: Loads the DisplayPort IP RAM code.
- syntax: void prt_dp_ram_init (prt_dp_ds_struct *dp, uint32_t len, uint8_t *ram);
- parameters:
- dppointer to DisplayPort IP-core
- lenlength of RAM code
- rampointer to RAM code
- returns: none
prt_dp_init
- description: Initialize the DisplayPort IP.
- syntax: void prt_dp_init (prt_dp_ds_struct *dp, uint8_t id);
- parameters:
- dppointer to DisplayPort IP-core
- idDisplayPort IP-core identifier
- returns: none
prt_dp_ping
- description: Checks if the DisplayPort IP is alive.
- syntax: bool prt_dp_ping (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when the IP-core is running, else false.
prt_dp_lic
- description: Sends the license key to the policy maker.
- syntax: bool prt_dp_lic (prt_dp_ds_struct *dp, char *lic);
- parameters:
- dppointer to DisplayPort IP-core
- licpointer to license key
- returns: true when the license is accepted, else false.
prt_dp_set_lnk_max_lanes
- description: Sets the maximum supported lanes.
- syntax: void prt_dp_set_lnk_max_lanes (prt_dp_ds_struct *dp, uint8_t lanes);
- parameters:
- dppointer to DisplayPort IP-core
- lanesmaximum lanes (1, 2 or 4)
- returns: none
prt_dp_set_lnk_max_rate
- description: Sets the maximum supported rate.
- syntax: void prt_dp_set_lnk_max_rate (prt_dp_ds_struct *dp, uint8_t rate);
- parameters:
- dppointer to DisplayPort IP-core
- ratemaximum link rate
- returns: none
prt_dp_cfg
- description: Configures the DisplayPort IP.
- syntax: bool prt_dp_cfg (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
prt_dp_sta
- description: Reads the DisplayPort IP status.
- syntax: void prt_dp_sta (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
prt_dp_run
- description: Starts the policy maker.
- syntax: uint8_t prt_dp_run (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when successful, else false.
prt_dp_lnk_req_ok
- description: Informs the driver that the requested line rate and/or voltage and preamble levels has been set.
- syntax: void prt_dp_lnk_req_ok (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
prt_dp_dpcd_cmd_is_wr
- description: This function returns true if the DPCD command is a write.
- syntax: uint8_t prt_dp_dpcd_cmd_is_wr (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when DPCD command is a write, else false.
prt_dp_dpcd_cmd_is_rd
- description: This function returns true if the DPCD command is a read.
- syntax: uint8_t prt_dp_dpcd_cmd_is_rd (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when DPCD command is a read, else false.
prt_dp_dpcd_adr_get
- description: Get DPCD address.
- syntax: uint32_t prt_dp_dpcd_adr_get (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: DPCD address.
prt_dp_dpcd_len_get
- description: Get DPCD length.
- syntax: uint8_t prt_dp_dpcd_len_get (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: DPCD length.
prt_dp_dpcd_dat_get
- description: Get DPCD data.
- syntax: uint8_t prt_dp_dpcd_dat_get (prt_dp_ds_struct *dp, uint8_t idx);
- parameters:
- dppointer to DisplayPort IP-core
- idxindex (0 - 15 bytes)
- returns: DPCD data.
prt_dp_dpcd_dat_set
- description: Set DPCD data.
- syntax: void prt_dp_dpcd_dat_set (prt_dp_ds_struct *dp, uint8_t idx, uint8_t dat);
- parameters:
- dppointer to DisplayPort IP-core
- idxindex (0 - 15 bytes)
- datdata
- returns: None
prt_dp_get_lnk_rate
- description: Gets the link rate requested by the policy maker.
- syntax: uint8_t prt_dp_get_lnk_rate (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: link rate.
- PRT_DP_PHY_LINERATE_16201.62 Gbps
- PRT_DP_PHY_LINERATE_27002.7 Gbps
- PRT_DP_PHY_LINERATE_54005.4 Gbps
- PRT_DP_PHY_LINERATE_81008.1 Gbps
prt_dp_get_lnk_lanes
- description: Gets the number of lanes the link is configured for.
- syntax: uint8_t prt_dp_get_lnk_lanes (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: number of lanes.
prt_dp_get_lnk_volt
- description: Gets the voltage swing requested by the policy maker.
- syntax: uint8_t prt_dp_get_lnk_volt (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: voltage swing.
- 0400 mV
- 1600 mV
- 2800 mV
- 31200 mV
prt_dp_get_lnk_pre
- description: Gets the pre-emphasis requested by the policy maker.
- syntax: uint8_t prt_dp_get_lnk_pre (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: pre-emphasis.
- 00 dB
- 13.5 dB
- 26.0 dB
- 39.5 dB
prt_dp_get_lnk_ssc
- description: Gets the spread spectrum clocking flag of the link.
- syntax: uint8_t prt_dp_get_lnk_ssc (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when spread spectrum clocking is enabled, else false.
prt_dp_get_lnk_act_lanes
- description: Gets number of active lanes.
- syntax: uint8_t prt_dp_get_lnk_act_lanes (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: 1, 2 or 4<
prt_dp_get_lnk_act_rate
- description: Gets active line rate.
- syntax: uint8_t prt_dp_get_lnk_act_rate (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns:
- PRT_DP_PHY_LINERATE_16201.62 Gbps
- PRT_DP_PHY_LINERATE_27002.7 Gbps
- PRT_DP_PHY_LINERATE_54005.4 Gbps
- PRT_DP_PHY_LINERATE_81008.1 Gbps
prt_dp_get_lnk_reason
- description: Gets reason why the link went down.
- syntax: uint8_t prt_dp_get_lnk_reason (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns:
- PRT_DP_LNK_DOWN_PHYLink went down
- PRT_DP_LNK_DOWN_CLKNo link clock
- PRT_DP_LNK_DOWN_CDRCDR loss of lock
- PRT_DP_LNK_DOWN_SCRMScrambler loss of lock
- PRT_DP_LNK_DOWN_TRNTraining error
- PRT_DP_LNK_DOWN_VIDVideo error
- PRT_DP_LNK_DOWN_HPDHPD
- PRT_DP_LNK_DOWN_IDLELink idle
- PRT_DP_LNK_DOWN_TOTime out (evaluation)
prt_dp_get_vid_reason
- description: Gets reason why the video stream went down.
- syntax: uint8_t prt_dp_get_vid_reason (prt_dp_ds_struct *dp, uint8_t stream);
- parameters:
- dppointer to DisplayPort IP-core
- streamstream number (0 or 1)
- returns:
- PRT_DP_VID_DOWN_CLKNo video clock
- PRT_DP_VID_DOWN_LNKLink went down
- PRT_DP_VID_DOWN_ERRError
- PRT_DP_VID_DOWN_IDLEVideo idle
prt_dp_hpd_get
- description: Gets HPD status.
- syntax: uint8_t prt_dp_hpd_get (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns:
- PRT_DP_HPD_UNPLUGHPD deasserted
- PRT_DP_HPD_PLUGHPD asserted
- PRT_DP_HPD_IRQHPD interrupt
prt_dp_is_lnk_up
- description: Check if the link is up.
- syntax: bool prt_dp_is_lnk_up (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when the link is up, else false.
prt_dp_is_trn_pass
- description: Check if the link training passed.
- syntax: bool prt_dp_is_trn_pass (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when the training passed, else false.
prt_dp_is_vid_up
- description: Check if the video stream is up.
- syntax: bool prt_dp_is_vid_up (prt_dp_ds_struct *dp, uint8_t stream);
- parameters:
- dppointer to DisplayPort IP-core
- streamstream number (0 or 1)
- returns: true when the video is up, else false.
prt_dprx_hpd
- description: Sets DPRX HPD.
- syntax: uint8_t prt_dprx_hpd (prt_dp_ds_struct *dp, uint8_t hpd);
- parameters:
- dppointer to DisplayPort IP-core
- hpdhot plug state
- PRT_DP_HPD_UNPLUGHPD deassert
- PRT_DP_HPD_PLUGHPD assert
- PRT_DP_HPD_IRQHPD interrupt
- returns: none
Transmitter
prt_dptx_vid_str
- description: Starts the video stream.
- syntax: uint8_t prt_dptx_vid_str (prt_dp_ds_struct *dp, uint8_t stream);
- parameters:
- dppointer to DisplayPort IP-core
- streamstream number (0 or 1)
- returns: true when the video is started, else false.
prt_dptx_vid_stp
- description: Stops the video stream.
- syntax: uint8_t prt_dptx_vid_stp (prt_dp_ds_struct *dp, uint8_t stream);
- parameters:
- dppointer to DisplayPort IP-core
- streamstream number (0 or 1)
- returns: true when the video is stopped, else false.
prt_dptx_msa_set
- description: Sets the Main Stream Attributes (MSA)
- syntax: uint8_t prt_dptx_msa_set (prt_dp_ds_struct *dp, prt_dp_tp_struct *tp, uint8_t stream);
- parameters:
- dppointer to DisplayPort IP-core
- tppointer to timing parameters
- streamstream number (0 or 1)
- returns: true when ok, ekse false.
prt_dptx_dpcd_wr
- description: Write DPCD data.
- syntax: uint8_t prt_dptx_dpcd_wr (prt_dp_ds_struct *dp, uint32_t adr, uint8_t len, uint8_t *dat);
- parameters:
- dppointer to DisplayPort IP-core
- adrDPCD address
- lenDPCD length (1 - 16 bytes)
- datpointer to DPCD data
- returns: true when successful, else false.
prt_dptx_dpcd_rd
- description: Read DPCD data.
- syntax: uint8_t prt_dptx_dpcd_rd (prt_dp_ds_struct *dp, uint32_t adr, uint8_t len, uint8_t *dat);
- parameters:
- dppointer to DisplayPort IP-core
- adrDPCD address
- lenDPCD length (1 - 16 bytes)
- datpointer to DPCD data
- returns: true when successful, else false.
prt_dptx_mst_str
- description: Starts multi stream transport.
- syntax: uint8_t prt_dptx_mst_str (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when successful, else false.
prt_dptx_mst_stp
- description: Stops multi stream transport.
- syntax: uint8_t prt_dptx_mst_stp (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when successful, else false.
prt_dptx_trn
- description: Starts link training.
- syntax: uint8_t prt_dptx_trn (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: true when successful, else false.
prt_dptx_edid_rd
- description: Read EDID data from DP sink.
- syntax: uint8_t prt_dptx_edid_rd (prt_dp_ds_struct *dp, uint16_t adr, uint16_t len, uint8_t *dat);
- parameters:
- dppointer to DisplayPort IP-core
- adrbase address
- lenlength
- datpointer to data buffer
- returns: true when successful, else false.
Receiver
prt_dprx_phy_rst_ack
- description: Acknowledge the driver that the PHY reset has been completed.
- syntax: void prt_dprx_phy_rst_ack (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
prt_dprx_tp_get
- description: Gets DPRX timing parameters.
- syntax: prt_dp_tp_struct prt_dprx_tp_get (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: pointer to timing parameters
prt_dprx_get_trn_tps
- description: Gets current training pattern.
- syntax: uint8_t prt_dprx_get_trn_tps (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns:
- 0None
- 1TPS1
- 2TPS2
- 3TPS3
- 4TPS4
prt_dprx_edid_wr
- description: Write EDID data to policy maker.
- syntax: uint8_t prt_dprx_edid_wr (prt_dp_ds_struct *dp, uint16_t len, uint8_t *dat);
- parameters:
- dppointer to DisplayPort IP-core
- lenlength
- datpointer to data buffer
- returns: true when successful, else false.
prt_dprx_dpcd_blk_set
- description: The function sets the address of the DPCD block. There are in total 16 blocks.
- syntax: uint8_t prt_dprx_dpcd_blk_set (prt_dp_ds_struct *dp, uint8_t idx, uint32_t adr);
- parameters:
- dppointer to DisplayPort IP-core
- idxindex (0 - 15)
- adrDPCD base address
- returns: true when successful, else false.
prt_dprx_dpcd_ack
- description: Answers the pending DPCD transaction with an acknowledge. Called after the DPCD call back has handled the transaction.
- syntax: void prt_dprx_dpcd_ack (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
prt_dprx_dpcd_nack
- description: Answers the pending DPCD transaction with a not acknowledge.
- syntax: void prt_dprx_dpcd_nack (prt_dp_ds_struct *dp);
- parameters:
- dppointer to DisplayPort IP-core
- returns: none
Callbacks
The callback functions are used by the driver to signal the application about an event. Functions are registered using the prt_dp_set_cb function. The driver decodes the mail from the policy maker in prt_dp_mail_dec, which runs from prt_dp_irq_handler, and calls the handler from there. A handler therefore runs in interrupt context and should be kept short: note what happened and leave the work to the main loop. The handler names below are the ones used in the reference design. The diagram shows the DP states and the callbacks that follow from them.
Figure 1: DP callbacks
dptx_hpd_cb
registered with: PRT_DP_CB_HPD
description: The function is called on a hot plug event of the transmitter: a sink was plugged in, a sink was removed, or a sink issued an HPD pulse.
dp_sta_cb
registered with: PRT_DP_CB_STA
description: The function is called when the policy maker answers a prt_dp_sta request. Since that request does not block, this is where the reply arrives. The values are read with prt_dp_get_sta.
dp_trn_cb
registered with: PRT_DP_CB_TRN
description: The function is called when the training status is updated. prt_dp_is_trn_pass tells whether the link training passed.
dprx_pwr_ctl_cb
registered with: PRT_DP_CB_PWR_CTL
description: The function is called when the source changes the power state of the receiver. This callback is for the receiver only.
dprx_phy_rst_cb
registered with: PRT_DP_CB_PHY_RST
description: The function is called during the link training and can be used to reset the PHY. The receiver acknowledges the reset with prt_dprx_phy_rst_ack.
dptx_phy_rate_cb / dprx_phy_rate_cb
registered with: PRT_DP_CB_PHY_RATE
description: The function is called when the policy maker requests a new line rate. The requested rate is read with prt_dp_get_lnk_rate.
dptx_phy_vap_cb
registered with: PRT_DP_CB_PHY_VAP
description: The function is called when the policy maker requests to update the voltage swing and pre-emphasis levels. The requested levels are read with prt_dp_get_lnk_volt and prt_dp_get_lnk_pre.
dp_lnk_cb
registered with: PRT_DP_CB_LNK
description: The function is called when the link status is updated. prt_dp_is_lnk_up gives the state, and prt_dp_get_lnk_reason the reason for a link down.
dp_vid_cb
registered with: PRT_DP_CB_VID
description: The function is called when the video stream status is updated. prt_dp_is_vid_up gives the state, and prt_dp_get_vid_reason the reason a stream went down.
dprx_msa_cb
registered with: PRT_DP_CB_MSA
description: The function is called when the receiver received updated main stream attributes. The video timing parameters are read with prt_dprx_tp_get.
dprx_dpcd_cb
registered with: PRT_DP_CB_DPCD
description: The function is called when the receiver received a DPCD command. The command is inspected with prt_dp_dpcd_cmd_is_rd, prt_dp_dpcd_cmd_is_wr, prt_dp_dpcd_adr_get, prt_dp_dpcd_len_get and prt_dp_dpcd_dat_get, and answered with prt_dprx_dpcd_ack or prt_dprx_dpcd_nack.
dp_debug_cb
registered with: PRT_DP_CB_DBG
description: The function is called when the policy maker sends a debug byte, which is read with prt_dp_debug_get.