mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 02:16:17 +00:00
testdisplay: add sprite scaling and location support
Allow testdisplay to locate the sprite on the screen and potentially scale it using different crtc width/height vs the source width/height (determined by the resolution on the target pipe). Also fix exit, making sure we properly disable all the planes. Signed-off-by: Jesse Barnes <jbarnes@virtuougseek.org>
This commit is contained in:
parent
d510953ef3
commit
24e60385fe
@ -89,6 +89,8 @@ int force_vsync_start;
|
|||||||
int force_vsync_end;
|
int force_vsync_end;
|
||||||
int force_vtotal;
|
int force_vtotal;
|
||||||
|
|
||||||
|
int crtc_x, crtc_y, crtc_w, crtc_h;
|
||||||
|
|
||||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||||
|
|
||||||
struct type_name {
|
struct type_name {
|
||||||
@ -686,10 +688,10 @@ paint_plane(cairo_t *cr, int width, int height, int stride)
|
|||||||
double gr_height, gr_width;
|
double gr_height, gr_width;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
y = height * 0.10;
|
y = 0;
|
||||||
gr_width = width * 0.75;
|
gr_width = width;
|
||||||
gr_height = height * 0.08;
|
gr_height = height * 0.25;
|
||||||
x = (width / 2) - (gr_width / 2);
|
x = 0;
|
||||||
|
|
||||||
paint_color_gradient(cr, x, y, gr_width, gr_height, 1, 0, 0);
|
paint_color_gradient(cr, x, y, gr_width, gr_height, 1, 0, 0);
|
||||||
|
|
||||||
@ -743,8 +745,8 @@ enable_plane(struct connector *c)
|
|||||||
width, height, cairo_status_to_string(status));
|
width, height, cairo_status_to_string(status));
|
||||||
|
|
||||||
ret = drmModeAddFB2(fd, width, height, V4L2_PIX_FMT_RGB32, 24, 32,
|
ret = drmModeAddFB2(fd, width, height, V4L2_PIX_FMT_RGB32, 24, 32,
|
||||||
cairo_image_surface_get_stride(surface),
|
cairo_image_surface_get_stride(surface),
|
||||||
handle, &fb_id);
|
handle, &fb_id);
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
gem_close(fd, handle);
|
gem_close(fd, handle);
|
||||||
|
|
||||||
@ -754,7 +756,8 @@ enable_plane(struct connector *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drmModeSetPlane(fd, plane_id, c->crtc, fb_id, x, y, 0, 0)) {
|
if (drmModeSetPlane(fd, plane_id, c->crtc, fb_id, crtc_x, crtc_y,
|
||||||
|
crtc_w, crtc_h, 0, 0, width, height)) {
|
||||||
fprintf(stderr, "failed to enable plane: %s\n",
|
fprintf(stderr, "failed to enable plane: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
@ -762,21 +765,42 @@ enable_plane(struct connector *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disable_plane(struct connector *c)
|
disable_planes(int fd)
|
||||||
{
|
{
|
||||||
uint32_t plane_id;
|
struct connector *connectors;
|
||||||
|
int c;
|
||||||
|
|
||||||
plane_id = connector_find_plane(c);
|
resources = drmModeGetResources(fd);
|
||||||
if (!plane_id) {
|
if (!resources) {
|
||||||
fprintf(stderr, "failed to find plane for crtc\n");
|
fprintf(stderr, "drmModeGetResources failed: %s\n",
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drmModeSetPlane(fd, plane_id, c->crtc, 0, 0, 0, 0, 0)) {
|
|
||||||
fprintf(stderr, "failed to enable plane: %s\n",
|
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectors = calloc(resources->count_connectors,
|
||||||
|
sizeof(struct connector));
|
||||||
|
if (!connectors)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Find any connected displays */
|
||||||
|
for (c = 0; c < resources->count_connectors; c++) {
|
||||||
|
uint32_t plane_id;
|
||||||
|
|
||||||
|
plane_id = connector_find_plane(&connectors[c]);
|
||||||
|
if (!plane_id) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"failed to find plane for crtc\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (drmModeSetPlane(fd, plane_id, connectors[c].crtc, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0)) {
|
||||||
|
fprintf(stderr, "failed to disable plane: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drmModeFreeResources(resources);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void enable_plane(struct connector *c) { return; }
|
static void enable_plane(struct connector *c) { return; }
|
||||||
@ -944,16 +968,16 @@ static int 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:pmt";
|
static char optstr[] = "hiaf:s:d:p:mt";
|
||||||
|
|
||||||
static void usage(char *name)
|
static void usage(char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-hiafs]\n", name);
|
fprintf(stderr, "usage: %s [-hiasdpmtf]\n", name);
|
||||||
fprintf(stderr, "\t-i\tdump info\n");
|
fprintf(stderr, "\t-i\tdump info\n");
|
||||||
fprintf(stderr, "\t-a\ttest all modes\n");
|
fprintf(stderr, "\t-a\ttest all modes\n");
|
||||||
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\t<crtcx,y>,<crtcw,h> test overlay plane\n");
|
||||||
fprintf(stderr, "\t-m\ttest the preferred mode\n");
|
fprintf(stderr, "\t-m\ttest the preferred mode\n");
|
||||||
fprintf(stderr, "\t-t\tuse a tiled framebuffer\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");
|
||||||
@ -998,8 +1022,10 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,
|
|||||||
gsize count;
|
gsize count;
|
||||||
|
|
||||||
count = read(g_io_channel_unix_get_fd(source), buf, sizeof(buf));
|
count = read(g_io_channel_unix_get_fd(source), buf, sizeof(buf));
|
||||||
if (buf[0] == 'q' && (count == 1 || buf[1] == '\n'))
|
if (buf[0] == 'q' && (count == 1 || buf[1] == '\n')) {
|
||||||
|
disable_planes(fd);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1040,6 +1066,9 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "using depth %d\n", depth);
|
fprintf(stderr, "using depth %d\n", depth);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
|
if (sscanf(optarg, "%d,%d,%d,%d", &crtc_x, &crtc_y,
|
||||||
|
&crtc_w, &crtc_h) != 4)
|
||||||
|
usage(argv[0]);
|
||||||
test_plane = 1;
|
test_plane = 1;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
@ -1159,6 +1188,8 @@ out_udev_mon_unref:
|
|||||||
out_udev_unref:
|
out_udev_unref:
|
||||||
udev_unref(u);
|
udev_unref(u);
|
||||||
out_close:
|
out_close:
|
||||||
|
if (test_plane)
|
||||||
|
disable_planes(fd);
|
||||||
drmClose(fd);
|
drmClose(fd);
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user