All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
@ 2014-02-19 10:08 sagar.a.kamble
  2014-02-24 15:44 ` Sagar Arun Kamble
  2014-02-25 18:18 ` Ville Syrjälä
  0 siblings, 2 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-02-19 10:08 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

With this patch two properties are added. One for CRTC+Sprite planes
and another for Cursor planes. Through these client will be able to
change the pixel format of the planes w.r.t Alpha channel.
Number of drm properties are limited so should we restrain from adding this
as drm property or should we expose this as IOCTL itself.

Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h      |   2 +
 drivers/gpu/drm/i915/i915_reg.h      |   6 ++
 drivers/gpu/drm/i915/intel_display.c | 156 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |   8 +-
 drivers/gpu/drm/i915/intel_sprite.c  |  59 +++++++++++--
 5 files changed, 222 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 8c64831..5ced53d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1560,6 +1560,8 @@ typedef struct drm_i915_private {
 
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
+	struct drm_property *plane_alpha_property;
+	struct drm_property *cursor_alpha_property;
 
 	uint32_t hw_context_size;
 	struct list_head context_list;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 2f564ce..039270e 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3522,7 +3522,11 @@
 /* New style CUR*CNTR flags */
 #define   CURSOR_MODE		0x27
 #define   CURSOR_MODE_DISABLE   0x00
+#define   CURSOR_MODE_128_32B_AX 0x02
+#define   CURSOR_MODE_256_32B_AX 0x03
 #define   CURSOR_MODE_64_32B_AX 0x07
+#define   CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX)
+#define   CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX)
 #define   CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX)
 #define   MCURSOR_PIPE_SELECT	(1 << 28)
 #define   MCURSOR_PIPE_A	0x00
@@ -3569,7 +3573,9 @@
 #define   DISPPLANE_RGBX101010			(0x8<<26)
 #define   DISPPLANE_RGBA101010			(0x9<<26)
 #define   DISPPLANE_BGRX101010			(0xa<<26)
+#define   DISPPLANE_BGRA101010			(0xb<<26)
 #define   DISPPLANE_RGBX161616			(0xc<<26)
+#define   DISPPLANE_RGBA161616			(0xd<<26)
 #define   DISPPLANE_RGBX888			(0xe<<26)
 #define   DISPPLANE_RGBA888			(0xf<<26)
 #define   DISPPLANE_STEREO_ENABLE		(1<<25)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f19e6ea..a854bcb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2047,6 +2047,86 @@ unsigned long intel_gen4_compute_page_offset(int *x, int *y,
 	}
 }
 
+u32 control_plane_alpha(u32 pixformat, unsigned int alpha)
+{
+	switch (pixformat) {
+	case DISPPLANE_RGBX888:
+	case DISPPLANE_RGBA888:
+		if (alpha)
+			pixformat = DISPPLANE_RGBA888;
+		else
+			pixformat = DISPPLANE_RGBX888;
+		break;
+	case DISPPLANE_BGRX888:
+	case DISPPLANE_BGRA888:
+		if (alpha)
+			pixformat = DISPPLANE_BGRA888;
+		else
+			pixformat = DISPPLANE_BGRX888;
+		break;
+	case DISPPLANE_RGBX101010:
+	case DISPPLANE_RGBA101010:
+		if (alpha)
+			pixformat = DISPPLANE_RGBA101010;
+		else
+			pixformat = DISPPLANE_RGBX101010;
+		break;
+	case DISPPLANE_BGRX101010:
+	case DISPPLANE_BGRA101010:
+		if (alpha)
+			pixformat = DISPPLANE_BGRA101010;
+		else
+			pixformat = DISPPLANE_BGRX101010;
+		break;
+	case DISPPLANE_RGBX161616:
+	case DISPPLANE_RGBA161616:
+		if (alpha)
+			pixformat = DISPPLANE_RGBA161616;
+		else
+			pixformat = DISPPLANE_RGBX161616;
+		break;
+	default:
+		if (alpha)
+			DRM_DEBUG_DRIVER("Pixel format 0x%08x does not support Alpha Control\n", pixformat);
+		break;
+	}
+	return pixformat;
+}
+
+u32 control_cursor_alpha(u32 pixformat, unsigned int alpha)
+{
+	switch (pixformat) {
+	case CURSOR_MODE_128_32B_AX:
+	case CURSOR_MODE_128_ARGB_AX:
+		if (alpha)
+			pixformat = CURSOR_MODE_128_ARGB_AX;
+		else
+			pixformat = CURSOR_MODE_128_32B_AX;
+		break;
+
+	case CURSOR_MODE_256_ARGB_AX:
+	case CURSOR_MODE_256_32B_AX:
+		if (alpha)
+			pixformat = CURSOR_MODE_256_ARGB_AX;
+		else
+			pixformat = CURSOR_MODE_256_32B_AX;
+		break;
+
+	case CURSOR_MODE_64_ARGB_AX:
+	case CURSOR_MODE_64_32B_AX:
+		if (alpha)
+			pixformat = CURSOR_MODE_64_ARGB_AX;
+		else
+			pixformat = CURSOR_MODE_64_32B_AX;
+		break;
+	default:
+		if (alpha)
+			DRM_DEBUG_DRIVER("Pixel format 0x%08x does not support Alpha Control\n", pixformat);
+		break;
+	}
+	return pixformat;
+}
+
 static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 			     int x, int y)
 {
@@ -2107,6 +2187,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 		BUG();
 	}
 
