dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
	dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v3 2/4] drm/i915: Eliminate the horrendous format check code
Date: Fri, 26 Oct 2018 13:08:01 -0700	[thread overview]
Message-ID: <de6edce61101f5f063f33dd25400b1e7c2654a04.camel@intel.com> (raw)
In-Reply-To: <20180309151450.20365-2-ville.syrjala@linux.intel.com>

On Fri, 2018-03-09 at 17:14 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the messy framebuffer format/modifier validation code
> with a single call to drm_any_plane_has_format(). The code was
> extremely annoying to maintain as you had to have a lot of platform
> checks for different formats. The new code requires zero maintenance.
> 
> v2: Nuke the modifier checks as well since the core does that too now
> v3: Call drm_any_plane_has_format() from the driver code
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Patch looks good to me, but does not apply cleanly now.


> ---
>  drivers/gpu/drm/i915/intel_display.c | 90 ++++--------------------
> ------------
>  1 file changed, 8 insertions(+), 82 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c
> b/drivers/gpu/drm/i915/intel_display.c
> index 2933ad38094f..7f06fa83d894 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13989,7 +13989,6 @@ static int intel_framebuffer_init(struct
> intel_framebuffer *intel_fb,
>  {
>  	struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
>  	struct drm_framebuffer *fb = &intel_fb->base;
> -	struct drm_format_name_buf format_name;
>  	u32 pitch_limit;
>  	unsigned int tiling, stride;
>  	int ret = -EINVAL;
> @@ -14020,33 +14019,14 @@ static int intel_framebuffer_init(struct
> intel_framebuffer *intel_fb,
>  		}
>  	}
>  
> -	/* Passed in modifier sanity checking. */
> -	switch (mode_cmd->modifier[0]) {
> -	case I915_FORMAT_MOD_Y_TILED_CCS:
> -	case I915_FORMAT_MOD_Yf_TILED_CCS:
> -		switch (mode_cmd->pixel_format) {
> -		case DRM_FORMAT_XBGR8888:
> -		case DRM_FORMAT_ABGR8888:
> -		case DRM_FORMAT_XRGB8888:
> -		case DRM_FORMAT_ARGB8888:
> -			break;
> -		default:
> -			DRM_DEBUG_KMS("RC supported only with RGB8888
> formats\n");
> -			goto err;
> -		}
> -		/* fall through */
> -	case I915_FORMAT_MOD_Y_TILED:
> -	case I915_FORMAT_MOD_Yf_TILED:
> -		if (INTEL_GEN(dev_priv) < 9) {
> -			DRM_DEBUG_KMS("Unsupported tiling 0x%llx!\n",
> -				      mode_cmd->modifier[0]);
> -			goto err;
> -		}
> -	case DRM_FORMAT_MOD_LINEAR:
> -	case I915_FORMAT_MOD_X_TILED:
> -		break;
> -	default:
> -		DRM_DEBUG_KMS("Unsupported fb modifier 0x%llx!\n",
> +	if (!drm_any_plane_has_format(&dev_priv->drm,
> +				      mode_cmd->pixel_format,
> +				      mode_cmd->modifier[0])) {
> +		struct drm_format_name_buf format_name;
> +
> +		DRM_DEBUG_KMS("unsupported pixel format %s / modifier
> 0x%llx\n",
> +			      drm_get_format_name(mode_cmd-
> >pixel_format,
> +						  &format_name),
>  			      mode_cmd->modifier[0]);
>  		goto err;
>  	}
> @@ -14081,60 +14061,6 @@ static int intel_framebuffer_init(struct
> intel_framebuffer *intel_fb,
>  		goto err;
>  	}
>  
> -	/* Reject formats not supported by any plane early. */
> -	switch (mode_cmd->pixel_format) {
> -	case DRM_FORMAT_C8:
> -	case DRM_FORMAT_RGB565:
> -	case DRM_FORMAT_XRGB8888:
> -	case DRM_FORMAT_ARGB8888:
> -		break;
> -	case DRM_FORMAT_XRGB1555:
> -		if (INTEL_GEN(dev_priv) > 3) {
> -			DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -				      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -			goto err;
> -		}
> -		break;
> -	case DRM_FORMAT_ABGR8888:
> -		if (!IS_VALLEYVIEW(dev_priv) &&
> !IS_CHERRYVIEW(dev_priv) &&
> -		    INTEL_GEN(dev_priv) < 9) {
> -			DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -				      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -			goto err;
> -		}
> -		break;
> -	case DRM_FORMAT_XBGR8888:
> -	case DRM_FORMAT_XRGB2101010:
> -	case DRM_FORMAT_XBGR2101010:
> -		if (INTEL_GEN(dev_priv) < 4) {
> -			DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -				      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -			goto err;
> -		}
> -		break;
> -	case DRM_FORMAT_ABGR2101010:
> -		if (!IS_VALLEYVIEW(dev_priv) &&
> !IS_CHERRYVIEW(dev_priv)) {
> -			DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -				      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -			goto err;
> -		}
> -		break;
> -	case DRM_FORMAT_YUYV:
> -	case DRM_FORMAT_UYVY:
> -	case DRM_FORMAT_YVYU:
> -	case DRM_FORMAT_VYUY:
> -		if (INTEL_GEN(dev_priv) < 5 && !IS_G4X(dev_priv)) {
> -			DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -				      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -			goto err;
> -		}
> -		break;
> -	default:
> -		DRM_DEBUG_KMS("unsupported pixel format: %s\n",
> -			      drm_get_format_name(mode_cmd-
> >pixel_format, &format_name));
> -		goto err;
> -	}
> -
>  	/* FIXME need to adjust LINOFF/TILEOFF accordingly. */
>  	if (mode_cmd->offsets[0] != 0)
>  		goto err;

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-10-26 20:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 15:14 [PATCH v3 1/4] drm: Add drm_any_plane_has_format() Ville Syrjala
2018-03-09 15:14 ` [PATCH v3 2/4] drm/i915: Eliminate the horrendous format check code Ville Syrjala
2018-10-26 20:08   ` Dhinakaran Pandiyan [this message]
2018-03-09 15:14 ` [PATCH 3/4] drm: Fix some coding style issues Ville Syrjala
2018-03-09 15:14 ` [PATCH 4/4] drm/vc4: Validate framebuffer pixel format/modifier Ville Syrjala
2018-03-09 20:54   ` Eric Anholt
2018-03-12 15:04     ` Ville Syrjälä
2018-03-12 16:57     ` Daniel Vetter
2018-10-26 20:04 ` [PATCH v3 1/4] drm: Add drm_any_plane_has_format() Dhinakaran Pandiyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de6edce61101f5f063f33dd25400b1e7c2654a04.camel@intel.com \
    --to=dhinakaran.pandiyan@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox