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 v5 7/9] drm: Expose modes with aspect ratio, only if requested
Date: Fri, 23 Feb 2018 16:36:47 +0200	[thread overview]
Message-ID: <20180223143647.GM5453@intel.com> (raw)
In-Reply-To: <1518697262-3001-8-git-send-email-ankit.k.nautiyal@intel.com>

On Thu, Feb 15, 2018 at 05:51:00PM +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
> whether 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.
> V4: rebase
> V5: Addressed review comments from Ville:
>     -used a pointer to store last valid mode.
>     -avoided, modifying of picture_aspect_ratio in kernel mode,
>      instead only flags bits of user mode are reset (if aspect-ratio
>      is not supported).
> ---
>  drivers/gpu/drm/drm_connector.c | 45 ++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 16b9c38..49778e8 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1507,8 +1507,10 @@ 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,
> -					 const struct drm_file *file_priv)
> +static bool
> +drm_mode_expose_to_userspace(const struct drm_display_mode *last_mode,
> +			     const struct drm_display_mode *mode,

I would put the 'mode' argument first since that's the "main" object
we're operating on.

> +			     const struct drm_file *file_priv)
>  {
>  	/*
>  	 * If user-space hasn't configured the driver to expose the stereo 3D
> @@ -1516,6 +1518,23 @@ 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. But in case of a unique
> +	 * mode, let the mode be passed, so that it can be enumerated with
> +	 * aspect ratio bits erased.

Might want to note that we expect the list to be sorted such that modes
that have different aspect ratio but are otherwise identical are back to
back.

> +	 */
> +	if (!file_priv->aspect_ratio_allowed &&
> +	    mode->picture_aspect_ratio != HDMI_PICTURE_ASPECT_NONE) {
> +		if (last_mode && !drm_mode_match(mode, last_mode,
> +						 DRM_MODE_MATCH_TIMINGS |
> +						 DRM_MODE_MATCH_CLOCK |
> +						 DRM_MODE_MATCH_FLAGS |
> +						 DRM_MODE_MATCH_3D_FLAGS))
> +			return true;
> +		else
> +			return false;

How does that even work? It'll return false as long as
last_mode==NULL, and last_mode never becomes non-NULL unless
we return true.

To me it looks like the correct logic would be:
if (last_mode && drm_mode_match(...))
	return false;

> +	}
>  
>  	return true;
>  }
> @@ -1527,6 +1546,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;
>  	int mode_count = 0;
>  	int encoders_count = 0;
>  	int ret = 0;
> @@ -1582,9 +1602,13 @@ 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 */
> +	last_valid_mode = NULL;
>  	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++;
> +			last_valid_mode = mode;
> +		}
>  
>  	/*
>  	 * This ioctl is called twice, once to determine how much space is
> @@ -1593,11 +1617,21 @@ 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;
> +		last_valid_mode = NULL;
>  		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;
> -
>  			drm_mode_convert_to_umode(&u_mode, mode);
> +
> +			/*
> +			 * Reset the aspect-ratio flag bits from the user mode,
> +			 * if the user mode does have aspect ratio capability.
> +			 */
> +			if (!file_priv->aspect_ratio_allowed)
> +				u_mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK);

Useless parens. Could use the same helper I suggested we add for
getcrtc() and getblob().

> +
>  			if (copy_to_user(mode_ptr + copied,
>  					 &u_mode, sizeof(u_mode))) {
>  				ret = -EFAULT;
> @@ -1605,6 +1639,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  
>  				goto out;
>  			}
> +			last_valid_mode = mode;
>  			copied++;
>  		}
>  	}
> -- 
> 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-02-23 14:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 12:20 [PATCH v5 0/9] Aspect ratio support in DRM layer Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 1/9] drm/modes: Introduce drm_mode_match() Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 2/9] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 3/9] drm/edid: Fix cea mode aspect ratio handling Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 4/9] drm: Add DRM client cap for aspect-ratio Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 5/9] drm: Handle aspect-ratio info in getblob Nautiyal, Ankit K
2018-02-23 14:22   ` Ville Syrjälä
2018-02-26 15:02     ` Nautiyal, Ankit K
2018-02-15 12:20 ` [PATCH v5 6/9] drm: Handle aspect ratio info in legacy and atomic modeset paths Nautiyal, Ankit K
2018-02-23 14:28   ` Ville Syrjälä
2018-02-26 15:10     ` Nautiyal, Ankit K
2018-02-15 12:21 ` [PATCH v5 7/9] drm: Expose modes with aspect ratio, only if requested Nautiyal, Ankit K
2018-02-23 14:36   ` Ville Syrjälä [this message]
2018-02-26 15:30     ` Nautiyal, Ankit K
2018-02-15 12:21 ` [PATCH v5 8/9] drm: Add aspect ratio parsing in DRM layer Nautiyal, Ankit K
2018-02-23 14:54   ` Ville Syrjälä
2018-02-26 15:48     ` Nautiyal, Ankit K
2018-02-26 15:57       ` Ville Syrjälä
2018-02-15 12:21 ` [PATCH v5 9/9] 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=20180223143647.GM5453@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.