All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v13 07/10] drm: Handle aspect ratio info in legacy modeset path
Date: Wed, 2 May 2018 09:56:56 +0200	[thread overview]
Message-ID: <20180502075656.GY12521@phenom.ffwll.local> (raw)
In-Reply-To: <1525243822-19308-8-git-send-email-ankit.k.nautiyal@intel.com>

On Wed, May 02, 2018 at 12:20:19PM +0530, Nautiyal, Ankit K wrote:
> From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> 
> If the user-space does not support aspect-ratio, and requests for a
> modeset with mode having aspect ratio bits set, then the given
> user-mode must be rejected. Secondly, while preparing a user-mode from
> kernel mode, the aspect-ratio info must not be given, if aspect-ratio
> is not supported by the user.
> 
> This patch:
> 1. rejects the modes with aspect-ratio info, during modeset, if the
>    user does not support aspect ratio.
> 2. does not load the aspect-ratio info in user-mode structure, if
>    aspect ratio is not supported.
> 3. adds helper functions for determining if aspect-ratio is expected
>    in user-mode and for allowing/disallowing the aspect-ratio, if its
>    not expected.
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> 
> V3: Addressed review comments from Ville:
>     Do not corrupt the current crtc state by updating aspect-ratio on
>     the fly.
> V4: rebase
> V5: As suggested by Ville, rejected the modeset calls for modes with
>     aspect ratio, if the user does not set aspect-ratio cap.
> V6: Used the helper functions for determining if aspect-ratio is
>     expected in the user-mode.
> V7: rebase
> V8: rebase
> V9: rebase
> V10: Modified the commit-message
> V11: rebase
> V12: Merged the patch for adding aspect-ratio helper functions
>      with this patch.
> V13: Minor modifications as suggested by Ville.
> ---
>  drivers/gpu/drm/drm_crtc.c          |  8 +++++++
>  drivers/gpu/drm/drm_crtc_internal.h |  6 +++++
>  drivers/gpu/drm/drm_modes.c         | 47 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 61 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index a231dd5..98323f4 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -449,6 +449,7 @@ int drm_mode_getcrtc(struct drm_device *dev,
>  			crtc_resp->mode_valid = 0;
>  		}
>  	}
> +	drm_mode_filter_aspect_ratio_flags(file_priv, &crtc_resp->mode);
>  	drm_modeset_unlock(&crtc->mutex);
>  
>  	return 0;
> @@ -628,6 +629,13 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>  			ret = -ENOMEM;
>  			goto out;
>  		}
> +		if (!drm_mode_aspect_ratio_allowed(file_priv,
> +						   &crtc_req->mode)) {
> +			DRM_DEBUG_KMS("Unexpected aspect-ratio flag bits\n");
> +			ret = -EINVAL;
> +			goto out;
> +		}
> +
>  
>  		ret = drm_mode_convert_umode(dev, mode, &crtc_req->mode);
>  		if (ret) {
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index 5d307b2..31d6c77 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -222,3 +222,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>  void drm_mode_fixup_1366x768(struct drm_display_mode *mode);
>  void drm_reset_display_info(struct drm_connector *connector);
>  u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid);
> +
> +/* drm_modes.c */
> +bool drm_mode_aspect_ratio_allowed(const struct drm_file *file_priv,
> +				   struct drm_mode_modeinfo *umode);
> +void drm_mode_filter_aspect_ratio_flags(const struct drm_file *file_priv,
> +					struct drm_mode_modeinfo *umode);
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index c395a24..2bf2f0b 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1759,3 +1759,50 @@ bool drm_mode_is_420(const struct drm_display_info *display,
>  		drm_mode_is_420_also(display, mode);
>  }
>  EXPORT_SYMBOL(drm_mode_is_420);
> +
> +/**
> + * drm_mode_aspect_ratio_allowed - checks if the aspect-ratio information
> + * is expected from the user-mode.
> + *
> + * If the user has set aspect-ratio cap, then the flag of the user-mode is
> + * allowed to contain aspect-ratio value.
> + * If the user does not set aspect-ratio cap, then the only value allowed in the
> + * flags bits is aspect-ratio NONE.
> + *
> + * @file_priv: file private structure to get the user capabilities
> + * @umode: drm_mode_modeinfo struct, whose flag carry the aspect ratio
> + * information.
> + *
> + * Returns:
> + * true if the aspect-ratio info is allowed in the user-mode flags.
> + * false, otherwise.
> + */

We generally don't do full kerneldoc for drm.ko internal functions (which
these both are), only for driver functions. I'd remove them both because
they don't add a hole lot really.

> +bool
> +drm_mode_aspect_ratio_allowed(const struct drm_file *file_priv,
> +			      struct drm_mode_modeinfo *umode)

I don't really see the point of this helper. It has a bit a confusing
name, and open-code it looks simpler to me in setcrtc.

> +{
> +	if (file_priv->aspect_ratio_allowed ||
> +	    (umode->flags & DRM_MODE_FLAG_PIC_AR_MASK) == DRM_MODE_FLAG_PIC_AR_NONE)
> +		return true;
> +	return false;
> +}
> +
> +/**
> + * drm_mode_filter_aspect_ratio_flags - filters the aspect-ratio bits in the
> + * user-mode flags.
> + *
> + * Checks if the aspect-ratio information is allowed. Resets the aspect-ratio
> + * bits in the user-mode flags, if aspect-ratio info is not allowed.
> + *
> + * @file_priv: file private structure to get the user capabilities.
> + * @umode: drm_mode_modeinfo struct, whose flags' aspect-ratio bits needs to
> + * be filtered.
> + *
> + */
> +void
> +drm_mode_filter_aspect_ratio_flags(const struct drm_file *file_priv,
> +				   struct drm_mode_modeinfo *umode)
> +{
> +	if (!drm_mode_aspect_ratio_allowed(file_priv, umode))

You only need to check for file_priv->aspect_ratio_allowed here, then
clear unconditionally.
-Daniel

> +		umode->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
> +}
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-05-02  7:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02  6:50 [PATCH v13 00/10] Aspect ratio support in DRM layer Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 01/10] drm/modes: Introduce drm_mode_match() Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 02/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 03/10] drm/edid: Fix cea mode aspect ratio handling Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 04/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 05/10] video/hdmi: Reject illegal picture aspect ratios Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 06/10] drm: Add DRM client cap for aspect-ratio Nautiyal, Ankit K
2018-05-02  7:52   ` [Intel-gfx] " Daniel Vetter
2018-05-02  6:50 ` [PATCH v13 07/10] drm: Handle aspect ratio info in legacy modeset path Nautiyal, Ankit K
2018-05-02  7:56   ` Daniel Vetter [this message]
2018-05-02  6:50 ` [PATCH v13 08/10] drm: Expose modes with aspect ratio, only if requested Nautiyal, Ankit K
2018-05-03  6:26   ` Daniel Vetter
2018-05-04 20:19     ` Ville Syrjälä
2018-05-07  5:04       ` Nautiyal, Ankit K
2018-05-07 12:28         ` Ville Syrjälä
2018-05-07 12:52           ` Nautiyal, Ankit K
2018-05-07 13:36       ` Daniel Vetter
2018-05-02  6:50 ` [PATCH v13 09/10] drm: Add aspect ratio parsing in DRM layer Nautiyal, Ankit K
2018-05-02  6:50 ` [PATCH v13 10/10] drm: Add and handle new aspect ratios " Nautiyal, Ankit K
2018-05-02 10:00 ` ✗ Fi.CI.CHECKPATCH: warning for Aspect ratio support " Patchwork
2018-05-02 10:15 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-02 12:44 ` ✓ Fi.CI.IGT: " Patchwork

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=20180502075656.GY12521@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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 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.