Make it possible to print plane properties, and the properties of other DRM mode objects, if available.
Signed-off-by: Wladimir J. van der Laan <laa...@gmail.com> --- tests/modeprint/modeprint.c | 100 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c index 0d85410..42c0a1b 100644 --- a/tests/modeprint/modeprint.c +++ b/tests/modeprint/modeprint.c @@ -52,6 +52,7 @@ int full_modes; int encoders; int crtcs; int fbs; +int planes; char *module_name; static const char* getConnectionText(drmModeConnection conn) @@ -92,7 +93,7 @@ static int printMode(struct drm_mode_modeinfo *mode) return 0; } -static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t value) +static int printProperty(int fd, drmModePropertyPtr props, uint64_t value) { const char *name = NULL; int j; @@ -141,6 +142,25 @@ static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, ui return 0; } +static int printObjectProps(int fd, uint32_t object_id, uint32_t object_type) +{ + uint32_t i; + + drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(fd, object_id, object_type); + if (props) { + for (i = 0; i < props->count_props; i++) { + drmModePropertyPtr prop = drmModeGetProperty(fd, props->props[i]); + if (prop) { + printProperty(fd, prop, props->prop_values[i]); + drmModeFreeProperty(prop); + } + } + drmModeFreeObjectProperties(props); + } + + return 0; +} + static const char * const output_names[] = { "None", "VGA", "DVI-I", @@ -204,7 +224,7 @@ static int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connect for (i = 0; i < connector->count_props; i++) { props = drmModeGetProperty(fd, connector->props[i]); if (props) { - printProperty(fd, res, props, connector->prop_values[i]); + printProperty(fd, props, connector->prop_values[i]); drmModeFreeProperty(props); } } @@ -221,6 +241,11 @@ static int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, ui printf("\ttype :%d\n", encoder->encoder_type); printf("\tpossible_crtcs :0x%x\n", encoder->possible_crtcs); printf("\tpossible_clones :0x%x\n", encoder->possible_clones); + + if (full_props) { + printObjectProps(fd, encoder->crtc_id, DRM_MODE_OBJECT_ENCODER); + } + return 0; } @@ -235,6 +260,10 @@ static int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id printf("\tmode : %p\n", &crtc->mode); printf("\tgamma size : %d\n", crtc->gamma_size); + if (full_props) { + printObjectProps(fd, crtc->crtc_id, DRM_MODE_OBJECT_CRTC); + } + return 0; } @@ -249,16 +278,50 @@ static int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) printf("\tdepth : %i\n", fb->depth); printf("\tbuffer_id : %i\n", fb->handle); + if (full_props) { + printObjectProps(fd, fb->fb_id, DRM_MODE_OBJECT_FB); + } + + return 0; +} + +static int printPlane(int fd, drmModePlanePtr plane) +{ + uint32_t i; + + printf("Plane\n"); + printf("\tcount_formats : %i\n", plane->count_formats); + if (plane->count_formats) { + printf("\tformats :"); + for (i = 0; i < plane->count_formats; i++) + printf(" %c%c%c%c", plane->formats[i] >> 24, plane->formats[i] >> 16, plane->formats[i] >> 8, plane->formats[i] >> 0); + printf("\n"); + } + printf("\tplane_id : %i\n", plane->plane_id); + printf("\tcrtc_id : %i\n", plane->crtc_id); + printf("\tfb_id : %i\n", plane->fb_id);; + printf("\tcrtc_x : %i\n", plane->crtc_x); + printf("\tcrtc_y : %i\n", plane->crtc_y); + printf("\tx : %i\n", plane->x); + printf("\ty : %i\n", plane->y); + printf("\tpossible_crtcs : 0x%x\n", plane->possible_crtcs); + printf("\tgamma_size : %i\n", plane->gamma_size); + + if (full_props) { + printObjectProps(fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); + } + return 0; } -static int printRes(int fd, drmModeResPtr res) +static int printRes(int fd, drmModeResPtr res, drmModePlaneResPtr pres) { int i; drmModeFBPtr fb; drmModeCrtcPtr crtc; drmModeEncoderPtr encoder; drmModeConnectorPtr connector; + drmModePlanePtr plane; printf("Resources\n\n"); @@ -266,6 +329,7 @@ static int printRes(int fd, drmModeResPtr res) printf("count_encoders : %i\n", res->count_encoders); printf("count_crtcs : %i\n", res->count_crtcs); printf("count_fbs : %i\n", res->count_fbs); + printf("count_planes : %i\n", pres->count_planes); printf("\n"); @@ -325,6 +389,19 @@ static int printRes(int fd, drmModeResPtr res) } } + if (planes) { + for (i = 0; i < (int)pres->count_planes; i++) { + plane = drmModeGetPlane(fd, pres->planes[i]); + + if (!plane) + printf("Could not get plane %i\n", pres->planes[i]); + else { + printPlane(fd, plane); + drmModeFreePlane(plane); + } + } + } + return 0; } @@ -338,6 +415,7 @@ static void args(int argc, char **argv) crtcs = 0; modes = 0; encoders = 0; + planes = 0; full_modes = 0; full_props = 0; connectors = 0; @@ -376,12 +454,16 @@ static void args(int argc, char **argv) } else if (strcmp(argv[i], "-encoders") == 0) { encoders = 1; defaults = 0; + } else if (strcmp(argv[i], "-planes") == 0) { + planes = 1; + defaults = 0; } else if (strcmp(argv[i], "-v") == 0) { fbs = 1; edid = 1; crtcs = 1; modes = 1; encoders = 1; + planes = 1; full_modes = 1; full_props = 1; connectors = 1; @@ -397,6 +479,7 @@ static void args(int argc, char **argv) crtcs = 1; modes = 1; encoders = 1; + planes = 1; full_modes = 0; full_props = 0; connectors = 1; @@ -407,6 +490,7 @@ int main(int argc, char **argv) { int fd; drmModeResPtr res; + drmModePlaneResPtr pres; if (argc == 1) { printf("Please add modulename as first argument\n"); @@ -430,9 +514,17 @@ int main(int argc, char **argv) drmClose(fd); return 1; } + pres = drmModeGetPlaneResources(fd); + if (pres == 0) { + printf("Failed to get plane resources from card\n"); + drmModeFreeResources(res); + drmClose(fd); + return 1; + } - printRes(fd, res); + printRes(fd, res, pres); + drmModeFreePlaneResources(pres); drmModeFreeResources(res); printf("Ok\n"); -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel