dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Wayne Lin <Wayne.Lin-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/2] drm/edid: Add aspect ratios to HDMI 4K modes
Date: Fri, 15 Nov 2019 21:22:01 +0200	[thread overview]
Message-ID: <20191115192201.GK1208@intel.com> (raw)
In-Reply-To: <20191112075307.12574-1-Wayne.Lin-5C7GfCeVMHo@public.gmane.org>

On Tue, Nov 12, 2019 at 03:53:06PM +0800, Wayne Lin wrote:
> [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.
> 
> Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 45 +++++++++++++++++++++++++++++---------
>  1 file changed, 35 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 77a39fc76045..fcd7ae29049d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -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},
                         ^                           ^
Missing named initializer.                 Missing ", "

>  };
>  
>  /*** 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;
> -- 
> 2.17.1

-- 
Ville Syrjälä
Intel
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Wayne Lin <Wayne.Lin@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/edid: Add aspect ratios to HDMI 4K modes
Date: Fri, 15 Nov 2019 21:22:01 +0200	[thread overview]
Message-ID: <20191115192201.GK1208@intel.com> (raw)
Message-ID: <20191115192201.NzRvxJyZh_ySPseDlmgrKj7x6Yo-JoQC6UDm3sTXrlE@z> (raw)
In-Reply-To: <20191112075307.12574-1-Wayne.Lin@amd.com>

On Tue, Nov 12, 2019 at 03:53:06PM +0800, Wayne Lin wrote:
> [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.
> 
> Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 45 +++++++++++++++++++++++++++++---------
>  1 file changed, 35 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 77a39fc76045..fcd7ae29049d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -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},
                         ^                           ^
Missing named initializer.                 Missing ", "

>  };
>  
>  /*** 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;
> -- 
> 2.17.1

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-11-15 19:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12  7:53 [PATCH 1/2] drm/edid: Add aspect ratios to HDMI 4K modes Wayne Lin
2019-11-12  7:53 ` Wayne Lin
2019-11-12  7:53 ` [PATCH 2/2] drm/edid: Add alternate clock for SMPTE 4K Wayne Lin
2019-11-12  7:53   ` Wayne Lin
2019-11-12  9:36   ` Neil Armstrong
     [not found]     ` <75d0e827-25b2-ceae-0484-a98af7b8b693-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2019-11-15 19:23       ` Ville Syrjälä
2019-11-15 19:23         ` Ville Syrjälä
2019-11-15 19:22   ` Ville Syrjälä
     [not found] ` <20191112075307.12574-1-Wayne.Lin-5C7GfCeVMHo@public.gmane.org>
2019-11-15 19:22   ` Ville Syrjälä [this message]
2019-11-15 19:22     ` [PATCH 1/2] drm/edid: Add aspect ratios to HDMI 4K modes Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191115192201.GK1208@intel.com \
    --to=ville.syrjala-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=Wayne.Lin-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).