bool phy_initialized;
bool audio_supported;
+ struct mutex plugged_lock;
+ bool plugged;
+
struct drm_device *drm_dev;
struct drm_dp_aux *aux;
dp->panel->dpcd,
dp->panel->downstream_ports);
- dp->msm_dp_display.link_ready = true;
-
dp->msm_dp_display.psr_supported = dp->panel->psr_cap.version && psr_enabled;
dp->audio_supported = info->has_audio;
return rc;
}
-static void msm_dp_display_host_phy_init(struct msm_dp_display_private *dp)
+/**
+ * msm_dp_display_host_phy_init() - start up DP PHY
+ * @dp: main display data structure
+ *
+ * Prepare DP PHY for the AUX transactions to succeed.
+ *
+ * Returns: true if this call has initliazed the PHY and false if the PHY has
+ * already been setup beforehand.
+ */
+static bool msm_dp_display_host_phy_init(struct msm_dp_display_private *dp)
{
drm_dbg_dp(dp->drm_dev, "type=%d core_init=%d phy_init=%d\n",
dp->msm_dp_display.connector_type, dp->core_initialized,
if (!dp->phy_initialized) {
msm_dp_ctrl_phy_init(dp->ctrl);
dp->phy_initialized = true;
+ return true;
}
+
+ return false;
}
static void msm_dp_display_host_phy_exit(struct msm_dp_display_private *dp)
u32 sink_request = dp->link->sink_request;
drm_dbg_dp(dp->drm_dev, "%d\n", sink_request);
- if (!dp->msm_dp_display.link_ready) {
- if (sink_request & DP_LINK_STATUS_UPDATED) {
- drm_dbg_dp(dp->drm_dev, "Disconnected sink_request: %d\n",
- sink_request);
- DRM_ERROR("Disconnected, no DP_LINK_STATUS_UPDATED\n");
- return -EINVAL;
- }
- }
msm_dp_ctrl_handle_sink_request(dp->ctrl);
dp->msm_dp_display.connector_type,
dp->link->sink_count);
- if (dp->msm_dp_display.link_ready)
- return 0;
+ guard(mutex)(&dp->plugged_lock);
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret) {
msm_dp_display_host_phy_init(dp);
ret = msm_dp_display_process_hpd_high(dp);
- if (ret) { /* link train failed */
- dp->msm_dp_display.link_ready = false;
- msm_dp_aux_enable_xfers(dp->aux, false);
- pm_runtime_put_sync(&pdev->dev);
- }
drm_dbg_dp(dp->drm_dev, "After, type=%d sink_count=%d\n",
dp->msm_dp_display.connector_type,
dp->link->sink_count);
- /* uevent will complete connection part */
- return 0;
+ dp->plugged = true;
+
+ return ret;
};
static void msm_dp_display_handle_plugged_change(struct msm_dp *msm_dp_display,
dp->msm_dp_display.connector_type,
dp->link->sink_count);
- if (!dp->msm_dp_display.link_ready)
+ guard(mutex)(&dp->plugged_lock);
+ if (!dp->plugged)
return 0;
/* triggered by irq_hdp with sink_count = 0 */
dp->panel->dpcd,
dp->panel->downstream_ports);
- dp->msm_dp_display.link_ready = false;
-
/* signal the disconnect event early to ensure proper teardown */
msm_dp_display_handle_plugged_change(&dp->msm_dp_display, false);
dp->msm_dp_display.connector_type,
dp->link->sink_count);
- /* uevent will complete disconnection part */
- pm_runtime_put_sync(&pdev->dev);
+ if (dp->plugged) {
+ pm_runtime_put_sync(&pdev->dev);
+ dp->plugged = false;
+ }
+
return 0;
}
struct msm_dp_display_private *priv;
u8 dpcd[DP_RECEIVER_CAP_SIZE];
struct drm_dp_desc desc;
+ bool phy_deinit;
int ret;
dp = to_dp_bridge(bridge)->msm_dp_display;
priv = container_of(dp, struct msm_dp_display_private, msm_dp_display);
- if (!dp->link_ready)
- return status;
-
+ guard(mutex)(&priv->plugged_lock);
ret = pm_runtime_resume_and_get(&dp->pdev->dev);
if (ret) {
DRM_ERROR("failed to pm_runtime_resume\n");
return status;
}
+ phy_deinit = msm_dp_display_host_phy_init(priv);
+
msm_dp_aux_enable_xfers(priv->aux, true);
ret = msm_dp_aux_is_link_connected(priv->aux);
- if (!ret) {
+ DRM_DEBUG_DP("aux link status: %x\n", ret);
+ if (!priv->plugged && !ret) {
DRM_DEBUG_DP("aux not connected\n");
+ priv->plugged = false;
goto end;
}
ret = drm_dp_read_dpcd_caps(priv->aux, dpcd);
if (ret) {
DRM_DEBUG_DP("failed to read caps\n");
+ priv->plugged = false;
goto end;
}
ret = drm_dp_read_desc(priv->aux, &desc, drm_dp_is_branch(dpcd));
if (ret) {
DRM_DEBUG_DP("failed to read desc\n");
+ priv->plugged = false;
goto end;
}
status = connector_status_connected;
+ priv->plugged = true;
+
if (drm_dp_read_sink_count_cap(connector, dpcd, &desc)) {
int sink_count = drm_dp_read_sink_count(priv->aux);
}
end:
- pm_runtime_put_sync(&dp->pdev->dev);
+ /*
+ * If we detected the DPRX, leave the controller on so that it doesn't
+ * lose the state.
+ */
+ if (!priv->plugged) {
+ if (phy_deinit) {
+ msm_dp_aux_enable_xfers(priv->aux, false);
+ msm_dp_display_host_phy_exit(priv);
+ }
+
+ pm_runtime_put_sync(&dp->pdev->dev);
+ }
+
return status;
}
(dp->msm_dp_display.connector_type == DRM_MODE_CONNECTOR_eDP);
dp->hpd_isr_status = 0;
+ mutex_init(&dp->plugged_lock);
+
rc = msm_dp_display_get_io(dp);
if (rc)
return rc;
return;
}
- if (dp->link_ready && !dp->power_on) {
+ if (!dp->power_on) {
msm_dp_display_host_phy_init(msm_dp_display);
force_link_train = true;
}
if (dp->is_edp)
msm_dp_hpd_unplug_handle(msm_dp_display);
- if (!dp->link_ready)
- drm_dbg_dp(dp->drm_dev, "type=%d is disconnected\n", dp->connector_type);
-
msm_dp_display_disable(msm_dp_display);
drm_dbg_dp(dp->drm_dev, "type=%d Done\n", dp->connector_type);
hpd_link_status = msm_dp_aux_is_link_connected(dp->aux);
- drm_dbg_dp(dp->drm_dev, "type=%d link hpd_link_status=0x%x, link_ready=%d, status=%d\n",
- msm_dp_display->connector_type, hpd_link_status,
- msm_dp_display->link_ready, status);
+ drm_dbg_dp(dp->drm_dev, "type=%d link hpd_link_status=0x%x, status=%d\n",
+ msm_dp_display->connector_type, hpd_link_status, status);
if (status == connector_status_connected) {
if (hpd_link_status == ISR_HPD_REPLUG_COUNT) {
#include "dp_audio.h"
#include "dp_drm.h"
-static int msm_dp_bridge_atomic_check(struct drm_bridge *bridge,
- struct drm_bridge_state *bridge_state,
- struct drm_crtc_state *crtc_state,
- struct drm_connector_state *conn_state)
-{
- struct msm_dp *dp;
-
- dp = to_dp_bridge(bridge)->msm_dp_display;
-
- drm_dbg_dp(dp->drm_dev, "link_ready = %s\n",
- str_true_false(dp->link_ready));
-
- /*
- * There is no protection in the DRM framework to check if the display
- * pipeline has been already disabled before trying to disable it again.
- * Hence if the sink is unplugged, the pipeline gets disabled, but the
- * crtc->active is still true. Any attempt to set the mode or manually
- * disable this encoder will result in the crash.
- *
- * TODO: add support for telling the DRM subsystem that the pipeline is
- * disabled by the hardware and thus all access to it should be forbidden.
- * After that this piece of code can be removed.
- */
- if (bridge->ops & DRM_BRIDGE_OP_HPD)
- return (dp->link_ready) ? 0 : -ENOTCONN;
-
- return 0;
-}
-
-
/**
* msm_dp_bridge_get_modes - callback to add drm modes via drm_mode_probed_add()
* @bridge: Poiner to drm bridge
dp = to_dp_bridge(bridge)->msm_dp_display;
/* pluggable case assumes EDID is read when HPD */
- if (dp->link_ready) {
- rc = msm_dp_display_get_modes(dp);
- if (rc <= 0) {
- DRM_ERROR("failed to get DP sink modes, rc=%d\n", rc);
- return rc;
- }
+ rc = msm_dp_display_get_modes(dp);
+ if (rc <= 0) {
+ DRM_ERROR("failed to get DP sink modes, rc=%d\n", rc);
+ return rc;
} else {
drm_dbg_dp(connector->dev, "No sink connected\n");
}
.mode_valid = msm_dp_bridge_mode_valid,
.get_modes = msm_dp_bridge_get_modes,
.detect = msm_dp_bridge_detect,
- .atomic_check = msm_dp_bridge_atomic_check,
.hpd_enable = msm_dp_bridge_hpd_enable,
.hpd_disable = msm_dp_bridge_hpd_disable,
.hpd_notify = msm_dp_bridge_hpd_notify,