Skip to contentSkip to conversation

Adding support for plane constant alpha drm property.

PATCH In review [email protected] 1 participant 5 messages May 5, 2014 – Jun 3, 2014

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

cover Adding support for plane constant alpha drm property.

From: Sagar Kamble <[email protected]>

This patch series introduces drm property for plane level alpha.
These patches are based on following patches which are already under review/reviewed:

Documentation: drm: describing drm properties exposed by various drivers Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller.

Sagar Kamble (3):
drm/i915: Add set_property function for planes drm/i915: Enabling constant alpha drm property
Documentation: drm: describing plane constant alpha property

 Documentation/DocBook/drm.tmpl      | 10 ++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 11 ++++++++++
 drivers/gpu/drm/i915/i915_drv.h     |  1 +
 drivers/gpu/drm/i915/i915_reg.h     |  1 +
 drivers/gpu/drm/i915/intel_drv.h    |  1 +
 drivers/gpu/drm/i915/intel_sprite.c | 43 ++++++++++++++++++++++++++++++++++++-
 6 files changed, 65 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.5
#1 lore raw

PATCH 1/3 drm/i915: Add set_property function for planes

From: Sagar Kamble <[email protected]>

---
 drivers/gpu/drm/i915/i915_dma.c     | 2 ++
 drivers/gpu/drm/i915/intel_sprite.c | 9 +++++++++
 2 files changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_dma.c +2 -0
index 96177ee..191c5e6 100644
@@ -1903,6 +1903,8 @@ void i915_driver_lastclose(struct drm_device * dev)
 	if (!dev_priv)
 		return;
 
+	/* Restore drm properties if any to their default values */
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		intel_fbdev_restore_mode(dev);
 		vga_switcheroo_process_delayed_switch();
drivers/gpu/drm/i915/intel_sprite.c +9 -0
index 9436f18..c46e18d 100644
@@ -1011,6 +1011,14 @@ out_unlock:
 	return ret;
 }
 
