From: "Wladimir J. van der Laan" <laanwj@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
"Wladimir J. van der Laan" <laanwj@gmail.com>,
Emil Velikov <emil.l.velikov@gmail.com>
Subject: [PATCH libdrm 1/2] tests/modeprint: Print plane and other object properties
Date: Sun, 19 Nov 2017 10:49:30 +0100 [thread overview]
Message-ID: <1511084971-7638-2-git-send-email-laanwj@gmail.com> (raw)
In-Reply-To: <1511084971-7638-1-git-send-email-laanwj@gmail.com>
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 <laanwj@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
next prev parent reply other threads:[~2017-11-19 9:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-19 9:49 [PATCH libdrm 0/2] Print plane modifiers in modeprint Wladimir J. van der Laan
2017-11-19 9:49 ` Wladimir J. van der Laan [this message]
2017-11-19 9:49 ` [PATCH libdrm 2/2] tests/modeprint: Print details for IN_FORMATS blob Wladimir J. van der Laan
2017-11-20 11:36 ` [PATCH libdrm 0/2] Print plane modifiers in modeprint Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511084971-7638-2-git-send-email-laanwj@gmail.com \
--to=laanwj@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox