Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_prober.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Common interface to probe for devices.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup xrt_iface
9 */
10
11#pragma once
12
13#include "xrt/xrt_device.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
20/*
21 *
22 * Prober and device manager.
23 *
24 */
25
26struct cJSON;
27typedef struct cJSON cJSON;
28
29struct xrt_fs;
31struct xrt_prober;
32struct xrt_prober_entry;
35struct xrt_auto_prober;
37struct xrt_builder;
41struct os_hid_device;
42struct os_serial_device;
44
45/*!
46 * The maximum number of devices that a single
47 * @ref xrt_prober_entry::found or
48 * @ref xrt_auto_prober::lelo_dallas_autoprobe
49 * function called by the prober can create per-call.
50 *
51 * @ingroup xrt_iface
52 */
53#define XRT_MAX_DEVICES_PER_PROBE 16
54
55/*!
56 * The maximum number of @ref xrt_auto_prober instances that can be handled.
57 *
58 * @ingroup xrt_iface
59 */
60#define XRT_MAX_AUTO_PROBERS 16
61
62/*!
63 * Bus type of a device.
64 */
66{
67 XRT_BUS_TYPE_UNKNOWN,
68 XRT_BUS_TYPE_USB,
69 XRT_BUS_TYPE_BLUETOOTH,
70};
71
72/*!
73 * String descriptor types
74 */
76{
77 XRT_PROBER_STRING_MANUFACTURER,
78 XRT_PROBER_STRING_PRODUCT,
79 XRT_PROBER_STRING_SERIAL_NUMBER,
80};
81
82/*!
83 * A probed device, may or may not be opened.
84 *
85 * @ingroup xrt_iface
86 */
88{
89 /*!
90 * USB/Bluetooth vendor ID (VID)
91 */
92 uint16_t vendor_id;
93
94 /*!
95 * USB/Bluetooth product ID (PID)
96 */
97 uint16_t product_id;
98
99 /*!
100 * Device bus type
101 */
103
104 /*!
105 * USB device class
106 */
108};
109
110/*!
111 * Callback for listing video devices.
112 *
113 * @param xp Prober
114 * @param pdev Prober device being iterated
115 * @param product Product string, if available
116 * @param manufacturer Manufacturer string, if available
117 * @param serial Serial number string, if available
118 * @param ptr Your opaque userdata pointer as provided to @ref xrt_prober_list_video_devices
119 * @ingroup xrt_iface
120 */
121typedef void (*xrt_prober_list_video_func_t)(struct xrt_prober *xp,
122 struct xrt_prober_device *pdev,
123 const char *product,
124 const char *manufacturer,
125 const char *serial,
126 void *ptr);
127
128/*!
129 * The main prober that probes and manages found but not opened HMD devices
130 * that are connected to the system.
131 *
132 * @ingroup xrt_iface
133 */
135{
136 //! Factory for producing tracked objects.
138
139 /*!
140 * Enumerate all connected devices, whether or not we have an associated
141 * driver. Cannot be called with the device list is locked
142 * @ref xrt_prober::lock_list and @ref xrt_prober::unlock_list.
143 *
144 * This function along with lock/unlock allows a @ref xrt_builder to
145 * re-probe the devices after having opened another device. A bit more
146 * detailed: It can get a list of devices, search it, open the enabling
147 * one, release the list, do a probe, get the list again and re-scan
148 * to detect any additional devices that may show up once the first
149 * device has been been started.
150 *
151 * @see xrt_prober::lock_list, xrt_prober::unlock_list
152 */
154
155 /*!
156 * Locks the prober list of probed devices and returns it.
157 * While locked, calling @ref xrt_prober::probe is forbidden. Not thread safe.
158 *
159 * See @ref xrt_prober::probe for more detailed expected usage.
160 *
161 * @see xrt_prober::probe, xrt_prober::unlock_list
162 */
164 struct xrt_prober_device ***out_devices,
165 size_t *out_device_count);
166
167 /*!
168 * Unlocks the list, allowing for @ref xrt_prober::probe to be called.
169 * Takes a pointer to the list pointer and clears it. Not thread safe.
170 * See @ref xrt_prober::probe for more detailed expected usage.
171 *
172 * @see xrt_prober::probe, xrt_prober::lock_list
173 */
174 xrt_result_t (*unlock_list)(struct xrt_prober *xp, struct xrt_prober_device ***devices);
175
176 /*!
177 * Dump a listing of all devices found on the system to logging system
178 * or platform dependent output (stdout).
179 *
180 * @param[in] xp Prober self parameter.
181 * @param[in] use_stdout If true uses stdout instead of logging code.
182 *
183 * @note Code consuming this interface should use xrt_prober_dump()
184 */
185 int (*dump)(struct xrt_prober *xp, bool use_stdout);
186
187 /*!
188 * Create system devices.
189 *
190 * @param[in] xp Prober self parameter.
191 * @param[in] broadcast Event sink that broadcasts events to all sessions.
192 * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
193 * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
194 *
195 * @note Code consuming this interface should use xrt_prober_create_system()
196 */
198 struct xrt_session_event_sink *broadcast,
199 struct xrt_system_devices **out_xsysd,
200 struct xrt_space_overseer **out_xso);
201
202 /*!
203 * Iterate through drivers (by ID and auto-probers) checking to see if
204 * they can handle any connected devices from the last xrt_prober::probe
205 * call, opening those devices to create instances of xrt_device
206 * implementations.
207 *
208 * If no HMD (not even a simulated HMD) is found, then no devices will be
209 * returned (all xdevs will be NULL). Otherwise, xdevs will be populated
210 * with the HMD in xdevs[0], and any subsequent non-NULL values
211 * referring to additional non-HMD devices.
212 *
213 * @param xp Pointer to self
214 * @param[in,out] xdevs Pointer to xrt_device array. Array elements will
215 * be populated.
216 * @param[in] xdev_capacity The capacity of the @p xdevs array.
217 *
218 * @return 0 on success (including "no HMD found"), <0 on error.
219 *
220 * Returned devices have their ownership transferred to the caller: all
221 * should be cleaned up with xrt_device_destroy().
222 *
223 * @note Code consuming this interface should use
224 * xrt_prober_select(). Typically used through an xrt_instance and the
225 * xrt_instance_select() method which usually calls xrt_prober_probe()
226 * and xrt_prober_select().
227 */
228 int (*select)(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity);
229
230 /*!
231 * Open a HID (Human Interface Device) interface using native HID support.
232 *
233 * @param xp Pointer to self
234 * @param xpdev prober device
235 * @param iface HID interface number
236 * @param[out] out_hid_dev instance of @ref os_hid_device for the given interface
237 *
238 * @return 0 on success, <0 on error.
239 */
241 struct xrt_prober_device *xpdev,
242 int iface,
243 struct os_hid_device **out_hid_dev);
244
245 /*!
246 * Open a serial device using native serial support.
247 *
248 * @param xp Pointer to self
249 * @param xpdev prober device
250 * @param parameters Serial parameters to use when opening the device
251 * @param[out] out_hid_dev instance of @ref os_hid_device for the given interface
252 *
253 * @return 0 on success, <0 on error.
254 */
256 struct xrt_prober_device *xpdev,
257 const struct os_serial_parameters *parameters,
258 struct os_serial_device **out_serial_dev);
259
260 /*!
261 * Opens the selected video device and returns a @ref xrt_fs, does not
262 * start it.
263 */
264 int (*open_video_device)(struct xrt_prober *xp,
265 struct xrt_prober_device *xpdev,
266 struct xrt_frame_context *xfctx,
267 struct xrt_fs **out_xfs);
268
269 /*!
270 * Iterate through available video devices, calling your callback @p cb with your userdata @p ptr.
271 *
272 * @param xp Pointer to self
273 * @param cb Callback function
274 * @param ptr Opaque pointer for your userdata, passed through to the callback.
275 *
276 * @see xrt_prober_list_video_func_t
277 * @return 0 on success, <0 on error.
278 */
280
281 /*!
282 * Retrieve the raw @ref xrt_builder, @ref xrt_prober_entry and @ref xrt_auto_prober arrays.
283 *
284 * @param xp Pointer to self
285 * @param[out] out_builder_count The size of @p out_builders
286 * @param[out] out_builders An array of builders.
287 * @param[out] out_entry_count The size of @p out_entries
288 * @param[out] out_entries An array of prober entries
289 * @param[out] out_auto_probers An array of up to @ref XRT_MAX_AUTO_PROBERS auto-probers
290 *
291 * @return 0 on success, <0 on error.
292 */
293 int (*get_builders)(struct xrt_prober *xp,
294 size_t *out_builder_count,
295 struct xrt_builder ***out_builders,
296 size_t *out_entry_count,
297 struct xrt_prober_entry ***out_entries,
298 struct xrt_auto_prober ***out_auto_probers);
299
300 /*!
301 * Returns a string property on the device of the given type
302 * @p which_string in @p out_buffer.
303 *
304 * @param[in] xp Prober.
305 * @param[in] xpdev Device to get string property from.
306 * @param[in] which_string Which string property to query.
307 * @param[in,out] out_buffer Target buffer.
308 * @param[in] max_length Max length of the target buffer.
309 *
310 * @return The length of the string, or negative on error.
311 *
312 */
314 struct xrt_prober_device *xpdev,
315 enum xrt_prober_string which_string,
316 unsigned char *out_buffer,
317 size_t max_length);
318
319 /*!
320 * Determine whether a prober device can be opened.
321 *
322 * @param xp Pointer to self
323 * @param xpdev prober device
324 *
325 * @return true if @p xpdev can be opened.
326 */
327 bool (*can_open)(struct xrt_prober *xp, struct xrt_prober_device *xpdev);
328
329 /*!
330 * Destroy the prober and set the pointer to null.
331 *
332 * Code consuming this interface should use xrt_prober_destroy().
333 *
334 * @param xp_ptr pointer to self-pointer
335 */
336 void (*destroy)(struct xrt_prober **xp_ptr);
337};
338
339/*!
340 * @copydoc xrt_prober::probe
341 *
342 * Helper function for @ref xrt_prober::probe.
343 *
344 * @public @memberof xrt_prober
345 */
346XRT_NONNULL_ALL static inline xrt_result_t
348{
349 return xp->probe(xp);
350}
351
352/*!
353 * @copydoc xrt_prober::lock_list
354 *
355 * Helper function for @ref xrt_prober::lock_list.
356 *
357 * @public @memberof xrt_prober
358 */
359XRT_NONNULL_ALL static inline xrt_result_t
360xrt_prober_lock_list(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
361{
362 return xp->lock_list(xp, out_devices, out_device_count);
363}
364
365/*!
366 * @copydoc xrt_prober::unlock_list
367 *
368 * Helper function for @ref xrt_prober::unlock_list.
369 *
370 * @public @memberof xrt_prober
371 */
372XRT_NONNULL_ALL static inline xrt_result_t
374{
375 return xp->unlock_list(xp, devices);
376}
377
378/*!
379 * @copydoc xrt_prober::dump
380 *
381 * Helper function for @ref xrt_prober::dump.
382 *
383 * @public @memberof xrt_prober
384 */
385XRT_NONNULL_ALL static inline int
386xrt_prober_dump(struct xrt_prober *xp, bool use_stdout)
387{
388 return xp->dump(xp, use_stdout);
389}
390
391/*!
392 * @copydoc xrt_prober::create_system
393 *
394 * Helper function for @ref xrt_prober::create_system.
395 *
396 * @public @memberof xrt_prober
397 */
398XRT_NONNULL_ALL static inline xrt_result_t
400 struct xrt_session_event_sink *broadcast,
401 struct xrt_system_devices **out_xsysd,
402 struct xrt_space_overseer **out_xso)
403{
404 return xp->create_system(xp, broadcast, out_xsysd, out_xso);
405}
406
407/*!
408 * @copydoc xrt_prober::select
409 *
410 * Helper function for @ref xrt_prober::select.
411 *
412 * @public @memberof xrt_prober
413 */
414XRT_NONNULL_ALL static inline int
415xrt_prober_select(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
416{
417 return xp->select(xp, xdevs, xdev_capacity);
418}
419
420/*!
421 * @copydoc xrt_prober::open_hid_interface
422 *
423 * Helper function for @ref xrt_prober::open_hid_interface.
424 *
425 * @public @memberof xrt_prober
426 */
427XRT_NONNULL_ALL static inline int
429 struct xrt_prober_device *xpdev,
430 int iface,
431 struct os_hid_device **out_hid_dev)
432{
433 return xp->open_hid_interface(xp, xpdev, iface, out_hid_dev);
434}
435
436/*!
437 * @copydoc xrt_prober::open_serial_device
438 *
439 * Helper function for @ref xrt_prober::open_serial_device.
440 *
441 * @public @memberof xrt_prober
442 */
443XRT_NONNULL_ALL static inline int
445 struct xrt_prober_device *xpdev,
446 const struct os_serial_parameters *parameters,
447 struct os_serial_device **out_serial_dev)
448{
449 return xp->open_serial_device(xp, xpdev, parameters, out_serial_dev);
450}
451
452/*!
453 * @copydoc xrt_prober::get_string_descriptor
454 *
455 * Helper function for @ref xrt_prober::get_string_descriptor.
456 *
457 * @public @memberof xrt_prober
458 */
459XRT_NONNULL_ALL static inline int
461 struct xrt_prober_device *xpdev,
462 enum xrt_prober_string which_string,
463 unsigned char *out_buffer,
464 size_t max_length)
465{
466 return xp->get_string_descriptor(xp, xpdev, which_string, out_buffer, max_length);
467}
468
469/*!
470 * @copydoc xrt_prober::can_open
471 *
472 * Helper function for @ref xrt_prober::can_open.
473 *
474 * @public @memberof xrt_prober
475 */
476XRT_NONNULL_ALL static inline bool
478{
479 return xp->can_open(xp, xpdev);
480}
481
482
483/*!
484 * @copydoc xrt_prober::open_video_device
485 *
486 * Helper function for @ref xrt_prober::xrt_prober_open_video_device.
487 *
488 * @public @memberof xrt_prober
489 */
490XRT_NONNULL_FIRST static inline int
492 struct xrt_prober_device *xpdev,
493 struct xrt_frame_context *xfctx,
494 struct xrt_fs **out_xfs)
495{
496 return xp->open_video_device(xp, xpdev, xfctx, out_xfs);
497}
498
499/*!
500 * @copydoc xrt_prober::list_video_devices
501 *
502 * Helper function for @ref xrt_prober::list_video_devices.
503 *
504 * @public @memberof xrt_prober
505 */
506static inline int
508{
509 return xp->list_video_devices(xp, cb, ptr);
510}
511
512/*!
513 * @copydoc xrt_prober::get_builders
514 *
515 * Helper function for @ref xrt_prober::get_builders.
516 *
517 * @public @memberof xrt_prober
518 */
519XRT_NONNULL_ALL static inline int
521 size_t *out_builder_count,
522 struct xrt_builder ***out_builders,
523 size_t *out_entry_count,
524 struct xrt_prober_entry ***out_entries,
525 struct xrt_auto_prober ***out_auto_probers)
526{
527 return xp->get_builders(xp, out_builder_count, out_builders, out_entry_count, out_entries, out_auto_probers);
528}
529
530/*!
531 * @copydoc xrt_prober::destroy
532 *
533 * Helper for calling through the function pointer: does a null check and sets
534 * xp_ptr to null if freed.
535 *
536 * @public @memberof xrt_prober
537 */
538XRT_NONNULL_ALL static inline void
540{
541 struct xrt_prober *xp = *xp_ptr;
542 if (xp == NULL) {
543 return;
544 }
545
546 xp->destroy(xp_ptr);
547 *xp_ptr = NULL;
548}
549
550
551/*
552 *
553 * Builder interface.
554 *
555 */
556
557/*!
558 * A estimate from a setter upper about how many devices they can open.
559 *
560 * @ingroup xrt_iface
561 */
563{
564 struct
565 {
566 bool head;
567 bool left;
568 bool right;
569 bool dof6;
570 uint32_t extra_device_count;
571 } certain, maybe;
572
573 /*!
574 * A setter upper defined priority, mostly for vive vs survive.
575 *
576 * 0 normal priority, positive value higher, negative lower.
577 */
578 int32_t priority;
579};
580
581/*!
582 * Function pointer type for creating a @ref xrt_builder.
583 *
584 * @ingroup xrt_iface
585 */
586typedef struct xrt_builder *(*xrt_builder_create_func_t)(void);
587
588/*!
589 * Sets up a collection of devices and builds a system, a setter upper.
590 *
591 * @ingroup xrt_iface
592 */
594{
595 //! Short identifier, like "vive", "north_star", "rgb_tracking".
596 const char *identifier;
597
598 //! "Localized" pretty name.
599 const char *name;
600
601 //! List of identifiers for drivers this setter-upper uses/supports.
602 const char **driver_identifiers;
603
604 //! Number of driver identifiers.
606
607 //! Should this builder be excluded from automatic discovery.
609
610 /*!
611 * From the devices found, estimate without opening the devices how
612 * good the system will be.
613 *
614 * @param[in] xb Builder self parameter.
615 * @param[in] xp Prober
616 * @param[in] config JSON config object if found for this setter upper.
617 * @param[out] out_estimate Estimate to be filled out.
618 *
619 * @note Code consuming this interface should use xrt_builder_estimate_system()
620 */
622 cJSON *config,
623 struct xrt_prober *xp,
624 struct xrt_builder_estimate *out_estimate);
625
626 /*!
627 * We are now committed to opening these devices.
628 *
629 * @param[in] xb Builder self parameter.
630 * @param[in] xp Prober
631 * @param[in] config JSON config object if found for this setter upper.
632 * @param[in] broadcast Event sink that broadcasts events to all sessions.
633 * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL.
634 * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL.
635 *
636 * @note Code consuming this interface should use xrt_builder_open_system()
637 */
639 cJSON *config,
640 struct xrt_prober *xp,
641 struct xrt_session_event_sink *broadcast,
642 struct xrt_system_devices **out_xsysd,
643 struct xrt_space_overseer **out_xso);
644
645 /*!
646 * Destroy this setter upper.
647 *
648 * @note Code consuming this interface should use xrt_builder_destroy()
649 */
650 void (*destroy)(struct xrt_builder *xb);
651};
652
653/*!
654 * @copydoc xrt_builder::estimate_system
655 *
656 * Helper function for @ref xrt_builder::estimate_system.
657 *
658 * @public @memberof xrt_builder
659 */
660XRT_NONNULL_ALL static inline xrt_result_t
662 cJSON *config,
663 struct xrt_prober *xp,
664 struct xrt_builder_estimate *out_estimate)
665{
666 return xb->estimate_system(xb, config, xp, out_estimate);
667}
668
669/*!
670 * @copydoc xrt_builder::open_system
671 *
672 * Helper function for @ref xrt_builder::open_system.
673 *
674 * @public @memberof xrt_builder
675 */
676XRT_NONNULL_ALL static inline xrt_result_t
678 cJSON *config,
679 struct xrt_prober *xp,
680 struct xrt_session_event_sink *broadcast,
681 struct xrt_system_devices **out_xsysd,
682 struct xrt_space_overseer **out_xso)
683{
684 return xb->open_system(xb, config, xp, broadcast, out_xsysd, out_xso);
685}
686
687/*!
688 * @copydoc xrt_builder::destroy
689 *
690 * Helper for calling through the function pointer: does a null check and sets
691 * xb_ptr to null if freed.
692 *
693 * @public @memberof xrt_builder
694 */
695XRT_NONNULL_ALL static inline void
697{
698 struct xrt_builder *xb = *xb_ptr;
699 if (xb == NULL) {
700 return;
701 }
702
703 xb->destroy(xb);
704 *xb_ptr = NULL;
705}
706
707
708/*
709 *
710 * Found device interface.
711 *
712 */
713
714/*!
715 * Function pointer type for a handler that gets called when a device matching vendor and product ID is detected.
716 *
717 * @param xp Prober
718 * @param devices The array of prober devices found by the prober.
719 * @param num_devices The number of elements in @p devices
720 * @param index Which element in the prober device array matches your query?
721 * @param attached_data
722 * @param out_xdevs An empty array of size @p XRT_MAX_DEVICES_PER_PROBE you may populate with @ref xrt_device
723 * instances.
724 *
725 * @return the number of elements of @p out_xdevs populated by this call.
726 */
727typedef int (*xrt_prober_found_func_t)(struct xrt_prober *xp,
728 struct xrt_prober_device **devices,
729 size_t num_devices,
730 size_t index,
731 cJSON *attached_data,
732 struct xrt_device **out_xdevs);
733
734/*!
735 * Entry for a single device.
736 *
737 * @ingroup xrt_iface
738 */
740{
741 /*!
742 * USB/Bluetooth vendor ID (VID) to filter on.
743 */
744 uint16_t vendor_id;
745
746 /*!
747 * USB/Bluetooth product ID (PID) to filter on.
748 */
749 uint16_t product_id;
750
751 /*!
752 * Handler that gets called when a device matching vendor and product ID is detected.
753 *
754 * @see xrt_prober_found_func_t
755 */
757
758 /*!
759 * A human-readable name for the device associated with this VID/PID.
760 */
761 const char *name;
762
763 /*!
764 * A human-readable name for the driver associated with this VID/PID.
765 *
766 * Separate because a single driver might handle multiple VID/PID entries.
767 */
768 const char *driver_name;
769};
770
771
772/*
773 *
774 * Auto prober.
775 *
776 */
777
778/*!
779 * Function pointer type for creating a auto prober.
780 *
781 * @ingroup xrt_iface
782 */
783typedef struct xrt_auto_prober *(*xrt_auto_prober_create_func_t)(void);
784
785/*!
786 * @interface xrt_auto_prober
787 *
788 * An interface to be exposed by a device driver that should probe for the
789 * existence of its own device on the system, rather than using shared probers
790 * with vendor/product IDs, etc.
791 *
792 * @ingroup xrt_iface
793 */
795{
796 const char *name;
797
798 /*!
799 * Do the internal probing that the driver needs to do to find
800 * devices.
801 *
802 * @param xap Self pointer
803 * @param attached_data JSON "attached data" for this device from
804 * config, if any.
805 * @param[in] no_hmds If true, do not probe for HMDs, only other
806 * devices.
807 * @param[in] xp Prober: provided to use the tracking factory,
808 * among other reasons.
809 * @param[out] out_xdevs Array of @ref XRT_MAX_DEVICES_PER_PROBE @c NULL
810 * @ref xrt_device pointers. First elements will be populated with new
811 * devices.
812 *
813 * @return The number of devices written into @p out_xdevs, 0 if none.
814 *
815 * @note Leeloo Dallas is a reference to The Fifth Element.
816 */
818 cJSON *attached_data,
819 bool no_hmds,
820 struct xrt_prober *xp,
821 struct xrt_device **out_xdevs);
822 /*!
823 * Destroy this auto-prober.
824 *
825 * @param xap Self pointer
826 */
827 void (*destroy)(struct xrt_auto_prober *xap);
828};
829
830
831/*
832 *
833 * Prober creation.
834 *
835 */
836
837/*!
838 * Main root of all of the probing device.
839 *
840 * @ingroup xrt_iface
841 */
843{
844 /*!
845 * A null terminated list of @ref xrt_builder creation functions.
846 */
848
849 /*!
850 * A null terminated list of null terminated lists of
851 * @ref xrt_prober_entry.
852 */
854
855 /*!
856 * A null terminated list of @ref xrt_auto_prober creation functions.
857 */
859
860 /*!
861 * Lets you chain multiple prober entry lists.
862 */
864};
865
866/*!
867 * Create a prober with a list of known devices and autoprobers.
868 *
869 * Typically used by xrt_instance_create implementations to create the prober,
870 * often with a shared list called `target_list`.
871 *
872 * @param[out] out_xp Pointer to xrt_prober pointer, will be populated with
873 * created xrt_prober instance.
874 * @param[in] list Prober entry list
875 *
876 * @public @memberof xrt_prober
877 */
878XRT_NONNULL_ALL int
879xrt_prober_create_with_lists(struct xrt_prober **out_xp, struct xrt_prober_entry_lists *list);
880
881
882#ifdef __cplusplus
883}
884#endif
void(* xrt_prober_list_video_func_t)(struct xrt_prober *xp, struct xrt_prober_device *pdev, const char *product, const char *manufacturer, const char *serial, void *ptr)
Callback for listing video devices.
Definition xrt_prober.h:121
struct xrt_auto_prober *(* xrt_auto_prober_create_func_t)(void)
Function pointer type for creating a auto prober.
Definition xrt_prober.h:783
enum xrt_result xrt_result_t
Result type used across Monado.
struct xrt_builder *(* xrt_builder_create_func_t)(void)
Function pointer type for creating a xrt_builder.
Definition xrt_prober.h:586
Representing a single hid interface on a device.
Definition os_hid.h:29
Representing a single serial interface on a device.
Definition os_serial.h:33
Represents the parameters for opening a serial device, such as baud rate, parity, etc.
Definition os_serial.h:54
An interface to be exposed by a device driver that should probe for the existence of its own device o...
Definition xrt_prober.h:795
void(* destroy)(struct xrt_auto_prober *xap)
Destroy this auto-prober.
Definition xrt_prober.h:827
int(* lelo_dallas_autoprobe)(struct xrt_auto_prober *xap, cJSON *attached_data, bool no_hmds, struct xrt_prober *xp, struct xrt_device **out_xdevs)
Do the internal probing that the driver needs to do to find devices.
Definition xrt_prober.h:817
A estimate from a setter upper about how many devices they can open.
Definition xrt_prober.h:563
int32_t priority
A setter upper defined priority, mostly for vive vs survive.
Definition xrt_prober.h:578
Sets up a collection of devices and builds a system, a setter upper.
Definition xrt_prober.h:594
static XRT_NONNULL_ALL xrt_result_t xrt_builder_estimate_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_builder_estimate *out_estimate)
From the devices found, estimate without opening the devices how good the system will be.
Definition xrt_prober.h:661
const char ** driver_identifiers
List of identifiers for drivers this setter-upper uses/supports.
Definition xrt_prober.h:602
static XRT_NONNULL_ALL xrt_result_t xrt_builder_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
We are now committed to opening these devices.
Definition xrt_prober.h:677
static XRT_NONNULL_ALL void xrt_builder_destroy(struct xrt_builder **xb_ptr)
Destroy this setter upper.
Definition xrt_prober.h:696
xrt_result_t(* estimate_system)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_builder_estimate *out_estimate)
From the devices found, estimate without opening the devices how good the system will be.
Definition xrt_prober.h:621
void(* destroy)(struct xrt_builder *xb)
Destroy this setter upper.
Definition xrt_prober.h:650
bool exclude_from_automatic_discovery
Should this builder be excluded from automatic discovery.
Definition xrt_prober.h:608
const char * name
"Localized" pretty name.
Definition xrt_prober.h:599
xrt_result_t(* open_system)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
We are now committed to opening these devices.
Definition xrt_prober.h:638
size_t driver_identifier_count
Number of driver identifiers.
Definition xrt_prober.h:605
const char * identifier
Short identifier, like "vive", "north_star", "rgb_tracking".
Definition xrt_prober.h:596
A single HMD or input device.
Definition xrt_device.h:310
Object used to track all sinks and frame producers in a graph.
Definition xrt_frame.h:108
Frameserver that generates frames.
Definition xrt_frameserver.h:70
A probed device, may or may not be opened.
Definition xrt_prober.h:88
uint16_t product_id
USB/Bluetooth product ID (PID)
Definition xrt_prober.h:97
uint8_t usb_dev_class
USB device class.
Definition xrt_prober.h:107
uint16_t vendor_id
USB/Bluetooth vendor ID (VID)
Definition xrt_prober.h:92
enum xrt_bus_type bus
Device bus type.
Definition xrt_prober.h:102
Main root of all of the probing device.
Definition xrt_prober.h:843
struct xrt_prober_entry ** entries
A null terminated list of null terminated lists of xrt_prober_entry.
Definition xrt_prober.h:853
xrt_builder_create_func_t * builders
A null terminated list of xrt_builder creation functions.
Definition xrt_prober.h:847
struct xrt_prober_entry_lists * next
Lets you chain multiple prober entry lists.
Definition xrt_prober.h:863
xrt_auto_prober_create_func_t * auto_probers
A null terminated list of xrt_auto_prober creation functions.
Definition xrt_prober.h:858
Entry for a single device.
Definition xrt_prober.h:740
uint16_t product_id
USB/Bluetooth product ID (PID) to filter on.
Definition xrt_prober.h:749
xrt_prober_found_func_t found
Handler that gets called when a device matching vendor and product ID is detected.
Definition xrt_prober.h:756
uint16_t vendor_id
USB/Bluetooth vendor ID (VID) to filter on.
Definition xrt_prober.h:744
const char * driver_name
A human-readable name for the driver associated with this VID/PID.
Definition xrt_prober.h:768
const char * name
A human-readable name for the device associated with this VID/PID.
Definition xrt_prober.h:761
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition xrt_prober.h:135
xrt_result_t(* lock_list)(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
Locks the prober list of probed devices and returns it.
Definition xrt_prober.h:163
struct xrt_tracking_factory * tracking
Factory for producing tracked objects.
Definition xrt_prober.h:137
static XRT_NONNULL_ALL void xrt_prober_destroy(struct xrt_prober **xp_ptr)
Destroy the prober and set the pointer to null.
Definition xrt_prober.h:539
static XRT_NONNULL_ALL xrt_result_t xrt_prober_probe(struct xrt_prober *xp)
Enumerate all connected devices, whether or not we have an associated driver.
Definition xrt_prober.h:347
int(* select)(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
Iterate through drivers (by ID and auto-probers) checking to see if they can handle any connected dev...
Definition xrt_prober.h:228
static XRT_NONNULL_ALL int xrt_prober_select(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_capacity)
Iterate through drivers (by ID and auto-probers) checking to see if they can handle any connected dev...
Definition xrt_prober.h:415
static XRT_NONNULL_ALL bool xrt_prober_can_open(struct xrt_prober *xp, struct xrt_prober_device *xpdev)
Determine whether a prober device can be opened.
Definition xrt_prober.h:477
xrt_result_t(* unlock_list)(struct xrt_prober *xp, struct xrt_prober_device ***devices)
Unlocks the list, allowing for xrt_prober::probe to be called.
Definition xrt_prober.h:174
int(* open_video_device)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, struct xrt_frame_context *xfctx, struct xrt_fs **out_xfs)
Opens the selected video device and returns a xrt_fs, does not start it.
Definition xrt_prober.h:264
static XRT_NONNULL_FIRST int xrt_prober_open_video_device(struct xrt_prober *xp, struct xrt_prober_device *xpdev, struct xrt_frame_context *xfctx, struct xrt_fs **out_xfs)
Opens the selected video device and returns a xrt_fs, does not start it.
Definition xrt_prober.h:491
int(* open_hid_interface)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, int iface, struct os_hid_device **out_hid_dev)
Open a HID (Human Interface Device) interface using native HID support.
Definition xrt_prober.h:240
bool(* can_open)(struct xrt_prober *xp, struct xrt_prober_device *xpdev)
Determine whether a prober device can be opened.
Definition xrt_prober.h:327
int(* dump)(struct xrt_prober *xp, bool use_stdout)
Dump a listing of all devices found on the system to logging system or platform dependent output (std...
Definition xrt_prober.h:185
static XRT_NONNULL_ALL int xrt_prober_get_string_descriptor(struct xrt_prober *xp, struct xrt_prober_device *xpdev, enum xrt_prober_string which_string, unsigned char *out_buffer, size_t max_length)
Returns a string property on the device of the given type which_string in out_buffer.
Definition xrt_prober.h:460
static XRT_NONNULL_ALL xrt_result_t xrt_prober_lock_list(struct xrt_prober *xp, struct xrt_prober_device ***out_devices, size_t *out_device_count)
Locks the prober list of probed devices and returns it.
Definition xrt_prober.h:360
int(* get_string_descriptor)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, enum xrt_prober_string which_string, unsigned char *out_buffer, size_t max_length)
Returns a string property on the device of the given type which_string in out_buffer.
Definition xrt_prober.h:313
static XRT_NONNULL_ALL int xrt_prober_open_serial_device(struct xrt_prober *xp, struct xrt_prober_device *xpdev, const struct os_serial_parameters *parameters, struct os_serial_device **out_serial_dev)
Open a serial device using native serial support.
Definition xrt_prober.h:444
int(* get_builders)(struct xrt_prober *xp, size_t *out_builder_count, struct xrt_builder ***out_builders, size_t *out_entry_count, struct xrt_prober_entry ***out_entries, struct xrt_auto_prober ***out_auto_probers)
Retrieve the raw xrt_builder, xrt_prober_entry and xrt_auto_prober arrays.
Definition xrt_prober.h:293
int(* list_video_devices)(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr)
Iterate through available video devices, calling your callback cb with your userdata ptr.
Definition xrt_prober.h:279
static XRT_NONNULL_ALL int xrt_prober_dump(struct xrt_prober *xp, bool use_stdout)
Dump a listing of all devices found on the system to logging system or platform dependent output (std...
Definition xrt_prober.h:386
static XRT_NONNULL_ALL xrt_result_t xrt_prober_unlock_list(struct xrt_prober *xp, struct xrt_prober_device ***devices)
Unlocks the list, allowing for xrt_prober::probe to be called.
Definition xrt_prober.h:373
xrt_result_t(* create_system)(struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
Create system devices.
Definition xrt_prober.h:197
static int xrt_prober_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr)
Iterate through available video devices, calling your callback cb with your userdata ptr.
Definition xrt_prober.h:507
xrt_result_t(* probe)(struct xrt_prober *xp)
Enumerate all connected devices, whether or not we have an associated driver.
Definition xrt_prober.h:153
int(* open_serial_device)(struct xrt_prober *xp, struct xrt_prober_device *xpdev, const struct os_serial_parameters *parameters, struct os_serial_device **out_serial_dev)
Open a serial device using native serial support.
Definition xrt_prober.h:255
static XRT_NONNULL_ALL int xrt_prober_open_hid_interface(struct xrt_prober *xp, struct xrt_prober_device *xpdev, int iface, struct os_hid_device **out_hid_dev)
Open a HID (Human Interface Device) interface using native HID support.
Definition xrt_prober.h:428
static XRT_NONNULL_ALL int xrt_prober_get_builders(struct xrt_prober *xp, size_t *out_builder_count, struct xrt_builder ***out_builders, size_t *out_entry_count, struct xrt_prober_entry ***out_entries, struct xrt_auto_prober ***out_auto_probers)
Retrieve the raw xrt_builder, xrt_prober_entry and xrt_auto_prober arrays.
Definition xrt_prober.h:520
static XRT_NONNULL_ALL xrt_result_t xrt_prober_create_system(struct xrt_prober *xp, struct xrt_session_event_sink *broadcast, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso)
Create system devices.
Definition xrt_prober.h:399
void(* destroy)(struct xrt_prober **xp_ptr)
Destroy the prober and set the pointer to null.
Definition xrt_prober.h:336
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition xrt_session.h:237
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:214
Tracking factory.
Definition xrt_tracking.h:94
Header defining an xrt display or controller device.
xrt_prober_string
String descriptor types.
Definition xrt_prober.h:76
xrt_bus_type
Bus type of a device.
Definition xrt_prober.h:66
int(* xrt_prober_found_func_t)(struct xrt_prober *xp, struct xrt_prober_device **devices, size_t num_devices, size_t index, cJSON *attached_data, struct xrt_device **out_xdevs)
Function pointer type for a handler that gets called when a device matching vendor and product ID is ...
Definition xrt_prober.h:727