Don't hardcode AVPack in the kernel, read it from SMC instead

This commit is contained in:
Luke Usher 2018-08-22 08:40:30 +01:00
parent 31e3cea0f7
commit 06f860dd30
2 changed files with 21 additions and 5 deletions

View File

@ -70,6 +70,7 @@ namespace xboxkrnl
#include "devices\EEPROMDevice.h" // For g_EEPROM
#include "devices\Xbox.h" // For InitXboxHardware()
#include "devices\LED.h" // For LED::Sequence
#include "devices\SMCDevice.h" // For SMC Access
#include "EmuSha.h" // For the SHA1 functions
#include "Timer.h" // For Timer_Init
#include "..\Common\Input\InputConfig.h" // For the InputDeviceManager
@ -1488,6 +1489,9 @@ __declspec(noreturn) void CxbxKrnlInit
InitXboxHardware(HardwareModel::Revision1_5); // TODO : Make configurable
// Read Xbox video mode from the SMC, store it in HalBootSMCVideoMode
xboxkrnl::HalReadSMBusValue(SMBUS_ADDRESS_SYSTEM_MICRO_CONTROLLER, SMC_COMMAND_AV_PACK, FALSE, &xboxkrnl::HalBootSMCVideoMode);
if (bLLE_USB) {
#if 0 // Reenable this when LLE USB actually works
int ret;

View File

@ -120,17 +120,29 @@ VOID ARX_WR(VOID *Ptr, xboxkrnl::UCHAR i, xboxkrnl::UCHAR d)
}
// Global Variable(s)
PVOID g_pPersistedData = NULL;
ULONG AvpCurrentMode = 0;
ULONG AvSMCVideoModeToAVPack(ULONG VideoMode)
{
switch (VideoMode)
{
case 0x0: return AV_PACK_SCART;
case 0x1: return AV_PACK_HDTV;
case 0x2: return AV_PACK_VGA;
case 0x3: return AV_PACK_RFU;
case 0x4: return AV_PACK_SVIDEO;
case 0x6: return AV_PACK_STANDARD;
}
return AV_PACK_NONE;
}
ULONG AvQueryAvCapabilities()
{
// This is the only AV mode we currently emulate, so we can hardcode the return value
// TODO: Once we add the ability to change av pack, read HalSmcVideoMode) and convert it to a AV_PACK_*
ULONG avpack = AV_PACK_HDTV;
ULONG avpack = AvSMCVideoModeToAVPack(xboxkrnl::HalBootSMCVideoMode);
ULONG type;
ULONG resultSize;