|
@@ -275,10 +275,11 @@ static enum policy_engine_state pe_sink_ready(void)
|
275
|
275
|
/* Wait for an event */
|
276
|
276
|
if (min_power) {
|
277
|
277
|
evt = chEvtWaitAnyTimeout(PDB_EVT_PE_MSG_RX | PDB_EVT_PE_RESET
|
278
|
|
- | PDB_EVT_PE_I_OVRTEMP, PD_T_SINK_REQUEST);
|
|
278
|
+ | PDB_EVT_PE_I_OVRTEMP | PDB_EVT_PE_GET_SOURCE_CAP,
|
|
279
|
+ PD_T_SINK_REQUEST);
|
279
|
280
|
} else {
|
280
|
281
|
evt = chEvtWaitAny(PDB_EVT_PE_MSG_RX | PDB_EVT_PE_RESET
|
281
|
|
- | PDB_EVT_PE_I_OVRTEMP);
|
|
282
|
+ | PDB_EVT_PE_I_OVRTEMP | PDB_EVT_PE_GET_SOURCE_CAP);
|
282
|
283
|
}
|
283
|
284
|
|
284
|
285
|
/* If we got reset signaling, transition to default */
|
|
@@ -291,6 +292,11 @@ static enum policy_engine_state pe_sink_ready(void)
|
291
|
292
|
return PESinkHardReset;
|
292
|
293
|
}
|
293
|
294
|
|
|
295
|
+ /* If the DPM wants us to, send a Get_Source_Cap message */
|
|
296
|
+ if (evt & PDB_EVT_PE_GET_SOURCE_CAP) {
|
|
297
|
+ return PESinkGetSourceCap;
|
|
298
|
+ }
|
|
299
|
+
|
294
|
300
|
/* If no event was received, the timer ran out. */
|
295
|
301
|
if (evt == 0) {
|
296
|
302
|
/* Repeat our Request message */
|
|
@@ -397,7 +403,28 @@ static enum policy_engine_state pe_sink_ready(void)
|
397
|
403
|
|
398
|
404
|
static enum policy_engine_state pe_sink_get_source_cap(void)
|
399
|
405
|
{
|
400
|
|
- /* Stubbed until we actually have a need for this */
|
|
406
|
+ /* Get a message object */
|
|
407
|
+ union pd_msg *get_source_cap = chPoolAlloc(&pdb_msg_pool);
|
|
408
|
+ /* Make a Get_Source_Cap message */
|
|
409
|
+ get_source_cap->hdr = PD_MSGTYPE_GET_SOURCE_CAP | PD_DATAROLE_UFP
|
|
410
|
+ | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
|
|
411
|
+ /* Transmit the Get_Source_Cap */
|
|
412
|
+ chMBPost(&pdb_prltx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
|
|
413
|
+ chEvtSignal(pdb_prltx_thread, PDB_EVT_PRLTX_MSG_TX);
|
|
414
|
+ eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
|
|
415
|
+ | PDB_EVT_PE_RESET);
|
|
416
|
+ /* Free the sent message */
|
|
417
|
+ chPoolFree(&pdb_msg_pool, get_source_cap);
|
|
418
|
+ get_source_cap = NULL;
|
|
419
|
+ /* If we got reset signaling, transition to default */
|
|
420
|
+ if (evt & PDB_EVT_PE_RESET) {
|
|
421
|
+ return PESinkTransitionDefault;
|
|
422
|
+ }
|
|
423
|
+ /* If the message transmission failed, send a hard reset */
|
|
424
|
+ if ((evt & PDB_EVT_PE_TX_DONE) == 0) {
|
|
425
|
+ return PESinkHardReset;
|
|
426
|
+ }
|
|
427
|
+
|
401
|
428
|
return PESinkReady;
|
402
|
429
|
}
|
403
|
430
|
|