diff --git a/src/display.c b/src/display.c index 1bb28ae26..cc53c31c4 100644 --- a/src/display.c +++ b/src/display.c @@ -30,6 +30,7 @@ static dcp_dev_t *dcp; static dcp_iboot_if_t *iboot; static u64 fb_dva; static u64 fb_size; +bool has_dcp; bool display_is_external; bool display_is_dptx; bool display_needs_power_cycle; @@ -244,14 +245,23 @@ static uintptr_t display_map_fb(uintptr_t iova, u64 paddr, u64 size) const display_config_t *display_get_config(void) { + const display_config_t *conf = NULL; + if (adt_is_compatible(adt, 0, "J473AP")) - return &display_config_m2; + conf = &display_config_m2; else if (adt_is_compatible(adt, 0, "J474sAP") || adt_is_compatible(adt, 0, "J475cAP")) - return &display_config_m2_pro_max; + conf = &display_config_m2_pro_max; else if (adt_is_compatible(adt, 0, "J180dAP") || adt_is_compatible(adt, 0, "J475dAP")) - return &display_config_m2_ultra; + conf = &display_config_m2_ultra; else - return &display_config_m1; + conf = &display_config_m1; + + has_dcp = adt_path_offset(adt, conf->dcp) > 0; + if (!has_dcp) { + return NULL; + } + + return conf; } int display_start_dcp(void) @@ -264,13 +274,13 @@ int display_start_dcp(void) return 0; #endif + const display_config_t *disp_cfg = display_get_config(); + if (!has_dcp) { - printf("display: DCP not present\n"); + printf("display: device has no DCP. Display will not be initialised.\n"); return -1; } - const display_config_t *disp_cfg = display_get_config(); - display_is_dptx = !!disp_cfg->dptx_phy[0]; dcp = dcp_init(disp_cfg); @@ -655,6 +665,10 @@ int display_init(void) void display_shutdown(dcp_shutdown_mode mode) { + /* We have no DCP, so just exit */ + if (!has_dcp) + return; + if (iboot) { dcp_ib_shutdown(iboot); switch (mode) { diff --git a/src/main.c b/src/main.c index 2f1a7cc9f..e5c1ff920 100644 --- a/src/main.c +++ b/src/main.c @@ -51,7 +51,6 @@ void get_device_info(void) printf(" Target: %s\n", target); is_mac = !!strstr(model, "Mac"); - has_dcp = adt_path_offset(adt, "/arm-io/dcp") > 0; int chosen = adt_path_offset(adt, "/chosen"); if (chosen > 0) { @@ -165,8 +164,7 @@ void m1n1_main(void) display_init(); // Kick DCP to sleep, so dodgy monitors which cause reconnect cycles don't cause us to lose the // framebuffer. - if (has_dcp) - display_shutdown(DCP_SLEEP_IF_EXTERNAL); + display_shutdown(DCP_SLEEP_IF_EXTERNAL); // On idevice we need to always clear, because otherwise it looks scuffed on white devices fb_init(!is_mac); fb_display_logo(); diff --git a/src/utils.c b/src/utils.c index 8a4b8d0f7..d587ad741 100644 --- a/src/utils.c +++ b/src/utils.c @@ -12,7 +12,7 @@ #include "vsprintf.h" #include "xnuboot.h" -bool is_mac, has_dcp; +bool is_mac; static char ascii(char s) { diff --git a/src/utils.h b/src/utils.h index 28403b6ce..6789da7ec 100644 --- a/src/utils.h +++ b/src/utils.h @@ -464,7 +464,7 @@ struct vector_args { extern u32 board_id, chip_id; -extern bool is_mac, has_dcp; +extern bool is_mac; extern bool cpufeat_actlr_el2, cpufeat_fast_ipi, cpufeat_mmu_sprr; extern bool cpufeat_global_sleep, cpufeat_workaround_cyclone_cache;