Skip to contentSkip to conversation

drm/tinydrm: Advertise that we can do only DRM_FORMAT_MOD_LINEAR.

PATCH In review Eric Anholt 2 participants 2 messages Oct 25, 2018 – Oct 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tinydrm: Advertise that we can do only DRM_FORMAT_MOD_LINEAR.

Without this, the xserver relies on what the 3D driver exposes and assumes that the display can handle it, and then the DRM driver happily tries to scan out a tiled format.

---
 drivers/gpu/drm/drm_simple_kms_helper.c     | 8 ++++++++
 drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 1 +
 drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 6 +++++-
 3 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_simple_kms_helper.c +8 -0
index 51fa978f0d23..917812448d1b 100644
@@ -190,6 +190,13 @@ static void drm_simple_kms_plane_cleanup_fb(struct drm_plane *plane,
 	pipe->funcs->cleanup_fb(pipe, state);
 }
 
+static bool drm_simple_kms_format_mod_supported(struct drm_plane *plane,
+						uint32_t format,
+						uint64_t modifier)
+{
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+
 static const struct drm_plane_helper_funcs drm_simple_kms_plane_helper_funcs = {
 	.prepare_fb = drm_simple_kms_plane_prepare_fb,
 	.cleanup_fb = drm_simple_kms_plane_cleanup_fb,
@@ -204,6 +211,7 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {
 	.reset			= drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state	= drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
+	.format_mod_supported   = drm_simple_kms_format_mod_supported,
 };
 
 /**
drivers/gpu/drm/tinydrm/core/tinydrm-core.c +1 -0
index 255341ee4eb9..9af51d982a33 100644
@@ -146,6 +146,7 @@ static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
 	drm->dev_private = tdev;
 	drm_mode_config_init(drm);
 	drm->mode_config.funcs = &tinydrm_mode_config_funcs;
+	drm->mode_config.allow_fb_modifiers = true;
 
 	return 0;
 }
drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c +5 -1
index 7e8e24d0b7a7..eacfc0ec8ff1 100644
@@ -184,6 +184,10 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
 	struct drm_display_mode mode_copy;
 	struct drm_connector *connector;
 	int ret;
+	static const uint64_t modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 
 	drm_mode_copy(&mode_copy, mode);
 	ret = tinydrm_rotate_mode(&mode_copy, rotation);
@@ -202,6 +206,6 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
 		return PTR_ERR(connector);
 
 	return drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
-					    format_count, NULL, connector);
+					    format_count, modifiers, connector);
 }
 EXPORT_SYMBOL(tinydrm_display_pipe_init);
Signature · 1 line
2.19.1
Acked-by on v1 1/1
#1 lore raw

Den 25.10.2018 18.26, skrev Eric Anholt:

Quoted 16 lines

Without this, the xserver relies on what the 3D driver exposes and assumes that the display can handle it, and then the DRM driver happily tries to scan out a tiled format.

---
  drivers/gpu/drm/drm_simple_kms_helper.c     | 8 ++++++++
  drivers/gpu/drm/tinydrm/core/tinydrm-core.c | 1 +
  drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 6 +++++-
  3 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_simple_kms_helper.c +0 -0
index 51fa978f0d23..917812448d1b 100644

drivers/gpu/drm/drm_simple_kms_helper.c static void drm_simple_kms_plane_cleanup_fb(struct drm_plane *plane, · line 199

Quoted 10 lines
drivers/gpu/drm/drm_simple_kms_helper.c +7 -0
@@ -190,6 +190,13 @@ static void drm_simple_kms_plane_cleanup_fb(struct drm_plane *plane,
  	pipe->funcs->cleanup_fb(pipe, state);
  }
 
+static bool drm_simple_kms_format_mod_supported(struct drm_plane *plane,
+						uint32_t format,
+						uint64_t modifier)
+{
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+

I assume this also works for the other drivers that use this helper. A quick look at the code seems to support this assumption. Format modifiers is something I've never looked at before.

Quoted 39 lines
drivers/gpu/drm/drm_simple_kms_helper.c +1 -0
  static const struct drm_plane_helper_funcs drm_simple_kms_plane_helper_funcs = {
  	.prepare_fb = drm_simple_kms_plane_prepare_fb,
  	.cleanup_fb = drm_simple_kms_plane_cleanup_fb,
@@ -204,6 +211,7 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {
  	.reset			= drm_atomic_helper_plane_reset,
  	.atomic_duplicate_state	= drm_atomic_helper_plane_duplicate_state,
  	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
+	.format_mod_supported   = drm_simple_kms_format_mod_supported,
  };
 
  /**
drivers/gpu/drm/tinydrm/core/tinydrm-core.c +1 -0
index 255341ee4eb9..9af51d982a33 100644
@@ -146,6 +146,7 @@ static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
  	drm->dev_private = tdev;
  	drm_mode_config_init(drm);
  	drm->mode_config.funcs = &tinydrm_mode_config_funcs;
+	drm->mode_config.allow_fb_modifiers = true;
 
  	return 0;
  }
drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c +4 -0
index 7e8e24d0b7a7..eacfc0ec8ff1 100644
@@ -184,6 +184,10 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
  	struct drm_display_mode mode_copy;
  	struct drm_connector *connector;
  	int ret;
+	static const uint64_t modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 
  	drm_mode_copy(&mode_copy, mode);
  	ret = tinydrm_rotate_mode(&mode_copy, rotation);

drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c tinydrm_display_pipe_init(struct tinydrm_device *tdev, · line 211

Quoted 7 lines
drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c +1 -1
@@ -202,6 +206,6 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
  		return PTR_ERR(connector);
 
  	return drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
-					    format_count, NULL, connector);
+					    format_count, modifiers, connector);
  }
  EXPORT_SYMBOL(tinydrm_display_pipe_init);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel