@@ -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);
@@ -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;
@@ -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
@@ -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
@@ -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;
}