[Intel-gfx] [PATCH v5 3/3] drm/i915: Add format modifiers for Intel

Ben Widawsky ben at bwidawsk.net
Thu May 18 01:14:29 UTC 2017


On 17-05-17 01:20:50, Emil Velikov wrote:
>Hi Ben,
>
>A couple of small questions/suggestions that I hope you find useful.
>Please don't block any of this work based on my comments.
>
>On 16 May 2017 at 22:31, Ben Widawsky <ben at bwidawsk.net> wrote:
>
>> +static bool intel_primary_plane_format_mod_supported(struct drm_plane *plane,
>> +                                                    uint32_t format,
>> +                                                    uint64_t modifier)
>> +{
>> +       struct drm_i915_private *dev_priv = to_i915(plane->dev);
>> +
>> +       if (WARN_ON(modifier == DRM_FORMAT_MOD_INVALID))
>> +               return false;
>> +
>> +       if (INTEL_GEN(dev_priv) >= 9)
>> +               return skl_mod_supported(format, modifier);
>> +       else if (INTEL_GEN(dev_priv) >= 4)
>> +               return i965_mod_supported(format, modifier);
>> +       else
>> +               return i8xx_mod_supported(format, modifier);
>> +
>Nit: if you rewrite this as below, the control flow should be clearer.
>Thus the 'return false;' at the end, will be [more] obvious that it's
>unreachable ;-)
>
>       if (INTEL_GEN(dev_priv) >= 9)
>               return skl_mod_supported(format, modifier);
>
>       if (INTEL_GEN(dev_priv) >= 4)
>               return i965_mod_supported(format, modifier);
>
>       return i8xx_mod_supported(format, modifier);
>
>

It's a good point, however many other blocks of code do the same thing, and I
think the nature of if/else if/else implies unreachable. I can add
unreachable()... In fact, I just did.

>> +       return false;
>> +}
>> +
>
>
>> --- a/drivers/gpu/drm/i915/intel_sprite.c
>> +++ b/drivers/gpu/drm/i915/intel_sprite.c
>
>> +static bool intel_sprite_plane_format_mod_supported(struct drm_plane *plane,
>> +                                                    uint32_t format,
>> +                                                    uint64_t modifier)
>> +{
>> +       struct drm_i915_private *dev_priv = to_i915(plane->dev);
>> +
>> +       if (WARN_ON(modifier == DRM_FORMAT_MOD_INVALID))
>> +               return false;
>> +
>> +       BUG_ON(plane->base.type != DRM_PLANE_TYPE_OVERLAY);
>> +
>> +       switch (format) {
>> +               case DRM_FORMAT_XBGR2101010:
>> +               case DRM_FORMAT_ABGR2101010:
>> +                       if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
>> +                               return true;
>> +                       break;
>> +               case DRM_FORMAT_RGB565:
>> +               case DRM_FORMAT_ABGR8888:
>> +               case DRM_FORMAT_ARGB8888:
>> +                       if (INTEL_GEN(dev_priv) >= 9 || IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
>> +                               return true;
>> +                       break;
>> +               case DRM_FORMAT_XBGR8888:
>> +                       if (INTEL_GEN(dev_priv) >= 6)
>> +                               return true;
>> +                       break;
>> +               case DRM_FORMAT_XRGB8888:
>> +               case DRM_FORMAT_YUYV:
>> +               case DRM_FORMAT_YVYU:
>> +               case DRM_FORMAT_UYVY:
>> +               case DRM_FORMAT_VYUY:
>> +                       return true;
>> +       }
>> +
>> +       return false;
>> +}
>> +
>> +const struct drm_plane_funcs intel_sprite_plane_funcs = {
>> +        .update_plane = drm_atomic_helper_update_plane,
>> +        .disable_plane = drm_atomic_helper_disable_plane,
>> +        .destroy = intel_plane_destroy,
>> +        .set_property = drm_atomic_helper_plane_set_property,
>> +        .atomic_get_property = intel_plane_atomic_get_property,
>> +        .atomic_set_property = intel_plane_atomic_set_property,
>> +        .atomic_duplicate_state = intel_plane_duplicate_state,
>> +        .atomic_destroy_state = intel_plane_destroy_state,
>> +        .format_mod_supported = intel_sprite_plane_format_mod_supported,
>> +};
>> +
>Having a dull moment - is intel_sprite_plane_funcs (+
>intel_sprite_plane_format_mod_supported) unused or I'm seeing things?
>If one is to keep it, for future work, perhaps it's worth adding a 2-3
>word comment,
>
>Regards,
>Emil

Not sure how this happened, it is a mistake. Thanks for spotting it. Here's what
I got locally:

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3519c10abcc3..a8f4c5783ec2 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13479,7 +13479,7 @@ static bool intel_primary_plane_format_mod_supported(struct drm_plane *plane,
        else
                return i8xx_mod_supported(format, modifier);

-       return false;
+       unreachable();
 }

 static bool intel_cursor_plane_format_mod_supported(struct drm_plane *plane,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index e7c5c0a94bbd..1d582b436b59 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -1233,7 +1233,7 @@ intel_sprite_plane_create(struct drm_i915_private *dev_priv,

        if (INTEL_GEN(dev_priv) >= 9)
                ret = drm_universal_plane_init(&dev_priv->drm, &intel_plane->base,
-                                              possible_crtcs, &intel_plane_funcs,
+                                              possible_crtcs, &intel_sprite_plane_funcs,
                                               plane_formats, num_plane_formats,
                                               modifiers,
                                               DRM_PLANE_TYPE_OVERLAY,


-- 
Ben Widawsky, Intel Open Source Technology Center


More information about the Intel-gfx mailing list