From: Sean Paul <sean@poorly.run>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
wei.c.li@intel.com, harish.krupo.kps@intel.com,
Sean Paul <sean@poorly.run>
Subject: Re: [PATCH v2 2/3] drm: Add CRTC background color property (v2)
Date: Wed, 14 Nov 2018 11:17:25 -0500 [thread overview]
Message-ID: <20181114161725.GQ154160@art_vandelay> (raw)
In-Reply-To: <20181113232149.22753-3-matthew.d.roper@intel.com>
On Tue, Nov 13, 2018 at 03:21:48PM -0800, Matt Roper wrote:
> Some display controllers can be programmed to present non-black colors
> for pixels not covered by any plane (or pixels covered by the
> transparent regions of higher planes). Compositors that want a UI with
> a solid color background can potentially save memory bandwidth by
> setting the CRTC background property and using smaller planes to display
> the rest of the content.
>
> To avoid confusion between different ways of encoding RGB data, we
> define a standard 64-bit format that should be used for this property's
> value. Helper functions and macros are provided to generate and dissect
> values in this standard format with varying component precision values.
>
> v2:
> - Swap internal representation's blue and red bits to make it easier
> to read if printed out. (Ville)
> - Document bgcolor property in drm_blend.c. (Sean Paul)
> - s/background_color/bgcolor/ for consistency between property name and
> value storage field. (Sean Paul)
> - Add a convenience function to attach property to a given crtc.
>
> Cc: dri-devel@lists.freedesktop.org
> Cc: wei.c.li@intel.com
> Cc: harish.krupo.kps@intel.com
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Sean Paul <sean@poorly.run>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
> drivers/gpu/drm/drm_atomic_state_helper.c | 1 +
> drivers/gpu/drm/drm_atomic_uapi.c | 5 +++++
> drivers/gpu/drm/drm_blend.c | 21 ++++++++++++++++++---
> drivers/gpu/drm/drm_mode_config.c | 6 ++++++
> include/drm/drm_blend.h | 1 +
> include/drm/drm_crtc.h | 17 +++++++++++++++++
> include/drm/drm_mode_config.h | 5 +++++
> include/uapi/drm/drm_mode.h | 26 ++++++++++++++++++++++++++
> 8 files changed, 79 insertions(+), 3 deletions(-)
/snip
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index d3e0fe31efc5..7c4f902aa290 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -888,6 +888,32 @@ struct drm_mode_revoke_lease {
> __u32 lessee_id;
> };
>
> +/*
> + * Put RGBA values into a standard 64-bit representation that can be used
> + * for ioctl parameters, inter-driver commmunication, etc. If the component
> + * values being provided contain less than 16 bits of precision, they'll
> + * be shifted into the most significant bits.
> + */
> +static inline __u64
> +drm_rgba(__u8 bpc, __u16 red, __u16 green, __u16 blue, __u16 alpha)
> +{
> + int msb_shift = 16 - bpc;
> +
> + return (__u64)alpha << msb_shift << 48 |
> + (__u64)red << msb_shift << 32 |
> + (__u64)green << msb_shift << 16 |
> + (__u64)blue << msb_shift;
> +}
> +
> +/*
> + * Extract the specified number of bits of a specific color component from a
> + * standard 64-bit RGBA value.
> + */
> +#define DRM_RGBA_BLUE(c, numbits) (__u16)((c & 0xFFFFull) >> (16-numbits))
> +#define DRM_RGBA_GREEN(c, numbits) (__u16)((c & 0xFFFFull<<16) >> (32-numbits))
> +#define DRM_RGBA_RED(c, numbits) (__u16)((c & 0xFFFFull<<32) >> (48-numbits))
> +#define DRM_RGBA_ALPHA(c, numbits) (__u16)((c & 0xFFFFull<<48) >> (64-numbits))
#define DRM_RGBA_COMP(c, shift, numbits) \
(__u16)(((c) & 0xFFFFull << (shift)) >> (32 - ((shift) + 16 - (numbits)))
#define DRM_RGBA_BLUE(c, numbits) DRM_RGBA_COMP(c, 0, numbits)
#define DRM_RGBA_GREEN(c, numbits) DRM_RGBA_COMP(c, 16, numbits)
#define DRM_RGBA_RED(c, numbits) DRM_RGBA_COMP(c, 32, numbits)
#define DRM_RGBA_ALPHA(c, numbits) DRM_RGBA_COMP(c, 48, numbits)
With that,
Reviewed-by: Sean Paul <sean@poorly.run>
> +
> #if defined(__cplusplus)
> }
> #endif
> --
> 2.14.4
>
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-11-14 16:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 23:21 [PATCH v2 0/3] CRTC background color Matt Roper
2018-11-13 23:21 ` [PATCH v2 2/3] drm: Add CRTC background color property (v2) Matt Roper
2018-11-14 16:17 ` Sean Paul [this message]
2018-11-15 0:27 ` Matt Roper
2018-11-14 17:20 ` Ville Syrjälä
2018-11-14 17:29 ` Matt Roper
2018-11-13 23:21 ` [PATCH v2 3/3] drm/i915/gen9+: Add support for pipe background color (v2) Matt Roper
2018-11-14 18:05 ` Ville Syrjälä
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=20181114161725.GQ154160@art_vandelay \
--to=sean@poorly.run \
--cc=dri-devel@lists.freedesktop.org \
--cc=harish.krupo.kps@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.d.roper@intel.com \
--cc=wei.c.li@intel.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