From e74cb66fd701bdf2039acc061ade10e95cf81ee6 Mon Sep 17 00:00:00 2001 From: Eric Chanudet Date: Tue, 16 Jul 2019 16:17:09 -0400 Subject: [PATCH 1/3] xenfb2: Amend default framebuffer values. 1280x1024 32bpp default stride should be 5120 minimum, 4096 is just not enough to represent a pixel line. This leads to plugins reporting the initial framebuffer as invalid: > [PLUGIN-DRM] drmModeAddFB(/dev/dri/card0, 1280x1024:24/32 pitch:4096) failed (Invalid argument). > [drm:drm_internal_framebuffer_create [drm]] bad pitch 4096 for plane 0 Since Xenfb2 is being loaded fairly late there is no console to display anyway, but the error should not trigger anyway. Signed-off-by: Eric Chanudet OXT-1639 (cherry picked from commit 12d74ce0638ec82ccc0b6bed490b0b83f57ec6fc) Signed-off-by: Eric Chanudet --- surfman/src/xenfb.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/surfman/src/xenfb.c b/surfman/src/xenfb.c index 7c1ebd1..ccf8c9d 100644 --- a/surfman/src/xenfb.c +++ b/surfman/src/xenfb.c @@ -32,6 +32,20 @@ #define XENFB_PAGE_SIZE 4096 +/* + * XenFB2 default framebuffer values. + * Idealy this should match the xenfb2 values to avoid unecessary resizing. + */ +#define XENFB2_DEFAULT_VIDEORAM (16 * 1024 * 1024) +#define XENFB2_DEFAULT_WIDTH 1024 +#define XENFB2_DEFAULT_HEIGHT 768 +#define XENFB2_DEFAULT_BPP 32 +/* It is good practice to keep this a multiple of 64 to satisfy DRM + * requirements. */ +#define XENFB2_DEFAULT_PITCH \ + (XENFB2_DEFAULT_WIDTH * XENFB2_DEFAULT_BPP / 8) +#define XENFB2_DEFAULT_OFFSET 0 + static struct event backend_xenstore_event; struct xenfb_device; @@ -257,14 +271,23 @@ xenfb_init (xen_device_t xendev) { struct xenfb_framebuffer *fb = xendev; - backend_print (fb->back, fb->devid, "default-xres", "%d", 1280); - backend_print (fb->back, fb->devid, "default-yres", "%d", 1024); - backend_print (fb->back, fb->devid, "default-bpp", "%d", 32); - backend_print (fb->back, fb->devid, "default-pitch", "%d", 4096); - - backend_print (fb->back, fb->devid, "videoram", "%d", 16 * 1024 * 1024); - - surface_update_format (fb->s, 1280, 1024, 4096, SURFMAN_FORMAT_BGRX8888, 0); + backend_print (fb->back, fb->devid, + "default-xres", "%u", XENFB2_DEFAULT_WIDTH); + backend_print (fb->back, fb->devid, + "default-yres", "%u", XENFB2_DEFAULT_HEIGHT); + backend_print (fb->back, fb->devid, + "default-bpp", "%u", XENFB2_DEFAULT_BPP); + backend_print (fb->back, fb->devid, + "default-pitch", "%u", XENFB2_DEFAULT_PITCH); + backend_print (fb->back, fb->devid, + "videoram", "%u", XENFB2_DEFAULT_VIDEORAM); + + surface_update_format (fb->s, + XENFB2_DEFAULT_WIDTH, + XENFB2_DEFAULT_HEIGHT, + XENFB2_DEFAULT_PITCH, + SURFMAN_FORMAT_BGRX8888, + XENFB2_DEFAULT_OFFSET); return 0; } From 46810bd66750288bf04cab0806ae03ae2e0c9deb Mon Sep 17 00:00:00 2001 From: Eric Chanudet Date: Tue, 16 Jul 2019 16:30:13 -0400 Subject: [PATCH 2/3] drm: Initialize offset with psurface. Also memset() the psurface. This used to let uninitialized values being printed through DRM_DEBUG. Signed-off-by: Eric Chanudet (cherry picked from commit 694546b3afcdcb9d50725f05a5cc166b1e385ee1) Signed-off-by: Eric Chanudet --- plugins/drm/src/drm-plugin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/drm/src/drm-plugin.c b/plugins/drm/src/drm-plugin.c index 58fed36..15172dc 100644 --- a/plugins/drm/src/drm-plugin.c +++ b/plugins/drm/src/drm-plugin.c @@ -276,7 +276,7 @@ INTERNAL surfman_psurface_t drmp_get_psurface_from_surface(surfman_plugin_t *plu (void) plugin; struct drm_surface *s; - s = malloc(sizeof (*s)); + s = calloc(1, sizeof (*s)); if (!s) { DRM_ERR("Could not allocate memory (%s).", strerror(errno)); return NULL; @@ -292,6 +292,7 @@ INTERNAL surfman_psurface_t drmp_get_psurface_from_surface(surfman_plugin_t *plu } s->fb.pitch = surfman_surface->stride; s->fb.size = surfman_surface->page_count * XC_PAGE_SIZE; + s->fb.offset = surfman_surface->offset; s->fb.map = surface_map(surfman_surface); s->domid = surfman_surface->pages_domid; From 356b9231a1cfd2f7c233cd116ad51738cdf9f50a Mon Sep 17 00:00:00 2001 From: Eric Chanudet Date: Tue, 16 Jul 2019 16:34:49 -0400 Subject: [PATCH 3/3] drm: Amend printf format. fb->offset is an off_t aka unsigned long. Signed-off-by: Eric Chanudet (cherry picked from commit f4c49703aec966f889d932c33e34eca66b465fb2) Signed-off-by: Eric Chanudet --- plugins/drm/src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/drm/src/utils.h b/plugins/drm/src/utils.h index 0a9e7ab..22122ea 100644 --- a/plugins/drm/src/utils.h +++ b/plugins/drm/src/utils.h @@ -142,7 +142,7 @@ static inline void framebuffer_dump(const char *indent, const struct framebuffer if (!fb) { DRM_DBG("%sframebuffer (%p) = { }", indent, fb); } else { - DRM_DBG("%sframebuffer (%p) = { %ux%u %u/%ubpp, %u stride, %u bytes, @%p:%lld }", + DRM_DBG("%sframebuffer (%p) = { %ux%u %u/%ubpp, %u stride, %u bytes, @%p:%ld }", indent, fb, fb->width, fb->height, fb->bpp, fb->depth, fb->pitch, fb->size, fb->map, fb->offset);