diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-07-07 17:56:26 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-08 04:24:42 +0000 |
commit | 786e208b508585d490722f143c0f7ec3971e15d5 (patch) | |
tree | 9a008c5a371fd69d90a188da73b2eb68714762d9 /common/usb_pd_protocol.c | |
parent | 2d1509cd16d8f0a2c6a58bd5ddd8dfac98e34683 (diff) | |
download | chrome-ec-786e208b508585d490722f143c0f7ec3971e15d5.tar.gz |
pd: properly transition when answering GetSourceCap
Once the source has successfully sent a SourceCap packet (ie it got
acked), it needs to transition from the DISCOVERY to the NEGOCIATE
state.
This was done when the source was sending unsolicited SourceCap, but
this was missing when the SourceCap was an answer to a Sink GetSourceCap
request. The usual effect of the missing transition was sending twice
the SourceCap triggering some collisions.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=plug a Zinger to a Firefly, randomly push the Firefly voltage
selection buttons and see the transition always happening properly.
Change-Id: If4b335e2144595f22ad4e9a8a9e289506f597407
Reviewed-on: https://chromium-review.googlesource.com/206941
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r-- | common/usb_pd_protocol.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 36350449a0..d5bda7c6f3 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -540,6 +540,7 @@ static void handle_data_request(void *ctxt, uint16_t head, uint32_t *payload) static void handle_ctrl_request(void *ctxt, uint16_t head, uint32_t *payload) { int type = PD_HEADER_TYPE(head); + int res; switch (type) { case PD_CTRL_GOOD_CRC: @@ -549,7 +550,9 @@ static void handle_ctrl_request(void *ctxt, uint16_t head, uint32_t *payload) /* Nothing else to do */ break; case PD_CTRL_GET_SOURCE_CAP: - send_source_cap(ctxt); + res = send_source_cap(ctxt); + if ((res >= 0) && (pd_task_state == PD_STATE_SRC_DISCOVERY)) + pd_task_state = PD_STATE_SRC_NEGOCIATE; break; #ifdef CONFIG_USB_PD_DUAL_ROLE case PD_CTRL_GET_SINK_CAP: |