Skip to content

Commit

Permalink
added support to configure the brightnes for screen init to BOOTCTR9
Browse files Browse the repository at this point in the history
section
  • Loading branch information
Hartie95 committed Mar 9, 2016
1 parent b4b93f4 commit 8291985
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ This section includes some BootCTR9 only configurations:
* This is the same as fileLog, but the log is showen on the bottom screen, instead of written to a file
* screenEnabled
* This configures if the screen should be enabled directly at boot
* screenBrightness
* This configures the brightness that us used for screen initialisation


## How do I update it?
Expand Down
1 change: 1 addition & 0 deletions bootloader/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef struct {
bool fileLog;
bool screenLog;
unsigned int screenEnabled;
unsigned int screenBrightness;
} loaderConfiguration;


Expand Down
1 change: 1 addition & 0 deletions bootloader/include/screen.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "common.h"

typedef void (*arm11Function)(void);
void setStartBrightness(u32 _brightness);
void screenInit();
void screenDeinit();
void __attribute__((naked)) disable_lcds();
Expand Down
2 changes: 2 additions & 0 deletions bootloader/source/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ int handlerLoaderConfiguration(void *user, const char *section, const char *name
pconfig->screenLog = myAtoi(value);
} else if (MATCH(pconfig->section, "screenEnabled")) {
pconfig->screenEnabled = myAtoi(value);
} else if (MATCH(pconfig->section, "screenBrightness")) {
pconfig->screenBrightness = numberToInt(value);
}
return 1;
}
15 changes: 9 additions & 6 deletions bootloader/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
#define DEFAULT_SCREEN_LOADER 1 /* 0 - use payloadConfiguration in the end, 1 - screen init at start */
#define DEFAULT_LOG_FILE 0
#define DEFAULT_LOG_SCREEN 0
#define DEFAULT_SPLASH 0 /* 0 - disabled, 1 - splash screen, 2 - asciiSplash */
#define DEFAULT_SPLASH_IMAGE {0}
#define DEFAULT_BOOTSPLASH 0 /* 0 - disabled, 1 - splash screen, 2 - asciiSplash */
#define DEFAULT_BOOTSPLASH_IMAGE {0}
#define DEFAULT_BRIGHTNESS 0xFF

#define INI_FILE "/arm9loaderhax/boot_config.ini"
#define INI_FILE_BOOTCTR "/boot_config.ini"
Expand Down Expand Up @@ -85,7 +86,7 @@ int main() {
configuration app = {
.section = DEFAULT_SECTION,
.path = DEFAULT_PATH,
.splashDelay = DEFAULT_KEYDELAY,
.splashDelay = DEFAULT_SPLASHDELAY,
.payload = DEFAULT_PAYLOAD,
.offset = DEFAULT_OFFSET,
.splash = DEFAULT_SPLASH,
Expand All @@ -94,12 +95,13 @@ int main() {
};
loaderConfiguration loader = {
.section = LOADER_SECTION,
.keyDelay = DEFAULT_SPLASHDELAY,
.bootsplash = DEFAULT_SPLASH,
.bootsplash_image = DEFAULT_SPLASH_IMAGE,
.keyDelay = DEFAULT_KEYDELAY,
.bootsplash = DEFAULT_BOOTSPLASH,
.bootsplash_image = DEFAULT_BOOTSPLASH_IMAGE,
.fileLog = DEFAULT_LOG_FILE,
.screenLog = DEFAULT_LOG_SCREEN,
.screenEnabled = DEFAULT_SCREEN,
.screenBrightness = DEFAULT_BRIGHTNESS,
};
FATFS fs;
FIL payload;
Expand All @@ -108,6 +110,7 @@ int main() {
{
iniparse(INI_FILE,handlerLoaderConfiguration,&loader);
initLog(loader.fileLog, loader.screenLog);
setStartBrightness(loader.screenBrightness);
initScreen(loader.screenEnabled);

if(loader.screenEnabled)
Expand Down
33 changes: 22 additions & 11 deletions bootloader/source/screen.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#include "screen.h"
#include "i2c.h"

#define DEFAULT_BRIGHTNESS 0x39
#define FB_TOP_LEFT 0x18300000
#define FB_TOP_RIGHT 0x18300000
#define FB_BOTTOM 0x18346500

//got code for disabeling from CakesForeveryWan
volatile u32 *a11_entry = (volatile u32 *)0x1FFFFFF8;
volatile u32 *a11_entry = (volatile u32 *)0x1FFFFFF8;
volatile u32 brightness = DEFAULT_BRIGHTNESS;
bool screenInitialized=false;

void setStartBrightness(u32 _brightness)
{
brightness=_brightness;
}
void screenInit()
{
if(*((u8*)0x101401C0) == 0x0&&screenInitialized==false)
Expand Down Expand Up @@ -53,8 +64,8 @@ void __attribute__((naked)) disable_lcds()
void regSet();
void __attribute__ ((naked)) enable_lcd()
{
//__asm__ ("ldr r0,=0x1FFF4D80\n\t mov sp, r0");
regSet();
//__asm__ ("ldr r0,=_stack\n\t mov sp, r0");
regSet();
}

void regSet()
Expand Down Expand Up @@ -157,10 +168,10 @@ void regSet()
*((volatile u32*)0x10202a04) = 0x00000000; // color fill disable
*((volatile u32*)0x1020200C) &= 0xFFFEFFFE;// wtf register

*((volatile u32*)0x10202240) = 0xFF;
*((volatile u32*)0x10202240) = brightness;
*((volatile u32*)0x10202244) = 0x1023E;

*((volatile u32*)0x10202A40) = 0xFF;
*((volatile u32*)0x10202A40) = brightness;
*((volatile u32*)0x10202A44) = 0x1023E;

// After hm call cmd 0x00160042 to acquire rights
Expand Down Expand Up @@ -219,13 +230,13 @@ void regSet()
*((volatile u32*)0x1040059C) = 0x00000000;
//(122860 log)

*((volatile u32*)0x10400468) = 0x18300000;
*((volatile u32*)0x1040046c) = 0x18300000;
*((volatile u32*)0x10400494) = 0x18300000;
*((volatile u32*)0x10400498) = 0x18300000;
*((volatile u32*)0x10400468) = FB_TOP_LEFT;
*((volatile u32*)0x1040046c) = FB_TOP_LEFT;
*((volatile u32*)0x10400494) = FB_TOP_RIGHT;
*((volatile u32*)0x10400498) = FB_TOP_RIGHT;

*((volatile u32*)0x10400568) = 0x18300000 + 0x46500;
*((volatile u32*)0x1040056c) = 0x18300000 + 0x46500;
*((volatile u32*)0x10400568) = FB_BOTTOM;
*((volatile u32*)0x1040056c) = FB_BOTTOM;

*((volatile u32*)0x10400478) = 0x00000001;
*((volatile u32*)0x10400578) = 0x00000001;
Expand Down

0 comments on commit 8291985

Please sign in to comment.