2019-09-03 11:58:42 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-08-17 21:40:52 +02:00
|
|
|
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
2019-09-03 11:58:42 +02:00
|
|
|
#include "nvidia.h"
|
2021-03-26 10:43:15 +01:00
|
|
|
#include "../Platform/Settings.h"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
injection for NVIDIA card usage e.g (to be placed in the config.plist, under graphics tag):
|
|
|
|
<key>Graphics</key>
|
|
|
|
<dict>
|
|
|
|
<key>NVIDIA</key>
|
|
|
|
<array>
|
|
|
|
<dict>
|
|
|
|
<key>Model</key>
|
|
|
|
<string>Quadro FX 380</string>
|
|
|
|
<key>IOPCIPrimaryMatch</key>
|
|
|
|
<string>0x10DE0658</string>
|
|
|
|
<key>VRAM</key>
|
|
|
|
<integer>256</integer>
|
|
|
|
<key>VideoPorts</key>
|
|
|
|
<integer>2</integer>
|
|
|
|
<key>LoadVBios</key>
|
|
|
|
<true/>
|
|
|
|
</dict>
|
|
|
|
<dict>
|
|
|
|
<key>Model</key>
|
|
|
|
<string>YOUR_SECOND_CARD_NAME</string>
|
|
|
|
<key>IOPCIPrimaryMatch</key>
|
|
|
|
<string>YOUR_SECOND_CARD_ID</string>
|
|
|
|
<key>IOPCISubDevId</key>
|
|
|
|
<string>YOUR_SECOND_CARD_SUB_ID(if necessary)</string>
|
|
|
|
<key>VRAM</key>
|
|
|
|
<integer>YOUR_SECOND_CARD_VRAM_SIZE</integer>
|
|
|
|
<key>VideoPorts</key>
|
|
|
|
<integer>YOUR_SECOND_CARD_PORTS</integer>
|
|
|
|
<key>LoadVBios</key>
|
|
|
|
<true/><!--YOUR_SECOND_CARD_LOADVBIOS-->
|
|
|
|
</dict>
|
|
|
|
</array>
|
|
|
|
<key>ATI</key>
|
|
|
|
<array>
|
|
|
|
<dict>
|
|
|
|
<key>Model</key>
|
|
|
|
<string>ATI Radeon HD6670</string>
|
|
|
|
<key>IOPCIPrimaryMatch</key>
|
|
|
|
<string>0x6758</string>
|
|
|
|
<key>IOPCISubDevId</key>
|
|
|
|
<string>0x1342</string>
|
|
|
|
<key>VRAM</key>
|
|
|
|
<integer>2048</integer>
|
|
|
|
</dict>
|
|
|
|
</array>
|
|
|
|
</dict>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG_CARD_VLIST 1
|
|
|
|
|
|
|
|
#if DEBUG_CARD_VLIST == 0
|
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_CARD_VLIST, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2021-02-06 18:16:46 +01:00
|
|
|
//LIST_ENTRY gCardList = INITIALIZE_LIST_HEAD_VARIABLE (gCardList);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
//void AddCard(CONST CHAR8* Model, UINT32 Id, UINT32 SubId, UINT64 VideoRam, UINTN VideoPorts, BOOLEAN LoadVBios)
|
|
|
|
//{
|
|
|
|
// CARDLIST* new_card = new CARDLIST;
|
|
|
|
// new_card->Signature = CARDLIST_SIGNATURE;
|
|
|
|
// new_card->Id = Id;
|
|
|
|
// new_card->SubId = SubId;
|
|
|
|
// new_card->VideoRam = VideoRam;
|
|
|
|
// new_card->VideoPorts = VideoPorts;
|
|
|
|
// new_card->LoadVBios = LoadVBios;
|
|
|
|
// new_card->Model.takeValueFrom(Model);
|
|
|
|
// gCardList.AddReference(new_card, true);
|
|
|
|
//}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds(UINT32 Id, UINT32 SubId)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
2021-03-28 22:13:43 +02:00
|
|
|
for ( size_t idx = 0; idx < gSettings.Graphics.ATICardList.size(); ++idx ) {
|
|
|
|
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.ATICardList[idx];
|
|
|
|
if(entry.Id == Id) {
|
|
|
|
return &entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ( size_t idx = 0; idx < gSettings.Graphics.NVIDIACardList.size(); ++idx ) {
|
|
|
|
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.NVIDIACardList[idx];
|
2021-02-06 18:16:46 +01:00
|
|
|
if(entry.Id == Id) {
|
|
|
|
return &entry;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-28 22:13:43 +02:00
|
|
|
/*
|
|
|
|
* To ease copy/paste and text replacement from GetUserSettings, the parameter has the same name as the global
|
|
|
|
* and is passed by non-const reference.
|
|
|
|
* This temporary during the refactoring
|
|
|
|
*/
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wshadow"
|
|
|
|
void FillCardList(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
|
2019-09-03 11:58:42 +02:00
|
|
|
{
|
2021-03-28 22:13:43 +02:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
if (gSettings.Graphics.ATICardList.isEmpty() && gSettings.Graphics.NVIDIACardList.isEmpty() && (CfgDict != NULL)) {
|
|
|
|
CONST CHAR8 *VEN[] = { "ATI", "NVIDIA" };
|
|
|
|
XObjArray<SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD>* cardlist[] = { &gSettings.Graphics.ATICardList, &gSettings.Graphics.NVIDIACardList };
|
2020-08-25 17:35:19 +02:00
|
|
|
size_t Count = sizeof(VEN) / sizeof(VEN[0]);
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
for (size_t Index = 0; Index < Count; Index++) {
|
2020-02-17 21:41:09 +01:00
|
|
|
CONST CHAR8 *key = VEN[Index];
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
const TagArray* prop = CfgDict->arrayPropertyForKey(key);
|
2020-08-18 18:45:44 +02:00
|
|
|
if( prop && prop->isArray() ) {
|
2019-09-03 11:58:42 +02:00
|
|
|
INTN i;
|
|
|
|
INTN count;
|
|
|
|
|
2020-08-19 14:50:26 +02:00
|
|
|
const TagStruct* prop2 = 0;
|
|
|
|
const TagStruct* element = 0;
|
2020-08-22 15:39:24 +02:00
|
|
|
count = prop->arrayContent().size();
|
2021-03-26 10:43:15 +01:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* new_card = new SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD;
|
|
|
|
|
|
|
|
// CONST CHAR8 *model_name = NULL;
|
|
|
|
// UINT32 dev_id = 0;
|
|
|
|
// UINT32 subdev_id = 0;
|
|
|
|
// UINT64 VramSize = 0;
|
|
|
|
// UINTN VideoPorts = 0;
|
|
|
|
// BOOLEAN LoadVBios = FALSE;
|
2020-08-22 15:39:24 +02:00
|
|
|
element = &prop->arrayContent()[i];
|
|
|
|
if ( !element->isDict()) {
|
2021-03-28 22:13:43 +02:00
|
|
|
MsgLog("MALFORMED PLIST in FillCardList() : element[%lld] is not a dict\n", i);
|
2020-08-22 15:39:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-08-25 17:35:19 +02:00
|
|
|
const TagDict* dictElement = element->getDict();
|
2019-09-03 11:58:42 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("Model");
|
2021-03-28 22:13:43 +02:00
|
|
|
if ( prop2 && prop2->isString() && prop2->getString()->stringValue().notEmpty() ) {
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->Model = prop2->getString()->stringValue();
|
2020-08-22 15:39:24 +02:00
|
|
|
} else {
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->Model = "VideoCard"_XS8;
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("IOPCIPrimaryMatch");
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->Id = (UINT32)GetPropertyAsInteger(prop2, 0);
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("IOPCISubDevId");
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->SubId = (UINT32)GetPropertyAsInteger(prop2, 0);
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("VRAM");
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->VideoRam = LShiftU64((UINTN)GetPropertyAsInteger(prop2, 0), 20); //Mb -> bytes
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("VideoPorts");
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->VideoPorts = (UINT16)GetPropertyAsInteger(prop2, 0);
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2020-08-25 17:35:19 +02:00
|
|
|
prop2 = dictElement->propertyForKey("LoadVBios");
|
2020-08-22 15:39:24 +02:00
|
|
|
if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) {
|
2021-03-26 10:43:15 +01:00
|
|
|
new_card->LoadVBios = TRUE;
|
2020-08-22 15:39:24 +02:00
|
|
|
}
|
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
DBG("FillCardList :: %s : \"%s\" (%08X, %08X)\n", key, new_card->Model.c_str(), new_card->Id, new_card->SubId);
|
2020-08-22 15:39:24 +02:00
|
|
|
|
2021-03-26 10:43:15 +01:00
|
|
|
// AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios);
|
|
|
|
new_card->Signature = CARDLIST_SIGNATURE;
|
|
|
|
// new_card->Id = dev_id;
|
|
|
|
// new_card->SubId = subdev_id;
|
|
|
|
// new_card->VideoRam = VramSize;
|
|
|
|
// new_card->VideoPorts = VideoPorts;
|
|
|
|
// new_card->LoadVBios = LoadVBios;
|
|
|
|
// new_card->Model.takeValueFrom(model_name);
|
2021-03-28 22:13:43 +02:00
|
|
|
cardlist[Index]->AddReference(new_card, true);
|
2019-09-03 11:58:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|