mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
compile time fixed brightness bugfix, reinstated command to set brightness from ARM9
This commit is contained in:
parent
50e97d2dab
commit
6dc89d7107
@ -29,6 +29,11 @@ void LCD_SetBrightness(u8 brightness)
|
||||
*REG_LCD(0xA40) = brightness;
|
||||
}
|
||||
|
||||
u8 LCD_GetBrightness(void)
|
||||
{
|
||||
return *REG_LCD(0x240);
|
||||
}
|
||||
|
||||
void LCD_Initialize(u8 brightness)
|
||||
{
|
||||
*REG_LCD(0x014) = 0x00000001;
|
||||
|
@ -22,6 +22,8 @@
|
||||
#define VBLANK_INTERRUPT (0x2A)
|
||||
|
||||
void LCD_SetBrightness(u8 brightness);
|
||||
u8 LCD_GetBrightness(void);
|
||||
|
||||
void LCD_Deinitialize(void);
|
||||
|
||||
void GPU_PSCFill(u32 start, u32 end, u32 fv);
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
static GlobalSharedMemory SharedMemory_State;
|
||||
|
||||
#ifndef FIXED_BRIGHTNESS
|
||||
static const u8 brightness_lvls[] = {
|
||||
0x10, 0x17, 0x1E, 0x25,
|
||||
0x2C, 0x34, 0x3C, 0x44,
|
||||
@ -41,14 +42,19 @@ static const u8 brightness_lvls[] = {
|
||||
0x79, 0x8C, 0xA7, 0xD2
|
||||
};
|
||||
static int prev_bright_lvl = -1;
|
||||
#endif
|
||||
|
||||
static bool auto_brightness = true;
|
||||
|
||||
void VBlank_Handler(u32 __attribute__((unused)) irqn)
|
||||
{
|
||||
#ifndef FIXED_BRIGHTNESS
|
||||
int cur_bright_lvl = (MCU_GetVolumeSlider() >> 2) % countof(brightness_lvls);
|
||||
if (cur_bright_lvl != prev_bright_lvl) {
|
||||
if ((cur_bright_lvl != prev_bright_lvl) && auto_brightness) {
|
||||
prev_bright_lvl = cur_bright_lvl;
|
||||
LCD_SetBrightness(brightness_lvls[cur_bright_lvl]);
|
||||
}
|
||||
#endif
|
||||
|
||||
// the state should probably be stored on its own
|
||||
// setion without caching enabled, since it must
|
||||
@ -58,7 +64,7 @@ void VBlank_Handler(u32 __attribute__((unused)) irqn)
|
||||
ARM_DMB();
|
||||
}
|
||||
|
||||
static bool legacy = false;
|
||||
static bool legacy_boot = false;
|
||||
|
||||
void PXI_RX_Handler(u32 __attribute__((unused)) irqn)
|
||||
{
|
||||
@ -79,7 +85,7 @@ void PXI_RX_Handler(u32 __attribute__((unused)) irqn)
|
||||
case PXI_LEGACY_MODE:
|
||||
{
|
||||
// TODO: If SMP is enabled, an IPI should be sent here (with a DSB)
|
||||
legacy = true;
|
||||
legacy_boot = true;
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
@ -139,6 +145,18 @@ void PXI_RX_Handler(u32 __attribute__((unused)) irqn)
|
||||
break;
|
||||
}
|
||||
|
||||
case PXI_BRIGHTNESS:
|
||||
{
|
||||
ret = LCD_GetBrightness();
|
||||
if (args[0] && (args[0] < 0x100)) {
|
||||
LCD_SetBrightness(args[0]);
|
||||
auto_brightness = false;
|
||||
} else {
|
||||
auto_brightness = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* New CMD template:
|
||||
case CMD_ID:
|
||||
{
|
||||
@ -159,6 +177,10 @@ void PXI_RX_Handler(u32 __attribute__((unused)) irqn)
|
||||
|
||||
void __attribute__((noreturn)) MainLoop(void)
|
||||
{
|
||||
#ifdef FIXED_BRIGHTNESS
|
||||
LCD_SetBrightness(FIXED_BRIGHTNESS);
|
||||
#endif
|
||||
|
||||
// enable PXI RX interrupt
|
||||
GIC_Enable(PXI_RX_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO + 2, PXI_RX_Handler);
|
||||
|
||||
@ -174,7 +196,7 @@ void __attribute__((noreturn)) MainLoop(void)
|
||||
// Process IRQs until the ARM9 tells us it's time to boot something else
|
||||
do {
|
||||
ARM_WFI();
|
||||
} while(!legacy);
|
||||
} while(!legacy_boot);
|
||||
|
||||
SYS_CoreZeroShutdown();
|
||||
SYS_CoreShutdown();
|
||||
|
@ -39,6 +39,7 @@ enum {
|
||||
PXI_NVRAM_READ,
|
||||
|
||||
PXI_NOTIFY_LED,
|
||||
PXI_BRIGHTNESS,
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user