public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: Vandita Kulkarni <vandita.kulkarni@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/9] drm: Introduce DRM_MODE_COLOR()
Date: Wed, 20 Jan 2016 16:22:25 -0800	[thread overview]
Message-ID: <20160121002225.GI10214@intel.com> (raw)
In-Reply-To: <1453130143-7228-4-git-send-email-vandita.kulkarni@intel.com>

On Mon, Jan 18, 2016 at 08:45:37PM +0530, Vandita Kulkarni wrote:
> From: Damien Lespiau <damien.lespiau@intel.com>
> 
> In the hope of expressing colors in the KMS API in a consitant want,
> let's introduce a ARGB 16161616 color and a few convinience macros
> around it.
> 
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>

This is somewhat similar to some of the background color prep work I did
here:

        http://patchwork.freedesktop.org/patch/62679/

I purposely wrapped the value into a struct to prevent drivers from
trying to do their own bitwise operations on color values without using
the provided helpers (which could easily lead to bugs if they mistakenly
forget that the color values aren't in their preferred format already).

Since you're going on to make properties that take values in this
format, the drm_property_create_rgba() and such that I have in that
patch (and the corresponding libdrm helpers that are also on the mailing
list) might be useful here as well.


Matt

> ---
>  drivers/gpu/drm/i915/intel_sprite.c |  1 -
>  include/uapi/drm/drm_mode.h         | 34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index b7acfdf..9538658 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -210,7 +210,6 @@ skl_update_plane(struct drm_plane *drm_plane,
>  		PLANE_CTL_PIPE_GAMMA_ENABLE |
>  		PLANE_CTL_PIPE_CSC_ENABLE;
>  
> -	plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
>  	plane_ctl |= skl_plane_ctl_format(fb->pixel_format,
>  					plane_state->premultiplied_alpha,
>  					plane_state->drop_alpha);

This hunk should be squashed into the previous patch.


> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 50adb46..12687bc 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -295,6 +295,40 @@ struct drm_mode_get_connector {
>   */
>  #define DRM_MODE_PROP_ATOMIC        0x80000000
>  
> +/* Color for the KMS API, ARGB (msb -> lsb) 16bits per component. */
> +#define DRM_MODE_COLOR(a, r, b, g)	\
> +	(((__u64)(a) << 48) | ((__u64)(r) << 32) | \
> +	 ((__u64)(g) << 16) | (__u64)(b))
> +
> +/* Extract full precision, 8 bits, 10 bits and 12 bits components. */
> +#define DRM_MODE_COLOR_ALPHA(color)	(((color) >> 48) & 0xffff)
> +#define DRM_MODE_COLOR_RED(color)	(((color) >> 32) & 0xffff)
> +#define DRM_MODE_COLOR_BLUE(color)	(((color) >> 16) & 0xffff)
> +#define DRM_MODE_COLOR_GREEN(color)	((color) & 0xffff)
> +#define DRM_MODE_COLOR_ALPHA_8(color)	(((color) >> (48 + 8)) & 0xff)
> +#define DRM_MODE_COLOR_RED_8(color)	(((color) >> (32 + 8)) & 0xff)
> +#define DRM_MODE_COLOR_BLUE_8(color)	(((color) >> (16 + 8)) & 0xff)
> +#define DRM_MODE_COLOR_GREEN_8(color)	(((color) >>  8) & 0xff)
> +#define DRM_MODE_COLOR_ALPHA_10(color)	(((color) >> (48 + 6)) & 0x3ff)
> +#define DRM_MODE_COLOR_RED_10(color)	(((color) >> (32 + 6)) & 0x3ff)
> +#define DRM_MODE_COLOR_BLUE_10(color)	(((color) >> (16 + 6)) & 0x3ff)
> +#define DRM_MODE_COLOR_GREEN_10(color)	(((color) >>  6) & 0x3ff)
> +#define DRM_MODE_COLOR_ALPHA_12(color)	(((color) >> (48 + 4)) & 0xfff)
> +#define DRM_MODE_COLOR_RED_12(color)	(((color) >> (32 + 4)) & 0xfff)
> +#define DRM_MODE_COLOR_BLUE_12(color)	(((color) >> (16 + 4)) & 0xfff)
> +#define DRM_MODE_COLOR_GREEN_12(color)	(((color) >>  4) & 0xfff)
> +
> +/* Handy macros to convert a DRM_MODE_COLOR() into common precisions */
> +#define DRM_MODE_COLOR_TO_ARGB_8888(color)	 \
> +	((DRM_MODE_COLOR_ALPHA_8(color) << 24) | \
> +	 (DRM_MODE_COLOR_RED_8(color)   << 16) | \
> +	 (DRM_MODE_COLOR_GREEN_8(color) << 8)  | \
> +	 DRM_MODE_COLOR_BLUE_8(color))
> +#define DRM_MODE_COLOR_TO_RGB_101010(color)	  \
> +	 ((DRM_MODE_COLOR_RED_10(color)  << 20) | \
> +	 (DRM_MODE_COLOR_GREEN_10(color) << 10) | \
> +	 DRM_MODE_COLOR_BLUE_10(color))
> +
>  struct drm_mode_property_enum {
>  	__u64 value;
>  	char name[DRM_PROP_NAME_LEN];
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-01-21  0:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 15:15 [PATCH 0/9] Support blending modes of display planes Vandita Kulkarni
2016-01-18  8:01 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-01-18 15:15 ` [PATCH 1/9] drm: Introduce the blend-func property Vandita Kulkarni
2016-01-21  0:12   ` Matt Roper
2016-01-18 15:15 ` [PATCH 2/9] drm/i915/skl: Add blend_func to SKL/BXT sprite planes Vandita Kulkarni
2016-01-21  0:13   ` Matt Roper
2016-01-18 15:15 ` [PATCH 3/9] drm: Introduce DRM_MODE_COLOR() Vandita Kulkarni
2016-01-21  0:22   ` Matt Roper [this message]
2016-01-18 15:15 ` [PATCH 4/9] drm: Add an blend_color property Vandita Kulkarni
2016-01-21  0:29   ` Matt Roper
2016-01-18 15:15 ` [PATCH 5/9] drm/i915/skl: Add support for blending modes Vandita Kulkarni
2016-01-21 22:33   ` Matt Roper
2016-01-18 15:15 ` [PATCH 6/9] drm/i915/skl: Drop alpha in non ARGB formats Vandita Kulkarni
2016-01-18 15:15 ` [PATCH 7/9] drm/i915: Support blend func on primary Vandita Kulkarni
2016-01-18 15:15 ` [PATCH 8/9] drm/i915/skl: Support blend color " Vandita Kulkarni
2016-01-18 15:15 ` [PATCH 9/9] drm/i915/skl: Separate out disable plane alpha Vandita Kulkarni
2016-01-22  0:31 ` [PATCH 0/9] Support blending modes of display planes Matt Roper
2016-01-25 16:19   ` Daniel Vetter
2016-04-26  9:32     ` [PATCHv2 0/5] " Vandita Kulkarni
2016-04-26  9:33       ` [PATCHv2 1/5] drm: Introduce the blend-func property Vandita Kulkarni
2016-04-26 12:46         ` Daniel Vetter
2016-04-27  8:17           ` Jani Nikula
2016-04-26 12:47         ` Daniel Vetter
2016-04-26  9:33       ` [PATCHv2 2/5] drm/i915/skl: Add blend_func to SKL/BXT sprite planes Vandita Kulkarni
2016-04-26  9:33       ` [PATCHv2 3/5] drm: Introduce DRM_MODE_COLOR() Vandita Kulkarni
2016-04-26  9:33       ` [PATCHv2 4/5] drm: Add an blend_color property Vandita Kulkarni
2016-04-26  9:33       ` [PATCHv2 5/5] drm/i915/skl: Add support for blending modes Vandita Kulkarni
2016-04-26 12:46       ` [PATCHv2 0/5] Support blending modes of display planes Daniel Vetter
2016-04-26 13:53     ` ✗ Fi.CI.BAT: warning for series starting with [PATCHv2,1/5] drm: Introduce the blend-func property 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=20160121002225.GI10214@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=vandita.kulkarni@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