+static int intel_plane_set_property(struct drm_plane *plane,
+				    struct drm_property *prop,
+				    uint64_t val)
+{
+	int ret = -EINVAL;
+	return ret;
+}
+
 int intel_plane_restore(struct drm_plane *plane)
 {
 	struct intel_plane *intel_plane = to_intel_plane(plane);
@@ -1037,6 +1045,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[] = {
Signature · 1 line
1.8.5
#2 lore raw

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

In reply to [email protected]

From: Sagar Kamble <[email protected]>

Testcase: kms_plane_props

---
 drivers/gpu/drm/i915/i915_dma.c     |  9 +++++++++
 drivers/gpu/drm/i915/i915_drv.h     |  1 +
 drivers/gpu/drm/i915/i915_reg.h     |  1 +
 drivers/gpu/drm/i915/intel_drv.h    |  1 +
 drivers/gpu/drm/i915/intel_sprite.c | 34 +++++++++++++++++++++++++++++++++-
 5 files changed, 45 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +9 -0
index 191c5e6..bd6ca0a 100644
@@ -1896,6 +1896,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 void i915_driver_lastclose(struct drm_device * dev)
 {
 	struct drm_i915_private *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
@@ -1904,6 +1905,14 @@ void i915_driver_lastclose(struct drm_device * dev)
 		return;
 
 	/* Restore drm properties if any to their default values */
+	if (dev_priv->const_alpha_property) {
+		list_for_each_entry(plane, &dev->mode_config.plane_list, base.head) {
+			plane->const_alpha = 255;
+			drm_object_property_set_value(&plane->base.base,
+						dev_priv->const_alpha_property,
+						plane->const_alpha);
+		}
+	}
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		intel_fbdev_restore_mode(dev);
drivers/gpu/drm/i915/i915_drv.h +1 -0
index ec82f6b..7b3d430 100644
@@ -1587,6 +1587,7 @@ typedef struct drm_i915_private {
 
 	struct drm_property *broadcast_rgb_property;
 	struct drm_property *force_audio_property;
+	struct drm_property *const_alpha_property;
 
 	uint32_t hw_context_size;
 	struct list_head context_list;
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 9f5b18d..db91c53 100644
@@ -3780,6 +3780,7 @@ 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 _SPRA_LINOFF		0x70284
 #define _SPRA_STRIDE		0x70288
 #define _SPRA_POS		0x7028c
drivers/gpu/drm/i915/intel_drv.h +1 -0
index bfc8073..777942d 100644
@@ -416,6 +416,7 @@ struct intel_plane {
 	unsigned int crtc_w, crtc_h;
 	uint32_t src_x, src_y;
 	uint32_t src_w, src_h;
+	uint8_t const_alpha;
 
 	/* 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 +33 -1
index c46e18d..cc7efe1 100644
@@ -51,10 +51,12 @@ 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 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;
@@ -104,6 +106,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 		break;
 	}
 
+	I915_WRITE(sprconstalpha, (intel_plane->const_alpha | SPRITE_CONSTANT_ALPHA_ENABLE));
 	/*
 	 * Enable gamma to match primary/cursor plane behaviour.
 	 * FIXME should be user controllable via propertiesa.
@@ -1015,7 +1018,22 @@ 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);
 	int ret = -EINVAL;
+	uint8_t old_val = 255;
+
+	if (prop == dev_priv->const_alpha_property) {
+		if (val >= 0 && val <= 255) {
+			old_val = intel_plane->const_alpha;
+			intel_plane->const_alpha = val & 0xFF;
+			ret = intel_plane_restore(plane);
+			if (ret)
+				intel_plane->const_alpha = old_val;
+		} else
+			DRM_ERROR("Invalid alpha value supplied\n");
+	}
+
 	return ret;
 }
 
@@ -1087,6 +1105,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	const uint32_t *plane_formats;
 	int num_plane_formats;
 	int ret;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 
 	if (INTEL_INFO(dev)->gen < 5)
 		return -ENODEV;
@@ -1148,6 +1167,8 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 		return -ENODEV;
 	}
 
+	intel_plane->const_alpha = 255;
+
 	intel_plane->pipe = pipe;
 	intel_plane->plane = plane;
 	possible_crtcs = (1 << pipe);
@@ -1155,8 +1176,19 @@ 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->const_alpha_property)
+		dev_priv->const_alpha_property = drm_property_create_range(dev, 0,
+				   "const-alpha", 0, 255);
 
+	if (dev_priv->const_alpha_property)
+		drm_object_attach_property(&intel_plane->base.base,
+				dev_priv->const_alpha_property,
+				intel_plane->const_alpha);
+out:
 	return ret;
 }
Signature · 1 line
1.8.5
#3 lore raw

PATCH 3/3 Documentation: drm: describing plane constant alpha property

In reply to [email protected]

From: Sagar Kamble <[email protected]>

---
 Documentation/DocBook/drm.tmpl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Documentation/DocBook/drm.tmpl +9 -1
index a5d66c1..7228712 100644
@@ -2606,7 +2606,7 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >TBD</td>
 	</tr>
 	<tr>
-	<td rowspan="21" valign="top" >i915</td>
+	<td rowspan="22" valign="top" >i915</td>
 	<td rowspan="3" valign="top" >Generic</td>
 	<td valign="top" >"Broadcast RGB"</td>
 	<td valign="top" >ENUM</td>
@@ -2629,6 +2629,14 @@ void intel_crt_init(struct drm_device *dev)
 	<td valign="top" >TBD</td>
 	</tr>
 	<tr>
+	<td rowspan="1" valign="top" >Overlay</td>
+	<td valign="top" >"const-alpha"</td>
+	<td valign="top" >RANGE</td>
+	<td valign="top" >Min=0, Max=255</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Sets the plane level alpha value</td>
+	</tr>
+	<tr>
 	<td rowspan="17" valign="top" >SDVO-TV</td>
 	<td valign="top" >.mode.</td>
 	<td valign="top" >ENUM</td>
Signature · 1 line
1.8.5
#4 lore raw
In reply to [email protected]

Gentle reminder for reviewing the patches.

Thanks,
Sagar

Quoted 21 lines · On Mon, 2014-05-05 at 23:44 +0530, [email protected] wrote:

From: Sagar Kamble <[email protected]>

This patch series introduces drm property for plane level alpha.
These patches are based on following patches which are already under review/reviewed:

Documentation: drm: describing drm properties exposed by various drivers Propagate the error from intel_update_plane() up through intel_plane_restore() to the caller.

Sagar Kamble (3):
drm/i915: Add set_property function for planes drm/i915: Enabling constant alpha drm property
Documentation: drm: describing plane constant alpha property

 Documentation/DocBook/drm.tmpl      | 10 ++++++++-
 drivers/gpu/drm/i915/i915_dma.c     | 11 ++++++++++
 drivers/gpu/drm/i915/i915_drv.h     |  1 +
 drivers/gpu/drm/i915/i915_reg.h     |  1 +
 drivers/gpu/drm/i915/intel_drv.h    |  1 +
 drivers/gpu/drm/i915/intel_sprite.c | 43 ++++++++++++++++++++++++++++++++++++-
 6 files changed, 65 insertions(+), 2 deletions(-)