Re: [Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-12-12 Thread Daniel Vetter
On Wed, Dec 07, 2011 at 12:29:22PM -0800, Jesse Barnes wrote:
 Add new ioctls for getting and setting the current destination color
 key.  This allows for simple overlay display control by matching a color
 key value in the primary plane before blending the overlay on top.
 
 v2: remove unnecessary mutex acquire/release around reg accesses
 
 Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org

[snip]

 +/* Set the destination color key on a given sprite */
 +struct drm_intel_set_sprite_destkey {
 + __u32 plane_id;
 + __u32 value;
 +};
 +
 +/* Get the current destination color key on a given sprite */
 +struct drm_intel_get_sprite_destkey {
 + __u32 plane_id;
 + __u32 value;
 +};

As explained in my top-reply, I think we want a __u32 flags here to
enable the colorkey (and maybe switch between dst/src color key). Nothing
else to complain about here.
-Daniel
-- 
Daniel Vetter
Mail: dan...@ffwll.ch
Mobile: +41 (0)79 365 57 48
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-12-07 Thread Jesse Barnes
Add new ioctls for getting and setting the current destination color
key.  This allows for simple overlay display control by matching a color
key value in the primary plane before blending the overlay on top.

v2: remove unnecessary mutex acquire/release around reg accesses

Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
---
 drivers/gpu/drm/i915/i915_dma.c |2 +
 drivers/gpu/drm/i915/i915_reg.h |2 +
 drivers/gpu/drm/i915/intel_drv.h|8 ++
 drivers/gpu/drm/i915/intel_sprite.c |  138 +++
 include/drm/i915_drm.h  |   16 
 5 files changed, 166 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index a9533c5..bc7ee4f 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2295,6 +2295,8 @@ struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, 
DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_DESTKEY, intel_sprite_set_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_DESTKEY, intel_sprite_get_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index a2ce411..860b250 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2738,6 +2738,8 @@
 #define DVSSIZE(pipe) _PIPE(pipe, _DVSASIZE, _DVSBSIZE)
 #define DVSSCALE(pipe) _PIPE(pipe, _DVSASCALE, _DVSBSCALE)
 #define DVSTILEOFF(pipe) _PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
+#define DVSKEYVAL(pipe) _PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
+#define DVSKEYMSK(pipe) _PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
 
 #define _SPRA_CTL  0x70280
 #define   SPRITE_ENABLE(131)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 089cdde..e0407cd 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -190,6 +190,8 @@ struct intel_plane {
 uint32_t x, uint32_t y,
 uint32_t src_w, uint32_t src_h);
void (*disable_plane)(struct drm_plane *plane);
+   int (*update_destkey)(struct drm_plane *plane, u32 value);
+   u32 (*get_destkey)(struct drm_plane *plane);
 };
 
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
@@ -412,4 +414,10 @@ extern void sandybridge_update_wm(struct drm_device *dev);
 extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
   uint32_t sprite_width,
   int pixel_size);
+
+extern int intel_sprite_set_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+extern int intel_sprite_get_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+
 #endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index 18eb7b8..a51edc9 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -96,6 +96,7 @@ ivb_update_plane(struct drm_plane *plane, struct 
drm_framebuffer *fb,
/* must disable */
sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
sprctl |= SPRITE_ENABLE;
+   sprctl |= SPRITE_DEST_KEY;
 
/* Sizes are 0 based */
src_w--;
@@ -154,6 +155,41 @@ ivb_disable_plane(struct drm_plane *plane)
POSTING_READ(SPRSURF(pipe));
 }
 
+static int
+ivb_update_destkey(struct drm_plane *plane, u32 value)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   int ret = 0;
+
+   if (value  0xff)
+   return -EINVAL;
+
+   intel_plane = to_intel_plane(plane);
+
+   I915_WRITE(SPRKEYVAL(intel_plane-pipe), value);
+   I915_WRITE(SPRKEYMSK(intel_plane-pipe), 0xff);
+   POSTING_READ(SPRKEYMSK(intel_plane-pipe));
+
+   return ret;
+}
+
+static u32
+ivb_get_destkey(struct drm_plane *plane)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   u32 value;
+
+   intel_plane = to_intel_plane(plane);
+
+   value = I915_READ(SPRKEYVAL(intel_plane-pipe));
+
+   return value;
+}
+
 static void
 snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
