Skip to contentSkip to conversation

drm/bridge: adv7511: fix support for large EDIDs

PATCH Superseded Hans Verkuil 3 participants 6 messages Mar 24, 2021 – Mar 26, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bridge: adv7511: fix support for large EDIDs

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

The reworked code just waits for any EDID segment reads to finish (this does nothing if the a segment is already read), checks if the desired segment matches the read segment, and if not, then it requests the new segment and waits again for the EDID segment to be read.

Finally it checks if the currently buffered EDID segment contains the desired EDID block, and if not it will update the EDID buffer from the adv7511.

Tested with my Koelsch board and with EDIDs of 1, 2, 3 and 4 blocks.

---
Testing on the Renesas board also requires these two adv7604 patches if you want to test with an HDMI cable between the HDMI input and output:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
---

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +21 -14
index 76555ae64e9c..9e8db1c60167 100644
@@ -328,6 +328,7 @@ static void adv7511_set_link_config(struct adv7511 *adv7511,
 static void __adv7511_power_on(struct adv7511 *adv7511)
 {
 	adv7511->current_edid_segment = -1;
+	adv7511->edid_read = false;
 
 	regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
 			   ADV7511_POWER_POWER_DOWN, 0);
@@ -529,29 +530,35 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 	struct adv7511 *adv7511 = data;
 	struct i2c_msg xfer[2];
 	uint8_t offset;
+	unsigned int cur_segment;
 	unsigned int i;
 	int ret;
 
 	if (len > 128)
 		return -EINVAL;
 
-	if (adv7511->current_edid_segment != block / 2) {
-		unsigned int status;
+	/* wait for any EDID segment reads to finish */
+	adv7511_wait_for_edid(adv7511, 200);
 
-		ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
-				  &status);
+	ret = regmap_read(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, &cur_segment);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * If the current read segment does not match what we need, then
+	 * write the new segment and wait for it to be read.
+	 */
+	if (cur_segment != block / 2) {
+		adv7511->edid_read = false;
+		cur_segment = block / 2;
+		regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
+			     cur_segment);
+		ret = adv7511_wait_for_edid(adv7511, 200);
 		if (ret < 0)
 			return ret;
+	}
 
-		if (status != 2) {
-			adv7511->edid_read = false;
-			regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
-				     block);
-			ret = adv7511_wait_for_edid(adv7511, 200);
-			if (ret < 0)
-				return ret;
-		}
-
+	if (adv7511->current_edid_segment != cur_segment) {
 		/* Break this apart, hopefully more I2C controllers will
 		 * support 64 byte transfers than 256 byte transfers
 		 */
@@ -579,7 +586,7 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 			offset += 64;
 		}
 
-		adv7511->current_edid_segment = block / 2;
+		adv7511->current_edid_segment = cur_segment;
 	}
 
 	if (block % 2 == 0)
Tested-by on v1 1/1
#1 lore raw

Hi Hans,

Thanks for your patch.

Quoted 17 lines · Hans Verkuil

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

The reworked code just waits for any EDID segment reads to finish (this does nothing if the a segment is already read), checks if the desired segment matches the read segment, and if not, then it requests the new segment and waits again for the EDID segment to be read.

Quoted 7 lines

Finally it checks if the currently buffered EDID segment contains the desired EDID block, and if not it will update the EDID buffer from the adv7511.

Tested with my Koelsch board and with EDIDs of 1, 2, 3 and 4 blocks.

Quoted 77 lines

---
Testing on the Renesas board also requires these two adv7604 patches if you want to test with an HDMI cable between the HDMI input and output:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
---

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +21 -14
index 76555ae64e9c..9e8db1c60167 100644
@@ -328,6 +328,7 @@ static void adv7511_set_link_config(struct adv7511 *adv7511,
 static void __adv7511_power_on(struct adv7511 *adv7511)
 {
 	adv7511->current_edid_segment = -1;
+	adv7511->edid_read = false;
 
 	regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
 			   ADV7511_POWER_POWER_DOWN, 0);
@@ -529,29 +530,35 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 	struct adv7511 *adv7511 = data;
 	struct i2c_msg xfer[2];
 	uint8_t offset;
+	unsigned int cur_segment;
 	unsigned int i;
 	int ret;
 
 	if (len > 128)
 		return -EINVAL;
 
-	if (adv7511->current_edid_segment != block / 2) {
-		unsigned int status;
+	/* wait for any EDID segment reads to finish */
+	adv7511_wait_for_edid(adv7511, 200);
 
-		ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
-				  &status);
+	ret = regmap_read(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, &cur_segment);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * If the current read segment does not match what we need, then
+	 * write the new segment and wait for it to be read.
+	 */
+	if (cur_segment != block / 2) {
+		adv7511->edid_read = false;
+		cur_segment = block / 2;
+		regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
+			     cur_segment);
+		ret = adv7511_wait_for_edid(adv7511, 200);
 		if (ret < 0)
 			return ret;
+	}
 
