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