media: add support for the EDID EEODB
Subsystems (2)
v2 cover media: add support for the EDID EEODB
Add support for the HDMI Forum EDID Extension Override Data Block by introducing the v4l2_num_edid_blocks() helper function.
Update the adv7511-v4l2 driver to use this new function. This fixes adv7511 support for EDIDs using the EEODB as otherwise only the first two blocks would be read.
Regards,
Hans
Changes since v1:
- add lots of comments to the v4l2_num_edid_blocks helper. There are a lot of constants there, so those needed proper comments.
Hans Verkuil (2):
media: v4l2-dv-timings: add v4l2_num_edid_blocks() helper
media: adv7511-v4l2: add support for the EEODB
drivers/media/i2c/adv7511-v4l2.c | 6 ++-- drivers/media/v4l2-core/v4l2-dv-timings.c | 36 +++++++++++++++++++++++ include/media/v4l2-dv-timings.h | 1 + 3 files changed, 41 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.2
PATCH v2 1/2 media: v4l2-dv-timings: add v4l2_num_edid_blocks() helper
This new function determines how many blocks the EDID has. Traditionally the number of extension blocks is read from the EDID at offset 126, but this can be overridden by the HDMI Forum EDID Extension Override Data Block. So check that as well in this helper.
--- drivers/media/v4l2-core/v4l2-dv-timings.c | 36 +++++++++++++++++++++++ include/media/v4l2-dv-timings.h | 1 + 2 files changed, 37 insertions(+)
drivers/media/v4l2-core/v4l2-dv-timings.c +36 -0
@@ -1017,6 +1017,42 @@ v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi, }EXPORT_SYMBOL_GPL (v4l2_hdmi_rx_colorimetry); +/** +* v4l2_num_edid_blocks() - return the number of EDID blocks +* +* @edid: pointer to the EDID data +* @max_blocks: maximum number of supported EDID blocks +* +* Return: the number of EDID blocks based on the contents of the EDID. +* This supports the HDMI Forum EDID Extension Override Data Block. +*/ +unsigned int v4l2_num_edid_blocks (const u8 *edid,unsigned int max_blocks) +{ +unsigned int blocks; + +if (!edid || !max_blocks) +return 0 ; + +// The number of extension blocks is recorded at byte 126 of the +// first 128-byte block in the EDID. +// +// If there is an HDMI Forum EDID Extension Override Data Block +// present, then it is in bytes 4-6 of the first CTA-861 extension +// block of the EDID. + blocks = edid[126 ] +1 ; +// Check for HDMI Forum EDID Extension Override Data Block +if (blocks >=2 &&// The EDID must be at least 2 blocks + max_blocks >=3 &&// The caller supports at least 3 blocks + edid[128 ] ==2 &&// The first extension block is type CTA-861 + edid[133 ] ==0x78 &&// Identifier for the EEODB + (edid[132 ] &0xe0 ) ==0xe0 &&// Tag Code == 7 + (edid[132 ] &0x1f ) >=2 &&// Length >= 2 + edid[134 ] >1 )// Number of extension blocks is sane + blocks = edid[134 ] +1 ; +return blocks > max_blocks ? max_blocks : blocks; +} +EXPORT_SYMBOL_GPL (v4l2_num_edid_blocks); +/** * v4l2_get_edid_phys_addr() - find and return the physical address *
include/media/v4l2-dv-timings.h +1 -0
@@ -252,6 +252,7 @@ v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi,const struct hdmi_vendor_infoframe *hdmi, unsigned int height); +unsigned int v4l2_num_edid_blocks (const u8 *edid,unsigned int max_blocks);u16 v4l2_get_edid_phys_addr (const u8 *edid,unsigned int size,unsigned int *offset);void v4l2_set_edid_phys_addr (u8 *edid,unsigned int size,u16 phys_addr);
Signature · 1 line
2.45.2
PATCH v2 2/2 media: adv7511-v4l2: add support for the EEODB
In reply to Hans VerkuilSupport the HDMI Forum EDID Extension Override Data Block by using the new v4l2_num_edid_blocks helper function.
--- drivers/media/i2c/adv7511-v4l2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/i2c/adv7511-v4l2.c +4 -2
@@ -1664,7 +1664,9 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)if (!err) {adv7511_dbg_dump_edid (2 , debug, sd, segment, &state->edid.data[segment *256 ]);if (segment ==0 ) { - state->edid.blocks = state->edid.data[0x7e ] +1 ; + state->edid.blocks = +v4l2_num_edid_blocks (state->edid.data, +EDID_MAX_SEGM *2 );v4l2_dbg (1 , debug, sd,"%s: %d blocks in total\n" , __func__, state->edid.blocks); }
@@ -1682,7 +1684,7 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)/* one more segment read ok */ state->edid.segments = segment +1 ;v4l2_ctrl_s_ctrl (state->have_edid0_ctrl,0x1 ); -if (((state->edid.data[0x7e ] >>1 ) +1 ) > state->edid.segments) { +if (state->edid.blocks > state->edid.segments *2 ) {/* Request next EDID segment */ v4l2_dbg (1 , debug, sd,"%s: request segment %d\n" , __func__, state->edid.segments);adv7511_wr (sd,0xc9 ,0xf );
Signature · 1 line
2.45.2