usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles
Subsystems (5)
PATCH 1/1 usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles
From: Pablo Sun <[email protected]>
From: Pablo Sun <[email protected]>
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.
--- drivers/usb/typec/altmodes/displayport.c | 4 ++-- include/linux/usb/typec_dp.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/usb/typec/altmodes/displayport.c +2 -2
@@ -98,8 +98,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)case DP_STATUS_CON_UFP_D :case DP_STATUS_CON_BOTH :/* NOTE: First acting as DP source */ conf |=DP_CONF_UFP_U_AS_UFP_D ; - pin_assign =DP_CAP_DFP_D_PIN_ASSIGN (dp->alt->vdo) & -DP_CAP_UFP_D_PIN_ASSIGN (dp->port->vdo); + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) & +DP_CAP_PIN_ASSIGN_DFP_D (dp->port->vdo);break ;default :break ;
include/linux/usb/typec_dp.h +5 -0
@@ -73,6 +73,11 @@ enum {#define DP_CAP_USB BIT(7)#define DP_CAP_DFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(15, 8)) >> 8)#define DP_CAP_UFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) +/* Get pin assignment taking plug & receptacle into consideration */ +#define DP_CAP_PIN_ASSIGN_UFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) +#define DP_CAP_PIN_ASSIGN_DFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))/* DisplayPort Status Update VDO bits */ #define DP_STATUS_CONNECTION (_status_) ((_status_) & 3)
Signature · 1 line
2.18.0
Heikki Krogerus
maintainerHi guys,
Quoted 3 lines · Macpaul Lin
From: Pablo Sun <[email protected]>
From: Pablo Sun <[email protected]>
Looks like there's something wrong with the formating of the patch here?
Quoted 23 lines
Fix incorrect pin assignment values when connecting to a monitor with Type-C receptacle instead of a plug.
According to specification, an
UFP_Dreceptacle's pin assignment should came from theUFP_Dpin assignments field (bit 23:16), while anUFP_Dplug's assignments are described in theDFP_Dpin 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=0x140045The existing logic only take cares of
UPF_Dplug case, and would take the bit 15:8 for this0x140045case.This results in an non-existing pin assignment
0x0indp_altmode_configure.To fix this problem a new set of macros are introduced to take plug/receptacle differences into consideration.
Quoted 6 lines
Co-developed-by Pablo Sun <[email protected]>Signed-off-by Pablo Sun <[email protected]>Co-developed-by Macpaul Lin <[email protected]>Signed-off-by Macpaul Lin <[email protected]>Reviewed-by Guillaume Ranquet <[email protected]>
If this is a fix, then you need to have the "Fixes" tag that tells which commit the patch is fixing.
Quoted 38 lines
--- drivers/usb/typec/altmodes/displayport.c | 4 ++-- include/linux/usb/typec_dp.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)drivers/usb/typec/altmodes/displayport.c +2
-2@@ -98,8 +98,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)case DP_STATUS_CON_UFP_D :case DP_STATUS_CON_BOTH :/* NOTE: First acting as DP source */ conf |=DP_CONF_UFP_U_AS_UFP_D ; - pin_assign =DP_CAP_DFP_D_PIN_ASSIGN (dp->alt->vdo) & -DP_CAP_UFP_D_PIN_ASSIGN (dp->port->vdo); + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) & +DP_CAP_PIN_ASSIGN_DFP_D (dp->port->vdo);break ;default :break ;include/linux/usb/typec_dp.h +5
-0@@ -73,6 +73,11 @@ enum {#define DP_CAP_USB BIT(7)#define DP_CAP_DFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(15, 8)) >> 8)#define DP_CAP_UFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) +/* Get pin assignment taking plug & receptacle into consideration */ +#define DP_CAP_PIN_ASSIGN_UFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) +#define DP_CAP_PIN_ASSIGN_DFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))/* DisplayPort Status Update VDO bits */ #define DP_STATUS_CONNECTION (_status_) ((_status_) & 3)Signature · 1 line
2.18.0
thanks,
Signature · 1 line
heikki
Quoted 9 lines · Heikki Krogerus
Hi guys,
Quoted 3 lines · Macpaul Lin
From: Pablo Sun <[email protected]>
From: Pablo Sun <[email protected]>
Looks like there's something wrong with the formating of the patch here?
The duplicated line will be removed in patch v2.
Quoted 30 lines
Quoted 23 lines
Fix incorrect pin assignment values when connecting to a monitor with Type-C receptacle instead of a plug.
According to specification, an
UFP_Dreceptacle's pin assignment should came from theUFP_Dpin assignments field (bit 23:16), while anUFP_Dplug's assignments are described in theDFP_Dpin 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=0x140045The existing logic only take cares of
UPF_Dplug case, and would take the bit 15:8 for this0x140045case.This results in an non-existing pin assignment
0x0indp_altmode_configure.To fix this problem a new set of macros are introduced to take plug/receptacle differences into consideration.
Quoted 6 lines
Co-developed-by Pablo Sun <[email protected]>Signed-off-by Pablo Sun <[email protected]>Co-developed-by Macpaul Lin <[email protected]>Signed-off-by Macpaul Lin <[email protected]>Reviewed-by Guillaume Ranquet <[email protected]>
Quoted 2 lines
If this is a fix, then you need to have the "Fixes" tag that tells which commit the patch is fixing.
Thanks for the review.
Will add "Fixes" tag and "Reviewed-by" tags in patch v2.
Quoted 6 lines
Review
Quoted 6 lines
--- drivers/usb/typec/altmodes/displayport.c | 4 ++-- include/linux/usb/typec_dp.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/typec/altmodes/displayport.c
Quoted 4 lines
drivers/usb/typec/altmodes/displayport.c static int dp_altmode_configure(struct dp_altmode *dp,
Quoted 4 lines
index
9360ca177c7d..8dd0e505ef99100644drivers/usb/typec/altmodes/displayport.c +0
-0@@ -98,8 +98,8 @@ static int dp_altmode_configure(struct dp_altmode *dp,
u8 con)
Quoted 9 lines
Quoted 9 lines
drivers/usb/typec/altmodes/displayport.c +2
-2case DP_STATUS_CON_UFP_D :case DP_STATUS_CON_BOTH :/* NOTE: First acting as DP source */ conf |=DP_CONF_UFP_U_AS_UFP_D ; - pin_assign =DP_CAP_DFP_D_PIN_ASSIGN (dp->alt->vdo) & -DP_CAP_UFP_D_PIN_ASSIGN (dp->port->vdo); + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) & +DP_CAP_PIN_ASSIGN_DFP_D (dp->port->vdo);break ;default :
Quoted 8 lines
include/linux/usb/typec_dp.h enum { · line 74
Quoted 8 lines
drivers/usb/typec/altmodes/displayport.c +0
-0break ;include/linux/usb/typec_dp.h +0
-0@@ -73,6 +73,11 @@ enum {#define DP_CAP_USB BIT(7)#define DP_CAP_DFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(15, 8)) >>
8)
Quoted 1 line
include/linux/usb/typec_dp.h enum { · line 75
Quoted 1 line
include/linux/usb/typec_dp.h +0
-0#define DP_CAP_UFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(23, 16)) >>
16)
Quoted 6 lines
Quoted 6 lines
include/linux/usb/typec_dp.h +5
-0+/* Get pin assignment taking plug & receptacle into consideration */ +#define DP_CAP_PIN_ASSIGN_UFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) +#define DP_CAP_PIN_ASSIGN_DFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))
Quoted 7 lines
Quoted 4 lines
include/linux/usb/typec_dp.h +0
-0/* DisplayPort Status Update VDO bits */ #define DP_STATUS_CONNECTION (_status_) ((_status_) & 3)Signature · 1 line
2.18.0thanks,
Thanks.
Macpaul Lin
PATCH v2 1/1 usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles
In reply to Macpaul LinFrom: Pablo Sun <[email protected]>
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.
---
Changes in v2:
- Fix commit message.
- Remove duplicate "From:" tag.
- Add "Fixes:" tag.
- Add more "Reviewed-by:" tag.
drivers/usb/typec/altmodes/displayport.c | 4 ++-- include/linux/usb/typec_dp.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/usb/typec/altmodes/displayport.c +2 -2
@@ -98,8 +98,8 @@ static int dp_altmode_configure(struct dp_altmode *dp, u8 con)case DP_STATUS_CON_UFP_D :case DP_STATUS_CON_BOTH :/* NOTE: First acting as DP source */ conf |=DP_CONF_UFP_U_AS_UFP_D ; - pin_assign =DP_CAP_DFP_D_PIN_ASSIGN (dp->alt->vdo) & -DP_CAP_UFP_D_PIN_ASSIGN (dp->port->vdo); + pin_assign =DP_CAP_PIN_ASSIGN_UFP_D (dp->alt->vdo) & +DP_CAP_PIN_ASSIGN_DFP_D (dp->port->vdo);break ;default :break ;
include/linux/usb/typec_dp.h +5 -0
@@ -73,6 +73,11 @@ enum {#define DP_CAP_USB BIT(7)#define DP_CAP_DFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(15, 8)) >> 8)#define DP_CAP_UFP_D_PIN_ASSIGN (_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) +/* Get pin assignment taking plug & receptacle into consideration */ +#define DP_CAP_PIN_ASSIGN_UFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_)) +#define DP_CAP_PIN_ASSIGN_DFP_D (_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \ + DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))/* DisplayPort Status Update VDO bits */ #define DP_STATUS_CONNECTION (_status_) ((_status_) & 3)
Signature · 1 line
2.18.0