Skip to content

Commit b0fc85e

Browse files
committed
display: contain all display init logic within display.c
Display handling was spread across main.c, utils.c and display.c with the addition of iDevice support. Condense all of this functionality into display.c. This also fixes a regression introduced in 869d2ae ("Skip over features unsupported in A7-A11 SoCs."), which caused devices using dcpext to skip DCP initialisation. Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
1 parent dbafd05 commit b0fc85e

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

src/display.c

+21-7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static dcp_dev_t *dcp;
3030
static dcp_iboot_if_t *iboot;
3131
static u64 fb_dva;
3232
static u64 fb_size;
33+
bool has_dcp;
3334
bool display_is_external;
3435
bool display_is_dptx;
3536
bool display_needs_power_cycle;
@@ -244,14 +245,23 @@ static uintptr_t display_map_fb(uintptr_t iova, u64 paddr, u64 size)
244245

245246
const display_config_t *display_get_config(void)
246247
{
248+
const display_config_t *conf = NULL;
249+
247250
if (adt_is_compatible(adt, 0, "J473AP"))
248-
return &display_config_m2;
251+
conf = &display_config_m2;
249252
else if (adt_is_compatible(adt, 0, "J474sAP") || adt_is_compatible(adt, 0, "J475cAP"))
250-
return &display_config_m2_pro_max;
253+
conf = &display_config_m2_pro_max;
251254
else if (adt_is_compatible(adt, 0, "J180dAP") || adt_is_compatible(adt, 0, "J475dAP"))
252-
return &display_config_m2_ultra;
255+
conf = &display_config_m2_ultra;
253256
else
254-
return &display_config_m1;
257+
conf = &display_config_m1;
258+
259+
has_dcp = !!adt_path_offset(adt, conf->dcp);
260+
if (!has_dcp) {
261+
return NULL;
262+
}
263+
264+
return conf;
255265
}
256266

257267
int display_start_dcp(void)
@@ -264,13 +274,13 @@ int display_start_dcp(void)
264274
return 0;
265275
#endif
266276

277+
const display_config_t *disp_cfg = display_get_config();
278+
267279
if (!has_dcp) {
268-
printf("display: DCP not present\n");
280+
printf("display: device has no DCP. Display will not be initialised.\n");
269281
return -1;
270282
}
271283

272-
const display_config_t *disp_cfg = display_get_config();
273-
274284
display_is_dptx = !!disp_cfg->dptx_phy[0];
275285

276286
dcp = dcp_init(disp_cfg);
@@ -655,6 +665,10 @@ int display_init(void)
655665

656666
void display_shutdown(dcp_shutdown_mode mode)
657667
{
668+
/* We have no DCP, so just exit */
669+
if (!has_dcp)
670+
return;
671+
658672
if (iboot) {
659673
dcp_ib_shutdown(iboot);
660674
switch (mode) {

src/main.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void get_device_info(void)
5151
printf(" Target: %s\n", target);
5252

5353
is_mac = !!strstr(model, "Mac");
54-
has_dcp = adt_path_offset(adt, "/arm-io/dcp") > 0;
5554

5655
int chosen = adt_path_offset(adt, "/chosen");
5756
if (chosen > 0) {
@@ -165,8 +164,7 @@ void m1n1_main(void)
165164
display_init();
166165
// Kick DCP to sleep, so dodgy monitors which cause reconnect cycles don't cause us to lose the
167166
// framebuffer.
168-
if (has_dcp)
169-
display_shutdown(DCP_SLEEP_IF_EXTERNAL);
167+
display_shutdown(DCP_SLEEP_IF_EXTERNAL);
170168
// On idevice we need to always clear, because otherwise it looks scuffed on white devices
171169
fb_init(!is_mac);
172170
fb_display_logo();

src/utils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "vsprintf.h"
1313
#include "xnuboot.h"
1414

15-
bool is_mac, has_dcp;
15+
bool is_mac;
1616

1717
static char ascii(char s)
1818
{

src/utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ struct vector_args {
464464

465465
extern u32 board_id, chip_id;
466466

467-
extern bool is_mac, has_dcp;
467+
extern bool is_mac;
468468
extern bool cpufeat_actlr_el2, cpufeat_fast_ipi, cpufeat_mmu_sprr;
469469
extern bool cpufeat_global_sleep, cpufeat_workaround_cyclone_cache;
470470

0 commit comments

Comments
 (0)