Fix screens not working on firmlaunch

- LCD fill was not unset
- Still needs to do screeninit on firmlaunch even though PDN_GPU_CNT is 0x1007F
This commit is contained in:
TuxSH 2019-02-26 20:19:52 +01:00
parent 1c7b55ee1e
commit f718297591
5 changed files with 38 additions and 20 deletions

View File

@ -40,6 +40,10 @@ extern volatile Arm11Operation operation;
static void initScreens(u32 brightnessLevel, struct fb *fbs)
{
*(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202204 = 0x01000000; //set LCD fill black to hide potential garbage -- NFIRM does it before firmlaunching
*(vu32 *)0x10202A04 = 0x01000000;
*(vu32 *)0x10202014 = 0x00000001;
*(vu32 *)0x1020200C &= 0xFFFEFFFE;
*(vu32 *)0x10202240 = brightnessLevel;
@ -118,16 +122,33 @@ static void initScreens(u32 brightnessLevel, struct fb *fbs)
//Disco register
for(u32 i = 0; i < 256; i++)
*(vu32 *)0x10400584 = 0x10101 * i;
*(vu32 *)0x10202204 = 0x00000000; //unset LCD fill
*(vu32 *)0x10202A04 = 0x00000000;
}
static void setupFramebuffers(struct fb *fbs)
{
*(vu32 *)0x10202204 = 0x01000000; //set LCD fill black to hide potential garbage -- NFIRM does it before firmlaunching
*(vu32 *)0x10202A04 = 0x01000000;
*(vu32 *)0x10400468 = (u32)fbs[0].top_left;
*(vu32 *)0x1040046c = (u32)fbs[1].top_left;
*(vu32 *)0x10400494 = (u32)fbs[0].top_right;
*(vu32 *)0x10400498 = (u32)fbs[1].top_right;
*(vu32 *)0x10400568 = (u32)fbs[0].bottom;
*(vu32 *)0x1040056c = (u32)fbs[1].bottom;
//Set framebuffer format, framebuffer select and stride
*(vu32 *)0x10400470 = 0x80341;
*(vu32 *)0x10400478 = 0;
*(vu32 *)0x10400490 = 0x2D0;
*(vu32 *)0x10400570 = 0x80301;
*(vu32 *)0x10400578 = 0;
*(vu32 *)0x10400590 = 0x2D0;
*(vu32 *)0x10202204 = 0x00000000; //unset LCD fill
*(vu32 *)0x10202A04 = 0x00000000;
}
static void clearScreens(struct fb *fb)

View File

@ -40,6 +40,6 @@ typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
#define PDN_GPU_CNT (*(vu32 *)0x10141200)
#define ARESCREENSINITIALIZED (PDN_GPU_CNT != 1)
#define ARESCREENSINITIALIZED ((PDN_GPU_CNT & 0xFF) != 1)

View File

@ -35,6 +35,8 @@
#include "i2c.h"
#include "utils.h"
bool needToSetupScreens = true;
struct fb fbs[2] =
{
{
@ -92,11 +94,9 @@ void clearScreens(bool isAlternate)
void initScreens(void)
{
static bool needToSetup = true;
if(needToSetup)
if(needToSetupScreens)
{
if(!ARESCREENSINITIALIZED)
if(!ARESCREENSINITIALIZED || bootType == FIRMLAUNCH)
{
*(vu32 *)ARM11_PARAMETERS_ADDRESS = brightness[MULTICONFIG(BRIGHTNESS)];
memcpy((void *)(ARM11_PARAMETERS_ADDRESS + 4), fbs, sizeof(fbs));
@ -111,7 +111,7 @@ void initScreens(void)
invokeArm11Function(SETUP_FRAMEBUFFERS);
clearScreens(true);
needToSetup = false;
needToSetupScreens = false;
}
clearScreens(false);

View File

@ -33,9 +33,9 @@
#include "types.h"
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
#define PDN_GPU_CNT (*(vu32 *)0x10141200)
#define ARESCREENSINITIALIZED (PDN_GPU_CNT != 1)
#define ARESCREENSINITIALIZED ((PDN_GPU_CNT & 0xFF) != 1)
#define ARM11_PARAMETERS_ADDRESS 0x1FFFF000
@ -65,6 +65,8 @@ typedef enum
extern struct fb fbs[2];
extern bool needToSetupScreens;
void prepareArm11ForFirmlaunch(void);
void deinitScreens(void);
void swapFramebuffers(bool isAlternate);

View File

@ -106,7 +106,7 @@ u32 waitInput(bool isMenu)
void mcuPowerOff(void)
{
if(bootType != FIRMLAUNCH && ARESCREENSINITIALIZED) clearScreens(false);
if(!needToSetupScreens) clearScreens(false);
//Shutdown LCD
if(ARESCREENSINITIALIZED) i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 0);
@ -136,17 +136,12 @@ void error(const char *fmt, ...)
vsprintf(buf, fmt, args);
va_end(args);
if(bootType != FIRMLAUNCH)
{
initScreens();
initScreens();
drawString(true, 10, 10, COLOR_RED, "An error has occurred:");
u32 posY = drawString(true, 10, 30, COLOR_WHITE, buf);
drawString(true, 10, posY + 2 * SPACING_Y, COLOR_WHITE, "Press any button to shutdown");
drawString(true, 10, 10, COLOR_RED, "An error has occurred:");
u32 posY = drawString(true, 10, 30, COLOR_WHITE, buf);
drawString(true, 10, posY + 2 * SPACING_Y, COLOR_WHITE, "Press any button to shutdown");
waitInput(false);
}
else fileWrite(buf, "firmlauncherror.txt", strlen(buf));
waitInput(false);
mcuPowerOff();
}