drm: bridge: dw_hdmi: Misc enable/disable, CEC and EDID cleanup
Subsystems (4)
Jonas Karlman
reviewerv2 cover drm: bridge: dw_hdmi: Misc enable/disable, CEC and EDID cleanup
This series ensure poweron/poweroff and CEC phys addr invalidation is happening under drm mode_config mutex lock, and also ensure EDID is updated (when the dw-hdmi connector is used) after a hotplug pulse.
These changes has mainly been tested on Rockchip devices together with a series [1] that add HDMI 2.0 4K@60Hz support to RK3228, RK3328, RK3399 and RK3568.
Rockchip use the dw-hdmi connector so this should also be validated with a driver that use the bridge connector.
Changes in v2:
- Add patch to disable scrambler feature when not supported
- Add patch to only notify connected status on HPD interrupt
- Update commit messages
- Collect r-b tags
- Rebased on next-20240906
[1] https://lore.kernel.org/r/[email protected]/
Jonas Karlman (10):
drm: bridge: dw_hdmi: Disable scrambler feature when not supported
drm: bridge: dw_hdmi: Only notify connected status on HPD interrupt
drm: bridge: dw_hdmi: Call poweron/poweroff from atomic enable/disable
drm: bridge: dw_hdmi: Use passed mode instead of stored previous_mode
drm: bridge: dw_hdmi: Fold poweron and setup functions
drm: bridge: dw_hdmi: Remove previous_mode and mode_set
drm: bridge: dw_hdmi: Invalidate CEC phys addr from connector detect
drm: bridge: dw_hdmi: Remove cec_notifier_mutex
drm: bridge: dw_hdmi: Update EDID during hotplug processing
drm: bridge: dw_hdmi: Use display_info is_hdmi and has_audio
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 150 +++++++--------------- 1 file changed, 43 insertions(+), 107 deletions(-)
Signature · 1 line
2.46.0
Jonas Karlman
reviewerPATCH v2 1/10 drm: bridge: dw_hdmi: Disable scrambler feature when not supported
The scrambler feature can be left enabled when hotplugging from a sink and mode that require scrambling to a sink that does not support SCDC or scrambling.
Typically a blank screen or 'no signal' message can be observed after using a HDMI 2.0 4K@60Hz mode and then hotplugging to a sink that only support HDMI 1.4.
Fix this by disabling the scrambler feature when SCDC is not supported.
---
v2: New patch
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2 -0
@@ -2117,6 +2117,8 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, HDMI_MC_SWRSTZ);drm_scdc_set_scrambling (hdmi->curr_conn,0 ); } + }else if (hdmi->version >=0x200a ) { +hdmi_writeb (hdmi,0 ,HDMI_FC_SCRAMBLER_CTRL ); }/* Set up horizontal active pixel width */
Signature · 1 line
2.46.0
Re: [PATCH v2 01/10] drm: bridge: dw_hdmi: Disable scrambler feature when not supported
Quoted 24 lines · Jonas Karlman
The scrambler feature can be left enabled when hotplugging from a sink and mode that require scrambling to a sink that does not support SCDC or scrambling.
Typically a blank screen or 'no signal' message can be observed after using a HDMI 2.0 4K@60Hz mode and then hotplugging to a sink that only support HDMI 1.4.
Fix this by disabling the scrambler feature when SCDC is not supported.
Fixes 264fce6cc2c1 ("drm/bridge: dw-hdmi: Add SCDC and TMDS Scrambling support")Reported-by Christopher Obbard <[email protected]>Signed-off-by Jonas Karlman <[email protected]>---
v2: New patch--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_av_composer(struct dw_hdmi *hdmi, · line 2124
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0@@ -2117,6 +2117,8 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, HDMI_MC_SWRSTZ);drm_scdc_set_scrambling (hdmi->curr_conn,0 ); } + }else if (hdmi->version >=0x200a ) { +hdmi_writeb (hdmi,0 ,HDMI_FC_SCRAMBLER_CTRL ); }/* Set up horizontal active pixel width */
Jonas Karlman
reviewerPATCH v2 2/10 drm: bridge: dw_hdmi: Only notify connected status on HPD interrupt
In reply to Jonas Karlmandrm_helper_hpd_irq_event() and drm_bridge_hpd_notify() may incorrectly be called with a connected status when HPD is high and RX sense is changed. This typically happen when the HDMI cable is unplugged, shortly before the HPD is changed to low.
Fix this by only notify connected status on the HPD interrupt when HPD is going high, not on the RX sense interrupt when RX sense is changed.
---
v2: New patch
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2 -1
@@ -3123,7 +3123,8 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)mutex_unlock (&hdmi->cec_notifier_mutex); } -if (phy_stat &HDMI_PHY_HPD ) +if ((intr_stat &HDMI_IH_PHY_STAT0_HPD ) && + (phy_stat &HDMI_PHY_HPD )) status = connector_status_connected;if (!(phy_stat & (HDMI_PHY_HPD |HDMI_PHY_RX_SENSE )))
Signature · 1 line
2.46.0
Neil Armstrong
maintainerRe: [PATCH v2 02/10] drm: bridge: dw_hdmi: Only notify connected status on HPD interrupt
Quoted 21 lines · Jonas Karlman
drm_helper_hpd_irq_event()anddrm_bridge_hpd_notify()may incorrectly be called with a connected status when HPD is high and RX sense is changed. This typically happen when the HDMI cable is unplugged, shortly before the HPD is changed to low.Fix this by only notify connected status on the HPD interrupt when HPD is going high, not on the RX sense interrupt when RX sense is changed.
Fixes da09daf88108 ("drm: bridge: dw_hdmi: only trigger hotplug event on link change")Signed-off-by Jonas Karlman <[email protected]>---
v2: New patch--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) · line 3130
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-1@@ -3123,7 +3123,8 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)mutex_unlock (&hdmi->cec_notifier_mutex); } -if (phy_stat &HDMI_PHY_HPD ) +if ((intr_stat &HDMI_IH_PHY_STAT0_HPD ) && + (phy_stat &HDMI_PHY_HPD )) status = connector_status_connected;if (!(phy_stat & (HDMI_PHY_HPD |HDMI_PHY_RX_SENSE )))
Perhaps this should be also checked for the other lines checking HDMI_PHY_HPD ?
Neil
Jonas Karlman
reviewerRe: [PATCH v2 02/10] drm: bridge: dw_hdmi: Only notify connected status on HPD interrupt
Hi Neil,
Quoted 25 lines · Neil Armstrong
Quoted 24 lines · Jonas Karlman
drm_helper_hpd_irq_event()anddrm_bridge_hpd_notify()may incorrectly be called with a connected status when HPD is high and RX sense is changed. This typically happen when the HDMI cable is unplugged, shortly before the HPD is changed to low.Fix this by only notify connected status on the HPD interrupt when HPD is going high, not on the RX sense interrupt when RX sense is changed.
Fixes da09daf88108 ("drm: bridge: dw_hdmi: only trigger hotplug event on link change")Signed-off-by Jonas Karlman <[email protected]>---
v2: New patch--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -3123,7 +3123,8 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)mutex_unlock (&hdmi->cec_notifier_mutex); }
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) · line 3130
Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-1-if (phy_stat &HDMI_PHY_HPD ) +if ((intr_stat &HDMI_IH_PHY_STAT0_HPD ) && + (phy_stat &HDMI_PHY_HPD )) status = connector_status_connected;if (!(phy_stat & (HDMI_PHY_HPD |HDMI_PHY_RX_SENSE )))Perhaps this should be also checked for the other lines checking
HDMI_PHY_HPD?
I think this is the only place we need to check to match the original intent of da09daf88108 ("drm: bridge: dw_hdmi: only trigger hotplug event on link change").
The interrupt pattern I can see when physically unplugging are:
- RX interrupt: HPD=high RX=low -> triggered connected event
- HPD interrupt: HPD=low RX=low -> trigger disconnected event
Based on the commit message the intent was to trigger hotplug event:
- when HPD goes high (plugin)
- when both HPD and RX sense has gone low (plugout)
For plugin we should only trigger when HPD=high at HPD interrupt, as is done after this patch, to avoid unnecessary events when RX changes.
For plugout the event should be triggered when both HPD=low and RX=low, that can happen at either HPD or RX interrupt.
This should probably be revisited in future, I think we should ignore RX sense and instead use a work queue and a small debounce timeout after HPD interrupt or similar, to better support EDID refresh. Something for a future series.
Regards,
Jonas
Quoted 2 lines
Neil
Jonas Karlman
reviewerPATCH v2 3/10 drm: bridge: dw_hdmi: Call poweron/poweroff from atomic enable/disable
In reply to Jonas KarlmanChange to only call poweron/poweroff from atomic_enable/atomic_disable ops instead of trying to be clever by keeping a bridge_is_on state and poweron/off in the hotplug irq handler.
The bridge is already enabled/disabled depending on connection state with the call to drm_helper_hpd_irq_event() in hotplug irq handler.
A benefit of this is that drm mode_config mutex is always held at poweron/off, something that may reduce the need for our own mutex.
---
v2: Update commit message
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 33 ++--------------------- 1 file changed, 2 insertions(+), 31 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2 -31
@@ -169,7 +169,6 @@ struct dw_hdmi {enum drm_connector_force force;/* mutex-protected force state */ struct drm_connector *curr_conn;/* current connector (only valid when !disabled) */ bool disabled;/* DRM has disabled our bridge */ -bool bridge_is_on;/* indicates the bridge is on */ bool rxsense;/* rxsense state */ u8 phy_mask;/* desired phy int mask settings */ u8 mc_clkdis;/* clock disable register */
@@ -2382,8 +2381,6 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)static void dw_hdmi_poweron (struct dw_hdmi *hdmi) { - hdmi->bridge_is_on = true; -/* * The curr_conn field is guaranteed to be valid here, as this function * is only be called when !hdmi->disabled.
@@ -2397,30 +2394,6 @@ static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) hdmi->phy.ops->disable (hdmi, hdmi->phy.data); hdmi->phy.enabled = false; } - - hdmi->bridge_is_on = false; -} - -static void dw_hdmi_update_power (struct dw_hdmi *hdmi) -{ -int force = hdmi->force; - -if (hdmi->disabled) { - force =DRM_FORCE_OFF ; - }else if (force ==DRM_FORCE_UNSPECIFIED ) { -if (hdmi->rxsense) - force =DRM_FORCE_ON ; -else - force =DRM_FORCE_OFF ; - } - -if (force ==DRM_FORCE_OFF ) { -if (hdmi->bridge_is_on) -dw_hdmi_poweroff (hdmi); - }else { -if (!hdmi->bridge_is_on) -dw_hdmi_poweron (hdmi); - } }/*
@@ -2545,7 +2518,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector)mutex_lock (&hdmi->mutex); hdmi->force = connector->force; -dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi);mutex_unlock (&hdmi->mutex); }
@@ -2954,7 +2926,7 @@ static void dw_hdmi_bridge_atomic_disable(struct drm_bridge *bridge,mutex_lock (&hdmi->mutex); hdmi->disabled = true; hdmi->curr_conn =NULL ; -dw_hdmi_update_power (hdmi); +dw_hdmi_poweroff (hdmi);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, false);mutex_unlock (&hdmi->mutex);
@@ -2973,7 +2945,7 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; -dw_hdmi_update_power (hdmi); +dw_hdmi_poweron (hdmi);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, true);mutex_unlock (&hdmi->mutex);
@@ -3072,7 +3044,6 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense)if (hpd) hdmi->rxsense = true; -dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi); }mutex_unlock (&hdmi->mutex);
Signature · 1 line
2.46.0
Re: [PATCH v2 03/10] drm: bridge: dw_hdmi: Call poweron/poweroff from atomic enable/disable
Quoted 96 lines · Jonas Karlman
Change to only call poweron/poweroff from atomic_enable/atomic_disable ops instead of trying to be clever by keeping a
bridge_is_onstate and poweron/off in the hotplug irq handler.The bridge is already enabled/disabled depending on connection state with the call to
drm_helper_hpd_irq_event()in hotplug irq handler.A benefit of this is that drm
mode_configmutex is always held at poweron/off, something that may reduce the need for our own mutex.Signed-off-by Jonas Karlman <[email protected]>---
v2: Update commit message--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 33 ++--------------------- 1 file changed, 2 insertions(+), 31 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-30@@ -169,7 +169,6 @@ struct dw_hdmi {enum drm_connector_force force;/* mutex-protected force state */ struct drm_connector *curr_conn;/* current connector (only valid when !disabled) */ bool disabled;/* DRM has disabled our bridge */ -bool bridge_is_on;/* indicates the bridge is on */ bool rxsense;/* rxsense state */ u8 phy_mask;/* desired phy int mask settings */ u8 mc_clkdis;/* clock disable register */ @@ -2382,8 +2381,6 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)static void dw_hdmi_poweron (struct dw_hdmi *hdmi) { - hdmi->bridge_is_on = true; -/* * The curr_conn field is guaranteed to be valid here, as this function * is only be called when !hdmi->disabled. @@ -2397,30 +2394,6 @@ static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) hdmi->phy.ops->disable (hdmi, hdmi->phy.data); hdmi->phy.enabled = false; } - - hdmi->bridge_is_on = false; -} - -static void dw_hdmi_update_power (struct dw_hdmi *hdmi) -{ -int force = hdmi->force; - -if (hdmi->disabled) { - force =DRM_FORCE_OFF ; - }else if (force ==DRM_FORCE_UNSPECIFIED ) { -if (hdmi->rxsense) - force =DRM_FORCE_ON ; -else - force =DRM_FORCE_OFF ; - } - -if (force ==DRM_FORCE_OFF ) { -if (hdmi->bridge_is_on) -dw_hdmi_poweroff (hdmi); - }else { -if (!hdmi->bridge_is_on) -dw_hdmi_poweron (hdmi); - } }/* @@ -2545,7 +2518,6 @@ static void dw_hdmi_connector_force(struct drm_connector *connector)mutex_lock (&hdmi->mutex); hdmi->force = connector->force; -dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi);mutex_unlock (&hdmi->mutex); }@@ -2954,7 +2926,7 @@ static void dw_hdmi_bridge_atomic_disable(struct drm_bridge *bridge,mutex_lock (&hdmi->mutex); hdmi->disabled = true; hdmi->curr_conn =NULL ; -dw_hdmi_update_power (hdmi); +dw_hdmi_poweroff (hdmi);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, false);mutex_unlock (&hdmi->mutex);@@ -2973,7 +2945,7 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; -dw_hdmi_update_power (hdmi); +dw_hdmi_poweron (hdmi);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, true);mutex_unlock (&hdmi->mutex);
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense) · line 3049
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-1@@ -3072,7 +3044,6 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense)if (hpd) hdmi->rxsense = true; -dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi); }mutex_unlock (&hdmi->mutex);
Jonas Karlman
reviewerPATCH v2 4/10 drm: bridge: dw_hdmi: Use passed mode instead of stored previous_mode
In reply to Jonas KarlmanUse the passed mode instead of mixing use of passed mode and the stored previous_mode. The passed mode is currenly always the previous_mode.
Also fix a small typo and add a variable to help shorten a code line.
---
v2: Update commit message, s/type/typo/
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -5
@@ -2240,6 +2240,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi,const struct drm_connector *connector, const struct drm_display_mode *mode) { + const struct drm_display_info *display = &connector->display_info;int ret;hdmi_disable_overflow_interrupts (hdmi);
@@ -2285,12 +2286,10 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, hdmi->hdmi_data.video_mode.mdataenablepolarity = true;/* HDMI Initialization Step B.1 */ -hdmi_av_composer (hdmi, &connector->display_info, mode); +hdmi_av_composer (hdmi, display, mode); -/* HDMI Initializateion Step B.2 */ - ret = hdmi->phy.ops->init (hdmi, hdmi->phy.data, - &connector->display_info, - &hdmi->previous_mode); +/* HDMI Initialization Step B.2 */ + ret = hdmi->phy.ops->init (hdmi, hdmi->phy.data, display, mode);if (ret)return ret; hdmi->phy.enabled = true;
Signature · 1 line
2.46.0
Re: [PATCH v2 04/10] drm: bridge: dw_hdmi: Use passed mode instead of stored previous_mode
Quoted 30 lines · Jonas Karlman
Use the passed mode instead of mixing use of passed mode and the stored
previous_mode. The passed mode is currenly always theprevious_mode.Also fix a small typo and add a variable to help shorten a code line.
Signed-off-by Jonas Karlman <[email protected]>---
v2: Update commit message, s/type/typo/--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-1@@ -2240,6 +2240,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi,const struct drm_connector *connector, const struct drm_display_mode *mode) { + const struct drm_display_info *display = &connector->display_info;int ret;hdmi_disable_overflow_interrupts (hdmi);@@ -2285,12 +2286,10 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, hdmi->hdmi_data.video_mode.mdataenablepolarity = true;/* HDMI Initialization Step B.1 */ -hdmi_av_composer (hdmi, &connector->display_info, mode); +hdmi_av_composer (hdmi, display, mode);
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static int dw_hdmi_setup(struct dw_hdmi *hdmi, · line 2295
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-4-/* HDMI Initializateion Step B.2 */ - ret = hdmi->phy.ops->init (hdmi, hdmi->phy.data, - &connector->display_info, - &hdmi->previous_mode); +/* HDMI Initialization Step B.2 */ + ret = hdmi->phy.ops->init (hdmi, hdmi->phy.data, display, mode);if (ret)return ret; hdmi->phy.enabled = true;
Jonas Karlman
reviewerPATCH v2 5/10 drm: bridge: dw_hdmi: Fold poweron and setup functions
In reply to Jonas KarlmanFold the poweron and setup functions into one function and use the adjusted_mode directly from the new crtc_state to remove the need of storing previous_mode.
---
v2: No change
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +8 -13
@@ -2236,9 +2236,9 @@ static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) HDMI_IH_MUTE_FC_STAT2); } -static int dw_hdmi_setup (struct dw_hdmi *hdmi, -const struct drm_connector *connector, -const struct drm_display_mode *mode) +static int dw_hdmi_poweron (struct dw_hdmi *hdmi, +const struct drm_connector *connector, +const struct drm_display_mode *mode) {const struct drm_display_info *display = &connector->display_info;int ret;
@@ -2378,15 +2378,6 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)hdmi_writeb (hdmi, ih_mute,HDMI_IH_MUTE ); } -static void dw_hdmi_poweron (struct dw_hdmi *hdmi) -{ -/* -* The curr_conn field is guaranteed to be valid here, as this function -* is only be called when !hdmi->disabled. -*/ -dw_hdmi_setup (hdmi, hdmi->curr_conn, &hdmi->previous_mode); -} -static void dw_hdmi_poweroff (struct dw_hdmi *hdmi) {if (hdmi->phy.enabled) {
@@ -2936,15 +2927,19 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, {struct dw_hdmi *hdmi = bridge->driver_private;struct drm_atomic_state *state = old_state->base.state; +const struct drm_display_mode *mode;struct drm_connector *connector; +struct drm_crtc *crtc; connector =drm_atomic_get_new_connector_for_encoder (state, bridge->encoder); + crtc =drm_atomic_get_new_connector_state (state, connector)->crtc; + mode = &drm_atomic_get_new_crtc_state (state, crtc)->adjusted_mode;mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; -dw_hdmi_poweron (hdmi); +dw_hdmi_poweron (hdmi, connector, mode);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, true);mutex_unlock (&hdmi->mutex);
Signature · 1 line
2.46.0
Re: [PATCH v2 05/10] drm: bridge: dw_hdmi: Fold poweron and setup functions
Quoted 55 lines · Jonas Karlman
Fold the poweron and setup functions into one function and use the
adjusted_modedirectly from the newcrtc_stateto remove the need of storingprevious_mode.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6
-12@@ -2236,9 +2236,9 @@ static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) HDMI_IH_MUTE_FC_STAT2); } -static int dw_hdmi_setup (struct dw_hdmi *hdmi, -const struct drm_connector *connector, -const struct drm_display_mode *mode) +static int dw_hdmi_poweron (struct dw_hdmi *hdmi, +const struct drm_connector *connector, +const struct drm_display_mode *mode) {const struct drm_display_info *display = &connector->display_info;int ret;@@ -2378,15 +2378,6 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)hdmi_writeb (hdmi, ih_mute,HDMI_IH_MUTE ); } -static void dw_hdmi_poweron (struct dw_hdmi *hdmi) -{ -/* -* The curr_conn field is guaranteed to be valid here, as this function -* is only be called when !hdmi->disabled. -*/ -dw_hdmi_setup (hdmi, hdmi->curr_conn, &hdmi->previous_mode); -} -static void dw_hdmi_poweroff (struct dw_hdmi *hdmi) {if (hdmi->phy.enabled) {@@ -2936,15 +2927,19 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, {struct dw_hdmi *hdmi = bridge->driver_private;struct drm_atomic_state *state = old_state->base.state; +const struct drm_display_mode *mode;struct drm_connector *connector; +struct drm_crtc *crtc; connector =drm_atomic_get_new_connector_for_encoder (state, bridge->encoder); + crtc =drm_atomic_get_new_connector_state (state, connector)->crtc;
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, · line 2945
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-1+ mode = &drm_atomic_get_new_crtc_state (state, crtc)->adjusted_mode;mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; -dw_hdmi_poweron (hdmi); +dw_hdmi_poweron (hdmi, connector, mode);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, true);mutex_unlock (&hdmi->mutex);
Jonas Karlman
reviewerPATCH v2 6/10 drm: bridge: dw_hdmi: Remove previous_mode and mode_set
In reply to Jonas KarlmanWith the use of adjusted_mode directly from the crtc_state there is no longer a need to store a copy in previous_mode, remove it and the now unneeded mode_set ops.
---
v2: No change
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -18
@@ -154,8 +154,6 @@ struct dw_hdmi {bool enabled; } phy; -struct drm_display_mode previous_mode; -struct i2c_adapter *ddc;void __iomem *regs;bool sink_is_hdmi;
@@ -165,7 +163,7 @@ struct dw_hdmi {struct pinctrl_state *default_state;struct pinctrl_state *unwedge_state; -struct mutex mutex;/* for state below and previous_mode */ +struct mutex mutex;/* for state below */ enum drm_connector_force force;/* mutex-protected force state */ struct drm_connector *curr_conn;/* current connector (only valid when !disabled) */ bool disabled;/* DRM has disabled our bridge */
@@ -2894,20 +2892,6 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,return mode_status; } -static void dw_hdmi_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *orig_mode, -const struct drm_display_mode *mode) -{ -struct dw_hdmi *hdmi = bridge->driver_private; - -mutex_lock (&hdmi->mutex); - -/* Store the display mode for plugin/DKMS poweron events */ -drm_mode_copy (&hdmi->previous_mode, mode); - -mutex_unlock (&hdmi->mutex); -} -static void dw_hdmi_bridge_atomic_disable (struct drm_bridge *bridge,struct drm_bridge_state *old_state) {
@@ -2971,7 +2955,6 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { .atomic_get_input_bus_fmts = dw_hdmi_bridge_atomic_get_input_bus_fmts, .atomic_enable = dw_hdmi_bridge_atomic_enable, .atomic_disable = dw_hdmi_bridge_atomic_disable, - .mode_set = dw_hdmi_bridge_mode_set, .mode_valid = dw_hdmi_bridge_mode_valid, .detect = dw_hdmi_bridge_detect, .edid_read = dw_hdmi_bridge_edid_read,
Signature · 1 line
2.46.0
Re: [PATCH v2 06/10] drm: bridge: dw_hdmi: Remove previous_mode and mode_set
Quoted 55 lines · Jonas Karlman
With the use of
adjusted_modedirectly from thecrtc_statethere is no longer a need to store a copy inprevious_mode, remove it and the now unneededmode_setops.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-17@@ -154,8 +154,6 @@ struct dw_hdmi {bool enabled; } phy; -struct drm_display_mode previous_mode; -struct i2c_adapter *ddc;void __iomem *regs;bool sink_is_hdmi;@@ -165,7 +163,7 @@ struct dw_hdmi {struct pinctrl_state *default_state;struct pinctrl_state *unwedge_state; -struct mutex mutex;/* for state below and previous_mode */ +struct mutex mutex;/* for state below */ enum drm_connector_force force;/* mutex-protected force state */ struct drm_connector *curr_conn;/* current connector (only valid when !disabled) */ bool disabled;/* DRM has disabled our bridge */ @@ -2894,20 +2892,6 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,return mode_status; } -static void dw_hdmi_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *orig_mode, -const struct drm_display_mode *mode) -{ -struct dw_hdmi *hdmi = bridge->driver_private; - -mutex_lock (&hdmi->mutex); - -/* Store the display mode for plugin/DKMS poweron events */ -drm_mode_copy (&hdmi->previous_mode, mode); - -mutex_unlock (&hdmi->mutex); -} -static void dw_hdmi_bridge_atomic_disable (struct drm_bridge *bridge,struct drm_bridge_state *old_state) {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { · line 2960
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-1@@ -2971,7 +2955,6 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { .atomic_get_input_bus_fmts = dw_hdmi_bridge_atomic_get_input_bus_fmts, .atomic_enable = dw_hdmi_bridge_atomic_enable, .atomic_disable = dw_hdmi_bridge_atomic_disable, - .mode_set = dw_hdmi_bridge_mode_set, .mode_valid = dw_hdmi_bridge_mode_valid, .detect = dw_hdmi_bridge_detect, .edid_read = dw_hdmi_bridge_edid_read,
Jonas Karlman
reviewerPATCH v2 7/10 drm: bridge: dw_hdmi: Invalidate CEC phys addr from connector detect
In reply to Jonas KarlmanWait until the connector detect ops is called to invalidate CEC phys addr instead of doing it directly from the irq handler.
---
v2: Collect r-b tag
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +11 -7
@@ -2454,7 +2454,17 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) { struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, connector); -return dw_hdmi_detect (hdmi); +enum drm_connector_status status; + + status =dw_hdmi_detect (hdmi); + +if (status == connector_status_disconnected) { +mutex_lock (&hdmi->cec_notifier_mutex); +cec_notifier_phys_addr_invalidate (hdmi->cec_notifier); +mutex_unlock (&hdmi->cec_notifier_mutex); + } + +return status; }static int dw_hdmi_connector_get_modes (struct drm_connector *connector)
@@ -3065,12 +3075,6 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) phy_stat &HDMI_PHY_HPD , phy_stat & HDMI_PHY_RX_SENSE); -if ((phy_stat & (HDMI_PHY_RX_SENSE |HDMI_PHY_HPD )) ==0 ) { -mutex_lock (&hdmi->cec_notifier_mutex); -cec_notifier_phys_addr_invalidate (hdmi->cec_notifier); -mutex_unlock (&hdmi->cec_notifier_mutex); - } -if ((intr_stat &HDMI_IH_PHY_STAT0_HPD ) && (phy_stat &HDMI_PHY_HPD )) status = connector_status_connected;
Signature · 1 line
2.46.0
Jonas Karlman
reviewerPATCH v2 8/10 drm: bridge: dw_hdmi: Remove cec_notifier_mutex
In reply to Jonas KarlmanWith CEC phys addr invalidation moved away from the irq handler there is no longer a need for cec_notifier_mutex, remove it.
---
v2: Collect r-b tag
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -10
@@ -186,7 +186,6 @@ struct dw_hdmi {void (*enable_audio)(struct dw_hdmi *hdmi);void (*disable_audio)(struct dw_hdmi *hdmi); -struct mutex cec_notifier_mutex;struct cec_notifier *cec_notifier;hdmi_codec_plugged_cb plugged_cb;
@@ -2458,11 +2457,8 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); -if (status == connector_status_disconnected) { -mutex_lock (&hdmi->cec_notifier_mutex); +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier); -mutex_unlock (&hdmi->cec_notifier_mutex); - }return status; }
@@ -2576,9 +2572,7 @@ static int dw_hdmi_connector_create(struct dw_hdmi *hdmi)if (!notifier)return -ENOMEM ; -mutex_lock (&hdmi->cec_notifier_mutex); hdmi->cec_notifier = notifier; -mutex_unlock (&hdmi->cec_notifier_mutex);return 0 ; }
@@ -2876,10 +2870,8 @@ static void dw_hdmi_bridge_detach(struct drm_bridge *bridge) {struct dw_hdmi *hdmi = bridge->driver_private; -mutex_lock (&hdmi->cec_notifier_mutex);cec_notifier_conn_unregister (hdmi->cec_notifier); hdmi->cec_notifier =NULL ; -mutex_unlock (&hdmi->cec_notifier_mutex); } static enum drm_mode_status
@@ -3304,7 +3296,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,mutex_init (&hdmi->mutex);mutex_init (&hdmi->audio_mutex); -mutex_init (&hdmi->cec_notifier_mutex);spin_lock_init (&hdmi->audio_lock); ret =dw_hdmi_parse_dt (hdmi);
Signature · 1 line
2.46.0
Jonas Karlman
reviewerPATCH v2 9/10 drm: bridge: dw_hdmi: Update EDID during hotplug processing
In reply to Jonas KarlmanUpdate successfully read EDID during hotplug processing to ensure the connector diplay_info is always up-to-date.
---
v2: No change
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +12 -0
@@ -2457,6 +2457,18 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); +/* Update EDID during hotplug processing (force=false) */ +if (status == connector_status_connected && !force) { +const struct drm_edid *drm_edid; + + drm_edid =dw_hdmi_edid_read (hdmi, connector); +if (drm_edid) +drm_edid_connector_update (connector, drm_edid); +cec_notifier_set_phys_addr (hdmi->cec_notifier, + connector->display_info.source_physical_address); +drm_edid_free (drm_edid); + } +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier);
Signature · 1 line
2.46.0
Neil Armstrong
maintainerRe: [PATCH v2 09/10] drm: bridge: dw_hdmi: Update EDID during hotplug processing
Quoted 23 lines · Jonas Karlman
Update successfully read EDID during hotplug processing to ensure the connector
diplay_infois always up-to-date.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5
-0@@ -2457,6 +2457,18 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); +/* Update EDID during hotplug processing (force=false) */ +if (status == connector_status_connected && !force) { +const struct drm_edid *drm_edid; + + drm_edid =dw_hdmi_edid_read (hdmi, connector);
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c dw_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 2474
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7
-0+if (drm_edid) +drm_edid_connector_update (connector, drm_edid); +cec_notifier_set_phys_addr (hdmi->cec_notifier, + connector->display_info.source_physical_address); +drm_edid_free (drm_edid); + } +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier);
I wonder why we should read edid at each dw_hdmi_connector_detect() call, AFAIK it should only be when we have HPD pulses
Neil
Jonas Karlman
reviewerRe: [PATCH v2 09/10] drm: bridge: dw_hdmi: Update EDID during hotplug processing
Hi Neil,
Quoted 29 lines · Neil Armstrong
Quoted 28 lines · Jonas Karlman
Update successfully read EDID during hotplug processing to ensure the connector
diplay_infois always up-to-date.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0@@ -2457,6 +2457,18 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); +/* Update EDID during hotplug processing (force=false) */ +if (status == connector_status_connected && !force) { +const struct drm_edid *drm_edid; + + drm_edid =dw_hdmi_edid_read (hdmi, connector); +if (drm_edid) +drm_edid_connector_update (connector, drm_edid); +cec_notifier_set_phys_addr (hdmi->cec_notifier, + connector->display_info.source_physical_address); +drm_edid_free (drm_edid);
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c dw_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 2474
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0+ } +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier);I wonder why we should read edid at each
dw_hdmi_connector_detect()call, AFAIK it should only be when we have HPD pulses
That is what this change intends to help do.
As stated in the short comment EDID is only updated at HPD processing, i.e. when force=false. To be on the safe side EDID is also only updated here when connected and EDID could be read.
drm_helper_probe_detect() is called with force=true in the fill_modes/get_modes call path that is triggered by userspace or the kernel kms client.
After a HPD interrupt the call to drm_helper_hpd_irq_event() will call check_connector_changed() that in turn calls drm_helper_probe_detect() with force=false to check/detect if connector status has changed. It is in this call chain the EDID may be read and updated in this detect ops.
Reading EDID here at HPD processing may not be fully needed, however it help kernel keep the internal EDID state in better sync with sink when userspace does not act on the HOTPLUG=1 uevent.
Regards,
Jonas
Quoted 2 lines
Neil
[email protected]
maintainerRe: [PATCH v2 09/10] drm: bridge: dw_hdmi: Update EDID during hotplug processing
Quoted 51 lines · Jonas Karlman
Hi Neil,
Quoted 29 lines · Neil Armstrong
Quoted 28 lines · Jonas Karlman
Update successfully read EDID during hotplug processing to ensure the connector
diplay_infois always up-to-date.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0@@ -2457,6 +2457,18 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); +/* Update EDID during hotplug processing (force=false) */ +if (status == connector_status_connected && !force) { +const struct drm_edid *drm_edid; + + drm_edid =dw_hdmi_edid_read (hdmi, connector); +if (drm_edid) +drm_edid_connector_update (connector, drm_edid); +cec_notifier_set_phys_addr (hdmi->cec_notifier, + connector->display_info.source_physical_address); +drm_edid_free (drm_edid);Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c dw_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 2474
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0+ } +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier);I wonder why we should read edid at each
dw_hdmi_connector_detect()call, AFAIK it should only be when we have HPD pulsesThat is what this change intends to help do.
As stated in the short comment EDID is only updated at HPD processing, i.e. when force=false. To be on the safe side EDID is also only updated here when connected and EDID could be read.
drm_helper_probe_detect()is called with force=true in the fill_modes/get_modes call path that is triggered by userspace or the kernel kms client.
Quoted 8 lines
After a HPD interrupt the call to
drm_helper_hpd_irq_event()will callcheck_connector_changed()that in turn callsdrm_helper_probe_detect()with force=false to check/detect if connector status has changed. It is in this call chain the EDID may be read and updated in this detect ops.Reading EDID here at HPD processing may not be fully needed, however it help kernel keep the internal EDID state in better sync with sink when userspace does not act on the HOTPLUG=1 uevent.
I understand but if somehow a dw-hdmi integration fails to have HDP working properly, EDID will be read continuously which is really not what we want.
HDMI 1.4b specifies in Section 8.5 and Appendix A:
============><==========================================
An HDMI Sink shall not assert high voltage level on its Hot Plug Detect pin when the E-EDID is not available for reading.
An HDMI Sink shall indicate any change to the contents of the E-EDID by driving a low voltage level pulse on the Hot Plug Detect pin. This pulse shall be at least 100 msec. ============><==========================================
So this is OK with the first sentence, and should also work with the second one because right after the pulse we will read the EDID again, but I think we should have a much more robust way to detect those 100ms pulses, no ?
Maxime, do you have an opinion on this ?
Neil
Quoted 7 lines
Regards,
JonasQuoted 2 lines
Neil
Jonas Karlman
reviewerRe: [PATCH v2 09/10] drm: bridge: dw_hdmi: Update EDID during hotplug processing
Quoted 57 lines · On 2024-09-20 09:04, [email protected] wrote:
Quoted 56 lines · Jonas Karlman
Hi Neil,
Quoted 29 lines · Neil Armstrong
Quoted 28 lines · Jonas Karlman
Update successfully read EDID during hotplug processing to ensure the connector
diplay_infois always up-to-date.Signed-off-by Jonas Karlman <[email protected]>---
v2: No change--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0@@ -2457,6 +2457,18 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) status =dw_hdmi_detect (hdmi); +/* Update EDID during hotplug processing (force=false) */ +if (status == connector_status_connected && !force) { +const struct drm_edid *drm_edid; + + drm_edid =dw_hdmi_edid_read (hdmi, connector); +if (drm_edid) +drm_edid_connector_update (connector, drm_edid); +cec_notifier_set_phys_addr (hdmi->cec_notifier, + connector->display_info.source_physical_address); +drm_edid_free (drm_edid);Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c dw_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 2474
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0+ } +if (status == connector_status_disconnected)cec_notifier_phys_addr_invalidate (hdmi->cec_notifier);I wonder why we should read edid at each
dw_hdmi_connector_detect()call, AFAIK it should only be when we have HPD pulsesThat is what this change intends to help do.
As stated in the short comment EDID is only updated at HPD processing, i.e. when force=false. To be on the safe side EDID is also only updated here when connected and EDID could be read.
drm_helper_probe_detect()is called with force=true in the fill_modes/get_modes call path that is triggered by userspace or the kernel kms client.After a HPD interrupt the call to
drm_helper_hpd_irq_event()will callcheck_connector_changed()that in turn callsdrm_helper_probe_detect()with force=false to check/detect if connector status has changed. It is in this call chain the EDID may be read and updated in this detect ops.
Quoted 7 lines
Quoted 3 lines
Reading EDID here at HPD processing may not be fully needed, however it help kernel keep the internal EDID state in better sync with sink when userspace does not act on the HOTPLUG=1 uevent.
I understand but if somehow a dw-hdmi integration fails to have HDP working properly, EDID will be read continuously which is really not what we want.
I do not fully understand when or how that could happen.
The dw_hdmi_detect() -> phy.ops->read_hpd() call chain only return connected status when HPD is high, for what I can see from all current integrations.
The default dw_hdmi_phy_read_hpd() used by all but meson should only return connected status when the HPD is high:
return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? connector_status_connected : connector_status_disconnected;
DRM_CONNECTOR_POLL_HPD is also used for all integrations so there should not be any polling happening that would trigger multiple detect calls.
I guess this could/should be improved to also check for the polled type to not cause multiple unnecessary EDID reads, in case a future integration need to poll connector status.
Quoted 9 lines
HDMI 1.4b specifies in Section 8.5 and Appendix A:
============><==========================================
An HDMI Sink shall not assert high voltage level on its Hot Plug Detect pin when the E-EDID is not available for reading.
An HDMI Sink shall indicate any change to the contents of the E-EDID by driving a low voltage level pulse on the Hot Plug Detect pin. This pulse shall be at least 100 msec. ============><==========================================
Quoted 3 lines
So this is OK with the first sentence, and should also work with the second one because right after the pulse we will read the EDID again, but I think we should have a much more robust way to detect those 100ms pulses, no ?
Using a work queue to debounce reacting on HPD event for >100 ms when HPD goes from high to low and a few ms when it goes from low to high could probably further prevent unnecessary detect calls, and also help avoid a possible unnecessary disable/enable cycle.
I have not seen anything other in core that handles the EDID refresh in any special way, but I may have missed something?
Will try to use a debounce work queue to delay any calls to helper_hpd_irq_event() and drm_bridge_hpd_notify() and see if that could improve the HPD handling.
Regards,
Jonas
Quoted 13 lines
Maxime, do you have an opinion on this ?
Neil
Quoted 7 lines
Regards,
JonasQuoted 2 lines
Neil
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Jonas Karlman
reviewerPATCH v2 10/10 drm: bridge: dw_hdmi: Use display_info is_hdmi and has_audio
In reply to Jonas Karlmandrm_edid_connector_update() is being called from bridge connector ops and from detect and get_modes ops for dw-hdmi connector.
Change to use is_hdmi and has_audio from display_info directly instead of keeping our own state in sink_is_hdmi and sink_has_audio.
Also remove the old and unused edid struct member and related define.
---
v2: Collect r-b tag
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 32 ++++------------------- 1 file changed, 5 insertions(+), 27 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -27
@@ -43,8 +43,6 @@#define DDC_CI_ADDR 0x37#define DDC_SEGMENT_ADDR 0x30 -#define HDMI_EDID_LEN 512 -/* DW-HDMI Controller >= 0x200a are at least compliant with SCDC version 1 */ #define SCDC_MIN_SOURCE_VERSION 0x1
@@ -145,8 +143,6 @@ struct dw_hdmi {int vic; -u8 edid[HDMI_EDID_LEN ]; -struct {const struct dw_hdmi_phy_ops *ops;const char *name;
@@ -156,8 +152,6 @@ struct dw_hdmi {struct i2c_adapter *ddc;void __iomem *regs; -bool sink_is_hdmi; -bool sink_has_audio;struct pinctrl *pinctrl;struct pinctrl_state *default_state;
@@ -2038,7 +2032,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, HDMI_FC_INVIDCONF_IN_I_P_INTERLACED :HDMI_FC_INVIDCONF_IN_I_P_PROGRESSIVE ; - inv_val |= hdmi->sink_is_hdmi ? + inv_val |= display->is_hdmi ?HDMI_FC_INVIDCONF_DVI_MODEZ_HDMI_MODE :HDMI_FC_INVIDCONF_DVI_MODEZ_DVI_MODE ;
@@ -2274,7 +2268,7 @@ static int dw_hdmi_poweron(struct dw_hdmi *hdmi,if (hdmi->hdmi_data.enc_out_bus_format ==MEDIA_BUS_FMT_FIXED ) hdmi->hdmi_data.enc_out_bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; - hdmi->hdmi_data.rgb_limited_range = hdmi->sink_is_hdmi && + hdmi->hdmi_data.rgb_limited_range = display->is_hdmi &&drm_default_rgb_quant_range (mode) ==HDMI_QUANTIZATION_RANGE_LIMITED ;
@@ -2294,7 +2288,7 @@ static int dw_hdmi_poweron(struct dw_hdmi *hdmi,/* HDMI Initialization Step B.3 */ dw_hdmi_enable_video_path (hdmi); -if (hdmi->sink_has_audio) { +if (display->has_audio) {dev_dbg (hdmi->dev,"sink has audio support\n" );/* HDMI Initialization Step E - Configure audio */
@@ -2303,7 +2297,7 @@ static int dw_hdmi_poweron(struct dw_hdmi *hdmi, }/* not for DVI mode */ -if (hdmi->sink_is_hdmi) { +if (display->is_hdmi) {dev_dbg (hdmi->dev,"%s HDMI mode\n" , __func__);/* HDMI Initialization Step F - Configure AVI InfoFrame */
@@ -2417,29 +2411,13 @@ static const struct drm_edid *dw_hdmi_edid_read(struct dw_hdmi *hdmi, struct drm_connector *connector) {const struct drm_edid *drm_edid; -const struct edid *edid;if (!hdmi->ddc)return NULL ; drm_edid =drm_edid_read_ddc (connector, hdmi->ddc); -if (!drm_edid) { +if (!drm_edid)dev_dbg (hdmi->dev,"failed to get edid\n" ); -return NULL ; - } - -/* -* FIXME: This should use connector->display_info.is_hdmi and -* connector->display_info.has_audio from a path that has read the EDID -* and called drm_edid_connector_update(). -*/ - edid =drm_edid_raw (drm_edid); - -dev_dbg (hdmi->dev,"got edid: width[%d] x height[%d]\n" , - edid->width_cm, edid->height_cm); - - hdmi->sink_is_hdmi =drm_detect_hdmi_monitor (edid); - hdmi->sink_has_audio =drm_detect_monitor_audio (edid);return drm_edid; }
Signature · 1 line
2.46.0
Hi Jonas,
Quoted 7 lines · Jonas Karlman
This series ensure poweron/poweroff and CEC phys addr invalidation is happening under drm
mode_configmutex lock, and also ensure EDID is updated (when the dw-hdmi connector is used) after a hotplug pulse.These changes has mainly been tested on Rockchip devices together with a series [1] that add HDMI 2.0 4K@60Hz support to RK3228, RK3328, RK3399 and RK3568.
I did some tests with this series (together with the 4K60Hz one).
Test setup:
- TV capable of display 4K@60Hz
- monitor capable of displaying 1080p@60Hz
- Quartz64 Model-A
- Rock64
When I booted up connected to the 4K TV, the boot messages were displayed in 1080p resolution. IIUC it was to be considered an improvement when it would be illegible at 4K, but that did not happen. Neither on the Q64-A or the Rock64.
When executing ``cat /sys/class/graphics/*/modes`` it returned ``U:3840x2160p-0``, so that was good.
I then went on the HDMI-hot-plug-swap-test and connected it to my 1080p monitor while the system was still online. That did not change the output of the previous command. As my monitor doesn't support 4K it seems to have chosen a 640p or 720p resolution.
IOW the letters were rather big. With enough output on the screen, it went off the visible area, so all I could do then was 'blind' typing.
If I booted up connected to the 1080p monitor then it reported a 1080p resolution and when swapping to the 4K TV, it kept reporting that value and displaying things in 1080p resolution, but ofc there were no abnormal big letters or output falling off the screen this time.
If I did those test when Sway was running, all the data (``swaymsg -t get_outputs --pretty``) showed that a proper resolution switch was made and the display was correctly adjusted accordingly.
I then tried to do the keep-swapping-until-output-breaks what Chris reported about in the previous series.
At some point I thought I was able to reproduce the issue ... to then conclude I had likely hit the poweroff button when swapping the cables. And another time I thought I had managed to reproduce it ... to then find out display wasn't working at all anymore. Turned out that likely due to all that swapping, it was no longer properly inserted into my monitor.
I've tried it a LOT of times, but I have to conclude that I was not able to reproduce the problem and therefor also not the solution.
HTH,
Diederik
Hi Jonas and Laurent,
I may be showing my n00bness ... or I actually found something ...
Quoted 20 lines · Diederik de Haas
Quoted 7 lines · Jonas Karlman
This series ensure poweron/poweroff and CEC phys addr invalidation is happening under drm
mode_configmutex lock, and also ensure EDID is updated (when the dw-hdmi connector is used) after a hotplug pulse.These changes has mainly been tested on Rockchip devices together with a series [1] that add HDMI 2.0 4K@60Hz support to RK3228, RK3328, RK3399 and RK3568.
I did some tests with this series (together with the 4K60Hz one).
...
I then went on the HDMI-hot-plug-swap-test and connected it to my 1080p monitor while the system was still online. That did not change the output of the previous command. As my monitor doesn't support 4K it seems to have chosen a 640p or 720p resolution.
IOW the letters were rather big. With enough output on the screen, it went off the visible area, so all I could do then was 'blind' typing.
Quoted 4 lines
If I booted up connected to the 1080p monitor then it reported a 1080p resolution and when swapping to the 4K TV, it kept reporting that value and displaying things in 1080p resolution, but ofc there were no abnormal big letters or output falling off the screen this time.
A DT validation on rk3328-rock64.dtb reported this:
rockchip/rk3328-rock64.dtb: hdmi@ff3c0000: interrupts: [[0, 35, 4], [0, 71, 4]] is too long
That's because display/bridge/synopsys,dw-hdmi.yaml dt-binding has interrupts : maxItems : 1
and the rk3328.dtsi file has 2 interrupts in its hdmi node.
Easiest solution is to just remove the 2nd one and that makes DT validation happy.
Looking at the rk3328 TRM, I found these hdmi related interrupts:
67 hdmi_intr
103 hdmi_intr_wakeup
Looking at the rk3399 TRM, I found these hdmi related interrupts:
23 hdmi_irq
24 hdmi_wakeup_irq
Looking at the rk3568 TRM, I found these hdmi related interrupts:
76 hdmi_wakeup
77 hdmi
So my thinking is:
- what if the dt-binding is incorrect? (-> maxItems : 2?)
- wakeup 'sounds like' Hot Plug Detection?
which makes it relevant for this series and it could mean that the rk3399-base.dtsi and rk356x.dtsi are actually missing an interrupt definition in their DT files?
Or I am completely talking nonsense, which is the most likely scenario.
Cheers,
Diederik