From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
laurent.pinchart@ideasonboard.com
Subject: Re: [RFC v3 07/12] drm/modes: Add drm_umode_equal()
Date: Tue, 6 Mar 2018 09:42:51 +0100 [thread overview]
Message-ID: <20180306084251.GF22212@phenom.ffwll.local> (raw)
In-Reply-To: <20180222200653.19453-8-noralf@tronnes.org>
On Thu, Feb 22, 2018 at 09:06:48PM +0100, Noralf Trønnes wrote:
> Add a way to check if userspace modes are equal. Useful for in-kernel
> clients. Also export drm_mode_convert_umode().
>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Assuming we don't use the KMS ioctls for in-kernel clients I guess we
don't need this here either?
-Daniel
> ---
> drivers/gpu/drm/drm_modes.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
> include/drm/drm_modes.h | 2 ++
> 2 files changed, 52 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 5a8033fda4e3..0e39164f15aa 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1631,6 +1631,56 @@ int drm_mode_convert_umode(struct drm_device *dev,
> out:
> return ret;
> }
> +EXPORT_SYMBOL(drm_mode_convert_umode);
> +
> +/**
> + * drm_umode_equal - test modeinfo modes for equality
> + * @mode1: first mode
> + * @mode2: second mode
> + *
> + * Check to see if @mode1 and @mode2 are equivalent.
> + *
> + * Returns:
> + * True if the modes are equal, false otherwise.
> + */
> +bool drm_umode_equal(const struct drm_mode_modeinfo *mode1,
> + const struct drm_mode_modeinfo *mode2)
> +{
> + if (!mode1 && !mode2)
> + return true;
> +
> + if (!mode1 || !mode2)
> + return false;
> +
> + /* do clock check convert to PICOS so fb modes get matched the same */
> + if (mode1->clock && mode2->clock) {
> + if (KHZ2PICOS(mode1->clock) != KHZ2PICOS(mode2->clock))
> + return false;
> + } else if (mode1->clock != mode2->clock) {
> + return false;
> + }
> +
> + if ((mode1->flags & DRM_MODE_FLAG_3D_MASK) !=
> + (mode2->flags & DRM_MODE_FLAG_3D_MASK))
> + return false;
> +
> + if (mode1->hdisplay == mode2->hdisplay &&
> + mode1->hsync_start == mode2->hsync_start &&
> + mode1->hsync_end == mode2->hsync_end &&
> + mode1->htotal == mode2->htotal &&
> + mode1->hskew == mode2->hskew &&
> + mode1->vdisplay == mode2->vdisplay &&
> + mode1->vsync_start == mode2->vsync_start &&
> + mode1->vsync_end == mode2->vsync_end &&
> + mode1->vtotal == mode2->vtotal &&
> + mode1->vscan == mode2->vscan &&
> + (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
> + (mode2->flags & ~DRM_MODE_FLAG_3D_MASK))
> + return true;
> +
> + return false;
> +}
> +EXPORT_SYMBOL(drm_umode_equal);
>
> /**
> * drm_mode_is_420_only - if a given videomode can be only supported in YCBCR420
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 0d310beae6af..05e73ca4f2ae 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -447,6 +447,8 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
> int drm_mode_convert_umode(struct drm_device *dev,
> struct drm_display_mode *out,
> const struct drm_mode_modeinfo *in);
> +bool drm_umode_equal(const struct drm_mode_modeinfo *mode1,
> + const struct drm_mode_modeinfo *mode2);
> void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
> void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
> bool drm_mode_is_420_only(const struct drm_display_info *display,
> --
> 2.15.1
>
--
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
next prev parent reply other threads:[~2018-03-06 8:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 20:06 [RFC v3 00/12] drm: Add generic fbdev emulation Noralf Trønnes
2018-02-22 20:06 ` [RFC v3 01/12] drm: provide management functions for drm_file Noralf Trønnes
2018-02-22 20:06 ` [RFC v3 02/12] drm/file: Don't set master on in-kernel clients Noralf Trønnes
2018-03-06 8:28 ` Daniel Vetter
2018-02-22 20:06 ` [RFC v3 03/12] drm: Make ioctls available for in-kernel clients part 1 Noralf Trønnes
2018-02-22 20:06 ` [RFC v3 04/12] drm: Make ioctls available for in-kernel clients part 2 Noralf Trønnes
2018-03-06 8:41 ` Daniel Vetter
2018-02-22 20:06 ` [RFC v3 05/12] drm: Add _ioctl suffix to some functions Noralf Trønnes
2018-02-22 20:06 ` [RFC v3 06/12] drm: Add DRM device iterator Noralf Trønnes
2018-02-22 20:06 ` [RFC v3 07/12] drm/modes: Add drm_umode_equal() Noralf Trønnes
2018-03-06 8:42 ` Daniel Vetter [this message]
2018-02-22 20:06 ` [RFC v3 08/12] drm/framebuffer: Add drm_mode_can_dirtyfb() Noralf Trønnes
2018-03-06 8:45 ` Daniel Vetter
2018-02-22 20:06 ` [RFC v3 09/12] drm: Add API for in-kernel clients Noralf Trønnes
2018-03-06 8:56 ` Daniel Vetter
2018-03-08 17:12 ` Noralf Trønnes
2018-03-12 16:51 ` Daniel Vetter
2018-03-12 20:21 ` Noralf Trønnes
2018-03-13 15:11 ` Daniel Vetter
2018-02-22 20:06 ` [RFC v3 10/12] drm/client: Add fbdev emulation client Noralf Trønnes
2018-03-06 9:06 ` Daniel Vetter
2018-02-22 20:06 ` [RFC v3 11/12] drm/client: Add bootsplash client Noralf Trønnes
2018-03-06 9:12 ` Daniel Vetter
2018-03-06 15:21 ` Max Staudt
2018-02-22 20:06 ` [RFC v3 12/12] drm/client: Add VT console client Noralf Trønnes
2018-02-22 21:03 ` ✗ Fi.CI.BAT: failure for drm: Add generic fbdev emulation (rev3) 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=20180306084251.GF22212@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=noralf@tronnes.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