[PATCH v2 5/5] drm/log: Color the timestamp, to improve readability
Jocelyn Falempe
jfalempe at redhat.com
Fri Aug 16 12:52:37 UTC 2024
Color the timesamp prefix, similar to dmesg.
Signed-off-by: Jocelyn Falempe <jfalempe at redhat.com>
---
drivers/gpu/drm/drm_log.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_log.c b/drivers/gpu/drm/drm_log.c
index b94ce3ea48a0..effdf6ee20b1 100644
--- a/drivers/gpu/drm/drm_log.c
+++ b/drivers/gpu/drm/drm_log.c
@@ -45,6 +45,7 @@ struct drm_log_scanout {
u32 format;
u32 px_width;
u32 front_color;
+ u32 prefix_color;
};
struct drm_log_client {
@@ -186,7 +187,7 @@ static void drm_log_clear_line(struct drm_log_scanout *scanout, u32 line)
}
static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
- unsigned int len)
+ unsigned int len, unsigned int prefix_len)
{
struct drm_framebuffer *fb = scanout->buffer->fb;
struct iosys_map map;
@@ -203,9 +204,10 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
iosys_map_incr(&map, r.y1 * fb->pitches[0]);
for (i = 0; i < len && i < scanout->columns; i++) {
+ u32 color = (i < prefix_len) ? scanout->prefix_color : scanout->front_color;
src = drm_draw_get_char_bitmap(font, s[i], font_pitch);
drm_log_blit(&map, fb->pitches[0], src, font_pitch, font->height, font->width,
- 1, px_width, scanout->front_color);
+ 1, px_width, color);
iosys_map_incr(&map, font->width * px_width);
}
@@ -217,7 +219,7 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
}
static void drm_log_draw_new_line(struct drm_log_scanout *scanout,
- const char *s, unsigned int len)
+ const char *s, unsigned int len, unsigned int prefix_len)
{
if (scanout->line == 0) {
drm_log_clear_line(scanout, 0);
@@ -226,20 +228,31 @@ static void drm_log_draw_new_line(struct drm_log_scanout *scanout,
} else if (scanout->line + 2 < scanout->rows)
drm_log_clear_line(scanout, scanout->line + 2);
- drm_log_draw_line(scanout, s, len);
+ drm_log_draw_line(scanout, s, len, prefix_len);
}
+/*
+ * Depends on print_time() in printk.c
+ * Timestamp is written with "[%5lu.%06lu]"
+ */
+#define TS_PREFIX_LEN 13
+
static void drm_log_draw_kmsg_record(struct drm_log_scanout *scanout,
const char *s, unsigned int len)
{
+ u32 prefix_len = 0;
+
+ if (len > TS_PREFIX_LEN && s[0] == '[' && s[6] == '.' && s[TS_PREFIX_LEN] == ']')
+ prefix_len = TS_PREFIX_LEN + 1;
while (len > scanout->columns) {
- drm_log_draw_new_line(scanout, s, scanout->columns);
+ drm_log_draw_new_line(scanout, s, scanout->columns, prefix_len);
s += scanout->columns;
len -= scanout->columns;
+ prefix_len = 0;
}
if (len)
- drm_log_draw_new_line(scanout, s, len);
+ drm_log_draw_new_line(scanout, s, len, prefix_len);
}
static u32 drm_log_find_usable_format(struct drm_plane *plane)
@@ -279,6 +292,7 @@ static int drm_log_setup_modeset(struct drm_client_dev *client,
scanout->rows = height / scanout->font->height;
scanout->columns = width / scanout->font->width;
scanout->front_color = drm_draw_color_from_xrgb8888(0xffffff, format);
+ scanout->prefix_color = drm_draw_color_from_xrgb8888(0x4e9a06, format);
return 0;
}
--
2.46.0
More information about the dri-devel
mailing list