The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: Make it possible to control where dump goes

+53 -33
+8 -5
src/xrt/include/xrt/xrt_prober.h
··· 171 171 xrt_result_t (*unlock_list)(struct xrt_prober *xp, struct xrt_prober_device ***devices); 172 172 173 173 /*! 174 - * Dump a listing of all devices found on the system to platform 175 - * dependent output (stdout). 174 + * Dump a listing of all devices found on the system to logging system 175 + * or platform dependent output (stdout). 176 + * 177 + * @param[in] xp Prober self parameter. 178 + * @param[in] use_stdout If true uses stdout instead of logging code. 176 179 * 177 180 * @note Code consuming this interface should use xrt_prober_dump() 178 181 */ 179 - int (*dump)(struct xrt_prober *xp); 182 + int (*dump)(struct xrt_prober *xp, bool use_stdout); 180 183 181 184 /*! 182 185 * Create system devices. ··· 362 365 * @public @memberof xrt_prober 363 366 */ 364 367 static inline int 365 - xrt_prober_dump(struct xrt_prober *xp) 368 + xrt_prober_dump(struct xrt_prober *xp, bool use_stdout) 366 369 { 367 - return xp->dump(xp); 370 + return xp->dump(xp, use_stdout); 368 371 } 369 372 370 373 /*!
+40 -21
src/xrt/state_trackers/prober/p_dump.c
··· 11 11 #include "xrt/xrt_config_have.h" 12 12 13 13 #include "util/u_misc.h" 14 + #include "util/u_pretty_print.h" 15 + 14 16 #include "p_prober.h" 15 17 16 18 #include <stdio.h> 17 19 #include <string.h> 18 20 #include <inttypes.h> 19 21 22 + 23 + #define P(...) \ 24 + do { \ 25 + u_pp(dg, __VA_ARGS__); \ 26 + } while (false) 27 + 28 + #define PT(fmt, ...) P("\t" fmt "\n", __VA_ARGS__) 29 + #define PTT(fmt, ...) P("\t\t" fmt "\n", __VA_ARGS__) 20 30 21 31 static int 22 32 print_ports(char *tmp, size_t size, uint8_t *ports, int num) ··· 63 73 */ 64 74 65 75 void 66 - p_dump_device(struct prober *p, struct prober_device *pdev, int id) 76 + p_dump_device(struct prober *p, struct prober_device *pdev, int id, bool use_stdout) 67 77 { 78 + struct u_pp_sink_stack_only sink; 79 + u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); 80 + 68 81 char tmp[1024]; 69 82 70 83 if (pdev->usb.bus != 0 && pdev->usb.addr == 0 && pdev->base.vendor_id != 0 && pdev->base.product_id == 0) { 71 84 return; 72 85 } 73 86 74 - U_LOG_RAW("\t% 3i: 0x%04x:0x%04x", id, pdev->base.vendor_id, pdev->base.product_id); 75 - U_LOG_RAW("\t\tptr: %p", (void *)pdev); 76 - U_LOG_RAW("\t\tusb_dev_class: %02x", pdev->base.usb_dev_class); 87 + PT("% 3i: 0x%04x:0x%04x", id, pdev->base.vendor_id, pdev->base.product_id); 88 + PTT("ptr: %p", (void *)pdev); 89 + PTT("usb_dev_class: %02x", pdev->base.usb_dev_class); 77 90 78 91 79 92 if (pdev->usb.serial != NULL || pdev->usb.product != NULL || pdev->usb.manufacturer != NULL) { 80 - U_LOG_RAW("\t\tusb.product: %s", pdev->usb.product); 81 - U_LOG_RAW("\t\tusb.manufacturer: %s", pdev->usb.manufacturer); 82 - U_LOG_RAW("\t\tusb.serial: %s", pdev->usb.serial); 93 + PTT("usb.product: %s", pdev->usb.product); 94 + PTT("usb.manufacturer: %s", pdev->usb.manufacturer); 95 + PTT("usb.serial: %s", pdev->usb.serial); 83 96 } 84 97 85 98 if (pdev->usb.bus != 0 || pdev->usb.addr != 0) { 86 - U_LOG_RAW("\t\tusb.bus: %i", pdev->usb.bus); 87 - U_LOG_RAW("\t\tusb.addr: %i", pdev->usb.addr); 99 + PTT("usb.bus: %i", pdev->usb.bus); 100 + PTT("usb.addr: %i", pdev->usb.addr); 88 101 } 89 102 90 103 if (pdev->bluetooth.id != 0) { 91 - U_LOG_RAW("\t\tbluetooth.id: %012" PRIx64 "", pdev->bluetooth.id); 104 + PTT("bluetooth.id: %012" PRIx64 "", pdev->bluetooth.id); 92 105 } 93 106 94 107 int num = pdev->usb.num_ports; 95 108 if (print_ports(tmp, ARRAY_SIZE(tmp), pdev->usb.ports, num)) { 96 - U_LOG_RAW("\t\tport%s %s", num > 1 ? "s:" : ": ", tmp); 109 + PTT("port%s %s", num > 1 ? "s:" : ": ", tmp); 97 110 } 98 111 99 112 #ifdef XRT_HAVE_LIBUSB 100 113 if (pdev->usb.dev != NULL) { 101 - U_LOG_RAW("\t\tlibusb: %p", (void *)pdev->usb.dev); 114 + PTT("libusb: %p", (void *)pdev->usb.dev); 102 115 } 103 116 #endif 104 117 ··· 107 120 if (uvc_dev != NULL) { 108 121 struct uvc_device_descriptor *desc; 109 122 110 - U_LOG_RAW("\t\tlibuvc: %p", (void *)uvc_dev); 123 + PTT("libuvc: %p", (void *)uvc_dev); 111 124 112 125 uvc_get_device_descriptor(uvc_dev, &desc); 113 126 114 127 if (desc->product != NULL) { 115 128 116 - U_LOG_RAW("\t\tproduct: '%s'", desc->product); 129 + PTT("product: '%s'", desc->product); 117 130 } 118 131 if (desc->manufacturer != NULL) { 119 132 120 - U_LOG_RAW("\t\tmanufacturer: '%s'", desc->manufacturer); 133 + PTT("manufacturer: '%s'", desc->manufacturer); 121 134 } 122 135 if (desc->serialNumber != NULL) { 123 136 124 - U_LOG_RAW("\t\tserial: '%s'", desc->serialNumber); 137 + PTT("serial: '%s'", desc->serialNumber); 125 138 } 126 139 127 140 uvc_free_device_descriptor(desc); ··· 133 146 for (size_t j = 0; j < pdev->num_v4ls; j++) { 134 147 struct prober_v4l *v4l = &pdev->v4ls[j]; 135 148 136 - U_LOG_RAW("\t\tv4l.iface: %i", (int)v4l->usb_iface); 137 - U_LOG_RAW("\t\tv4l.index: %i", (int)v4l->v4l_index); 138 - U_LOG_RAW("\t\tv4l.path: '%s'", v4l->path); 149 + PTT("v4l.iface: %i", (int)v4l->usb_iface); 150 + PTT("v4l.index: %i", (int)v4l->v4l_index); 151 + PTT("v4l.path: '%s'", v4l->path); 139 152 } 140 153 #endif 141 154 ··· 143 156 for (size_t j = 0; j < pdev->num_hidraws; j++) { 144 157 struct prober_hidraw *hidraw = &pdev->hidraws[j]; 145 158 146 - U_LOG_RAW("\t\thidraw.iface: %i", (int)hidraw->interface); 147 - U_LOG_RAW("\t\thidraw.path: '%s'", hidraw->path); 159 + PTT("hidraw.iface: %i", (int)hidraw->interface); 160 + PTT("hidraw.path: '%s'", hidraw->path); 148 161 } 149 162 #endif 163 + 164 + if (use_stdout) { 165 + printf("%s", sink.buffer); 166 + } else { 167 + U_LOG_RAW("%s", sink.buffer); 168 + } 150 169 }
+3 -5
src/xrt/state_trackers/prober/p_prober.c
··· 86 86 p_unlock_list(struct xrt_prober *xp, struct xrt_prober_device ***devices); 87 87 88 88 static int 89 - p_dump(struct xrt_prober *xp); 89 + p_dump(struct xrt_prober *xp, bool use_stdout); 90 90 91 91 static xrt_result_t 92 92 p_create_system(struct xrt_prober *xp, ··· 960 960 } 961 961 962 962 static int 963 - p_dump(struct xrt_prober *xp) 963 + p_dump(struct xrt_prober *xp, bool use_stdout) 964 964 { 965 965 XRT_TRACE_MARKER(); 966 966 967 967 struct prober *p = (struct prober *)xp; 968 - XRT_MAYBE_UNUSED ssize_t k = 0; 969 - XRT_MAYBE_UNUSED size_t j = 0; 970 968 971 969 for (size_t i = 0; i < p->device_count; i++) { 972 970 struct prober_device *pdev = &p->devices[i]; 973 - p_dump_device(p, pdev, (int)i); 971 + p_dump_device(p, pdev, (int)i, use_stdout); 974 972 } 975 973 976 974 return 0;
+1 -1
src/xrt/state_trackers/prober/p_prober.h
··· 190 190 * @public @memberof prober 191 191 */ 192 192 void 193 - p_dump_device(struct prober *p, struct prober_device *pdev, int id); 193 + p_dump_device(struct prober *p, struct prober_device *pdev, int id, bool use_stdout); 194 194 195 195 /*! 196 196 * Get or create a @ref prober_device from the device.
+1 -1
src/xrt/targets/cli/cli_cmd_test.c
··· 65 65 // So the user can see what we found. 66 66 printf(" :: Dumping!\n"); 67 67 68 - ret = xrt_prober_dump(xp); 68 + ret = xrt_prober_dump(xp, true); 69 69 if (ret != 0) { 70 70 do_exit(&xi, ret); 71 71 }