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#include "util/u_device.h"
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23
24struct ipc_connection;
25
26/*!
27 * An IPC client proxy for an @ref xrt_device.
28 *
29 * @implements xrt_device
30 * @ingroup ipc_client
31 */
32struct ipc_client_xdev
33{
34 struct xrt_device base;
35
36 struct ipc_connection *ipc_c;
37
38 uint32_t device_id;
39};
40
41/*!
42 * Convenience helper to go from a xdev to @ref ipc_client_xdev.
43 *
44 * @ingroup ipc_client
45 */
46static inline struct ipc_client_xdev *
47ipc_client_xdev(struct xrt_device *xdev)
48{
49 return (struct ipc_client_xdev *)xdev;
50}
51
52/*!
53 * Initializes a ipc_client_xdev so that it's basically fully usable as a
54 * @ref xrt_device object. Does not fill in the destroy function or the any
55 * if the HMD components / functions.
56 *
57 * @ingroup ipc_client
58 * @public @memberof ipc_client_xdev
59 */
60void
61ipc_client_xdev_init(struct ipc_client_xdev *icx,
62 struct ipc_connection *ipc_c,
63 struct xrt_tracking_origin *xtrack,
64 uint32_t device_id,
65 u_device_destroy_function_t destroy_fn);
66
67/*!
68 * Frees any memory that was allocated as part of init and resets some pointers.
69 *
70 * @ingroup ipc_client
71 * @public @memberof ipc_client_xdev
72 */
73void
74ipc_client_xdev_fini(struct ipc_client_xdev *icx);
75
76
77#ifdef __cplusplus
78}
79#endif