mirror of
https://github.com/CTCaer/hekate.git
synced 2024-12-24 12:14:11 +00:00
Allow toggling of auto power off from HOS waking
This commit is contained in:
parent
2f43b20124
commit
381d5c9236
@ -46,6 +46,7 @@ void set_default_configuration()
|
||||
h_cfg.se_keygen_done = 0;
|
||||
h_cfg.sbar_time_keeping = 0;
|
||||
h_cfg.backlight = 100;
|
||||
h_cfg.autohosoff = 1;
|
||||
h_cfg.errors = 0;
|
||||
}
|
||||
|
||||
@ -101,6 +102,9 @@ int create_config_entry()
|
||||
f_puts("\nbacklight=", &fp);
|
||||
itoa(h_cfg.backlight, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\nautohosoff=", &fp);
|
||||
itoa(h_cfg.autohosoff, lbuf, 10);
|
||||
f_puts(lbuf, &fp);
|
||||
f_puts("\n", &fp);
|
||||
|
||||
if (mainIniFound)
|
||||
@ -635,3 +639,61 @@ void config_backlight()
|
||||
return;
|
||||
btn_wait();
|
||||
}
|
||||
|
||||
void config_auto_hos_poweroff()
|
||||
{
|
||||
gfx_clear_grey(&gfx_ctxt, 0x1B);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 5);
|
||||
u32 *hp_values = (u32 *)malloc(sizeof(u32) * 2);
|
||||
|
||||
for (u32 j = 0; j < 2; j++)
|
||||
{
|
||||
hp_values[j] = j;
|
||||
ments[j + 2].type = MENT_DATA;
|
||||
ments[j + 2].data = &hp_values[j];
|
||||
}
|
||||
|
||||
ments[0].type = MENT_BACK;
|
||||
ments[0].caption = "Back";
|
||||
|
||||
ments[1].type = MENT_CHGLINE;
|
||||
|
||||
if (h_cfg.autohosoff)
|
||||
{
|
||||
ments[2].caption = " Disable";
|
||||
ments[3].caption = "*Enable";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ments[2].caption = "*Disable";
|
||||
ments[3].caption = " Enable";
|
||||
}
|
||||
|
||||
memset(&ments[4], 0, sizeof(ment_t));
|
||||
menu_t menu = {ments, "Power off if woke up from HOS", 0, 0};
|
||||
|
||||
u32 *temp_autohosoff = (u32 *)tui_do_menu(&gfx_con, &menu);
|
||||
if (temp_autohosoff != NULL)
|
||||
{
|
||||
gfx_clear_grey(&gfx_ctxt, 0x1B);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
h_cfg.autohosoff = *(u32 *)temp_autohosoff;
|
||||
// Save choice to ini file.
|
||||
if (!create_config_entry())
|
||||
gfx_puts(&gfx_con, "\nConfiguration was saved!\n");
|
||||
else
|
||||
EPRINTF("\nConfiguration saving failed!");
|
||||
gfx_puts(&gfx_con, "\nPress any key...");
|
||||
}
|
||||
|
||||
free(ments);
|
||||
free(hp_values);
|
||||
|
||||
if (temp_autohosoff == NULL)
|
||||
return;
|
||||
btn_wait();
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ typedef struct _hekate_config
|
||||
u32 customlogo;
|
||||
u32 verification;
|
||||
u32 backlight;
|
||||
u32 autohosoff;
|
||||
u32 errors;
|
||||
// Global temporary config.
|
||||
int se_keygen_done;
|
||||
@ -46,5 +47,6 @@ void config_bootdelay();
|
||||
void config_customlogo();
|
||||
void config_verification();
|
||||
void config_backlight();
|
||||
void config_auto_hos_poweroff();
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
|
@ -259,15 +259,18 @@ void check_power_off_from_hos()
|
||||
u8 hosWakeup = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_IRQTOP);
|
||||
if (hosWakeup & MAX77620_IRQ_TOP_RTC_MASK)
|
||||
{
|
||||
sd_unmount();
|
||||
|
||||
gfx_clear_grey(&gfx_ctxt, 0x1B);
|
||||
u8 *BOOTLOGO = (void *)malloc(0x4000);
|
||||
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
|
||||
gfx_set_rect_grey(&gfx_ctxt, BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
|
||||
usleep(2000000);
|
||||
|
||||
display_backlight_brightness(10, 5000);
|
||||
display_backlight_brightness(100, 25000);
|
||||
usleep(600000);
|
||||
display_backlight_brightness(0, 20000);
|
||||
|
||||
power_off();
|
||||
}
|
||||
}
|
||||
@ -457,6 +460,7 @@ void reconfig_hw_workaround(bool extra_reconfig, u32 magic)
|
||||
|
||||
if (extra_reconfig)
|
||||
{
|
||||
msleep(10);
|
||||
PMC(APBDEV_PMC_PWR_DET_VAL) |= (1 << 12);
|
||||
|
||||
clock_disable_cl_dvfs();
|
||||
@ -2322,6 +2326,8 @@ void auto_launch_firmware()
|
||||
h_cfg.verification = atoi(kv->val);
|
||||
else if (!strcmp("backlight", kv->key))
|
||||
h_cfg.backlight = atoi(kv->val);
|
||||
else if (!strcmp("autohosoff", kv->key))
|
||||
h_cfg.autohosoff = atoi(kv->val);
|
||||
}
|
||||
boot_entry_id++;
|
||||
continue;
|
||||
@ -2342,6 +2348,9 @@ void auto_launch_firmware()
|
||||
}
|
||||
}
|
||||
|
||||
if (h_cfg.autohosoff)
|
||||
check_power_off_from_hos();
|
||||
|
||||
if (h_cfg.autoboot_list)
|
||||
{
|
||||
ini_free(&ini_sections);
|
||||
@ -3131,6 +3140,7 @@ ment_t ment_options[] = {
|
||||
MDEF_HANDLER("Auto boot", config_autoboot),
|
||||
MDEF_HANDLER("Boot time delay", config_bootdelay),
|
||||
MDEF_HANDLER("Custom boot logo", config_customlogo),
|
||||
MDEF_HANDLER("Auto HOS power off", config_auto_hos_poweroff),
|
||||
MDEF_HANDLER("Backlight", config_backlight),
|
||||
MDEF_END()
|
||||
};
|
||||
@ -3281,8 +3291,6 @@ void ipl_main()
|
||||
display_backlight_pwm_init();
|
||||
//display_backlight_brightness(h_cfg.backlight, 1000);
|
||||
|
||||
check_power_off_from_hos();
|
||||
|
||||
// Load saved configuration and auto boot if enabled.
|
||||
auto_launch_firmware();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user