The open source OpenXR runtime
1// Copyright 2020-2023, Collabora, Ltd.
2// Copyright 2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Shared functions for IPC client @ref xrt_device.
7 * @author Pete Black <pblack@collabora.com>
8 * @author Jakob Bornecrantz <jakob@collabora.com>
9 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
10 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
11 * @ingroup ipc_client
12 */
13
14#pragma once
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20
21struct ipc_connection;
22
23/*!
24 * An IPC client proxy for an @ref xrt_device.
25 *
26 * @implements xrt_device
27 * @ingroup ipc_client
28 */
29struct ipc_client_xdev
30{
31 struct xrt_device base;
32
33 struct ipc_connection *ipc_c;
34
35 uint32_t device_id;
36};
37
38/*!
39 * Convenience helper to go from a xdev to @ref ipc_client_xdev.
40 *
41 * @ingroup ipc_client
42 */
43static inline struct ipc_client_xdev *
44ipc_client_xdev(struct xrt_device *xdev)
45{
46 return (struct ipc_client_xdev *)xdev;
47}
48
49/*!
50 * Initializes a ipc_client_xdev so that it's basically fully usable as a
51 * @ref xrt_device object. Does not fill in the destroy function or the any
52 * if the HMD components / functions.
53 *
54 * @ingroup ipc_client
55 * @public @memberof ipc_client_xdev
56 */
57void
58ipc_client_xdev_init(struct ipc_client_xdev *icx,
59 struct ipc_connection *ipc_c,
60 struct xrt_tracking_origin *xtrack,
61 uint32_t device_id);
62
63/*!
64 * Frees any memory that was allocated as part of init and resets some pointers.
65 *
66 * @ingroup ipc_client
67 * @public @memberof ipc_client_xdev
68 */
69void
70ipc_client_xdev_fini(struct ipc_client_xdev *icx);
71
72
73#ifdef __cplusplus
74}
75#endif