[01/37] drm/i915: Add local 'fb' variables
diff mbox

Message ID 1479498793-31021-2-git-send-email-ville.syrjala@linux.intel.com
State New
Headers show

Commit Message

Ville Syrjälä Nov. 18, 2016, 7:52 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a local 'fb' variable to a few places to get rid of the
'crtc->primary->fb' stuff. Looks neater and helps me with my poor
coccinelle skills later.

While at it switch over to using the pixel format rather than
depth+bpp.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_overlay.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

Comments

Daniel Vetter Nov. 30, 2016, 2:44 p.m. UTC | #1
On Fri, Nov 18, 2016 at 09:52:37PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a local 'fb' variable to a few places to get rid of the
> 'crtc->primary->fb' stuff. Looks neater and helps me with my poor
> coccinelle skills later.
> 
> While at it switch over to using the pixel format rather than
> depth+bpp.
> 
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/i915/intel_overlay.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
> index fd0e4dac7cc1..ce3667c18e18 100644
> --- a/drivers/gpu/drm/i915/intel_overlay.c
> +++ b/drivers/gpu/drm/i915/intel_overlay.c
> @@ -658,6 +658,8 @@ static bool update_scaling_factors(struct intel_overlay *overlay,
>  static void update_colorkey(struct intel_overlay *overlay,
>  			    struct overlay_registers __iomem *regs)
>  {
> +	const struct drm_framebuffer *fb =
> +		overlay->crtc->base.primary->fb;
>  	u32 key = overlay->color_key;
>  	u32 flags;
>  
> @@ -665,24 +667,20 @@ static void update_colorkey(struct intel_overlay *overlay,
>  	if (overlay->color_key_enabled)
>  		flags |= DST_KEY_ENABLE;
>  
> -	switch (overlay->crtc->base.primary->fb->bits_per_pixel) {
> -	case 8:
> +	switch (fb->pixel_format) {
> +	case DRM_FORMAT_C8:
>  		key = 0;
>  		flags |= CLK_RGB8I_MASK;
>  		break;
> -
> -	case 16:
> -		if (overlay->crtc->base.primary->fb->depth == 15) {
> -			key = RGB15_TO_COLORKEY(key);
> -			flags |= CLK_RGB15_MASK;
> -		} else {
> -			key = RGB16_TO_COLORKEY(key);
> -			flags |= CLK_RGB16_MASK;
> -		}
> +	case DRM_FORMAT_XRGB1555:
> +		key = RGB15_TO_COLORKEY(key);
> +		flags |= CLK_RGB15_MASK;
>  		break;
> -
> -	case 24:
> -	case 32:
> +	case DRM_FORMAT_RGB565:
> +		key = RGB16_TO_COLORKEY(key);
> +		flags |= CLK_RGB16_MASK;
> +		break;
> +	default:
>  		flags |= CLK_RGB24_MASK;
>  		break;
>  	}
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index fd0e4dac7cc1..ce3667c18e18 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -658,6 +658,8 @@  static bool update_scaling_factors(struct intel_overlay *overlay,
 static void update_colorkey(struct intel_overlay *overlay,
 			    struct overlay_registers __iomem *regs)
 {
+	const struct drm_framebuffer *fb =
+		overlay->crtc->base.primary->fb;
 	u32 key = overlay->color_key;
 	u32 flags;
 
@@ -665,24 +667,20 @@  static void update_colorkey(struct intel_overlay *overlay,
 	if (overlay->color_key_enabled)
 		flags |= DST_KEY_ENABLE;
 
-	switch (overlay->crtc->base.primary->fb->bits_per_pixel) {
-	case 8:
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_C8:
 		key = 0;
 		flags |= CLK_RGB8I_MASK;
 		break;
-
-	case 16:
-		if (overlay->crtc->base.primary->fb->depth == 15) {
-			key = RGB15_TO_COLORKEY(key);
-			flags |= CLK_RGB15_MASK;
-		} else {
-			key = RGB16_TO_COLORKEY(key);
-			flags |= CLK_RGB16_MASK;
-		}
+	case DRM_FORMAT_XRGB1555:
+		key = RGB15_TO_COLORKEY(key);
+		flags |= CLK_RGB15_MASK;
 		break;
-
-	case 24:
-	case 32:
+	case DRM_FORMAT_RGB565:
+		key = RGB16_TO_COLORKEY(key);
+		flags |= CLK_RGB16_MASK;
+		break;
+	default:
 		flags |= CLK_RGB24_MASK;
 		break;
 	}