Bladeren bron

Add PE_SNK_Not_Supported_Received state

This state requires that the DPM be informed of the receipt of a
Not_Supported message.  Some DPMs may not need to do this, so the new
dpm.not_supported_received function is optional.
Clara Hobbs 6 jaren geleden
bovenliggende
commit
45c3bf3d7a
3 gewijzigde bestanden met toevoegingen van 31 en 1 verwijderingen
  1. 7
    0
      lib/include/pdb_dpm.h
  2. 22
    0
      lib/src/policy_engine.c
  3. 2
    1
      src/main.c

+ 7
- 0
lib/include/pdb_dpm.h Bestand weergeven

@@ -134,6 +134,13 @@ struct pdb_dpm_callbacks {
134 134
      * omitted.
135 135
      */
136 136
     pdb_dpm_func transition_typec;
137
+
138
+    /*
139
+     * Handle a received Not_Supported message.
140
+     *
141
+     * Optional.  If no special handling is needed, this may be omitted.
142
+     */
143
+    pdb_dpm_func not_supported_received;
137 144
 };
138 145
 
139 146
 

+ 22
- 0
lib/src/policy_engine.c Bestand weergeven

@@ -43,6 +43,7 @@ enum policy_engine_state {
43 43
     PESinkSendSoftReset,
44 44
     PESinkSendNotSupported,
45 45
     PESinkChunkReceived,
46
+    PESinkNotSupportedReceived,
46 47
     PESinkSourceUnresponsive
47 48
 };
48 49
 
@@ -414,6 +415,13 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
414 415
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
415 416
                     cfg->pe._message = NULL;
416 417
                     return PESinkChunkReceived;
418
+                /* Tell the DPM a message we sent got a response of
419
+                 * Not_Supported. */
420
+                } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_NOT_SUPPORTED
421
+                        && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
422
+                    chPoolFree(&pdb_msg_pool, cfg->pe._message);
423
+                    cfg->pe._message = NULL;
424
+                    return PESinkNotSupportedReceived;
417 425
                 /* If we got an unknown message, send a soft reset */
418 426
                 } else {
419 427
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
@@ -666,6 +674,17 @@ static enum policy_engine_state pe_sink_chunk_received(struct pdb_config *cfg)
666 674
     return PESinkSendNotSupported;
667 675
 }
668 676
 
677
+static enum policy_engine_state pe_sink_not_supported_received(struct pdb_config *cfg)
678
+{
679
+    /* Inform the Device Policy Manager that we received a Not_Supported
680
+     * message. */
681
+    if (cfg->dpm.not_supported_received != NULL) {
682
+        cfg->dpm.not_supported_received(cfg);
683
+    }
684
+
685
+    return PESinkReady;
686
+}
687
+
669 688
 /*
670 689
  * When Power Delivery is unresponsive, fall back to Type-C Current
671 690
  */
@@ -756,6 +775,9 @@ static THD_FUNCTION(PolicyEngine, vcfg) {
756 775
             case PESinkSourceUnresponsive:
757 776
                 state = pe_sink_source_unresponsive(cfg);
758 777
                 break;
778
+            case PESinkNotSupportedReceived:
779
+                state = pe_sink_not_supported_received(cfg);
780
+                break;
759 781
             default:
760 782
                 /* This is an error.  It really shouldn't happen.  We might
761 783
                  * want to handle it anyway, though. */

+ 2
- 1
src/main.c Bestand weergeven

@@ -84,7 +84,8 @@ static struct pdb_config pdb_config = {
84 84
         pdbs_dpm_transition_min,
85 85
         pdbs_dpm_transition_standby,
86 86
         pdbs_dpm_transition_requested,
87
-        pdbs_dpm_transition_requested /* XXX type-c current */
87
+        pdbs_dpm_transition_requested, /* XXX type-c current */
88
+        NULL
88 89
     },
89 90
     .dpm_data = &dpm_data
90 91
 };

Laden…
Annuleren
Opslaan