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
             /* If we got a Source_Capabilities message, read it. */
97
             /* If we got a Source_Capabilities message, read it. */
98
             if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
98
             if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
99
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
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
                 return PESinkEvalCap;
112
                 return PESinkEvalCap;
101
             /* If the message was a Soft_Reset, do the soft reset procedure */
113
             /* If the message was a Soft_Reset, do the soft reset procedure */
102
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOFT_RESET
114
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOFT_RESET
653
     /* Initialize the old_tcc_match */
665
     /* Initialize the old_tcc_match */
654
     cfg->pe._old_tcc_match = -1;
666
     cfg->pe._old_tcc_match = -1;
655
     /* Initialize the PD message header template */
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
     while (true) {
670
     while (true) {
659
         switch (state) {
671
         switch (state) {

Loading…
Cancel
Save