-		if (status != 2) {
-			adv7511->edid_read = false;
-			regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
-				     block);
-			ret = adv7511_wait_for_edid(adv7511, 200);
-			if (ret < 0)
-				return ret;
-		}
-
+	if (adv7511->current_edid_segment != cur_segment) {
 		/* Break this apart, hopefully more I2C controllers will
 		 * support 64 byte transfers than 256 byte transfers
 		 */
@@ -579,7 +586,7 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 			offset += 64;
 		}
 
-		adv7511->current_edid_segment = block / 2;
+		adv7511->current_edid_segment = cur_segment;
 	}
 
 	if (block % 2 == 0)
Signature · 2 lines
Regards,
Niklas Söderlund
#2 lore raw
In reply to Hans Verkuil

Hi Hans,

Thank you for the patch.

Quoted 11 lines · Hans Verkuil

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

Bits 3:0 of DDC_STATUS report the DDC controller state, which can be used to wait until the DDC controller is idle (it reports, among other possible states, if an EDID read is in progress). Other options are possible of course, including waiting for ADV7511_INT0_EDID_READY as done in adv7511_wait_for_edid(), but I wonder if the !irq case in adv7511_wait_for_edid() wouldn't be better of busy-looping on the DDC status instead of running the interrupt handler manually. That's unrelated to this patch though.

Quoted 36 lines

The reworked code just waits for any EDID segment reads to finish (this does nothing if the a segment is already read), checks if the desired segment matches the read segment, and if not, then it requests the new segment and waits again for the EDID segment to be read.

Finally it checks if the currently buffered EDID segment contains the desired EDID block, and if not it will update the EDID buffer from the adv7511.

Tested with my Koelsch board and with EDIDs of 1, 2, 3 and 4 blocks.

---
Testing on the Renesas board also requires these two adv7604 patches if you want to test with an HDMI cable between the HDMI input and output:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
---

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2 -0
index 76555ae64e9c..9e8db1c60167 100644
@@ -328,6 +328,7 @@ static void adv7511_set_link_config(struct adv7511 *adv7511,
 static void __adv7511_power_on(struct adv7511 *adv7511)
 {
 	adv7511->current_edid_segment = -1;
+	adv7511->edid_read = false;
 
 	regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
 			   ADV7511_POWER_POWER_DOWN, 0);
@@ -529,29 +530,35 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 	struct adv7511 *adv7511 = data;
 	struct i2c_msg xfer[2];
 	uint8_t offset;
+	unsigned int cur_segment;

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 541

Quoted 10 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2 -2
 	unsigned int i;
 	int ret;
 
 	if (len > 128)
 		return -EINVAL;
 
-	if (adv7511->current_edid_segment != block / 2) {
-		unsigned int status;
+	/* wait for any EDID segment reads to finish */
+	adv7511_wait_for_edid(adv7511, 200);

Why do we need to wait for the EDID read to complete here ? Does the ADV7511 initiate an EDID read by itself that we need to wait for it to complete ?

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 545

Quoted 6 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +3 -2
-		ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
-				  &status);
+	ret = regmap_read(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, &cur_segment);
+	if (ret < 0)
+		return ret;

Do we need to read this from the device, can't we instead use current_edid_segment ?

Quoted 15 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +12 -0
+
+	/*
+	 * If the current read segment does not match what we need, then
+	 * write the new segment and wait for it to be read.
+	 */
+	if (cur_segment != block / 2) {
+		adv7511->edid_read = false;
+		cur_segment = block / 2;
+		regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
+			     cur_segment);
+		ret = adv7511_wait_for_edid(adv7511, 200);
 		if (ret < 0)
 			return ret;
+	}
 

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 561

Quoted 10 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1 -9
-		if (status != 2) {
-			adv7511->edid_read = false;
-			regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
-				     block);
-			ret = adv7511_wait_for_edid(adv7511, 200);
-			if (ret < 0)
-				return ret;
-		}
-
+	if (adv7511->current_edid_segment != cur_segment) {

Do you need to test this condition separately from the previous one ?

Quoted 12 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1 -1
 		/* Break this apart, hopefully more I2C controllers will
 		 * support 64 byte transfers than 256 byte transfers
 		 */
@@ -579,7 +586,7 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 			offset += 64;
 		}
 
