Skip to content

Commit 1396634

Browse files
committed
drm: apple: dptx: Rework/document get_max_lane_count()
phy_validate() on the DP only ATC phy returns 0 lanes if it happens before the phy_set_mode(PHY_MODE_DP). Since this is the only known case default to 4 lanes as the phy is used exclusively for DP. Fixes: #367 Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 76e5a45 commit 1396634

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

drivers/gpu/drm/apple/dptxep.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,31 @@ static int dptxport_call_get_max_lane_count(struct apple_epic_service *service,
250250
{
251251
struct dptxport_apcall_lane_count *reply = reply_;
252252
struct dptx_port *dptx = service->cookie;
253+
struct apple_dcp *dcp = service->ep->dcp;
253254
union phy_configure_opts phy_ops;
254255
int ret;
255256

256257
if (reply_size < sizeof(*reply))
257258
return -EINVAL;
258259

259-
reply->retcode = cpu_to_le32(0);
260-
reply->lane_count = cpu_to_le64(2);
261-
262260
ret = phy_validate(dptx->atcphy, PHY_MODE_DP, 0, &phy_ops);
263-
if (ret < 0 || phy_ops.dp.lanes < 2) {
264-
// phy_validate might return 0 lines if atc-phy is not yet
265-
// switched to DP alt mode
266-
dev_dbg(service->ep->dcp->dev, "get_max_lane_count: "
267-
"phy_validate ret:%d lanes:%d\n", ret, phy_ops.dp.lanes);
268-
dptx->lane_count = 0;
261+
if (ret < 0) {
262+
dev_err(dcp->dev, "phy_validate failed: %d\n", ret);
263+
reply->retcode = cpu_to_le32(1);
264+
reply->lane_count = cpu_to_le64(0);
269265
} else {
266+
if (phy_ops.dp.lanes < 2) {
267+
// phy_validate might return 0 lanes if atc phy is not
268+
// yet switched to DP mode
269+
dev_dbg(dcp->dev, "get_max_lane_count: phy lanes: %d\n",
270+
phy_ops.dp.lanes);
271+
// default to 4 lanes
272+
dptx->lane_count = 4;
273+
} else {
274+
dptx->lane_count = phy_ops.dp.lanes;
275+
}
270276
reply->retcode = cpu_to_le32(0);
271-
reply->lane_count = cpu_to_le64(phy_ops.dp.lanes);
272-
dptx->lane_count = phy_ops.dp.lanes;
277+
reply->lane_count = cpu_to_le64(dptx->lane_count);
273278
}
274279

275280
return 0;

0 commit comments

Comments
 (0)