|
@@ -409,8 +409,8 @@ static enum policy_engine_state pe_sink_get_source_cap(struct pdb_config *cfg)
|
409
|
409
|
/* Get a message object */
|
410
|
410
|
union pd_msg *get_source_cap = chPoolAlloc(&pdb_msg_pool);
|
411
|
411
|
/* Make a Get_Source_Cap message */
|
412
|
|
- get_source_cap->hdr = PD_MSGTYPE_GET_SOURCE_CAP | PD_DATAROLE_UFP
|
413
|
|
- | PD_SPECREV_2_0 | PD_POWERROLE_SINK | PD_NUMOBJ(0);
|
|
412
|
+ get_source_cap->hdr = cfg->pe.hdr_template | PD_MSGTYPE_GET_SOURCE_CAP
|
|
413
|
+ | PD_NUMOBJ(0);
|
414
|
414
|
/* Transmit the Get_Source_Cap */
|
415
|
415
|
chMBPost(&cfg->prl.tx_mailbox, (msg_t) get_source_cap, TIME_IMMEDIATE);
|
416
|
416
|
chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
|
|
@@ -503,8 +503,7 @@ static enum policy_engine_state pe_sink_soft_reset(struct pdb_config *cfg)
|
503
|
503
|
/* Get a message object */
|
504
|
504
|
union pd_msg *accept = chPoolAlloc(&pdb_msg_pool);
|
505
|
505
|
/* Make an Accept message */
|
506
|
|
- accept->hdr = PD_MSGTYPE_ACCEPT | PD_DATAROLE_UFP | PD_SPECREV_2_0
|
507
|
|
- | PD_POWERROLE_SINK | PD_NUMOBJ(0);
|
|
506
|
+ accept->hdr = cfg->pe.hdr_template | PD_MSGTYPE_ACCEPT | PD_NUMOBJ(0);
|
508
|
507
|
/* Transmit the Accept */
|
509
|
508
|
chMBPost(&cfg->prl.tx_mailbox, (msg_t) accept, TIME_IMMEDIATE);
|
510
|
509
|
chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
|
|
@@ -533,8 +532,7 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
|
533
|
532
|
/* Get a message object */
|
534
|
533
|
union pd_msg *softrst = chPoolAlloc(&pdb_msg_pool);
|
535
|
534
|
/* Make a Soft_Reset message */
|
536
|
|
- softrst->hdr = PD_MSGTYPE_SOFT_RESET | PD_DATAROLE_UFP | PD_SPECREV_2_0
|
537
|
|
- | PD_POWERROLE_SINK | PD_NUMOBJ(0);
|
|
535
|
+ softrst->hdr = cfg->pe.hdr_template | PD_MSGTYPE_SOFT_RESET | PD_NUMOBJ(0);
|
538
|
536
|
/* Transmit the soft reset */
|
539
|
537
|
chMBPost(&cfg->prl.tx_mailbox, (msg_t) softrst, TIME_IMMEDIATE);
|
540
|
538
|
chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
|
|
@@ -593,8 +591,7 @@ static enum policy_engine_state pe_sink_send_reject(struct pdb_config *cfg)
|
593
|
591
|
/* Get a message object */
|
594
|
592
|
union pd_msg *reject = chPoolAlloc(&pdb_msg_pool);
|
595
|
593
|
/* Make a Reject message */
|
596
|
|
- reject->hdr = PD_MSGTYPE_REJECT | PD_DATAROLE_UFP | PD_SPECREV_2_0
|
597
|
|
- | PD_POWERROLE_SINK | PD_NUMOBJ(0);
|
|
594
|
+ reject->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REJECT | PD_NUMOBJ(0);
|
598
|
595
|
|
599
|
596
|
/* Transmit the message */
|
600
|
597
|
chMBPost(&cfg->prl.tx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
|
|
@@ -655,6 +652,8 @@ static THD_FUNCTION(PolicyEngine, vcfg) {
|
655
|
652
|
chMBObjectInit(&cfg->pe.mailbox, cfg->pe._mailbox_queue, PDB_MSG_POOL_SIZE);
|
656
|
653
|
/* Initialize the old_tcc_match */
|
657
|
654
|
cfg->pe._old_tcc_match = -1;
|
|
655
|
+ /* Initialize the PD message header template */
|
|
656
|
+ cfg->pe.hdr_template = PD_DATAROLE_UFP | PD_SPECREV_2_0 | PD_POWERROLE_SINK;
|
658
|
657
|
|
659
|
658
|
while (true) {
|
660
|
659
|
switch (state) {
|