+	dspcntr |= control_plane_alpha(dspcntr & DISPPLANE_PIXFORMAT_MASK,
+				       intel_crtc->primary_alpha);
+
 	if (INTEL_INFO(dev)->gen >= 4) {
 		if (obj->tiling_mode != I915_TILING_NONE)
 			dspcntr |= DISPPLANE_TILED;
@@ -7415,6 +7498,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 		if (base) {
 			cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
 			cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
+			cntl |= control_cursor_alpha(cntl & CURSOR_MODE, intel_crtc->cursor_alpha);
 			cntl |= pipe << 28; /* Connect to correct pipe */
 		} else {
 			cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
@@ -8755,6 +8839,59 @@ free_work:
 	return ret;
 }
 
+static int intel_set_primary_plane_alpha(struct intel_crtc *crtc,
+                                           unsigned int alpha)
+{
+       struct drm_device *dev = crtc->base.dev;
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       unsigned int old_alpha;
+       int ret = 0;
+
+       old_alpha = crtc->primary_alpha;
+       crtc->primary_alpha = alpha;
+
+       if (!crtc->active)
+               return 0;
+
+       intel_crtc_wait_for_pending_flips(&crtc->base);
+
+       ret = dev_priv->display.update_plane(&crtc->base, crtc->base.fb, 0, 0);
+       if (ret)
+               crtc->primary_alpha = old_alpha;
+
+       return ret;
+}
+
+static void intel_set_cursor_plane_alpha(struct intel_crtc *crtc,
+                                           unsigned int alpha)
+{
+       crtc->cursor_alpha = alpha;
+
+       if (crtc->active)
+              intel_crtc_update_cursor(&crtc->base, true);
+}
+
+static int intel_crtc_set_property(struct drm_crtc *crtc,
+                                    struct drm_property *prop,
+                                    uint64_t val)
+{
+        struct drm_device *dev = crtc->dev;
+        struct drm_i915_private *dev_priv = dev->dev_private;
+        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+        uint64_t old_val;
+        int ret = -ENOENT;
+
+        if (prop == dev_priv->plane_alpha_property) {
+               ret = intel_set_primary_plane_alpha(intel_crtc,
+                                                   intel_crtc->primary_alpha);
+	} else if (prop == dev_priv->cursor_alpha_property) {
+		intel_set_cursor_plane_alpha(intel_crtc, val);
+		return 0;
+	}
+
+	return ret;
+}
+
 static struct drm_crtc_helper_funcs intel_helper_funcs = {
 	.mode_set_base_atomic = intel_pipe_set_base_atomic,
 	.load_lut = intel_crtc_load_lut,
@@ -10167,6 +10304,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.set_config = intel_crtc_set_config,
 	.destroy = intel_crtc_destroy,
 	.page_flip = intel_crtc_page_flip,
+	.set_property = intel_crtc_set_property
 };
 
 static void intel_cpu_pll_init(struct drm_device *dev)
@@ -10305,6 +10443,24 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
 	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
 	dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
 
+	if (!dev_priv->plane_alpha_property)
+		dev_priv->plane_alpha_property =
+			drm_property_create_range(dev, 0, "plane-alpha", 0, 1);
+
+	if (dev_priv->plane_alpha_property)
+		drm_object_attach_property(&intel_crtc->base.base,
+					dev_priv->plane_alpha_property,
+					intel_crtc->primary_alpha);
+
+       if (!dev_priv->cursor_alpha_property)
+	       dev_priv->cursor_alpha_property =
+			drm_property_create_range(dev, 0, "cursor-alpha", 0, 1);
+
+       if (dev_priv->cursor_alpha_property)
+	       drm_object_attach_property(&intel_crtc->base.base,
+				       dev_priv->cursor_alpha_property,
+				       intel_crtc->cursor_alpha);
+
 	drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index a4ffc02..0080d3a 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -339,6 +339,9 @@ struct intel_crtc {
 	struct drm_crtc base;
 	enum pipe pipe;
 	enum plane plane;
+	unsigned int primary_alpha; /* primary plane alpha control */
+        unsigned int cursor_alpha; /* cursor plane alpha control */
+
 	u8 lut_r[256], lut_g[256], lut_b[256];
 	/*
 	 * Whether the crtc and the connected output pipeline is active. Implies
@@ -405,6 +408,7 @@ struct intel_plane {
 	unsigned int crtc_w, crtc_h;
 	uint32_t src_x, src_y;
 	uint32_t src_w, src_h;
+	unsigned int plane_alpha;
 
 	/* Since we need to change the watermarks before/after
 	 * enabling/disabling the planes, we need to store the parameters here
@@ -676,6 +680,8 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
 enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
 					     enum pipe pipe);
 void intel_wait_for_vblank(struct drm_device *dev, int pipe);
+u32 control_plane_alpha(u32 pixformat, unsigned int alpha);
+u32 control_cursor_alpha(u32 pixformat, unsigned int alpha);
 void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
 int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
 void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
@@ -906,7 +912,7 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
 int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
 void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
 			       enum plane plane);
-void intel_plane_restore(struct drm_plane *plane);
+int intel_plane_restore(struct drm_plane *plane);
 void intel_plane_disable(struct drm_plane *plane);
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 			      struct drm_file *file_priv);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 336ae6c..9f6c91a 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -104,6 +104,9 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		break;
 	}
 
+	sprctl |= control_plane_alpha(sprctl & SP_PIXFORMAT_MASK,
+				       intel_plane->plane_alpha);
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -262,6 +265,9 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		BUG();
 	}
 
+	sprctl |= control_plane_alpha(sprctl & SPRITE_PIXFORMAT_MASK,
+				       intel_plane->plane_alpha);
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -446,6 +452,9 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		BUG();
 	}
 
+	dvscntr |= control_plane_alpha(dvscntr & DVS_PIXFORMAT_MASK,
+				       intel_plane->plane_alpha);
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -1011,18 +1020,38 @@ out_unlock:
 	return ret;
 }
 
-void intel_plane_restore(struct drm_plane *plane)
+static int intel_plane_set_property(struct drm_plane *plane,
+                                    struct drm_property *prop,
+                                    uint64_t val)
+{
+        struct drm_i915_private *dev_priv = plane->dev->dev_private;
+        struct intel_plane *intel_plane = to_intel_plane(plane);
+        uint64_t old_val;
+        int ret = -ENOENT;
+
+        if (prop == dev_priv->plane_alpha_property) {
+                old_val = intel_plane->plane_alpha;
+                intel_plane->plane_alpha = val;
+                ret = intel_plane_restore(plane);
+                if (ret)
+                        intel_plane->plane_alpha = old_val;
+        }
+
+        return ret;
+}
+
+int intel_plane_restore(struct drm_plane *plane)
 {
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 
 	if (!plane->crtc || !plane->fb)
-		return;
+		return 0;
 
-	intel_update_plane(plane, plane->crtc, plane->fb,
-			   intel_plane->crtc_x, intel_plane->crtc_y,
-			   intel_plane->crtc_w, intel_plane->crtc_h,
-			   intel_plane->src_x, intel_plane->src_y,
-			   intel_plane->src_w, intel_plane->src_h);
+	return intel_update_plane(plane, plane->crtc, plane->fb,
+				  intel_plane->crtc_x, intel_plane->crtc_y,
+				  intel_plane->crtc_w, intel_plane->crtc_h,
+				  intel_plane->src_x, intel_plane->src_y,
+				  intel_plane->src_w, intel_plane->src_h);
 }
 
 void intel_plane_disable(struct drm_plane *plane)
@@ -1037,6 +1066,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = intel_update_plane,
 	.disable_plane = intel_disable_plane,
 	.destroy = intel_destroy_plane,
+	.set_property = intel_plane_set_property,
 };
 
 static uint32_t ilk_plane_formats[] = {
@@ -1073,6 +1103,7 @@ static uint32_t vlv_plane_formats[] = {
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_plane *intel_plane;
 	unsigned long possible_crtcs;
 	const uint32_t *plane_formats;
@@ -1146,8 +1177,20 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 			     &intel_plane_funcs,
 			     plane_formats, num_plane_formats,
 			     false);
-	if (ret)
+	if (ret) {
 		kfree(intel_plane);
+		goto out;
+	}
+
+	if (!dev_priv->plane_alpha_property)
+		dev_priv->plane_alpha_property =
+			drm_property_create_range(dev, 0, "plane-alpha", 0, 1);
+
+	if (dev_priv->plane_alpha_property)
+		drm_object_attach_property(&intel_plane->base.base,
+					dev_priv->plane_alpha_property,
+					intel_plane->plane_alpha);
 
+out:
 	return ret;
 }
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-02-19 10:08 [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property sagar.a.kamble
@ 2014-02-24 15:44 ` Sagar Arun Kamble
  2014-03-06 12:03   ` Damien Lespiau
  2014-02-25 18:18 ` Ville Syrjälä
  1 sibling, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-02-24 15:44 UTC (permalink / raw)
  To: intel-gfx

Gentle Reminder !!!
Kindly review and provide feedback

thanks,
Sagar

On Wed, 2014-02-19 at 15:38 +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> With this patch two properties are added. One for CRTC+Sprite planes
> and another for Cursor planes. Through these client will be able to
> change the pixel format of the planes w.r.t Alpha channel.
> Number of drm properties are limited so should we restrain from adding this
> as drm property or should we expose this as IOCTL itself.
> 
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h      |   2 +
>  drivers/gpu/drm/i915/i915_reg.h      |   6 ++
>  drivers/gpu/drm/i915/intel_display.c | 156 +++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_drv.h     |   8 +-
>  drivers/gpu/drm/i915/intel_sprite.c  |  59 +++++++++++--
>  5 files changed, 222 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 8c64831..5ced53d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1560,6 +1560,8 @@ typedef struct drm_i915_private {
>  
>  	struct drm_property *broadcast_rgb_property;
>  	struct drm_property *force_audio_property;
> +	struct drm_property *plane_alpha_property;
> +	struct drm_property *cursor_alpha_property;
>  
>  	uint32_t hw_context_size;
>  	struct list_head context_list;
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 2f564ce..039270e 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -3522,7 +3522,11 @@
>  /* New style CUR*CNTR flags */
>  #define   CURSOR_MODE		0x27
>  #define   CURSOR_MODE_DISABLE   0x00
> +#define   CURSOR_MODE_128_32B_AX 0x02
> +#define   CURSOR_MODE_256_32B_AX 0x03
>  #define   CURSOR_MODE_64_32B_AX 0x07
> +#define   CURSOR_MODE_128_ARGB_AX ((1 << 5) | CURSOR_MODE_128_32B_AX)
> +#define   CURSOR_MODE_256_ARGB_AX ((1 << 5) | CURSOR_MODE_256_32B_AX)
>  #define   CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX)
>  #define   MCURSOR_PIPE_SELECT	(1 << 28)
>  #define   MCURSOR_PIPE_A	0x00
> @@ -3569,7 +3573,9 @@
>  #define   DISPPLANE_RGBX101010			(0x8<<26)
>  #define   DISPPLANE_RGBA101010			(0x9<<26)
>  #define   DISPPLANE_BGRX101010			(0xa<<26)
> +#define   DISPPLANE_BGRA101010			(0xb<<26)
>  #define   DISPPLANE_RGBX161616			(0xc<<26)
> +#define   DISPPLANE_RGBA161616			(0xd<<26)
>  #define   DISPPLANE_RGBX888			(0xe<<26)
>  #define   DISPPLANE_RGBA888			(0xf<<26)
>  #define   DISPPLANE_STEREO_ENABLE		(1<<25)
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index f19e6ea..a854bcb 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2047,6 +2047,86 @@ unsigned long intel_gen4_compute_page_offset(int *x, int *y,
>  	}
>  }
>  
> +u32 control_plane_alpha(u32 pixformat, unsigned int alpha)
> +{
> +	switch (pixformat) {
> +	case DISPPLANE_RGBX888:
> +	case DISPPLANE_RGBA888:
> +		if (alpha)
> +			pixformat = DISPPLANE_RGBA888;
> +		else
> +			pixformat = DISPPLANE_RGBX888;
> +		break;
> +	case DISPPLANE_BGRX888:
> +	case DISPPLANE_BGRA888:
> +		if (alpha)
> +			pixformat = DISPPLANE_BGRA888;
> +		else
> +			pixformat = DISPPLANE_BGRX888;
> +		break;
> +	case DISPPLANE_RGBX101010:
> +	case DISPPLANE_RGBA101010:
> +		if (alpha)
> +			pixformat = DISPPLANE_RGBA101010;
> +		else
> +			pixformat = DISPPLANE_RGBX101010;
> +		break;
> +	case DISPPLANE_BGRX101010:
> +	case DISPPLANE_BGRA101010:
> +		if (alpha)
> +			pixformat = DISPPLANE_BGRA101010;
> +		else
> +			pixformat = DISPPLANE_BGRX101010;
> +		break;
> +	case DISPPLANE_RGBX161616:
> +	case DISPPLANE_RGBA161616:
> +		if (alpha)
> +			pixformat = DISPPLANE_RGBA161616;
> +		else
> +			pixformat = DISPPLANE_RGBX161616;
> +		break;
> +	default:
> +		if (alpha)
> +			DRM_DEBUG_DRIVER("Pixel format 0x%08x does not support Alpha Control\n", pixformat);
> +		break;
> +	}
> +	return pixformat;
> +}
> +
> +u32 control_cursor_alpha(u32 pixformat, unsigned int alpha)
> +{
> +	switch (pixformat) {
> +	case CURSOR_MODE_128_32B_AX:
> +	case CURSOR_MODE_128_ARGB_AX:
> +		if (alpha)
> +			pixformat = CURSOR_MODE_128_ARGB_AX;
> +		else
> +			pixformat = CURSOR_MODE_128_32B_AX;
> +		break;
> +
> +	case CURSOR_MODE_256_ARGB_AX:
> +	case CURSOR_MODE_256_32B_AX:
> +		if (alpha)
> +			pixformat = CURSOR_MODE_256_ARGB_AX;
> +		else
> +			pixformat = CURSOR_MODE_256_32B_AX;
> +		break;
> +
> +	case CURSOR_MODE_64_ARGB_AX:
> +	case CURSOR_MODE_64_32B_AX:
> +		if (alpha)
> +			pixformat = CURSOR_MODE_64_ARGB_AX;
> +		else
> +			pixformat = CURSOR_MODE_64_32B_AX;
> +		break;
> +	default:
> +		if (alpha)
> +			DRM_DEBUG_DRIVER("Pixel format 0x%08x does not support Alpha Control\n", pixformat);
> +		break;
> +	}
> +	return pixformat;
> +}
> +
>  static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
>  			     int x, int y)
>  {
> @@ -2107,6 +2187,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
>  		BUG();
>  	}
>  
> +	dspcntr |= control_plane_alpha(dspcntr & DISPPLANE_PIXFORMAT_MASK,
> +				       intel_crtc->primary_alpha);
> +
>  	if (INTEL_INFO(dev)->gen >= 4) {
>  		if (obj->tiling_mode != I915_TILING_NONE)
>  			dspcntr |= DISPPLANE_TILED;
> @@ -7415,6 +7498,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
>  		if (base) {
>  			cntl &= ~(CURSOR_MODE | MCURSOR_PIPE_SELECT);
>  			cntl |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
> +			cntl |= control_cursor_alpha(cntl & CURSOR_MODE, intel_crtc->cursor_alpha);
>  			cntl |= pipe << 28; /* Connect to correct pipe */
>  		} else {
>  			cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE);
> @@ -8755,6 +8839,59 @@ free_work:
>  	return ret;
>  }
>  
> +static int intel_set_primary_plane_alpha(struct intel_crtc *crtc,
> +                                           unsigned int alpha)
> +{
> +       struct drm_device *dev = crtc->base.dev;
> +       struct drm_i915_private *dev_priv = dev->dev_private;
> +       unsigned int old_alpha;
> +       int ret = 0;
> +
> +       old_alpha = crtc->primary_alpha;
> +       crtc->primary_alpha = alpha;
> +
> +       if (!crtc->active)
> +               return 0;
> +
> +       intel_crtc_wait_for_pending_flips(&crtc->base);
> +
> +       ret = dev_priv->display.update_plane(&crtc->base, crtc->base.fb, 0, 0);
> +       if (ret)
> +               crtc->primary_alpha = old_alpha;
> +
> +       return ret;
> +}
> +
> +static void intel_set_cursor_plane_alpha(struct intel_crtc *crtc,
> +                                           unsigned int alpha)
> +{
> +       crtc->cursor_alpha = alpha;
> +
> +       if (crtc->active)
> +              intel_crtc_update_cursor(&crtc->base, true);
> +}
> +
> +static int intel_crtc_set_property(struct drm_crtc *crtc,
> +                                    struct drm_property *prop,
> +                                    uint64_t val)
> +{
> +        struct drm_device *dev = crtc->dev;
> +        struct drm_i915_private *dev_priv = dev->dev_private;
> +        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +        uint64_t old_val;
> +        int ret = -ENOENT;
> +
> +        if (prop == dev_priv->plane_alpha_property) {
> +               ret = intel_set_primary_plane_alpha(intel_crtc,
> +                                                   intel_crtc->primary_alpha);
> +	} else if (prop == dev_priv->cursor_alpha_property) {
> +		intel_set_cursor_plane_alpha(intel_crtc, val);
> +		return 0;
> +	}
> +
> +	return ret;
> +}
> +
>  static struct drm_crtc_helper_funcs intel_helper_funcs = {
>  	.mode_set_base_atomic = intel_pipe_set_base_atomic,
>  	.load_lut = intel_crtc_load_lut,
> @@ -10167,6 +10304,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
>  	.set_config = intel_crtc_set_config,
>  	.destroy = intel_crtc_destroy,
>  	.page_flip = intel_crtc_page_flip,
> +	.set_property = intel_crtc_set_property
>  };
>  
>  static void intel_cpu_pll_init(struct drm_device *dev)
> @@ -10305,6 +10443,24 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
>  	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
>  	dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
>  
> +	if (!dev_priv->plane_alpha_property)
> +		dev_priv->plane_alpha_property =
> +			drm_property_create_range(dev, 0, "plane-alpha", 0, 1);
> +
> +	if (dev_priv->plane_alpha_property)
> +		drm_object_attach_property(&intel_crtc->base.base,
> +					dev_priv->plane_alpha_property,
> +					intel_crtc->primary_alpha);
> +
> +       if (!dev_priv->cursor_alpha_property)
> +	       dev_priv->cursor_alpha_property =
> +			drm_property_create_range(dev, 0, "cursor-alpha", 0, 1);
> +
> +       if (dev_priv->cursor_alpha_property)
> +	       drm_object_attach_property(&intel_crtc->base.base,
> +				       dev_priv->cursor_alpha_property,
> +				       intel_crtc->cursor_alpha);
> +
>  	drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index a4ffc02..0080d3a 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -339,6 +339,9 @@ struct intel_crtc {
>  	struct drm_crtc base;
>  	enum pipe pipe;
>  	enum plane plane;
> +	unsigned int primary_alpha; /* primary plane alpha control */
> +        unsigned int cursor_alpha; /* cursor plane alpha control */
> +
>  	u8 lut_r[256], lut_g[256], lut_b[256];
>  	/*
>  	 * Whether the crtc and the connected output pipeline is active. Implies
> @@ -405,6 +408,7 @@ struct intel_plane {
>  	unsigned int crtc_w, crtc_h;
>  	uint32_t src_x, src_y;
>  	uint32_t src_w, src_h;
> +	unsigned int plane_alpha;
>  
>  	/* Since we need to change the watermarks before/after
>  	 * enabling/disabling the planes, we need to store the parameters here
> @@ -676,6 +680,8 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
>  enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
>  					     enum pipe pipe);
>  void intel_wait_for_vblank(struct drm_device *dev, int pipe);
> +u32 control_plane_alpha(u32 pixformat, unsigned int alpha);
> +u32 control_cursor_alpha(u32 pixformat, unsigned int alpha);
>  void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
>  int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
>  void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
> @@ -906,7 +912,7 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
>  int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
>  void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
>  			       enum plane plane);
> -void intel_plane_restore(struct drm_plane *plane);
> +int intel_plane_restore(struct drm_plane *plane);
>  void intel_plane_disable(struct drm_plane *plane);
>  int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>  			      struct drm_file *file_priv);
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 336ae6c..9f6c91a 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -104,6 +104,9 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  		break;
>  	}
>  
> +	sprctl |= control_plane_alpha(sprctl & SP_PIXFORMAT_MASK,
> +				       intel_plane->plane_alpha);
> +
>  	/*
>  	 * Enable gamma to match primary/cursor plane behaviour.
>  	 * FIXME should be user controllable via propertiesa.
> @@ -262,6 +265,9 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>  		BUG();
>  	}
>  
> +	sprctl |= control_plane_alpha(sprctl & SPRITE_PIXFORMAT_MASK,
> +				       intel_plane->plane_alpha);
> +
>  	/*
>  	 * Enable gamma to match primary/cursor plane behaviour.
>  	 * FIXME should be user controllable via propertiesa.
> @@ -446,6 +452,9 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>  		BUG();
>  	}
>  
> +	dvscntr |= control_plane_alpha(dvscntr & DVS_PIXFORMAT_MASK,
> +				       intel_plane->plane_alpha);
> +
>  	/*
>  	 * Enable gamma to match primary/cursor plane behaviour.
>  	 * FIXME should be user controllable via propertiesa.
> @@ -1011,18 +1020,38 @@ out_unlock:
>  	return ret;
>  }
>  
> -void intel_plane_restore(struct drm_plane *plane)
> +static int intel_plane_set_property(struct drm_plane *plane,
> +                                    struct drm_property *prop,
> +                                    uint64_t val)
> +{
> +        struct drm_i915_private *dev_priv = plane->dev->dev_private;
> +        struct intel_plane *intel_plane = to_intel_plane(plane);
> +        uint64_t old_val;
> +        int ret = -ENOENT;
> +
> +        if (prop == dev_priv->plane_alpha_property) {
> +                old_val = intel_plane->plane_alpha;
> +                intel_plane->plane_alpha = val;
> +                ret = intel_plane_restore(plane);
> +                if (ret)
> +                        intel_plane->plane_alpha = old_val;
> +        }
> +
> +        return ret;
> +}
> +
> +int intel_plane_restore(struct drm_plane *plane)
>  {
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
>  
>  	if (!plane->crtc || !plane->fb)
> -		return;
> +		return 0;
>  
> -	intel_update_plane(plane, plane->crtc, plane->fb,
> -			   intel_plane->crtc_x, intel_plane->crtc_y,
> -			   intel_plane->crtc_w, intel_plane->crtc_h,
> -			   intel_plane->src_x, intel_plane->src_y,
> -			   intel_plane->src_w, intel_plane->src_h);
> +	return intel_update_plane(plane, plane->crtc, plane->fb,
> +				  intel_plane->crtc_x, intel_plane->crtc_y,
> +				  intel_plane->crtc_w, intel_plane->crtc_h,
> +				  intel_plane->src_x, intel_plane->src_y,
> +				  intel_plane->src_w, intel_plane->src_h);
>  }
>  
>  void intel_plane_disable(struct drm_plane *plane)
> @@ -1037,6 +1066,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
>  	.update_plane = intel_update_plane,
>  	.disable_plane = intel_disable_plane,
>  	.destroy = intel_destroy_plane,
> +	.set_property = intel_plane_set_property,
>  };
>  
>  static uint32_t ilk_plane_formats[] = {
> @@ -1073,6 +1103,7 @@ static uint32_t vlv_plane_formats[] = {
>  int
>  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  {
> +	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_plane *intel_plane;
>  	unsigned long possible_crtcs;
>  	const uint32_t *plane_formats;
> @@ -1146,8 +1177,20 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  			     &intel_plane_funcs,
>  			     plane_formats, num_plane_formats,
>  			     false);
> -	if (ret)
> +	if (ret) {
>  		kfree(intel_plane);
> +		goto out;
> +	}
> +
> +	if (!dev_priv->plane_alpha_property)
> +		dev_priv->plane_alpha_property =
> +			drm_property_create_range(dev, 0, "plane-alpha", 0, 1);
> +
> +	if (dev_priv->plane_alpha_property)
> +		drm_object_attach_property(&intel_plane->base.base,
> +					dev_priv->plane_alpha_property,
> +					intel_plane->plane_alpha);
>  
> +out:
>  	return ret;
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-02-19 10:08 [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property sagar.a.kamble
  2014-02-24 15:44 ` Sagar Arun Kamble
@ 2014-02-25 18:18 ` Ville Syrjälä
  2014-03-04  9:42   ` [Intel-gfx] " Daniel Vetter
  1 sibling, 1 reply; 53+ messages in thread
From: Ville Syrjälä @ 2014-02-25 18:18 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: intel-gfx, dri-devel

On Wed, Feb 19, 2014 at 03:38:08PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> With this patch two properties are added. One for CRTC+Sprite planes
> and another for Cursor planes. Through these client will be able to
> change the pixel format of the planes w.r.t Alpha channel.
> Number of drm properties are limited so should we restrain from adding this
> as drm property or should we expose this as IOCTL itself.

We need to stop adding properties on a whim and design and document them
properly. So what I'd like to see is someone going over the current
properties and collecting them up in some (even bares bones) documentation
in Documentation/Docbook. The current way will lead to a huge mess when
userspace actually starts to depend on properties. So far properties
have been mostly some optional extra junk on the side people that may
want to frob, but that's going to change as we add more of them,
especially with plane and crtc properties, which actually affect how
the scene gets composed together.

And I think we need to put a hold on adding the plane properties to the
crtc since the plan is to convert everything to drm_plane. With the
current rate we're going to have a ton of properties on the crtc that no
one will use. Adding properties to the sprite planes seems OK in the
meantime.

As far as alpha blending is concerned I've had the following ideas:
- we need a plane property for constant alpha. Some drivers might
  already have this, so might be good to check. Although I'm fairly
  sure what's there won't be entirely future proof. I was thinking that
  we should standardize of using 16bits for color components in
  properties. That way you can still stick a full ARGB value into
  one property, and we should be good for a few more years until
  someone has the idea to move beyond 16bits per channel. And it's
  more or less hardware agnostic. Obviously if the hardware won't
  use the full precision, you get to throw away the low bits, but I
  don't think there's any other good way to go.
- we need another property to indicate whether the source pixels
  are premultiplied or not. Or maybe it's easier for people to think
  in terms of what operations the hardware will do, in which case
  we should make the property indicate whether the hardware will
  do the premultiplication during blending or not. I'm not sure
  which approach feels more natural to people.
- And finally we need to figure out how to blend it all together.
  It might make sense to model this after glBlendFunc(), so it would
  be an enum property, or maybe two if we want separate properties
  for source and destination factors.

Obviously the final result will depend on additional things like the
z-order, which is going to be another property. I think this one might
already exists in some form in other drivers. So we should definitely
look at what's there and try to do the same if possible. Which again
underlines the need to collect up the current properties into some
central documentation.

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Intel-gfx] [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-02-25 18:18 ` Ville Syrjälä
@ 2014-03-04  9:42   ` Daniel Vetter
  2014-03-04 12:06     ` Ville Syrjälä
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-03-04  9:42 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, sagar.a.kamble, dri-devel

On Tue, Feb 25, 2014 at 08:18:30PM +0200, Ville Syrjälä wrote:
> On Wed, Feb 19, 2014 at 03:38:08PM +0530, sagar.a.kamble@intel.com wrote:
> > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > 
> > With this patch two properties are added. One for CRTC+Sprite planes
> > and another for Cursor planes. Through these client will be able to
> > change the pixel format of the planes w.r.t Alpha channel.
> > Number of drm properties are limited so should we restrain from adding this
> > as drm property or should we expose this as IOCTL itself.
> 
> We need to stop adding properties on a whim and design and document them
> properly. So what I'd like to see is someone going over the current
> properties and collecting them up in some (even bares bones) documentation
> in Documentation/Docbook. The current way will lead to a huge mess when
> userspace actually starts to depend on properties. So far properties
> have been mostly some optional extra junk on the side people that may
> want to frob, but that's going to change as we add more of them,
> especially with plane and crtc properties, which actually affect how
> the scene gets composed together.
> 
> And I think we need to put a hold on adding the plane properties to the
> crtc since the plan is to convert everything to drm_plane. With the
> current rate we're going to have a ton of properties on the crtc that no
> one will use. Adding properties to the sprite planes seems OK in the
> meantime.
> 
> As far as alpha blending is concerned I've had the following ideas:
> - we need a plane property for constant alpha. Some drivers might
>   already have this, so might be good to check. Although I'm fairly
>   sure what's there won't be entirely future proof. I was thinking that
>   we should standardize of using 16bits for color components in
>   properties. That way you can still stick a full ARGB value into
>   one property, and we should be good for a few more years until
>   someone has the idea to move beyond 16bits per channel. And it's
>   more or less hardware agnostic. Obviously if the hardware won't
>   use the full precision, you get to throw away the low bits, but I
>   don't think there's any other good way to go.
> - we need another property to indicate whether the source pixels
>   are premultiplied or not. Or maybe it's easier for people to think
>   in terms of what operations the hardware will do, in which case
>   we should make the property indicate whether the hardware will
>   do the premultiplication during blending or not. I'm not sure
>   which approach feels more natural to people.
> - And finally we need to figure out how to blend it all together.
>   It might make sense to model this after glBlendFunc(), so it would
>   be an enum property, or maybe two if we want separate properties
>   for source and destination factors.
> 
> Obviously the final result will depend on additional things like the
> z-order, which is going to be another property. I think this one might
> already exists in some form in other drivers. So we should definitely
> look at what's there and try to do the same if possible. Which again
> underlines the need to collect up the current properties into some
> central documentation.

Concurred on stealing the blending model from GL. It seems what everyon
else is aiming for at least at both the hw and sw level ... One issue with
that is handling color keys, since those aren't supported by glBlendFunc.
But I guess we could just add those as additional modes, since the usual
blend funcs already require a constant blend color, which could be reused
as the color key.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-03-04  9:42   ` [Intel-gfx] " Daniel Vetter
@ 2014-03-04 12:06     ` Ville Syrjälä
  2014-03-06 10:28       ` [Intel-gfx] " Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Ville Syrjälä @ 2014-03-04 12:06 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, sagar.a.kamble, dri-devel

On Tue, Mar 04, 2014 at 10:42:38AM +0100, Daniel Vetter wrote:
> On Tue, Feb 25, 2014 at 08:18:30PM +0200, Ville Syrjälä wrote:
> > On Wed, Feb 19, 2014 at 03:38:08PM +0530, sagar.a.kamble@intel.com wrote:
> > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > 
> > > With this patch two properties are added. One for CRTC+Sprite planes
> > > and another for Cursor planes. Through these client will be able to
> > > change the pixel format of the planes w.r.t Alpha channel.
> > > Number of drm properties are limited so should we restrain from adding this
> > > as drm property or should we expose this as IOCTL itself.
> > 
> > We need to stop adding properties on a whim and design and document them
> > properly. So what I'd like to see is someone going over the current
> > properties and collecting them up in some (even bares bones) documentation
> > in Documentation/Docbook. The current way will lead to a huge mess when
> > userspace actually starts to depend on properties. So far properties
> > have been mostly some optional extra junk on the side people that may
> > want to frob, but that's going to change as we add more of them,
> > especially with plane and crtc properties, which actually affect how
> > the scene gets composed together.
> > 
> > And I think we need to put a hold on adding the plane properties to the
> > crtc since the plan is to convert everything to drm_plane. With the
> > current rate we're going to have a ton of properties on the crtc that no
> > one will use. Adding properties to the sprite planes seems OK in the
> > meantime.
> > 
> > As far as alpha blending is concerned I've had the following ideas:
> > - we need a plane property for constant alpha. Some drivers might
> >   already have this, so might be good to check. Although I'm fairly
> >   sure what's there won't be entirely future proof. I was thinking that
> >   we should standardize of using 16bits for color components in
> >   properties. That way you can still stick a full ARGB value into
> >   one property, and we should be good for a few more years until
> >   someone has the idea to move beyond 16bits per channel. And it's
> >   more or less hardware agnostic. Obviously if the hardware won't
> >   use the full precision, you get to throw away the low bits, but I
> >   don't think there's any other good way to go.
> > - we need another property to indicate whether the source pixels
> >   are premultiplied or not. Or maybe it's easier for people to think
> >   in terms of what operations the hardware will do, in which case
> >   we should make the property indicate whether the hardware will
> >   do the premultiplication during blending or not. I'm not sure
> >   which approach feels more natural to people.
> > - And finally we need to figure out how to blend it all together.
> >   It might make sense to model this after glBlendFunc(), so it would
> >   be an enum property, or maybe two if we want separate properties
> >   for source and destination factors.
> > 
> > Obviously the final result will depend on additional things like the
> > z-order, which is going to be another property. I think this one might
> > already exists in some form in other drivers. So we should definitely
> > look at what's there and try to do the same if possible. Which again
> > underlines the need to collect up the current properties into some
> > central documentation.
> 
> Concurred on stealing the blending model from GL. It seems what everyon
> else is aiming for at least at both the hw and sw level ... One issue with
> that is handling color keys, since those aren't supported by glBlendFunc.
> But I guess we could just add those as additional modes, since the usual
> blend funcs already require a constant blend color, which could be reused
> as the color key.

I've been thinking that color key stuff could just be implemented as
separate properties.

Color keying anyway may require min+max values or value+mask, so a single
value is not enough. But we might want to model the keying function in
a similar fashion to the blendfunc. Some old ATI hardware had a very
flexible color keying functinality where you would specify the graphics
and video keying functions (true,false,eq,neq) and then you had to
choose how to combine the result from those (and,or). If the combined
result was true it would pick the video data, and for false it'd pick
the graphics data. I've not seen that on any other hardware since, but
it's certainly flexible enough to represent the typical src/dst keying
modes.

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Intel-gfx] [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-03-04 12:06     ` Ville Syrjälä
@ 2014-03-06 10:28       ` Sagar Arun Kamble
  2014-03-06 11:24         ` Daniel Vetter
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-03-06 10:28 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, dri-devel

On Tue, 2014-03-04 at 14:06 +0200, Ville Syrjälä wrote:
> On Tue, Mar 04, 2014 at 10:42:38AM +0100, Daniel Vetter wrote:
> > On Tue, Feb 25, 2014 at 08:18:30PM +0200, Ville Syrjälä wrote:
> > > On Wed, Feb 19, 2014 at 03:38:08PM +0530, sagar.a.kamble@intel.com wrote:
> > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > 
> > > > With this patch two properties are added. One for CRTC+Sprite planes
> > > > and another for Cursor planes. Through these client will be able to
> > > > change the pixel format of the planes w.r.t Alpha channel.
> > > > Number of drm properties are limited so should we restrain from adding this
> > > > as drm property or should we expose this as IOCTL itself.
> > > 
> > > We need to stop adding properties on a whim and design and document them
> > > properly. So what I'd like to see is someone going over the current
> > > properties and collecting them up in some (even bares bones) documentation
> > > in Documentation/Docbook. The current way will lead to a huge mess when
> > > userspace actually starts to depend on properties. So far properties
> > > have been mostly some optional extra junk on the side people that may
> > > want to frob, but that's going to change as we add more of them,
> > > especially with plane and crtc properties, which actually affect how
> > > the scene gets composed together.
> > > 
> > > And I think we need to put a hold on adding the plane properties to the
> > > crtc since the plan is to convert everything to drm_plane. With the
> > > current rate we're going to have a ton of properties on the crtc that no
> > > one will use. Adding properties to the sprite planes seems OK in the
> > > meantime.
> > > 
> > > As far as alpha blending is concerned I've had the following ideas:
> > > - we need a plane property for constant alpha. Some drivers might
> > >   already have this, so might be good to check. Although I'm fairly
> > >   sure what's there won't be entirely future proof. I was thinking that
> > >   we should standardize of using 16bits for color components in
> > >   properties. That way you can still stick a full ARGB value into
> > >   one property, and we should be good for a few more years until
> > >   someone has the idea to move beyond 16bits per channel. And it's
> > >   more or less hardware agnostic. Obviously if the hardware won't
> > >   use the full precision, you get to throw away the low bits, but I
> > >   don't think there's any other good way to go.
> > > - we need another property to indicate whether the source pixels
> > >   are premultiplied or not. Or maybe it's easier for people to think
> > >   in terms of what operations the hardware will do, in which case
> > >   we should make the property indicate whether the hardware will
> > >   do the premultiplication during blending or not. I'm not sure
> > >   which approach feels more natural to people.
> > > - And finally we need to figure out how to blend it all together.
> > >   It might make sense to model this after glBlendFunc(), so it would
> > >   be an enum property, or maybe two if we want separate properties
> > >   for source and destination factors.
> > > 
> > > Obviously the final result will depend on additional things like the
> > > z-order, which is going to be another property. I think this one might
> > > already exists in some form in other drivers. So we should definitely
> > > look at what's there and try to do the same if possible. Which again
> > > underlines the need to collect up the current properties into some
> > > central documentation.
> > 
> > Concurred on stealing the blending model from GL. It seems what everyon
> > else is aiming for at least at both the hw and sw level ... One issue with
> > that is handling color keys, since those aren't supported by glBlendFunc.
> > But I guess we could just add those as additional modes, since the usual
> > blend funcs already require a constant blend color, which could be reused
> > as the color key.
> 
> I've been thinking that color key stuff could just be implemented as
> separate properties.
> 
> Color keying anyway may require min+max values or value+mask, so a single
> value is not enough. But we might want to model the keying function in
> a similar fashion to the blendfunc. Some old ATI hardware had a very
> flexible color keying functinality where you would specify the graphics
> and video keying functions (true,false,eq,neq) and then you had to
> choose how to combine the result from those (and,or). If the combined
> result was true it would pick the video data, and for false it'd pick
> the graphics data. I've not seen that on any other hardware since, but
> it's certainly flexible enough to represent the typical src/dst keying
> modes.
We can only model GL_CONSTANT_ALPHA given we have sprite control
registers for that. How do we model other pixel arithmetic related to
color blending?
How do we model source and destination pixel arithmetic? We can only set
alpha/pre-multiplied alpha for individual planes.

> 


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-03-06 10:28       ` [Intel-gfx] " Sagar Arun Kamble
@ 2014-03-06 11:24         ` Daniel Vetter
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-03-06 11:24 UTC (permalink / raw)
  To: Sagar Arun Kamble; +Cc: intel-gfx, dri-devel

On Thu, Mar 6, 2014 at 11:28 AM, Sagar Arun Kamble
<sagar.a.kamble@intel.com> wrote:
> We can only model GL_CONSTANT_ALPHA given we have sprite control
> registers for that. How do we model other pixel arithmetic related to
> color blending?
> How do we model source and destination pixel arithmetic? We can only set
> alpha/pre-multiplied alpha for individual planes.

We reject it if userspace attempts it ;-) But we kinda want a model
which also works for the next few hw platforms and also on other
drivers, so going with this sounds like the right approach to me.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-02-24 15:44 ` Sagar Arun Kamble
@ 2014-03-06 12:03   ` Damien Lespiau
  2014-03-06 12:09     ` Damien Lespiau
  0 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-06 12:03 UTC (permalink / raw)
  To: Sagar Arun Kamble; +Cc: intel-gfx

On Mon, Feb 24, 2014 at 09:14:41PM +0530, Sagar Arun Kamble wrote:
> Gentle Reminder !!!
> Kindly review and provide feedback

This main issue here is that we don't have yet the split between the
CRTC and the primary plane in the DRM API.

Why is this a problem? because you need to define a 'plane-alpha'
property on the CRTC and we'll have to maintain it forever and we don't
really want that when a neat split between the CRTC and primary plane is
not far off.

Work is ongoing on this, Matt bravely took the task:

  http://lists.freedesktop.org/archives/dri-devel/2014-February/054719.html

With a v2 in the queue.

I believe we need to sort this first, before adding more plane properties.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property
  2014-03-06 12:03   ` Damien Lespiau
@ 2014-03-06 12:09     ` Damien Lespiau
  0 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-06 12:09 UTC (permalink / raw)
  To: Sagar Arun Kamble; +Cc: intel-gfx

On Thu, Mar 06, 2014 at 12:03:07PM +0000, Damien Lespiau wrote:
> On Mon, Feb 24, 2014 at 09:14:41PM +0530, Sagar Arun Kamble wrote:
> > Gentle Reminder !!!
> > Kindly review and provide feedback
> 
> This main issue here is that we don't have yet the split between the
> CRTC and the primary plane in the DRM API.
> 
> Why is this a problem? because you need to define a 'plane-alpha'
> property on the CRTC and we'll have to maintain it forever and we don't
> really want that when a neat split between the CRTC and primary plane is
> not far off.
> 
> Work is ongoing on this, Matt bravely took the task:
> 
>   http://lists.freedesktop.org/archives/dri-devel/2014-February/054719.html
> 
> With a v2 in the queue.
> 
> I believe we need to sort this first, before adding more plane properties.

Ah, didn't see the rest of the thread because my MUA decided to split
the thread between two directories. Scrap that mail :)

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-06 11:24         ` Daniel Vetter
@ 2014-03-08  8:21           ` sagar.a.kamble
  2014-03-08  8:21               ` sagar.a.kamble
                               ` (4 more replies)
  0 siblings, 5 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch series introduces drm property modelled after glBlendFuc function. For i915
constant alpha is exposed through this property to start with. Additional new property
value for controlling pre-multiplied alpha is added.
i-g-t test case is to be added.

These patches are based on following patches which are already under review/reviewed:

4ae74f3 Documentation: drm: describing drm properties exposed by various drivers
134bdfe Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller.
a6ad21c Make drm_property_create_bitmask() a bit more generic by allowing the caller to specify which bits are in fact supported.

Sagar Kamble (4):
  drm: Added plane alpha and color blending property
  drm/i915: Enabling constant alpha drm property
  drm/i915: Enabling pre-multiplied alpha drm property
  Documentation: drm: describing plane alpha and color blending property

 Documentation/DocBook/drm.tmpl      |  13 +++-
 drivers/gpu/drm/drm_crtc.c          |  33 +++++++++
 drivers/gpu/drm/i915/i915_dma.c     |  11 ++-
 drivers/gpu/drm/i915/i915_drv.h     |   1 +
 drivers/gpu/drm/i915/i915_reg.h     |   2 +
 drivers/gpu/drm/i915/intel_drv.h    |   8 +++
 drivers/gpu/drm/i915/intel_sprite.c | 132 +++++++++++++++++++++++++++++++++++-
 include/drm/drm_crtc.h              |  25 +++++++
 8 files changed, 222 insertions(+), 3 deletions(-)

-- 
1.8.5

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH 1/4] drm: Added plane alpha and color blending property
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
@ 2014-03-08  8:21               ` sagar.a.kamble
  2014-03-08  8:21             ` [PATCH 2/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
                                 ` (3 subsequent siblings)
  4 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble, airlied, dri-devel, linux-kernel

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch creates a generic blending enum property.
Drivers may support subset of these values.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4e43fc2..15281a3 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	idr_destroy(&dev->mode_config.crtc_idr);
 }
 EXPORT_SYMBOL(drm_mode_config_cleanup);
+
+struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors)
+{
+	static const struct drm_prop_enum_list props[] = {
+		{ DRM_BLEND_NONE,   			"none" },
+		{ DRM_BLEND_ZERO,  			"zero" },
+		{ DRM_BLEND_ONE, 			"one" },
+		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
+		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
+		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
+		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
+		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
+		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
+		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
+		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
+		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" },
+		{ DRM_BLEND_SRC1_COLOR, 		"src1-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC1_COLOR, 	"one-minus-src1-color" },
+		{ DRM_BLEND_SRC1_ALPHA, 		"src1-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC1_ALPHA, 	"one-minus-src1-alpha" },
+		{ DRM_BLEND_PREMULTIPLIED_ALPHA, 	"pre-multiplied-alpha" }
+	};
+
+	return drm_property_create_bitmask(dev, 0, "blend",
+					   props, ARRAY_SIZE(props),
+					   supported_factors);
+}
+EXPORT_SYMBOL(drm_mode_create_blend_property);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 784a568..6c5847f 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,6 +65,29 @@ struct drm_object_properties {
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
 
+/* Blending property bits */
+#define DRM_BLEND_NONE				0
+#define DRM_BLEND_ZERO				1
+#define DRM_BLEND_ONE				2
+#define DRM_BLEND_SRC_COLOR			3
+#define DRM_BLEND_ONE_MINUS_SRC_COLOR		4
+#define DRM_BLEND_DST_COLOR			5
+#define DRM_BLEND_ONE_MINUS_DST_COLOR		6
+#define DRM_BLEND_SRC_ALPHA			7
+#define DRM_BLEND_ONE_MINUS_SRC_ALPHA		8
+#define DRM_BLEND_DST_ALPHA			9
+#define DRM_BLEND_ONE_MINUS_DST_ALPHA		10
+#define DRM_BLEND_CONSTANT_COLOR		11
+#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR	12
+#define DRM_BLEND_CONSTANT_ALPHA		13
+#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA	14
+#define DRM_BLEND_SRC_ALPHA_SATURATE		15
+#define DRM_BLEND_SRC1_COLOR			16
+#define DRM_BLEND_ONE_MINUS_SRC1_COLOR		17
+#define DRM_BLEND_SRC1_ALPHA			18
+#define DRM_BLEND_ONE_MINUS_SRC1_ALPHA		19
+#define DRM_BLEND_PREMULTIPLIED_ALPHA		20
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
@@ -1179,6 +1202,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
 extern const char *drm_get_format_name(uint32_t format);
+extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH 1/4] drm: Added plane alpha and color blending property
@ 2014-03-08  8:21               ` sagar.a.kamble
  0 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: airlied, Sagar Kamble, linux-kernel, dri-devel

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch creates a generic blending enum property.
Drivers may support subset of these values.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4e43fc2..15281a3 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	idr_destroy(&dev->mode_config.crtc_idr);
 }
 EXPORT_SYMBOL(drm_mode_config_cleanup);
+
+struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors)
+{
+	static const struct drm_prop_enum_list props[] = {
+		{ DRM_BLEND_NONE,   			"none" },
+		{ DRM_BLEND_ZERO,  			"zero" },
+		{ DRM_BLEND_ONE, 			"one" },
+		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
+		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
+		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
+		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
+		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
+		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
+		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
+		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
+		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" },
+		{ DRM_BLEND_SRC1_COLOR, 		"src1-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC1_COLOR, 	"one-minus-src1-color" },
+		{ DRM_BLEND_SRC1_ALPHA, 		"src1-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC1_ALPHA, 	"one-minus-src1-alpha" },
+		{ DRM_BLEND_PREMULTIPLIED_ALPHA, 	"pre-multiplied-alpha" }
+	};
+
+	return drm_property_create_bitmask(dev, 0, "blend",
+					   props, ARRAY_SIZE(props),
+					   supported_factors);
+}
+EXPORT_SYMBOL(drm_mode_create_blend_property);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 784a568..6c5847f 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,6 +65,29 @@ struct drm_object_properties {
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
 
+/* Blending property bits */
+#define DRM_BLEND_NONE				0
+#define DRM_BLEND_ZERO				1
+#define DRM_BLEND_ONE				2
+#define DRM_BLEND_SRC_COLOR			3
+#define DRM_BLEND_ONE_MINUS_SRC_COLOR		4
+#define DRM_BLEND_DST_COLOR			5
+#define DRM_BLEND_ONE_MINUS_DST_COLOR		6
+#define DRM_BLEND_SRC_ALPHA			7
+#define DRM_BLEND_ONE_MINUS_SRC_ALPHA		8
+#define DRM_BLEND_DST_ALPHA			9
+#define DRM_BLEND_ONE_MINUS_DST_ALPHA		10
+#define DRM_BLEND_CONSTANT_COLOR		11
+#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR	12
+#define DRM_BLEND_CONSTANT_ALPHA		13
+#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA	14
+#define DRM_BLEND_SRC_ALPHA_SATURATE		15
+#define DRM_BLEND_SRC1_COLOR			16
+#define DRM_BLEND_ONE_MINUS_SRC1_COLOR		17
+#define DRM_BLEND_SRC1_ALPHA			18
+#define DRM_BLEND_ONE_MINUS_SRC1_ALPHA		19
+#define DRM_BLEND_PREMULTIPLIED_ALPHA		20
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
@@ -1179,6 +1202,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
 extern const char *drm_get_format_name(uint32_t format);
+extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH 2/4] drm/i915: Enabling constant alpha drm property
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
  2014-03-08  8:21               ` sagar.a.kamble
