Browse Source

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 7 years ago
parent
commit
45c3bf3d7a
3 changed files with 31 additions and 1 deletions
  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 View File

134
      * omitted.
134
      * omitted.
135
      */
135
      */
136
     pdb_dpm_func transition_typec;
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 View File

43
     PESinkSendSoftReset,
43
     PESinkSendSoftReset,
44
     PESinkSendNotSupported,
44
     PESinkSendNotSupported,
45
     PESinkChunkReceived,
45
     PESinkChunkReceived,
46
+    PESinkNotSupportedReceived,
46
     PESinkSourceUnresponsive
47
     PESinkSourceUnresponsive
47
 };
48
 };
48
 
49
 
414
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
415
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
415
                     cfg->pe._message = NULL;
416
                     cfg->pe._message = NULL;
416
                     return PESinkChunkReceived;
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
                 /* If we got an unknown message, send a soft reset */
425
                 /* If we got an unknown message, send a soft reset */
418
                 } else {
426
                 } else {
419
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
427
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
666
     return PESinkSendNotSupported;
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
  * When Power Delivery is unresponsive, fall back to Type-C Current
689
  * When Power Delivery is unresponsive, fall back to Type-C Current
671
  */
690
  */
756
             case PESinkSourceUnresponsive:
775
             case PESinkSourceUnresponsive:
757
                 state = pe_sink_source_unresponsive(cfg);
776
                 state = pe_sink_source_unresponsive(cfg);
758
                 break;
777
                 break;
778
+            case PESinkNotSupportedReceived:
779
+                state = pe_sink_not_supported_received(cfg);
780
+                break;
759
             default:
781
             default:
760
                 /* This is an error.  It really shouldn't happen.  We might
782
                 /* This is an error.  It really shouldn't happen.  We might
761
                  * want to handle it anyway, though. */
783
                  * want to handle it anyway, though. */

+ 2
- 1
src/main.c View File

84
         pdbs_dpm_transition_min,
84
         pdbs_dpm_transition_min,
85
         pdbs_dpm_transition_standby,
85
         pdbs_dpm_transition_standby,
86
         pdbs_dpm_transition_requested,
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
     .dpm_data = &dpm_data
90
     .dpm_data = &dpm_data
90
 };
91
 };

Loading…
Cancel
Save