[PATCH 4/5] drm/i915: add destination color key support
Alex Deucher
alexdeucher at gmail.com
Tue Nov 8 14:36:11 PST 2011
On Tue, Nov 8, 2011 at 5:06 PM, Daniel Vetter <daniel at ffwll.ch> wrote:
> On Mon, Nov 07, 2011 at 10:02:55AM -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.
>>
>> Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
>
> A few comments below and a snide-y one here: If the goal is simply to keep
> the bubble intact, this is fine by me. If we want something that has the
> chance to be useable by a generic driver I think we want a drm interface
> for plane/crtc properties (you could wire up set_gamma on planes in the
> same series ... ;-) Again, I don't really care ...
Even further off topic, the panel scaler support should ideally be a
property of crtcs/planes rather than a connector property. However,
that would be a bit of pain to implement and keep backwards
compatibility.
Alex
>
> Cheers, Daniel
>
>> ---
>> 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 (1<<31)
>> 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 f458921..1adeda8 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 > 0xffffff)
>> + 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), 0xffffff);
>> + POSTING_READ(SPRKEYMSK(intel_plane->pipe));
>> + mutex_unlock(&dev->struct_mutex);
>
> "Just grab the lock in case" is nice and all, but totally unnecessary
> here. You already grab the mode_config.mutex in the intel ioctl interface
> function.
>
>> +
>> + 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);
>
> dito
>
>> +
>> + 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 @@ snb_disable_plane(struct drm_plane *plane)
>> }
>>
>> static int
>> +snb_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 > 0xffffff)
>> + return -EINVAL;
>> +
>> + intel_plane = to_intel_plane(plane);
>> +
>> + mutex_lock(&dev->struct_mutex);
>> + I915_WRITE(DVSKEYVAL(intel_plane->pipe), value);
>> + I915_WRITE(DVSKEYMSK(intel_plane->pipe), 0xffffff);
>> + POSTING_READ(DVSKEYMSK(intel_plane->pipe));
>> + mutex_unlock(&dev->struct_mutex);
>
> same
>
>> +
>> + return ret;
>> +}
>> +
>> +static u32
>> +snb_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(DVSKEYVAL(intel_plane->pipe));
>> + mutex_unlock(&dev->struct_mutex);
>
> again
>
>> +
>> + return value;
>> +}
>> +
>> +static int
>> intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>> struct drm_framebuffer *fb, int crtc_x, int crtc_y,
>> unsigned int crtc_w, unsigned int crtc_h,
>> @@ -377,6 +456,69 @@ static void intel_destroy_plane(struct drm_plane *plane)
>> kfree(intel_plane);
>> }
>>
>> +int intel_sprite_set_destkey(struct drm_device *dev, void *data,
>> + struct drm_file *file_priv)
>> +{
>> + struct drm_intel_set_sprite_destkey *set = data;
>> + struct drm_i915_private *dev_priv = dev->dev_private;
>> + struct drm_mode_object *obj;
>> + struct drm_plane *plane;
>> + struct intel_plane *intel_plane;
>> + int ret = 0;
>> +
>> + if (!dev_priv)
>> + return -EINVAL;
>> +
>> + if (set->value > 0xffffff)
>> + return -EINVAL;
>> +
>> + mutex_lock(&dev->mode_config.mutex);
>> +
>> + obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE);
>> + if (!obj) {
>> + ret = -EINVAL;
>> + goto out_unlock;
>> + }
>> +
>> + plane = obj_to_plane(obj);
>> + intel_plane = to_intel_plane(plane);
>> + ret = intel_plane->update_destkey(plane, set->value);
>> +
>> +out_unlock:
>> + mutex_unlock(&dev->mode_config.mutex);
>> + return ret;
>> +}
>> +
>> +int intel_sprite_get_destkey(struct drm_device *dev, void *data,
>> + struct drm_file *file_priv)
>> +{
>> + struct drm_intel_get_sprite_destkey *get = data;
>> + struct drm_i915_private *dev_priv = dev->dev_private;
>> + struct drm_mode_object *obj;
>> + struct drm_plane *plane;
>> + struct intel_plane *intel_plane;
>> + int ret = 0;
>> +
>> + if (!dev_priv)
>> + return -EINVAL;
>> +
>> + mutex_lock(&dev->mode_config.mutex);
>> +
>> + obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE);
>> + if (!obj) {
>> + ret = -EINVAL;
>> + goto out_unlock;
>> + }
>> +
>> + plane = obj_to_plane(obj);
>> + intel_plane = to_intel_plane(plane);
>> + get->value = intel_plane->get_destkey(plane);
>> +
>> +out_unlock:
>> + mutex_unlock(&dev->mode_config.mutex);
>> + return ret;
>> +}
>
> Frankly I'd prefer the driver code to simply keep track of the destkey
> instead of interogating the hw with the ->get_destkey call.
>
>> +
>> static const struct drm_plane_funcs intel_plane_funcs = {
>> .update_plane = intel_update_plane,
>> .disable_plane = intel_disable_plane,
>> @@ -411,10 +553,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
>> intel_plane->max_downscale = 16;
>> intel_plane->update_plane = snb_update_plane;
>> intel_plane->disable_plane = snb_disable_plane;
>> + intel_plane->update_destkey = snb_update_destkey;
>> + intel_plane->get_destkey = snb_get_destkey;
>> } else if (IS_GEN7(dev)) {
>> intel_plane->max_downscale = 2;
>> intel_plane->update_plane = ivb_update_plane;
>> intel_plane->disable_plane = ivb_disable_plane;
>> + intel_plane->update_destkey = ivb_update_destkey;
>> + intel_plane->get_destkey = ivb_get_destkey;
>> }
>>
>> intel_plane->pipe = pipe;
>> diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
>> index 28c0d11..71674b3 100644
>> --- a/include/drm/i915_drm.h
>> +++ b/include/drm/i915_drm.h
>> @@ -198,6 +198,8 @@ typedef struct _drm_i915_sarea {
>> #define DRM_I915_OVERLAY_PUT_IMAGE 0x27
>> #define DRM_I915_OVERLAY_ATTRS 0x28
>> #define DRM_I915_GEM_EXECBUFFER2 0x29
>> +#define DRM_I915_GET_SPRITE_DESTKEY 0x2a
>> +#define DRM_I915_SET_SPRITE_DESTKEY 0x2b
>>
>> #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
>> #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
>> @@ -239,6 +241,8 @@ typedef struct _drm_i915_sarea {
>> #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
>> #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
>> #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
>> +#define DRM_IOCTL_I915_SET_SPRITE_DESTKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_DESTKEY, struct drm_intel_set_sprite_destkey)
>> +#define DRM_IOCTL_I915_GET_SPRITE_DESTKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_DESTKEY, struct drm_intel_get_sprite_destkey)
>>
>> /* Allow drivers to submit batchbuffers directly to hardware, relying
>> * on the security mechanisms provided by hardware.
>> @@ -844,4 +848,16 @@ struct drm_intel_overlay_attrs {
>> __u32 gamma5;
>> };
>>
>> +/* 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;
>> +};
>> +
>> #endif /* _I915_DRM_H_ */
>> --
> --
> Daniel Vetter
> Mail: daniel at ffwll.ch
> Mobile: +41 (0)79 365 57 48
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
More information about the dri-devel
mailing list