@ 2014-03-08  8:21             ` sagar.a.kamble
  2014-03-20 13:51               ` Damien Lespiau
  2014-03-08  8:21             ` [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property sagar.a.kamble
                               ` (2 subsequent siblings)
  4 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: David Airlie, Daniel Vetter, Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch enables constant alpha property for Sprite planes.
Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | (8 bit alpha value)
for applying constant alpha on a plane. To disable constant alpha,
client has to set BIT(DRM_BLEND_NONE)

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c     | 11 ++++++-
 drivers/gpu/drm/i915/i915_drv.h     |  1 +
 drivers/gpu/drm/i915/i915_reg.h     |  2 ++
 drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
 drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
 5 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index e4d2b9f..286251d 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1897,13 +1897,22 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 void i915_driver_lastclose(struct drm_device * dev)
 {
 	drm_i915_private_t *dev_priv = dev->dev_private;
-
+	struct intel_plane *plane;
 	/* On gen6+ we refuse to init without kms enabled, but then the drm core
 	 * goes right around and calls lastclose. Check for this and don't clean
 	 * up anything. */
 	if (!dev_priv)
 		return;
 
+	if (dev_priv->blend_property) {
+		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
+			plane->blend_param.value = BIT(DRM_BLEND_NONE);
+			drm_object_property_set_value(&plane->base.base,
+						dev_priv->blend_property,
+						plane->blend_param.value);
+		}
+	}
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		intel_fbdev_restore_mode(dev);
 		vga_switcheroo_process_delayed_switch();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2a319ba..8a82fb7 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1604,6 +1604,7 @@ typedef struct drm_i915_private {
 
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
+	struct drm_property *blend_property;
 
 	uint32_t hw_context_size;
 	struct list_head context_list;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 146609a..292d55d 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3772,6 +3772,8 @@ enum punit_power_well {
 #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
 #define   SPRITE_TILED			(1<<10)
 #define   SPRITE_DEST_KEY		(1<<2)
+#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
+#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
 #define _SPRA_LINOFF		0x70284
 #define _SPRA_STRIDE		0x70288
 #define _SPRA_POS		0x7028c
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 4a4c6dd..e33124c 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -405,6 +405,13 @@ struct intel_plane {
 	unsigned int crtc_w, crtc_h;
 	uint32_t src_x, src_y;
 	uint32_t src_w, src_h;
+	union {
+		uint64_t value;
+		struct {
+			unsigned int type;
+			unsigned int factor;
+		} details;
+	} blend_param;
 
 	/* Since we need to change the watermarks before/after
 	 * enabling/disabling the planes, we need to store the parameters here
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 9436f18..4c3d2a2 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 	int pipe = intel_plane->pipe;
 	int plane = intel_plane->plane;
 	u32 sprctl;
+	u32 sprconstalpha;
+	unsigned int blend_type, blend_factor;
 	unsigned long sprsurf_offset, linear_offset;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
 
 	sprctl = I915_READ(SPCNTR(pipe, plane));
 
+	sprconstalpha = SPCONSTALPHA(pipe, plane);
+
 	/* Mask out pixel format bits in case we change it */
 	sprctl &= ~SP_PIXFORMAT_MASK;
 	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
@@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		break;
 	}
 
+	/* Handle plane alpha and color blending properties */
+	blend_type = intel_plane->blend_param.details.type;
+	blend_factor = intel_plane->blend_param.details.factor;
+
+	switch (blend_type) {
+	case DRM_BLEND_NONE:
+		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
+		break;
+	case DRM_BLEND_CONSTANT_ALPHA:
+		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
+						SPRITE_CONSTANT_ALPHA_ENABLE);
+		break;
+	default:
+		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
+		break;
+	}
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -1011,6 +1032,26 @@ out_unlock:
 	return ret;
 }
 
+static int intel_plane_set_property(struct drm_plane *plane,
+				    struct drm_property *prop,
+				    uint64_t val)
+{
+	struct drm_i915_private *dev_priv = plane->dev->dev_private;
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+	uint64_t old_val;
+	int ret = -ENOENT;
+
+	if (prop == dev_priv->blend_property) {
+		old_val = intel_plane->blend_param.value;
+		intel_plane->blend_param.value = val;
+		ret = intel_plane_restore(plane);
+		if (ret)
+			intel_plane->blend_param.value = old_val;
+	}
+
+	return ret;
+}
+
 int intel_plane_restore(struct drm_plane *plane)
 {
 	struct intel_plane *intel_plane = to_intel_plane(plane);
@@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = intel_update_plane,
 	.disable_plane = intel_disable_plane,
 	.destroy = intel_destroy_plane,
+	.set_property = intel_plane_set_property,
 };
 
 static uint32_t ilk_plane_formats[] = {
@@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_plane *intel_plane;
 	unsigned long possible_crtcs;
 	const uint32_t *plane_formats;
@@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
+	/* Initialize drm properties for plane */
+	intel_plane->blend_param.details.type = BIT(DRM_BLEND_NONE);
+	intel_plane->blend_param.details.factor = 0;
+
 	possible_crtcs = (1 << pipe);
 	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
 			     &intel_plane_funcs,
 			     plane_formats, num_plane_formats,
 			     false);
-	if (ret)
+	if (ret) {
 		kfree(intel_plane);
+		goto out;
+	}
+
+	if (!dev_priv->blend_property)
+		dev_priv->blend_property = drm_mode_create_blend_property(dev,
+							BIT(DRM_BLEND_NONE) |
+							BIT(DRM_BLEND_CONSTANT_ALPHA));
 
+	if (dev_priv->blend_property)
+		drm_object_attach_property(&intel_plane->base.base,
+				dev_priv->blend_property,
+				intel_plane->blend_param.value);
+out:
 	return ret;
 }
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
  2014-03-08  8:21               ` sagar.a.kamble
  2014-03-08  8:21             ` [PATCH 2/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
@ 2014-03-08  8:21             ` sagar.a.kamble
  2014-03-19 15:10               ` Damien Lespiau
  2014-03-08  8:21             ` [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
  2014-03-20 14:11             ` [PATCH 0/4] Adding support for plane alpha/color blending through drm property Damien Lespiau
  4 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: David Airlie, Daniel Vetter, Sagar Kamble, Srinivas, Vidya

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch enables property for changin the pixel format
of plane to enable/disable pre-multiplied alpha format.
Client has to set BIT(DRM_BLEND_PREMULTIPLIED_ALPHA) | 0x0/0x1
to disable/enable pre-multiplied alpha format.

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Srinivas, Vidya <vidya.srinivas@intel.com>
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h    |  1 +
 drivers/gpu/drm/i915/intel_sprite.c | 73 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index e33124c..44c366d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -685,6 +685,7 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
 enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
 					     enum pipe pipe);
 void intel_wait_for_vblank(struct drm_device *dev, int pipe);
+u32 control_premultiplied_alpha(u32 pixformat, unsigned int alpha);
 void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
 int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
 void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 4c3d2a2..183bd80 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -120,6 +120,10 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
 						SPRITE_CONSTANT_ALPHA_ENABLE);
 		break;
+	case DRM_BLEND_PREMULTIPLIED_ALPHA:
+		sprctl |= control_premultiplied_alpha(sprctl & SP_PIXFORMAT_MASK,
+						blend_factor);
+		break;
 	default:
 		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
 		break;
@@ -249,6 +253,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	int pipe = intel_plane->pipe;
 	u32 sprctl, sprscale = 0;
+	unsigned int blend_type, blend_factor;
 	unsigned long sprsurf_offset, linear_offset;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
 
@@ -283,6 +288,22 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		BUG();
 	}
 
+	/* Handle plane alpha and color blending properties */
+	blend_type = intel_plane->blend_param.details.type;
+	blend_factor = intel_plane->blend_param.details.factor;
+
+	switch (blend_type) {
+	case DRM_BLEND_NONE:
+		break;
+	case DRM_BLEND_PREMULTIPLIED_ALPHA:
+		sprctl |= control_premultiplied_alpha(sprctl & SPRITE_PIXFORMAT_MASK,
+						blend_factor);
+		break;
+	default:
+		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
+		break;
+	}
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -434,6 +455,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	int pipe = intel_plane->pipe;
 	unsigned long dvssurf_offset, linear_offset;
 	u32 dvscntr, dvsscale;
+	unsigned int blend_type, blend_factor;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
 
 	dvscntr = I915_READ(DVSCNTR(pipe));
@@ -467,6 +489,22 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		BUG();
 	}
 
+	/* Handle plane alpha and color blending properties */
+	blend_type = intel_plane->blend_param.details.type;
+	blend_factor = intel_plane->blend_param.details.factor;
+
+	switch (blend_type) {
+	case DRM_BLEND_NONE:
+		break;
+	case DRM_BLEND_PREMULTIPLIED_ALPHA:
+		dvscntr |= control_premultiplied_alpha(dvscntr & DVS_PIXFORMAT_MASK,
+					blend_factor);
+		break;
+	default:
+		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
+		break;
+	}
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -1112,6 +1150,38 @@ static uint32_t vlv_plane_formats[] = {
 	DRM_FORMAT_VYUY,
 };
 
+u32 control_premultiplied_alpha(u32 pixformat, unsigned int alpha)
+{
+	switch (pixformat) {
+	case DISPPLANE_RGBX888:
+	case DISPPLANE_RGBA888:
+		if (alpha)
+			pixformat = DISPPLANE_RGBA888;
+		else
+			pixformat = DISPPLANE_RGBX888;
+		break;
+	case DISPPLANE_BGRX888:
+	case DISPPLANE_BGRA888:
+		if (alpha)
+			pixformat = DISPPLANE_BGRA888;
+		else
+			pixformat = DISPPLANE_BGRX888;
+		break;
+	case DISPPLANE_RGBX101010:
+	case DISPPLANE_RGBA101010:
+		if (alpha)
+			pixformat = DISPPLANE_RGBA101010;
+		else
+			pixformat = DISPPLANE_RGBX101010;
+		break;
+	default:
+		if (alpha)
+			DRM_DEBUG_DRIVER("Pixel format 0x%08x does not support Alpha Control\n", pixformat);
+		break;
+	}
+	return pixformat;
+}
+
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
@@ -1201,7 +1271,8 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	if (!dev_priv->blend_property)
 		dev_priv->blend_property = drm_mode_create_blend_property(dev,
 							BIT(DRM_BLEND_NONE) |
-							BIT(DRM_BLEND_CONSTANT_ALPHA));
+							BIT(DRM_BLEND_CONSTANT_ALPHA) |
+							BIT(DRM_BLEND_PREMULTIPLIED_ALPHA));
 
 	if (dev_priv->blend_property)
 		drm_object_attach_property(&intel_plane->base.base,
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
                               ` (2 preceding siblings ...)
  2014-03-08  8:21             ` [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property sagar.a.kamble
@ 2014-03-08  8:21             ` sagar.a.kamble
  2014-03-10 14:43               ` Laurent Pinchart
  2014-03-20 14:11             ` [PATCH 0/4] Adding support for plane alpha/color blending through drm property Damien Lespiau
  4 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-08  8:21 UTC (permalink / raw)
  To: intel-gfx
  Cc: Laurent Pinchart, linux-doc, Daniel Vetter, dri-devel,
	Purushothaman, Vijay A, Rob Landley, Alex Deucher, Dave Airlie,
	Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

Cc: Rob Landley <rob@landley.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman@intel.com>
Cc: linux-doc@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 Documentation/DocBook/drm.tmpl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 5650d13..ba260e8 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2334,7 +2334,7 @@ void intel_crt_init(struct drm_device *dev)
 </tr>
 <tr>
 <td rowspan="19" valign="top" >DRM</td>
-<td rowspan="2" valign="top" >Generic</td>
+<td rowspan="3" valign="top" >Generic</td>
 <td valign="top" >“EDID”</td>
 <td valign="top" >BLOB | IMMUTABLE</td>
 <td valign="top" >0</td>
@@ -2349,6 +2349,17 @@ void intel_crt_init(struct drm_device *dev)
 <td valign="top" >Contains DPMS operation mode value.</td>
 </tr>
 <tr>
+<td valign="top" >“blend”</td>
+<td valign="top" >BITMASK</td>
+<td valign="top" >{ {0, "none"}, {1, "zero"}, {2, "one"}, {3, "src-color"}, {4, "one-minus-src-color"}
+, {5, "dst-color"}, {6, "one-minus-dst-color"}, {7, "src-alpha"}, {8, "one-minus-src-alpha"}, {9, "dst-alpha"}
+, {10, "one-minus-dst-alpha"}, {11, "constant-color"}, {12, "one-minus-constant-color"}, {13, "constant-alpha"}
+, {14, "one-minus-constant-alpha"}, {15, "alpha-saturate"}, {16, "src1-color"}, {17, "one-minus-src1-color"}
+, {18, "src1-alpha"}, {19, "one-minus-src1-alpha"}, {20, "pre-multiplied-alpha"} }</td>
+<td valign="top" >Plane</td>
+<td valign="top" >Contains plane alpha/color blending operation value.</td>
+</tr>
+<tr>
 <td rowspan="2" valign="top" >DVI-I</td>
 <td valign="top" >“subconnector”</td>
 <td valign="top" >ENUM</td>
-- 
1.8.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property
  2014-03-08  8:21             ` [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
@ 2014-03-10 14:43               ` Laurent Pinchart
  0 siblings, 0 replies; 53+ messages in thread
From: Laurent Pinchart @ 2014-03-10 14:43 UTC (permalink / raw)
  To: dri-devel
  Cc: Laurent Pinchart, linux-doc, Daniel Vetter, intel-gfx,
	Rob Landley, Alex Deucher, Dave Airlie, sagar.a.kamble

Hi Sagar,

Thank you for the patch.

On Saturday 08 March 2014 13:51:19 sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> Cc: Rob Landley <rob@landley.net>
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
> Cc: Sagar Kamble <sagar.a.kamble@intel.com>
> Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman@intel.com>
> Cc: linux-doc@vger.kernel.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  Documentation/DocBook/drm.tmpl | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 5650d13..ba260e8 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2334,7 +2334,7 @@ void intel_crt_init(struct drm_device *dev)
>  </tr>
>  <tr>
>  <td rowspan="19" valign="top" >DRM</td>
> -<td rowspan="2" valign="top" >Generic</td>
> +<td rowspan="3" valign="top" >Generic</td>
>  <td valign="top" >“EDID”</td>
>  <td valign="top" >BLOB | IMMUTABLE</td>
>  <td valign="top" >0</td>
> @@ -2349,6 +2349,17 @@ void intel_crt_init(struct drm_device *dev)
>  <td valign="top" >Contains DPMS operation mode value.</td>
>  </tr>
>  <tr>
> +<td valign="top" >“blend”</td>
> +<td valign="top" >BITMASK</td>
> +<td valign="top" >{ {0, "none"}, {1, "zero"}, {2, "one"}, {3, "src-color"},
> {4, "one-minus-src-color"} +, {5, "dst-color"}, {6, "one-minus-dst-color"},
> {7, "src-alpha"}, {8, "one-minus-src-alpha"}, {9, "dst-alpha"} +, {10,
> "one-minus-dst-alpha"}, {11, "constant-color"}, {12,
> "one-minus-constant-color"}, {13, "constant-alpha"} +, {14,
> "one-minus-constant-alpha"}, {15, "alpha-saturate"}, {16, "src1-color"},
> {17, "one-minus-src1-color"} +, {18, "src1-alpha"}, {19,
> "one-minus-src1-alpha"}, {20, "pre-multiplied-alpha"} }</td> +<td
> valign="top" >Plane</td>
> +<td valign="top" >Contains plane alpha/color blending operation value.</td>

I believe this calls for a description of each property value. From patches 
1/4 and 4/4 it's not entirely clear to me what all values mean.

> +</tr>
> +<tr>
>  <td rowspan="2" valign="top" >DVI-I</td>
>  <td valign="top" >“subconnector”</td>
>  <td valign="top" >ENUM</td>

-- 
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-08  8:21             ` [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property sagar.a.kamble
@ 2014-03-19 15:10               ` Damien Lespiau
  2014-03-20  9:59                 ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-19 15:10 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: David Airlie, Daniel Vetter, intel-gfx, Srinivas, Vidya

On Sat, Mar 08, 2014 at 01:51:18PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch enables property for changin the pixel format
> of plane to enable/disable pre-multiplied alpha format.
> Client has to set BIT(DRM_BLEND_PREMULTIPLIED_ALPHA) | 0x0/0x1
> to disable/enable pre-multiplied alpha format.
> 
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: David Airlie <airlied@linux.ie>
> Signed-off-by: Srinivas, Vidya <vidya.srinivas@intel.com>
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>

Huum, the alpha being premultiplied or not seems to be a property of the
framebuffer to me, not of the plane. It seems to me that we should
define alternative premultiplied DRM_FORMATs and make the sprite planes
advertise support for premultiplied fbs in the format list when the
hardware indeed supports them.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-19 15:10               ` Damien Lespiau
@ 2014-03-20  9:59                 ` Sagar Arun Kamble
  2014-03-20 11:38                   ` Damien Lespiau
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-03-20  9:59 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: David Airlie, Daniel Vetter, intel-gfx, Srinivas, Vidya

Hi Damien,

On Wed, 2014-03-19 at 15:10 +0000, Damien Lespiau wrote:
> On Sat, Mar 08, 2014 at 01:51:18PM +0530, sagar.a.kamble@intel.com wrote:
> > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > 
> > This patch enables property for changin the pixel format
> > of plane to enable/disable pre-multiplied alpha format.
> > Client has to set BIT(DRM_BLEND_PREMULTIPLIED_ALPHA) | 0x0/0x1
> > to disable/enable pre-multiplied alpha format.
> > 
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: David Airlie <airlied@linux.ie>
> > Signed-off-by: Srinivas, Vidya <vidya.srinivas@intel.com>
> > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> Huum, the alpha being premultiplied or not seems to be a property of the
> framebuffer to me, not of the plane. It seems to me that we should
> define alternative premultiplied DRM_FORMATs and make the sprite planes
> advertise support for premultiplied fbs in the format list when the
> hardware indeed supports them.
This is what i think of usage of this property:

Composer/user mode starts using plane with XRGB format and then it wants
to add transparency to the plane. So it will set the format to ARGB
format and provide buffer for that plane that will have pixels with
pre-multiplied alpha (a*r, a*g, a*b, a).
This can be done with primary plane(CRTC) as well, however I have 
not added this as CRTC property since CRTCs are going to be drm_plane
soon.

Will this kind of interface for usermode to toggle the pixel format's
alpha be useful?

Thanks,
Sagar

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-20  9:59                 ` Sagar Arun Kamble
@ 2014-03-20 11:38                   ` Damien Lespiau
  2014-03-20 13:51                     ` Daniel Vetter
  0 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 11:38 UTC (permalink / raw)
  To: Sagar Arun Kamble; +Cc: David Airlie, Daniel Vetter, intel-gfx, Srinivas, Vidya

On Thu, Mar 20, 2014 at 03:29:42PM +0530, Sagar Arun Kamble wrote:
> Hi Damien,
> 
> On Wed, 2014-03-19 at 15:10 +0000, Damien Lespiau wrote:
> > On Sat, Mar 08, 2014 at 01:51:18PM +0530, sagar.a.kamble@intel.com wrote:
> > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > 
> > > This patch enables property for changin the pixel format
> > > of plane to enable/disable pre-multiplied alpha format.
> > > Client has to set BIT(DRM_BLEND_PREMULTIPLIED_ALPHA) | 0x0/0x1
> > > to disable/enable pre-multiplied alpha format.
> > > 
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > Cc: David Airlie <airlied@linux.ie>
> > > Signed-off-by: Srinivas, Vidya <vidya.srinivas@intel.com>
> > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > 
> > Huum, the alpha being premultiplied or not seems to be a property of the
> > framebuffer to me, not of the plane. It seems to me that we should
> > define alternative premultiplied DRM_FORMATs and make the sprite planes
> > advertise support for premultiplied fbs in the format list when the
> > hardware indeed supports them.
> This is what i think of usage of this property:
> 
> Composer/user mode starts using plane with XRGB format and then it wants
> to add transparency to the plane. So it will set the format to ARGB
> format and provide buffer for that plane that will have pixels with
> pre-multiplied alpha (a*r, a*g, a*b, a).
> This can be done with primary plane(CRTC) as well, however I have 
> not added this as CRTC property since CRTCs are going to be drm_plane
> soon.
> 
> Will this kind of interface for usermode to toggle the pixel format's
> alpha be useful?

I don't think so, nop.

Besides being a convoluted apocalyptic scenario, one cannot simply
change the format of the FB without re-adding it with AddFB2().

There's a usage model for the compositor to add a plane-global alpha to
a plane (fades the client provided render target) and that's indeed a
plane property.

As far I as can tell, the premultiplied alpha format ban be sued support
scanning out OpenGL blended fbs.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Intel-gfx] [PATCH 1/4] drm: Added plane alpha and color blending property
  2014-03-08  8:21               ` sagar.a.kamble
@ 2014-03-20 11:58                 ` Damien Lespiau
  -1 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 11:58 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: intel-gfx, airlied, linux-kernel, dri-devel

On Sat, Mar 08, 2014 at 01:51:16PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch creates a generic blending enum property.
> Drivers may support subset of these values.
> 
> Cc: airlied@linux.ie
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
>  2 files changed, 58 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4e43fc2..15281a3 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev)
>  	idr_destroy(&dev->mode_config.crtc_idr);
>  }
>  EXPORT_SYMBOL(drm_mode_config_cleanup);
> +
> +struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
> +				unsigned int supported_factors)
> +{
> +	static const struct drm_prop_enum_list props[] = {
> +		{ DRM_BLEND_NONE,   			"none" },
> +		{ DRM_BLEND_ZERO,  			"zero" },
> +		{ DRM_BLEND_ONE, 			"one" },
> +		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
> +		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
> +		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
> +		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
> +		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
> +		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
> +		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
> +		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" },
> +		{ DRM_BLEND_SRC1_COLOR, 		"src1-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_COLOR, 	"one-minus-src1-color" },
> +		{ DRM_BLEND_SRC1_ALPHA, 		"src1-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_ALPHA, 	"one-minus-src1-alpha" },
> +		{ DRM_BLEND_PREMULTIPLIED_ALPHA, 	"pre-multiplied-alpha" }

Again, whether the fbs are premultipled or not is orthogonal to how we
want to blend the plane. I still think it'd be better to add
premultiplied fb DRM formats.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 1/4] drm: Added plane alpha and color blending property
@ 2014-03-20 11:58                 ` Damien Lespiau
  0 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 11:58 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: airlied, intel-gfx, linux-kernel, dri-devel

On Sat, Mar 08, 2014 at 01:51:16PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch creates a generic blending enum property.
> Drivers may support subset of these values.
> 
> Cc: airlied@linux.ie
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
>  2 files changed, 58 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4e43fc2..15281a3 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev)
>  	idr_destroy(&dev->mode_config.crtc_idr);
>  }
>  EXPORT_SYMBOL(drm_mode_config_cleanup);
> +
> +struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
> +				unsigned int supported_factors)
> +{
> +	static const struct drm_prop_enum_list props[] = {
> +		{ DRM_BLEND_NONE,   			"none" },
> +		{ DRM_BLEND_ZERO,  			"zero" },
> +		{ DRM_BLEND_ONE, 			"one" },
> +		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
> +		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
> +		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
> +		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
> +		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
> +		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
> +		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
> +		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" },
> +		{ DRM_BLEND_SRC1_COLOR, 		"src1-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_COLOR, 	"one-minus-src1-color" },
> +		{ DRM_BLEND_SRC1_ALPHA, 		"src1-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_ALPHA, 	"one-minus-src1-alpha" },
> +		{ DRM_BLEND_PREMULTIPLIED_ALPHA, 	"pre-multiplied-alpha" }

Again, whether the fbs are premultipled or not is orthogonal to how we
want to blend the plane. I still think it'd be better to add
premultiplied fb DRM formats.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-20 11:38                   ` Damien Lespiau
@ 2014-03-20 13:51                     ` Daniel Vetter
  2014-03-20 14:00                       ` Damien Lespiau
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-03-20 13:51 UTC (permalink / raw)
  To: Damien Lespiau
  Cc: Srinivas, Vidya, David Airlie, Daniel Vetter, intel-gfx,
	Sagar Arun Kamble

On Thu, Mar 20, 2014 at 11:38:18AM +0000, Damien Lespiau wrote:
> On Thu, Mar 20, 2014 at 03:29:42PM +0530, Sagar Arun Kamble wrote:
> > Hi Damien,
> > 
> > On Wed, 2014-03-19 at 15:10 +0000, Damien Lespiau wrote:
> > > On Sat, Mar 08, 2014 at 01:51:18PM +0530, sagar.a.kamble@intel.com wrote:
> > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > 
> > > > This patch enables property for changin the pixel format
> > > > of plane to enable/disable pre-multiplied alpha format.
> > > > Client has to set BIT(DRM_BLEND_PREMULTIPLIED_ALPHA) | 0x0/0x1
> > > > to disable/enable pre-multiplied alpha format.
> > > > 
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > Cc: David Airlie <airlied@linux.ie>
> > > > Signed-off-by: Srinivas, Vidya <vidya.srinivas@intel.com>
> > > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > 
> > > Huum, the alpha being premultiplied or not seems to be a property of the
> > > framebuffer to me, not of the plane. It seems to me that we should
> > > define alternative premultiplied DRM_FORMATs and make the sprite planes
> > > advertise support for premultiplied fbs in the format list when the
> > > hardware indeed supports them.
> > This is what i think of usage of this property:
> > 
> > Composer/user mode starts using plane with XRGB format and then it wants
> > to add transparency to the plane. So it will set the format to ARGB
> > format and provide buffer for that plane that will have pixels with
> > pre-multiplied alpha (a*r, a*g, a*b, a).
> > This can be done with primary plane(CRTC) as well, however I have 
> > not added this as CRTC property since CRTCs are going to be drm_plane
> > soon.
> > 
> > Will this kind of interface for usermode to toggle the pixel format's
> > alpha be useful?
> 
> I don't think so, nop.
> 
> Besides being a convoluted apocalyptic scenario, one cannot simply
> change the format of the FB without re-adding it with AddFB2().
> 
> There's a usage model for the compositor to add a plane-global alpha to
> a plane (fades the client provided render target) and that's indeed a
> plane property.
> 
> As far I as can tell, the premultiplied alpha format ban be sued support
> scanning out OpenGL blended fbs.

I'm not sure I follow this discussion completely, but in my opinion may
_never_ change the pixel format of a drm framebuffer object.

Think of a drm framebuffer as a view of the underlying object(s) with
strides, pixel format, dimensions and other stuff specified. If you need a
different view, simply create a new drm framebuffer object.

Note that drm framebuffer objects are never shared (as opposed to the
underlying gem backing storage which can be shared with flink or dma-buf),
so this doesn't need any synchronization outside of the compositor itself.

I don't really have a decent opinion on the pre-multiplied vs
non-premultiplied ARGB formats issue at hand. In case of doubt I think we
should follow what gl does. But I have no clue how that's handled in gl
;-)

And maybe I'm completely missing the point here ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 2/4] drm/i915: Enabling constant alpha drm property
  2014-03-08  8:21             ` [PATCH 2/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
@ 2014-03-20 13:51               ` Damien Lespiau
  2014-03-25 14:32                   ` sagar.a.kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 13:51 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: David Airlie, Daniel Vetter, intel-gfx

On Sat, Mar 08, 2014 at 01:51:17PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch enables constant alpha property for Sprite planes.
> Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | (8 bit alpha value)
> for applying constant alpha on a plane. To disable constant alpha,
> client has to set BIT(DRM_BLEND_NONE)
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: David Airlie <airlied@linux.ie>

No need to Cc David on i915 patches, let's spare him from now on.

> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_dma.c     | 11 ++++++-
>  drivers/gpu/drm/i915/i915_drv.h     |  1 +
>  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
>  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
>  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
>  5 files changed, 80 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index e4d2b9f..286251d 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1897,13 +1897,22 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
>  void i915_driver_lastclose(struct drm_device * dev)
>  {
>  	drm_i915_private_t *dev_priv = dev->dev_private;
> -
> +	struct intel_plane *plane;
>  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
>  	 * goes right around and calls lastclose. Check for this and don't clean
>  	 * up anything. */

Why are you removing the new line between the variable declaration and
the comment?

>  	if (!dev_priv)
>  		return;
>  
> +	if (dev_priv->blend_property) {
> +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> +			plane->blend_param.value = BIT(DRM_BLEND_NONE);
> +			drm_object_property_set_value(&plane->base.base,
> +						dev_priv->blend_property,
> +						plane->blend_param.value);
> +		}
> +	}
> +
>  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		intel_fbdev_restore_mode(dev);
>  		vga_switcheroo_process_delayed_switch();
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 2a319ba..8a82fb7 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1604,6 +1604,7 @@ typedef struct drm_i915_private {
>  
>  	struct drm_property *broadcast_rgb_property;
>  	struct drm_property *force_audio_property;
> +	struct drm_property *blend_property;
>  
>  	uint32_t hw_context_size;
>  	struct list_head context_list;
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 146609a..292d55d 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -3772,6 +3772,8 @@ enum punit_power_well {
>  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
>  #define   SPRITE_TILED			(1<<10)
>  #define   SPRITE_DEST_KEY		(1<<2)
> +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
>  #define _SPRA_LINOFF		0x70284
>  #define _SPRA_STRIDE		0x70288
>  #define _SPRA_POS		0x7028c
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 4a4c6dd..e33124c 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -405,6 +405,13 @@ struct intel_plane {
>  	unsigned int crtc_w, crtc_h;
>  	uint32_t src_x, src_y;
>  	uint32_t src_w, src_h;
> +	union {
> +		uint64_t value;
> +		struct {
> +			unsigned int type;
> +			unsigned int factor;
> +		} details;
> +	} blend_param;
>  
>  	/* Since we need to change the watermarks before/after
>  	 * enabling/disabling the planes, we need to store the parameters here
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 9436f18..4c3d2a2 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  	int pipe = intel_plane->pipe;
>  	int plane = intel_plane->plane;
>  	u32 sprctl;
> +	u32 sprconstalpha;
> +	unsigned int blend_type, blend_factor;
>  	unsigned long sprsurf_offset, linear_offset;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>  
>  	sprctl = I915_READ(SPCNTR(pipe, plane));
>  
> +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> +
>  	/* Mask out pixel format bits in case we change it */
>  	sprctl &= ~SP_PIXFORMAT_MASK;
>  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  		break;
>  	}
>  
> +	/* Handle plane alpha and color blending properties */
> +	blend_type = intel_plane->blend_param.details.type;
> +	blend_factor = intel_plane->blend_param.details.factor;
> +
> +	switch (blend_type) {
> +	case DRM_BLEND_NONE:
> +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> +		break;
> +	case DRM_BLEND_CONSTANT_ALPHA:
> +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> +						SPRITE_CONSTANT_ALPHA_ENABLE);
> +		break;
> +	default:
> +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> +		break;
> +	}
> +
>  	/*
>  	 * Enable gamma to match primary/cursor plane behaviour.
>  	 * FIXME should be user controllable via propertiesa.
> @@ -1011,6 +1032,26 @@ out_unlock:
>  	return ret;
>  }
>  
> +static int intel_plane_set_property(struct drm_plane *plane,
> +				    struct drm_property *prop,
> +				    uint64_t val)
> +{
> +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> +	struct intel_plane *intel_plane = to_intel_plane(plane);
> +	uint64_t old_val;
> +	int ret = -ENOENT;

This should be -EINVAL. This existing API is to return -EINVAL, see:

static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
                                      struct drm_property *property,
                                      uint64_t value)
{
        int ret = -EINVAL;
...

Let's no introduce something different.

> +
> +	if (prop == dev_priv->blend_property) {
> +		old_val = intel_plane->blend_param.value;
> +		intel_plane->blend_param.value = val;
> +		ret = intel_plane_restore(plane);
> +		if (ret)
> +			intel_plane->blend_param.value = old_val;
> +	}
> +
> +	return ret;
> +}
> +
>  int intel_plane_restore(struct drm_plane *plane)
>  {
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
> @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
>  	.update_plane = intel_update_plane,
>  	.disable_plane = intel_disable_plane,
>  	.destroy = intel_destroy_plane,
> +	.set_property = intel_plane_set_property,
>  };
>  
>  static uint32_t ilk_plane_formats[] = {
> @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
>  int
>  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  {
> +	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_plane *intel_plane;
>  	unsigned long possible_crtcs;
>  	const uint32_t *plane_formats;
> @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  
>  	intel_plane->pipe = pipe;
>  	intel_plane->plane = plane;
> +	/* Initialize drm properties for plane */
> +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_NONE);
> +	intel_plane->blend_param.details.factor = 0;
> +
>  	possible_crtcs = (1 << pipe);
>  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
>  			     &intel_plane_funcs,
>  			     plane_formats, num_plane_formats,
>  			     false);
> -	if (ret)
> +	if (ret) {
>  		kfree(intel_plane);
> +		goto out;
> +	}
> +
> +	if (!dev_priv->blend_property)
> +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> +							BIT(DRM_BLEND_NONE) |
> +							BIT(DRM_BLEND_CONSTANT_ALPHA));
>  
> +	if (dev_priv->blend_property)
> +		drm_object_attach_property(&intel_plane->base.base,
> +				dev_priv->blend_property,
> +				intel_plane->blend_param.value);
> +out:
>  	return ret;
>  }
> -- 
> 1.8.5
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property
  2014-03-20 13:51                     ` Daniel Vetter
@ 2014-03-20 14:00                       ` Damien Lespiau
  0 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 14:00 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Srinivas, Vidya, David Airlie, Daniel Vetter, intel-gfx,
	Sagar Arun Kamble

On Thu, Mar 20, 2014 at 02:51:20PM +0100, Daniel Vetter wrote:
> I don't really have a decent opinion on the pre-multiplied vs
> non-premultiplied ARGB formats issue at hand. In case of doubt I think we
> should follow what gl does. But I have no clue how that's handled in gl
> ;-)
 
I'd still like a premultipled DRM format, but let's wait for Ville
opinion.

In GL, the blending equation doesn't do anything automatically. So if
you have a premultiplied source, you need to setup the blending
function/factor accordingly.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
                               ` (3 preceding siblings ...)
  2014-03-08  8:21             ` [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
@ 2014-03-20 14:11             ` Damien Lespiau
  2014-03-20 14:45               ` Damien Lespiau
  4 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 14:11 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: intel-gfx

On Sat, Mar 08, 2014 at 01:51:15PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch series introduces drm property modelled after glBlendFuc function. For i915
> constant alpha is exposed through this property to start with. Additional new property
> value for controlling pre-multiplied alpha is added.
> i-g-t test case is to be added.
> 
> These patches are based on following patches which are already under review/reviewed:
> 
> 4ae74f3 Documentation: drm: describing drm properties exposed by various drivers
> 134bdfe Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller.
> a6ad21c Make drm_property_create_bitmask() a bit more generic by allowing the caller to specify which bits are in fact supported.
> 
> Sagar Kamble (4):
>   drm: Added plane alpha and color blending property
>   drm/i915: Enabling constant alpha drm property
>   drm/i915: Enabling pre-multiplied alpha drm property
>   Documentation: drm: describing plane alpha and color blending property

I'm not sure I follow what's being done with the GL blending equation
here. If we want to support a global alpha on the source plane (ie the
plane that is going to be blended into the "render target", what's
already there), the blending equation looks like:

(source is non-premultiplied, note the use of glBlendFuncSeparate())

RGB = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
A   = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)

(source is premultiplied)

RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)

The gl blending stuff doesn't know anything about the premultiplied
nature of the incoming source color, it has to be programmed
accordingly.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [Intel-gfx] [PATCH 1/4] drm: Added plane alpha and color blending property
  2014-03-08  8:21               ` sagar.a.kamble
  (?)
  (?)
@ 2014-03-20 14:21               ` Damien Lespiau
  -1 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 14:21 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: intel-gfx, airlied, linux-kernel, dri-devel

On Sat, Mar 08, 2014 at 01:51:16PM +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch creates a generic blending enum property.
> Drivers may support subset of these values.
> 
> Cc: airlied@linux.ie
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
>  2 files changed, 58 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4e43fc2..15281a3 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -4147,3 +4147,36 @@ void drm_mode_config_cleanup(struct drm_device *dev)
>  	idr_destroy(&dev->mode_config.crtc_idr);
>  }
>  EXPORT_SYMBOL(drm_mode_config_cleanup);
> +
> +struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
> +				unsigned int supported_factors)
> +{
> +	static const struct drm_prop_enum_list props[] = {
> +		{ DRM_BLEND_NONE,   			"none" },
> +		{ DRM_BLEND_ZERO,  			"zero" },
> +		{ DRM_BLEND_ONE, 			"one" },
> +		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
> +		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
> +		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
> +		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
> +		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
> +		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
> +		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
> +		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" },
> +		{ DRM_BLEND_SRC1_COLOR, 		"src1-color" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_COLOR, 	"one-minus-src1-color" },
> +		{ DRM_BLEND_SRC1_ALPHA, 		"src1-alpha" },
> +		{ DRM_BLEND_ONE_MINUS_SRC1_ALPHA, 	"one-minus-src1-alpha" },
> +		{ DRM_BLEND_PREMULTIPLIED_ALPHA, 	"pre-multiplied-alpha" }
> +	};

Another few notes:

- You seem to assume that there's a need for DRM_BLEND_NONE, what would it
do? The property should default to DRM_BLEND_SRC_COLOR ie "Take the
color from this plane for the blending".

- There's no need to expose SRC1 variants, this was done in GL to expose a
second color the fragment shader can output, not applicable here.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-20 14:11             ` [PATCH 0/4] Adding support for plane alpha/color blending through drm property Damien Lespiau
@ 2014-03-20 14:45               ` Damien Lespiau
  2014-03-21 13:36                 ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-20 14:45 UTC (permalink / raw)
  To: sagar.a.kamble; +Cc: intel-gfx

On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> (source is premultiplied)
> 
> RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)

