Skip to content

Commit

Permalink
Merge pull request #1015 from dmazzella/patch-1
Browse files Browse the repository at this point in the history
Arduino_H7_Video: handling errors at initialization time
  • Loading branch information
leonardocavagnis authored Jan 17, 2025
2 parents f9744ff + 0255e38 commit d9e1757
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
5 changes: 4 additions & 1 deletion libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ int Arduino_H7_Video::begin() {
#endif

/* Video controller/bridge init */
_shield->init(_edidMode);
int err_code = _shield->init(_edidMode);
if (err_code < 0) {
return 3; /* Video controller fail init */
}

#if __has_include("lvgl.h")
/* Initiliaze LVGL library */
Expand Down
15 changes: 12 additions & 3 deletions libraries/Arduino_H7_Video/src/H7DisplayShield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ int USBCVideoClass::init(int edidmode) {
}

//Checking HDMI plug event
anx7625_wait_hpd_event(0);
err_code = anx7625_wait_hpd_event(0);
if(err_code < 0) {
return err_code;
}

//Read EDID
anx7625_dp_get_edid(0, &recognized_edid);
err_code = anx7625_dp_get_edid(0, &recognized_edid);
if(err_code < 0) {
return err_code;
}

//DSI Configuration
anx7625_dp_start(0, &recognized_edid, (enum edid_modes) edidmode);
err_code = anx7625_dp_start(0, &recognized_edid, (enum edid_modes) edidmode);
if(err_code < 0) {
return err_code;
}

return 0;
}
Expand Down
16 changes: 11 additions & 5 deletions libraries/Arduino_H7_Video/src/anx7625.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,21 @@ int anx7625_init(uint8_t bus) {
return 0;
}

void anx7625_wait_hpd_event(uint8_t bus) {
int anx7625_wait_hpd_event(uint8_t bus) {
ANXINFO("Waiting for HDMI hot plug event...\n");

while (1) {

int retry_hpd_change = 10000;
while (--retry_hpd_change) {
mdelay(10);
int detected = anx7625_hpd_change_detect(bus);
if (detected == 1)
break;
if (detected < 0)
return -1;
if (detected > 0)
return 0;
}

ANXERROR("Timed out to detect HPD change on bus %d.\n", bus);
return -1;
}

int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/Arduino_H7_Video/src/anx7625.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern "C" {
int anx7625_dp_start(uint8_t bus, const struct edid *edid, enum edid_modes mode = EDID_MODE_AUTO);
int anx7625_dp_get_edid(uint8_t bus, struct edid *out);
int anx7625_init(uint8_t bus);
void anx7625_wait_hpd_event(uint8_t bus);
int anx7625_wait_hpd_event(uint8_t bus);
int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status);
int anx7625_read_system_status(uint8_t bus, uint8_t *sys_status);
bool anx7625_is_power_provider(uint8_t bus);
Expand Down

0 comments on commit d9e1757

Please sign in to comment.