diff mbox series

[v2] drm/plane: add alpha and blend_mode to atomic_print_state

Message ID 20211215160837.2715448-1-dmitry.baryshkov@linaro.org
State New
Headers show
Series [v2] drm/plane: add alpha and blend_mode to atomic_print_state | expand

Commit Message

Dmitry Baryshkov Dec. 15, 2021, 4:08 p.m. UTC
When dumping plane state also output plane's alpha and blending mode
values to ease debugging of complex composition cases.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Changes since v1:
 - Changed alpha property format to pad with zeroes
---
 drivers/gpu/drm/drm_atomic.c        |  3 +++
 drivers/gpu/drm/drm_blend.c         | 21 +++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h |  3 +++
 3 files changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ff1416cd609a..20db99c041eb 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -709,6 +709,9 @@  static void drm_atomic_plane_print_state(struct drm_printer *p,
 		   drm_get_color_encoding_name(state->color_encoding));
 	drm_printf(p, "\tcolor-range=%s\n",
 		   drm_get_color_range_name(state->color_range));
+	drm_printf(p, "\talpha=%04X\n", state->alpha);
+	drm_printf(p, "\tblend_mode=%s\n",
+		   drm_get_pixel_blend_mode_name(state->pixel_blend_mode));
 
 	if (plane->funcs->atomic_print_state)
 		plane->funcs->atomic_print_state(p, state);
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index ec37cbfabb50..e3971758ec53 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -616,3 +616,24 @@  int drm_plane_create_blend_mode_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_blend_mode_property);
+
+static const char * const pixel_blend_mode_name[] = {
+	[DRM_MODE_BLEND_PIXEL_NONE] = "None",
+	[DRM_MODE_BLEND_PREMULTI] = "Pre-multiplied",
+	[DRM_MODE_BLEND_COVERAGE] = "Coverage",
+};
+
+/**
+ * drm_get_pixel_blend_mode_name - return a string for color encoding
+ * @encoding: color encoding to compute name of
+ *
+ * In contrast to the other drm_get_*_name functions this one here returns a
+ * const pointer and hence is threadsafe.
+ */
+const char *drm_get_pixel_blend_mode_name(uint16_t blend_mode)
+{
+	if (WARN_ON(blend_mode >= ARRAY_SIZE(pixel_blend_mode_name)))
+		return "unknown";
+
+	return pixel_blend_mode_name[blend_mode];
+}
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index 63279e984342..0794307191cf 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -289,3 +289,6 @@  void drm_mode_fixup_1366x768(struct drm_display_mode *mode);
 void drm_reset_display_info(struct drm_connector *connector);
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid);
 void drm_update_tile_info(struct drm_connector *connector, const struct edid *edid);
+
+/* drm_blend.c */
+const char *drm_get_pixel_blend_mode_name(uint16_t blend_mode);