@@ -259,6 +295,41 @@ 

Re: [Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-11-16 Thread Daniel Vetter
On Mon, Nov 14, 2011 at 21:22, Jesse Barnes jbar...@virtuousgeek.org wrote:
 Add new ioctls for getting and setting the current destination color
 key.  This allows for simple overlay display control by matching a color
 key value in the primary plane before blending the overlay on top.

 Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org

Just a few comments because reviewing patches here is a royal pain:
- Is taking dev-struct_mutex really required around the register access?
- You unconditionally enable the color key. Do we anticipate any other
uses (like no color key or dst color key) or is this just the
make-Xv-work ioctl?
- Same for the mask 

Cheers, Daniel
-- 
Daniel Vetter
daniel.vet...@ffwll.ch - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-11-16 Thread Jesse Barnes
On Wed, 16 Nov 2011 17:10:53 +0100
Daniel Vetter dan...@ffwll.ch wrote:

 On Mon, Nov 14, 2011 at 21:22, Jesse Barnes jbar...@virtuousgeek.org wrote:
  Add new ioctls for getting and setting the current destination color
  key.  This allows for simple overlay display control by matching a color
  key value in the primary plane before blending the overlay on top.
 
  Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
 
 Just a few comments because reviewing patches here is a royal pain:
 - Is taking dev-struct_mutex really required around the register access?

Oh did I leave them in place for these paths?  I'll drop them too.

 - You unconditionally enable the color key. Do we anticipate any other
 uses (like no color key or dst color key) or is this just the
 make-Xv-work ioctl?

I was thinking of that...  W/o a src or dest key, the overlay will
always be on top.  That's probably reasonable for simple cases, so
having a key present flag makes sense.

Which means setting a 0 dest key would mean disable dest key and go
back to the default behavior.  So the interface would stay the same
even if we added other key types in the future.

-- 
Jesse Barnes, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-11-14 Thread Jesse Barnes
Add new ioctls for getting and setting the current destination color
key.  This allows for simple overlay display control by matching a color
key value in the primary plane before blending the overlay on top.

Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
---
 drivers/gpu/drm/i915/i915_dma.c |2 +
 drivers/gpu/drm/i915/i915_reg.h |2 +
 drivers/gpu/drm/i915/intel_drv.h|8 ++
 drivers/gpu/drm/i915/intel_sprite.c |  146 +++
 include/drm/i915_drm.h  |   16 
 5 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2eac955..0385a27 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2294,6 +2294,8 @@ struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, 
DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_DESTKEY, intel_sprite_set_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_DESTKEY, intel_sprite_get_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 7929a55..d486bab 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2726,6 +2726,8 @@
 #define DVSSIZE(pipe) _PIPE(pipe, _DVSASIZE, _DVSBSIZE)
 #define DVSSCALE(pipe) _PIPE(pipe, _DVSASCALE, _DVSBSCALE)
 #define DVSTILEOFF(pipe) _PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
+#define DVSKEYVAL(pipe) _PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
+#define DVSKEYMSK(pipe) _PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
 
 #define _SPRA_CTL  0x70280
 #define   SPRITE_ENABLE(131)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f91de00..68ef060 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -190,6 +190,8 @@ struct intel_plane {
 uint32_t x, uint32_t y,
 uint32_t src_w, uint32_t src_h);
void (*disable_plane)(struct drm_plane *plane);
+   int (*update_destkey)(struct drm_plane *plane, u32 value);
+   u32 (*get_destkey)(struct drm_plane *plane);
 };
 
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
@@ -407,4 +409,10 @@ extern void intel_write_eld(struct drm_encoder *encoder,
struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 
+extern int intel_sprite_set_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+extern int intel_sprite_get_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+
+
 #endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index d8ae3e4..b470e9b 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -99,6 +99,7 @@ ivb_update_plane(struct drm_plane *plane, struct 
drm_framebuffer *fb,
/* must disable */
sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
sprctl |= SPRITE_ENABLE;
+   sprctl |= SPRITE_DEST_KEY;
 
/* Sizes are 0 based */
src_w--;
@@ -140,6 +141,45 @@ ivb_disable_plane(struct drm_plane *plane)
POSTING_READ(SPRSURF(pipe));
 }
 
+static int
+ivb_update_destkey(struct drm_plane *plane, u32 value)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   int ret = 0;
+
+   if (value  0xff)
+   return -EINVAL;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   I915_WRITE(SPRKEYVAL(intel_plane-pipe), value);
+   I915_WRITE(SPRKEYMSK(intel_plane-pipe), 0xff);
+   POSTING_READ(SPRKEYMSK(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return ret;
+}
+
+static u32
+ivb_get_destkey(struct drm_plane *plane)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   u32 value;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   value = I915_READ(SPRKEYVAL(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return value;
+}
+
 static void
 snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
@@ -228,6 

[Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-11-14 Thread Jesse Barnes
Add new ioctls for getting and setting the current destination color
key.  This allows for simple overlay display control by matching a color
key value in the primary plane before blending the overlay on top.

Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
---
 drivers/gpu/drm/i915/i915_dma.c |2 +
 drivers/gpu/drm/i915/i915_reg.h |2 +
 drivers/gpu/drm/i915/intel_drv.h|8 ++
 drivers/gpu/drm/i915/intel_sprite.c |  146 +++
 include/drm/i915_drm.h  |   16 
 5 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2eac955..0385a27 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2294,6 +2294,8 @@ struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, 
DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_DESTKEY, intel_sprite_set_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_DESTKEY, intel_sprite_get_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 7929a55..d486bab 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2726,6 +2726,8 @@
 #define DVSSIZE(pipe) _PIPE(pipe, _DVSASIZE, _DVSBSIZE)
 #define DVSSCALE(pipe) _PIPE(pipe, _DVSASCALE, _DVSBSCALE)
 #define DVSTILEOFF(pipe) _PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
+#define DVSKEYVAL(pipe) _PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
+#define DVSKEYMSK(pipe) _PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
 
 #define _SPRA_CTL  0x70280
 #define   SPRITE_ENABLE(131)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f91de00..68ef060 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -190,6 +190,8 @@ struct intel_plane {
 uint32_t x, uint32_t y,
 uint32_t src_w, uint32_t src_h);
void (*disable_plane)(struct drm_plane *plane);
+   int (*update_destkey)(struct drm_plane *plane, u32 value);
+   u32 (*get_destkey)(struct drm_plane *plane);
 };
 
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
@@ -407,4 +409,10 @@ extern void intel_write_eld(struct drm_encoder *encoder,
struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 
+extern int intel_sprite_set_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+extern int intel_sprite_get_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+
+
 #endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index d8ae3e4..b470e9b 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -99,6 +99,7 @@ ivb_update_plane(struct drm_plane *plane, struct 
drm_framebuffer *fb,
/* must disable */
sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
sprctl |= SPRITE_ENABLE;
+   sprctl |= SPRITE_DEST_KEY;
 
/* Sizes are 0 based */
src_w--;
@@ -140,6 +141,45 @@ ivb_disable_plane(struct drm_plane *plane)
POSTING_READ(SPRSURF(pipe));
 }
 
+static int
+ivb_update_destkey(struct drm_plane *plane, u32 value)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   int ret = 0;
+
+   if (value  0xff)
+   return -EINVAL;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   I915_WRITE(SPRKEYVAL(intel_plane-pipe), value);
+   I915_WRITE(SPRKEYMSK(intel_plane-pipe), 0xff);
+   POSTING_READ(SPRKEYMSK(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return ret;
+}
+
+static u32
+ivb_get_destkey(struct drm_plane *plane)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   u32 value;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   value = I915_READ(SPRKEYVAL(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return value;
+}
+
 static void
 snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
@@ -228,6 

[Intel-gfx] [PATCH 2/3] drm/i915: add destination color key support

2011-11-08 Thread Jesse Barnes
Add new ioctls for getting and setting the current destination color
key.  This allows for simple overlay display control by matching a color
key value in the primary plane before blending the overlay on top.

Signed-off-by: Jesse Barnes jbar...@virtuousgeek.org
---
 drivers/gpu/drm/i915/i915_dma.c |2 +
 drivers/gpu/drm/i915/i915_reg.h |2 +
 drivers/gpu/drm/i915/intel_drv.h|8 ++
 drivers/gpu/drm/i915/intel_sprite.c |  146 +++
 include/drm/i915_drm.h  |   16 
 5 files changed, 174 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2eac955..0385a27 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2294,6 +2294,8 @@ struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, 
DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_DESTKEY, intel_sprite_set_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+   DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_DESTKEY, intel_sprite_get_destkey, 
DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index b2270fa..8bed5d8 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2724,6 +2724,8 @@
 #define DVSSIZE(pipe) _PIPE(pipe, _DVSASIZE, _DVSBSIZE)
 #define DVSSCALE(pipe) _PIPE(pipe, _DVSASCALE, _DVSBSCALE)
 #define DVSTILEOFF(pipe) _PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
+#define DVSKEYVAL(pipe) _PIPE(pipe, _DVSAKEYVAL, _DVSBKEYVAL)
+#define DVSKEYMSK(pipe) _PIPE(pipe, _DVSAKEYMSK, _DVSBKEYMSK)
 
 #define _SPRA_CTL  0x70280
 #define   SPRITE_ENABLE(131)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 6284562..b0081d2 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -189,6 +189,8 @@ struct intel_plane {
 uint32_t x, uint32_t y,
 uint32_t src_w, uint32_t src_h);
void (*disable_plane)(struct drm_plane *plane);
+   int (*update_destkey)(struct drm_plane *plane, u32 value);
+   u32 (*get_destkey)(struct drm_plane *plane);
 };
 
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
@@ -406,4 +408,10 @@ extern void intel_write_eld(struct drm_encoder *encoder,
struct drm_display_mode *mode);
 extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
 
+extern int intel_sprite_set_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+extern int intel_sprite_get_destkey(struct drm_device *dev, void *data,
+struct drm_file *file_priv);
+
+
 #endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_sprite.c 
b/drivers/gpu/drm/i915/intel_sprite.c
index a4e9721..7c6c6c7 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -99,6 +99,7 @@ ivb_update_plane(struct drm_plane *plane, struct 
drm_framebuffer *fb,
/* must disable */
sprctl |= SPRITE_TRICKLE_FEED_DISABLE;
sprctl |= SPRITE_ENABLE;
+   sprctl |= SPRITE_DEST_KEY;
 
/* Sizes are 0 based */
src_w--;
@@ -139,6 +140,45 @@ ivb_disable_plane(struct drm_plane *plane)
intel_wait_for_vblank(dev, pipe);
 }
 
+static int
+ivb_update_destkey(struct drm_plane *plane, u32 value)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   int ret = 0;
+
+   if (value  0xff)
+   return -EINVAL;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   I915_WRITE(SPRKEYVAL(intel_plane-pipe), value);
+   I915_WRITE(SPRKEYMSK(intel_plane-pipe), 0xff);
+   POSTING_READ(SPRKEYMSK(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return ret;
+}
+
+static u32
+ivb_get_destkey(struct drm_plane *plane)
+{
+   struct drm_device *dev = plane-dev;
+   struct drm_i915_private *dev_priv = dev-dev_private;
+   struct intel_plane *intel_plane;
+   u32 value;
+
+   intel_plane = to_intel_plane(plane);
+
+   mutex_lock(dev-struct_mutex);
+   value = I915_READ(SPRKEYVAL(intel_plane-pipe));
+   mutex_unlock(dev-struct_mutex);
+
+   return value;
+}
+
 static void
 snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 unsigned long start, int crtc_x, int crtc_y,
@@ -227,6 +267,45