From 7c807a8605fb8104599bb8c4c1ddab579e6f5aef Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 3 Nov 2020 19:03:06 +0000 Subject: [PATCH] xrt: Add device driver provided bindings --- doc/changes/xrt/mr.587.md | 4 +++ src/xrt/include/xrt/xrt_device.h | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 doc/changes/xrt/mr.587.md diff --git a/doc/changes/xrt/mr.587.md b/doc/changes/xrt/mr.587.md new file mode 100644 index 000000000..c1cfb3f51 --- /dev/null +++ b/doc/changes/xrt/mr.587.md @@ -0,0 +1,4 @@ +Add `xrt_binding_profile` struct, related pair structs and fields on +`xrt_device` to allow to move the static rebinding of inputs and outputs into +device drivers. This makes it easier to get a overview in the driver itself +which bindings it can bind to. diff --git a/src/xrt/include/xrt/xrt_device.h b/src/xrt/include/xrt/xrt_device.h index 087188b56..01e6a7b23 100644 --- a/src/xrt/include/xrt/xrt_device.h +++ b/src/xrt/include/xrt/xrt_device.h @@ -167,11 +167,56 @@ struct xrt_input union xrt_input_value value; }; +/*! + * A single named output, that sits on a @ref xrt_device. + * + * @ingroup xrt_iface + */ struct xrt_output { enum xrt_output_name name; }; + +/*! + * A binding pair, going @p from a binding point to a @p device input. + * + * @ingroup xrt_iface + */ +struct xrt_binding_input_pair +{ + enum xrt_input_name from; //!< From which name. + enum xrt_input_name device; //!< To input on the device. +}; + +/*! + * A binding pair, going @p from a binding point to a @p device output. + * + * @ingroup xrt_iface + */ +struct xrt_binding_output_pair +{ + enum xrt_output_name from; //!< From which name. + enum xrt_output_name device; //!< To output on the device. +}; + +/*! + * A binding profile, has lists of binding pairs to goes from device in @p name + * to the device it hangs off on. + * + * @ingroup xrt_iface + */ +struct xrt_binding_profile +{ + //! Device this binding emulates. + enum xrt_device_name name; + + struct xrt_binding_input_pair *inputs; + size_t num_inputs; + struct xrt_binding_output_pair *outputs; + size_t num_outputs; +}; + /*! * @interface xrt_device * @@ -194,6 +239,11 @@ struct xrt_device //! Always set, pointing to the tracking system for this device. struct xrt_tracking_origin *tracking_origin; + //! Number of bindings. + size_t num_binding_profiles; + // Array of alternative binding profiles. + struct xrt_binding_profile *binding_profiles; + //! Number of inputs. size_t num_inputs; //! Array of input structs.