[Intel-gfx] [PATCH v1 2/3] drm/i915: Enabling constant alpha drm property
sagar.a.kamble at intel.com
sagar.a.kamble at intel.com
Mon May 5 20:14:03 CEST 2014
From: Sagar Kamble <sagar.a.kamble at intel.com>
Testcase: kms_plane_props
Cc: daniel.vetter at ffwll.ch
Cc: jani.nikula at linux.intel.com
Cc: ville.syrjala at linux.intel.com
Cc: indranil.mukherjee at intel.com
Cc: shashidhar.hiremath at intel.com
Cc: vandita.kulkarni at intel.com
Cc: vijay.a.purushothaman at intel.com
Cc: ankitprasad.r.sharma at intel.com
Signed-off-by: Sagar Kamble <sagar.a.kamble at intel.com>
---
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(-)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 191c5e6..bd6ca0a 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -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);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ec82f6b..7b3d430 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 9f5b18d..db91c53 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -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
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index bfc8073..777942d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -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
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index c46e18d..cc7efe1 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -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;
}
--
1.8.5
More information about the Intel-gfx
mailing list