// gcc -Og -Wall -Wextra $(pkg-config --cflags libdrm) -o list-kms-devices list-kms-devices.c $(pkg-config --libs libdrm) #include #include #include #include #include int main() { for( int i = 0; i < DRM_MAX_MINOR; ++i ) { char path[ 32 ]; // this is plenty for this purpose sprintf( path, DRM_DEV_NAME, DRM_DIR_NAME, i ); int fd = open( path, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK ); if( fd < 0 ) { if( errno != ENOENT ) fprintf( stderr, "%s: %m\n", path ); continue; } if( drmSetClientCap( fd, DRM_CLIENT_CAP_ATOMIC, 1 ) >= 0 ) { printf( "%s:\n", path ); drmVersionPtr v = drmGetVersion( fd ); printf( "\tdriver: %s (%s)\n", v->name, v->desc ); printf( "\tversion: v%d.%d.%d (%s)\n", v->version_major, v->version_minor, v->version_patchlevel, v->date ); drmFreeVersion( v ); } close( fd ); } return 0; }