From a8e6b070cbd107d8c2f44f44ae8231a4f4efea90 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Fri, 17 Feb 2017 18:57:20 -0800 Subject: pd: prefer CD pin assignments over EF for USBC->USBC case. BRANCH=samus,glados,oak,gru,reef BUG=chromium:694597 TEST=manual, connect samus to USB-C monitor via cable and see it select pin assigmnent 'C' Change-Id: Iddad5b654715bd30ba081c62f8fb53e07816498c Reviewed-on: https://chromium-review.googlesource.com/465379 Commit-Ready: Todd Broch Tested-by: Todd Broch Reviewed-by: Vincent Palatin --- common/usb_pd_policy.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 6c33d48f58..568169fbbf 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -496,8 +496,8 @@ static void dfp_consume_attention(int port, uint32_t *payload) } /* - * This algorithm defaults to choosing higher pin config over lower ones. Pin - * configs are organized in pairs with the following breakdown. + * This algorithm defaults to choosing higher pin config over lower ones in + * order to prefer multi-function if desired. * * NAME | SIGNALING | OUTPUT TYPE | MULTI-FUNCTION | PIN CONFIG * ------------------------------------------------------------- @@ -511,9 +511,8 @@ static void dfp_consume_attention(int port, uint32_t *payload) * if UFP has NOT asserted multi-function preferred code masks away B/D/F * leaving only A/C/E. For single-output dongles that should leave only one * possible pin config depending on whether its a converter DP->(VGA|HDMI) or DP - * output. If someone creates a multi-output dongle presumably they would need - * to either offer different mode capabilities depending upon connection type or - * the DFP would need additional system policy to expose those options. + * output. If UFP is a USB-C receptacle it may assert C/D/E/F. The DFP USB-C + * receptacle must always choose C/D in those cases. */ int pd_dfp_dp_get_pin_mode(int port, uint32_t status) { @@ -535,6 +534,10 @@ int pd_dfp_dp_get_pin_mode(int port, uint32_t status) /* TODO(crosbug.com/p/39656) revisit if DFP drives USB Gen 2 signals */ pin_caps &= ~MODE_DP_PIN_BR2_MASK; + /* if C/D present they have precedence over E/F for USB-C->USB-C */ + if (pin_caps & (MODE_DP_PIN_C | MODE_DP_PIN_D)) + pin_caps &= ~(MODE_DP_PIN_E | MODE_DP_PIN_F); + /* get_next_bit returns undefined for zero */ if (!pin_caps) return 0; -- cgit v1.2.1