diff --git a/arm9/source/i2c.h b/arm9/source/i2c.h index ea944225..f8d85064 100644 --- a/arm9/source/i2c.h +++ b/arm9/source/i2c.h @@ -40,6 +40,8 @@ typedef enum I2C_DEV_CAMERA = 1, // Unconfirmed I2C_DEV_CAMERA2 = 2, // Unconfirmed I2C_DEV_MCU = 3, + I2C_DEV_LCD_TOP = 5, + I2C_DEV_LCD_BOT = 6, I2C_DEV_GYRO = 10, I2C_DEV_DEBUG_PAD = 12, I2C_DEV_IR = 13, diff --git a/arm9/source/screen.c b/arm9/source/screen.c index e82475d5..5644788b 100644 --- a/arm9/source/screen.c +++ b/arm9/source/screen.c @@ -70,6 +70,14 @@ void prepareArm11ForFirmlaunch(void) void deinitScreens(void) { if(ARESCREENSINITIALIZED) invokeArm11Function(DEINIT_SCREENS); + + // Backlight voltage off + I2C_writeReg(I2C_DEV_MCU, 0x22, 0x14); + wait(50); + + // LCD panel voltage off + I2C_writeReg(I2C_DEV_MCU, 0x22, 0x01); + wait(50); } void updateBrightness(u32 brightnessIndex) @@ -102,8 +110,31 @@ void initScreens(void) memcpy((void *)(ARM11_PARAMETERS_ADDRESS + 4), fbs, sizeof(fbs)); invokeArm11Function(INIT_SCREENS); - //Turn on backlight - I2C_writeReg(I2C_DEV_MCU, 0x22, 0x2A); + // Fragile code, needs proper fix/total rewrite of the baremetal components anyway + // Assume controller revision is not 0x00 for either screen (this revision is extremely + // old and shouldn't be seen in retail units nor normal devunits) + + // Controller reset off + I2C_writeReg(I2C_DEV_LCD_TOP, 0xFE, 0xAA); + I2C_writeReg(I2C_DEV_LCD_BOT, 0xFE, 0xAA); + wait(5); + + // Controller power on + I2C_writeReg(I2C_DEV_LCD_TOP, 0x01, 0x10); + I2C_writeReg(I2C_DEV_LCD_BOT, 0x01, 0x10); + wait(5); + + // Clear error flag + I2C_writeReg(I2C_DEV_LCD_TOP, 0x60, 0x00); + I2C_writeReg(I2C_DEV_LCD_BOT, 0x60, 0x00); + wait(5); + + // LCD panel (bias ?) voltage on + I2C_writeReg(I2C_DEV_MCU, 0x22, 0x02); + wait(50); + + // Backlight voltage on + I2C_writeReg(I2C_DEV_MCU, 0x22, 0x28); wait(5); } else updateBrightness(MULTICONFIG(BRIGHTNESS)); @@ -122,4 +153,4 @@ void initScreens(void) void zerofillN3dsAblRegisters(void) { invokeArm11Function(ZEROFILL_N3DS_ABL_REGISTERS); -} \ No newline at end of file +}