drm/dp: Pull drm_dp_link_power_up/down from Tegra to common drm_dp_helper
Subsystems (6)
PATCH v2 1/5 drm/dp: Pull drm_dp_link_power_up/down from Tegra to common drm_dp_helper
From: Andy Yan <[email protected]>
The helper functions drm_dp_link_power_up/down were moved to Tegra DRM in commit 9a42c7c647a9 ("drm/tegra: Move drm_dp_link helpers to Tegra DRM")".
Now since more and more users are duplicating the same code in their own drivers, it's time to make them as DRM DP common helpers again.
---
Changes in v2:
- Fix commit message as suggested by Dmitry
drivers/gpu/drm/display/drm_dp_helper.c | 69 +++++++++++++++++++++++++ drivers/gpu/drm/tegra/dp.c | 67 ------------------------ drivers/gpu/drm/tegra/dp.h | 2 - drivers/gpu/drm/tegra/sor.c | 4 +- include/drm/display/drm_dp_helper.h | 2 + 5 files changed, 73 insertions(+), 71 deletions(-)
drivers/gpu/drm/display/drm_dp_helper.c +69 -0
@@ -838,6 +838,75 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, }EXPORT_SYMBOL (drm_dp_dpcd_read_phy_link_status); +/** +* drm_dp_link_power_up() - power up a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D0 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +/* +* According to the DP 1.1 specification, a "Sink Device must exit the +* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink +* Control Field" (register 0x600). +*/ +usleep_range (1000 ,2000 ); + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_up); + +/** +* drm_dp_link_power_down() - power down a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D3 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_down); +static int read_payload_update_status (struct drm_dp_aux *aux) {int ret;
drivers/gpu/drm/tegra/dp.c +0 -67
73 lines not on this page · raw message
drivers/gpu/drm/tegra/dp.h +0 -2
@@ -164,8 +164,6 @@ int drm_dp_link_remove_rate(struct drm_dp_link *link, unsigned long rate);void drm_dp_link_update_rates (struct drm_dp_link *link);int drm_dp_link_probe (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link);int drm_dp_link_configure (struct drm_dp_aux *aux,struct drm_dp_link *link); int drm_dp_link_choose(struct drm_dp_link *link, const struct drm_display_mode *mode,
drivers/gpu/drm/tegra/sor.c +2 -2
@@ -2666,7 +2666,7 @@ static void tegra_sor_dp_disable(struct drm_encoder *encoder)* the AUX transactions would just be timing out. */ if (output->connector.status != connector_status_disconnected) { - err =drm_dp_link_power_down (sor->aux, &sor->link); + err =drm_dp_link_power_down (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power down link: %d\n" , err);
@@ -2882,7 +2882,7 @@ static void tegra_sor_dp_enable(struct drm_encoder *encoder)else dev_dbg (sor->dev,"link training succeeded\n" ); - err =drm_dp_link_power_up (sor->aux, &sor->link); + err =drm_dp_link_power_up (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power up DP link: %d\n" , err);
include/drm/display/drm_dp_helper.h +2 -0
@@ -566,6 +566,8 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,int drm_dp_dpcd_read_phy_link_status (struct drm_dp_aux *aux,enum drm_dp_phy dp_phy,u8 link_status[DP_LINK_STATUS_SIZE ]); +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision); +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision);int drm_dp_dpcd_write_payload (struct drm_dp_aux *aux,int vcpid,u8 start_time_slot,u8 time_slot_count);
Signature · 1 line
2.43.0
PATCH v2 2/5 drm/bridge: cdns-mhdp8546: Switch to common helpers to power up/down dp link
From: Andy Yan <[email protected]>
Use the common dp link power up/down helpers to avoid duplicating code.
---
(no changes since v1)
.../drm/bridge/cadence/cdns-mhdp8546-core.c | 74 +------------------ 1 file changed, 2 insertions(+), 72 deletions(-)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +2 -72
@@ -545,76 +545,6 @@ int cdns_mhdp_adjust_lt(struct cdns_mhdp_device *mhdp, unsigned int nlanes,return ret; } -/** -* cdns_mhdp_link_power_up() - power up a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -static -int cdns_mhdp_link_power_up (struct drm_dp_aux *aux,struct cdns_mhdp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -/* -* According to the DP 1.1 specification, a "Sink Device must exit the -* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink -* Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - -return 0 ; -} - -/** -* cdns_mhdp_link_power_down() - power down a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -static -int cdns_mhdp_link_power_down (struct drm_dp_aux *aux, -struct cdns_mhdp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D3 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -return 0 ; -} -/** * cdns_mhdp_link_configure() - configure a DisplayPort link * @aux: DisplayPort AUX channel
@@ -1453,7 +1383,7 @@ static int cdns_mhdp_link_up(struct cdns_mhdp_device *mhdp) mhdp->link.capabilities |=DP_LINK_CAP_ENHANCED_FRAMING ;dev_dbg (mhdp->dev,"Set sink device power state via DPCD\n" ); -cdns_mhdp_link_power_up (&mhdp->aux, &mhdp->link); +drm_dp_link_power_up (&mhdp->aux, mhdp->link.revision);cdns_mhdp_fill_sink_caps (mhdp, dpcd);
@@ -1500,7 +1430,7 @@ static void cdns_mhdp_link_down(struct cdns_mhdp_device *mhdp)WARN_ON (!mutex_is_locked (&mhdp->link_mutex));if (mhdp->plugged) -cdns_mhdp_link_power_down (&mhdp->aux, &mhdp->link); +drm_dp_link_power_down (&mhdp->aux, mhdp->link.revision); mhdp->link_up = false; }
Signature · 1 line
2.43.0
PATCH v2 3/5 drm/bridge: anx6345: Switch to common helpers to power up/down dp link
In reply to Andy YanFrom: Andy Yan <[email protected]>
Use the common dp link power up/down helpers to avoid duplicating code.
---
(no changes since v1)
.../drm/bridge/analogix/analogix-anx6345.c | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix-anx6345.c +1 -29
@@ -143,35 +143,7 @@ static int anx6345_dp_link_training(struct anx6345 *anx6345)if (err)return err; -/* -* Power up the sink (DP_SET_POWER register is only available on DPCD -* v1.1 and later). -*/ -if (anx6345->dpcd[DP_DPCD_REV ] >=0x11 ) { - err =drm_dp_dpcd_readb (&anx6345->aux,DP_SET_POWER , &dpcd[0 ]); -if (err <0 ) { -DRM_ERROR ("Failed to read DP_SET_POWER register: %d\n" , - err); -return err; - } - - dpcd[0 ] &= ~DP_SET_POWER_MASK ; - dpcd[0 ] |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (&anx6345->aux,DP_SET_POWER , dpcd[0 ]); -if (err <0 ) { -DRM_ERROR ("Failed to power up DisplayPort link: %d\n" , - err); -return err; - } - -/* -* According to the DP 1.1 specification, a "Sink Device must -* exit the power saving state within 1 ms" (Section 2.5.3.1, -* Table 5-52, "Sink Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - } +drm_dp_link_power_up (&anx6345->aux, anx6345->dpcd[DP_DPCD_REV ]);/* Possibly enable downspread on the sink */ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
Signature · 1 line
2.43.0
PATCH v2 4/5 drm/bridge: anx78xx: Switch to common helpers to power up/down dp link
In reply to Andy YanFrom: Andy Yan <[email protected]>
Use the common dp link power up/down helpers to avoid duplicating code.
---
(no changes since v1)
.../drm/bridge/analogix/analogix-anx78xx.c | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c +1 -29
@@ -656,35 +656,7 @@ static int anx78xx_dp_link_training(struct anx78xx *anx78xx)if (err)return err; -/* -* Power up the sink (DP_SET_POWER register is only available on DPCD -* v1.1 and later). -*/ -if (anx78xx->dpcd[DP_DPCD_REV ] >=0x11 ) { - err =drm_dp_dpcd_readb (&anx78xx->aux,DP_SET_POWER , &dpcd[0 ]); -if (err <0 ) { -DRM_ERROR ("Failed to read DP_SET_POWER register: %d\n" , - err); -return err; - } - - dpcd[0 ] &= ~DP_SET_POWER_MASK ; - dpcd[0 ] |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (&anx78xx->aux,DP_SET_POWER , dpcd[0 ]); -if (err <0 ) { -DRM_ERROR ("Failed to power up DisplayPort link: %d\n" , - err); -return err; - } - -/* -* According to the DP 1.1 specification, a "Sink Device must -* exit the power saving state within 1 ms" (Section 2.5.3.1, -* Table 5-52, "Sink Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - } +drm_dp_link_power_up (&anx78xx->aux, anx78xx->dpcd[DP_DPCD_REV ]);/* Possibly enable downspread on the sink */ err = regmap_write(anx78xx->map[I2C_IDX_TX_P0],
Signature · 1 line
2.43.0
PATCH v2 5/5 drm/bridge: it6505: Switch to common helpers to power up/down dp link
In reply to Andy YanFrom: Andy Yan <[email protected]>
Use the common dp link power up/down helpers to avoid duplicating code.
---
(no changes since v1)
drivers/gpu/drm/bridge/ite-it6505.c | 46 +++-------------------------- 1 file changed, 4 insertions(+), 42 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +4 -42
@@ -771,40 +771,6 @@ static void it6505_calc_video_info(struct it6505 *it6505) DRM_MODE_ARG(&it6505->video_info)); } -static int it6505_drm_dp_link_set_power (struct drm_dp_aux *aux, -struct it6505_drm_dp_link *link, -u8 mode) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <DPCD_V_1_1 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |= mode; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -if (mode ==DP_SET_POWER_D0 ) { -/* -* According to the DP 1.1 specification, a "Sink Device must -* exit the power saving state within 1 ms" (Section 2.5.3.1, -* Table 5-52, "Sink Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - } - -return 0 ; -} -static void it6505_clear_int (struct it6505 *it6505) {it6505_write (it6505,INT_STATUS_01 ,0xFF );
@@ -2578,8 +2544,7 @@ static void it6505_irq_hpd(struct it6505 *it6505) } it6505->auto_train_retry =AUTO_TRAIN_RETRY ; -it6505_drm_dp_link_set_power (&it6505->aux, &it6505->link, -DP_SET_POWER_D0 ); +drm_dp_link_power_up (&it6505->aux, it6505->link.revision); dp_sink_count =it6505_dpcd_read (it6505,DP_SINK_COUNT ); it6505->sink_count =DP_GET_SINK_COUNT (dp_sink_count);
@@ -2910,8 +2875,7 @@ static enum drm_connector_status it6505_detect(struct it6505 *it6505) }if (it6505->hpd_state) { -it6505_drm_dp_link_set_power (&it6505->aux, &it6505->link, -DP_SET_POWER_D0 ); +drm_dp_link_power_up (&it6505->aux, it6505->link.revision); dp_sink_count =it6505_dpcd_read (it6505,DP_SINK_COUNT ); it6505->sink_count =DP_GET_SINK_COUNT (dp_sink_count); DRM_DEV_DEBUG_DRIVER(dev, "it6505->sink_count:%d branch:%d",
@@ -3233,8 +3197,7 @@ static void it6505_bridge_atomic_enable(struct drm_bridge *bridge,it6505_int_mask_enable (it6505);it6505_video_reset (it6505); -it6505_drm_dp_link_set_power (&it6505->aux, &it6505->link, -DP_SET_POWER_D0 ); +drm_dp_link_power_up (&it6505->aux, it6505->link.revision); } static void it6505_bridge_atomic_disable(struct drm_bridge *bridge,
@@ -3246,8 +3209,7 @@ static void it6505_bridge_atomic_disable(struct drm_bridge *bridge,DRM_DEV_DEBUG_DRIVER (dev,"start" );if (it6505->powered) { -it6505_drm_dp_link_set_power (&it6505->aux, &it6505->link, -DP_SET_POWER_D3 ); +drm_dp_link_power_down (&it6505->aux, it6505->link.revision);it6505_video_disable (it6505); } }
Signature · 1 line
2.43.0
Hello Dmitry,
Could you take this series? If so, merging it earlier can avoid future conflicts from other patches.
Besides, I can update my DP driver based on drm-misc-next.
Quoted 230 lines · Andy Yan
From: Andy Yan <[email protected]>
The helper functions drm_dp_link_power_up/down were moved to Tegra DRM in commit
9a42c7c647a9("drm/tegra: Movedrm_dp_linkhelpers to Tegra DRM")".Now since more and more users are duplicating the same code in their own drivers, it's time to make them as DRM DP common helpers again.
Signed-off-by Andy Yan <[email protected]>Acked-by Dmitry Baryshkov <[email protected]>---
Changes in v2:
- Fix commit message as suggested by Dmitrydrivers/gpu/drm/display/drm_dp_helper.c | 69 +++++++++++++++++++++++++ drivers/gpu/drm/tegra/dp.c | 67 ------------------------ drivers/gpu/drm/tegra/dp.h | 2 - drivers/gpu/drm/tegra/sor.c | 4 +- include/drm/display/drm_dp_helper.h | 2 + 5 files changed, 73 insertions(+), 71 deletions(-)drivers/gpu/drm/display/drm_dp_helper.c +69
-0@@ -838,6 +838,75 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, }EXPORT_SYMBOL (drm_dp_dpcd_read_phy_link_status); +/** +* drm_dp_link_power_up() - power up a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D0 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +/* +* According to the DP 1.1 specification, a "Sink Device must exit the +* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink +* Control Field" (register 0x600). +*/ +usleep_range (1000 ,2000 ); + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_up); + +/** +* drm_dp_link_power_down() - power down a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D3 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_down); +static int read_payload_update_status (struct drm_dp_aux *aux) {int ret;drivers/gpu/drm/tegra/dp.c +0
-67@@ -255,73 +255,6 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)return 0 ; } -/** -* drm_dp_link_power_up() - power up a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -/* -* According to the DP 1.1 specification, a "Sink Device must exit the -* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink -* Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - -return 0 ; -} - -/** -* drm_dp_link_power_down() - power down a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D3 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -return 0 ; -} -/** * drm_dp_link_configure() - configure a DisplayPort link * @aux: DisplayPort AUX channel drivers/gpu/drm/tegra/dp.h +0
-2@@ -164,8 +164,6 @@ int drm_dp_link_remove_rate(struct drm_dp_link *link, unsigned long rate);void drm_dp_link_update_rates (struct drm_dp_link *link);int drm_dp_link_probe (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link);int drm_dp_link_configure (struct drm_dp_aux *aux,struct drm_dp_link *link); int drm_dp_link_choose(struct drm_dp_link *link, const struct drm_display_mode *mode,drivers/gpu/drm/tegra/sor.c +2
-2@@ -2666,7 +2666,7 @@ static void tegra_sor_dp_disable(struct drm_encoder *encoder)* the AUX transactions would just be timing out. */ if (output->connector.status != connector_status_disconnected) { - err =drm_dp_link_power_down (sor->aux, &sor->link); + err =drm_dp_link_power_down (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power down link: %d\n" , err);@@ -2882,7 +2882,7 @@ static void tegra_sor_dp_enable(struct drm_encoder *encoder)else dev_dbg (sor->dev,"link training succeeded\n" ); - err =drm_dp_link_power_up (sor->aux, &sor->link); + err =drm_dp_link_power_up (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power up DP link: %d\n" , err);include/drm/display/drm_dp_helper.h +2
-0@@ -566,6 +566,8 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,int drm_dp_dpcd_read_phy_link_status (struct drm_dp_aux *aux,enum drm_dp_phy dp_phy,u8 link_status[DP_LINK_STATUS_SIZE ]); +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision); +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision);int drm_dp_dpcd_write_payload (struct drm_dp_aux *aux,int vcpid,u8 start_time_slot,u8 time_slot_count);Signature · 1 line
2.43.0
Quoted 4 lines · Andy Yan
Hello Dmitry,
Could you take this series? If so, merging it earlier can avoid future conflicts from other patches.
Besides, I can update my DP driver based on drm-misc-next.
I'd really like an ack from Thiery or Mikko.
If tere is none (and no objections), I'll push it on Monday.
Quoted 232 lines
Quoted 230 lines · Andy Yan
From: Andy Yan <[email protected]>
The helper functions drm_dp_link_power_up/down were moved to Tegra DRM in commit
9a42c7c647a9("drm/tegra: Movedrm_dp_linkhelpers to Tegra DRM")".Now since more and more users are duplicating the same code in their own drivers, it's time to make them as DRM DP common helpers again.
Signed-off-by Andy Yan <[email protected]>Acked-by Dmitry Baryshkov <[email protected]>---
Changes in v2:
- Fix commit message as suggested by Dmitrydrivers/gpu/drm/display/drm_dp_helper.c | 69 +++++++++++++++++++++++++ drivers/gpu/drm/tegra/dp.c | 67 ------------------------ drivers/gpu/drm/tegra/dp.h | 2 - drivers/gpu/drm/tegra/sor.c | 4 +- include/drm/display/drm_dp_helper.h | 2 + 5 files changed, 73 insertions(+), 71 deletions(-)drivers/gpu/drm/display/drm_dp_helper.c +69
-0@@ -838,6 +838,75 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, }EXPORT_SYMBOL (drm_dp_dpcd_read_phy_link_status); +/** +* drm_dp_link_power_up() - power up a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D0 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +/* +* According to the DP 1.1 specification, a "Sink Device must exit the +* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink +* Control Field" (register 0x600). +*/ +usleep_range (1000 ,2000 ); + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_up); + +/** +* drm_dp_link_power_down() - power down a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D3 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_down); +static int read_payload_update_status (struct drm_dp_aux *aux) {int ret;drivers/gpu/drm/tegra/dp.c +0
-67@@ -255,73 +255,6 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)return 0 ; } -/** -* drm_dp_link_power_up() - power up a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -/* -* According to the DP 1.1 specification, a "Sink Device must exit the -* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink -* Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - -return 0 ; -} - -/** -* drm_dp_link_power_down() - power down a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D3 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -return 0 ; -} -/** * drm_dp_link_configure() - configure a DisplayPort link * @aux: DisplayPort AUX channel drivers/gpu/drm/tegra/dp.h +0
-2@@ -164,8 +164,6 @@ int drm_dp_link_remove_rate(struct drm_dp_link *link, unsigned long rate);void drm_dp_link_update_rates (struct drm_dp_link *link);int drm_dp_link_probe (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link);int drm_dp_link_configure (struct drm_dp_aux *aux,struct drm_dp_link *link); int drm_dp_link_choose(struct drm_dp_link *link, const struct drm_display_mode *mode,drivers/gpu/drm/tegra/sor.c +2
-2@@ -2666,7 +2666,7 @@ static void tegra_sor_dp_disable(struct drm_encoder *encoder)* the AUX transactions would just be timing out. */ if (output->connector.status != connector_status_disconnected) { - err =drm_dp_link_power_down (sor->aux, &sor->link); + err =drm_dp_link_power_down (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power down link: %d\n" , err);@@ -2882,7 +2882,7 @@ static void tegra_sor_dp_enable(struct drm_encoder *encoder)else dev_dbg (sor->dev,"link training succeeded\n" ); - err =drm_dp_link_power_up (sor->aux, &sor->link); + err =drm_dp_link_power_up (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power up DP link: %d\n" , err);include/drm/display/drm_dp_helper.h +2
-0@@ -566,6 +566,8 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,int drm_dp_dpcd_read_phy_link_status (struct drm_dp_aux *aux,enum drm_dp_phy dp_phy,u8 link_status[DP_LINK_STATUS_SIZE ]); +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision); +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision);int drm_dp_dpcd_write_payload (struct drm_dp_aux *aux,int vcpid,u8 start_time_slot,u8 time_slot_count);Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes Dmitry
Gentle ping......
Quoted 252 lines · Dmitry Baryshkov
Quoted 4 lines · Andy Yan
Hello Dmitry,
Could you take this series? If so, merging it earlier can avoid future conflicts from other patches.
Besides, I can update my DP driver based on drm-misc-next.I'd really like an ack from Thiery or Mikko.
If tere is none (and no objections), I'll push it on Monday.
Quoted 232 lines
Quoted 230 lines · Andy Yan
From: Andy Yan <[email protected]>
The helper functions drm_dp_link_power_up/down were moved to Tegra DRM in commit
9a42c7c647a9("drm/tegra: Movedrm_dp_linkhelpers to Tegra DRM")".Now since more and more users are duplicating the same code in their own drivers, it's time to make them as DRM DP common helpers again.
Signed-off-by Andy Yan <[email protected]>Acked-by Dmitry Baryshkov <[email protected]>---
Changes in v2:
- Fix commit message as suggested by Dmitrydrivers/gpu/drm/display/drm_dp_helper.c | 69 +++++++++++++++++++++++++ drivers/gpu/drm/tegra/dp.c | 67 ------------------------ drivers/gpu/drm/tegra/dp.h | 2 - drivers/gpu/drm/tegra/sor.c | 4 +- include/drm/display/drm_dp_helper.h | 2 + 5 files changed, 73 insertions(+), 71 deletions(-)drivers/gpu/drm/display/drm_dp_helper.c +69
-0@@ -838,6 +838,75 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, }EXPORT_SYMBOL (drm_dp_dpcd_read_phy_link_status); +/** +* drm_dp_link_power_up() - power up a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D0 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +/* +* According to the DP 1.1 specification, a "Sink Device must exit the +* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink +* Control Field" (register 0x600). +*/ +usleep_range (1000 ,2000 ); + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_up); + +/** +* drm_dp_link_power_down() - power down a DisplayPort link +* @aux: DisplayPort AUX channel +* @revision: DPCD revision supported on the link +* +* Returns 0 on success or a negative error code on failure. +*/ +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision) +{ +u8 value; +int err; + +/* DP_SET_POWER register is only available on DPCD v1.1 and later */ +if (revision <DP_DPCD_REV_11 ) +return 0 ; + + err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); +if (err <0 ) +return err; + + value &= ~DP_SET_POWER_MASK ; + value |=DP_SET_POWER_D3 ; + + err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (drm_dp_link_power_down); +static int read_payload_update_status (struct drm_dp_aux *aux) {int ret;drivers/gpu/drm/tegra/dp.c +0
-67@@ -255,73 +255,6 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)return 0 ; } -/** -* drm_dp_link_power_up() - power up a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D0 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -/* -* According to the DP 1.1 specification, a "Sink Device must exit the -* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink -* Control Field" (register 0x600). -*/ -usleep_range (1000 ,2000 ); - -return 0 ; -} - -/** -* drm_dp_link_power_down() - power down a DisplayPort link -* @aux: DisplayPort AUX channel -* @link: pointer to a structure containing the link configuration -* -* Returns 0 on success or a negative error code on failure. -*/ -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link) -{ -u8 value; -int err; - -/* DP_SET_POWER register is only available on DPCD v1.1 and later */ -if (link->revision <0x11 ) -return 0 ; - - err =drm_dp_dpcd_readb (aux,DP_SET_POWER , &value); -if (err <0 ) -return err; - - value &= ~DP_SET_POWER_MASK ; - value |=DP_SET_POWER_D3 ; - - err =drm_dp_dpcd_writeb (aux,DP_SET_POWER , value); -if (err <0 ) -return err; - -return 0 ; -} -/** * drm_dp_link_configure() - configure a DisplayPort link * @aux: DisplayPort AUX channel drivers/gpu/drm/tegra/dp.h +0
-2@@ -164,8 +164,6 @@ int drm_dp_link_remove_rate(struct drm_dp_link *link, unsigned long rate);void drm_dp_link_update_rates (struct drm_dp_link *link);int drm_dp_link_probe (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_up (struct drm_dp_aux *aux,struct drm_dp_link *link); -int drm_dp_link_power_down (struct drm_dp_aux *aux,struct drm_dp_link *link);int drm_dp_link_configure (struct drm_dp_aux *aux,struct drm_dp_link *link); int drm_dp_link_choose(struct drm_dp_link *link, const struct drm_display_mode *mode,drivers/gpu/drm/tegra/sor.c +2
-2@@ -2666,7 +2666,7 @@ static void tegra_sor_dp_disable(struct drm_encoder *encoder)* the AUX transactions would just be timing out. */ if (output->connector.status != connector_status_disconnected) { - err =drm_dp_link_power_down (sor->aux, &sor->link); + err =drm_dp_link_power_down (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power down link: %d\n" , err);@@ -2882,7 +2882,7 @@ static void tegra_sor_dp_enable(struct drm_encoder *encoder)else dev_dbg (sor->dev,"link training succeeded\n" ); - err =drm_dp_link_power_up (sor->aux, &sor->link); + err =drm_dp_link_power_up (sor->aux, sor->link.revision);if (err <0 )dev_err (sor->dev,"failed to power up DP link: %d\n" , err);include/drm/display/drm_dp_helper.h +2
-0@@ -566,6 +566,8 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,int drm_dp_dpcd_read_phy_link_status (struct drm_dp_aux *aux,enum drm_dp_phy dp_phy,u8 link_status[DP_LINK_STATUS_SIZE ]); +int drm_dp_link_power_up (struct drm_dp_aux *aux,unsigned char revision); +int drm_dp_link_power_down (struct drm_dp_aux *aux,unsigned char revision);int drm_dp_dpcd_write_payload (struct drm_dp_aux *aux,int vcpid,u8 start_time_slot,u8 time_slot_count);Signature · 1 line
2.43.0Signature · 7 lines
With best wishes Dmitry _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Dmitry Baryshkov
AppliedQuoted 8 lines · Andy Yan
The helper functions drm_dp_link_power_up/down were moved to Tegra DRM in commit
9a42c7c647a9("drm/tegra: Movedrm_dp_linkhelpers to Tegra DRM")".Now since more and more users are duplicating the same code in their own drivers, it's time to make them as DRM DP common helpers again.
[...]
Applied to drm-misc-next, thanks!
[1/5] drm/dp: Pull drm_dp_link_power_up/down from Tegra to common drm_dp_helper
commit: 09cdda7a60f45784cebddf1fa2109d6279f9890b
[2/5] drm/bridge: cdns-mhdp8546: Switch to common helpers to power up/down dp link
commit: 23ee8c6b34fdfed970e2fae2b2ac5635303d77b8
[3/5] drm/bridge: anx6345: Switch to common helpers to power up/down dp link
commit: 4adde49ba497ebd376a164c517152670e4f8eedd
[4/5] drm/bridge: anx78xx: Switch to common helpers to power up/down dp link
commit: 39f14a01994b5102bdc4632a339a59a03a2f89f3
[5/5] drm/bridge: it6505: Switch to common helpers to power up/down dp link
commit: f09d9f921f2b7b78e73e9f192a9c08b534b8e5e5Best regards,
Signature · 2 lines
With best wishes Dmitry