drm/sun4i: layer: Add tiled modifier support and helper
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Fri, 18 Jan 2019 14:51:25 +0000 (15:51 +0100)
committerMaxime Ripard <maxime.ripard@bootlin.com>
Fri, 18 Jan 2019 18:18:00 +0000 (19:18 +0100)
This introduces a list of supported modifiers for the driver, that
includes the Allwinner tiled modifier, as well as a format_mod_supported
callback.

The callback uses both the backend and frontend helpers to indicate
per-format modifier support (including for the linear modifier).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190118145133.21281-16-paul.kocialkowski@bootlin.com
drivers/gpu/drm/sun4i/sun4i_layer.c

index 8cf8ca997b1d6b74ae58594e47a79d826c9a4020..c5a999ca1d72a90e8debfd108fb3b13fdeec6272 100644 (file)
@@ -114,6 +114,13 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane,
        sun4i_backend_layer_enable(backend, layer->id, true);
 }
 
+static bool sun4i_layer_format_mod_supported(struct drm_plane *plane,
+                                            uint32_t format, uint64_t modifier)
+{
+       return sun4i_backend_format_is_supported(format, modifier) ||
+              sun4i_frontend_format_is_supported(format, modifier);
+}
+
 static const struct drm_plane_helper_funcs sun4i_backend_layer_helper_funcs = {
        .prepare_fb     = drm_gem_fb_prepare_fb,
        .atomic_disable = sun4i_backend_layer_atomic_disable,
@@ -127,6 +134,7 @@ static const struct drm_plane_funcs sun4i_backend_layer_funcs = {
        .disable_plane          = drm_atomic_helper_disable_plane,
        .reset                  = sun4i_backend_layer_reset,
        .update_plane           = drm_atomic_helper_update_plane,
+       .format_mod_supported   = sun4i_layer_format_mod_supported,
 };
 
 static const uint32_t sun4i_layer_formats[] = {
@@ -157,6 +165,12 @@ static const uint32_t sun4i_layer_formats[] = {
        DRM_FORMAT_YVYU,
 };
 
+static const uint64_t sun4i_layer_modifiers[] = {
+       DRM_FORMAT_MOD_LINEAR,
+       DRM_FORMAT_MOD_ALLWINNER_TILED,
+       DRM_FORMAT_MOD_INVALID
+};
+
 static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
                                                struct sun4i_backend *backend,
                                                enum drm_plane_type type)
@@ -173,7 +187,7 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
                                       &sun4i_backend_layer_funcs,
                                       sun4i_layer_formats,
                                       ARRAY_SIZE(sun4i_layer_formats),
-                                      NULL, type, NULL);
+                                      sun4i_layer_modifiers, type, NULL);
        if (ret) {
                dev_err(drm->dev, "Couldn't initialize layer\n");
                return ERR_PTR(ret);