Print plane modifiers in modeprint
cover Print plane modifiers in modeprint
This patch series adds support for printing the properties of all DRM mode objects. This is subsequently used to parse the IN_FORMATS blob to be able to print the available modifiers and their formats.
Wladimir J. van der Laan (2):
tests/modeprint: Print plane and other object properties tests/modeprint: Print details for IN_FORMATS blob
tests/modeprint/modeprint.c | 122 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 4 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 tests/modeprint: Print plane and other object properties
Make it possible to print plane properties, and the properties of other DRM mode objects, if available.
--- tests/modeprint/modeprint.c | 100 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-)
tests/modeprint/modeprint.c +96 -4
@@ -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, uireturn 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 connectfor (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, uiprintf ("\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 idprintf ("\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" );
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 tests/modeprint: Print details for IN_FORMATS blob
In reply to Wladimir J. van der LaanPretty-print formats and modifiers in IN_FORMATS blob.
--- tests/modeprint/modeprint.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
tests/modeprint/modeprint.c +23 -0
@@ -93,6 +93,28 @@ static int printMode(struct drm_mode_modeinfo *mode)return 0 ; } +static int printBlob (const char *name,void *data,uint32_t length) +{ +if (!strcmp (name,"IN_FORMATS" )) { +struct drm_format_modifier_blob *m = data; +uint32_t *fmts = (uint32_t *)(((char *)data) + m->formats_offset); +struct drm_format_modifier *mod = (struct drm_format_modifier *)(((char *)data) + m->modifiers_offset); +int i,j,k; +printf ("\tmodifiers :\n" ); +for (j =0 ; j < (int )m->count_modifiers; j++) { +printf ("\t\t0x%016" PRIx64, mod[j].modifier); +for (i =0 ; i <64 && (i + mod[j].offset) < (int )m->count_formats; i++) { +if (mod[j].formats & (1 <<i)) { + k = i + mod[j].offset; +printf (" %c%c%c%c" , fmts[k] >>24 , fmts[k] >>16 , fmts[k] >>8 , fmts[k] >>0 ); + } + } +printf ("\n" ); + } + } +return 0 ; +} +static int printProperty (int fd,drmModePropertyPtr props,uint64_t value) {const char *name =NULL ;
@@ -120,6 +142,7 @@ static int printProperty(int fd, drmModePropertyPtr props, uint64_t value) blob =drmModeGetPropertyBlob (fd, value);if (blob) {printf ("blob is %d length, %08X\n" , blob->length, *(uint32_t *)blob->data); +printBlob (props->name, blob->data, blob->length);drmModeFreePropertyBlob (blob); }else {printf ("error getting blob %" PRIu64"\n" , value);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Wladimir J. van der Laan
This patch series adds support for printing the properties of all DRM mode objects. This is subsequently used to parse the
IN_FORMATSblob to be able to print the available modifiers and their formats.Wladimir J. van der Laan (2):
tests/modeprint: Print plane and other object properties tests/modeprint: Print details forIN_FORMATSblob
Series looks good.
Crazy idea:
Worth folding modeprint and modetest into a single binary? There seems to be a lot of duplicated functionality across the two.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel