All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
Cc: Jose Abreu <jose.abreu@synopsys.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 6/8] drm: Expose modes with aspect ratio, only if requested
Date: Mon, 29 Jan 2018 20:58:24 +0200	[thread overview]
Message-ID: <20180129185824.GV5453@intel.com> (raw)
In-Reply-To: <1515738096-16892-7-git-send-email-ankit.k.nautiyal@intel.com>

On Fri, Jan 12, 2018 at 11:51:34AM +0530, Nautiyal, Ankit K wrote:
> From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> 
> We parse the EDID and add all the modes in the connector's
> modelist. This adds CEA modes with aspect ratio information
> too, regadless of if user space requested this information or
> not.
> 
> This patch prunes the modes with aspect-ratio information, from
> a connector's modelist, if the user-space has not set the aspect
> ratio DRM client cap.
> 
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> 
> V3: As suggested by Ville, modified the mechanism of pruning of
> modes with aspect-ratio, if the aspect-ratio is not supported.
> Instead of straight away pruning such a mode, the mode is
> retained with aspect-ratio bits set to zero, provided it is
> unique.
> ---
>  drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++----
>  1 file changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index b85a774..d968ec3 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1502,7 +1502,8 @@ static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *conne
>  	return connector->encoder;
>  }
>  
> -static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
> +static bool drm_mode_expose_to_userspace(const struct drm_display_mode *last_mode,
> +					 const struct drm_display_mode *mode,
>  					 const struct drm_file *file_priv)
>  {
>  	/*
> @@ -1511,6 +1512,18 @@ static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
>  	 */
>  	if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode))
>  		return false;
> +	/*
> +	 * If user-space hasn't configured the driver to expose the modes
> +	 * with aspect-ratio, don't expose them.
> +	 */
> +	if (!file_priv->aspect_ratio_allowed &&
> +	    mode->picture_aspect_ratio != HDMI_PICTURE_ASPECT_NONE &&
> +	    drm_mode_match(mode, last_mode,
> +			   DRM_MODE_MATCH_TIMINGS |
> +			   DRM_MODE_MATCH_CLOCK |
> +			   DRM_MODE_MATCH_FLAGS |
> +			   DRM_MODE_MATCH_3D_FLAGS))
> +		return false;
>  
>  	return true;
>  }
> @@ -1522,6 +1535,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  	struct drm_connector *connector;
>  	struct drm_encoder *encoder;
>  	struct drm_display_mode *mode;
> +	struct drm_display_mode last_valid_mode;

A pointer should be sufficient.

>  	int mode_count = 0;
>  	int encoders_count = 0;
>  	int ret = 0;
> @@ -1577,9 +1591,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  	out_resp->connection = connector->status;
>  
>  	/* delayed so we get modes regardless of pre-fill_modes state */
> +	memset(&last_valid_mode, 0, sizeof(struct drm_display_mode));
>  	list_for_each_entry(mode, &connector->modes, head)
> -		if (drm_mode_expose_to_userspace(mode, file_priv))
> +		if (drm_mode_expose_to_userspace(&last_valid_mode, mode, file_priv)) {
>  			mode_count++;
> +			drm_mode_copy(&last_valid_mode, mode);
> +		}
>  
>  	/*
>  	 * This ioctl is called twice, once to determine how much space is
> @@ -1588,10 +1605,16 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  	if ((out_resp->count_modes >= mode_count) && mode_count) {
>  		copied = 0;
>  		mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr;
> +		memset(&last_valid_mode, 0, sizeof(struct drm_display_mode));
>  		list_for_each_entry(mode, &connector->modes, head) {
> -			if (!drm_mode_expose_to_userspace(mode, file_priv))
> +			if (!drm_mode_expose_to_userspace(&last_valid_mode,
> +							  mode,
> +							  file_priv))
>  				continue;
> -
> +			if (!file_priv->aspect_ratio_allowed)
> +				mode->picture_aspect_ratio =
> +						HDMI_PICTURE_ASPECT_NONE;

Here you're clobbering the internal mode structure. That's not
acceptable.

> +			drm_mode_copy(&last_valid_mode, mode);
>  			drm_mode_convert_to_umode(&u_mode, mode);
>  			if (copy_to_user(mode_ptr + copied,
>  					 &u_mode, sizeof(u_mode))) {
> -- 
> 2.7.4

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

  reply	other threads:[~2018-01-29 18:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12  6:21 [PATCH v3 0/8] Aspect ratio support in DRM layer Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 1/8] drm/modes: Introduce drm_mode_match() Nautiyal, Ankit K
2018-01-17  8:41   ` Sharma, Shashank
2018-01-17 15:21     ` Ville Syrjälä
2018-01-18  6:10       ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 2/8] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Nautiyal, Ankit K
2018-01-17  8:53   ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 3/8] drm/edid: Fix cea mode aspect ratio handling Nautiyal, Ankit K
2018-01-17  9:05   ` Sharma, Shashank
2018-01-17 15:29     ` Ville Syrjälä
2018-01-18  6:14       ` Sharma, Shashank
2018-01-12  6:21 ` [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio Nautiyal, Ankit K
2018-01-17  9:11   ` Sharma, Shashank
2018-01-18 10:16   ` Maarten Lankhorst
2018-01-18 15:41     ` ankit.k.nautiyal
2018-01-18 16:04       ` Ville Syrjälä
2018-01-19  5:44         ` Nautiyal, Ankit K
2018-01-22  4:34     ` [PATCH v4 " Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths Nautiyal, Ankit K
2018-01-29 18:53   ` Ville Syrjälä
2018-01-31  6:34     ` Nautiyal, Ankit K
2018-01-31 13:09       ` Ville Syrjälä
2018-02-01 11:05         ` Nautiyal, Ankit K
2018-02-01 12:54           ` Ville Syrjälä
2018-02-08  4:29             ` Nautiyal, Ankit K
2018-02-13  4:51               ` Nautiyal, Ankit K
2018-02-13 13:18                 ` Ville Syrjälä
2018-02-13 16:23                   ` Nautiyal, Ankit K
2018-02-13 16:45                     ` Ville Syrjälä
2018-02-15 11:57                       ` Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 6/8] drm: Expose modes with aspect ratio, only if requested Nautiyal, Ankit K
2018-01-29 18:58   ` Ville Syrjälä [this message]
2018-01-31  8:00     ` Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 7/8] drm: Add aspect ratio parsing in DRM layer Nautiyal, Ankit K
2018-01-12  6:21 ` [PATCH v3 8/8] drm: Add and handle new aspect ratios " Nautiyal, Ankit K

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=20180129185824.GV5453@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jose.abreu@synopsys.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.