[Intel-gfx] [PATCH xf86-video-intel 1/4] sna/video/sprite: Fix colorkey setup for depth != 24

Chris Wilson chris at chris-wilson.co.uk
Mon Oct 22 16:26:52 UTC 2018


Quoting Ville Syrjala (2018-10-22 14:59:26)
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Set up the colorkey correctly for depth != 24. For 8bpc we
> need to replicate the same key value into each channel, for
> depth 15/16 we need to mask off the unused low bits in each
> channel, and for depth 30 we just use the 8 msbs of each channel
> as the colorkey register can't hold the full 10 bits.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  src/sna/sna_video_sprite.c | 52 +++++++++++++++++++++++++++++++++++---
>  1 file changed, 49 insertions(+), 3 deletions(-)
> 
> diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c
> index 8b7ae8ae9e75..bb7b200b4dcc 100644
> --- a/src/sna/sna_video_sprite.c
> +++ b/src/sna/sna_video_sprite.c
> @@ -228,6 +228,52 @@ update_dst_box_to_crtc_coords(struct sna *sna, xf86CrtcPtr crtc, BoxPtr dstBox)
>         }
>  }
>  
> +static uint32_t ckey_chan(uint32_t value, int weight)
> +{
> +       return value << 8 >> weight;

Ok, making an 8bit value out of whatever input.

> +}
> +
> +static uint32_t ckey_value_chan(uint32_t value, uint32_t mask,
> +                               int offset, int weight)
> +{
> +       return ckey_chan((value & mask) >> offset, weight);
> +}
> +
> +static uint32_t ckey_value(struct sna *sna,
> +                          struct sna_video *video)
> +{
> +       ScrnInfoPtr scrn = sna->scrn;
> +       uint32_t r, g ,b;
> +
> +       if (scrn->depth == 8) {
> +               r = g = b = video->color_key & 0xff;
> +       } else {
> +               r = ckey_value_chan(video->color_key, scrn->mask.red,
> +                                   scrn->offset.red, scrn->weight.red);
> +               g = ckey_value_chan(video->color_key, scrn->mask.green,
> +                                   scrn->offset.green, scrn->weight.green);
> +               b = ckey_value_chan(video->color_key, scrn->mask.blue,
> +                                   scrn->offset.blue, scrn->weight.blue);

Makes sense.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the Intel-gfx mailing list