The open source OpenXR runtime
at main 155 lines 2.9 kB view raw
1// Copyright 2019-2023, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3/*! 4 * @file 5 * @brief Prints information about the system. 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 */ 8 9#include "xrt/xrt_space.h" 10#include "xrt/xrt_system.h" 11#include "xrt/xrt_device.h" 12#include "xrt/xrt_prober.h" 13#include "xrt/xrt_instance.h" 14#include "xrt/xrt_config_drivers.h" 15 16#include "util/u_git_tag.h" 17 18#include "cli_common.h" 19 20#include <string.h> 21#include <stdio.h> 22 23#define P(...) printf(__VA_ARGS__) 24#define PT(...) printf("\t" __VA_ARGS__) 25#define PTT(...) printf("\t\t" __VA_ARGS__) 26 27 28 29static int 30do_exit(struct xrt_instance **xi_ptr, int ret) 31{ 32 xrt_instance_destroy(xi_ptr); 33 34 printf(" :: Exiting '%i'\n", ret); 35 36 return ret; 37} 38 39int 40cli_cmd_info(int argc, const char **argv) 41{ 42 struct xrt_instance *xi = NULL; 43 xrt_result_t xret = XRT_SUCCESS; 44 int ret = 0; 45 46 P(" :: Basic info\n"); 47 PT("runtime: '%s'\n", u_runtime_description); 48 PT("git-tag: '%s'\n", u_git_tag); 49 50 51 /* 52 * Initialize the instance and prober. 53 */ 54 55 P(" :: Creating instance and prober\n"); 56 57 ret = xrt_instance_create(NULL, &xi); 58 if (ret != 0) { 59 PT("Failed to create instance!"); 60 return do_exit(&xi, 0); 61 } 62 63 PT("instance: Ok\n"); 64 65 struct xrt_prober *xp = NULL; 66 xret = xrt_instance_get_prober(xi, &xp); 67 if (xret != XRT_SUCCESS) { 68 PT("No xrt_prober could be created!\n"); 69 return do_exit(&xi, -1); 70 } 71 72 PT("prober: Ok\n"); 73 74 75 /* 76 * List builders, drivers and any modules. 77 */ 78 79 P(" :: Built builders\n"); 80 81 size_t builder_count; 82 struct xrt_builder **builders; 83 size_t num_entries; 84 struct xrt_prober_entry **entries; 85 struct xrt_auto_prober **auto_probers; 86 ret = xrt_prober_get_builders(xp, &builder_count, &builders, &num_entries, &entries, &auto_probers); 87 if (ret != 0) { 88 PT("Failed to get builders!"); 89 do_exit(&xi, ret); 90 } 91 92 for (size_t i = 0; i < builder_count; i++) { 93 struct xrt_builder *builder = builders[i]; 94 if (builder == NULL) { 95 continue; 96 } 97 98 PT("%s: %s\n", builder->identifier, builder->name); 99 100 for (uint32_t k = 0; k < builder->driver_identifier_count; k++) { 101 PTT("%s\n", builder->driver_identifiers[k]); 102 } 103 } 104 105 P(" :: Built auto probers\n"); 106 for (size_t i = 0; i < XRT_MAX_AUTO_PROBERS; i++) { 107 if (auto_probers[i] == NULL) { 108 continue; 109 } 110 111 PT("%s\n", auto_probers[i]->name); 112 } 113 114 P(" :: Built modules and drivers\n"); 115 116#ifdef XRT_BUILD_DRIVER_HANDTRACKING 117 PT("ht\n"); 118#endif 119 120#ifdef XRT_BUILD_DRIVER_DEPTHAI 121 PT("depthai\n"); 122#endif 123 124#ifdef XRT_BUILD_DRIVER_V4L2 125 PT("v4l2\n"); 126#endif 127 128#ifdef XRT_BUILD_DRIVER_VF 129 PT("vf\n"); 130#endif 131 132 133 /* 134 * Dump hardware devices connected. 135 */ 136 137 P(" :: Dumping devices\n"); 138 139 // Need to first probe for devices. 140 xrt_prober_probe(xp); 141 142 // Then we can dump then. 143 xrt_prober_dump(xp, true); 144 145 146 /* 147 * Done. 148 */ 149 150 // End of program 151 P(" :: All ok, shutting down.\n"); 152 153 // Finally done 154 return do_exit(&xi, 0); 155}