Grr, copy/paste error. If the source is already premultiplied:

RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-20 14:45               ` Damien Lespiau
@ 2014-03-21 13:36                 ` Sagar Arun Kamble
  2014-03-21 19:23                   ` Damien Lespiau
  2014-03-25 10:03                   ` Sagar Arun Kamble
  0 siblings, 2 replies; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-03-21 13:36 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx

Hi Damien,

On Thu, 2014-03-20 at 14:45 +0000, Damien Lespiau wrote:
> On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> > (source is premultiplied)
> > 
> > RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> 
> Grr, copy/paste error. If the source is already premultiplied:
> 
> RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> 

1. Currently there is no interface to advertise the DRM_FORMATS plane
supportes to user mode? Should we add new IOCTL for that and include
pre-multiplied alpha formats while advertising? Or am I missing any such
API already available?

2. About constant alpha property - when we program constant alpha
register will hardware be able to take care of the blending as per
equations you have specified for non-premultiplied-alpha and
premultiplied-alpha cases or we have to do any additional setting?
Confusion is because of two combinations:
a. pre-multiplied alpha+constant alpha
b. non-pre-multiplied alpha+constant alpha

Kindly clarify.

thanks,
Sagar

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-21 13:36                 ` Sagar Arun Kamble
@ 2014-03-21 19:23                   ` Damien Lespiau
  2014-04-02 19:36                     ` Ville Syrjälä
  2014-03-25 10:03                   ` Sagar Arun Kamble
  1 sibling, 1 reply; 53+ messages in thread
From: Damien Lespiau @ 2014-03-21 19:23 UTC (permalink / raw)
  To: Akash Goel, Daniel Vetter, ville.syrjala; +Cc: intel-gfx

On Fri, Mar 21, 2014 at 07:06:46PM +0530, Sagar Arun Kamble wrote:
> Hi Damien,
> 
> On Thu, 2014-03-20 at 14:45 +0000, Damien Lespiau wrote:
> > On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> > > (source is premultiplied)
> > > 
> > > RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > 
> > Grr, copy/paste error. If the source is already premultiplied:
> > 
> > RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > 
> 
> 1. Currently there is no interface to advertise the DRM_FORMATS plane
> supportes to user mode? Should we add new IOCTL for that and include
> pre-multiplied alpha formats while advertising? Or am I missing any such
> API already available?

There's a 'formats' array in drmModePlane.

> 2. About constant alpha property - when we program constant alpha
> register will hardware be able to take care of the blending as per
> equations you have specified for non-premultiplied-alpha and
> premultiplied-alpha cases or we have to do any additional setting?
> Confusion is because of two combinations:
> a. pre-multiplied alpha+constant alpha
> b. non-pre-multiplied alpha+constant alpha

The first part of the question should be in the spec. I really do expect
the hw to work correctly with any combination of (premul, non-premult) x
(plane alpha, no plane alpha)

To be more clear: I don't think the glBlendFunc constants can represent
everything we want:

- It'd need to differentiate what we want do to between RGB and A (the
  same reason glBlendFuncSeparate was introduced).

- We can't represent blending of an unpremultied fb with a plane-global
  alpha with just the GL blending equation as it needs two
  multiplications (so in GL, you would do one of them in the fragment
  shader).

I would just proceed with a premultipled FB format and the alpha plane
property.

Let's wait until Ville returns, I may be totally not getting what he
meant.

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-21 13:36                 ` Sagar Arun Kamble
  2014-03-21 19:23                   ` Damien Lespiau
@ 2014-03-25 10:03                   ` Sagar Arun Kamble
  2014-03-25 10:51                     ` Daniel Vetter
  1 sibling, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-03-25 10:03 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx

Hi Damien,

Could you please clarify following queries.

Thanks,
Sagar
On Fri, 2014-03-21 at 19:06 +0530, Sagar Arun Kamble wrote:
> Hi Damien,
> 
> On Thu, 2014-03-20 at 14:45 +0000, Damien Lespiau wrote:
> > On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> > > (source is premultiplied)
> > > 
> > > RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > 
> > Grr, copy/paste error. If the source is already premultiplied:
> > 
> > RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > 
> 
> 1. Currently there is no interface to advertise the DRM_FORMATS plane
> supportes to user mode? Should we add new IOCTL for that and include
> pre-multiplied alpha formats while advertising? Or am I missing any such
> API already available?
> 
> 2. About constant alpha property - when we program constant alpha
> register will hardware be able to take care of the blending as per
> equations you have specified for non-premultiplied-alpha and
> premultiplied-alpha cases or we have to do any additional setting?
> Confusion is because of two combinations:
> a. pre-multiplied alpha+constant alpha
> b. non-pre-multiplied alpha+constant alpha
> 
> Kindly clarify.
> 
> thanks,
> Sagar
> 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-25 10:03                   ` Sagar Arun Kamble
@ 2014-03-25 10:51                     ` Daniel Vetter
  2014-03-25 12:26                       ` Damien Lespiau
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-03-25 10:51 UTC (permalink / raw)
  To: Sagar Arun Kamble; +Cc: intel-gfx

On Tue, Mar 25, 2014 at 03:33:42PM +0530, Sagar Arun Kamble wrote:
> Hi Damien,
> 
> Could you please clarify following queries.

He did, in a reply to your mail ...
-Daniel

> 
> Thanks,
> Sagar
> On Fri, 2014-03-21 at 19:06 +0530, Sagar Arun Kamble wrote:
> > Hi Damien,
> > 
> > On Thu, 2014-03-20 at 14:45 +0000, Damien Lespiau wrote:
> > > On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> > > > (source is premultiplied)
> > > > 
> > > > RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > > 
> > > Grr, copy/paste error. If the source is already premultiplied:
> > > 
> > > RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > > 
> > 
> > 1. Currently there is no interface to advertise the DRM_FORMATS plane
> > supportes to user mode? Should we add new IOCTL for that and include
> > pre-multiplied alpha formats while advertising? Or am I missing any such
> > API already available?
> > 
> > 2. About constant alpha property - when we program constant alpha
> > register will hardware be able to take care of the blending as per
> > equations you have specified for non-premultiplied-alpha and
> > premultiplied-alpha cases or we have to do any additional setting?
> > Confusion is because of two combinations:
> > a. pre-multiplied alpha+constant alpha
> > b. non-pre-multiplied alpha+constant alpha
> > 
> > Kindly clarify.
> > 
> > thanks,
> > Sagar
> > 
> > 
> 
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-25 10:51                     ` Daniel Vetter
@ 2014-03-25 12:26                       ` Damien Lespiau
  0 siblings, 0 replies; 53+ messages in thread
From: Damien Lespiau @ 2014-03-25 12:26 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx, Sagar Arun Kamble

On Tue, Mar 25, 2014 at 11:51:57AM +0100, Daniel Vetter wrote:
> On Tue, Mar 25, 2014 at 03:33:42PM +0530, Sagar Arun Kamble wrote:
> > Hi Damien,
> > 
> > Could you please clarify following queries.
> 
> He did, in a reply to your mail ...

In case you cannot find it:

  http://lists.freedesktop.org/archives/intel-gfx/2014-March/042136.html

-- 
Damien

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair
  2014-03-20 13:51               ` Damien Lespiau
@ 2014-03-25 14:32                   ` sagar.a.kamble
  0 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble, airlied, dri-devel, linux-kernel

From: Sagar Kamble <sagar.a.kamble@intel.com>

With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use
of 64 bit value of bitmask property as two 32 bit values.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
 include/uapi/drm/drm_mode.h |  3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4e43fc2..d0d03ec 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index,
 
 	/*
 	 * Bitmask enum properties have the additional constraint of values
-	 * from 0 to 63
+	 * from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint
+	 * range is 0 to 31.
 	 */
-	if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
-		return -EINVAL;
+	if (property->flags & DRM_MODE_PROP_BITMASK)
+		if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) ||
+		    (value > 63))
+			return -EINVAL;
 
 	if (!list_empty(&property->enum_blob_list)) {
 		list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
@@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property,
 	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
 		int i;
 		uint64_t valid_mask = 0;
-		for (i = 0; i < property->num_values; i++)
-			valid_mask |= (1ULL << property->values[i]);
-		return !(value & ~valid_mask);
+		uint32_t valid_32bit_mask = 0;
+		if (property->flags & DRM_MODE_PROP_32BIT_PAIR) {
+			for (i = 0; i < property->num_values; i++)
+				valid_32bit_mask |= (1UL << property->values[i]);
+			return !((value & 0xFFFFFFFF) & ~valid_32bit_mask);
+		} else {
+			for (i = 0; i < property->num_values; i++)
+				valid_mask |= (1ULL << property->values[i]);
+			return !(value & ~valid_mask);
+		}
 	} else if (property->flags & DRM_MODE_PROP_BLOB) {
 		/* Only the driver knows */
 		return true;
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index f104c26..5e3a7d9 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -250,6 +250,9 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
 #define DRM_MODE_PROP_BLOB	(1<<4)
 #define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
+#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types
+					 * and 32 bit of value of the type */
+
 
 struct drm_mode_property_enum {
 	__u64 value;
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair
@ 2014-03-25 14:32                   ` sagar.a.kamble
  0 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: airlied, Sagar Kamble, linux-kernel, dri-devel

From: Sagar Kamble <sagar.a.kamble@intel.com>

With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use
of 64 bit value of bitmask property as two 32 bit values.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
 include/uapi/drm/drm_mode.h |  3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4e43fc2..d0d03ec 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index,
 
 	/*
 	 * Bitmask enum properties have the additional constraint of values
-	 * from 0 to 63
+	 * from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint
+	 * range is 0 to 31.
 	 */
-	if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
-		return -EINVAL;
+	if (property->flags & DRM_MODE_PROP_BITMASK)
+		if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) ||
+		    (value > 63))
+			return -EINVAL;
 
 	if (!list_empty(&property->enum_blob_list)) {
 		list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
@@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property,
 	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
 		int i;
 		uint64_t valid_mask = 0;
-		for (i = 0; i < property->num_values; i++)
-			valid_mask |= (1ULL << property->values[i]);
-		return !(value & ~valid_mask);
+		uint32_t valid_32bit_mask = 0;
+		if (property->flags & DRM_MODE_PROP_32BIT_PAIR) {
+			for (i = 0; i < property->num_values; i++)
+				valid_32bit_mask |= (1UL << property->values[i]);
+			return !((value & 0xFFFFFFFF) & ~valid_32bit_mask);
+		} else {
+			for (i = 0; i < property->num_values; i++)
+				valid_mask |= (1ULL << property->values[i]);
+			return !(value & ~valid_mask);
+		}
 	} else if (property->flags & DRM_MODE_PROP_BLOB) {
 		/* Only the driver knows */
 		return true;
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index f104c26..5e3a7d9 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -250,6 +250,9 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
 #define DRM_MODE_PROP_BLOB	(1<<4)
 #define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
+#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types
+					 * and 32 bit of value of the type */
+
 
 struct drm_mode_property_enum {
 	__u64 value;
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v2 2/4] drm: Added plane alpha and color blending property
  2014-03-25 14:32                   ` sagar.a.kamble
@ 2014-03-25 14:32                     ` sagar.a.kamble
  -1 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble, airlied, dri-devel, linux-kernel

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch creates a generic blending bitmask property modeled after
glBlendFunc. Drivers may support subset of these values.

v2: Removing blend properties that are not applicable
    [Damien's Review Comments].
    Adding DRM_MODE_PROP_32BIT_PAIR flag to blend property.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 27 +++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 19 +++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d0d03ec..a1f254e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4157,3 +4157,30 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	idr_destroy(&dev->mode_config.crtc_idr);
 }
 EXPORT_SYMBOL(drm_mode_config_cleanup);
+
+struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors)
+{
+	static const struct drm_prop_enum_list props[] = {
+		{ DRM_BLEND_ZERO,  			"zero" },
+		{ DRM_BLEND_ONE, 			"one" },
+		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
+		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
+		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
+		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
+		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
+		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
+		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
+		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
+		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" }
+	};
+
+	return drm_property_create_bitmask(dev, DRM_MODE_PROP_32BIT_PAIR, "blend",
+					   props, ARRAY_SIZE(props),
+					   supported_factors);
+}
+EXPORT_SYMBOL(drm_mode_create_blend_property);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 784a568..a9fbfec 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,6 +65,23 @@ struct drm_object_properties {
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
 
+/* Blending property bits */
+#define DRM_BLEND_ZERO				0
+#define DRM_BLEND_ONE				1
+#define DRM_BLEND_SRC_COLOR			2
+#define DRM_BLEND_ONE_MINUS_SRC_COLOR		3
+#define DRM_BLEND_DST_COLOR			4
+#define DRM_BLEND_ONE_MINUS_DST_COLOR		5
+#define DRM_BLEND_SRC_ALPHA			6
+#define DRM_BLEND_ONE_MINUS_SRC_ALPHA		7
+#define DRM_BLEND_DST_ALPHA			8
+#define DRM_BLEND_ONE_MINUS_DST_ALPHA		9
+#define DRM_BLEND_CONSTANT_COLOR		10
+#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR	11
+#define DRM_BLEND_CONSTANT_ALPHA		12
+#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA	13
+#define DRM_BLEND_SRC_ALPHA_SATURATE		14
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
@@ -1179,6 +1196,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
 extern const char *drm_get_format_name(uint32_t format);
+extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v2 2/4] drm: Added plane alpha and color blending property
@ 2014-03-25 14:32                     ` sagar.a.kamble
  0 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble, linux-kernel, dri-devel

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch creates a generic blending bitmask property modeled after
glBlendFunc. Drivers may support subset of these values.

v2: Removing blend properties that are not applicable
    [Damien's Review Comments].
    Adding DRM_MODE_PROP_32BIT_PAIR flag to blend property.

Cc: airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 27 +++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 19 +++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d0d03ec..a1f254e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4157,3 +4157,30 @@ void drm_mode_config_cleanup(struct drm_device *dev)
 	idr_destroy(&dev->mode_config.crtc_idr);
 }
 EXPORT_SYMBOL(drm_mode_config_cleanup);
+
+struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors)
+{
+	static const struct drm_prop_enum_list props[] = {
+		{ DRM_BLEND_ZERO,  			"zero" },
+		{ DRM_BLEND_ONE, 			"one" },
+		{ DRM_BLEND_SRC_COLOR, 			"src-color" },
+		{ DRM_BLEND_ONE_MINUS_SRC_COLOR,  	"one-minus-src-color" },
+		{ DRM_BLEND_DST_COLOR, 			"dst-color" },
+		{ DRM_BLEND_ONE_MINUS_DST_COLOR,  	"one-minus-dst-color" },
+		{ DRM_BLEND_SRC_ALPHA, 			"src-alpha" },
+		{ DRM_BLEND_ONE_MINUS_SRC_ALPHA, 	"one-minus-src-alpha" },
+		{ DRM_BLEND_DST_ALPHA, 			"dst-alpha" },
+		{ DRM_BLEND_ONE_MINUS_DST_ALPHA, 	"one-minus-dst-alpha" },
+		{ DRM_BLEND_CONSTANT_COLOR, 		"constant-color" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_COLOR, 	"one-minus-constant-color" },
+		{ DRM_BLEND_CONSTANT_ALPHA, 		"constant-alpha" },
+		{ DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA, 	"one-minus-constant-alpha" },
+		{ DRM_BLEND_SRC_ALPHA_SATURATE, 	"alpha-saturate" }
+	};
+
+	return drm_property_create_bitmask(dev, DRM_MODE_PROP_32BIT_PAIR, "blend",
+					   props, ARRAY_SIZE(props),
+					   supported_factors);
+}
+EXPORT_SYMBOL(drm_mode_create_blend_property);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 784a568..a9fbfec 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -65,6 +65,23 @@ struct drm_object_properties {
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
 
+/* Blending property bits */
+#define DRM_BLEND_ZERO				0
+#define DRM_BLEND_ONE				1
+#define DRM_BLEND_SRC_COLOR			2
+#define DRM_BLEND_ONE_MINUS_SRC_COLOR		3
+#define DRM_BLEND_DST_COLOR			4
+#define DRM_BLEND_ONE_MINUS_DST_COLOR		5
+#define DRM_BLEND_SRC_ALPHA			6
+#define DRM_BLEND_ONE_MINUS_SRC_ALPHA		7
+#define DRM_BLEND_DST_ALPHA			8
+#define DRM_BLEND_ONE_MINUS_DST_ALPHA		9
+#define DRM_BLEND_CONSTANT_COLOR		10
+#define DRM_BLEND_ONE_MINUS_CONSTANT_COLOR	11
+#define DRM_BLEND_CONSTANT_ALPHA		12
+#define DRM_BLEND_ONE_MINUS_CONSTANT_ALPHA	13
+#define DRM_BLEND_SRC_ALPHA_SATURATE		14
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
@@ -1179,6 +1196,8 @@ extern int drm_format_plane_cpp(uint32_t format, int plane);
 extern int drm_format_horz_chroma_subsampling(uint32_t format);
 extern int drm_format_vert_chroma_subsampling(uint32_t format);
 extern const char *drm_get_format_name(uint32_t format);
+extern struct drm_property *drm_mode_create_blend_property(struct drm_device *dev,
+				unsigned int supported_factors);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-03-25 14:32                   ` sagar.a.kamble
  (?)
  (?)
@ 2014-03-25 14:32                   ` sagar.a.kamble
  2014-04-01  4:51                     ` Sagar Arun Kamble
  -1 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

This patch enables constant alpha property for Sprite planes.
Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
for applying constant alpha on a plane. To disable constant alpha,
client has to set BIT(DRM_BLEND_SRC_COLOR)

v2: Fixing property value comparison in vlv_update_plane with the use
of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
Reverting line spacing change in i915_driver_lastclose. Return value
of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]

Testcase: igt/kms_blend
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
 drivers/gpu/drm/i915/i915_drv.h     |  1 +
 drivers/gpu/drm/i915/i915_reg.h     |  2 ++
 drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
 drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
 5 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index e4d2b9f..e3a94a3 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
 {
 	drm_i915_private_t *dev_priv = dev->dev_private;
 
+	struct intel_plane *plane;
 	/* On gen6+ we refuse to init without kms enabled, but then the drm core
 	 * goes right around and calls lastclose. Check for this and don't clean
 	 * up anything. */
 	if (!dev_priv)
 		return;
 
+	if (dev_priv->blend_property) {
+		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
+			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
+			drm_object_property_set_value(&plane->base.base,
+						dev_priv->blend_property,
+						plane->blend_param.value);
+		}
+	}
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		intel_fbdev_restore_mode(dev);
 		vga_switcheroo_process_delayed_switch();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 70fbe90..0d1be70 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
 
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
+	struct drm_property *blend_property;
 
 	uint32_t hw_context_size;
 	struct list_head context_list;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 6174fda..bfcfe72 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3774,6 +3774,8 @@ enum punit_power_well {
 #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
 #define   SPRITE_TILED			(1<<10)
 #define   SPRITE_DEST_KEY		(1<<2)
+#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
+#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
 #define _SPRA_LINOFF		0x70284
 #define _SPRA_STRIDE		0x70288
 #define _SPRA_POS		0x7028c
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f4e0615..039a800 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -409,6 +409,13 @@ struct intel_plane {
 	unsigned int crtc_w, crtc_h;
 	uint32_t src_x, src_y;
 	uint32_t src_w, src_h;
+	union {
+		uint64_t value;
+		struct {
+			unsigned int type;
+			unsigned int factor;
+		} details;
+	} blend_param;
 
 	/* Since we need to change the watermarks before/after
 	 * enabling/disabling the planes, we need to store the parameters here
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 9436f18..9ec84bb 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 	int pipe = intel_plane->pipe;
 	int plane = intel_plane->plane;
 	u32 sprctl;
+	u32 sprconstalpha;
+	unsigned int blend_type, blend_factor;
 	unsigned long sprsurf_offset, linear_offset;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
 
 	sprctl = I915_READ(SPCNTR(pipe, plane));
 
+	sprconstalpha = SPCONSTALPHA(pipe, plane);
+
 	/* Mask out pixel format bits in case we change it */
 	sprctl &= ~SP_PIXFORMAT_MASK;
 	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
@@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		break;
 	}
 
+	/* Handle plane alpha and color blending properties */
+	blend_type = intel_plane->blend_param.details.type;
+	blend_factor = intel_plane->blend_param.details.factor;
+
+	switch (blend_type) {
+	case BIT(DRM_BLEND_SRC_COLOR):
+		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
+		break;
+	case BIT(DRM_BLEND_CONSTANT_ALPHA):
+		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
+						SPRITE_CONSTANT_ALPHA_ENABLE);
+		break;
+	default:
+		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
+		break;
+	}
+
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -1011,6 +1032,26 @@ out_unlock:
 	return ret;
 }
 
+static int intel_plane_set_property(struct drm_plane *plane,
+				    struct drm_property *prop,
+				    uint64_t val)
+{
+	struct drm_i915_private *dev_priv = plane->dev->dev_private;
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+	uint64_t old_val;
+	int ret = -EINVAL;
+
+	if (prop == dev_priv->blend_property) {
+		old_val = intel_plane->blend_param.value;
+		intel_plane->blend_param.value = val;
+		ret = intel_plane_restore(plane);
+		if (ret)
+			intel_plane->blend_param.value = old_val;
+	}
+
+	return ret;
+}
+
 int intel_plane_restore(struct drm_plane *plane)
 {
 	struct intel_plane *intel_plane = to_intel_plane(plane);
@@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = intel_update_plane,
 	.disable_plane = intel_disable_plane,
 	.destroy = intel_destroy_plane,
+	.set_property = intel_plane_set_property,
 };
 
 static uint32_t ilk_plane_formats[] = {
@@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
 int
 intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_plane *intel_plane;
 	unsigned long possible_crtcs;
 	const uint32_t *plane_formats;
@@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
+	/* Initialize drm properties for plane */
+	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
+	intel_plane->blend_param.details.factor = 0;
+
 	possible_crtcs = (1 << pipe);
 	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
 			     &intel_plane_funcs,
 			     plane_formats, num_plane_formats,
 			     false);
-	if (ret)
+	if (ret) {
 		kfree(intel_plane);
+		goto out;
+	}
+
+	if (!dev_priv->blend_property)
+		dev_priv->blend_property = drm_mode_create_blend_property(dev,
+							BIT(DRM_BLEND_SRC_COLOR) |
+							BIT(DRM_BLEND_CONSTANT_ALPHA));
 
+	if (dev_priv->blend_property)
+		drm_object_attach_property(&intel_plane->base.base,
+				dev_priv->blend_property,
+				intel_plane->blend_param.value);
+out:
 	return ret;
 }
-- 
1.8.5

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property
  2014-03-25 14:32                   ` sagar.a.kamble
                                     ` (2 preceding siblings ...)
  (?)
@ 2014-03-25 14:32                   ` sagar.a.kamble
  2014-03-26 12:30                     ` David Herrmann
  -1 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-25 14:32 UTC (permalink / raw)
  To: intel-gfx
  Cc: Sagar Kamble, rob, airlied, daniel.vetter, laurent.pinchart,
	dh.herrmann, alexander.deucher, ville.syrjala,
	vijay.a.purushothaman, linux-doc, dri-devel

From: Sagar Kamble <sagar.a.kamble@intel.com>

v2: Added description for "src-color" and "constant-alpha" property.

Cc: Rob Landley <rob at landley.net>
Cc: Dave Airlie <airlied at redhat.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
Cc: David Herrmann <dh.herrmann at gmail.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: "Ville Syrjälä" <ville.syrjala at linux.intel.com>
Cc: Sagar Kamble <sagar.a.kamble at intel.com>
Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman at intel.com>
Cc: linux-doc at vger.kernel.org
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 104402a..77a45fb 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev)
             enumerated bits defined by the property.</para></listitem>
         </varlistentry>
         <varlistentry>
+          <term>DRM_MODE_PROP_32BIT_PAIR</term>
+          <listitem><para>This flag restricts Bitmask properties restricts all
+	    enumerated values to the 0..31 range.
+            During get operation instance values combine one or more of the
+            enumerated bits defined by the property. During get user can specify
+	    {type, value} pair.</para></listitem>
+        </varlistentry>
+        <varlistentry>
           <term>DRM_MODE_PROP_BLOB</term>
           <listitem><para>Blob properties store a binary blob without any format
             restriction. The binary blobs are created as KMS standalone objects,
@@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev)
 	</tr>
 	<tr>
 	<td rowspan="19" valign="top" >DRM</td>
-	<td rowspan="2" valign="top" >Generic</td>
+	<td rowspan="3" valign="top" >Generic</td>
 	<td valign="top" >“EDID”</td>
 	<td valign="top" >BLOB | IMMUTABLE</td>
 	<td valign="top" >0</td>
@@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >Contains DPMS operation mode value.</td>
 	</tr>
 	<tr>