-		adv7511->current_edid_segment = block / 2;
+		adv7511->current_edid_segment = cur_segment;
 	}
 
 	if (block % 2 == 0)
Signature · 7 lines
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Hi Laurent,

Thank you for the review.

Quoted 68 lines · Laurent Pinchart

Hi Hans,

Thank you for the patch.

Quoted 11 lines · Hans Verkuil

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

Bits 3:0 of DDC_STATUS report the DDC controller state, which can be used to wait until the DDC controller is idle (it reports, among other possible states, if an EDID read is in progress). Other options are possible of course, including waiting for ADV7511_INT0_EDID_READY as done in adv7511_wait_for_edid(), but I wonder if the !irq case in adv7511_wait_for_edid() wouldn't be better of busy-looping on the DDC status instead of running the interrupt handler manually. That's unrelated to this patch though.

Quoted 42 lines

The reworked code just waits for any EDID segment reads to finish (this does nothing if the a segment is already read), checks if the desired segment matches the read segment, and if not, then it requests the new segment and waits again for the EDID segment to be read.

Finally it checks if the currently buffered EDID segment contains the desired EDID block, and if not it will update the EDID buffer from the adv7511.

Tested with my Koelsch board and with EDIDs of 1, 2, 3 and 4 blocks.

---
Testing on the Renesas board also requires these two adv7604 patches if you want to test with an HDMI cable between the HDMI input and output:

https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
---

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2 -0
index 76555ae64e9c..9e8db1c60167 100644
@@ -328,6 +328,7 @@ static void adv7511_set_link_config(struct adv7511 *adv7511,
 static void __adv7511_power_on(struct adv7511 *adv7511)
 {
 	adv7511->current_edid_segment = -1;
+	adv7511->edid_read = false;
 
 	regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
 			   ADV7511_POWER_POWER_DOWN, 0);
@@ -529,29 +530,35 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 	struct adv7511 *adv7511 = data;
 	struct i2c_msg xfer[2];
 	uint8_t offset;
+	unsigned int cur_segment;
 	unsigned int i;
 	int ret;
 
 	if (len > 128)
 		return -EINVAL;
 
Quoted 8 lines

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 541

Quoted 4 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +2 -2
-	if (adv7511->current_edid_segment != block / 2) {
-		unsigned int status;
+	/* wait for any EDID segment reads to finish */
+	adv7511_wait_for_edid(adv7511, 200);

Why do we need to wait for the EDID read to complete here ? Does the ADV7511 initiate an EDID read by itself that we need to wait for it to complete ?

Yes. When powered on it will automatically start to read the first segment.

Quoted 10 lines

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 545

Quoted 7 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +3 -2
-		ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
-				  &status);
+	ret = regmap_read(adv7511->regmap, ADV7511_REG_EDID_SEGMENT, &cur_segment);
+	if (ret < 0)
+		return ret;

Do we need to read this from the device, can't we instead use current_edid_segment ?

We can, provided we take into account that after poweron current_edid_segment is -1, and in that case we must not set ADV7511_REG_EDID_SEGMENT again.

I'll make that change.

Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +12 -0
+
+	/*
+	 * If the current read segment does not match what we need, then
+	 * write the new segment and wait for it to be read.
+	 */
+	if (cur_segment != block / 2) {
+		adv7511->edid_read = false;
+		cur_segment = block / 2;
+		regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
+			     cur_segment);
+		ret = adv7511_wait_for_edid(adv7511, 200);
 		if (ret < 0)
 			return ret;
+	}
 
Quoted 12 lines

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 561

Quoted 10 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1 -9
-		if (status != 2) {
-			adv7511->edid_read = false;
-			regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
-				     block);
-			ret = adv7511_wait_for_edid(adv7511, 200);
-			if (ret < 0)
-				return ret;
-		}
-
+	if (adv7511->current_edid_segment != cur_segment) {

Do you need to test this condition separately from the previous one ?

Yes, again for the initial power on case where segment 0 has been read without ADV7511_REG_EDID_SEGMENT being written by us, and so we still need to read out segment 0 from the adv7511.

I'll add some comments in v2.

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +0 -0
 		/* Break this apart, hopefully more I2C controllers will
 		 * support 64 byte transfers than 256 byte transfers
 		 */
@@ -579,7 +586,7 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
 			offset += 64;
 		}
 
