Browse Source

Send Not_Supported messages in PD 3.0 mode

In PD 3.0, there's a new control message, Not_Supported, which is sent
unsurprisingly when unsupported messages are received.  Basically, every
time we had sent a Reject message in PD 2.0, we're now supposed to send
Not_Supported instead.  As of this commit, that's exactly what we do.
Clara Hobbs 7 years ago
parent
commit
bf58de1ccd
1 changed files with 31 additions and 25 deletions
  1. 31
    25
      lib/src/policy_engine.c

+ 31
- 25
lib/src/policy_engine.c View File

41
     PESinkTransitionDefault,
41
     PESinkTransitionDefault,
42
     PESinkSoftReset,
42
     PESinkSoftReset,
43
     PESinkSendSoftReset,
43
     PESinkSendSoftReset,
44
-    PESinkSendReject,
44
+    PESinkSendNotSupported,
45
     PESinkSourceUnresponsive
45
     PESinkSourceUnresponsive
46
 };
46
 };
47
 
47
 
332
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
332
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
333
                 cfg->pe._message = NULL;
333
                 cfg->pe._message = NULL;
334
                 return PESinkReady;
334
                 return PESinkReady;
335
-            /* Reject DR_Swap messages */
335
+            /* DR_Swap messages are not supported */
336
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_DR_SWAP
336
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_DR_SWAP
337
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
337
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
338
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
338
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
339
                 cfg->pe._message = NULL;
339
                 cfg->pe._message = NULL;
340
-                return PESinkSendReject;
341
-            /* Reject Get_Source_Cap messages */
340
+                return PESinkSendNotSupported;
341
+            /* Get_Source_Cap messages are not supported */
342
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GET_SOURCE_CAP
342
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GET_SOURCE_CAP
343
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
343
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
344
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
344
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
345
                 cfg->pe._message = NULL;
345
                 cfg->pe._message = NULL;
346
-                return PESinkSendReject;
347
-            /* Reject PR_Swap messages */
346
+                return PESinkSendNotSupported;
347
+            /* PR_Swap messages are not supported */
348
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_PR_SWAP
348
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_PR_SWAP
349
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
349
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
350
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
350
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
351
                 cfg->pe._message = NULL;
351
                 cfg->pe._message = NULL;
352
-                return PESinkSendReject;
353
-            /* Reject VCONN_Swap messages */
352
+                return PESinkSendNotSupported;
353
+            /* VCONN_Swap messages are not supported */
354
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_VCONN_SWAP
354
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_VCONN_SWAP
355
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
355
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
356
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
356
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
357
                 cfg->pe._message = NULL;
357
                 cfg->pe._message = NULL;
358
-                return PESinkSendReject;
359
-            /* Reject Request messages */
358
+                return PESinkSendNotSupported;
359
+            /* Request messages are not supported */
360
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_REQUEST
360
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_REQUEST
361
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
361
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
362
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
362
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
363
                 cfg->pe._message = NULL;
363
                 cfg->pe._message = NULL;
364
-                return PESinkSendReject;
365
-            /* Reject Sink_Capabilities messages */
364
+                return PESinkSendNotSupported;
365
+            /* Sink_Capabilities messages are not supported */
366
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SINK_CAPABILITIES
366
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SINK_CAPABILITIES
367
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
367
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
368
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
368
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
369
                 cfg->pe._message = NULL;
369
                 cfg->pe._message = NULL;
370
-                return PESinkSendReject;
370
+                return PESinkSendNotSupported;
371
             /* Handle GotoMin messages */
371
             /* Handle GotoMin messages */
372
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GOTOMIN
372
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GOTOMIN
373
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
373
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
381
                     cfg->pe._message = NULL;
381
                     cfg->pe._message = NULL;
382
                     return PESinkTransitionSink;
382
                     return PESinkTransitionSink;
383
                 } else {
383
                 } else {
384
-                    /* We don't support GiveBack, so send a Reject */
384
+                    /* GiveBack is not supported */
385
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
385
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
386
                     cfg->pe._message = NULL;
386
                     cfg->pe._message = NULL;
387
-                    return PESinkSendReject;
387
+                    return PESinkSendNotSupported;
388
                 }
388
                 }
389
             /* Evaluate new Source_Capabilities */
389
             /* Evaluate new Source_Capabilities */
390
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
390
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
598
     return PESinkHardReset;
598
     return PESinkHardReset;
599
 }
599
 }
600
 
600
 
601
-static enum policy_engine_state pe_sink_send_reject(struct pdb_config *cfg)
601
+static enum policy_engine_state pe_sink_send_not_supported(struct pdb_config *cfg)
602
 {
602
 {
603
     /* Get a message object */
603
     /* Get a message object */
604
-    union pd_msg *reject = chPoolAlloc(&pdb_msg_pool);
605
-    /* Make a Reject message */
606
-    reject->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REJECT | PD_NUMOBJ(0);
604
+    union pd_msg *not_supported = chPoolAlloc(&pdb_msg_pool);
605
+
606
+    if ((cfg->pe.hdr_template & PD_HDR_SPECREV) == PD_SPECREV_2_0) {
607
+        /* Make a Reject message */
608
+        not_supported->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REJECT | PD_NUMOBJ(0);
609
+    } else if ((cfg->pe.hdr_template & PD_HDR_SPECREV) == PD_SPECREV_3_0) {
610
+        /* Make a Not_Supported message */
611
+        not_supported->hdr = cfg->pe.hdr_template | PD_MSGTYPE_NOT_SUPPORTED | PD_NUMOBJ(0);
612
+    }
607
 
613
 
608
     /* Transmit the message */
614
     /* Transmit the message */
609
-    chMBPost(&cfg->prl.tx_mailbox, (msg_t) reject, TIME_IMMEDIATE);
615
+    chMBPost(&cfg->prl.tx_mailbox, (msg_t) not_supported, TIME_IMMEDIATE);
610
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
616
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
611
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
612
             | PDB_EVT_PE_RESET);
618
             | PDB_EVT_PE_RESET);
613
 
619
 
614
-    /* Free the Reject message */
615
-    chPoolFree(&pdb_msg_pool, reject);
616
-    reject = NULL;
620
+    /* Free the message */
621
+    chPoolFree(&pdb_msg_pool, not_supported);
622
+    not_supported = NULL;
617
 
623
 
618
     /* If we got reset signaling, transition to default */
624
     /* If we got reset signaling, transition to default */
619
     if (evt & PDB_EVT_PE_RESET) {
625
     if (evt & PDB_EVT_PE_RESET) {
708
             case PESinkSendSoftReset:
714
             case PESinkSendSoftReset:
709
                 state = pe_sink_send_soft_reset(cfg);
715
                 state = pe_sink_send_soft_reset(cfg);
710
                 break;
716
                 break;
711
-            case PESinkSendReject:
712
-                state = pe_sink_send_reject(cfg);
717
+            case PESinkSendNotSupported:
718
+                state = pe_sink_send_not_supported(cfg);
713
                 break;
719
                 break;
714
             case PESinkSourceUnresponsive:
720
             case PESinkSourceUnresponsive:
715
                 state = pe_sink_source_unresponsive(cfg);
721
                 state = pe_sink_source_unresponsive(cfg);

Loading…
Cancel
Save