drm/edid: Add aspect ratios to HDMI 4K modes
Subsystems (2)
PATCH 1/2 drm/edid: Add aspect ratios to HDMI 4K modes
[Why]
HDMI 2.0 adds aspect ratio attribute to distinguish different 4k modes. According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate video mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.
Current code doesn't take aspect ratio into consideration while constructing avi infoframe. Should modify that.
[How]
Inherit Ville Syrjälä's work
"drm/edid: Prep for HDMI VIC aspect ratio" at
https://patchwork.kernel.org/patch/11174639/
Add picture_aspect_ratio attributes to edid_4k_modes[] and construct VIC and HDMI_VIC by taking aspect ratio into consideration.
--- drivers/gpu/drm/drm_edid.c | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_edid.c +35 -10
@@ -1288,25 +1288,25 @@ static const struct drm_display_mode edid_4k_modes[] = { 3840, 4016, 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 30, }, + .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },/* 2 - 3840x2160@25Hz */ {DRM_MODE ("3840x2160" ,DRM_MODE_TYPE_DRIVER ,297000 ,3840 ,4896 ,4984 ,5280 ,0 ,2160 ,2168 ,2178 ,2250 ,0 , DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 25, }, + .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 3 - 3840x2160@24Hz */ { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,3840 ,5116 ,5204 ,5500 ,0 ,2160 ,2168 ,2178 ,2250 ,0 ,DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC ), - .vrefresh = 24, }, + .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 4 - 4096x2160@24Hz (SMPTE) */ { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,4096 ,5116 ,5204 ,5500 ,0 ,2160 ,2168 ,2178 ,2250 ,0 ,DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC ), - .vrefresh = 24, }, + .vrefresh = 24, HDMI_PICTURE_ASPECT_256_135}, };/*** DDC fetch and block validation ***/
@@ -3110,6 +3110,11 @@ static enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)return edid_cea_modes[video_code].picture_aspect_ratio; } +static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio (const u8 video_code) +{ +return edid_4k_modes[video_code].picture_aspect_ratio; +} +/* * Calculate the alternate clock for HDMI modes (those from the HDMI vendor * specific block).
@@ -3136,6 +3141,9 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_4k_modes); vic++) {const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];unsigned int clock1, clock2;
@@ -3171,6 +3179,9 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_4k_modes); vic++) {const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];unsigned int clock1, clock2;
@@ -5118,6 +5129,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, const struct drm_display_mode *mode) {enum hdmi_picture_aspect picture_aspect; +u8 vic, hdmi_vic;int err;if (!frame || !mode)
@@ -5130,7 +5142,8 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,if (mode->flags &DRM_MODE_FLAG_DBLCLK ) frame->pixel_repeat =1 ; - frame->video_code =drm_mode_cea_vic (connector, mode); + vic =drm_mode_cea_vic (connector, mode); + hdmi_vic =drm_mode_hdmi_vic (connector, mode); frame->picture_aspect =HDMI_PICTURE_ASPECT_NONE ;
@@ -5144,11 +5157,15 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,/* * Populate picture aspect ratio from either -* user input (if specified) or from the CEA mode list. +* user input (if specified) or from the CEA/HDMI mode lists. */ picture_aspect = mode->picture_aspect_ratio; -if (picture_aspect ==HDMI_PICTURE_ASPECT_NONE ) - picture_aspect =drm_get_cea_aspect_ratio (frame->video_code); +if (picture_aspect ==HDMI_PICTURE_ASPECT_NONE ) { +if (vic) + picture_aspect =drm_get_cea_aspect_ratio (vic); +else if (hdmi_vic) + picture_aspect =drm_get_hdmi_aspect_ratio (hdmi_vic); + }/* * The infoframe can't convey anything but none, 4:3
@@ -5156,12 +5173,20 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,* we can only satisfy it by specifying the right VIC. */ if (picture_aspect >HDMI_PICTURE_ASPECT_16_9 ) { -if (picture_aspect != -drm_get_cea_aspect_ratio (frame->video_code)) +if (vic) { +if (picture_aspect !=drm_get_cea_aspect_ratio (vic)) +return -EINVAL ; + }else if (hdmi_vic) { +if (picture_aspect !=drm_get_hdmi_aspect_ratio (hdmi_vic)) +return -EINVAL ; + }else {return -EINVAL ; + } + picture_aspect =HDMI_PICTURE_ASPECT_NONE ; } + frame->video_code = vic; frame->picture_aspect = picture_aspect; frame->active_aspect =HDMI_ACTIVE_ASPECT_PICTURE ; frame->scan_mode =HDMI_SCAN_MODE_UNDERSCAN ;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/edid: Add alternate clock for SMPTE 4K
[Why]
In hdmi_mode_alternate_clock(), it adds an exception for VIC 4 mode (4096x2160@24) due to there is no alternate clock defined for that mode in HDMI1.4b. But HDMI2.0 adds 23.98Hz for that mode.
[How]
Remove the exception
--- drivers/gpu/drm/drm_edid.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/drm_edid.c +0 -3
@@ -3126,9 +3126,6 @@ static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)static unsigned int hdmi_mode_alternate_clock (const struct drm_display_mode *hdmi_mode) { -if (hdmi_mode->vdisplay ==4096 && hdmi_mode->hdisplay ==2160 ) -return hdmi_mode->clock; -return cea_mode_alternate_clock (hdmi_mode); }
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/edid: Add alternate clock for SMPTE 4K
Quoted 7 lines · Wayne Lin
[Why]
Inhdmi_mode_alternate_clock(), it adds an exception for VIC 4 mode (4096x2160@24) due to there is no alternate clock defined for that mode in HDMI1.4b. But HDMI2.0 adds 23.98Hz for that mode.[How]
Remove the exception
Shouldn't it be only bypassed when the sink is HDMI2 ?
Neil
Quoted 12 lines
Signed-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_edid.c | 3 --- 1 file changed, 3 deletions(-)drivers/gpu/drm/drm_edid.c +0
-0
drivers/gpu/drm/drm_edid.c static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code) · line 3131
Quoted 9 lines
drivers/gpu/drm/drm_edid.c +0
-3@@ -3126,9 +3126,6 @@ static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)static unsigned int hdmi_mode_alternate_clock (const struct drm_display_mode *hdmi_mode) { -if (hdmi_mode->vdisplay ==4096 && hdmi_mode->hdisplay ==2160 ) -return hdmi_mode->clock; -return cea_mode_alternate_clock (hdmi_mode); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 44 lines · Wayne Lin
[Why]
HDMI 2.0 adds aspect ratio attribute to distinguish different 4k modes. According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate video mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.Current code doesn't take aspect ratio into consideration while constructing avi infoframe. Should modify that.
[How]
Inherit Ville Syrjälä's work
"drm/edid: Prep for HDMI VIC aspect ratio" at
https://patchwork.kernel.org/patch/11174639/Add
picture_aspect_ratioattributes to edid_4k_modes[] and construct VIC andHDMI_VICby taking aspect ratio into consideration.Signed-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_edid.c | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_edid.c +2
-2@@ -1288,25 +1288,25 @@ static const struct drm_display_mode edid_4k_modes[] = { 3840, 4016, 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 30, }, + .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },/* 2 - 3840x2160@25Hz */ {DRM_MODE ("3840x2160" ,DRM_MODE_TYPE_DRIVER ,297000 ,3840 ,4896 ,4984 ,5280 ,0 ,2160 ,2168 ,2178 ,2250 ,0 , DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 25, }, + .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, /* 3 - 3840x2160@24Hz */ { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
drivers/gpu/drm/drm_edid.c static const struct drm_display_mode edid_4k_modes[] = { · line 1309
Quoted 10 lines
drivers/gpu/drm/drm_edid.c +2
-2DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 24, }, + .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },/* 4 - 4096x2160@24Hz (SMPTE) */ {DRM_MODE ("4096x2160" ,DRM_MODE_TYPE_DRIVER ,297000 ,4096 ,5116 ,5204 ,5500 ,0 ,2160 ,2168 ,2178 ,2250 ,0 , DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), - .vrefresh = 24, }, + .vrefresh = 24, HDMI_PICTURE_ASPECT_256_135},
^ ^
Missing named initializer. Missing ", "
Quoted 97 lines
drivers/gpu/drm/drm_edid.c +31
-6};/*** DDC fetch and block validation ***/ @@ -3110,6 +3110,11 @@ static enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)return edid_cea_modes[video_code].picture_aspect_ratio; } +static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio (const u8 video_code) +{ +return edid_4k_modes[video_code].picture_aspect_ratio; +} +/* * Calculate the alternate clock for HDMI modes (those from the HDMI vendor * specific block). @@ -3136,6 +3141,9 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_4k_modes); vic++) {const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];unsigned int clock1, clock2;@@ -3171,6 +3179,9 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_4k_modes); vic++) {const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];unsigned int clock1, clock2;@@ -5118,6 +5129,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, const struct drm_display_mode *mode) {enum hdmi_picture_aspect picture_aspect; +u8 vic, hdmi_vic;int err;if (!frame || !mode)@@ -5130,7 +5142,8 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,if (mode->flags &DRM_MODE_FLAG_DBLCLK ) frame->pixel_repeat =1 ; - frame->video_code =drm_mode_cea_vic (connector, mode); + vic =drm_mode_cea_vic (connector, mode); + hdmi_vic =drm_mode_hdmi_vic (connector, mode); frame->picture_aspect =HDMI_PICTURE_ASPECT_NONE ;@@ -5144,11 +5157,15 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,/* * Populate picture aspect ratio from either -* user input (if specified) or from the CEA mode list. +* user input (if specified) or from the CEA/HDMI mode lists. */ picture_aspect = mode->picture_aspect_ratio; -if (picture_aspect ==HDMI_PICTURE_ASPECT_NONE ) - picture_aspect =drm_get_cea_aspect_ratio (frame->video_code); +if (picture_aspect ==HDMI_PICTURE_ASPECT_NONE ) { +if (vic) + picture_aspect =drm_get_cea_aspect_ratio (vic); +else if (hdmi_vic) + picture_aspect =drm_get_hdmi_aspect_ratio (hdmi_vic); + }/* * The infoframe can't convey anything but none, 4:3 @@ -5156,12 +5173,20 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,* we can only satisfy it by specifying the right VIC. */ if (picture_aspect >HDMI_PICTURE_ASPECT_16_9 ) { -if (picture_aspect != -drm_get_cea_aspect_ratio (frame->video_code)) +if (vic) { +if (picture_aspect !=drm_get_cea_aspect_ratio (vic)) +return -EINVAL ; + }else if (hdmi_vic) { +if (picture_aspect !=drm_get_hdmi_aspect_ratio (hdmi_vic)) +return -EINVAL ; + }else {return -EINVAL ; + } + picture_aspect =HDMI_PICTURE_ASPECT_NONE ; } + frame->video_code = vic; frame->picture_aspect = picture_aspect; frame->active_aspect =HDMI_ACTIVE_ASPECT_PICTURE ; frame->scan_mode =HDMI_SCAN_MODE_UNDERSCAN ;Signature · 1 line
2.17.1
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/edid: Add alternate clock for SMPTE 4K
In reply to Wayne Lindrivers/gpu/drm/drm_edid.c static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)
Quoted 18 lines · Wayne Lin
[Why]
Inhdmi_mode_alternate_clock(), it adds an exception for VIC 4 mode (4096x2160@24) due to there is no alternate clock defined for that mode in HDMI1.4b. But HDMI2.0 adds 23.98Hz for that mode.[How]
Remove the exceptionSigned-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_edid.c | 3 --- 1 file changed, 3 deletions(-)drivers/gpu/drm/drm_edid.c +0
-0@@ -3126,9 +3126,6 @@ static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)
^ the comment above would no longer match the code. Pls fix it up.
Quoted 11 lines
drivers/gpu/drm/drm_edid.c +0
-3static unsigned int hdmi_mode_alternate_clock (const struct drm_display_mode *hdmi_mode) { -if (hdmi_mode->vdisplay ==4096 && hdmi_mode->hdisplay ==2160 ) -return hdmi_mode->clock; -return cea_mode_alternate_clock (hdmi_mode); }Signature · 1 line
2.17.1
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/edid: Add alternate clock for SMPTE 4K
In reply to a message not in the archiveQuoted 10 lines · Neil Armstrong
Quoted 7 lines · Wayne Lin
[Why]
Inhdmi_mode_alternate_clock(), it adds an exception for VIC 4 mode (4096x2160@24) due to there is no alternate clock defined for that mode in HDMI1.4b. But HDMI2.0 adds 23.98Hz for that mode.[How]
Remove the exceptionShouldn't it be only bypassed when the sink is HDMI2 ?
IMO just nuke the check. Can't see much harm coming from adding the 23.98Hz mode on HDMI 1.4 as well.
Quoted 29 lines
Neil
Quoted 12 lines
Signed-off-by Wayne Lin <[email protected]>--- drivers/gpu/drm/drm_edid.c | 3 --- 1 file changed, 3 deletions(-)drivers/gpu/drm/drm_edid.c +0
-0drivers/gpu/drm/drm_edid.c static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code) · line 3131
Quoted 9 lines
drivers/gpu/drm/drm_edid.c +0
-3@@ -3126,9 +3126,6 @@ static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)static unsigned int hdmi_mode_alternate_clock (const struct drm_display_mode *hdmi_mode) { -if (hdmi_mode->vdisplay ==4096 && hdmi_mode->hdisplay ==2160 ) -return hdmi_mode->clock; -return cea_mode_alternate_clock (hdmi_mode); }_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx