Skip to contentSkip to conversation

drm/i915: Added support for setting plane alpha through drm property

RFC In review [email protected] 6 participants 48 messages Feb 19, 2014 – Apr 15, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 drm/i915: Added support for setting plane alpha through drm property

From: Sagar Kamble <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 8c64831..5ced53d 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 2f564ce..039270e 100644
@@ -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)
drivers/gpu/drm/i915/intel_display.c +156 -0

192 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +7 -1
index a4ffc02..0080d3a 100644
@@ -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);
drivers/gpu/drm/i915/intel_sprite.c +51 -8

107 lines not on this page · raw message

Signature · 1 line
1.8.5
#1 lore raw

Gentle Reminder !!!
Kindly review and provide feedback

thanks,
Sagar

Quoted 416 lines · On Wed, 2014-02-19 at 15:38 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

---
 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(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 8c64831..5ced53d 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 2f564ce..039270e 100644
@@ -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)
drivers/gpu/drm/i915/intel_display.c +156 -0
index f19e6ea..a854bcb 100644
@@ -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);
 }
 
drivers/gpu/drm/i915/intel_drv.h +7 -1
index a4ffc02..0080d3a 100644
@@ -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);
drivers/gpu/drm/i915/intel_sprite.c +51 -8
index 336ae6c..9f6c91a 100644
@@ -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;
 }
#2 lore raw
Quoted 2 lines · Sagar Arun Kamble

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.

Signature · 1 line
Damien
#3 lore raw
Quoted 12 lines · Damien Lespiau
Quoted 2 lines · Sagar Arun Kamble

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.

Quoted 7 lines

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 :)

Signature · 1 line
Damien
#4 lore raw
In reply to [email protected]
Quoted 7 lines · On Wed, Feb 19, 2014 at 03:38:08PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#5 lore raw
Quoted 47 lines · Ville Syrjälä
Quoted 7 lines · On Wed, Feb 19, 2014 at 03:38:08PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 6 lines

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

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#6 lore raw
Quoted 55 lines · Daniel Vetter
Quoted 47 lines · Ville Syrjälä
Quoted 7 lines · On Wed, Feb 19, 2014 at 03:38:08PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 6 lines

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.

Quoted 6 lines

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.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#7 lore raw
Quoted 66 lines · Ville Syrjälä
Quoted 55 lines · Daniel Vetter
Quoted 47 lines · Ville Syrjälä
Quoted 7 lines · On Wed, Feb 19, 2014 at 03:38:08PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 6 lines

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.

Quoted 6 lines

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.

Quoted 10 lines

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.

Quoted 1 line

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 5 lines · Sagar Arun Kamble

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

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#9 lore raw

cover Adding support for plane alpha/color blending through drm property

From: Sagar Kamble <[email protected]>

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(-)
Signature · 1 line
1.8.5
#10 lore raw

PATCH 1/4 drm: Added plane alpha and color blending property

From: Sagar Kamble <[email protected]>

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

---
 drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_crtc.c +33 -0
index 4e43fc2..15281a3 100644
@@ -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);
include/drm/drm_crtc.h +25 -0
index 784a568..6c5847f 100644
@@ -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,
Signature · 1 line
1.8.5
#11 lore raw

Re: [Intel-gfx] [PATCH 1/4] drm: Added plane alpha and color blending property

Quoted 38 lines · On Sat, Mar 08, 2014 at 01:51:16PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_crtc.c +16 -0
index 4e43fc2..15281a3 100644
@@ -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" },

drivers/gpu/drm/drm_crtc.c void drm_mode_config_cleanup(struct drm_device *dev) · line 4175

Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +10 -0
+		{ 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.

Signature · 1 line
Damien
#12 lore raw

Re: [Intel-gfx] [PATCH 1/4] drm: Added plane alpha and color blending property

In reply to [email protected]
Quoted 39 lines · On Sat, Mar 08, 2014 at 01:51:16PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 drivers/gpu/drm/drm_crtc.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 25 +++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_crtc.c +17 -0
index 4e43fc2..15281a3 100644
@@ -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" },

drivers/gpu/drm/drm_crtc.c void drm_mode_config_cleanup(struct drm_device *dev) · line 4176

Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +10 -0
+		{ 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.

Signature · 1 line
Damien
#13 lore raw

PATCH 2/4 drm/i915: Enabling constant alpha drm property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

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 <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -1
index e4d2b9f..286251d 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 2a319ba..8a82fb7 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 146609a..292d55d 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index 4a4c6dd..e33124c 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1

108 lines not on this page · raw message

Signature · 1 line
1.8.5
#14 lore raw

Re: [PATCH 2/4] drm/i915: Enabling constant alpha drm property

Quoted 9 lines · On Sat, Mar 08, 2014 at 01:51:17PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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 <[email protected]>
Cc: Jani Nikula <[email protected]>
Cc: David Airlie <[email protected]>

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

Quoted 14 lines
---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e4d2b9f..286251d 100644

drivers/gpu/drm/i915/i915_dma.c int i915_driver_open(struct drm_device *dev, struct drm_file *file) · line 1903

Quoted 8 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
@@ -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?

Quoted 104 lines
drivers/gpu/drm/i915/i915_dma.c +9 -0
 	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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 2a319ba..8a82fb7 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 146609a..292d55d 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index 4a4c6dd..e33124c 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +21 -0
index 9436f18..4c3d2a2 100644
@@ -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;

drivers/gpu/drm/i915/intel_sprite.c out_unlock: · line 1042

Quoted 10 lines
drivers/gpu/drm/i915/intel_sprite.c +8 -0
 }
 
+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.

Quoted 69 lines
drivers/gpu/drm/i915/intel_sprite.c +31 -1
+
+	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;
 }
Signature · 6 lines
1.8.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

PATCH v2 1/4 drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair

From: Sagar Kamble <[email protected]>

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.

---
 drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
 include/uapi/drm/drm_mode.h |  3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_crtc.c +16 -6
index 4e43fc2..d0d03ec 100644
@@ -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;
include/uapi/drm/drm_mode.h +3 -0
index f104c26..5e3a7d9 100644
@@ -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;
Signature · 1 line
1.8.5
#16 lore raw

PATCH v2 2/4 drm: Added plane alpha and color blending property

From: Sagar Kamble <[email protected]>

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.

---
 drivers/gpu/drm/drm_crtc.c | 27 +++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 19 +++++++++++++++++++
 2 files changed, 46 insertions(+)
drivers/gpu/drm/drm_crtc.c +27 -0
index d0d03ec..a1f254e 100644
@@ -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);
include/drm/drm_crtc.h +19 -0
index 784a568..a9fbfec 100644
@@ -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,
Signature · 1 line
1.8.5
#17 lore raw

PATCH v2 3/4 drm/i915: Enabling constant alpha drm property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1

108 lines not on this page · raw message

Signature · 1 line
1.8.5
#18 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
#19 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
#20 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

Hi Ville,

Could you please review these patches.

thanks,
Sagar

Quoted 235 lines · Sagar Arun Kamble

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
#21 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

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

Quoted 245 lines · Sagar Arun Kamble

Hi Ville,

Could you please review these patches.

thanks,
Sagar

Quoted 235 lines · Sagar Arun Kamble

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
#22 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

Quoted 13 lines · Sagar Arun Kamble

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

Quoted 8 lines

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.

Quoted 5 lines

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.

Quoted 3 lines

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.

Quoted 3 lines

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.

Quoted 255 lines

Thanks,
Sagar

Quoted 245 lines · Sagar Arun Kamble

Hi Ville,

Could you please review these patches.

thanks,
Sagar

Quoted 235 lines · Sagar Arun Kamble

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
Signature · 2 lines
Ville Syrjälä
Intel OTC
#23 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

Hi Ville,

Thanks for the reply.
I have few more queries.

Quoted 28 lines · Ville Syrjälä
Quoted 13 lines · Sagar Arun Kamble

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

Quoted 8 lines

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.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

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.

Quoted 9 lines
Quoted 4 lines

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.

Quoted 264 lines
Quoted 3 lines

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.

Quoted 255 lines

Thanks,
Sagar

Quoted 245 lines · Sagar Arun Kamble

Hi Ville,

Could you please review these patches.

thanks,
Sagar

Quoted 235 lines · Sagar Arun Kamble

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#24 lore raw

Re: [PATCH v2 3/4] drm/i915: Enabling constant alpha drm property

Quoted 38 lines · Sagar Arun Kamble

Hi Ville,

Thanks for the reply.
I have few more queries.

Quoted 33 lines · Ville Syrjälä
Quoted 13 lines · Sagar Arun Kamble

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

Quoted 8 lines

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.

Quoted 5 lines

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?

Quoted 5 lines
Quoted 3 lines

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.

Quoted 8 lines

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.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

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

Quoted 6 lines
Quoted 4 lines

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.

Quoted 272 lines

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.

Quoted 264 lines
Quoted 3 lines

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.

Quoted 255 lines

Thanks,
Sagar

Quoted 245 lines · Sagar Arun Kamble

Hi Ville,

Could you please review these patches.

thanks,
Sagar

Quoted 235 lines · Sagar Arun Kamble

Reminder for review :)

Quoted 231 lines · Sagar Arun Kamble

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.

Quoted 213 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_dma.c +10 -0
index e4d2b9f..e3a94a3 100644
@@ -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();
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 70fbe90..0d1be70 100644
@@ -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;
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 6174fda..bfcfe72 100644
@@ -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
drivers/gpu/drm/i915/intel_drv.h +7 -0
index f4e0615..039a800 100644
@@ -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
drivers/gpu/drm/i915/intel_sprite.c +60 -1
index 9436f18..9ec84bb 100644
@@ -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;
 }
Signature · 2 lines
Ville Syrjälä
Intel OTC
#25 lore raw

PATCH v2 4/4 Documentation: drm: describing plane alpha and color blending property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

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
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +22 -1
index 104402a..77a45fb 100644
@@ -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>
Signature · 1 line
1.8.5
#26 lore raw

Re: [PATCH v2 4/4] Documentation: drm: describing plane alpha and color blending property

Hi

Quoted 25 lines · On Tue, Mar 25, 2014 at 3:32 PM, <[email protected]> wrote:

From: Sagar Kamble <[email protected]>

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
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +0 -0
index 104402a..77a45fb 100644

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2261

Quoted 9 lines
Documentation/DocBook/drm.tmpl +6 -0
@@ -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

Quoted 37 lines
Documentation/DocBook/drm.tmpl +16 -2
+        </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

#27 lore raw

PATCH v3 1/1 Documentation: drm: describing plane alpha and color blending property

From: Sagar Kamble <[email protected]>

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
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +22 -1
index 104402a..66386d0 100644
@@ -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>
Signature · 6 lines
1.8.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#28 lore raw

PATCH v3 1/1 Documentation: drm: describing plane alpha and color blending property

From: Sagar Kamble <[email protected]>

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
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +22 -1
index 104402a..66386d0 100644
@@ -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>
Signature · 6 lines
1.8.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#29 lore raw

Re: [PATCH v3 1/1] Documentation: drm: describing plane alpha and color blending property

Hi

Quoted 28 lines · On Thu, Mar 27, 2014 at 10:50 AM, <[email protected]> wrote:

From: Sagar Kamble <[email protected]>

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
---
 Documentation/DocBook/drm.tmpl | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +0 -0
index 104402a..66386d0 100644

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2261

Quoted 9 lines
Documentation/DocBook/drm.tmpl +6 -0
@@ -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.

Quoted 15 lines
Documentation/DocBook/drm.tmpl +3 -1
+        </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>

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2363

Quoted 5 lines
Documentation/DocBook/drm.tmpl +2 -0
@@ -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?

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2367

Quoted 4 lines
Documentation/DocBook/drm.tmpl +4 -0
+       <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?

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2369

Quoted 2 lines
Documentation/DocBook/drm.tmpl +2 -0
+       <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').

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2370

Quoted 1 line
Documentation/DocBook/drm.tmpl +1 -0
+       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).

Documentation/DocBook/drm.tmpl void intel_crt_init(struct drm_device *dev) · line 2372

Quoted 2 lines
Documentation/DocBook/drm.tmpl +2 -0
+       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

Quoted 8 lines
Documentation/DocBook/drm.tmpl +2 -1
+       </tr>
+       <tr>
        <td rowspan="2" valign="top" >DVI-I</td>
        <td valign="top" >"subconnector"</td>
        <td valign="top" >ENUM</td>
--

1.8.5

#30 lore raw

PATCH v4 1/1 Documentation: drm: describing plane alpha and color blending property

From: Sagar Kamble <[email protected]>

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]

---
 Documentation/DocBook/drm.tmpl | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +31 -1
index 104402a..dd2ae67 100644
@@ -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>
Signature · 1 line
1.8.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#31 lore raw

Re: [PATCH v2 1/4] drm: Adding new flag to restrict bitmask drm properties as 32 bit type and 32 bit value pair

In reply to [email protected]

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

Quoted 69 lines · On Tue, 2014-03-25 at 20:02 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

---
 drivers/gpu/drm/drm_crtc.c  | 22 ++++++++++++++++------
 include/uapi/drm/drm_mode.h |  3 +++
 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_crtc.c +16 -6
index 4e43fc2..d0d03ec 100644
@@ -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;
include/uapi/drm/drm_mode.h +3 -0
index f104c26..5e3a7d9 100644
@@ -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;
#32 lore raw

PATCH 3/4 drm/i915: Enabling pre-multiplied alpha drm property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

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 <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
---
 drivers/gpu/drm/i915/intel_drv.h    |  1 +
 drivers/gpu/drm/i915/intel_sprite.c | 73 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index e33124c..44c366d 100644
@@ -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,
drivers/gpu/drm/i915/intel_sprite.c +72 -1

115 lines not on this page · raw message

Signature · 1 line
1.8.5
#33 lore raw

Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property

Quoted 7 lines · On Sat, Mar 08, 2014 at 01:51:18PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 5 lines
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>

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.

Signature · 1 line
Damien
#34 lore raw

Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property

Hi Damien,

Quoted 14 lines · Damien Lespiau
Quoted 7 lines · On Sat, Mar 08, 2014 at 01:51:18PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 5 lines
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Quoted 5 lines

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

#35 lore raw

Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property

Quoted 32 lines · Sagar Arun Kamble

Hi Damien,

Quoted 14 lines · Damien Lespiau
Quoted 7 lines · On Sat, Mar 08, 2014 at 01:51:18PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 5 lines
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Quoted 5 lines

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.

Quoted 2 lines

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.

Signature · 1 line
Damien
#36 lore raw

Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property

Quoted 41 lines · Damien Lespiau
Quoted 32 lines · Sagar Arun Kamble

Hi Damien,

Quoted 14 lines · Damien Lespiau
Quoted 7 lines · On Sat, Mar 08, 2014 at 01:51:18PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 5 lines
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Quoted 5 lines

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.

Quoted 2 lines

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().

Quoted 6 lines

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

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#37 lore raw

Re: [PATCH 3/4] drm/i915: Enabling pre-multiplied alpha drm property

Quoted 4 lines · Daniel Vetter

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.

Signature · 1 line
Damien
#38 lore raw

PATCH 4/4 Documentation: drm: describing plane alpha and color blending property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

Cc Rob Landley <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc David Herrmann <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Ville Syrjälä" <[email protected]>
Cc Sagar Kamble <[email protected]>
Cc "Purushothaman, Vijay A" <[email protected]>
---
 Documentation/DocBook/drm.tmpl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +12 -1
index 5650d13..ba260e8 100644
@@ -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>
Signature · 6 lines
1.8.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#39 lore raw

Re: [PATCH 4/4] Documentation: drm: describing plane alpha and color blending property

Hi Sagar,

Thank you for the patch.

Quoted 41 lines · On Saturday 08 March 2014 13:51:19 [email protected] wrote:

From: Sagar Kamble <[email protected]>

Cc Rob Landley <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc David Herrmann <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Ville Syrjälä" <[email protected]>
Cc Sagar Kamble <[email protected]>
Cc "Purushothaman, Vijay A" <[email protected]>
---
 Documentation/DocBook/drm.tmpl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +4 -1
index 5650d13..ba260e8 100644
@@ -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,
Quoted 6 lines

"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.

Quoted 5 lines

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

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#40 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

In reply to [email protected]
Quoted 13 lines · On Sat, Mar 08, 2014 at 01:51:15PM +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

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.

Quoted 5 lines

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.

Signature · 1 line
Damien
#41 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

Quoted 3 lines · Damien Lespiau

(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)

Signature · 1 line
Damien
#42 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

Hi Damien,

Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Damien Lespiau

(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

#43 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

Quoted 10 lines · Sagar Arun Kamble

Hi Damien,

Quoted 7 lines · Damien Lespiau
Quoted 3 lines · Damien Lespiau

(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:

Quoted 7 lines
Quoted 2 lines

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.

Quoted 7 lines

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.

Signature · 1 line
Damien
#44 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

Quoted 33 lines · Damien Lespiau
Quoted 10 lines · Sagar Arun Kamble

Hi Damien,

Quoted 7 lines · Damien Lespiau
Quoted 3 lines · Damien Lespiau

(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:

Quoted 7 lines
Quoted 2 lines

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.

Quoted 7 lines

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)

Quoted 5 lines

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.

Quoted 5 lines

- 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.

Quoted 2 lines

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.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#45 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

In reply to Sagar Arun Kamble

Hi Damien,

Could you please clarify following queries.

Thanks,
Sagar

Quoted 32 lines · Sagar Arun Kamble

Hi Damien,

Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Damien Lespiau

(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

#46 lore raw

Re: [PATCH 0/4] Adding support for plane alpha/color blending through drm property

Quoted 3 lines · Sagar Arun Kamble

Hi Damien,

Could you please clarify following queries.

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

Quoted 42 lines

Thanks,
Sagar

Quoted 26 lines · Sagar Arun Kamble

Hi Damien,

Quoted 9 lines · Damien Lespiau
Quoted 3 lines · Damien Lespiau

(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

Quoted 6 lines

Kindly clarify.

thanks,
Sagar

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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