Skip to content

Arduino_H7_Video: handling errors at initialization time #1015

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

Merged
merged 2 commits into from
Jan 17, 2025
Merged
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
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
Loading