Skip to content

Commit c1e5c2f

Browse files
pablosungregkh
authored andcommitted
usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles
Fix incorrect pin assignment values when connecting to a monitor with Type-C receptacle instead of a plug. According to specification, an UFP_D receptacle's pin assignment should came from the UFP_D pin assignments field (bit 23:16), while an UFP_D plug's assignments are described in the DFP_D pin assignments (bit 15:8) during Mode Discovery. For example the LG 27 UL850-W is a monitor with Type-C receptacle. The monitor responds to MODE DISCOVERY command with following DisplayPort Capability flag: dp->alt->vdo=0x140045 The existing logic only take cares of UPF_D plug case, and would take the bit 15:8 for this 0x140045 case. This results in an non-existing pin assignment 0x0 in dp_altmode_configure. To fix this problem a new set of macros are introduced to take plug/receptacle differences into consideration. Fixes: 0e3bb7d ("usb: typec: Add driver for DisplayPort alternate mode") Cc: [email protected] Co-developed-by: Pablo Sun <[email protected]> Co-developed-by: Macpaul Lin <[email protected]> Reviewed-by: Guillaume Ranquet <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Pablo Sun <[email protected]> Signed-off-by: Macpaul Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1bcafc0 commit c1e5c2f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/usb/typec/altmodes/displayport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)
9999
case DP_STATUS_CON_UFP_D:
100100
case DP_STATUS_CON_BOTH: /* NOTE: First acting as DP source */
101101
conf |= DP_CONF_UFP_U_AS_UFP_D;
102-
pin_assign = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo) &
103-
DP_CAP_UFP_D_PIN_ASSIGN(dp->port->vdo);
102+
pin_assign = DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) &
103+
DP_CAP_PIN_ASSIGN_DFP_D(dp->port->vdo);
104104
break;
105105
default:
106106
break;

include/linux/usb/typec_dp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ enum {
7373
#define DP_CAP_USB BIT(7)
7474
#define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(15, 8)) >> 8)
7575
#define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(23, 16)) >> 16)
76+
/* Get pin assignment taking plug & receptacle into consideration */
77+
#define DP_CAP_PIN_ASSIGN_UFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
78+
DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_))
79+
#define DP_CAP_PIN_ASSIGN_DFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
80+
DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))
7681

7782
/* DisplayPort Status Update VDO bits */
7883
#define DP_STATUS_CONNECTION(_status_) ((_status_) & 3)

0 commit comments

Comments
 (0)