testdisplay: add tiled buffer test support

Useful for testing tiled vs linear framebuffers.
This commit is contained in:
Jesse Barnes 2011-06-07 13:27:35 -07:00
parent 7230c01421
commit b707feb9d5

View File

@ -71,7 +71,7 @@ struct udev_monitor *uevent_monitor;
drmModeRes *resources; drmModeRes *resources;
int fd, modes; int fd, modes;
int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0, int dump_info = 0, test_all_modes =0, test_preferred_mode = 0, force_mode = 0,
test_plane; test_plane, enable_tiling;
int sleep_between_modes = 5; int sleep_between_modes = 5;
uint32_t depth = 24; uint32_t depth = 24;
@ -395,14 +395,20 @@ static void gem_close(int fd, uint32_t handle)
static cairo_surface_t * static cairo_surface_t *
allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t bpp, allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t bpp,
uint32_t *handle) uint32_t *handle, int tiled)
{ {
cairo_format_t format; cairo_format_t format;
struct drm_i915_gem_set_tiling set_tiling;
int size, stride; int size, stride;
/* Scan-out has a 64 byte alignment restriction */ if (tiled) {
stride = (width * (bpp / 8) + 63) & -64; stride = (width * (bpp / 8) + 511) & ~511;
size = stride * height; size = stride * height;
} else {
/* Scan-out has a 64 byte alignment restriction */
stride = (width * (bpp / 8) + 63) & ~63;
size = stride * height;
}
switch (depth) { switch (depth) {
case 16: case 16:
@ -425,6 +431,18 @@ allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t bpp,
} }
*handle = gem_create(fd, size); *handle = gem_create(fd, size);
if (tiled) {
set_tiling.handle = *handle;
set_tiling.tiling_mode = I915_TILING_X;
set_tiling.stride = stride;
if (ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling)) {
fprintf(stderr, "set tiling failed: %s\n",
strerror(errno));
return NULL;
}
}
return cairo_image_surface_create_for_data return cairo_image_surface_create_for_data
(gem_mmap(fd, *handle, size, PROT_READ | PROT_WRITE), (gem_mmap(fd, *handle, size, PROT_READ | PROT_WRITE),
format, width, height, stride); format, width, height, stride);
@ -698,7 +716,7 @@ enable_plane(struct connector *c)
return; return;
} }
surface = allocate_surface(fd, width, height, 24, 32, &handle); surface = allocate_surface(fd, width, height, 24, 32, &handle, 1);
if (!surface) { if (!surface) {
fprintf(stderr, "allocation failed %dx%d\n", width, height); fprintf(stderr, "allocation failed %dx%d\n", width, height);
return; return;
@ -807,7 +825,7 @@ set_mode(struct connector *c)
height = c->mode.vdisplay; height = c->mode.vdisplay;
surface = allocate_surface(fd, width, height, depth, bpp, surface = allocate_surface(fd, width, height, depth, bpp,
&handle); &handle, enable_tiling);
if (!surface) { if (!surface) {
fprintf(stderr, "allocation failed %dx%d\n", width, height); fprintf(stderr, "allocation failed %dx%d\n", width, height);
continue; continue;
@ -917,7 +935,7 @@ static void update_display(void)
extern char *optarg; extern char *optarg;
extern int optind, opterr, optopt; extern int optind, opterr, optopt;
static char optstr[] = "hiaf:s:d:p"; static char optstr[] = "hiaf:s:d:pt";
static void usage(char *name) static void usage(char *name)
{ {
@ -927,6 +945,7 @@ static void usage(char *name)
fprintf(stderr, "\t-s\t<duration>\tsleep between each mode test\n"); fprintf(stderr, "\t-s\t<duration>\tsleep between each mode test\n");
fprintf(stderr, "\t-d\t<depth>\tbit depth of scanout buffer\n"); fprintf(stderr, "\t-d\t<depth>\tbit depth of scanout buffer\n");
fprintf(stderr, "\t-p\ttest overlay plane\n"); fprintf(stderr, "\t-p\ttest overlay plane\n");
fprintf(stderr, "\t-t\tuse a tiled framebuffer\n");
fprintf(stderr, "\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n"); fprintf(stderr, "\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n");
fprintf(stderr, "\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n"); fprintf(stderr, "\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n");
fprintf(stderr, "\t\ttest force mode\n"); fprintf(stderr, "\t\ttest force mode\n");
@ -1013,6 +1032,9 @@ int main(int argc, char **argv)
case 'p': case 'p':
test_plane = 1; test_plane = 1;
break; break;
case 't':
enable_tiling = 1;
break;
default: default:
fprintf(stderr, "unknown option %c\n", c); fprintf(stderr, "unknown option %c\n", c);
/* fall through */ /* fall through */