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,7 +41,7 @@ enum policy_engine_state {
41 41
     PESinkTransitionDefault,
42 42
     PESinkSoftReset,
43 43
     PESinkSendSoftReset,
44
-    PESinkSendReject,
44
+    PESinkSendNotSupported,
45 45
     PESinkSourceUnresponsive
46 46
 };
47 47
 
@@ -332,42 +332,42 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
332 332
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
333 333
                 cfg->pe._message = NULL;
334 334
                 return PESinkReady;
335
-            /* Reject DR_Swap messages */
335
+            /* DR_Swap messages are not supported */
336 336
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_DR_SWAP
337 337
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
338 338
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
339 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 342
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GET_SOURCE_CAP
343 343
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
344 344
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
345 345
                 cfg->pe._message = NULL;
346
-                return PESinkSendReject;
347
-            /* Reject PR_Swap messages */
346
+                return PESinkSendNotSupported;
347
+            /* PR_Swap messages are not supported */
348 348
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_PR_SWAP
349 349
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
350 350
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
351 351
                 cfg->pe._message = NULL;
352
-                return PESinkSendReject;
353
-            /* Reject VCONN_Swap messages */
352
+                return PESinkSendNotSupported;
353
+            /* VCONN_Swap messages are not supported */
354 354
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_VCONN_SWAP
355 355
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
356 356
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
357 357
                 cfg->pe._message = NULL;
358
-                return PESinkSendReject;
359
-            /* Reject Request messages */
358
+                return PESinkSendNotSupported;
359
+            /* Request messages are not supported */
360 360
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_REQUEST
361 361
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
362 362
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
363 363
                 cfg->pe._message = NULL;
364
-                return PESinkSendReject;
365
-            /* Reject Sink_Capabilities messages */
364
+                return PESinkSendNotSupported;
365
+            /* Sink_Capabilities messages are not supported */
366 366
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SINK_CAPABILITIES
367 367
                     && PD_NUMOBJ_GET(cfg->pe._message) > 0) {
368 368
                 chPoolFree(&pdb_msg_pool, cfg->pe._message);
369 369
                 cfg->pe._message = NULL;
370
-                return PESinkSendReject;
370
+                return PESinkSendNotSupported;
371 371
             /* Handle GotoMin messages */
372 372
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_GOTOMIN
373 373
                     && PD_NUMOBJ_GET(cfg->pe._message) == 0) {
@@ -381,10 +381,10 @@ static enum policy_engine_state pe_sink_ready(struct pdb_config *cfg)
381 381
                     cfg->pe._message = NULL;
382 382
                     return PESinkTransitionSink;
383 383
                 } else {
384
-                    /* We don't support GiveBack, so send a Reject */
384
+                    /* GiveBack is not supported */
385 385
                     chPoolFree(&pdb_msg_pool, cfg->pe._message);
386 386
                     cfg->pe._message = NULL;
387
-                    return PESinkSendReject;
387
+                    return PESinkSendNotSupported;
388 388
                 }
389 389
             /* Evaluate new Source_Capabilities */
390 390
             } else if (PD_MSGTYPE_GET(cfg->pe._message) == PD_MSGTYPE_SOURCE_CAPABILITIES
@@ -598,22 +598,28 @@ static enum policy_engine_state pe_sink_send_soft_reset(struct pdb_config *cfg)
598 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 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 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 616
     chEvtSignal(cfg->prl.tx_thread, PDB_EVT_PRLTX_MSG_TX);
611 617
     eventmask_t evt = chEvtWaitAny(PDB_EVT_PE_TX_DONE | PDB_EVT_PE_TX_ERR
612 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 624
     /* If we got reset signaling, transition to default */
619 625
     if (evt & PDB_EVT_PE_RESET) {
@@ -708,8 +714,8 @@ static THD_FUNCTION(PolicyEngine, vcfg) {
708 714
             case PESinkSendSoftReset:
709 715
                 state = pe_sink_send_soft_reset(cfg);
710 716
                 break;
711
-            case PESinkSendReject:
712
-                state = pe_sink_send_reject(cfg);
717
+            case PESinkSendNotSupported:
718
+                state = pe_sink_send_not_supported(cfg);
713 719
                 break;
714 720
             case PESinkSourceUnresponsive:
715 721
                 state = pe_sink_source_unresponsive(cfg);

Loading…
Cancel
Save