diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-02-06 09:59:31 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-02-06 09:59:31 +0100 |
commit | 9612f819292d64c8d2030e513602ee68a3ce0b04 (patch) | |
tree | f4dfb2460f628545fc1ae476e33709fa07eff23f | |
parent | 77542bdee936b118069d679afa9ac2f8125f1e36 (diff) | |
download | drminfo-9612f819292d64c8d2030e513602ee68a3ce0b04.tar.gz |
info tweaks
-rw-r--r-- | drminfo.c | 13 | ||||
-rw-r--r-- | drmtest.c | 44 | ||||
-rw-r--r-- | drmtools.c | 2 | ||||
-rw-r--r-- | drmtools.h | 1 | ||||
-rw-r--r-- | fbtest.c | 19 | ||||
-rw-r--r-- | gtktest.c | 2 | ||||
-rw-r--r-- | render.c | 29 | ||||
-rw-r--r-- | render.h | 2 | ||||
-rw-r--r-- | virtiotest.c | 15 |
9 files changed, 74 insertions, 53 deletions
@@ -310,15 +310,14 @@ static int drm_open(int devnr) static void drm_info_misc(int fd) { char *busid; - drmVersion *ver; - ver = drmGetVersion(fd); - fprintf(stderr, "name : \"%s\"\n", ver->name); - fprintf(stderr, "desc : \"%s\"\n", ver->desc); - fprintf(stderr, "date : \"%s\"\n", ver->date); + version = drmGetVersion(fd); + fprintf(stderr, "name : \"%s\"\n", version->name); + fprintf(stderr, "desc : \"%s\"\n", version->desc); + fprintf(stderr, "date : \"%s\"\n", version->date); fprintf(stderr, "version : v%d.%d.%d\n", - ver->version_major, ver->version_minor, - ver->version_patchlevel); + version->version_major, version->version_minor, + version->version_patchlevel); busid = drmGetBusid(fd); if (busid) { @@ -41,20 +41,39 @@ static cairo_surface_t *image; /* ------------------------------------------------------------------ */ -static void drm_draw(const char *text) +static void drm_draw(void) { char name[64]; - char info[80]; + char info1[80], info2[80], info3[80]; cairo_t *cr; + snprintf(info1, sizeof(info1), "drm driver: %s, v%d.%d.%d (%s)", + version->name, version->version_major, version->version_minor, + version->version_patchlevel, version->desc); + drm_conn_name(conn, name, sizeof(name)); - snprintf(info, sizeof(info), "drmtest: %dx%d at %s", + snprintf(info2, sizeof(info2), "%dx%d, output %s", mode->hdisplay, mode->vdisplay, name); + + if (fmt->fourcc) { + snprintf(info3, sizeof(info3), + "dumb drm buffer, bpp %d, fourcc %c%c%c%c (ADDFB2)", + fmt->bpp, + (fmt->fourcc >> 0) & 0xff, + (fmt->fourcc >> 8) & 0xff, + (fmt->fourcc >> 16) & 0xff, + (fmt->fourcc >> 24) & 0xff); + } else { + snprintf(info3, sizeof(info3), + "dumb drm buffer, bpp %d, depth %d (legacy ADDFB)", + fmt->bpp, fmt->depth); + } + cr = cairo_create(cs); if (image) { render_image(cr, mode->hdisplay, mode->vdisplay, image); } else { - render_test(cr, mode->hdisplay, mode->vdisplay, info, text); + render_test(cr, mode->hdisplay, mode->vdisplay, info1, info2, info3); } cairo_destroy(cr); } @@ -123,22 +142,7 @@ static void drm_init_dumb_fb(void) static void drm_draw_dumb_fb(void) { - char text[80]; - - if (fmt->fourcc) { - snprintf(text, sizeof(text), - "dumb framebuffer, bpp %d, fourcc %c%c%c%c (ADDFB2)", - fmt->bpp, - (fmt->fourcc >> 0) & 0xff, - (fmt->fourcc >> 8) & 0xff, - (fmt->fourcc >> 16) & 0xff, - (fmt->fourcc >> 24) & 0xff); - } else { - snprintf(text, sizeof(text), - "dumb framebuffer, bpp %d, depth %d (legacy ADDFB)", - fmt->bpp, fmt->depth); - } - drm_draw(text); + drm_draw(); drmModeDirtyFB(fd, fb_id, 0, 0); } @@ -601,6 +601,7 @@ int fd; uint32_t fb_id; drmModeConnector *conn = NULL; drmModeModeInfo *mode = NULL; +drmVersion *version = NULL; static drmModeEncoder *enc = NULL; static drmModeCrtc *scrtc = NULL; @@ -622,6 +623,7 @@ void drm_init_dev(int devnr, const char *output, fprintf(stderr, "open %s: %s\n", dev, strerror(errno)); exit(1); } + version = drmGetVersion(fd); if (need_dumb) { rc = drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &has_dumb); @@ -30,6 +30,7 @@ extern int fd; extern uint32_t fb_id; extern drmModeConnector *conn; extern drmModeModeInfo *mode; +extern drmVersion *version; void drm_init_dev(int devnr, const char *output, const char *modename, bool need_dumb); @@ -28,17 +28,23 @@ static cairo_surface_t *image; /* ------------------------------------------------------------------ */ -static void fb_draw(const char *text) +static void fb_draw(void) { - char info[80]; + char info1[80]; + char info2[80]; + char info3[80]; cairo_t *cr; - snprintf(info, sizeof(info), "fbtest: %dx%d", fb_var.xres, fb_var.yres); + snprintf(info1, sizeof(info1), "fb driver: %s", fb_fix.id); + snprintf(info2, sizeof(info2), "%dx%d", fb_var.xres, fb_var.yres); + snprintf(info3, sizeof(info3), "fbdev, %d bpp", + fb_var.bits_per_pixel); + cr = cairo_create(cs); if (image) { render_image(cr, fb_var.xres, fb_var.yres, image); } else { - render_test(cr, fb_var.xres, fb_var.yres, info, text); + render_test(cr, fb_var.xres, fb_var.yres, info1, info2, info3); } cairo_destroy(cr); } @@ -64,7 +70,6 @@ int main(int argc, char **argv) int framebuffer = 0; int secs = 60; char buf[32]; - char text[128]; int c; for (;;) { @@ -96,9 +101,7 @@ int main(int argc, char **argv) fb_var.xres, fb_var.yres, fb_fix.line_length); - snprintf(text, sizeof(text), "fbdev, %d bpp", - fb_var.bits_per_pixel); - fb_draw(text); + fb_draw(); tty_raw(); kbd_wait(secs); @@ -21,7 +21,7 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, } else { snprintf(info, sizeof(info), "gtktest: %dx%d", width, height); - render_test(cr, width, height, info, NULL); + render_test(cr, width, height, info, "line #2", "line #3"); } return FALSE; } @@ -8,7 +8,7 @@ static int pad = 15; static void render_color_bar(cairo_t *cr, int x, int y, int w, int h, double r, double g, double b, - const char *l1, const char *l2) + const char *l1, const char *l2, const char *l3) { cairo_font_extents_t ext; cairo_pattern_t *gr; @@ -26,12 +26,14 @@ static void render_color_bar(cairo_t *cr, int x, int y, int w, int h, CAIRO_FONT_WEIGHT_NORMAL); if (l2) { cairo_set_source_rgb(cr, 1, 1, 1); - cairo_set_font_size(cr, h/2 - pad); + cairo_set_font_size(cr, (h - 2*pad) / 3); cairo_font_extents(cr, &ext); cairo_move_to(cr, x + pad, y + pad + ext.ascent); cairo_show_text(cr, l1); cairo_move_to(cr, x + pad, y + pad + ext.ascent + ext.height); cairo_show_text(cr, l2); + cairo_move_to(cr, x + pad, y + pad + ext.ascent + ext.height * 2); + cairo_show_text(cr, l3); } else { cairo_set_source_rgb(cr, r, g, b); cairo_set_font_size(cr, h - 2*pad); @@ -41,7 +43,8 @@ static void render_color_bar(cairo_t *cr, int x, int y, int w, int h, } } -void render_test(cairo_t *cr, int width, int height, const char *l1, const char *l2) +void render_test(cairo_t *cr, int width, int height, + const char *l1, const char *l2, const char *l3) { int bar = 120; @@ -59,13 +62,19 @@ void render_test(cairo_t *cr, int width, int height, const char *l1, const char cairo_stroke(cr); render_color_bar(cr, pad, bar * 0 + pad, width - 2*pad, bar, - 0.6, 0.6, 0.6, l1, l2); - render_color_bar(cr, pad, bar * 1 + pad, width - 2*pad, bar, 1, 0, 0, "red", NULL); - render_color_bar(cr, pad, bar * 2 + pad, width - 2*pad, bar, 1, 1, 0, "yellow", NULL); - render_color_bar(cr, pad, bar * 3 + pad, width - 2*pad, bar, 0, 1, 0, "green", NULL); - render_color_bar(cr, pad, bar * 4 + pad, width - 2*pad, bar, 0, 1, 1, "cyan", NULL); - render_color_bar(cr, pad, bar * 5 + pad, width - 2*pad, bar, 0, 0, 1, "blue", NULL); - render_color_bar(cr, pad, bar * 6 + pad, width - 2*pad, bar, 1, 0, 1, "magenta", NULL); + 0.6, 0.6, 0.6, l1, l2, l3); + render_color_bar(cr, pad, bar * 1 + pad, width - 2*pad, bar, 1, 0, 0, + "red", NULL, NULL); + render_color_bar(cr, pad, bar * 2 + pad, width - 2*pad, bar, 1, 1, 0, + "yellow", NULL, NULL); + render_color_bar(cr, pad, bar * 3 + pad, width - 2*pad, bar, 0, 1, 0, + "green", NULL, NULL); + render_color_bar(cr, pad, bar * 4 + pad, width - 2*pad, bar, 0, 1, 1, + "cyan", NULL, NULL); + render_color_bar(cr, pad, bar * 5 + pad, width - 2*pad, bar, 0, 0, 1, + "blue", NULL, NULL); + render_color_bar(cr, pad, bar * 6 + pad, width - 2*pad, bar, 1, 0, 1, + "magenta", NULL, NULL); cairo_show_page(cr); } @@ -1,4 +1,4 @@ void render_test(cairo_t *cr, int width, int height, - const char *l1, const char *l2); + const char *l1, const char *l2, const char *l3); void render_image(cairo_t *cr, int width, int height, cairo_surface_t *image); diff --git a/virtiotest.c b/virtiotest.c index 484cc6b..1c35655 100644 --- a/virtiotest.c +++ b/virtiotest.c @@ -165,19 +165,22 @@ static void virtio_init_fb(void) stride); } -static void virtio_draw(const char *text) +static void virtio_draw(void) { - char info[80]; + char info1[80], info2[80], info3[80]; cairo_t *cr; - snprintf(info, sizeof(info), "virtiotest: %dx%d, fourcc %c%c%c%c", - mode->hdisplay, mode->vdisplay, + snprintf(info1, sizeof(info1), "virtio-gpu"); + snprintf(info2, sizeof(info2), "%dx%d", + mode->hdisplay, mode->vdisplay); + snprintf(info3, sizeof(info3), "fourcc %c%c%c%c", (fmt->fourcc >> 0) & 0xff, (fmt->fourcc >> 8) & 0xff, (fmt->fourcc >> 16) & 0xff, (fmt->fourcc >> 24) & 0xff); + cr = cairo_create(cs); - render_test(cr, mode->hdisplay, mode->vdisplay, info, text); + render_test(cr, mode->hdisplay, mode->vdisplay, info1, info2, info3); cairo_destroy(cr); } @@ -264,7 +267,7 @@ int main(int argc, char **argv) } virtio_init_fb(); - virtio_draw("hello world"); + virtio_draw(); virtio_transfer(); drm_show_fb(); |