|
@@ -49,8 +49,10 @@ static enum policy_engine_state pe_sink_startup(struct pdb_config *cfg)
|
49
|
49
|
{
|
50
|
50
|
/* We don't have an explicit contract currently */
|
51
|
51
|
cfg->pe._explicit_contract = false;
|
52
|
|
- /* Tell the DPM that we've started negotiations */
|
53
|
|
- cfg->dpm.pd_start(cfg);
|
|
52
|
+ /* Tell the DPM that we've started negotiations, if it cares */
|
|
53
|
+ if (cfg->dpm.pd_start != NULL) {
|
|
54
|
+ cfg->dpm.pd_start(cfg);
|
|
55
|
+ }
|
54
|
56
|
|
55
|
57
|
/* No need to reset the protocol layer here. There are two ways into this
|
56
|
58
|
* state: startup and exiting hard reset. On startup, the protocol layer
|
|
@@ -357,7 +359,8 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
|
357
|
359
|
/* Handle GotoMin messages */
|
358
|
360
|
} else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GOTOMIN
|
359
|
361
|
&& PD_NUMOBJ_GET(cfg->pe._message) == 0) {
|
360
|
|
- if (cfg->dpm.giveback_enabled(cfg)) {
|
|
362
|
+ if (cfg->dpm.giveback_enabled != NULL
|
|
363
|
+ && cfg->dpm.giveback_enabled(cfg)) {
|
361
|
364
|
/* Transition to the minimum current level */
|
362
|
365
|
cfg->dpm.transition_min(cfg);
|
363
|
366
|
cfg->pe._min_power = true;
|
|
@@ -620,16 +623,21 @@ static enum policy_engine_state pe_sink_send_reject(struct pdb_config *cfg)
|
620
|
623
|
*/
|
621
|
624
|
static enum policy_engine_state pe_sink_source_unresponsive(struct pdb_config *cfg)
|
622
|
625
|
{
|
623
|
|
- int tcc_match = cfg->dpm.evaluate_typec_current(cfg, fusb_get_typec_current(&cfg->fusb));
|
|
626
|
+ /* If the DPM can evaluate the Type-C Current advertisement */
|
|
627
|
+ if (cfg->dpm.evaluate_typec_current != NULL) {
|
|
628
|
+ /* Make the DPM evaluate the Type-C Current advertisement */
|
|
629
|
+ int tcc_match = cfg->dpm.evaluate_typec_current(cfg,
|
|
630
|
+ fusb_get_typec_current(&cfg->fusb));
|
|
631
|
+
|
|
632
|
+ /* If the last two readings are the same, set the output */
|
|
633
|
+ if (cfg->pe._old_tcc_match == tcc_match) {
|
|
634
|
+ cfg->dpm.transition_typec(cfg);
|
|
635
|
+ }
|
624
|
636
|
|
625
|
|
- /* If the last two readings are the same, set the output */
|
626
|
|
- if (cfg->pe._old_tcc_match == tcc_match) {
|
627
|
|
- cfg->dpm.transition_typec(cfg);
|
|
637
|
+ /* Remember whether or not the last measurement succeeded */
|
|
638
|
+ cfg->pe._old_tcc_match = tcc_match;
|
628
|
639
|
}
|
629
|
640
|
|
630
|
|
- /* Remember whether or not the last measurement succeeded */
|
631
|
|
- cfg->pe._old_tcc_match = tcc_match;
|
632
|
|
-
|
633
|
641
|
/* Wait tPDDebounce between measurements */
|
634
|
642
|
chThdSleep(PD_T_PD_DEBOUNCE);
|
635
|
643
|
|