-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
dp_connectorimpl.cpp
6889 lines (6033 loc) · 236 KB
/
dp_connectorimpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* SPDX-FileCopyrightText: Copyright (c) 1993-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************* DisplayPort********************************\
* *
* Module: dp_connectorimpl.cpp *
* DP connector implementation *
* *
\***************************************************************************/
#include "dp_internal.h"
#include "dp_guid.h"
#include "dp_configcaps.h"
#include "dp_list.h"
#include "dp_buffer.h"
#include "dp_auxdefs.h"
#include "dp_watermark.h"
#include "dp_edid.h"
#include "dp_discovery.h"
#include "dp_groupimpl.h"
#include "dp_deviceimpl.h"
#include "dp_connectorimpl.h"
#include "dp_auxbus.h"
#include "dpringbuffertypes.h"
#include "ctrl/ctrl0073/ctrl0073dfp.h"
#include "ctrl/ctrl0073/ctrl0073dp.h"
#include "dp_tracing.h"
using namespace DisplayPort;
// These wrappers are specifically for DSC PPS library malloc and free callbacks
// Pointer to these functions are populated to dscMalloc/dscFree in DSC_InitializeCallBack and it is initialized from both DPLib and HDMiPacketLib.
// In HDMI case, callback function for malloc/free needs client handle so to match function prototype, in DP case, adding these wrappers.
extern "C" void * dpMallocCb(const void *clientHandle, NvLength size);
extern "C" void dpFreeCb(const void *clientHandle, void *pMemPtr);
extern "C" void * dpMallocCb(const void *clientHandle, NvLength size)
{
return dpMalloc(size);
}
extern "C" void dpFreeCb(const void *clientHandle, void *pMemPtr)
{
dpFree(pMemPtr);
}
ConnectorImpl::ConnectorImpl(MainLink * main, AuxBus * auxBus, Timer * timer, Connector::EventSink * sink)
: main(main),
auxBus(auxBus),
timer(timer),
sink(sink),
bIgnoreSrcOuiHandshake(false),
linkPolicy(),
linkGuessed(false),
isLinkQuiesced(false),
bNoLtDoneAfterHeadDetach(false),
isDP12AuthCap(false),
isHDCPAuthOn(false),
isHDCPReAuthPending(false),
isHDCPAuthTriggered(false),
isHopLimitExceeded(false),
isDiscoveryDetectComplete(false),
bDeferNotifyLostDevice(false),
hdcpValidateData(),
authRetries(0),
retryLT(0),
hdcpCapsRetries(0),
hdcpCpIrqRxStatusRetries(0),
bFromResumeToNAB(false),
bAttachOnResume(false),
bHdcpAuthOnlyOnDemand(false),
constructorFailed(false),
policyModesetOrderMitigation(false),
policyForceLTAtNAB(false),
policyAssessLinkSafely(false),
bDisableVbiosScratchRegisterUpdate(false),
modesetOrderMitigation(false),
compoundQueryActive(false),
compoundQueryResult(false),
compoundQueryCount(0),
messageManager(0),
discoveryManager(0),
numPossibleLnkCfg(0),
linkAwaitingTransition(false),
linkState(DP_TRANSPORT_MODE_INIT),
bAudioOverRightPanel(false),
connectorActive(false),
firmwareGroup(0),
bAcpiInitDone(false),
bIsUefiSystem(false),
bSkipLt(false),
bMitigateZombie(false),
bDelayAfterD3(false),
bKeepOptLinkAlive(false),
bNoFallbackInPostLQA(false),
LT2FecLatencyMs(0),
bDscCapBasedOnParent(false),
ResStatus(this)
{
clearTimeslices();
hal = MakeDPCDHAL(auxBus, timer);
if (hal == NULL)
{
constructorFailed = true;
return;
}
highestAssessedLC = getMaxLinkConfig();
firmwareGroup = createFirmwareGroup();
if (firmwareGroup == NULL)
{
constructorFailed = true;
return;
}
hal->setPC2Disabled(main->isPC2Disabled());
//
// If a GPU is DP1.2 or DP1.4 supported then set these capalibilities.
// This is used for accessing DP1.2/DP1.4 specific register space & features
//
hal->setGpuDPSupportedVersions(main->isDP1_2Supported(), main->isDP1_4Supported());
// Set if GPU supports FEC. Check panel FEC caps only if GPU supports it.
hal->setGpuFECSupported(main->isFECSupported());
// Set if LTTPR training is supported per regKey
hal->setLttprSupported(main->isLttprSupported());
const DP_REGKEY_DATABASE& dpRegkeyDatabase = main->getRegkeyDatabase();
this->applyRegkeyOverrides(dpRegkeyDatabase);
hal->applyRegkeyOverrides(dpRegkeyDatabase);
// Initialize DSC callbacks
DSC_CALLBACK callback;
callback.clientHandle = NULL;
callback.dscPrint = NULL;
callback.dscMalloc = dpMallocCb;
callback.dscFree = dpFreeCb;
DSC_InitializeCallback(callback);
}
void ConnectorImpl::applyRegkeyOverrides(const DP_REGKEY_DATABASE& dpRegkeyDatabase)
{
DP_ASSERT(dpRegkeyDatabase.bInitialized &&
"All regkeys are invalid because dpRegkeyDatabase is not initialized!");
this->bSkipAssessLinkForEDP = dpRegkeyDatabase.bAssesslinkForEdpSkipped;
// If Hdcp authenticatoin on demand regkey is set, override to the provided value.
this->bHdcpAuthOnlyOnDemand = dpRegkeyDatabase.bHdcpAuthOnlyOnDemand;
if (dpRegkeyDatabase.bOptLinkKeptAlive)
{
this->bKeepLinkAliveMST = true;
this->bKeepLinkAliveSST = true;
}
else
{
this->bKeepLinkAliveMST = dpRegkeyDatabase.bOptLinkKeptAliveMst;
this->bKeepLinkAliveSST = dpRegkeyDatabase.bOptLinkKeptAliveSst;
}
this->bReportDeviceLostBeforeNew = dpRegkeyDatabase.bReportDeviceLostBeforeNew;
this->maxLinkRateFromRegkey = dpRegkeyDatabase.applyMaxLinkRateOverrides;
this->bEnableAudioBeyond48K = dpRegkeyDatabase.bAudioBeyond48kEnabled;
this->bDisableSSC = dpRegkeyDatabase.bSscDisabled;
this->bEnableFastLT = dpRegkeyDatabase.bFastLinkTrainingEnabled;
this->bDscMstCapBug3143315 = dpRegkeyDatabase.bDscMstCapBug3143315;
this->bDscMstEnablePassThrough = dpRegkeyDatabase.bDscMstEnablePassThrough;
}
void ConnectorImpl::setPolicyModesetOrderMitigation(bool enabled)
{
policyModesetOrderMitigation = enabled;
}
void ConnectorImpl::setPolicyForceLTAtNAB(bool enabled)
{
policyForceLTAtNAB = enabled;
}
void ConnectorImpl::setPolicyAssessLinkSafely(bool enabled)
{
policyAssessLinkSafely = enabled;
}
//
// This function is to re-read remote HDCP BKSV and BCAPS.
//
// Function is added for DP1.2 devices which don't have valid BKSV at HPD and
// make BKSV available after Payload Ack.
//
void ConnectorImpl::readRemoteHdcpCaps()
{
if (hdcpCapsRetries)
{
fireEvents();
return;
}
}
void ConnectorImpl::discoveryDetectComplete()
{
fireEvents();
// no outstanding EDID reads and branch/sink detections for MST
if (pendingEdidReads.isEmpty() &&
(!discoveryManager ||
(discoveryManager->outstandingBranchDetections.isEmpty() &&
discoveryManager->outstandingSinkDetections.isEmpty())))
{
bDeferNotifyLostDevice = false;
isDiscoveryDetectComplete = true;
bIsDiscoveryDetectActive = false;
// Complete detection and see if can enter power saving state.
isNoActiveStreamAndPowerdown();
fireEvents();
}
}
void ConnectorImpl::applyEdidWARs(Edid & edid, DiscoveryManager::Device device)
{
DpMonitorDenylistData *pDenylistData = new DpMonitorDenylistData();
NvU32 warFlag = 0;
warFlag = main->monitorDenylistInfo(edid.getManufId(), edid.getProductId(), pDenylistData);
// Apply any edid overrides if required
edid.applyEdidWorkArounds(warFlag, pDenylistData);
delete pDenylistData;
}
void DisplayPort::DevicePendingEDIDRead::mstEdidCompleted(EdidReadMultistream * from)
{
Address::StringBuffer sb;
DP_USED(sb);
DP_LOG(("DP-CONN> Edid read complete: %s %s",
from->topologyAddress.toString(sb),
from->edid.getName()));
ConnectorImpl * connector = parent;
parent->applyEdidWARs(from->edid, device);
parent->processNewDevice(device, from->edid, true, DISPLAY_PORT, RESERVED);
delete this;
connector->discoveryDetectComplete();
}
void DisplayPort::DevicePendingEDIDRead::mstEdidReadFailed(EdidReadMultistream * from)
{
Address::StringBuffer sb;
DP_USED(sb);
DP_LOG(("DP-CONN> Edid read failed: %s (using fallback)",
from->topologyAddress.toString(sb)));
ConnectorImpl * connector = parent;
parent->processNewDevice(device, Edid(), true, DISPLAY_PORT, RESERVED);
delete this;
connector->discoveryDetectComplete();
}
void ConnectorImpl::messageProcessed(MessageManager::MessageReceiver * from)
{
if (from == &ResStatus)
{
for (Device * i = enumDevices(0); i; i = enumDevices(i))
if (i->getGUID() == ResStatus.request.guid)
{
DeviceImpl * child = ((DeviceImpl *)i)->children[ResStatus.request.port];
if (child)
{
child->resetCacheInferredLink();
sink->bandwidthChangeNotification((DisplayPort::Device*)child, false);
return;
}
break;
}
// Child wasn't found... Invalidate all bandwidths on topology
for (Device * i = enumDevices(0); i; i = enumDevices(i)) {
((DeviceImpl *)i)->resetCacheInferredLink();
}
}
else
DP_ASSERT(0 && "Received unexpected upstream message that we AREN'T registered for");
}
void ConnectorImpl::discoveryNewDevice(const DiscoveryManager::Device & device)
{
//
// We're guaranteed that there isn't already a device on the list with the same
// address. If we receive the same device announce again - it is considered
// a notification that the device underlying may have seen an HPD.
//
// We're going to queue an EDID read, and remember which device we did it on.
// If the EDID comes back different we'll have mark the old device object
// as disconnected - and create a new one. This is required because
// EDID is one of the fields considered to be immutable.
//
if (!device.branch)
{
if (!device.videoSink)
{
// Don't read EDID on a device having no videoSink
processNewDevice(device, Edid(), false, DISPLAY_PORT, RESERVED);
return;
}
pendingEdidReads.insertBack(new DevicePendingEDIDRead(this, messageManager, device));
}
else
{
// Don't try to read the EDID on a branch device
processNewDevice(device, Edid(), true, DISPLAY_PORT, RESERVED);
}
}
void ConnectorImpl::processNewDevice(const DiscoveryManager::Device & device,
const Edid & edid,
bool isMultistream,
DwnStreamPortType portType,
DwnStreamPortAttribute portAttribute,
bool isCompliance)
{
//
// Ideally we should read EDID here. But instead just report the device
// try to find device in list of devices
//
DeviceImpl * existingDev = findDeviceInList(device.address);
if (existingDev)
existingDev->resetCacheInferredLink();
//
// Process fallback EDID
//
Edid processedEdid = edid;
if (!edid.getEdidSize() || !edid.isChecksumValid() || !edid.isValidHeader() ||
edid.isPatchedChecksum())
{
if (portType == WITHOUT_EDID)
{
switch(portAttribute)
{
case RESERVED:
case IL_720_480_60HZ:
case IL_720_480_50HZ:
case IL_1920_1080_60HZ:
case IL_1920_1080_50HZ:
case PG_1280_720_60HZ:
case PG_1280_720_50_HZ:
DP_ASSERT(0 && "Default EDID feature not supported!");
break;
}
}
if (portType == ANALOG_VGA)
makeEdidFallbackVGA(processedEdid);
else
{
makeEdidFallback(processedEdid, hal->getVideoFallbackSupported());
}
}
//
// Process caps
//
bool hasAudio = device.SDPStreams && device.SDPStreamSinks;
bool hasVideo = device.videoSink;
NvU64 maxTmdsClkRate = 0U;
ConnectorType connector = connectorDisplayPort;
if (portType == DISPLAY_PORT_PLUSPLUS || portType == DVI || portType == HDMI)
{
maxTmdsClkRate = device.maxTmdsClkRate;
}
switch(portType)
{
case DISPLAY_PORT:
case DISPLAY_PORT_PLUSPLUS: // DP port that supports DP and TMDS
connector = connectorDisplayPort;
break;
case ANALOG_VGA:
connector = connectorVGA;
break;
case DVI:
connector = connectorDVI;
break;
case HDMI:
connector = connectorHDMI;
break;
case WITHOUT_EDID:
connector = connectorDisplayPort;
break;
}
// Dongle in SST mode.
if ((device.peerDevice == Dongle) && (device.address.size() == 0))
hasAudio = hasVideo = false;
if (device.branch)
hasAudio = hasVideo = false;
if (!existingDev)
goto create;
if (isCompliance && (existingDev->processedEdid == processedEdid))
{
// unzombie the old device
}
else if (existingDev->audioSink != hasAudio ||
existingDev->videoSink != hasVideo ||
existingDev->rawEDID != edid ||
existingDev->processedEdid != processedEdid ||
existingDev->connectorType != connector ||
existingDev->multistream != isMultistream ||
existingDev->complianceDeviceEdidReadTest != isCompliance ||
existingDev->maxTmdsClkRate != maxTmdsClkRate ||
(existingDev->address.size() > 1 && !existingDev->getParent()) ||
// If it is an Uninitialized Mux device, goto create so that we can properly
// initialize the device and all its caps
existingDev->isFakedMuxDevice())
goto create;
// Complete match, make sure its marked as plugged
existingDev->plugged = true;
if (existingDev->isActive())
existingDev->activeGroup->update(existingDev, true);
fireEvents();
return;
create:
// If there is an existing device, mark it as no longer available.
if (existingDev)
existingDev->plugged = false;
// Find parent
DeviceImpl * parent = 0;
if (device.address.size() != 0)
{
for (Device * i = enumDevices(0); i; i = enumDevices(i))
{
if ((i->getTopologyAddress() == device.address.parent()) &&
(((DeviceImpl *)i)->plugged))
{
parent = (DeviceImpl*)i;
break;
}
}
}
DP_ASSERT((parent || device.address.size() <= 1) && "Device was registered before parent");
DeviceImpl * newDev;
//
// If it is a faked Mux device, we have already notified DD of few of its caps.
// Reuse the same device to make sure that DD updates the same device's parameters
// otherwise create a new device
//
if (existingDev && existingDev->isFakedMuxDevice())
{
newDev = existingDev;
existingDev = NULL;
}
else
{
newDev = new DeviceImpl(hal, this, parent);
}
if (parent)
parent->children[device.address.tail()] = newDev;
if (!newDev)
{
DP_ASSERT(0 && "new failed");
return;
}
// Fill out the new device
newDev->address = device.address;
newDev->multistream = isMultistream;
newDev->videoSink = hasVideo;
newDev->audioSink = hasAudio;
newDev->plugged = true;
newDev->rawEDID = edid;
newDev->processedEdid = processedEdid;
newDev->connectorType = connector;
newDev->guid = device.peerGuid;
newDev->peerDevice = device.peerDevice;
newDev->portMap = device.portMap;
newDev->dpcdRevisionMajor = device.dpcdRevisionMajor;
newDev->dpcdRevisionMinor = device.dpcdRevisionMinor;
newDev->complianceDeviceEdidReadTest = isCompliance;
newDev->maxTmdsClkRate = maxTmdsClkRate;
Address::NvU32Buffer addrBuffer;
dpMemZero(addrBuffer, sizeof(addrBuffer));
newDev->address.toNvU32Buffer(addrBuffer);
NV_DPTRACE_INFO(NEW_SINK_DETECTED, newDev->address.size(), addrBuffer[0], addrBuffer[1], addrBuffer[2], addrBuffer[3],
newDev->multistream, newDev->rawEDID.getManufId(), newDev->rawEDID.getProductId());
// Apply any DPCD overrides if required
newDev->dpcdOverrides();
//
// Some 4K eDP panel needs HBR2 to support higher modes, Highest assessed LC
// remains in a stale state after applying DPCD overrides here. So we need to
// assess the link again.
//
if (newDev->isOptimalLinkConfigOverridden())
{
this->assessLink();
}
// Panel has issues with LQA, reassess link
if (processedEdid.WARFlags.reassessMaxLink)
{
//
// If the highest assessed LC is not equal to max possible link config and
// panel is branch device which GPU is link training, re-assess link
//
int retries = 0;
while((retries < WAR_MAX_REASSESS_ATTEMPT) && (highestAssessedLC != getMaxLinkConfig()))
{
DP_LOG(("DP> Assessed link is not equal to highest possible config. Reassess link."));
this->assessLink();
retries++;
}
}
// Postpone the remote HDCPCap read for Dongles
DP_ASSERT(!isLinkInD3() && "Hdcp probe at D3");
if (device.peerDevice != Dongle)
{
DP_ASSERT(newDev->isDeviceHDCPDetectionAlive == false);
if ((newDev->deviceHDCPDetection = new DeviceHDCPDetection(newDev, messageManager, timer)))
{
//
// We cannot move the hdcpDetection after stream added because DD
// needs hdcp Cap before stream added.
//
newDev->isDeviceHDCPDetectionAlive = true;
newDev->deviceHDCPDetection->start();
}
else
{
// For the risk control, make the device as not HDCPCap.
DP_ASSERT(0 && "new failed");
newDev->isDeviceHDCPDetectionAlive = false;
newDev->isHDCPCap = False;
if (!newDev->isMultistream())
newDev->shadow.hdcpCapDone = true;
}
}
newDev->vrrEnablement = new VrrEnablement(newDev);
if (!newDev->vrrEnablement)
{
DP_ASSERT(0 && "new VrrEnablement failed");
}
BInfo bInfo;
if ((!isHopLimitExceeded) && (hal->getBinfo(bInfo)))
{
if (bInfo.maxCascadeExceeded || bInfo.maxDevsExceeded)
{
if (isHDCPAuthOn)
{
isHDCPAuthOn = false;
}
isHopLimitExceeded = true;
}
else
isHopLimitExceeded = false;
}
//
// If the device is a faked Mux device, then we just initizlied it.
// Reset its faked status and skip adding it to the deviceList
//
if (newDev->isFakedMuxDevice())
{
newDev->bIsFakedMuxDevice = false;
newDev->bIsPreviouslyFakedMuxDevice = true;
}
else
{
deviceList.insertBack(newDev);
}
// if a new device has replaced a previous compliance device; let this event be exposed to DD now.
// ie : the old device will be zombied/lost now ... lazily(instead of at an unplug which happened a while back.)
if (existingDev && existingDev->complianceDeviceEdidReadTest)
existingDev->lazyExitNow = true;
// Read panel DSC support only if GPU supports DSC
bool bGpuDscSupported;
main->getDscCaps(&bGpuDscSupported);
if (bGpuDscSupported && newDev->getDSCSupport())
{
// Read and parse DSC caps only if panel supports DSC
newDev->readAndParseDSCCaps();
}
// Decide if DSC stream can be sent to new device
newDev->bDSCPossible = false;
newDev->devDoingDscDecompression = NULL;
if (bGpuDscSupported && !processedEdid.WARFlags.bIgnoreDscCap)
{
if (newDev->multistream)
{
if ((newDev->peerDevice == Dongle) &&
(newDev->dpcdRevisionMajor != 0) &&
!bDscCapBasedOnParent)
{
// For Peer Type 4 device with LAM DPCD rev != 0.0, check only the device's own DSC capability.
if (newDev->isDSCSupported())
{
newDev->bDSCPossible = true;
newDev->devDoingDscDecompression = newDev;
}
}
else
{
if (this->bDscMstEnablePassThrough)
{
//
// Check the device's own and its parent's DSC capability.
// - Sink device will do DSC cecompression when
// 1. Sink device is capable of DSC decompression and parent
// supports DSC pass through.
//
// - Sink device's parent will do DSC decompression
// 1. If sink device supports DSC decompression but it's parent does not support
// DSC Pass through, but supports DSC decompression.
// 2. If the device does not support DSC decompression, but parent supports it.
//
if (newDev->isDSCSupported())
{
if (newDev->videoSink && newDev->parent)
{
if (newDev->parent->isDSCPassThroughSupported())
{
//
// This condition takes care of DSC capable sink devices
// connected behind a DSC Pass through capable branch
//
newDev->devDoingDscDecompression = newDev;
newDev->bDSCPossible = true;
}
else if (newDev->parent->isDSCSupported())
{
//
// This condition takes care of DSC capable sink devices
// connected behind a branch device that is not capable
// of DSC pass through but can do DSC decompression.
//
newDev->bDSCPossible = true;
newDev->devDoingDscDecompression = newDev->parent;
}
}
else
{
// This condition takes care of branch device capable of DSC.
newDev->devDoingDscDecompression = newDev;
newDev->bDSCPossible = true;
}
}
else if (newDev->parent && newDev->parent->isDSCSupported())
{
//
// This condition takes care of sink devices not capable of DSC
// but parent is capable of DSC decompression.
//
newDev->bDSCPossible = true;
newDev->devDoingDscDecompression = newDev->parent;
}
}
else
{
//
// Revert to old code if DSC Pass through support is not requested.
// This code will be deleted once DSC Pass through support will be enabled
// by default which will be done when 2Head1OR MST (GR-133) will be in production.
//
// Check the device's own and its parent's DSC capability. Parent of the device can do
// DSC decompression and send uncompressed stream to downstream device
//
if (newDev->isDSCSupported() || (newDev->parent && newDev->parent->isDSCSupported()))
{
newDev->bDSCPossible = true;
}
// For multistream device, determine who will do the DSC decompression
if (newDev->bDSCPossible)
{
if(!newDev->isDSCSupported())
{
newDev->devDoingDscDecompression = newDev->parent;
}
else
{
newDev->devDoingDscDecompression = newDev;
}
}
}
}
}
else
{
if (newDev->isDSCSupported())
{
newDev->bDSCPossible = true;
newDev->devDoingDscDecompression = newDev;
}
}
}
// Read panel replay capabilities
newDev->getPanelReplayCaps();
// Get Panel FEC support only if GPU supports FEC
if (this->isFECSupported())
{
newDev->getFECSupport();
}
if (main->supportMSAOverMST())
{
newDev->bMSAOverMSTCapable = newDev->getSDPExtnForColorimetrySupported();
}
else
{
newDev->bMSAOverMSTCapable = false;
}
fireEvents();
}
void ConnectorImpl::populateAllDpConfigs()
{
LinkRate linkRate;
LinkRates *pConnLinkRates;
unsigned laneCounts[] = {laneCount_1, laneCount_2, laneCount_4};
unsigned laneSets = sizeof(laneCounts) / sizeof(laneCounts[0]);
//
// Following sequence is to be followed for saving power by default;
// It may vary with sinks which support link rate table.
//
// Link Config MBPS
// 1*RBR 162
// 1*HBR 270
// 2*RBR 324
// 1*HBR2 540
// 2*HBR 540
// 4*RBR 648
// 1*HBR3 810
// ...
//
if (numPossibleLnkCfg)
{
DP_LOG(("DP> DPCONN> Rebuild possible link rate confgiurations"));
delete[] allPossibleLinkCfgs;
numPossibleLnkCfg = 0;
}
// Attempt to configure link rate table mode if supported
pConnLinkRates = linkPolicy.getLinkRates();
if (hal->isIndexedLinkrateCapable() &&
main->configureLinkRateTable(hal->getLinkRateTable(), pConnLinkRates))
{
// Maximal link rate is limited with link rate table
hal->overrideOptimalLinkRate(pConnLinkRates->getMaxRate());
hal->setIndexedLinkrateEnabled(true);
}
else
{
// Reset configured link rate table if ever enabled to get RM act right
if (hal->isIndexedLinkrateEnabled())
{
main->configureLinkRateTable(NULL, NULL);
hal->setIndexedLinkrateEnabled(false);
}
// Get maximal link rate supported by GPU
linkRate = main->maxLinkRateSupported();
// Insert by order
pConnLinkRates->clear();
if (linkRate >= RBR)
pConnLinkRates->import(linkBW_1_62Gbps);
if (linkRate >= HBR)
pConnLinkRates->import(linkBW_2_70Gbps);
if (linkRate >= HBR2)
pConnLinkRates->import(linkBW_5_40Gbps);
if (linkRate >= HBR3)
pConnLinkRates->import(linkBW_8_10Gbps);
}
numPossibleLnkCfg = laneSets * pConnLinkRates->getNumLinkRates();
if (numPossibleLnkCfg == 0)
{
DP_LOG(("DPCONN> %s: lane count %d or link rates %d!",
pConnLinkRates->getNumLinkRates(), laneSets, __FUNCTION__));
DP_ASSERT(0 && "Invalid lane count %d or link rates %d!");
return;
}
allPossibleLinkCfgs = new LinkConfiguration[numPossibleLnkCfg]();
if (allPossibleLinkCfgs == NULL)
{
DP_LOG(("DPCONN> %s: Failed to allocate allPossibleLinkCfgs array",
__FUNCTION__));
numPossibleLnkCfg = 0;
return;
}
// Populate all possible link configuration
linkRate = pConnLinkRates->getMaxRate();
for (unsigned i = 0; i < pConnLinkRates->getNumLinkRates(); i++)
{
for (unsigned j = 0; j < laneSets; j++)
{
allPossibleLinkCfgs[i * laneSets + j].setLaneRate(linkRate, laneCounts[j]);
}
linkRate = pConnLinkRates->getLowerRate(linkRate);
}
// Sort link configurations per bandwidth from low to high
for (unsigned i = 0; i < numPossibleLnkCfg - 1; i++)
{
LinkConfiguration *pLowCfg = &allPossibleLinkCfgs[i];
for (unsigned j = i + 1; j < numPossibleLnkCfg; j++)
{
if (allPossibleLinkCfgs[j] < *pLowCfg)
pLowCfg = &allPossibleLinkCfgs[j];
}
// Swap
if (pLowCfg != &allPossibleLinkCfgs[i])
{
LinkRate swapRate = pLowCfg->peakRate;
unsigned swapLanes = pLowCfg->lanes;
pLowCfg->setLaneRate(allPossibleLinkCfgs[i].peakRate,
allPossibleLinkCfgs[i].lanes);
allPossibleLinkCfgs[i].setLaneRate(swapRate, swapLanes);
}
}
}
void ConnectorImpl::discoveryLostDevice(const Address & address)
{
DeviceImpl * existingDev = findDeviceInList(address);
if (!existingDev)
{
DP_ASSERT(0 && "Device lost on device not in database?!");
return;
}
existingDev->plugged = false;
existingDev->devDoingDscDecompression = NULL;
fireEvents();
}
ConnectorImpl::~ConnectorImpl()
{
if (numPossibleLnkCfg)
delete[] allPossibleLinkCfgs;
timer->cancelCallbacks(this);
delete discoveryManager;
pendingEdidReads.clear();
delete messageManager;
delete hal;
}
//
// Clear all the state associated with the head attachment
//
void ConnectorImpl::hardwareWasReset()
{
activeLinkConfig.lanes = 0;
while (!activeGroups.isEmpty())
{
GroupImpl * g = (GroupImpl *)activeGroups.front();
activeGroups.remove(g);
inactiveGroups.insertBack(g);
g->setHeadAttached(false);
}
}
Group * ConnectorImpl::resume(bool firmwareLinkHandsOff,
bool firmwareDPActive,
bool plugged,
bool isUefiSystem,
unsigned firmwareHead,
bool bFirmwareLinkUseMultistream,
bool bDisableVbiosScratchRegisterUpdate,
bool bAllowMST)
{
Group * result = 0;
hardwareWasReset();
previousPlugged = false;
connectorActive = true;
bIsUefiSystem = isUefiSystem;
this->bDisableVbiosScratchRegisterUpdate = bDisableVbiosScratchRegisterUpdate;
bFromResumeToNAB = true;
if (firmwareLinkHandsOff)
{
isLinkQuiesced = true;
}
else if (firmwareDPActive)
{
DP_LOG(("CONN> Detected firmware panel is active on head %d.", firmwareHead));
((GroupImpl *)firmwareGroup)->setHeadAttached(true);
((GroupImpl *)firmwareGroup)->headIndex = firmwareHead;
((GroupImpl *)firmwareGroup)->streamIndex = 1;
((GroupImpl *)firmwareGroup)->headInFirmware = true;
this->linkState = bFirmwareLinkUseMultistream ? DP_TRANSPORT_MODE_MULTI_STREAM : DP_TRANSPORT_MODE_SINGLE_STREAM;
inactiveGroups.remove((GroupImpl *)firmwareGroup);
activeGroups.remove((GroupImpl *)firmwareGroup);
activeGroups.insertBack((GroupImpl *)firmwareGroup);
result = firmwareGroup;
}
hal->overrideMultiStreamCap(bAllowMST);
//
// In resume code path, all devices on this connector gets lost and deleted on first fireEvents()
// and that could generate unnecessary new/lost device events. Therefore defer to lost devices
// until discovery detect gets completed, this allows processNewDevice() function to look
// at matching existing devices and optimize creation of new devices. We only have to set the flag
// to true when plugged = true, since if disconnected, we are not going to defer anything.
//
bDeferNotifyLostDevice = plugged;
bAttachOnResume = true;
notifyLongPulse(plugged);
bAttachOnResume = false;
return result;
}
void ConnectorImpl::pause()
{
connectorActive = false;
if (messageManager)
{
messageManager->pause();
}
}
// Query current Device topology
Device * ConnectorImpl::enumDevices(Device * previousDevice)
{
if (previousDevice)
previousDevice = (DeviceImpl *)((DeviceImpl*)previousDevice)->next;