The open source OpenXR runtime
0
fork

Configure Feed

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

d/wmr: Add trace markers to some common functions

authored by

Jakob Bornecrantz and committed by
Mateo de Mayo
b322ff68 4aa2ae98

+119 -1
+16 -1
src/xrt/drivers/wmr/wmr_bt_controller.c
··· 21 21 #include "util/u_time.h" 22 22 #include "util/u_debug.h" 23 23 #include "util/u_device.h" 24 + #include "util/u_trace_marker.h" 24 25 25 26 #include "wmr_common.h" 26 27 #include "wmr_bt_controller.h" ··· 56 57 static bool 57 58 read_packets(struct wmr_bt_controller *d) 58 59 { 60 + DRV_TRACE_MARKER(); 61 + 59 62 unsigned char buffer[WMR_MOTION_CONTROLLER_MSG_BUFFER_SIZE]; 60 63 61 64 // Better cpu efficiency with blocking reads instead of multiple reads. ··· 63 66 64 67 // Get the timing as close to reading packet as possible. 65 68 uint64_t now_ns = os_monotonic_get_ns(); 69 + 70 + DRV_TRACE_IDENT(read_packets_got); 66 71 67 72 if (size < 0) { 68 73 WMR_ERROR(d, "WMR Controller (Bluetooth): Error reading from device"); ··· 288 293 static void 289 294 wmr_bt_controller_set_output(struct xrt_device *xdev, enum xrt_output_name name, union xrt_output_value *value) 290 295 { 296 + DRV_TRACE_MARKER(); 297 + 291 298 // struct wmr_bt_controller *d = wmr_bt_controller(xdev); 292 299 // Todo: implement 293 300 } 294 - 295 301 296 302 static void 297 303 wmr_bt_controller_get_tracked_pose(struct xrt_device *xdev, ··· 299 305 uint64_t at_timestamp_ns, 300 306 struct xrt_space_relation *out_relation) 301 307 { 308 + DRV_TRACE_MARKER(); 309 + 302 310 struct wmr_bt_controller *d = wmr_bt_controller(xdev); 303 311 304 312 // Variables needed for prediction. ··· 341 349 static void 342 350 wmr_bt_controller_update_inputs(struct xrt_device *xdev) 343 351 { 352 + DRV_TRACE_MARKER(); 353 + 344 354 struct wmr_bt_controller *d = wmr_bt_controller(xdev); 345 355 346 356 struct xrt_input *inputs = d->base.inputs; ··· 362 372 static void * 363 373 wmr_bt_controller_run_thread(void *ptr) 364 374 { 375 + DRV_TRACE_MARKER(); 376 + 365 377 struct wmr_bt_controller *d = wmr_bt_controller(ptr); 366 378 367 379 os_thread_helper_lock(&d->controller_thread); ··· 383 395 static void 384 396 wmr_bt_controller_destroy(struct xrt_device *xdev) 385 397 { 398 + DRV_TRACE_MARKER(); 399 + 386 400 struct wmr_bt_controller *d = wmr_bt_controller(xdev); 387 401 388 402 // Remove the variable tracking. ··· 445 459 enum xrt_device_type controller_type, 446 460 enum u_logging_level log_level) 447 461 { 462 + DRV_TRACE_MARKER(); 448 463 449 464 enum u_device_alloc_flags flags = U_DEVICE_ALLOC_TRACKING_NONE; 450 465 struct wmr_bt_controller *d = U_DEVICE_ALLOCATE(struct wmr_bt_controller, flags, 10, 1);
+15
src/xrt/drivers/wmr/wmr_camera.c
··· 20 20 #include "util/u_var.h" 21 21 #include "util/u_sink.h" 22 22 #include "util/u_frame.h" 23 + #include "util/u_trace_marker.h" 23 24 24 25 #include "wmr_protocol.h" 25 26 #include "wmr_camera.h" ··· 194 195 static void * 195 196 wmr_cam_usb_thread(void *ptr) 196 197 { 198 + DRV_TRACE_MARKER(); 199 + 197 200 struct wmr_camera *cam = ptr; 198 201 199 202 os_thread_helper_lock(&cam->usb_thread); ··· 250 253 static void LIBUSB_CALL 251 254 img_xfer_cb(struct libusb_transfer *xfer) 252 255 { 256 + DRV_TRACE_MARKER(); 257 + 253 258 struct wmr_camera *cam = xfer->user_data; 254 259 255 260 if (xfer->status != LIBUSB_TRANSFER_COMPLETED) { ··· 394 399 struct xrt_frame_sink *right_sink, 395 400 enum u_logging_level log_level) 396 401 { 402 + DRV_TRACE_MARKER(); 403 + 397 404 struct wmr_camera *cam = calloc(1, sizeof(struct wmr_camera)); 398 405 int res, i; 399 406 ··· 460 467 void 461 468 wmr_camera_free(struct wmr_camera *cam) 462 469 { 470 + DRV_TRACE_MARKER(); 471 + 463 472 // Stop the camera. 464 473 wmr_camera_stop(cam); 465 474 ··· 496 505 bool 497 506 wmr_camera_start(struct wmr_camera *cam, const struct wmr_camera_config *cam_configs, int config_count) 498 507 { 508 + DRV_TRACE_MARKER(); 509 + 499 510 int res = 0; 500 511 501 512 cam->configs = cam_configs; ··· 559 570 bool 560 571 wmr_camera_stop(struct wmr_camera *cam) 561 572 { 573 + DRV_TRACE_MARKER(); 574 + 562 575 int res, i; 563 576 564 577 if (!cam->running) { ··· 593 606 int 594 607 wmr_camera_set_exposure_gain(struct wmr_camera *cam, uint8_t camera_id, uint16_t exposure, uint8_t gain) 595 608 { 609 + DRV_TRACE_MARKER(); 610 + 596 611 struct wmr_camera_gain_cmd cmd = { 597 612 .magic = __cpu_to_le32(WMR_MAGIC), 598 613 .len = __cpu_to_le32(sizeof(struct wmr_camera_gain_cmd)),
+67
src/xrt/drivers/wmr/wmr_hmd.c
··· 28 28 #include "util/u_time.h" 29 29 #include "util/u_debug.h" 30 30 #include "util/u_device.h" 31 + #include "util/u_trace_marker.h" 31 32 #include "util/u_distortion_mesh.h" 32 33 33 34 #include "tracking/t_tracking.h" ··· 137 138 static void 138 139 hololens_handle_unknown(struct wmr_hmd *wh, const unsigned char *buffer, int size) 139 140 { 141 + DRV_TRACE_MARKER(); 142 + 140 143 WMR_DEBUG(wh, "Unknown hololens sensors message type: %02x, (%i)", buffer[0], size); 141 144 } 142 145 143 146 static void 144 147 hololens_handle_control(struct wmr_hmd *wh, const unsigned char *buffer, int size) 145 148 { 149 + DRV_TRACE_MARKER(); 150 + 146 151 WMR_DEBUG(wh, "WMR_MS_HOLOLENS_MSG_CONTROL: %02x, (%i)", buffer[0], size); 147 152 } 148 153 149 154 static void 150 155 hololens_handle_controller_status_packet(struct wmr_hmd *wh, const unsigned char *buffer, int size) 151 156 { 157 + DRV_TRACE_MARKER(); 158 + 152 159 if (size < 3) { 153 160 WMR_DEBUG(wh, "Got small packet 0x17 (%i)", size); 154 161 return; ··· 203 210 static void 204 211 hololens_handle_bt_iface_packet(struct wmr_hmd *wh, const unsigned char *buffer, int size) 205 212 { 213 + DRV_TRACE_MARKER(); 214 + 206 215 int pkt_type; 207 216 208 217 if (size < 2) ··· 235 244 static void 236 245 hololens_handle_controller_packet(struct wmr_hmd *wh, const unsigned char *buffer, int size) 237 246 { 247 + DRV_TRACE_MARKER(); 248 + 238 249 if (size >= 45) { 239 250 WMR_TRACE(wh, 240 251 "Got controller (%i)\n\t%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x | %02x %02x %02x " ··· 251 262 static void 252 263 hololens_handle_debug(struct wmr_hmd *wh, const unsigned char *buffer, int size) 253 264 { 265 + DRV_TRACE_MARKER(); 266 + 254 267 if (size < 12) { 255 268 WMR_TRACE(wh, "Got short debug packet (%i) 0x%02x", size, buffer[0]); 256 269 return; ··· 273 286 static void 274 287 hololens_handle_sensors(struct wmr_hmd *wh, const unsigned char *buffer, int size) 275 288 { 289 + DRV_TRACE_MARKER(); 290 + 276 291 // Get the timing as close to reading the packet as possible. 277 292 uint64_t now_ns = os_monotonic_get_ns(); 278 293 ··· 322 337 static bool 323 338 hololens_sensors_read_packets(struct wmr_hmd *wh) 324 339 { 340 + DRV_TRACE_MARKER(); 341 + 325 342 WMR_TRACE(wh, " "); 326 343 327 344 unsigned char buffer[WMR_FEATURE_BUFFER_SIZE]; ··· 404 421 static bool 405 422 control_read_packets(struct wmr_hmd *wh) 406 423 { 424 + DRV_TRACE_MARKER(); 425 + 407 426 unsigned char buffer[WMR_FEATURE_BUFFER_SIZE]; 408 427 409 428 // Do not block ··· 419 438 } else { 420 439 WMR_TRACE(wh, "Read %u bytes", size); 421 440 } 441 + 442 + DRV_TRACE_IDENT(control_packet_got); 422 443 423 444 switch (buffer[0]) { 424 445 case WMR_CONTROL_MSG_IPD_VALUE: // ··· 455 476 static void * 456 477 wmr_run_thread(void *ptr) 457 478 { 479 + DRV_TRACE_MARKER(); 480 + 458 481 struct wmr_hmd *wh = (struct wmr_hmd *)ptr; 459 482 460 483 os_thread_helper_lock(&wh->oth); ··· 482 505 static void 483 506 hololens_sensors_enable_imu(struct wmr_hmd *wh) 484 507 { 508 + DRV_TRACE_MARKER(); 509 + 485 510 int size = os_hid_write(wh->hid_hololens_sensors_dev, hololens_sensors_imu_on, sizeof(hololens_sensors_imu_on)); 486 511 if (size <= 0) { 487 512 WMR_ERROR(wh, "Error writing to device"); ··· 508 533 static int 509 534 wmr_hmd_activate_reverb(struct wmr_hmd *wh) 510 535 { 536 + DRV_TRACE_MARKER(); 537 + 511 538 struct os_hid_device *hid = wh->hid_control_dev; 512 539 513 540 WMR_TRACE(wh, "Activating HP Reverb G1/G2 HMD..."); ··· 568 595 static void 569 596 wmr_hmd_deactivate_reverb(struct wmr_hmd *wh) 570 597 { 598 + DRV_TRACE_MARKER(); 599 + 571 600 // Turn the screen off 572 601 wmr_hmd_screen_enable_reverb(wh, false); 573 602 ··· 577 606 static void 578 607 wmr_hmd_screen_enable_reverb(struct wmr_hmd *wh, bool enable) 579 608 { 609 + DRV_TRACE_MARKER(); 610 + 580 611 struct os_hid_device *hid = wh->hid_control_dev; 581 612 582 613 unsigned char cmd[2] = {0x04, 0x00}; ··· 595 626 static int 596 627 wmr_hmd_activate_odyssey_plus(struct wmr_hmd *wh) 597 628 { 629 + DRV_TRACE_MARKER(); 630 + 598 631 struct os_hid_device *hid = wh->hid_control_dev; 599 632 600 633 WMR_TRACE(wh, "Activating Odyssey HMD..."); ··· 628 661 static void 629 662 wmr_hmd_deactivate_odyssey_plus(struct wmr_hmd *wh) 630 663 { 664 + DRV_TRACE_MARKER(); 665 + 631 666 // Turn the screen off 632 667 wmr_hmd_screen_enable_odyssey_plus(wh, false); 633 668 ··· 637 672 static void 638 673 wmr_hmd_screen_enable_odyssey_plus(struct wmr_hmd *wh, bool enable) 639 674 { 675 + DRV_TRACE_MARKER(); 676 + 640 677 struct os_hid_device *hid = wh->hid_control_dev; 641 678 642 679 unsigned char cmd[2] = {0x12, 0x00}; ··· 670 707 static int 671 708 wmr_config_command_sync(struct wmr_hmd *wh, unsigned char type, unsigned char *buf, int len) 672 709 { 710 + DRV_TRACE_MARKER(); 711 + 673 712 struct os_hid_device *hid = wh->hid_hololens_sensors_dev; 674 713 675 714 unsigned char cmd[64] = {0x02, type}; ··· 691 730 static int 692 731 wmr_read_config_part(struct wmr_hmd *wh, unsigned char type, unsigned char *data, int len) 693 732 { 733 + DRV_TRACE_MARKER(); 734 + 694 735 unsigned char buf[33]; 695 736 int offset = 0; 696 737 int size; ··· 733 774 XRT_MAYBE_UNUSED static int 734 775 wmr_read_config_raw(struct wmr_hmd *wh, uint8_t **out_data, size_t *out_size) 735 776 { 777 + DRV_TRACE_MARKER(); 778 + 736 779 unsigned char meta[84]; 737 780 uint8_t *data; 738 781 int size, data_size; ··· 773 816 static int 774 817 wmr_read_config(struct wmr_hmd *wh) 775 818 { 819 + DRV_TRACE_MARKER(); 820 + 776 821 unsigned char *data = NULL, *config_json_block; 777 822 size_t data_size; 778 823 int ret; ··· 830 875 static void 831 876 wmr_hmd_update_inputs(struct xrt_device *xdev) 832 877 { 878 + DRV_TRACE_MARKER(); 879 + 833 880 struct wmr_hmd *wh = wmr_hmd(xdev); 834 881 (void)wh; 835 882 } ··· 840 887 uint64_t at_timestamp_ns, 841 888 struct xrt_space_relation *out_relation) 842 889 { 890 + DRV_TRACE_MARKER(); 891 + 843 892 struct wmr_hmd *wh = wmr_hmd(xdev); 844 893 845 894 if (name != XRT_INPUT_GENERIC_HEAD_POSE) { ··· 892 941 uint64_t at_timestamp_ns, 893 942 struct xrt_space_relation *out_relation) 894 943 { 944 + DRV_TRACE_MARKER(); 945 + 895 946 struct wmr_hmd *wh = wmr_hmd(xdev); 896 947 xrt_tracked_slam_get_tracked_pose(wh->slam.tracker, at_timestamp_ns, out_relation); 897 948 ··· 918 969 uint64_t at_timestamp_ns, 919 970 struct xrt_space_relation *out_relation) 920 971 { 972 + DRV_TRACE_MARKER(); 973 + 921 974 struct wmr_hmd *wh = wmr_hmd(xdev); 922 975 if (wh->slam.enabled && wh->use_slam_tracker) { 923 976 wmr_hmd_get_slam_tracked_pose(xdev, name, at_timestamp_ns, out_relation); ··· 933 986 uint32_t view_index, 934 987 struct xrt_pose *out_pose) 935 988 { 989 + DRV_TRACE_MARKER(); 990 + 936 991 (void)xdev; 937 992 u_device_get_view_pose(eye_relation, view_index, out_pose); 938 993 } ··· 940 995 static void 941 996 wmr_hmd_destroy(struct xrt_device *xdev) 942 997 { 998 + DRV_TRACE_MARKER(); 999 + 943 1000 struct wmr_hmd *wh = wmr_hmd(xdev); 944 1001 945 1002 // Destroy the thread object. ··· 973 1030 static bool 974 1031 compute_distortion_wmr(struct xrt_device *xdev, int view, float u, float v, struct xrt_uv_triplet *result) 975 1032 { 1033 + DRV_TRACE_MARKER(); 1034 + 976 1035 struct wmr_hmd *wh = wmr_hmd(xdev); 977 1036 978 1037 assert(view == 0 || view == 1); ··· 1034 1093 float *out_angle_down, 1035 1094 float *out_angle_up) 1036 1095 { 1096 + DRV_TRACE_MARKER(); 1097 + 1037 1098 assert(view == 0 || view == 1); 1038 1099 1039 1100 float tanangle_left = 0.0f, tanangle_right = 0.0f, tanangle_up = 0.0f, tanangle_down = 0.0f; ··· 1108 1169 static void 1109 1170 wmr_hmd_switch_tracker(void *wh_ptr) 1110 1171 { 1172 + DRV_TRACE_MARKER(); 1173 + 1111 1174 struct wmr_hmd *wh = (struct wmr_hmd *)wh_ptr; 1112 1175 wh->use_slam_tracker = !wh->use_slam_tracker; 1113 1176 struct u_var_button *btn = &wh->gui.switch_tracker_btn; ··· 1126 1189 static struct xrt_slam_sinks * 1127 1190 wmr_hmd_slam_track(struct wmr_hmd *wh) 1128 1191 { 1192 + DRV_TRACE_MARKER(); 1193 + 1129 1194 struct xrt_slam_sinks *sinks = NULL; 1130 1195 1131 1196 #ifdef XRT_HAVE_SLAM ··· 1152 1217 struct xrt_prober_device *dev_holo, 1153 1218 enum u_logging_level log_level) 1154 1219 { 1220 + DRV_TRACE_MARKER(); 1221 + 1155 1222 enum u_device_alloc_flags flags = 1156 1223 (enum u_device_alloc_flags)(U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE); 1157 1224 int ret = 0, i;
+4
src/xrt/drivers/wmr/wmr_prober.c
··· 14 14 #include "util/u_misc.h" 15 15 #include "util/u_debug.h" 16 16 #include "util/u_logging.h" 17 + #include "util/u_trace_marker.h" 17 18 18 19 #include "wmr_interface.h" 19 20 #include "wmr_hmd.h" ··· 152 153 cJSON *attached_data, 153 154 struct xrt_device **out_xdev) 154 155 { 156 + DRV_TRACE_MARKER(); 157 + 155 158 enum u_logging_level log_level = debug_get_log_option_wmr_log(); 156 159 157 160 struct xrt_prober_device *dev_holo = devices[index]; ··· 211 214 cJSON *attached_data, 212 215 struct xrt_device **out_xdev) 213 216 { 217 + DRV_TRACE_MARKER(); 214 218 215 219 enum u_logging_level log_level = debug_get_log_option_wmr_log(); 216 220
+17
src/xrt/drivers/wmr/wmr_source.c
··· 16 16 #include "util/u_debug.h" 17 17 #include "util/u_sink.h" 18 18 #include "util/u_var.h" 19 + #include "util/u_trace_marker.h" 19 20 #include "xrt/xrt_tracking.h" 20 21 #include "xrt/xrt_frameserver.h" 21 22 ··· 192 193 static bool 193 194 wmr_source_stream_stop(struct xrt_fs *xfs) 194 195 { 196 + DRV_TRACE_MARKER(); 197 + 195 198 struct wmr_source *ws = wmr_source_from_xfs(xfs); 196 199 197 200 bool stopped = wmr_camera_stop(ws->camera); ··· 206 209 static bool 207 210 wmr_source_is_running(struct xrt_fs *xfs) 208 211 { 212 + DRV_TRACE_MARKER(); 213 + 209 214 struct wmr_source *ws = wmr_source_from_xfs(xfs); 210 215 return ws->is_running; 211 216 } ··· 216 221 enum xrt_fs_capture_type capture_type, 217 222 uint32_t descriptor_index) 218 223 { 224 + DRV_TRACE_MARKER(); 225 + 219 226 struct wmr_source *ws = wmr_source_from_xfs(xfs); 220 227 221 228 if (xs == NULL && capture_type == XRT_FS_CAPTURE_TYPE_TRACKING) { ··· 241 248 static bool 242 249 wmr_source_slam_stream_start(struct xrt_fs *xfs, struct xrt_slam_sinks *sinks) 243 250 { 251 + DRV_TRACE_MARKER(); 252 + 244 253 struct wmr_source *ws = wmr_source_from_xfs(xfs); 245 254 if (sinks != NULL) { 246 255 ws->out_sinks = *sinks; ··· 258 267 static void 259 268 wmr_source_node_break_apart(struct xrt_frame_node *node) 260 269 { 270 + DRV_TRACE_MARKER(); 271 + 261 272 struct wmr_source *ws = container_of(node, struct wmr_source, node); 262 273 wmr_source_stream_stop(&ws->xfs); 263 274 } ··· 265 276 static void 266 277 wmr_source_node_destroy(struct xrt_frame_node *node) 267 278 { 279 + DRV_TRACE_MARKER(); 280 + 268 281 struct wmr_source *ws = container_of(node, struct wmr_source, node); 269 282 WMR_DEBUG(ws, "Destroying WMR source"); 270 283 u_sink_debug_destroy(&ws->ui_left_sink); ··· 289 302 struct xrt_fs * 290 303 wmr_source_create(struct xrt_frame_context *xfctx, struct xrt_prober_device *dev_holo, struct wmr_hmd_config cfg) 291 304 { 305 + DRV_TRACE_MARKER(); 306 + 292 307 struct wmr_source *ws = U_TYPED_CALLOC(struct wmr_source); 293 308 ws->log_level = debug_get_log_option_wmr_log(); 294 309 ws->average_imus = true; ··· 344 359 void 345 360 wmr_source_push_imu_packet(struct xrt_fs *xfs, uint64_t ts[4], struct xrt_vec3 accels[4], struct xrt_vec3 gyros[4]) 346 361 { 362 + DRV_TRACE_MARKER(); 363 + 347 364 struct wmr_source *ws = wmr_source_from_xfs(xfs); 348 365 349 366 if (ws->average_imus) {