Skip to content

Commit 6e4c968

Browse files
mtk-rex-bc-chendigetx
authored andcommitted
drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect()
In order to improve human readability, reduce the indentation by returning early if the dp/edp cable is not plugged in. Signed-off-by: Bo-Chen Chen <[email protected]> Acked-by: Chun-Kuang Hu <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c989a62 commit 6e4c968

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,39 +1933,41 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
19331933
bool enabled = mtk_dp->enabled;
19341934
u8 sink_count = 0;
19351935

1936-
if (mtk_dp->train_info.cable_plugged_in) {
1937-
if (!enabled) {
1938-
/* power on aux */
1939-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1940-
DP_PWR_STATE_BANDGAP_TPLL_LANE,
1941-
DP_PWR_STATE_MASK);
1942-
1943-
/* power on panel */
1944-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
1945-
usleep_range(2000, 5000);
1946-
}
1947-
/*
1948-
* Some dongles still source HPD when they do not connect to any
1949-
* sink device. To avoid this, we need to read the sink count
1950-
* to make sure we do connect to sink devices. After this detect
1951-
* function, we just need to check the HPD connection to check
1952-
* whether we connect to a sink device.
1953-
*/
1954-
drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
1955-
if (DP_GET_SINK_COUNT(sink_count))
1956-
ret = connector_status_connected;
1957-
1958-
if (!enabled) {
1959-
/* power off panel */
1960-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
1961-
usleep_range(2000, 3000);
1962-
1963-
/* power off aux */
1964-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1965-
DP_PWR_STATE_BANDGAP_TPLL,
1966-
DP_PWR_STATE_MASK);
1967-
}
1936+
if (!mtk_dp->train_info.cable_plugged_in)
1937+
return ret;
1938+
1939+
if (!enabled) {
1940+
/* power on aux */
1941+
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1942+
DP_PWR_STATE_BANDGAP_TPLL_LANE,
1943+
DP_PWR_STATE_MASK);
1944+
1945+
/* power on panel */
1946+
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
1947+
usleep_range(2000, 5000);
19681948
}
1949+
/*
1950+
* Some dongles still source HPD when they do not connect to any
1951+
* sink device. To avoid this, we need to read the sink count
1952+
* to make sure we do connect to sink devices. After this detect
1953+
* function, we just need to check the HPD connection to check
1954+
* whether we connect to a sink device.
1955+
*/
1956+
drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
1957+
if (DP_GET_SINK_COUNT(sink_count))
1958+
ret = connector_status_connected;
1959+
1960+
if (!enabled) {
1961+
/* power off panel */
1962+
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
1963+
usleep_range(2000, 3000);
1964+
1965+
/* power off aux */
1966+
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1967+
DP_PWR_STATE_BANDGAP_TPLL,
1968+
DP_PWR_STATE_MASK);
1969+
}
1970+
19691971
return ret;
19701972
}
19711973

0 commit comments

Comments
 (0)