Quoted 6 lines

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, · line 592

Quoted 5 lines
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +1 -1
-		adv7511->current_edid_segment = block / 2;
+		adv7511->current_edid_segment = cur_segment;
 	}
 
 	if (block % 2 == 0)

Regards,

Hans
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Laurent Pinchart
Quoted 17 lines · Laurent Pinchart

Hi Hans,

Thank you for the patch.

Quoted 11 lines · Hans Verkuil

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

Quoted 8 lines

Bits 3:0 of DDC_STATUS report the DDC controller state, which can be used to wait until the DDC controller is idle (it reports, among other possible states, if an EDID read is in progress). Other options are possible of course, including waiting for ADV7511_INT0_EDID_READY as done in adv7511_wait_for_edid(), but I wonder if the !irq case in adv7511_wait_for_edid() wouldn't be better of busy-looping on the DDC status instead of running the interrupt handler manually. That's unrelated to this patch though.

The DDC status tests for other things as well, including HDCP.

I think it is pure luck that this code even worked:

        if (adv7511->current_edid_segment != block / 2) {
                unsigned int status;

                ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
                                  &status);
                if (ret < 0)
                        return ret;

                if (status != 2) {
                        adv7511->edid_read = false;
                        regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
                                     block);
                        ret = adv7511_wait_for_edid(adv7511, 200);
                        if (ret < 0)
                                return ret;
                }

What happens on power on is that the adv7511 starts reading the EDID. So the DDC_STATUS is 1 (Reading EDID). This code is called, it falls in the status != 2 block, it writes the EDID_SEGMENT with 0 (it already is 0 after a power on), then waits for the EDID read to finish.

The only reason this works is that this code is called fast enough after the device is powered on that it is still reading the EDID.

It fails if you want to read the next segment, since in that case the status is 2 (IDLE) and it will never write the new segment to the EDID_SEGMENT register.

And besides, status wasn't ANDed with 0xf either, and HDCP might also be ongoing (should that be enabled in the future).

Regards,

Hans
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Hi Hans,

Quoted 23 lines · Hans Verkuil
Quoted 13 lines · Laurent Pinchart
Quoted 11 lines · Hans Verkuil

While testing support for large (> 256 bytes) EDIDs on the Renesas Koelsch board I noticed that the adv7511 bridge driver only read the first two blocks.

The media V4L2 version for the adv7511 (drivers/media/i2c/adv7511-v4l2.c) handled this correctly.

Besides a simple bug when setting the segment register (it was set to the block number instead of block / 2), the logic of the code was also weird. In particular reading the DDC_STATUS is odd: this is unrelated to EDID reading.

Quoted 8 lines

Bits 3:0 of DDC_STATUS report the DDC controller state, which can be used to wait until the DDC controller is idle (it reports, among other possible states, if an EDID read is in progress). Other options are possible of course, including waiting for ADV7511_INT0_EDID_READY as done in adv7511_wait_for_edid(), but I wonder if the !irq case in adv7511_wait_for_edid() wouldn't be better of busy-looping on the DDC status instead of running the interrupt handler manually. That's unrelated to this patch though.

Quoted 1 line

The DDC status tests for other things as well, including HDCP.

I haven't read the chip's documentation in details, but if HDCP negotiation is in progress, doesn't that keep the DDC bus busy, preventing an EDID read ?

Quoted 19 lines

I think it is pure luck that this code even worked:

        if (adv7511->current_edid_segment != block / 2) {
                unsigned int status;

                ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
                                  &status);
                if (ret < 0)
                        return ret;

                if (status != 2) {
                        adv7511->edid_read = false;
                        regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
                                     block);
                        ret = adv7511_wait_for_edid(adv7511, 200);
                        if (ret < 0)
                                return ret;
                }
Quoted 7 lines

What happens on power on is that the adv7511 starts reading the EDID. So the DDC_STATUS is 1 (Reading EDID). This code is called, it falls in the status != 2 block, it writes the EDID_SEGMENT with 0 (it already is 0 after a power on), then waits for the EDID read to finish.

The only reason this works is that this code is called fast enough after the device is powered on that it is still reading the EDID.

Yes, I agree with you. Luck is nice, except when it makes us merge incorrect code :-)

Quoted 6 lines

It fails if you want to read the next segment, since in that case the status is 2 (IDLE) and it will never write the new segment to the EDID_SEGMENT register.

And besides, status wasn't ANDed with 0xf either, and HDCP might also be ongoing (should that be enabled in the future).

Signature · 7 lines
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel