From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
Cc: intel-gfx@lists.freedesktop.org, ppaalanen@gmail.com,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v12 08/10] drm: Expose modes with aspect ratio, only if requested
Date: Fri, 27 Apr 2018 17:05:23 +0300 [thread overview]
Message-ID: <20180427140523.GX23723@intel.com> (raw)
In-Reply-To: <1524831296-11198-9-git-send-email-ankit.k.nautiyal@intel.com>
On Fri, Apr 27, 2018 at 05:44:54PM +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. However if such a mode is unique in the list, it is
> kept in the list, with aspect-ratio flags reset.
>
> 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).
> V6: As suggested by Ville, corrected the mode pruning logic and
> elaborated the mode pruning logic and the assumptions taken.
> V7: rebase
> V8: rebase
> V9: rebase
> V10: rebase
> V11: Fixed the issue caused in kms_3d test, and enhanced the pruning
> logic to correctly identify and prune modes with aspect-ratio,
> if aspect-ratio cap is not set.
> V12: As suggested by Ville, added another list_head in
> drm_mode_display to traverse the list of exposed modes and
> avoided duplication of modes.
> ---
> drivers/gpu/drm/drm_connector.c | 52 ++++++++++++++++++++++++++++++++++-------
> include/drm/drm_modes.h | 9 +++++++
> 2 files changed, 53 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index b3cde89..e12964b 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1531,15 +1531,35 @@ 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 *mode,
> + const struct list_head *modelist,
> + const struct drm_file *file_priv)
> {
> /*
> * If user-space hasn't configured the driver to expose the stereo 3D
> * modes, don't expose them.
> */
> + struct drm_display_mode *mode_itr;
> +
This is clearly misplaced. It should be before the comment. Hmm,
atually better move it into the aspect ratio if block since it's
not needed elsewhere.
> 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. However if such a mode
> + * is unique, let it be exposed, but reset the aspect-ratio flags
> + * while preparing the list of user-modes.
> + */
> + if (!file_priv->aspect_ratio_allowed &&
> + mode->picture_aspect_ratio != HDMI_PICTURE_ASPECT_NONE) {
> + list_for_each_entry(mode_itr, modelist, exp_head)
> + if (drm_mode_match(mode_itr, mode,
> + DRM_MODE_MATCH_TIMINGS |
> + DRM_MODE_MATCH_CLOCK |
> + DRM_MODE_MATCH_FLAGS |
> + DRM_MODE_MATCH_3D_FLAGS))
> + return false;
> + }
>
> return true;
> }
> @@ -1550,7 +1570,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
> struct drm_mode_get_connector *out_resp = data;
> struct drm_connector *connector;
> struct drm_encoder *encoder;
> - struct drm_display_mode *mode;
> + struct drm_display_mode *mode, *tmp;
> + struct list_head modelist;
LIST_HEAD_INIT(modelist);
And maybe call it export_list or something like that.
> int mode_count = 0;
> int encoders_count = 0;
> int ret = 0;
> @@ -1605,23 +1626,34 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
> out_resp->subpixel = connector->display_info.subpixel_order;
> out_resp->connection = connector->status;
>
> + INIT_LIST_HEAD(&modelist);
> +
> /* delayed so we get modes regardless of pre-fill_modes state */
> list_for_each_entry(mode, &connector->modes, head)
> - if (drm_mode_expose_to_userspace(mode, file_priv))
> + if (drm_mode_expose_to_userspace(mode, &modelist,
> + file_priv)) {
> + list_add_tail(&mode->exp_head, &modelist);
> mode_count++;
> + }
>
> /*
> * This ioctl is called twice, once to determine how much space is
> * needed, and the 2nd time to fill it.
> + * The modes that need to be exposed to the user are maintained in the
> + * 'modelist'. When the ioctl is called first time to determine the,
> + * space, the modelist gets filled, to find the no. of modes. In the
> + * 2nd time, the user modes are filled, one by one from the modelist.
> */
> if ((out_resp->count_modes >= mode_count) && mode_count) {
> copied = 0;
> mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr;
> - list_for_each_entry(mode, &connector->modes, head) {
> - if (!drm_mode_expose_to_userspace(mode, file_priv))
> - continue;
> -
> + list_for_each_entry(mode, &modelist, exp_head) {
> drm_mode_convert_to_umode(&u_mode, mode);
> + /*
> + * Reset aspect ratio flags of user-mode, if modes with
> + * aspect-ratio are not supported.
> + */
> + drm_mode_filter_aspect_ratio_flags(file_priv, &u_mode);
> if (copy_to_user(mode_ptr + copied,
> &u_mode, sizeof(u_mode))) {
> ret = -EFAULT;
> @@ -1651,6 +1683,10 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
> drm_modeset_unlock(&dev->mode_config.connection_mutex);
>
> out:
> + list_for_each_entry_safe(mode, tmp, &modelist, exp_head)
> + list_del(&mode->exp_head);
> + list_del(&modelist);
That last list_del() doesn't make sense. Also you can't touch the
mode->exp_head without locking. We should document that it's
protected by mode_config.mutex.
Since we don't actually care about exp_head outside of this function
I think we can just leave the stale pointers in place. No one else is
supposed to look at them, a fact we should probaly also include in the
documentation.
> +
> drm_connector_put(connector);
>
> return ret;
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index e0b060d..1888ec7 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -411,6 +411,15 @@ struct drm_display_mode {
> * Field for setting the HDMI picture aspect ratio of a mode.
> */
> enum hdmi_picture_aspect picture_aspect_ratio;
> +
> + /**
> + * @exp_head:
I think we can afford to write 'export_head'.
> + *
> + * struct list_head for modes to be exposed to the userspace.
> + *
> + */
> + struct list_head exp_head;
> +
> };
>
> /**
> --
> 2.7.4
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-04-27 14:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-27 12:14 [PATCH v12 00/10] Aspect ratio support in DRM layer Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 01/10] drm/modes: Introduce drm_mode_match() Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 02/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 03/10] drm/edid: Fix cea mode aspect ratio handling Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 04/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 05/10] video/hdmi: Reject illegal picture aspect ratios Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 06/10] drm: Add DRM client cap for aspect-ratio Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 07/10] drm: Handle aspect ratio info in legacy modeset path Nautiyal, Ankit K
2018-04-27 13:54 ` Ville Syrjälä
2018-04-30 6:21 ` Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 08/10] drm: Expose modes with aspect ratio, only if requested Nautiyal, Ankit K
2018-04-27 14:05 ` Ville Syrjälä [this message]
2018-04-30 6:52 ` Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 09/10] drm: Add aspect ratio parsing in DRM layer Nautiyal, Ankit K
2018-04-27 12:14 ` [PATCH v12 10/10] drm: Add and handle new aspect ratios " Nautiyal, Ankit K
2018-04-27 12:44 ` ✗ Fi.CI.CHECKPATCH: warning for Aspect ratio support " Patchwork
2018-04-27 12:59 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-04-27 13:28 ` ✗ Fi.CI.CHECKPATCH: warning " Patchwork
2018-04-27 13:47 ` ✓ Fi.CI.BAT: success " Patchwork
2018-04-27 17:13 ` ✓ Fi.CI.IGT: " Patchwork
2018-04-27 17:55 ` ✗ Fi.CI.IGT: failure " 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=20180427140523.GX23723@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ppaalanen@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox