From 4ae1874fc14e8a6d7e7ade72a6393fcc79ccf2e1 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Tue, 4 Apr 2023 14:46:22 +0200 Subject: [PATCH] TV type is now passthrough by default --- docs/04_config_options.md | 4 ++-- sw/bootloader/src/boot.c | 35 +++-------------------------------- sw/bootloader/src/boot.h | 3 ++- sw/bootloader/src/main.c | 6 ++---- sw/bootloader/src/sc64.h | 4 ++-- sw/controller/src/cfg.c | 10 +++++----- sw/deployer/src/sc64/types.rs | 8 ++++---- 7 files changed, 20 insertions(+), 50 deletions(-) diff --git a/docs/04_config_options.md b/docs/04_config_options.md index abb2608..c84efd4 100644 --- a/docs/04_config_options.md +++ b/docs/04_config_options.md @@ -159,10 +159,10 @@ type: *enum* | default: `3` - `0` - PAL TV type will be used - `1` - NTSC TV type will be used - `2` - MPAL TV type will be used -- `3` - TV type will be autodetected +- `3` - Console native TV type will be used Use this setting to force specific TV type. -By setting value `3` bootloader will try to guess TV type from loaded ROM header. +By setting value `3` bootloader will passthrough TV type native to the console. This setting is not used when **BOOT_MODE** is set to `3` or `4` (direct boot). --- diff --git a/sw/bootloader/src/boot.c b/sw/bootloader/src/boot.c index 5e29156..8ab0e5e 100644 --- a/sw/bootloader/src/boot.c +++ b/sw/bootloader/src/boot.c @@ -37,33 +37,6 @@ static io32_t *boot_get_device_base (boot_info_t *info) { return device_base_address; } -static bool boot_get_tv_type (boot_info_t *info) { - io32_t *base = boot_get_device_base(info); - - char region = ((pi_io_read(&base[15]) >> 8) & 0xFF); - - switch (region) { - case 'P': - case 'U': - info->tv_type = BOOT_TV_TYPE_PAL; - break; - - case 'E': - case 'J': - info->tv_type = BOOT_TV_TYPE_NTSC; - break; - - case 'B': - info->tv_type = BOOT_TV_TYPE_MPAL; - break; - - default: - return false; - } - - return true; -} - static bool boot_get_cic_seed (boot_info_t *info) { io32_t *base = boot_get_device_base(info); @@ -83,11 +56,9 @@ static bool boot_get_cic_seed (boot_info_t *info) { return false; } -void boot (boot_info_t *info, bool detect_tv_type, bool detect_cic_seed) { - if (detect_tv_type) { - if (!boot_get_tv_type(info)) { - info->tv_type = OS_INFO->tv_type; - } +void boot (boot_info_t *info, bool detect_cic_seed) { + if (info->tv_type == BOOT_TV_TYPE_PASSTHROUGH) { + info->tv_type = OS_INFO->tv_type; } if (detect_cic_seed) { diff --git a/sw/bootloader/src/boot.h b/sw/bootloader/src/boot.h index 07a7616..7563dfc 100644 --- a/sw/bootloader/src/boot.h +++ b/sw/bootloader/src/boot.h @@ -20,6 +20,7 @@ typedef enum { BOOT_TV_TYPE_PAL = 0, BOOT_TV_TYPE_NTSC = 1, BOOT_TV_TYPE_MPAL = 2, + BOOT_TV_TYPE_PASSTHROUGH = 3, } boot_tv_type_t; @@ -31,7 +32,7 @@ typedef struct { } boot_info_t; -void boot (boot_info_t *info, bool detect_tv_type, bool detect_cic_seed); +void boot (boot_info_t *info, bool detect_cic_seed); #endif diff --git a/sw/bootloader/src/main.c b/sw/bootloader/src/main.c index 4d1ede7..431cb2b 100644 --- a/sw/bootloader/src/main.c +++ b/sw/bootloader/src/main.c @@ -30,14 +30,12 @@ void main (void) { break; } - bool detect_tv_type = (sc64_boot_info.tv_type == TV_TYPE_UNKNOWN); - bool detect_cic_seed = (sc64_boot_info.cic_seed == CIC_SEED_UNKNOWN); - boot_info.reset_type = OS_INFO->reset_type; boot_info.tv_type = sc64_boot_info.tv_type; boot_info.cic_seed = (sc64_boot_info.cic_seed & 0xFF); + bool detect_cic_seed = (sc64_boot_info.cic_seed == CIC_SEED_AUTO); deinit(); - boot(&boot_info, detect_tv_type, detect_cic_seed); + boot(&boot_info, detect_cic_seed); } diff --git a/sw/bootloader/src/sc64.h b/sw/bootloader/src/sc64.h index 3502295..030f43d 100644 --- a/sw/bootloader/src/sc64.h +++ b/sw/bootloader/src/sc64.h @@ -64,14 +64,14 @@ typedef enum { } sc64_save_type_t; typedef enum { - CIC_SEED_UNKNOWN = 0xFFFF + CIC_SEED_AUTO = 0xFFFF } sc64_cic_seed_t; typedef enum { TV_TYPE_PAL = 0, TV_TYPE_NTSC = 1, TV_TYPE_MPAL = 2, - TV_TYPE_UNKNOWN = 3 + TV_TYPE_PASSTHROUGH = 3 } sc64_tv_type_t; typedef enum { diff --git a/sw/controller/src/cfg.c b/sw/controller/src/cfg.c index d8e04a1..1ff6a66 100644 --- a/sw/controller/src/cfg.c +++ b/sw/controller/src/cfg.c @@ -54,14 +54,14 @@ typedef enum { } boot_mode_t; typedef enum { - CIC_SEED_UNKNOWN = 0xFFFF + CIC_SEED_AUTO = 0xFFFF } cic_seed_t; typedef enum { TV_TYPE_PAL = 0, TV_TYPE_NTSC = 1, TV_TYPE_MPAL = 2, - TV_TYPE_UNKNOWN = 3 + TV_TYPE_PASSTHROUGH = 3 } tv_type_t; typedef enum { @@ -340,7 +340,7 @@ bool cfg_update (uint32_t *args) { p.cic_seed = (cic_seed_t) (args[1] & 0xFFFF); break; case CFG_ID_TV_TYPE: - if (args[1] > TV_TYPE_UNKNOWN) { + if (args[1] > TV_TYPE_PASSTHROUGH) { return true; } p.tv_type = (tv_type_t) (args[1] & 0x03); @@ -443,8 +443,8 @@ void cfg_reset_state (void) { dd_set_disk_state(DD_DISK_STATE_EJECTED); dd_set_sd_mode(false); isv_set_address(0); - p.cic_seed = CIC_SEED_UNKNOWN; - p.tv_type = TV_TYPE_UNKNOWN; + p.cic_seed = CIC_SEED_AUTO; + p.tv_type = TV_TYPE_PASSTHROUGH; p.boot_mode = BOOT_MODE_MENU; } diff --git a/sw/deployer/src/sc64/types.rs b/sw/deployer/src/sc64/types.rs index 3bbc354..3d0275d 100644 --- a/sw/deployer/src/sc64/types.rs +++ b/sw/deployer/src/sc64/types.rs @@ -340,7 +340,7 @@ pub enum TvType { PAL, NTSC, MPAL, - Auto, + Passthrough, } impl Display for TvType { @@ -349,7 +349,7 @@ impl Display for TvType { Self::PAL => "PAL", Self::NTSC => "NTSC", Self::MPAL => "MPAL", - Self::Auto => "Auto", + Self::Passthrough => "Passthrough", }) } } @@ -361,7 +361,7 @@ impl TryFrom for TvType { 0 => Self::PAL, 1 => Self::NTSC, 2 => Self::MPAL, - 3 => Self::Auto, + 3 => Self::Passthrough, _ => return Err(Error::new("Unknown TV type code")), }) } @@ -373,7 +373,7 @@ impl From for u32 { TvType::PAL => 0, TvType::NTSC => 1, TvType::MPAL => 2, - TvType::Auto => 3, + TvType::Passthrough => 3, } } }