Browse Source

Set the Specification Revision field to 2.0 or 3.0

Based on the first message sent from the Source, we now set the
Specification Revision field of our messages to 2.0 or 3.0.  We don't do
anything else 3.0 yet though, so it's a bit of lie, but this is a
necessary first step.
Clara Hobbs 7 years ago
parent
commit
d276942579
1 changed files with 13 additions and 1 deletions
  1. 13
    1
      lib/src/policy_engine.c

+ 13
- 1
lib/src/policy_engine.c View File

@@ -97,6 +97,18 @@ static enum policy_engine_state pe_sink_wait_cap(struct pdb_config *cfg)
97 97
             /* If we got a Source_Capabilities message, read it. */
98 98
             if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
99 99
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
100
+                /* First, determine what PD revision we're using */
101
+                if ((cfg->pe.hdr_template & PD_HDR_SPECREV) == PD_SPECREV_1_0) {
102
+                    /* If the other end is using at least version 3.0, we'll
103
+                     * use version 3.0. */
104
+                    if ((cfg->pe._message->hdr & PD_HDR_SPECREV) >= PD_SPECREV_3_0) {
105
+                        cfg->pe.hdr_template |= PD_SPECREV_3_0;
106
+                    /* Otherwise, use 2.0.  Don't worry about the 1.0 case
107
+                     * because we don't have hardware for PD 1.0 signaling. */
108
+                    } else {
109
+                        cfg->pe.hdr_template |= PD_SPECREV_2_0;
110
+                    }
111
+                }
100 112
                 return PESinkEvalCap;
101 113
             /* If the message was a Soft_Reset, do the soft reset procedure */
102 114
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOFT_RESET
@@ -653,7 +665,7 @@ static THD_FUNCTION(PolicyEngine, vcfg) {
653 665
     /* Initialize the old_tcc_match */
654 666
     cfg->pe._old_tcc_match = -1;
655 667
     /* Initialize the PD message header template */
656
-    cfg->pe.hdr_template = PD_DATAROLE_UFP | PD_SPECREV_2_0 | PD_POWERROLE_SINK;
668
+    cfg->pe.hdr_template = PD_DATAROLE_UFP | PD_POWERROLE_SINK;
657 669
 
658 670
     while (true) {
659 671
         switch (state) {

Loading…
Cancel
Save