Browse Source

Don't enter Sink Standby if we don't have to

According to the USB Power Delivery Specification Revision 3.0, Version
1.1, section 7.2.3.1, we're not required to enter Sink Standby when
changing the negotiated voltage on a single PPS APDO.  Now we don't.
This is done in the PE, so the DPM doesn't have to lift a finger to
avoid the unnecessary standby.
Clara Hobbs 7 years ago
parent
commit
35c5d27f6f
2 changed files with 21 additions and 3 deletions
  1. 2
    0
      lib/include/pdb_pe.h
  2. 19
    3
      lib/src/policy_engine.c

+ 2
- 0
lib/include/pdb_pe.h View File

62
     int8_t _old_tcc_match;
62
     int8_t _old_tcc_match;
63
     /* The index of the first PPS APDO */
63
     /* The index of the first PPS APDO */
64
     uint8_t _pps_index;
64
     uint8_t _pps_index;
65
+    /* The index of the just-requested PPS APDO */
66
+    uint8_t _last_pps;
65
     /* Virtual timer for SinkPPSPeriodicTimer */
67
     /* Virtual timer for SinkPPSPeriodicTimer */
66
     virtual_timer_t _sink_pps_periodic_timer;
68
     virtual_timer_t _sink_pps_periodic_timer;
67
     /* Queue for the PE mailbox */
69
     /* Queue for the PE mailbox */

+ 19
- 3
lib/src/policy_engine.c View File

142
 
142
 
143
 static enum policy_engine_state pe_sink_eval_cap(struct pdb_config *cfg)
143
 static enum policy_engine_state pe_sink_eval_cap(struct pdb_config *cfg)
144
 {
144
 {
145
-    /* If we have a message, remember the index of the first PPS APDO so we can
146
-     * check if the request is for a PPS APDO in PE_SNK_Select_Cap. */
145
+    /* If we have a Source_Capabilities message, remember the index of the
146
+     * first PPS APDO so we can check if the request is for a PPS APDO in
147
+     * PE_SNK_Select_Cap. */
147
     if (cfg->pe._message != NULL) {
148
     if (cfg->pe._message != NULL) {
148
         /* Start by assuming we won't find a PPS APDO (set the index greater
149
         /* Start by assuming we won't find a PPS APDO (set the index greater
149
          * than the maximum possible) */
150
          * than the maximum possible) */
156
                 break;
157
                 break;
157
             }
158
             }
158
         }
159
         }
160
+        /* New capabilities also means we can't be making a request from the
161
+         * same PPS APDO */
162
+        cfg->pe._last_pps = 8;
159
     }
163
     }
160
     /* Get a message object for the request if we don't have one already */
164
     /* Get a message object for the request if we don't have one already */
161
     if (cfg->pe._last_dpm_request == NULL) {
165
     if (cfg->pe._last_dpm_request == NULL) {
162
         cfg->pe._last_dpm_request = chPoolAlloc(&pdb_msg_pool);
166
         cfg->pe._last_dpm_request = chPoolAlloc(&pdb_msg_pool);
167
+    } else {
168
+        /* Remember the last PDO we requested if it was a PPS APDO */
169
+        if (PD_RDO_OBJPOS_GET(cfg->pe._last_dpm_request) >= cfg->pe._pps_index) {
170
+            cfg->pe._last_pps = PD_RDO_OBJPOS_GET(cfg->pe._last_dpm_request);
171
+        /* Otherwise, forget any PPS APDO we had requested */
172
+        } else {
173
+            cfg->pe._last_pps = 8;
174
+        }
163
     }
175
     }
164
     /* Ask the DPM what to request */
176
     /* Ask the DPM what to request */
165
     cfg->dpm.evaluate_capability(cfg, cfg->pe._message,
177
     cfg->dpm.evaluate_capability(cfg, cfg->pe._message,
221
         if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_ACCEPT
233
         if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_ACCEPT
222
                 && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
234
                 && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
223
             /* Transition to Sink Standby if necessary */
235
             /* Transition to Sink Standby if necessary */
224
-            cfg->dpm.transition_standby(cfg);
236
+            if (PD_RDO_OBJPOS_GET(cfg->pe._last_dpm_request) != cfg->pe._last_pps) {
237
+                cfg->dpm.transition_standby(cfg);
238
+            }
225
 
239
 
226
             cfg->pe._min_power = false;
240
             cfg->pe._min_power = false;
227
 
241
 
770
     cfg->pe._old_tcc_match = -1;
784
     cfg->pe._old_tcc_match = -1;
771
     /* Initialize the pps_index */
785
     /* Initialize the pps_index */
772
     cfg->pe._pps_index = 8;
786
     cfg->pe._pps_index = 8;
787
+    /* Initialize the last_pps */
788
+    cfg->pe._last_pps = 8;
773
     /* Initialize the PD message header template */
789
     /* Initialize the PD message header template */
774
     cfg->pe.hdr_template = PD_DATAROLE_UFP | PD_POWERROLE_SINK;
790
     cfg->pe.hdr_template = PD_DATAROLE_UFP | PD_POWERROLE_SINK;
775
 
791
 

Loading…
Cancel
Save