+	<td valign="top" >“blend”</td>
+	<td valign="top" >BITMASK | 32BIT_PAIR</td>
+	<td valign="top" >{ {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"}
+	, {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"}
+	, {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"}
+	, {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} }</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API
+	in OpenGL. Currently only "src-color" and "constant-alpha" are supported. <para>"src-color" will consider supplied fb
+	with plane's pixel format as input without any additional color/alpha changes.</para><para>"constant-alpha" will apply constant
+	transparency to all pixels in addition to source color.</para></td>
+	</tr>
+	<tr>
 	<td rowspan="2" valign="top" >DVI-I</td>
 	<td valign="top" >“subconnector”</td>
 	<td valign="top" >ENUM</td>
-- 
1.8.5


^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property
  2014-03-25 14:32                   ` [PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
@ 2014-03-26 12:30                     ` David Herrmann
  2014-03-27  9:03                       ` [PATCH v3 1/1] " sagar.a.kamble
  0 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-03-26 12:30 UTC (permalink / raw)
  To: sagar.a.kamble
  Cc: linux-doc, Daniel Vetter, Intel Graphics Development, dri-devel,
	vijay.a.purushothaman, Laurent Pinchart, rob, Alex Deucher,
	Dave Airlie

Hi

On Tue, Mar 25, 2014 at 3:32 PM,  <sagar.a.kamble@intel.com> wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
>
> v2: Added description for "src-color" and "constant-alpha" property.
>
> Cc: Rob Landley <rob at landley.net>
> Cc: Dave Airlie <airlied at redhat.com>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Cc: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> Cc: David Herrmann <dh.herrmann at gmail.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: "Ville Syrjälä" <ville.syrjala at linux.intel.com>
> Cc: Sagar Kamble <sagar.a.kamble at intel.com>
> Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman at intel.com>
> Cc: linux-doc at vger.kernel.org
> Cc: dri-devel at lists.freedesktop.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 104402a..77a45fb 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev)
>              enumerated bits defined by the property.</para></listitem>
>          </varlistentry>
>          <varlistentry>
> +          <term>DRM_MODE_PROP_32BIT_PAIR</term>
> +          <listitem><para>This flag restricts Bitmask properties restricts all
> +           enumerated values to the 0..31 range.
> +            During get operation instance values combine one or more of the
> +            enumerated bits defined by the property. During get user can specify
> +           {type, value} pair.</para></listitem>

Please rewrite that, lots of typos in there. Furthermore, if you use
verbs as nouns, you should emphasize them. So in your text, please
somehow emphasize/quote 'get'.

Thanks
David

> +        </varlistentry>
> +        <varlistentry>
>            <term>DRM_MODE_PROP_BLOB</term>
>            <listitem><para>Blob properties store a binary blob without any format
>              restriction. The binary blobs are created as KMS standalone objects,
> @@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev)
>         </tr>
>         <tr>
>         <td rowspan="19" valign="top" >DRM</td>
> -       <td rowspan="2" valign="top" >Generic</td>
> +       <td rowspan="3" valign="top" >Generic</td>
>         <td valign="top" >"EDID"</td>
>         <td valign="top" >BLOB | IMMUTABLE</td>
>         <td valign="top" >0</td>
> @@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev)
>         <td valign="top" >Contains DPMS operation mode value.</td>
>         </tr>
>         <tr>
> +       <td valign="top" >"blend"</td>
> +       <td valign="top" >BITMASK | 32BIT_PAIR</td>
> +       <td valign="top" >{ {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"}
> +       , {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"}
> +       , {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"}
> +       , {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} }</td>
> +       <td valign="top" >Plane</td>
> +       <td valign="top" >Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API
> +       in OpenGL. Currently only "src-color" and "constant-alpha" are supported. <para>"src-color" will consider supplied fb
> +       with plane's pixel format as input without any additional color/alpha changes.</para><para>"constant-alpha" will apply constant
> +       transparency to all pixels in addition to source color.</para></td>
> +       </tr>
> +       <tr>
>         <td rowspan="2" valign="top" >DVI-I</td>
>         <td valign="top" >"subconnector"</td>
>         <td valign="top" >ENUM</td>
> --
> 1.8.5
>

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property
  2014-03-26 12:30                     ` David Herrmann
@ 2014-03-27  9:03                       ` sagar.a.kamble
  2014-03-27  9:50                         ` sagar.a.kamble
  0 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-27  9:03 UTC (permalink / raw)
  To: intel-gfx
  Cc: daniel.vetter, linux-doc, dri-devel, laurent.pinchart, rob,
	alexander.deucher, airlied, Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

v2: Added description for "src-color" and "constant-alpha" property.
    [Review by Laurent Pinchart]

v3: Fixed typos. [Review by David Hermann]

Cc: Rob Landley <rob at landley.net>
Cc: Dave Airlie <airlied at redhat.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
Cc: David Herrmann <dh.herrmann at gmail.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: "Ville Syrjälä" <ville.syrjala at linux.intel.com>
Cc: Sagar Kamble <sagar.a.kamble at intel.com>
Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman at intel.com>
Cc: linux-doc at vger.kernel.org
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 104402a..66386d0 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev)
             enumerated bits defined by the property.</para></listitem>
         </varlistentry>
         <varlistentry>
+          <term>DRM_MODE_PROP_32BIT_PAIR</term>
+          <listitem><para>This flag restricts all enumerated values of Bitmask properties
+	    to the 0..31 range.
+            'get_property' operation will get combination of instance values of one or more of the
+            enumerated bits defined by the property. With 'set_property' operation, user can specify
+	    {value (MSB 32 bits), type (LSB 32 bits)} pair with 64 bit value for that property.</para></listitem>
+        </varlistentry>
+        <varlistentry>
           <term>DRM_MODE_PROP_BLOB</term>
           <listitem><para>Blob properties store a binary blob without any format
             restriction. The binary blobs are created as KMS standalone objects,
@@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev)
 	</tr>
 	<tr>
 	<td rowspan="19" valign="top" >DRM</td>
-	<td rowspan="2" valign="top" >Generic</td>
+	<td rowspan="3" valign="top" >Generic</td>
 	<td valign="top" >“EDID”</td>
 	<td valign="top" >BLOB | IMMUTABLE</td>
 	<td valign="top" >0</td>
@@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >Contains DPMS operation mode value.</td>
 	</tr>
 	<tr>
+	<td valign="top" >“blend”</td>
+	<td valign="top" >BITMASK | 32BIT_PAIR</td>
+	<td valign="top" >{ {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"}
+	, {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"}
+	, {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"}
+	, {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} }</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API
+	in OpenGL. Currently only "src-color" and "constant-alpha" are supported. <para>"src-color" will consider supplied fb
+	with plane's pixel format as input without any additional color/alpha changes.</para><para>"constant-alpha" will apply constant
+	transparency to all pixels in addition to source color.</para></td>
+	</tr>
+	<tr>
 	<td rowspan="2" valign="top" >DVI-I</td>
 	<td valign="top" >“subconnector”</td>
 	<td valign="top" >ENUM</td>
-- 
1.8.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* [PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property
  2014-03-27  9:03                       ` [PATCH v3 1/1] " sagar.a.kamble
@ 2014-03-27  9:50                         ` sagar.a.kamble
  2014-03-27 12:38                           ` David Herrmann
  0 siblings, 1 reply; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-27  9:50 UTC (permalink / raw)
  To: intel-gfx
  Cc: linux-doc, dri-devel, vijay.a.purushothaman, laurent.pinchart,
	rob, alexander.deucher, airlied, Sagar Kamble

From: Sagar Kamble <sagar.a.kamble@intel.com>

v2: Added description for "src-color" and "constant-alpha" property.
    [Review by Laurent Pinchart]

v3: Fixed typos. [Review by David Herrmann]

Cc: Rob Landley <rob at landley.net>
Cc: Dave Airlie <airlied at redhat.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
Cc: David Herrmann <dh.herrmann at gmail.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: "Ville Syrjälä" <ville.syrjala at linux.intel.com>
Cc: Sagar Kamble <sagar.a.kamble at intel.com>
Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman at intel.com>
Cc: linux-doc at vger.kernel.org
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 104402a..66386d0 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev)
             enumerated bits defined by the property.</para></listitem>
         </varlistentry>
         <varlistentry>
+          <term>DRM_MODE_PROP_32BIT_PAIR</term>
+          <listitem><para>This flag restricts all enumerated values of Bitmask properties
+	    to the 0..31 range.
+            'get_property' operation will get combination of instance values of one or more of the
+            enumerated bits defined by the property. With 'set_property' operation, user can specify
+	    {value (MSB 32 bits), type (LSB 32 bits)} pair with 64 bit value for that property.</para></listitem>
+        </varlistentry>
+        <varlistentry>
           <term>DRM_MODE_PROP_BLOB</term>
           <listitem><para>Blob properties store a binary blob without any format
             restriction. The binary blobs are created as KMS standalone objects,
@@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev)
 	</tr>
 	<tr>
 	<td rowspan="19" valign="top" >DRM</td>
-	<td rowspan="2" valign="top" >Generic</td>
+	<td rowspan="3" valign="top" >Generic</td>
 	<td valign="top" >“EDID”</td>
 	<td valign="top" >BLOB | IMMUTABLE</td>
 	<td valign="top" >0</td>
@@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >Contains DPMS operation mode value.</td>
 	</tr>
 	<tr>
+	<td valign="top" >“blend”</td>
+	<td valign="top" >BITMASK | 32BIT_PAIR</td>
+	<td valign="top" >{ {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"}
+	, {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"}
+	, {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"}
+	, {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} }</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API
+	in OpenGL. Currently only "src-color" and "constant-alpha" are supported. <para>"src-color" will consider supplied fb
+	with plane's pixel format as input without any additional color/alpha changes.</para><para>"constant-alpha" will apply constant
+	transparency to all pixels in addition to source color.</para></td>
+	</tr>
+	<tr>
 	<td rowspan="2" valign="top" >DVI-I</td>
 	<td valign="top" >“subconnector”</td>
 	<td valign="top" >ENUM</td>
-- 
1.8.5

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property
  2014-03-27  9:50                         ` sagar.a.kamble
@ 2014-03-27 12:38                           ` David Herrmann
  2014-03-27 17:31                             ` [PATCH v4 " sagar.a.kamble
  0 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-03-27 12:38 UTC (permalink / raw)
  To: sagar.a.kamble
  Cc: Intel Graphics Development, rob, Dave Airlie, Laurent Pinchart,
	Alex Deucher, Ville Syrjälä,
	vijay.a.purushothaman, linux-doc, dri-devel

Hi

On Thu, Mar 27, 2014 at 10:50 AM,  <sagar.a.kamble@intel.com> wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
>
> v2: Added description for "src-color" and "constant-alpha" property.
>     [Review by Laurent Pinchart]
>
> v3: Fixed typos. [Review by David Herrmann]
>
> Cc: Rob Landley <rob at landley.net>
> Cc: Dave Airlie <airlied at redhat.com>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Cc: Laurent Pinchart <laurent.pinchart+renesas at ideasonboard.com>
> Cc: David Herrmann <dh.herrmann at gmail.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: "Ville Syrjälä" <ville.syrjala at linux.intel.com>
> Cc: Sagar Kamble <sagar.a.kamble at intel.com>
> Cc: "Purushothaman, Vijay A" <vijay.a.purushothaman at intel.com>
> Cc: linux-doc at vger.kernel.org
> Cc: dri-devel at lists.freedesktop.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 104402a..66386d0 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2253,6 +2253,14 @@ void intel_crt_init(struct drm_device *dev)
>              enumerated bits defined by the property.</para></listitem>
>          </varlistentry>
>          <varlistentry>
> +          <term>DRM_MODE_PROP_32BIT_PAIR</term>
> +          <listitem><para>This flag restricts all enumerated values of Bitmask properties
> +           to the 0..31 range.
> +            'get_property' operation will get combination of instance values of one or more of the
> +            enumerated bits defined by the property. With 'set_property' operation, user can specify
> +           {value (MSB 32 bits), type (LSB 32 bits)} pair with 64 bit value for that property.</para></listitem>

This is a type description, right? I think this is overly complex (and
I actually don't understand it). How about this:

  "Pair-properties store two packed 32 bit values as 64bit unsigned
integer (often used as key-value pair). The lower 32bits contain the
first value (also: key), while the upper 32bits contain the second
value. Written as: ({key (LSB 32 bits), value (MSB 32 bits)})."

That should be enough for anyone to understand it. Please note that I
inverted 'type' and 'value' here. It's unnatural to list the value
first.

> +        </varlistentry>
> +        <varlistentry>
>            <term>DRM_MODE_PROP_BLOB</term>
>            <listitem><para>Blob properties store a binary blob without any format
>              restriction. The binary blobs are created as KMS standalone objects,
> @@ -2336,7 +2344,7 @@ void intel_crt_init(struct drm_device *dev)
>         </tr>
>         <tr>
>         <td rowspan="19" valign="top" >DRM</td>
> -       <td rowspan="2" valign="top" >Generic</td>
> +       <td rowspan="3" valign="top" >Generic</td>
>         <td valign="top" >"EDID"</td>
>         <td valign="top" >BLOB | IMMUTABLE</td>
>         <td valign="top" >0</td>
> @@ -2351,6 +2359,19 @@ void intel_crt_init(struct drm_device *dev)
>         <td valign="top" >Contains DPMS operation mode value.</td>
>         </tr>
>         <tr>
> +       <td valign="top" >"blend"</td>
> +       <td valign="top" >BITMASK | 32BIT_PAIR</td>

Ugh? This is not a bitmask, is it? It's just a 32BIT_PAIR, right?

> +       <td valign="top" >{ {0, "zero"}, {1, "one"}, {2, "src-color"}, {3, "one-minus-src-color"}
> +       , {4, "dst-color"}, {5, "one-minus-dst-color"}, {6, "src-alpha"}, {7, "one-minus-src-alpha"}, {8, "dst-alpha"}
> +       , {9, "one-minus-dst-alpha"}, {10, "constant-color"}, {11, "one-minus-constant-color"}, {12, "constant-alpha"}
> +       , {13, "one-minus-constant-alpha"}, {14, "alpha-saturate"} }</td>

 I think brackets are weird to describe enums, a table would be nicer.
People might misread this as 32-bit pairs, which this isn't. If you
want to avoid writing yet another table, how about:

ZERO = 0, ONE = 1, SRC_COLOR = 2, .. and so on?

> +       <td valign="top" >Plane</td>
> +       <td valign="top" >Contains plane alpha/color blending operation values. These are modeled after glBlendFunc API

Remove 'API' (or add 'the', like 'the glBlendFunc API').

> +       in OpenGL. Currently only "src-color" and "constant-alpha" are supported. <para>"src-color" will consider supplied fb

This is a driver-dependent statement. I don't think it belongs here.
I'd rather write it as "Not all modes are supported by all drivers.".

Also, please do line-breaks in front of <para>. They start
new-paragraphs, so we should do the same in the code (same below).

> +       with plane's pixel format as input without any additional color/alpha changes.</para><para>"constant-alpha" will apply constant
> +       transparency to all pixels in addition to source color.</para></td>

I would just drop the description of each of the modes. They're
described in the man-pages of glBlendFunc and everyone knows them (and
they're fairly obvious).

However, this doc doesn't describe the second value at all?
glBlendFunc() takes two of these enums, one for the source, one for
the target. So please add some statement like:

  "The first value of the 32BIT_PAIR describes the blending factors of
the source image, the second value describes the blending factors of
the destination image."

Thanks
David

> +       </tr>
> +       <tr>
>         <td rowspan="2" valign="top" >DVI-I</td>
>         <td valign="top" >"subconnector"</td>
>         <td valign="top" >ENUM</td>
> --
> 1.8.5
>

^ permalink raw reply	[flat|nested] 53+ messages in thread

* [PATCH v4 1/1] Documentation: drm: describing plane alpha and color blending property
  2014-03-27 12:38                           ` David Herrmann
@ 2014-03-27 17:31                             ` sagar.a.kamble
  0 siblings, 0 replies; 53+ messages in thread
From: sagar.a.kamble @ 2014-03-27 17:31 UTC (permalink / raw)
  To: intel-gfx
  Cc: linux-doc, daniel.vetter, dri-devel, vijay.a.purushothaman,
	laurent.pinchart, rob, alexander.deucher, airlied, Sagar Kamble

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3719 bytes --]

From: Sagar Kamble <sagar.a.kamble@intel.com>

v2: Added description for "src-color" and "constant-alpha" property.
    [Review by Laurent Pinchart]

v3: Fixed typos. [Review by David Herrmann]

v4: Additional formatting and modified description. [Review by David Herrmann]

Cc: rob@landley.net
Cc: airlied@redhat.com
Cc: daniel.vetter@ffwll.ch
Cc: laurent.pinchart@ideasonboard.com
Cc: dh.herrmann@gmail.com
Cc: alexander.deucher@amd.com
Cc: ville.syrjala@linux.intel.com
Cc: sagar.a.kamble@intel.com
Cc: vijay.a.purushothaman@intel.com
Cc: linux-doc@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
---
 Documentation/DocBook/drm.tmpl | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 104402a..dd2ae67 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2264,6 +2264,20 @@ void intel_crt_init(struct drm_device *dev)
       </variablelist>
     </para>
     <para>
+      In addition to above types, properties can be constrained by supplying additional
+      flags while creating the property. Supported flags are
+      <variablelist>
+        <varlistentry>
+          <term>DRM_MODE_PROP_32BIT_PAIR</term>
+          <listitem><para>This flag is applicable to Bitmask enum properties. It creates
+	    Pair-properties that store two packed 32 bit values as 64bit unsigned integer
+	    (often used as key-value pair). The lower 32 bits contain the first value (also: key),
+	    while the upper 32 bits contain the second value.
+	    Written as: ({key (LSB 32 bits), value (MSB 32 bits)}).</para></listitem>
+        </varlistentry>
+      </variablelist>
+    </para>
+    <para>
       To create a property drivers call one of the following functions depending
       on the property type. All property creation functions take property flags
       and name, as well as type-specific arguments.
@@ -2336,7 +2350,7 @@ void intel_crt_init(struct drm_device *dev)
 	</tr>
 	<tr>
 	<td rowspan="19" valign="top" >DRM</td>
-	<td rowspan="2" valign="top" >Generic</td>
+	<td rowspan="3" valign="top" >Generic</td>
 	<td valign="top" >“EDID”</td>
 	<td valign="top" >BLOB | IMMUTABLE</td>
 	<td valign="top" >0</td>
@@ -2351,6 +2365,22 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >Contains DPMS operation mode value.</td>
 	</tr>
 	<tr>
+	<td valign="top" >“blend”</td>
+	<td valign="top" >BITMASK | 32BIT_PAIR</td>
+	<td valign="top" >{ "zero" = 0, "one" = 1, "src-color" = 2, "one-minus-src-color" = 3
+	, "dst-color" = 4, "one-minus-dst-color" = 5, "src-alpha"= 6, "one-minus-src-alpha" = 7, "dst-alpha" = 8
+	, "one-minus-dst-alpha" = 9, "constant-color" = 10, "one-minus-constant-color" = 11, "constant-alpha" = 12
+	, "one-minus-constant-alpha" = 13, "alpha-saturate" = 14 }</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Contains plane alpha/color blending operation values. These are modeled after the glBlendFunc API
+	in OpenGL. Not all modes are supported by all drivers. The first value of the 32BIT_PAIR describes the blending mode
+	of the source plane, the second value describes the blending factors of the source plane.
+	<para>
+	For e.g. to apply constant alpha of 0xFF on source plane, the first value of this property for source plane should
+	be set to 2^10 and second value to value of alpha(0xFF).
+	</para></td>
+	</tr>
+	<tr>
 	<td rowspan="2" valign="top" >DVI-I</td>
 	<td valign="top" >“subconnector”</td>
 	<td valign="top" >ENUM</td>
-- 
1.8.5


[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-03-25 14:32                   ` [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
@ 2014-04-01  4:51                     ` Sagar Arun Kamble
  2014-04-02  6:12                       ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-01  4:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, Hiremath, Shashidhar, Sharma, Ankitprasad R

Gentle Reminder for reviewing this and related patches:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html


Also, provide views on "how do we handle pre-multiplied alpha pixel
formats or is there need to convey pre-multiplied alpha pixel format
through additional drm property?"
Since we are already advertising supported pre-multiplied formats
during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
etc.


On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> This patch enables constant alpha property for Sprite planes.
> Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> for applying constant alpha on a plane. To disable constant alpha,
> client has to set BIT(DRM_BLEND_SRC_COLOR)
> 
> v2: Fixing property value comparison in vlv_update_plane with the use
> of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> Reverting line spacing change in i915_driver_lastclose. Return value
> of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> 
> Testcase: igt/kms_blend
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
>  drivers/gpu/drm/i915/i915_drv.h     |  1 +
>  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
>  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
>  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
>  5 files changed, 80 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index e4d2b9f..e3a94a3 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
>  {
>  	drm_i915_private_t *dev_priv = dev->dev_private;
>  
> +	struct intel_plane *plane;
>  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
>  	 * goes right around and calls lastclose. Check for this and don't clean
>  	 * up anything. */
>  	if (!dev_priv)
>  		return;
>  
> +	if (dev_priv->blend_property) {
> +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> +			drm_object_property_set_value(&plane->base.base,
> +						dev_priv->blend_property,
> +						plane->blend_param.value);
> +		}
> +	}
> +
>  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		intel_fbdev_restore_mode(dev);
>  		vga_switcheroo_process_delayed_switch();
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 70fbe90..0d1be70 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
>  
>  	struct drm_property *broadcast_rgb_property;
>  	struct drm_property *force_audio_property;
> +	struct drm_property *blend_property;
>  
>  	uint32_t hw_context_size;
>  	struct list_head context_list;
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 6174fda..bfcfe72 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -3774,6 +3774,8 @@ enum punit_power_well {
>  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
>  #define   SPRITE_TILED			(1<<10)
>  #define   SPRITE_DEST_KEY		(1<<2)
> +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
>  #define _SPRA_LINOFF		0x70284
>  #define _SPRA_STRIDE		0x70288
>  #define _SPRA_POS		0x7028c
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index f4e0615..039a800 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -409,6 +409,13 @@ struct intel_plane {
>  	unsigned int crtc_w, crtc_h;
>  	uint32_t src_x, src_y;
>  	uint32_t src_w, src_h;
> +	union {
> +		uint64_t value;
> +		struct {
> +			unsigned int type;
> +			unsigned int factor;
> +		} details;
> +	} blend_param;
>  
>  	/* Since we need to change the watermarks before/after
>  	 * enabling/disabling the planes, we need to store the parameters here
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 9436f18..9ec84bb 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  	int pipe = intel_plane->pipe;
>  	int plane = intel_plane->plane;
>  	u32 sprctl;
> +	u32 sprconstalpha;
> +	unsigned int blend_type, blend_factor;
>  	unsigned long sprsurf_offset, linear_offset;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>  
>  	sprctl = I915_READ(SPCNTR(pipe, plane));
>  
> +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> +
>  	/* Mask out pixel format bits in case we change it */
>  	sprctl &= ~SP_PIXFORMAT_MASK;
>  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  		break;
>  	}
>  
> +	/* Handle plane alpha and color blending properties */
> +	blend_type = intel_plane->blend_param.details.type;
> +	blend_factor = intel_plane->blend_param.details.factor;
> +
> +	switch (blend_type) {
> +	case BIT(DRM_BLEND_SRC_COLOR):
> +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> +		break;
> +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> +						SPRITE_CONSTANT_ALPHA_ENABLE);
> +		break;
> +	default:
> +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> +		break;
> +	}
> +
>  	/*
>  	 * Enable gamma to match primary/cursor plane behaviour.
>  	 * FIXME should be user controllable via propertiesa.
> @@ -1011,6 +1032,26 @@ out_unlock:
>  	return ret;
>  }
>  
> +static int intel_plane_set_property(struct drm_plane *plane,
> +				    struct drm_property *prop,
> +				    uint64_t val)
> +{
> +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> +	struct intel_plane *intel_plane = to_intel_plane(plane);
> +	uint64_t old_val;
> +	int ret = -EINVAL;
> +
> +	if (prop == dev_priv->blend_property) {
> +		old_val = intel_plane->blend_param.value;
> +		intel_plane->blend_param.value = val;
> +		ret = intel_plane_restore(plane);
> +		if (ret)
> +			intel_plane->blend_param.value = old_val;
> +	}
> +
> +	return ret;
> +}
> +
>  int intel_plane_restore(struct drm_plane *plane)
>  {
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
> @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
>  	.update_plane = intel_update_plane,
>  	.disable_plane = intel_disable_plane,
>  	.destroy = intel_destroy_plane,
> +	.set_property = intel_plane_set_property,
>  };
>  
>  static uint32_t ilk_plane_formats[] = {
> @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
>  int
>  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  {
> +	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_plane *intel_plane;
>  	unsigned long possible_crtcs;
>  	const uint32_t *plane_formats;
> @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  
>  	intel_plane->pipe = pipe;
>  	intel_plane->plane = plane;
> +	/* Initialize drm properties for plane */
> +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> +	intel_plane->blend_param.details.factor = 0;
> +
>  	possible_crtcs = (1 << pipe);
>  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
>  			     &intel_plane_funcs,
>  			     plane_formats, num_plane_formats,
>  			     false);
> -	if (ret)
> +	if (ret) {
>  		kfree(intel_plane);
> +		goto out;
> +	}
> +
> +	if (!dev_priv->blend_property)
> +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> +							BIT(DRM_BLEND_SRC_COLOR) |
> +							BIT(DRM_BLEND_CONSTANT_ALPHA));
>  
> +	if (dev_priv->blend_property)
> +		drm_object_attach_property(&intel_plane->base.base,
> +				dev_priv->blend_property,
> +				intel_plane->blend_param.value);
> +out:
>  	return ret;
>  }

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-01  4:51                     ` Sagar Arun Kamble
@ 2014-04-02  6:12                       ` Sagar Arun Kamble
  2014-04-03  5:43                         ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-02  6:12 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, Hiremath, Shashidhar, Sharma, Ankitprasad R

Reminder for review :)

On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> Gentle Reminder for reviewing this and related patches:
> http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> 
> 
> Also, provide views on "how do we handle pre-multiplied alpha pixel
> formats or is there need to convey pre-multiplied alpha pixel format
> through additional drm property?"
> Since we are already advertising supported pre-multiplied formats
> during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> etc.
> 
> 
> On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > 
> > This patch enables constant alpha property for Sprite planes.
> > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > for applying constant alpha on a plane. To disable constant alpha,
> > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > 
> > v2: Fixing property value comparison in vlv_update_plane with the use
> > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > Reverting line spacing change in i915_driver_lastclose. Return value
> > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > 
> > Testcase: igt/kms_blend
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> >  5 files changed, 80 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > index e4d2b9f..e3a94a3 100644
> > --- a/drivers/gpu/drm/i915/i915_dma.c
> > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> >  {
> >  	drm_i915_private_t *dev_priv = dev->dev_private;
> >  
> > +	struct intel_plane *plane;
> >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> >  	 * goes right around and calls lastclose. Check for this and don't clean
> >  	 * up anything. */
> >  	if (!dev_priv)
> >  		return;
> >  
> > +	if (dev_priv->blend_property) {
> > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > +			drm_object_property_set_value(&plane->base.base,
> > +						dev_priv->blend_property,
> > +						plane->blend_param.value);
> > +		}
> > +	}
> > +
> >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> >  		intel_fbdev_restore_mode(dev);
> >  		vga_switcheroo_process_delayed_switch();
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index 70fbe90..0d1be70 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> >  
> >  	struct drm_property *broadcast_rgb_property;
> >  	struct drm_property *force_audio_property;
> > +	struct drm_property *blend_property;
> >  
> >  	uint32_t hw_context_size;
> >  	struct list_head context_list;
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index 6174fda..bfcfe72 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> >  #define   SPRITE_TILED			(1<<10)
> >  #define   SPRITE_DEST_KEY		(1<<2)
> > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> >  #define _SPRA_LINOFF		0x70284
> >  #define _SPRA_STRIDE		0x70288
> >  #define _SPRA_POS		0x7028c
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index f4e0615..039a800 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -409,6 +409,13 @@ struct intel_plane {
> >  	unsigned int crtc_w, crtc_h;
> >  	uint32_t src_x, src_y;
> >  	uint32_t src_w, src_h;
> > +	union {
> > +		uint64_t value;
> > +		struct {
> > +			unsigned int type;
> > +			unsigned int factor;
> > +		} details;
> > +	} blend_param;
> >  
> >  	/* Since we need to change the watermarks before/after
> >  	 * enabling/disabling the planes, we need to store the parameters here
> > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > index 9436f18..9ec84bb 100644
> > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> >  	int pipe = intel_plane->pipe;
> >  	int plane = intel_plane->plane;
> >  	u32 sprctl;
> > +	u32 sprconstalpha;
> > +	unsigned int blend_type, blend_factor;
> >  	unsigned long sprsurf_offset, linear_offset;
> >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> >  
> >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> >  
> > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > +
> >  	/* Mask out pixel format bits in case we change it */
> >  	sprctl &= ~SP_PIXFORMAT_MASK;
> >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> >  		break;
> >  	}
> >  
> > +	/* Handle plane alpha and color blending properties */
> > +	blend_type = intel_plane->blend_param.details.type;
> > +	blend_factor = intel_plane->blend_param.details.factor;
> > +
> > +	switch (blend_type) {
> > +	case BIT(DRM_BLEND_SRC_COLOR):
> > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > +		break;
> > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > +		break;
> > +	default:
> > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > +		break;
> > +	}
> > +
> >  	/*
> >  	 * Enable gamma to match primary/cursor plane behaviour.
> >  	 * FIXME should be user controllable via propertiesa.
> > @@ -1011,6 +1032,26 @@ out_unlock:
> >  	return ret;
> >  }
> >  
> > +static int intel_plane_set_property(struct drm_plane *plane,
> > +				    struct drm_property *prop,
> > +				    uint64_t val)
> > +{
> > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > +	uint64_t old_val;
> > +	int ret = -EINVAL;
> > +
> > +	if (prop == dev_priv->blend_property) {
> > +		old_val = intel_plane->blend_param.value;
> > +		intel_plane->blend_param.value = val;
> > +		ret = intel_plane_restore(plane);
> > +		if (ret)
> > +			intel_plane->blend_param.value = old_val;
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> >  int intel_plane_restore(struct drm_plane *plane)
> >  {
> >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> >  	.update_plane = intel_update_plane,
> >  	.disable_plane = intel_disable_plane,
> >  	.destroy = intel_destroy_plane,
> > +	.set_property = intel_plane_set_property,
> >  };
> >  
> >  static uint32_t ilk_plane_formats[] = {
> > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> >  int
> >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> >  {
> > +	struct drm_i915_private *dev_priv = dev->dev_private;
> >  	struct intel_plane *intel_plane;
> >  	unsigned long possible_crtcs;
> >  	const uint32_t *plane_formats;
> > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> >  
> >  	intel_plane->pipe = pipe;
> >  	intel_plane->plane = plane;
> > +	/* Initialize drm properties for plane */
> > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > +	intel_plane->blend_param.details.factor = 0;
> > +
> >  	possible_crtcs = (1 << pipe);
> >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> >  			     &intel_plane_funcs,
> >  			     plane_formats, num_plane_formats,
> >  			     false);
> > -	if (ret)
> > +	if (ret) {
> >  		kfree(intel_plane);
> > +		goto out;
> > +	}
> > +
> > +	if (!dev_priv->blend_property)
> > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > +							BIT(DRM_BLEND_SRC_COLOR) |
> > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> >  
> > +	if (dev_priv->blend_property)
> > +		drm_object_attach_property(&intel_plane->base.base,
> > +				dev_priv->blend_property,
> > +				intel_plane->blend_param.value);
> > +out:
> >  	return ret;
> >  }
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property
  2014-03-21 19:23                   ` Damien Lespiau
@ 2014-04-02 19:36                     ` Ville Syrjälä
  0 siblings, 0 replies; 53+ messages in thread
From: Ville Syrjälä @ 2014-04-02 19:36 UTC (permalink / raw)
  To: Damien Lespiau; +Cc: intel-gfx, Akash Goel, ville.syrjala, Daniel Vetter

On Fri, Mar 21, 2014 at 07:23:31PM +0000, Damien Lespiau wrote:
> On Fri, Mar 21, 2014 at 07:06:46PM +0530, Sagar Arun Kamble wrote:
> > Hi Damien,
> > 
> > On Thu, 2014-03-20 at 14:45 +0000, Damien Lespiau wrote:
> > > On Thu, Mar 20, 2014 at 02:11:40PM +0000, Damien Lespiau wrote:
> > > > (source is premultiplied)
> > > > 
> > > > RGBA = ADD(SRC_COLOR*SRC_ALPHA, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > > 
> > > Grr, copy/paste error. If the source is already premultiplied:
> > > 
> > > RGBA = ADD(SRC_COLOR, DST_COLOR*ONE_MINUS_SRC_ALPHA)
> > > 
> > 
> > 1. Currently there is no interface to advertise the DRM_FORMATS plane
> > supportes to user mode? Should we add new IOCTL for that and include
> > pre-multiplied alpha formats while advertising? Or am I missing any such
> > API already available?
> 
> There's a 'formats' array in drmModePlane.
> 
> > 2. About constant alpha property - when we program constant alpha
> > register will hardware be able to take care of the blending as per
> > equations you have specified for non-premultiplied-alpha and
> > premultiplied-alpha cases or we have to do any additional setting?
> > Confusion is because of two combinations:
> > a. pre-multiplied alpha+constant alpha
> > b. non-pre-multiplied alpha+constant alpha
> 
> The first part of the question should be in the spec. I really do expect
> the hw to work correctly with any combination of (premul, non-premult) x
> (plane alpha, no plane alpha)
> 
> To be more clear: I don't think the glBlendFunc constants can represent
> everything we want:
> 
> - It'd need to differentiate what we want do to between RGB and A (the
>   same reason glBlendFuncSeparate was introduced).

We won't be writing out the alpha anywhere so I'm thinking we don't need
to worry about it.

> 
> - We can't represent blending of an unpremultied fb with a plane-global
>   alpha with just the GL blending equation as it needs two
>   multiplications (so in GL, you would do one of them in the fragment
>   shader).

If I'm interpreting the docs correctly these are the kind of blend equations
we will have soonish:

Sc = Sc
Dc = Sc * Ca + (1-Ca) * Dc

Sc = Sc
Dc = Sc * 1 + (1-Sa) * Dc

premultiplied?
 0: Sc = Sc * Sa
 1: Sc = Sc
Dc = Sc * Sa*Ca + (1-Sa*Ca) * Dc

premultiplied?
 0: Sc = Sc * Sa
 1: Sc = Sc
Dc = Sc * 1 + (1-Sa) * Dc


For reference OMAP36xx was something like this I think:
premultiplied?
 0: Sc = Sc * Sa
 1: Sc = Sc
Dc = Sc * Ca + (1-Sa*Ca) * Dc

and OMAP34xx was something like this:
Sc = Sc
Dc = Sc * Sa*Ca + (1-Sa*Ca) * Dc


So we have src factors of:
1, Ca, Sa*Ca

and dst factors of:
0, 1-Ca, 1-Sa, 1-Sa*Ca

If we add the missing Sa src factor we have a fairly sensible looking
set. Obviously the constant alpha related factors aren't part of GL,
but I don't think we need to worry about that, we're not implementing
GL here after all, just something that resembles it a bit to make it
easier for people to grasp it.

So to make stuff easier for userspace to figure out what we actually
support, I'm thinking it could be just an enum property with the values
being something like '(dstf << 32) | (srcf << 0)' with the factors
defined something like so:

enum {
 ZERO,
 ONE,
 SRC_ALPHA,
 ONE_MINUS_SRC_ALPHA,
 CONST_ALPHA,
 ONE_MINUS_CONST_ALPHA,
 SRC_CONST_ALPHA,
 ONE_MINUS_SRC_CONST_ALPHA,
};

If it's an enum then the user can just pick out one of the
supported blend equations.

> I would just proceed with a premultipled FB format and the alpha plane
> property.

I'm not very enthusiastic about adding the pre-multiplied info to
the FB. That means adding new versions of all the alpha formats we
already have. I almost regret making the A vs. X distinction already.
Might have been neater to leave it entirely up to the blending
properties to figure out whether there's alpha or not.

The one not so annoying option would be to snatch one of the remaining
high bits and use that to indicate premult or not. But we still need to
figure out whether we make the already existing formats be the
premultiplied or non-premultiplied ones. That could have some implication
for user space as we probably can't radically change which formats we
accept to keep existing userspace functional.

So the other option is to not think of it as a property of the
framebuffer, but rather think of it in terms of what operations the
hardware will perform during blending. That way we could just add a flag
which says "yes please, premultiply the data for me".

One thing I didn't much think about is whether we need per-plane blend
functions. That would be the more flexible option, but at least the
current hardware doesn't seem to allow such flexibility. I guess being
future proof shouldn't hurt. We do have the option of per-plane
premultiplication at least. Hmm, actually I have to take that back as
the first two example functions I listed can appear simultaneosly
AFAICS. So this does make things a bit more complicated for userspace
as it can't freely pick blend functions when dealing with multiple
planes. Oh and also for OMAPs the bottom plane wouldn't be blended with
the background AFAICS, so it would always have a blend function of
ONE,ZERO.

OK, so that's my thoughts on the matter. Pardon me if I repeated some
nonsense that has already been shot down. I didn't have time to look at
the actual patches yet.

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-02  6:12                       ` Sagar Arun Kamble
@ 2014-04-03  5:43                         ` Sagar Arun Kamble
  2014-04-15  9:44                           ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-03  5:43 UTC (permalink / raw)
  To: Ville Syrjälä, intel-gfx
  Cc: Daniel Vetter, Hiremath, Shashidhar, Sharma, Ankitprasad R

Hi Ville,

Could you please review these patches.

thanks,
Sagar


On Wed, 2014-04-02 at 11:42 +0530, Sagar Arun Kamble wrote:
> Reminder for review :)
> 
> On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> > Gentle Reminder for reviewing this and related patches:
> > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> > 
> > 
> > Also, provide views on "how do we handle pre-multiplied alpha pixel
> > formats or is there need to convey pre-multiplied alpha pixel format
> > through additional drm property?"
> > Since we are already advertising supported pre-multiplied formats
> > during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> > etc.
> > 
> > 
> > On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > 
> > > This patch enables constant alpha property for Sprite planes.
> > > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > > for applying constant alpha on a plane. To disable constant alpha,
> > > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > > 
> > > v2: Fixing property value comparison in vlv_update_plane with the use
> > > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > > Reverting line spacing change in i915_driver_lastclose. Return value
> > > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > > 
> > > Testcase: igt/kms_blend
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > > ---
> > >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> > >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> > >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> > >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> > >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> > >  5 files changed, 80 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > > index e4d2b9f..e3a94a3 100644
> > > --- a/drivers/gpu/drm/i915/i915_dma.c
> > > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> > >  {
> > >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > >  
> > > +	struct intel_plane *plane;
> > >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> > >  	 * goes right around and calls lastclose. Check for this and don't clean
> > >  	 * up anything. */
> > >  	if (!dev_priv)
> > >  		return;
> > >  
> > > +	if (dev_priv->blend_property) {
> > > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > > +			drm_object_property_set_value(&plane->base.base,
> > > +						dev_priv->blend_property,
> > > +						plane->blend_param.value);
> > > +		}
> > > +	}
> > > +
> > >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > >  		intel_fbdev_restore_mode(dev);
> > >  		vga_switcheroo_process_delayed_switch();
> > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > > index 70fbe90..0d1be70 100644
> > > --- a/drivers/gpu/drm/i915/i915_drv.h
> > > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> > >  
> > >  	struct drm_property *broadcast_rgb_property;
> > >  	struct drm_property *force_audio_property;
> > > +	struct drm_property *blend_property;
> > >  
> > >  	uint32_t hw_context_size;
> > >  	struct list_head context_list;
> > > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > > index 6174fda..bfcfe72 100644
> > > --- a/drivers/gpu/drm/i915/i915_reg.h
> > > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> > >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> > >  #define   SPRITE_TILED			(1<<10)
> > >  #define   SPRITE_DEST_KEY		(1<<2)
> > > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> > >  #define _SPRA_LINOFF		0x70284
> > >  #define _SPRA_STRIDE		0x70288
> > >  #define _SPRA_POS		0x7028c
> > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > index f4e0615..039a800 100644
> > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > @@ -409,6 +409,13 @@ struct intel_plane {
> > >  	unsigned int crtc_w, crtc_h;
> > >  	uint32_t src_x, src_y;
> > >  	uint32_t src_w, src_h;
> > > +	union {
> > > +		uint64_t value;
> > > +		struct {
> > > +			unsigned int type;
> > > +			unsigned int factor;
> > > +		} details;
> > > +	} blend_param;
> > >  
> > >  	/* Since we need to change the watermarks before/after
> > >  	 * enabling/disabling the planes, we need to store the parameters here
> > > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > > index 9436f18..9ec84bb 100644
> > > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > >  	int pipe = intel_plane->pipe;
> > >  	int plane = intel_plane->plane;
> > >  	u32 sprctl;
> > > +	u32 sprconstalpha;
> > > +	unsigned int blend_type, blend_factor;
> > >  	unsigned long sprsurf_offset, linear_offset;
> > >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> > >  
> > >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> > >  
> > > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > > +
> > >  	/* Mask out pixel format bits in case we change it */
> > >  	sprctl &= ~SP_PIXFORMAT_MASK;
> > >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > >  		break;
> > >  	}
> > >  
> > > +	/* Handle plane alpha and color blending properties */
> > > +	blend_type = intel_plane->blend_param.details.type;
> > > +	blend_factor = intel_plane->blend_param.details.factor;
> > > +
> > > +	switch (blend_type) {
> > > +	case BIT(DRM_BLEND_SRC_COLOR):
> > > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > > +		break;
> > > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > > +		break;
> > > +	default:
> > > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > > +		break;
> > > +	}
> > > +
> > >  	/*
> > >  	 * Enable gamma to match primary/cursor plane behaviour.
> > >  	 * FIXME should be user controllable via propertiesa.
> > > @@ -1011,6 +1032,26 @@ out_unlock:
> > >  	return ret;
> > >  }
> > >  
> > > +static int intel_plane_set_property(struct drm_plane *plane,
> > > +				    struct drm_property *prop,
> > > +				    uint64_t val)
> > > +{
> > > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > +	uint64_t old_val;
> > > +	int ret = -EINVAL;
> > > +
> > > +	if (prop == dev_priv->blend_property) {
> > > +		old_val = intel_plane->blend_param.value;
> > > +		intel_plane->blend_param.value = val;
> > > +		ret = intel_plane_restore(plane);
> > > +		if (ret)
> > > +			intel_plane->blend_param.value = old_val;
> > > +	}
> > > +
> > > +	return ret;
> > > +}
> > > +
> > >  int intel_plane_restore(struct drm_plane *plane)
> > >  {
> > >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> > >  	.update_plane = intel_update_plane,
> > >  	.disable_plane = intel_disable_plane,
> > >  	.destroy = intel_destroy_plane,
> > > +	.set_property = intel_plane_set_property,
> > >  };
> > >  
> > >  static uint32_t ilk_plane_formats[] = {
> > > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> > >  int
> > >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > >  {
> > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > >  	struct intel_plane *intel_plane;
> > >  	unsigned long possible_crtcs;
> > >  	const uint32_t *plane_formats;
> > > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > >  
> > >  	intel_plane->pipe = pipe;
> > >  	intel_plane->plane = plane;
> > > +	/* Initialize drm properties for plane */
> > > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > > +	intel_plane->blend_param.details.factor = 0;
> > > +
> > >  	possible_crtcs = (1 << pipe);
> > >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> > >  			     &intel_plane_funcs,
> > >  			     plane_formats, num_plane_formats,
> > >  			     false);
> > > -	if (ret)
> > > +	if (ret) {
> > >  		kfree(intel_plane);
> > > +		goto out;
> > > +	}
> > > +
> > > +	if (!dev_priv->blend_property)
> > > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > > +							BIT(DRM_BLEND_SRC_COLOR) |
> > > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> > >  
> > > +	if (dev_priv->blend_property)
> > > +		drm_object_attach_property(&intel_plane->base.base,
> > > +				dev_priv->blend_property,
> > > +				intel_plane->blend_param.value);
> > > +out:
> > >  	return ret;
> > >  }
> > 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair
  2014-03-25 14:32                   ` sagar.a.kamble
@ 2014-04-10 10:39                     ` Sagar Arun Kamble
  -1 siblings, 0 replies; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-10 10:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: airlied, dri-devel, linux-kernel, robdclark, rusty


Adding Rob and Rusty in the review thread.

Kindly review these patches for interface being proposed to set
color/alpha property of planes modeled after glBlendFunc.

 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html

thanks,
Sagar


On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use
> of 64 bit value of bitmask property as two 32 bit values.
> 
> Cc: airlied@linux.ie
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
>  include/uapi/drm/drm_mode.h |  3 +++
>  2 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4e43fc2..d0d03ec 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index,
>  
>  	/*
>  	 * Bitmask enum properties have the additional constraint of values
> -	 * from 0 to 63
> +	 * from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint
> +	 * range is 0 to 31.
>  	 */
> -	if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
> -		return -EINVAL;
> +	if (property->flags & DRM_MODE_PROP_BITMASK)
> +		if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) ||
> +		    (value > 63))
> +			return -EINVAL;
>  
>  	if (!list_empty(&property->enum_blob_list)) {
>  		list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
> @@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property,
>  	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
>  		int i;
>  		uint64_t valid_mask = 0;
> -		for (i = 0; i < property->num_values; i++)
> -			valid_mask |= (1ULL << property->values[i]);
> -		return !(value & ~valid_mask);
> +		uint32_t valid_32bit_mask = 0;
> +		if (property->flags & DRM_MODE_PROP_32BIT_PAIR) {
> +			for (i = 0; i < property->num_values; i++)
> +				valid_32bit_mask |= (1UL << property->values[i]);
> +			return !((value & 0xFFFFFFFF) & ~valid_32bit_mask);
> +		} else {
> +			for (i = 0; i < property->num_values; i++)
> +				valid_mask |= (1ULL << property->values[i]);
> +			return !(value & ~valid_mask);
> +		}
>  	} else if (property->flags & DRM_MODE_PROP_BLOB) {
>  		/* Only the driver knows */
>  		return true;
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index f104c26..5e3a7d9 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -250,6 +250,9 @@ struct drm_mode_get_connector {
>  #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
>  #define DRM_MODE_PROP_BLOB	(1<<4)
>  #define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
> +#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types
> +					 * and 32 bit of value of the type */
> +
>  
>  struct drm_mode_property_enum {
>  	__u64 value;



^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair
@ 2014-04-10 10:39                     ` Sagar Arun Kamble
  0 siblings, 0 replies; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-10 10:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: rusty, linux-kernel, dri-devel


Adding Rob and Rusty in the review thread.

Kindly review these patches for interface being proposed to set
color/alpha property of planes modeled after glBlendFunc.

 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
 http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html

thanks,
Sagar


On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> From: Sagar Kamble <sagar.a.kamble@intel.com>
> 
> With this patch new flag DRM_MODE_PROP_32BIT_PAIR is added that will help make use
> of 64 bit value of bitmask property as two 32 bit values.
> 
> Cc: airlied@linux.ie
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
>  include/uapi/drm/drm_mode.h |  3 +++
>  2 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 4e43fc2..d0d03ec 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -2993,10 +2993,13 @@ int drm_property_add_enum(struct drm_property *property, int index,
>  
>  	/*
>  	 * Bitmask enum properties have the additional constraint of values
> -	 * from 0 to 63
> +	 * from 0 to 63. For properties with 32BIT_PAIR Flag set this constraint
> +	 * range is 0 to 31.
>  	 */
> -	if ((property->flags & DRM_MODE_PROP_BITMASK) && (value > 63))
> -		return -EINVAL;
> +	if (property->flags & DRM_MODE_PROP_BITMASK)
> +		if (((property->flags & DRM_MODE_PROP_32BIT_PAIR) && (value > 31)) ||
> +		    (value > 63))
> +			return -EINVAL;
>  
>  	if (!list_empty(&property->enum_blob_list)) {
>  		list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
> @@ -3305,9 +3308,16 @@ static bool drm_property_change_is_valid(struct drm_property *property,
>  	} else if (property->flags & DRM_MODE_PROP_BITMASK) {
>  		int i;
>  		uint64_t valid_mask = 0;
> -		for (i = 0; i < property->num_values; i++)
> -			valid_mask |= (1ULL << property->values[i]);
> -		return !(value & ~valid_mask);
> +		uint32_t valid_32bit_mask = 0;
> +		if (property->flags & DRM_MODE_PROP_32BIT_PAIR) {
> +			for (i = 0; i < property->num_values; i++)
> +				valid_32bit_mask |= (1UL << property->values[i]);
> +			return !((value & 0xFFFFFFFF) & ~valid_32bit_mask);
> +		} else {
> +			for (i = 0; i < property->num_values; i++)
> +				valid_mask |= (1ULL << property->values[i]);
> +			return !(value & ~valid_mask);
> +		}
>  	} else if (property->flags & DRM_MODE_PROP_BLOB) {
>  		/* Only the driver knows */
>  		return true;
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index f104c26..5e3a7d9 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -250,6 +250,9 @@ struct drm_mode_get_connector {
>  #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
>  #define DRM_MODE_PROP_BLOB	(1<<4)
>  #define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
> +#define DRM_MODE_PROP_32BIT_PAIR (1<<6) /* 32 bit bitmask of enumerated types
> +					 * and 32 bit of value of the type */
> +
>  
>  struct drm_mode_property_enum {
>  	__u64 value;

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-03  5:43                         ` Sagar Arun Kamble
@ 2014-04-15  9:44                           ` Sagar Arun Kamble
  2014-04-15 10:35                             ` Ville Syrjälä
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-15  9:44 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Daniel Vetter, intel-gfx, Hiremath, Shashidhar, Sharma, Ankitprasad R

Hi Ville,

Somehow I did not receive your review comments
(http://lists.freedesktop.org/archives/intel-gfx/2014-April/042956.html
) in my mailbox.

Here is my input w.r.t patches I have sent for review:

Currently my patches are modeling constant alpha blend factor (assuming
pre-multiplied format) as 

Dc = Sc * Ca + (1 - Ca) * Dc

User space has to supply (<alpha value>, CONSTANT_ALPHA) through drm
property to invoke this blending.

Here are my queries on your proposed approach:

1. src factors are 1, Ca, Sa*Ca and dst factors are 0, 1-Ca, 1-Sa,
1-Sa*Ca: How is factor 0 derived and applicable to Dst and not
applicable to src.

2. With this approach user will know what blend equation is supported.
How does user supply the blend parameters? Should we have another
property that will have blend equation selected and corresponding
parameters?

3. Is flag suggested for pre-multiply ("yes please, premultiply the data
for me") to be set during AddFB?

Kindly check my patches and provide feedback on the approach of stuffing
blend type and blend parameter into single 64bit drm property.


Thanks,
Sagar




On Thu, 2014-04-03 at 11:13 +0530, Sagar Arun Kamble wrote:
> Hi Ville,
> 
> Could you please review these patches.
> 
> thanks,
> Sagar
> 
> 
> On Wed, 2014-04-02 at 11:42 +0530, Sagar Arun Kamble wrote:
> > Reminder for review :)
> > 
> > On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> > > Gentle Reminder for reviewing this and related patches:
> > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> > > 
> > > 
> > > Also, provide views on "how do we handle pre-multiplied alpha pixel
> > > formats or is there need to convey pre-multiplied alpha pixel format
> > > through additional drm property?"
> > > Since we are already advertising supported pre-multiplied formats
> > > during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> > > etc.
> > > 
> > > 
> > > On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > 
> > > > This patch enables constant alpha property for Sprite planes.
> > > > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > > > for applying constant alpha on a plane. To disable constant alpha,
> > > > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > > > 
> > > > v2: Fixing property value comparison in vlv_update_plane with the use
> > > > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > > > Reverting line spacing change in i915_driver_lastclose. Return value
> > > > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > > > 
> > > > Testcase: igt/kms_blend
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > > > ---
> > > >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> > > >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> > > >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> > > >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> > > >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> > > >  5 files changed, 80 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > > > index e4d2b9f..e3a94a3 100644
> > > > --- a/drivers/gpu/drm/i915/i915_dma.c
> > > > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > > > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> > > >  {
> > > >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > > >  
> > > > +	struct intel_plane *plane;
> > > >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> > > >  	 * goes right around and calls lastclose. Check for this and don't clean
> > > >  	 * up anything. */
> > > >  	if (!dev_priv)
> > > >  		return;
> > > >  
> > > > +	if (dev_priv->blend_property) {
> > > > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > > > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > > > +			drm_object_property_set_value(&plane->base.base,
> > > > +						dev_priv->blend_property,
> > > > +						plane->blend_param.value);
> > > > +		}
> > > > +	}
> > > > +
> > > >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > >  		intel_fbdev_restore_mode(dev);
> > > >  		vga_switcheroo_process_delayed_switch();
> > > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > > > index 70fbe90..0d1be70 100644
> > > > --- a/drivers/gpu/drm/i915/i915_drv.h
> > > > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > > > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> > > >  
> > > >  	struct drm_property *broadcast_rgb_property;
> > > >  	struct drm_property *force_audio_property;
> > > > +	struct drm_property *blend_property;
> > > >  
> > > >  	uint32_t hw_context_size;
> > > >  	struct list_head context_list;
> > > > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > > > index 6174fda..bfcfe72 100644
> > > > --- a/drivers/gpu/drm/i915/i915_reg.h
> > > > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > > > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> > > >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> > > >  #define   SPRITE_TILED			(1<<10)
> > > >  #define   SPRITE_DEST_KEY		(1<<2)
> > > > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > > > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> > > >  #define _SPRA_LINOFF		0x70284
> > > >  #define _SPRA_STRIDE		0x70288
> > > >  #define _SPRA_POS		0x7028c
> > > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > > index f4e0615..039a800 100644
> > > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > > @@ -409,6 +409,13 @@ struct intel_plane {
> > > >  	unsigned int crtc_w, crtc_h;
> > > >  	uint32_t src_x, src_y;
> > > >  	uint32_t src_w, src_h;
> > > > +	union {
> > > > +		uint64_t value;
> > > > +		struct {
> > > > +			unsigned int type;
> > > > +			unsigned int factor;
> > > > +		} details;
> > > > +	} blend_param;
> > > >  
> > > >  	/* Since we need to change the watermarks before/after
> > > >  	 * enabling/disabling the planes, we need to store the parameters here
> > > > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > > > index 9436f18..9ec84bb 100644
> > > > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > > > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > > > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > >  	int pipe = intel_plane->pipe;
> > > >  	int plane = intel_plane->plane;
> > > >  	u32 sprctl;
> > > > +	u32 sprconstalpha;
> > > > +	unsigned int blend_type, blend_factor;
> > > >  	unsigned long sprsurf_offset, linear_offset;
> > > >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> > > >  
> > > >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> > > >  
> > > > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > > > +
> > > >  	/* Mask out pixel format bits in case we change it */
> > > >  	sprctl &= ~SP_PIXFORMAT_MASK;
> > > >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > > > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > >  		break;
> > > >  	}
> > > >  
> > > > +	/* Handle plane alpha and color blending properties */
> > > > +	blend_type = intel_plane->blend_param.details.type;
> > > > +	blend_factor = intel_plane->blend_param.details.factor;
> > > > +
> > > > +	switch (blend_type) {
> > > > +	case BIT(DRM_BLEND_SRC_COLOR):
> > > > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > +		break;
> > > > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > > > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > > > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > +		break;
> > > > +	default:
> > > > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > > > +		break;
> > > > +	}
> > > > +
> > > >  	/*
> > > >  	 * Enable gamma to match primary/cursor plane behaviour.
> > > >  	 * FIXME should be user controllable via propertiesa.
> > > > @@ -1011,6 +1032,26 @@ out_unlock:
> > > >  	return ret;
> > > >  }
> > > >  
> > > > +static int intel_plane_set_property(struct drm_plane *plane,
> > > > +				    struct drm_property *prop,
> > > > +				    uint64_t val)
> > > > +{
> > > > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > > > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > +	uint64_t old_val;
> > > > +	int ret = -EINVAL;
> > > > +
> > > > +	if (prop == dev_priv->blend_property) {
> > > > +		old_val = intel_plane->blend_param.value;
> > > > +		intel_plane->blend_param.value = val;
> > > > +		ret = intel_plane_restore(plane);
> > > > +		if (ret)
> > > > +			intel_plane->blend_param.value = old_val;
> > > > +	}
> > > > +
> > > > +	return ret;
> > > > +}
> > > > +
> > > >  int intel_plane_restore(struct drm_plane *plane)
> > > >  {
> > > >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> > > >  	.update_plane = intel_update_plane,
> > > >  	.disable_plane = intel_disable_plane,
> > > >  	.destroy = intel_destroy_plane,
> > > > +	.set_property = intel_plane_set_property,
> > > >  };
> > > >  
> > > >  static uint32_t ilk_plane_formats[] = {
> > > > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> > > >  int
> > > >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > >  {
> > > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > > >  	struct intel_plane *intel_plane;
> > > >  	unsigned long possible_crtcs;
> > > >  	const uint32_t *plane_formats;
> > > > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > >  
> > > >  	intel_plane->pipe = pipe;
> > > >  	intel_plane->plane = plane;
> > > > +	/* Initialize drm properties for plane */
> > > > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > > > +	intel_plane->blend_param.details.factor = 0;
> > > > +
> > > >  	possible_crtcs = (1 << pipe);
> > > >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> > > >  			     &intel_plane_funcs,
> > > >  			     plane_formats, num_plane_formats,
> > > >  			     false);
> > > > -	if (ret)
> > > > +	if (ret) {
> > > >  		kfree(intel_plane);
> > > > +		goto out;
> > > > +	}
> > > > +
> > > > +	if (!dev_priv->blend_property)
> > > > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > > > +							BIT(DRM_BLEND_SRC_COLOR) |
> > > > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> > > >  
> > > > +	if (dev_priv->blend_property)
> > > > +		drm_object_attach_property(&intel_plane->base.base,
> > > > +				dev_priv->blend_property,
> > > > +				intel_plane->blend_param.value);
> > > > +out:
> > > >  	return ret;
> > > >  }
> > > 
> > 
> 

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-15  9:44                           ` Sagar Arun Kamble
@ 2014-04-15 10:35                             ` Ville Syrjälä
  2014-04-15 11:23                               ` Sagar Arun Kamble
  0 siblings, 1 reply; 53+ messages in thread
From: Ville Syrjälä @ 2014-04-15 10:35 UTC (permalink / raw)
  To: Sagar Arun Kamble
  Cc: Daniel Vetter, intel-gfx, Hiremath, Shashidhar, Sharma, Ankitprasad R

On Tue, Apr 15, 2014 at 03:14:04PM +0530, Sagar Arun Kamble wrote:
> Hi Ville,
> 
> Somehow I did not receive your review comments
> (http://lists.freedesktop.org/archives/intel-gfx/2014-April/042956.html
> ) in my mailbox.
> 
> Here is my input w.r.t patches I have sent for review:
> 
> Currently my patches are modeling constant alpha blend factor (assuming
> pre-multiplied format) as 
> 
> Dc = Sc * Ca + (1 - Ca) * Dc
> 
> User space has to supply (<alpha value>, CONSTANT_ALPHA) through drm
> property to invoke this blending.
> 
> Here are my queries on your proposed approach:
> 
> 1. src factors are 1, Ca, Sa*Ca and dst factors are 0, 1-Ca, 1-Sa,
> 1-Sa*Ca: How is factor 0 derived and applicable to Dst and not
> applicable to src.

If blending is disabled the function will be Dc = Sc * 1 + 0 * Dc

Hence we get the ONE and ZERO blend factors.

> 
> 2. With this approach user will know what blend equation is supported.
> How does user supply the blend parameters? Should we have another
> property that will have blend equation selected and corresponding
> parameters?

By parameters you mean the constant alpha and background color for
instance? I think having those as separate properties is the cleanest
option.

> 
> 3. Is flag suggested for pre-multiply ("yes please, premultiply the data
> for me") to be set during AddFB?

If we define the flag that way, then I think we should make it part of
the blend equation rather than apply it to the FB. Or it could even be
a separate plane property. 

> 
> Kindly check my patches and provide feedback on the approach of stuffing
> blend type and blend parameter into single 64bit drm property.

I think we should avoid trying to stuff too much data into a single
property. IMO blend equation can be one property, constant alpha,
background color, pre-multiplication may be other properties.

> 
> 
> Thanks,
> Sagar
> 
> 
> 
> 
> On Thu, 2014-04-03 at 11:13 +0530, Sagar Arun Kamble wrote:
> > Hi Ville,
> > 
> > Could you please review these patches.
> > 
> > thanks,
> > Sagar
> > 
> > 
> > On Wed, 2014-04-02 at 11:42 +0530, Sagar Arun Kamble wrote:
> > > Reminder for review :)
> > > 
> > > On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> > > > Gentle Reminder for reviewing this and related patches:
> > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> > > > 
> > > > 
> > > > Also, provide views on "how do we handle pre-multiplied alpha pixel
> > > > formats or is there need to convey pre-multiplied alpha pixel format
> > > > through additional drm property?"
> > > > Since we are already advertising supported pre-multiplied formats
> > > > during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> > > > etc.
> > > > 
> > > > 
> > > > On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > 
> > > > > This patch enables constant alpha property for Sprite planes.
> > > > > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > > > > for applying constant alpha on a plane. To disable constant alpha,
> > > > > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > > > > 
> > > > > v2: Fixing property value comparison in vlv_update_plane with the use
> > > > > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > > > > Reverting line spacing change in i915_driver_lastclose. Return value
> > > > > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > > > > 
> > > > > Testcase: igt/kms_blend
> > > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> > > > >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> > > > >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> > > > >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> > > > >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> > > > >  5 files changed, 80 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > > > > index e4d2b9f..e3a94a3 100644
> > > > > --- a/drivers/gpu/drm/i915/i915_dma.c
> > > > > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > > > > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> > > > >  {
> > > > >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > > > >  
> > > > > +	struct intel_plane *plane;
> > > > >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> > > > >  	 * goes right around and calls lastclose. Check for this and don't clean
> > > > >  	 * up anything. */
> > > > >  	if (!dev_priv)
> > > > >  		return;
> > > > >  
> > > > > +	if (dev_priv->blend_property) {
> > > > > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > > > > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > > > > +			drm_object_property_set_value(&plane->base.base,
> > > > > +						dev_priv->blend_property,
> > > > > +						plane->blend_param.value);
> > > > > +		}
> > > > > +	}
> > > > > +
> > > > >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > >  		intel_fbdev_restore_mode(dev);
> > > > >  		vga_switcheroo_process_delayed_switch();
> > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > > > > index 70fbe90..0d1be70 100644
> > > > > --- a/drivers/gpu/drm/i915/i915_drv.h
> > > > > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > > > > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> > > > >  
> > > > >  	struct drm_property *broadcast_rgb_property;
> > > > >  	struct drm_property *force_audio_property;
> > > > > +	struct drm_property *blend_property;
> > > > >  
> > > > >  	uint32_t hw_context_size;
> > > > >  	struct list_head context_list;
> > > > > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > > > > index 6174fda..bfcfe72 100644
> > > > > --- a/drivers/gpu/drm/i915/i915_reg.h
> > > > > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > > > > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> > > > >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> > > > >  #define   SPRITE_TILED			(1<<10)
> > > > >  #define   SPRITE_DEST_KEY		(1<<2)
> > > > > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > > > > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> > > > >  #define _SPRA_LINOFF		0x70284
> > > > >  #define _SPRA_STRIDE		0x70288
> > > > >  #define _SPRA_POS		0x7028c
> > > > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > > > index f4e0615..039a800 100644
> > > > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > > > @@ -409,6 +409,13 @@ struct intel_plane {
> > > > >  	unsigned int crtc_w, crtc_h;
> > > > >  	uint32_t src_x, src_y;
> > > > >  	uint32_t src_w, src_h;
> > > > > +	union {
> > > > > +		uint64_t value;
> > > > > +		struct {
> > > > > +			unsigned int type;
> > > > > +			unsigned int factor;
> > > > > +		} details;
> > > > > +	} blend_param;
> > > > >  
> > > > >  	/* Since we need to change the watermarks before/after
> > > > >  	 * enabling/disabling the planes, we need to store the parameters here
> > > > > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > index 9436f18..9ec84bb 100644
> > > > > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > > > > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > >  	int pipe = intel_plane->pipe;
> > > > >  	int plane = intel_plane->plane;
> > > > >  	u32 sprctl;
> > > > > +	u32 sprconstalpha;
> > > > > +	unsigned int blend_type, blend_factor;
> > > > >  	unsigned long sprsurf_offset, linear_offset;
> > > > >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> > > > >  
> > > > >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> > > > >  
> > > > > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > > > > +
> > > > >  	/* Mask out pixel format bits in case we change it */
> > > > >  	sprctl &= ~SP_PIXFORMAT_MASK;
> > > > >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > > > > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > >  		break;
> > > > >  	}
> > > > >  
> > > > > +	/* Handle plane alpha and color blending properties */
> > > > > +	blend_type = intel_plane->blend_param.details.type;
> > > > > +	blend_factor = intel_plane->blend_param.details.factor;
> > > > > +
> > > > > +	switch (blend_type) {
> > > > > +	case BIT(DRM_BLEND_SRC_COLOR):
> > > > > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > +		break;
> > > > > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > > > > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > > > > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > +		break;
> > > > > +	default:
> > > > > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > > > > +		break;
> > > > > +	}
> > > > > +
> > > > >  	/*
> > > > >  	 * Enable gamma to match primary/cursor plane behaviour.
> > > > >  	 * FIXME should be user controllable via propertiesa.
> > > > > @@ -1011,6 +1032,26 @@ out_unlock:
> > > > >  	return ret;
> > > > >  }
> > > > >  
> > > > > +static int intel_plane_set_property(struct drm_plane *plane,
> > > > > +				    struct drm_property *prop,
> > > > > +				    uint64_t val)
> > > > > +{
> > > > > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > > > > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > +	uint64_t old_val;
> > > > > +	int ret = -EINVAL;
> > > > > +
> > > > > +	if (prop == dev_priv->blend_property) {
> > > > > +		old_val = intel_plane->blend_param.value;
> > > > > +		intel_plane->blend_param.value = val;
> > > > > +		ret = intel_plane_restore(plane);
> > > > > +		if (ret)
> > > > > +			intel_plane->blend_param.value = old_val;
> > > > > +	}
> > > > > +
> > > > > +	return ret;
> > > > > +}
> > > > > +
> > > > >  int intel_plane_restore(struct drm_plane *plane)
> > > > >  {
> > > > >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> > > > >  	.update_plane = intel_update_plane,
> > > > >  	.disable_plane = intel_disable_plane,
> > > > >  	.destroy = intel_destroy_plane,
> > > > > +	.set_property = intel_plane_set_property,
> > > > >  };
> > > > >  
> > > > >  static uint32_t ilk_plane_formats[] = {
> > > > > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> > > > >  int
> > > > >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > >  {
> > > > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > > > >  	struct intel_plane *intel_plane;
> > > > >  	unsigned long possible_crtcs;
> > > > >  	const uint32_t *plane_formats;
> > > > > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > >  
> > > > >  	intel_plane->pipe = pipe;
> > > > >  	intel_plane->plane = plane;
> > > > > +	/* Initialize drm properties for plane */
> > > > > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > > > > +	intel_plane->blend_param.details.factor = 0;
> > > > > +
> > > > >  	possible_crtcs = (1 << pipe);
> > > > >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> > > > >  			     &intel_plane_funcs,
> > > > >  			     plane_formats, num_plane_formats,
> > > > >  			     false);
> > > > > -	if (ret)
> > > > > +	if (ret) {
> > > > >  		kfree(intel_plane);
> > > > > +		goto out;
> > > > > +	}
> > > > > +
> > > > > +	if (!dev_priv->blend_property)
> > > > > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > > > > +							BIT(DRM_BLEND_SRC_COLOR) |
> > > > > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> > > > >  
> > > > > +	if (dev_priv->blend_property)
> > > > > +		drm_object_attach_property(&intel_plane->base.base,
> > > > > +				dev_priv->blend_property,
> > > > > +				intel_plane->blend_param.value);
> > > > > +out:
> > > > >  	return ret;
> > > > >  }
> > > > 
> > > 
> > 
> 

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-15 10:35                             ` Ville Syrjälä
@ 2014-04-15 11:23                               ` Sagar Arun Kamble
  2014-04-15 11:44                                 ` Ville Syrjälä
  0 siblings, 1 reply; 53+ messages in thread
From: Sagar Arun Kamble @ 2014-04-15 11:23 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Daniel Vetter, intel-gfx, Hiremath, Shashidhar, Sharma, Ankitprasad R

Hi Ville,

Thanks for the reply.
I have few more queries.
On Tue, 2014-04-15 at 13:35 +0300, Ville Syrjälä wrote:
> On Tue, Apr 15, 2014 at 03:14:04PM +0530, Sagar Arun Kamble wrote:
> > Hi Ville,
> > 
> > Somehow I did not receive your review comments
> > (http://lists.freedesktop.org/archives/intel-gfx/2014-April/042956.html
> > ) in my mailbox.
> > 
> > Here is my input w.r.t patches I have sent for review:
> > 
> > Currently my patches are modeling constant alpha blend factor (assuming
> > pre-multiplied format) as 
> > 
> > Dc = Sc * Ca + (1 - Ca) * Dc
> > 
> > User space has to supply (<alpha value>, CONSTANT_ALPHA) through drm
> > property to invoke this blending.
> > 
> > Here are my queries on your proposed approach:
> > 
> > 1. src factors are 1, Ca, Sa*Ca and dst factors are 0, 1-Ca, 1-Sa,
> > 1-Sa*Ca: How is factor 0 derived and applicable to Dst and not
> > applicable to src.
> 
> If blending is disabled the function will be Dc = Sc * 1 + 0 * Dc
> 
> Hence we get the ONE and ZERO blend factors.
> 
> > 
> > 2. With this approach user will know what blend equation is supported.
> > How does user supply the blend parameters? Should we have another
> > property that will have blend equation selected and corresponding
> > parameters?
> 
> By parameters you mean the constant alpha and background color for
> instance? I think having those as separate properties is the cleanest
> option.
Yes. I meant constant alpha value. For what type of blending background
color will be used?

So, the overall flow will be:

1. User queries supported blending equations.
2. Sets required blend equation.
3. Sets required blend parameters like constant alpha value etc.

Step 2 and 3 need to be done atomically.

> 
> > 
> > 3. Is flag suggested for pre-multiply ("yes please, premultiply the data
> > for me") to be set during AddFB?
> 
> If we define the flag that way, then I think we should make it part of
> the blend equation rather than apply it to the FB. Or it could even be
> a separate plane property. 
> 
This flag is actually part of following factors: SRC_ALPHA,
ONE_MINUS_SRC_ALPHA,SRC_CONST_ALPHA, ONE_MINUS_SRC_CONST_ALPHA.

What action does driver take if user selects these blend factors?
Change the pixel format to non-pre-multiplied format? This is again
coming back to our previous discussion where changing pixel format on
fly should not be done.

 
> > 
> > Kindly check my patches and provide feedback on the approach of stuffing
> > blend type and blend parameter into single 64bit drm property.
> 
> I think we should avoid trying to stuff too much data into a single
> property. IMO blend equation can be one property, constant alpha,
> background color, pre-multiplication may be other properties.
> 
> > 
> > 
> > Thanks,
> > Sagar
> > 
> > 
> > 
> > 
> > On Thu, 2014-04-03 at 11:13 +0530, Sagar Arun Kamble wrote:
> > > Hi Ville,
> > > 
> > > Could you please review these patches.
> > > 
> > > thanks,
> > > Sagar
> > > 
> > > 
> > > On Wed, 2014-04-02 at 11:42 +0530, Sagar Arun Kamble wrote:
> > > > Reminder for review :)
> > > > 
> > > > On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> > > > > Gentle Reminder for reviewing this and related patches:
> > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> > > > > 
> > > > > 
> > > > > Also, provide views on "how do we handle pre-multiplied alpha pixel
> > > > > formats or is there need to convey pre-multiplied alpha pixel format
> > > > > through additional drm property?"
> > > > > Since we are already advertising supported pre-multiplied formats
> > > > > during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> > > > > etc.
> > > > > 
> > > > > 
> > > > > On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > > > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > > 
> > > > > > This patch enables constant alpha property for Sprite planes.
> > > > > > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > > > > > for applying constant alpha on a plane. To disable constant alpha,
> > > > > > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > > > > > 
> > > > > > v2: Fixing property value comparison in vlv_update_plane with the use
> > > > > > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > > > > > Reverting line spacing change in i915_driver_lastclose. Return value
> > > > > > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > > > > > 
> > > > > > Testcase: igt/kms_blend
> > > > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> > > > > >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> > > > > >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> > > > > >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> > > > > >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> > > > > >  5 files changed, 80 insertions(+), 1 deletion(-)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > > > > > index e4d2b9f..e3a94a3 100644
> > > > > > --- a/drivers/gpu/drm/i915/i915_dma.c
> > > > > > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > > > > > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> > > > > >  {
> > > > > >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > > > > >  
> > > > > > +	struct intel_plane *plane;
> > > > > >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> > > > > >  	 * goes right around and calls lastclose. Check for this and don't clean
> > > > > >  	 * up anything. */
> > > > > >  	if (!dev_priv)
> > > > > >  		return;
> > > > > >  
> > > > > > +	if (dev_priv->blend_property) {
> > > > > > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > > > > > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > > > > > +			drm_object_property_set_value(&plane->base.base,
> > > > > > +						dev_priv->blend_property,
> > > > > > +						plane->blend_param.value);
> > > > > > +		}
> > > > > > +	}
> > > > > > +
> > > > > >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > > >  		intel_fbdev_restore_mode(dev);
> > > > > >  		vga_switcheroo_process_delayed_switch();
> > > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > > > > > index 70fbe90..0d1be70 100644
> > > > > > --- a/drivers/gpu/drm/i915/i915_drv.h
> > > > > > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > > > > > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> > > > > >  
> > > > > >  	struct drm_property *broadcast_rgb_property;
> > > > > >  	struct drm_property *force_audio_property;
> > > > > > +	struct drm_property *blend_property;
> > > > > >  
> > > > > >  	uint32_t hw_context_size;
> > > > > >  	struct list_head context_list;
> > > > > > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > > > > > index 6174fda..bfcfe72 100644
> > > > > > --- a/drivers/gpu/drm/i915/i915_reg.h
> > > > > > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > > > > > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> > > > > >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> > > > > >  #define   SPRITE_TILED			(1<<10)
> > > > > >  #define   SPRITE_DEST_KEY		(1<<2)
> > > > > > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > > > > > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> > > > > >  #define _SPRA_LINOFF		0x70284
> > > > > >  #define _SPRA_STRIDE		0x70288
> > > > > >  #define _SPRA_POS		0x7028c
> > > > > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > > > > index f4e0615..039a800 100644
> > > > > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > > > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > > > > @@ -409,6 +409,13 @@ struct intel_plane {
> > > > > >  	unsigned int crtc_w, crtc_h;
> > > > > >  	uint32_t src_x, src_y;
> > > > > >  	uint32_t src_w, src_h;
> > > > > > +	union {
> > > > > > +		uint64_t value;
> > > > > > +		struct {
> > > > > > +			unsigned int type;
> > > > > > +			unsigned int factor;
> > > > > > +		} details;
> > > > > > +	} blend_param;
> > > > > >  
> > > > > >  	/* Since we need to change the watermarks before/after
> > > > > >  	 * enabling/disabling the planes, we need to store the parameters here
> > > > > > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > index 9436f18..9ec84bb 100644
> > > > > > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > > >  	int pipe = intel_plane->pipe;
> > > > > >  	int plane = intel_plane->plane;
> > > > > >  	u32 sprctl;
> > > > > > +	u32 sprconstalpha;
> > > > > > +	unsigned int blend_type, blend_factor;
> > > > > >  	unsigned long sprsurf_offset, linear_offset;
> > > > > >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> > > > > >  
> > > > > >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> > > > > >  
> > > > > > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > > > > > +
> > > > > >  	/* Mask out pixel format bits in case we change it */
> > > > > >  	sprctl &= ~SP_PIXFORMAT_MASK;
> > > > > >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > > > > > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > > >  		break;
> > > > > >  	}
> > > > > >  
> > > > > > +	/* Handle plane alpha and color blending properties */
> > > > > > +	blend_type = intel_plane->blend_param.details.type;
> > > > > > +	blend_factor = intel_plane->blend_param.details.factor;
> > > > > > +
> > > > > > +	switch (blend_type) {
> > > > > > +	case BIT(DRM_BLEND_SRC_COLOR):
> > > > > > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > > +		break;
> > > > > > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > > > > > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > > > > > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > > +		break;
> > > > > > +	default:
> > > > > > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > > > > > +		break;
> > > > > > +	}
> > > > > > +
> > > > > >  	/*
> > > > > >  	 * Enable gamma to match primary/cursor plane behaviour.
> > > > > >  	 * FIXME should be user controllable via propertiesa.
> > > > > > @@ -1011,6 +1032,26 @@ out_unlock:
> > > > > >  	return ret;
> > > > > >  }
> > > > > >  
> > > > > > +static int intel_plane_set_property(struct drm_plane *plane,
> > > > > > +				    struct drm_property *prop,
> > > > > > +				    uint64_t val)
> > > > > > +{
> > > > > > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > > > > > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > > +	uint64_t old_val;
> > > > > > +	int ret = -EINVAL;
> > > > > > +
> > > > > > +	if (prop == dev_priv->blend_property) {
> > > > > > +		old_val = intel_plane->blend_param.value;
> > > > > > +		intel_plane->blend_param.value = val;
> > > > > > +		ret = intel_plane_restore(plane);
> > > > > > +		if (ret)
> > > > > > +			intel_plane->blend_param.value = old_val;
> > > > > > +	}
> > > > > > +
> > > > > > +	return ret;
> > > > > > +}
> > > > > > +
> > > > > >  int intel_plane_restore(struct drm_plane *plane)
> > > > > >  {
> > > > > >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> > > > > >  	.update_plane = intel_update_plane,
> > > > > >  	.disable_plane = intel_disable_plane,
> > > > > >  	.destroy = intel_destroy_plane,
> > > > > > +	.set_property = intel_plane_set_property,
> > > > > >  };
> > > > > >  
> > > > > >  static uint32_t ilk_plane_formats[] = {
> > > > > > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> > > > > >  int
> > > > > >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > > >  {
> > > > > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > > > > >  	struct intel_plane *intel_plane;
> > > > > >  	unsigned long possible_crtcs;
> > > > > >  	const uint32_t *plane_formats;
> > > > > > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > > >  
> > > > > >  	intel_plane->pipe = pipe;
> > > > > >  	intel_plane->plane = plane;
> > > > > > +	/* Initialize drm properties for plane */
> > > > > > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > > > > > +	intel_plane->blend_param.details.factor = 0;
> > > > > > +
> > > > > >  	possible_crtcs = (1 << pipe);
> > > > > >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> > > > > >  			     &intel_plane_funcs,
> > > > > >  			     plane_formats, num_plane_formats,
> > > > > >  			     false);
> > > > > > -	if (ret)
> > > > > > +	if (ret) {
> > > > > >  		kfree(intel_plane);
> > > > > > +		goto out;
> > > > > > +	}
> > > > > > +
> > > > > > +	if (!dev_priv->blend_property)
> > > > > > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > > > > > +							BIT(DRM_BLEND_SRC_COLOR) |
> > > > > > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> > > > > >  
> > > > > > +	if (dev_priv->blend_property)
> > > > > > +		drm_object_attach_property(&intel_plane->base.base,
> > > > > > +				dev_priv->blend_property,
> > > > > > +				intel_plane->blend_param.value);
> > > > > > +out:
> > > > > >  	return ret;
> > > > > >  }
> > > > > 
> > > > 
> > > 
> > 
> 


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 53+ messages in thread

* Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property
  2014-04-15 11:23                               ` Sagar Arun Kamble
@ 2014-04-15 11:44                                 ` Ville Syrjälä
  0 siblings, 0 replies; 53+ messages in thread
From: Ville Syrjälä @ 2014-04-15 11:44 UTC (permalink / raw)
  To: Sagar Arun Kamble
  Cc: Daniel Vetter, intel-gfx, Hiremath, Shashidhar, Sharma, Ankitprasad R

On Tue, Apr 15, 2014 at 04:53:22PM +0530, Sagar Arun Kamble wrote:
> Hi Ville,
> 
> Thanks for the reply.
> I have few more queries.
> On Tue, 2014-04-15 at 13:35 +0300, Ville Syrjälä wrote:
> > On Tue, Apr 15, 2014 at 03:14:04PM +0530, Sagar Arun Kamble wrote:
> > > Hi Ville,
> > > 
> > > Somehow I did not receive your review comments
> > > (http://lists.freedesktop.org/archives/intel-gfx/2014-April/042956.html
> > > ) in my mailbox.
> > > 
> > > Here is my input w.r.t patches I have sent for review:
> > > 
> > > Currently my patches are modeling constant alpha blend factor (assuming
> > > pre-multiplied format) as 
> > > 
> > > Dc = Sc * Ca + (1 - Ca) * Dc
> > > 
> > > User space has to supply (<alpha value>, CONSTANT_ALPHA) through drm
> > > property to invoke this blending.
> > > 
> > > Here are my queries on your proposed approach:
> > > 
> > > 1. src factors are 1, Ca, Sa*Ca and dst factors are 0, 1-Ca, 1-Sa,
> > > 1-Sa*Ca: How is factor 0 derived and applicable to Dst and not
> > > applicable to src.
> > 
> > If blending is disabled the function will be Dc = Sc * 1 + 0 * Dc
> > 
> > Hence we get the ONE and ZERO blend factors.
> > 
> > > 
> > > 2. With this approach user will know what blend equation is supported.
> > > How does user supply the blend parameters? Should we have another
> > > property that will have blend equation selected and corresponding
> > > parameters?
> > 
> > By parameters you mean the constant alpha and background color for
> > instance? I think having those as separate properties is the cleanest
> > option.
> Yes. I meant constant alpha value. For what type of blending background
> color will be used?

The background color just defines what color is at the bottom of the
stack. Typically it's black, but on certain hardware you can configure
it. The only really good use for this feature I can think of is power
saving. If most of the screen is supposed to be painted with a single
solid color, we could configure that background color accordingly and
configure the planes to cover only the parts of the screen where there's
some other content. This way there would be no memory fetches for most
of screen.

> 
> So, the overall flow will be:
> 
> 1. User queries supported blending equations.
> 2. Sets required blend equation.
> 3. Sets required blend parameters like constant alpha value etc.
> 
> Step 2 and 3 need to be done atomically.

Nuclear flip ftw. Before we get that, the best option is probably to
turn off the plane, configure all the properties, and re-enable the
plane. Obviosuly you still risk glitches during the plane
enable/disable, but that's already the case anyway.

> 
> > 
> > > 
> > > 3. Is flag suggested for pre-multiply ("yes please, premultiply the data
> > > for me") to be set during AddFB?
> > 
> > If we define the flag that way, then I think we should make it part of
> > the blend equation rather than apply it to the FB. Or it could even be
> > a separate plane property. 
> > 
> This flag is actually part of following factors: SRC_ALPHA,
> ONE_MINUS_SRC_ALPHA,SRC_CONST_ALPHA, ONE_MINUS_SRC_CONST_ALPHA.

No, based on the docs I have our hardware can effectively perform the
Sc*Sa twice. Once as the premultiplication step, and a second time as
part of the pipe blending. The pipe blending is what the blend equation
will control, and in addition the premultiplication can be performed by
the plane before the data even enters the pipe blender. So we need both
the SRC_ALPHA blend factors and some kind of a premultiplication control.

> 
> What action does driver take if user selects these blend factors?
> Change the pixel format to non-pre-multiplied format? This is again
> coming back to our previous discussion where changing pixel format on
> fly should not be done.
> 
>  
> > > 
> > > Kindly check my patches and provide feedback on the approach of stuffing
> > > blend type and blend parameter into single 64bit drm property.
> > 
> > I think we should avoid trying to stuff too much data into a single
> > property. IMO blend equation can be one property, constant alpha,
> > background color, pre-multiplication may be other properties.
> > 
> > > 
> > > 
> > > Thanks,
> > > Sagar
> > > 
> > > 
> > > 
> > > 
> > > On Thu, 2014-04-03 at 11:13 +0530, Sagar Arun Kamble wrote:
> > > > Hi Ville,
> > > > 
> > > > Could you please review these patches.
> > > > 
> > > > thanks,
> > > > Sagar
> > > > 
> > > > 
> > > > On Wed, 2014-04-02 at 11:42 +0530, Sagar Arun Kamble wrote:
> > > > > Reminder for review :)
> > > > > 
> > > > > On Tue, 2014-04-01 at 10:21 +0530, Sagar Arun Kamble wrote:
> > > > > > Gentle Reminder for reviewing this and related patches:
> > > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042350.html
> > > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042351.html
> > > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042352.html
> > > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042587.html
> > > > > > http://lists.freedesktop.org/archives/intel-gfx/2014-March/042354.html
> > > > > > 
> > > > > > 
> > > > > > Also, provide views on "how do we handle pre-multiplied alpha pixel
> > > > > > formats or is there need to convey pre-multiplied alpha pixel format
> > > > > > through additional drm property?"
> > > > > > Since we are already advertising supported pre-multiplied formats
> > > > > > during intel_plane_init/drm_plane_init by supplying vlv_plane_formats
> > > > > > etc.
> > > > > > 
> > > > > > 
> > > > > > On Tue, 2014-03-25 at 20:02 +0530, sagar.a.kamble@intel.com wrote:
> > > > > > > From: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > > > 
> > > > > > > This patch enables constant alpha property for Sprite planes.
> > > > > > > Client has to set BIT(DRM_BLEND_CONSTANT_ALPHA) | ((alpha value) << 32)
> > > > > > > for applying constant alpha on a plane. To disable constant alpha,
> > > > > > > client has to set BIT(DRM_BLEND_SRC_COLOR)
> > > > > > > 
> > > > > > > v2: Fixing property value comparison in vlv_update_plane with the use
> > > > > > > of BIT(). Replacing DRM_BLEND_NONE by DRM_BLEND_SRC_COLOR.
> > > > > > > Reverting line spacing change in i915_driver_lastclose. Return value
> > > > > > > of intel_plane_set_property is changed to -ENVAL [Damien's Review Comments]
> > > > > > > 
> > > > > > > Testcase: igt/kms_blend
> > > > > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > > > Signed-off-by: Sagar Kamble <sagar.a.kamble@intel.com>
> > > > > > > Tested-by: Sharma, Ankitprasad R <ankitprasad.r.sharma@intel.com>
> > > > > > > ---
> > > > > > >  drivers/gpu/drm/i915/i915_dma.c     | 10 ++++++
> > > > > > >  drivers/gpu/drm/i915/i915_drv.h     |  1 +
> > > > > > >  drivers/gpu/drm/i915/i915_reg.h     |  2 ++
> > > > > > >  drivers/gpu/drm/i915/intel_drv.h    |  7 +++++
> > > > > > >  drivers/gpu/drm/i915/intel_sprite.c | 61 ++++++++++++++++++++++++++++++++++++-
> > > > > > >  5 files changed, 80 insertions(+), 1 deletion(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> > > > > > > index e4d2b9f..e3a94a3 100644
> > > > > > > --- a/drivers/gpu/drm/i915/i915_dma.c
> > > > > > > +++ b/drivers/gpu/drm/i915/i915_dma.c
> > > > > > > @@ -1898,12 +1898,22 @@ void i915_driver_lastclose(struct drm_device * dev)
> > > > > > >  {
> > > > > > >  	drm_i915_private_t *dev_priv = dev->dev_private;
> > > > > > >  
> > > > > > > +	struct intel_plane *plane;
> > > > > > >  	/* On gen6+ we refuse to init without kms enabled, but then the drm core
> > > > > > >  	 * goes right around and calls lastclose. Check for this and don't clean
> > > > > > >  	 * up anything. */
> > > > > > >  	if (!dev_priv)
> > > > > > >  		return;
> > > > > > >  
> > > > > > > +	if (dev_priv->blend_property) {
> > > > > > > +		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
> > > > > > > +			plane->blend_param.value = BIT(DRM_BLEND_SRC_COLOR);
> > > > > > > +			drm_object_property_set_value(&plane->base.base,
> > > > > > > +						dev_priv->blend_property,
> > > > > > > +						plane->blend_param.value);
> > > > > > > +		}
> > > > > > > +	}
> > > > > > > +
> > > > > > >  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> > > > > > >  		intel_fbdev_restore_mode(dev);
> > > > > > >  		vga_switcheroo_process_delayed_switch();
> > > > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > > > > > > index 70fbe90..0d1be70 100644
> > > > > > > --- a/drivers/gpu/drm/i915/i915_drv.h
> > > > > > > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > > > > > > @@ -1607,6 +1607,7 @@ typedef struct drm_i915_private {
> > > > > > >  
> > > > > > >  	struct drm_property *broadcast_rgb_property;
> > > > > > >  	struct drm_property *force_audio_property;
> > > > > > > +	struct drm_property *blend_property;
> > > > > > >  
> > > > > > >  	uint32_t hw_context_size;
> > > > > > >  	struct list_head context_list;
> > > > > > > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > > > > > > index 6174fda..bfcfe72 100644
> > > > > > > --- a/drivers/gpu/drm/i915/i915_reg.h
> > > > > > > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > > > > > > @@ -3774,6 +3774,8 @@ enum punit_power_well {
> > > > > > >  #define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
> > > > > > >  #define   SPRITE_TILED			(1<<10)
> > > > > > >  #define   SPRITE_DEST_KEY		(1<<2)
> > > > > > > +#define	  SPRITE_CONSTANT_ALPHA_ENABLE  (1<<31)
> > > > > > > +#define   SPRITE_CONSTANT_ALPHA_MASK	(0xFF)
> > > > > > >  #define _SPRA_LINOFF		0x70284
> > > > > > >  #define _SPRA_STRIDE		0x70288
> > > > > > >  #define _SPRA_POS		0x7028c
> > > > > > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > > > > > > index f4e0615..039a800 100644
> > > > > > > --- a/drivers/gpu/drm/i915/intel_drv.h
> > > > > > > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > > > > > > @@ -409,6 +409,13 @@ struct intel_plane {
> > > > > > >  	unsigned int crtc_w, crtc_h;
> > > > > > >  	uint32_t src_x, src_y;
> > > > > > >  	uint32_t src_w, src_h;
> > > > > > > +	union {
> > > > > > > +		uint64_t value;
> > > > > > > +		struct {
> > > > > > > +			unsigned int type;
> > > > > > > +			unsigned int factor;
> > > > > > > +		} details;
> > > > > > > +	} blend_param;
> > > > > > >  
> > > > > > >  	/* Since we need to change the watermarks before/after
> > > > > > >  	 * enabling/disabling the planes, we need to store the parameters here
> > > > > > > diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > > index 9436f18..9ec84bb 100644
> > > > > > > --- a/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > > +++ b/drivers/gpu/drm/i915/intel_sprite.c
> > > > > > > @@ -51,11 +51,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > > > >  	int pipe = intel_plane->pipe;
> > > > > > >  	int plane = intel_plane->plane;
> > > > > > >  	u32 sprctl;
> > > > > > > +	u32 sprconstalpha;
> > > > > > > +	unsigned int blend_type, blend_factor;
> > > > > > >  	unsigned long sprsurf_offset, linear_offset;
> > > > > > >  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> > > > > > >  
> > > > > > >  	sprctl = I915_READ(SPCNTR(pipe, plane));
> > > > > > >  
> > > > > > > +	sprconstalpha = SPCONSTALPHA(pipe, plane);
> > > > > > > +
> > > > > > >  	/* Mask out pixel format bits in case we change it */
> > > > > > >  	sprctl &= ~SP_PIXFORMAT_MASK;
> > > > > > >  	sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
> > > > > > > @@ -104,6 +108,23 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
> > > > > > >  		break;
> > > > > > >  	}
> > > > > > >  
> > > > > > > +	/* Handle plane alpha and color blending properties */
> > > > > > > +	blend_type = intel_plane->blend_param.details.type;
> > > > > > > +	blend_factor = intel_plane->blend_param.details.factor;
> > > > > > > +
> > > > > > > +	switch (blend_type) {
> > > > > > > +	case BIT(DRM_BLEND_SRC_COLOR):
> > > > > > > +		I915_WRITE(sprconstalpha, ~SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > > > +		break;
> > > > > > > +	case BIT(DRM_BLEND_CONSTANT_ALPHA):
> > > > > > > +		I915_WRITE(sprconstalpha, (blend_factor & SPRITE_CONSTANT_ALPHA_MASK) |
> > > > > > > +						SPRITE_CONSTANT_ALPHA_ENABLE);
> > > > > > > +		break;
> > > > > > > +	default:
> > > > > > > +		DRM_DEBUG_DRIVER("%x Blending operation not supported", intel_plane->blend_param.details.type);
> > > > > > > +		break;
> > > > > > > +	}
> > > > > > > +
> > > > > > >  	/*
> > > > > > >  	 * Enable gamma to match primary/cursor plane behaviour.
> > > > > > >  	 * FIXME should be user controllable via propertiesa.
> > > > > > > @@ -1011,6 +1032,26 @@ out_unlock:
> > > > > > >  	return ret;
> > > > > > >  }
> > > > > > >  
> > > > > > > +static int intel_plane_set_property(struct drm_plane *plane,
> > > > > > > +				    struct drm_property *prop,
> > > > > > > +				    uint64_t val)
> > > > > > > +{
> > > > > > > +	struct drm_i915_private *dev_priv = plane->dev->dev_private;
> > > > > > > +	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > > > +	uint64_t old_val;
> > > > > > > +	int ret = -EINVAL;
> > > > > > > +
> > > > > > > +	if (prop == dev_priv->blend_property) {
> > > > > > > +		old_val = intel_plane->blend_param.value;
> > > > > > > +		intel_plane->blend_param.value = val;
> > > > > > > +		ret = intel_plane_restore(plane);
> > > > > > > +		if (ret)
> > > > > > > +			intel_plane->blend_param.value = old_val;
> > > > > > > +	}
> > > > > > > +
> > > > > > > +	return ret;
> > > > > > > +}
> > > > > > > +
> > > > > > >  int intel_plane_restore(struct drm_plane *plane)
> > > > > > >  {
> > > > > > >  	struct intel_plane *intel_plane = to_intel_plane(plane);
> > > > > > > @@ -1037,6 +1078,7 @@ static const struct drm_plane_funcs intel_plane_funcs = {
> > > > > > >  	.update_plane = intel_update_plane,
> > > > > > >  	.disable_plane = intel_disable_plane,
> > > > > > >  	.destroy = intel_destroy_plane,
> > > > > > > +	.set_property = intel_plane_set_property,
> > > > > > >  };
> > > > > > >  
> > > > > > >  static uint32_t ilk_plane_formats[] = {
> > > > > > > @@ -1073,6 +1115,7 @@ static uint32_t vlv_plane_formats[] = {
> > > > > > >  int
> > > > > > >  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > > > >  {
> > > > > > > +	struct drm_i915_private *dev_priv = dev->dev_private;
> > > > > > >  	struct intel_plane *intel_plane;
> > > > > > >  	unsigned long possible_crtcs;
> > > > > > >  	const uint32_t *plane_formats;
> > > > > > > @@ -1141,13 +1184,29 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
> > > > > > >  
> > > > > > >  	intel_plane->pipe = pipe;
> > > > > > >  	intel_plane->plane = plane;
> > > > > > > +	/* Initialize drm properties for plane */
> > > > > > > +	intel_plane->blend_param.details.type = BIT(DRM_BLEND_SRC_COLOR);
> > > > > > > +	intel_plane->blend_param.details.factor = 0;
> > > > > > > +
> > > > > > >  	possible_crtcs = (1 << pipe);
> > > > > > >  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
> > > > > > >  			     &intel_plane_funcs,
> > > > > > >  			     plane_formats, num_plane_formats,
> > > > > > >  			     false);
> > > > > > > -	if (ret)
> > > > > > > +	if (ret) {
> > > > > > >  		kfree(intel_plane);
> > > > > > > +		goto out;
> > > > > > > +	}
> > > > > > > +
> > > > > > > +	if (!dev_priv->blend_property)
> > > > > > > +		dev_priv->blend_property = drm_mode_create_blend_property(dev,
> > > > > > > +							BIT(DRM_BLEND_SRC_COLOR) |
> > > > > > > +							BIT(DRM_BLEND_CONSTANT_ALPHA));
> > > > > > >  
> > > > > > > +	if (dev_priv->blend_property)
> > > > > > > +		drm_object_attach_property(&intel_plane->base.base,
> > > > > > > +				dev_priv->blend_property,
> > > > > > > +				intel_plane->blend_param.value);
> > > > > > > +out:
> > > > > > >  	return ret;
> > > > > > >  }
> > > > > > 
> > > > > 
> > > > 
> > > 
> > 
> 

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2014-04-15 11:45 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 10:08 [RFC 1/1] drm/i915: Added support for setting plane alpha through drm property sagar.a.kamble
2014-02-24 15:44 ` Sagar Arun Kamble
2014-03-06 12:03   ` Damien Lespiau
2014-03-06 12:09     ` Damien Lespiau
2014-02-25 18:18 ` Ville Syrjälä
2014-03-04  9:42   ` [Intel-gfx] " Daniel Vetter
2014-03-04 12:06     ` Ville Syrjälä
2014-03-06 10:28       ` [Intel-gfx] " Sagar Arun Kamble
2014-03-06 11:24         ` Daniel Vetter
2014-03-08  8:21           ` [PATCH 0/4] Adding support for plane alpha/color blending " sagar.a.kamble
2014-03-08  8:21             ` [PATCH 1/4] drm: Added plane alpha and color blending property sagar.a.kamble
2014-03-08  8:21               ` sagar.a.kamble
2014-03-20 11:58               ` [Intel-gfx] " Damien Lespiau
2014-03-20 11:58                 ` Damien Lespiau
2014-03-20 14:21               ` [Intel-gfx] " Damien Lespiau
2014-03-08  8:21             ` [PATCH 2/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
2014-03-20 13:51               ` Damien Lespiau
2014-03-25 14:32                 ` [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair sagar.a.kamble
2014-03-25 14:32                   ` sagar.a.kamble
2014-03-25 14:32                   ` [PATCH v2 2/4] drm: Added plane alpha and color blending property sagar.a.kamble
2014-03-25 14:32                     ` sagar.a.kamble
2014-03-25 14:32                   ` [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property sagar.a.kamble
2014-04-01  4:51                     ` Sagar Arun Kamble
2014-04-02  6:12                       ` Sagar Arun Kamble
2014-04-03  5:43                         ` Sagar Arun Kamble
2014-04-15  9:44                           ` Sagar Arun Kamble
2014-04-15 10:35                             ` Ville Syrjälä
2014-04-15 11:23                               ` Sagar Arun Kamble
2014-04-15 11:44                                 ` Ville Syrjälä
2014-03-25 14:32                   ` [PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
2014-03-26 12:30                     ` David Herrmann
2014-03-27  9:03                       ` [PATCH v3 1/1] " sagar.a.kamble
2014-03-27  9:50                         ` sagar.a.kamble
2014-03-27 12:38                           ` David Herrmann
2014-03-27 17:31                             ` [PATCH v4 " sagar.a.kamble
2014-04-10 10:39                   ` [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair Sagar Arun Kamble
2014-04-10 10:39                     ` Sagar Arun Kamble
2014-03-08  8:21             ` [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property sagar.a.kamble
2014-03-19 15:10               ` Damien Lespiau
2014-03-20  9:59                 ` Sagar Arun Kamble
2014-03-20 11:38                   ` Damien Lespiau
2014-03-20 13:51                     ` Daniel Vetter
2014-03-20 14:00                       ` Damien Lespiau
2014-03-08  8:21             ` [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property sagar.a.kamble
2014-03-10 14:43               ` Laurent Pinchart
2014-03-20 14:11             ` [PATCH 0/4] Adding support for plane alpha/color blending through drm property Damien Lespiau
2014-03-20 14:45               ` Damien Lespiau
2014-03-21 13:36                 ` Sagar Arun Kamble
2014-03-21 19:23                   ` Damien Lespiau
2014-04-02 19:36                     ` Ville Syrjälä
2014-03-25 10:03                   ` Sagar Arun Kamble
2014-03-25 10:51                     ` Daniel Vetter
2014-03-25 12:26                       ` Damien Lespiau

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.