Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contain all display init logic within display.c #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "vsprintf.h"
#include "xnuboot.h"

bool is_mac, has_dcp;
bool is_mac;

static char ascii(char s)
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading