summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modetest/modetest.c73
1 files changed, 69 insertions, 4 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index e49838b4..a9a09105 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -86,15 +86,21 @@ struct plane {
drmModePropertyRes **props_info;
};
+struct source {
+ drmModeSource *source;
+};
+
struct resources {
drmModeRes *res;
drmModePlaneRes *plane_res;
+ drmModeSourceRes *source_res;
struct crtc *crtcs;
struct encoder *encoders;
struct connector *connectors;
struct fb *fbs;
struct plane *planes;
+ struct source *sources;
};
struct device {
@@ -482,6 +488,40 @@ static void dump_planes(struct device *dev)
return;
}
+static void dump_sources(struct device *dev)
+{
+ unsigned int i, j;
+
+ printf("Sources:\n");
+ printf("id\tplane\twidth\theight\tformat\tpossible planes\tname\n");
+
+ if (!dev->resources->source_res)
+ return;
+
+ for (i = 0; i < dev->resources->source_res->count_sources; i++) {
+ struct source *source = &dev->resources->sources[i];
+ drmModeSource *src = source->source;
+ if (!src)
+ continue;
+
+ printf("%d\t%d\t%d\t%d\t%4.4s\t0x%08x\t%s\n",
+ src->source_id, src->plane_id,
+ src->width, src->height, (char *)&src->pixel_format,
+ src->possible_planes, src->name);
+
+ if (!src->count_formats)
+ continue;
+
+ printf(" formats:");
+ for (j = 0; j < src->count_formats; j++)
+ printf(" %4.4s", (char *)&src->formats[j]);
+ printf("\n");
+ }
+ printf("\n");
+
+ return;
+}
+
static void free_resources(struct resources *res)
{
if (!res)
@@ -528,6 +568,12 @@ static void free_resources(struct resources *res)
drmModeFreePlaneResources(res->plane_res);
}
+ if (res->source_res) {
+ free_resource(res, source_res, source, Source);
+
+ drmModeFreeSourceResources(res->source_res);
+ }
+
free(res);
}
@@ -612,6 +658,7 @@ static struct resources *get_resources(struct device *dev)
for (i = 0; i < res->res->count_crtcs; ++i)
res->crtcs[i].mode = &res->crtcs[i].crtc->mode;
+ /* Planes */
res->plane_res = drmModeGetPlaneResources(dev->fd);
if (!res->plane_res) {
fprintf(stderr, "drmModeGetPlaneResources failed: %s\n",
@@ -628,6 +675,19 @@ static struct resources *get_resources(struct device *dev)
get_resource(res, plane_res, plane, Plane);
get_properties(res, plane_res, plane, PLANE);
+ /* Live sources */
+ res->source_res = drmModeGetSourceResources(dev->fd);
+ if (!res->source_res) /* Live sources are optional */
+ return res;
+
+ res->sources = malloc(res->source_res->count_sources * sizeof *res->sources);
+ if (!res->sources)
+ goto error;
+
+ memset(res->sources, 0, res->source_res->count_sources * sizeof *res->sources);
+
+ get_resource(res, source_res, source, Source);
+
return res;
error:
@@ -1309,7 +1369,7 @@ static void usage(char *name)
fprintf(stderr, "\t-c\tlist connectors\n");
fprintf(stderr, "\t-e\tlist encoders\n");
fprintf(stderr, "\t-f\tlist framebuffers\n");
- fprintf(stderr, "\t-p\tlist CRTCs and planes (pipes)\n");
+ fprintf(stderr, "\t-p\tlist CRTCs, planes and sources (pipes)\n");
fprintf(stderr, "\n Test options:\n\n");
fprintf(stderr, "\t-P <crtc_id>:<w>x<h>[+<x>+<y>][@<format>]\tset a plane\n");
@@ -1353,7 +1413,8 @@ int main(int argc, char **argv)
struct device dev;
int c;
- int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0;
+ int encoders = 0, connectors = 0, framebuffers = 0;
+ int crtcs = 0, planes = 0, sources = 0;
int drop_master = 0;
int test_vsync = 0;
const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos" };
@@ -1407,6 +1468,7 @@ int main(int argc, char **argv)
case 'p':
crtcs = 1;
planes = 1;
+ sources = 1;
break;
case 's':
pipe_args = realloc(pipe_args,
@@ -1443,8 +1505,10 @@ int main(int argc, char **argv)
}
}
- if (!args)
- encoders = connectors = crtcs = planes = framebuffers = 1;
+ if (!args) {
+ encoders = connectors = framebuffers = 1;
+ crtcs = planes = sources = 1;
+ }
if (module) {
dev.fd = drmOpen(module, NULL);
@@ -1492,6 +1556,7 @@ int main(int argc, char **argv)
dump_resource(&dev, connectors);
dump_resource(&dev, crtcs);
dump_resource(&dev, planes);
+ dump_resource(&dev, sources);
dump_resource(&dev, framebuffers);
for (i = 0; i < prop_count; ++i)