Skip to content

Commit d521eb0

Browse files
committed
Fixed hot plug hdmi cable event handling. If cable is not present just sit and wait instead of resetting anx7625.
1 parent a2c06d7 commit d521eb0

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

libraries/Portenta_Video/anx7625.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -818,13 +818,13 @@ static int anx7625_hpd_change_detect(uint8_t bus)
818818

819819
ret = anx7625_reg_read(bus, RX_P0_ADDR, SYSTEM_STSTUS, &status);
820820
if (ret < 0) {
821-
ANXERROR("IO error: Failed to clear interrupt status.\n");
821+
ANXERROR("IO error: Failed to read HPD_STATUS register.\n");
822822
return ret;
823823
}
824824

825825
if (status & HPD_STATUS) {
826826
anx7625_start_dp_work(bus);
827-
ANXINFO("HPD received 0x7e:0x45=%#x\n", status);
827+
ANXINFO("HPD event received 0x7e:0x45=%#x\n", status);
828828
return 1;
829829
}
830830
return 0;
@@ -1312,9 +1312,9 @@ int anx7625_dp_get_edid(uint8_t bus, struct edid *out)
13121312

13131313
int anx7625_init(uint8_t bus)
13141314
{
1315-
int retry_hpd_change = 500;
13161315
int retry_power_on = 3;
13171316

1317+
ANXINFO("Powering on anx7625...\n");
13181318
while (--retry_power_on) {
13191319
if (anx7625_power_on_init(bus) == 0)
13201320
break;
@@ -1323,16 +1323,18 @@ int anx7625_init(uint8_t bus)
13231323
ANXERROR("Failed to power on.\n");
13241324
return -1;
13251325
}
1326+
ANXINFO("Powering on anx7625 successfull.\n");
13261327

1327-
while (--retry_hpd_change) {
1328+
return 0;
1329+
}
1330+
1331+
void anx7625_wait_hpd_event(uint8_t bus)
1332+
{
1333+
ANXINFO("Waiting for hdmi hot plug event...\n");
1334+
while (1) {
13281335
mdelay(10);
13291336
int detected = anx7625_hpd_change_detect(bus);
1330-
if (detected < 0)
1331-
return -1;
1332-
if (detected > 0)
1333-
return 0;
1337+
if (detected == 1)
1338+
break;
13341339
}
1335-
1336-
ANXERROR("Timed out to detect HPD change on bus %d.\n", bus);
1337-
return -1;
13381340
}

libraries/Portenta_Video/anx7625.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ struct display_timing {
363363
int anx7625_dp_start(uint8_t bus, const struct edid *edid, enum edid_modes mode = EDID_MODE_AUTO);
364364
int anx7625_dp_get_edid(uint8_t bus, struct edid *out);
365365
int anx7625_init(uint8_t bus);
366+
void anx7625_wait_hpd_event(uint8_t bus);
366367
int stm32_dsi_config(uint8_t bus, struct edid *edid, struct display_timing *dt);
367368
void stm32_BriefDisplay(void);
368369
void stm32_LCD_Clear(uint32_t color);
@@ -374,4 +375,4 @@ uint32_t stm32_getYSize();
374375
uint32_t getFramebufferEnd();
375376
DMA2D_HandleTypeDef* stm32_get_DMA2D(void);
376377

377-
#endif /* __ANX7625_H__ */
378+
#endif /* __ANX7625_H__ */

libraries/Portenta_Video/examples/Envie_video_coreboot/Envie_video_coreboot.ino

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ void setup() {
2121
delay(10);
2222
video_rst = 0;
2323
delay(100);
24-
while (ret < 0) {
2524

26-
video_on = 0;
27-
delay(10);
28-
video_rst = 0;
29-
delay(100);
30-
31-
video_on = 1;
32-
delay(100);
33-
video_rst = 1;
25+
video_on = 1;
26+
delay(100);
27+
video_rst = 1;
3428

35-
ret = anx7625_init(0);
29+
ret = anx7625_init(0);
30+
if(ret < 0) {
31+
printf("Cannot continue, anx7625 init failed.\n");
32+
while(1);
3633
}
34+
35+
anx7625_wait_hpd_event(0);
36+
3737
anx7625_dp_get_edid(0, &recognized_edid);
3838
anx7625_dp_start(0, &recognized_edid, EDID_MODE_640x480_60Hz);
3939

@@ -47,10 +47,7 @@ void setup() {
4747
int i = 0;
4848

4949
void loop() {
50-
delay(1000);
51-
52-
i = random(0, 0xFFFFFF);
53-
printf("now: %d\n", millis());
50+
printf("Now: %d\n", millis());
5451

5552
delay(1000);
5653
}

0 commit comments

Comments
 (0)