drm/msm/dp: fix connect/disconnect handled at irq_hpd
Some usb type-c dongle use irq_hpd request to perform device connection
and disconnection. This patch add handling of both connection and
disconnection are based on the state of hpd_state and sink_count.
Changes in V2:
-- add dp_display_handle_port_ststus_changed()
-- fix kernel test robot complaint
Changes in V3:
-- add encoder_mode_set into struct dp_display_private
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 26b8d66a39
("drm/msm/dp: promote irq_hpd handle to handle link training correctly")
Tested-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
parent
854f6f1c65
commit
c58eb1b54f
1 changed files with 55 additions and 37 deletions
|
@ -102,6 +102,8 @@ struct dp_display_private {
|
||||||
struct dp_display_mode dp_mode;
|
struct dp_display_mode dp_mode;
|
||||||
struct msm_dp dp_display;
|
struct msm_dp dp_display;
|
||||||
|
|
||||||
|
bool encoder_mode_set;
|
||||||
|
|
||||||
/* wait for audio signaling */
|
/* wait for audio signaling */
|
||||||
struct completion audio_comp;
|
struct completion audio_comp;
|
||||||
|
|
||||||
|
@ -279,13 +281,24 @@ static void dp_display_send_hpd_event(struct msm_dp *dp_display)
|
||||||
drm_helper_hpd_irq_event(connector->dev);
|
drm_helper_hpd_irq_event(connector->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dp_display_send_hpd_notification(struct dp_display_private *dp,
|
|
||||||
bool hpd)
|
static void dp_display_set_encoder_mode(struct dp_display_private *dp)
|
||||||
{
|
{
|
||||||
static bool encoder_mode_set;
|
|
||||||
struct msm_drm_private *priv = dp->dp_display.drm_dev->dev_private;
|
struct msm_drm_private *priv = dp->dp_display.drm_dev->dev_private;
|
||||||
struct msm_kms *kms = priv->kms;
|
struct msm_kms *kms = priv->kms;
|
||||||
|
|
||||||
|
if (!dp->encoder_mode_set && dp->dp_display.encoder &&
|
||||||
|
kms->funcs->set_encoder_mode) {
|
||||||
|
kms->funcs->set_encoder_mode(kms,
|
||||||
|
dp->dp_display.encoder, false);
|
||||||
|
|
||||||
|
dp->encoder_mode_set = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dp_display_send_hpd_notification(struct dp_display_private *dp,
|
||||||
|
bool hpd)
|
||||||
|
{
|
||||||
if ((hpd && dp->dp_display.is_connected) ||
|
if ((hpd && dp->dp_display.is_connected) ||
|
||||||
(!hpd && !dp->dp_display.is_connected)) {
|
(!hpd && !dp->dp_display.is_connected)) {
|
||||||
DRM_DEBUG_DP("HPD already %s\n", (hpd ? "on" : "off"));
|
DRM_DEBUG_DP("HPD already %s\n", (hpd ? "on" : "off"));
|
||||||
|
@ -298,15 +311,6 @@ static int dp_display_send_hpd_notification(struct dp_display_private *dp,
|
||||||
|
|
||||||
dp->dp_display.is_connected = hpd;
|
dp->dp_display.is_connected = hpd;
|
||||||
|
|
||||||
if (dp->dp_display.is_connected && dp->dp_display.encoder
|
|
||||||
&& !encoder_mode_set
|
|
||||||
&& kms->funcs->set_encoder_mode) {
|
|
||||||
kms->funcs->set_encoder_mode(kms,
|
|
||||||
dp->dp_display.encoder, false);
|
|
||||||
DRM_DEBUG_DP("set_encoder_mode() Completed\n");
|
|
||||||
encoder_mode_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dp_display_send_hpd_event(&dp->dp_display);
|
dp_display_send_hpd_event(&dp->dp_display);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -342,7 +346,6 @@ static int dp_display_process_hpd_high(struct dp_display_private *dp)
|
||||||
|
|
||||||
dp_add_event(dp, EV_USER_NOTIFICATION, true, 0);
|
dp_add_event(dp, EV_USER_NOTIFICATION, true, 0);
|
||||||
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -359,6 +362,8 @@ static void dp_display_host_init(struct dp_display_private *dp)
|
||||||
if (dp->usbpd->orientation == ORIENTATION_CC2)
|
if (dp->usbpd->orientation == ORIENTATION_CC2)
|
||||||
flip = true;
|
flip = true;
|
||||||
|
|
||||||
|
dp_display_set_encoder_mode(dp);
|
||||||
|
|
||||||
dp_power_init(dp->power, flip);
|
dp_power_init(dp->power, flip);
|
||||||
dp_ctrl_host_init(dp->ctrl, flip);
|
dp_ctrl_host_init(dp->ctrl, flip);
|
||||||
dp_aux_init(dp->aux);
|
dp_aux_init(dp->aux);
|
||||||
|
@ -442,24 +447,42 @@ static void dp_display_handle_video_request(struct dp_display_private *dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dp_display_handle_port_ststus_changed(struct dp_display_private *dp)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (dp_display_is_sink_count_zero(dp)) {
|
||||||
|
DRM_DEBUG_DP("sink count is zero, nothing to do\n");
|
||||||
|
if (dp->hpd_state != ST_DISCONNECTED) {
|
||||||
|
dp->hpd_state = ST_DISCONNECT_PENDING;
|
||||||
|
dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dp->hpd_state == ST_DISCONNECTED) {
|
||||||
|
dp->hpd_state = ST_CONNECT_PENDING;
|
||||||
|
rc = dp_display_process_hpd_high(dp);
|
||||||
|
if (rc)
|
||||||
|
dp->hpd_state = ST_DISCONNECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static int dp_display_handle_irq_hpd(struct dp_display_private *dp)
|
static int dp_display_handle_irq_hpd(struct dp_display_private *dp)
|
||||||
{
|
{
|
||||||
u32 sink_request;
|
u32 sink_request = dp->link->sink_request;
|
||||||
|
|
||||||
sink_request = dp->link->sink_request;
|
if (dp->hpd_state == ST_DISCONNECTED) {
|
||||||
|
if (sink_request & DP_LINK_STATUS_UPDATED) {
|
||||||
if (sink_request & DS_PORT_STATUS_CHANGED) {
|
DRM_ERROR("Disconnected, no DP_LINK_STATUS_UPDATED\n");
|
||||||
if (dp_display_is_sink_count_zero(dp)) {
|
return -EINVAL;
|
||||||
DRM_DEBUG_DP("sink count is zero, nothing to do\n");
|
|
||||||
return -ENOTCONN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dp_display_process_hpd_high(dp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dp_ctrl_handle_sink_request(dp->ctrl);
|
dp_ctrl_handle_sink_request(dp->ctrl);
|
||||||
|
|
||||||
if (dp->link->sink_request & DP_TEST_LINK_VIDEO_PATTERN)
|
if (sink_request & DP_TEST_LINK_VIDEO_PATTERN)
|
||||||
dp_display_handle_video_request(dp);
|
dp_display_handle_video_request(dp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -490,19 +513,10 @@ static int dp_display_usbpd_attention_cb(struct device *dev)
|
||||||
rc = dp_link_process_request(dp->link);
|
rc = dp_link_process_request(dp->link);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
sink_request = dp->link->sink_request;
|
sink_request = dp->link->sink_request;
|
||||||
if (sink_request & DS_PORT_STATUS_CHANGED) {
|
if (sink_request & DS_PORT_STATUS_CHANGED)
|
||||||
/* same as unplugged */
|
rc = dp_display_handle_port_ststus_changed(dp);
|
||||||
hpd->hpd_high = 0;
|
else
|
||||||
dp->hpd_state = ST_DISCONNECT_PENDING;
|
rc = dp_display_handle_irq_hpd(dp);
|
||||||
dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = dp_display_handle_irq_hpd(dp);
|
|
||||||
|
|
||||||
if (!rc && (sink_request & DS_PORT_STATUS_CHANGED)) {
|
|
||||||
hpd->hpd_high = 1;
|
|
||||||
dp->hpd_state = ST_CONNECT_PENDING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -668,6 +682,7 @@ static int dp_disconnect_pending_timeout(struct dp_display_private *dp, u32 data
|
||||||
static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
|
static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
|
||||||
{
|
{
|
||||||
u32 state;
|
u32 state;
|
||||||
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&dp->event_mutex);
|
mutex_lock(&dp->event_mutex);
|
||||||
|
|
||||||
|
@ -678,7 +693,10 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dp_display_usbpd_attention_cb(&dp->pdev->dev);
|
ret = dp_display_usbpd_attention_cb(&dp->pdev->dev);
|
||||||
|
if (ret == -ECONNRESET) { /* cable unplugged */
|
||||||
|
dp->core_initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&dp->event_mutex);
|
mutex_unlock(&dp->event_mutex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue