The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Refactor out common ipc_client_xdev

+58 -39
+28 -1
src/xrt/ipc/client/ipc_client.h
··· 1 - // Copyright 2020, Collabora, Ltd. 1 + // Copyright 2020-2023, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 62 62 enum u_logging_level log_level; 63 63 }; 64 64 65 + /*! 66 + * An IPC client proxy for an @ref xrt_device. 67 + * 68 + * @implements xrt_device 69 + * @ingroup ipc_client 70 + */ 71 + struct ipc_client_xdev 72 + { 73 + struct xrt_device base; 74 + 75 + struct ipc_connection *ipc_c; 76 + 77 + uint32_t device_id; 78 + }; 79 + 80 + 65 81 /* 66 82 * 67 83 * Internal functions. 68 84 * 69 85 */ 86 + 87 + /*! 88 + * Convenience helper to go from a xdev to @ref ipc_client_xdev. 89 + * 90 + * @ingroup ipc_client 91 + */ 92 + static inline struct ipc_client_xdev * 93 + ipc_client_xdev(struct xrt_device *xdev) 94 + { 95 + return (struct ipc_client_xdev *)xdev; 96 + } 70 97 71 98 /*! 72 99 * Create an IPC client system compositor.
+15 -19
src/xrt/ipc/client/ipc_client_device.c
··· 1 - // Copyright 2020, Collabora, Ltd. 1 + // Copyright 2020-2023, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 35 35 */ 36 36 37 37 /*! 38 - * An IPC client proxy for an @ref xrt_device. 39 - * @implements xrt_device 38 + * An IPC client proxy for an controller or other non-MHD @ref xrt_device and 39 + * @ref ipc_client_xdev. Using a typedef reduce impact of refactor change. 40 + * 41 + * @implements ipc_client_xdev 42 + * @ingroup ipc_client 40 43 */ 41 - struct ipc_client_device 42 - { 43 - struct xrt_device base; 44 - 45 - struct ipc_connection *ipc_c; 46 - 47 - uint32_t device_id; 48 - }; 44 + typedef struct ipc_client_xdev ipc_client_device_t; 49 45 50 46 51 47 /* ··· 54 50 * 55 51 */ 56 52 57 - static inline struct ipc_client_device * 53 + static inline ipc_client_device_t * 58 54 ipc_client_device(struct xrt_device *xdev) 59 55 { 60 - return (struct ipc_client_device *)xdev; 56 + return (ipc_client_device_t *)xdev; 61 57 } 62 58 63 59 static void 64 60 ipc_client_device_destroy(struct xrt_device *xdev) 65 61 { 66 - struct ipc_client_device *icd = ipc_client_device(xdev); 62 + ipc_client_device_t *icd = ipc_client_device(xdev); 67 63 68 64 // Remove the variable tracking. 69 65 u_var_remove_root(icd); ··· 79 75 static void 80 76 ipc_client_device_update_inputs(struct xrt_device *xdev) 81 77 { 82 - struct ipc_client_device *icd = ipc_client_device(xdev); 78 + ipc_client_device_t *icd = ipc_client_device(xdev); 83 79 84 80 xrt_result_t r = ipc_call_device_update_input(icd->ipc_c, icd->device_id); 85 81 if (r != XRT_SUCCESS) { ··· 93 89 uint64_t at_timestamp_ns, 94 90 struct xrt_space_relation *out_relation) 95 91 { 96 - struct ipc_client_device *icd = ipc_client_device(xdev); 92 + ipc_client_device_t *icd = ipc_client_device(xdev); 97 93 98 94 xrt_result_t r = 99 95 ipc_call_device_get_tracked_pose(icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_relation); ··· 109 105 struct xrt_hand_joint_set *out_value, 110 106 uint64_t *out_timestamp_ns) 111 107 { 112 - struct ipc_client_device *icd = ipc_client_device(xdev); 108 + ipc_client_device_t *icd = ipc_client_device(xdev); 113 109 114 110 xrt_result_t r = ipc_call_device_get_hand_tracking(icd->ipc_c, icd->device_id, name, at_timestamp_ns, out_value, 115 111 out_timestamp_ns); ··· 134 130 static void 135 131 ipc_client_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value) 136 132 { 137 - struct ipc_client_device *icd = ipc_client_device(xdev); 133 + ipc_client_device_t *icd = ipc_client_device(xdev); 138 134 139 135 xrt_result_t r = ipc_call_device_set_output(icd->ipc_c, icd->device_id, name, value); 140 136 if (r != XRT_SUCCESS) { ··· 154 150 155 151 // Allocate and setup the basics. 156 152 enum u_device_alloc_flags flags = (enum u_device_alloc_flags)(U_DEVICE_ALLOC_HMD); 157 - struct ipc_client_device *icd = U_DEVICE_ALLOCATE(struct ipc_client_device, flags, 0, 0); 153 + ipc_client_device_t *icd = U_DEVICE_ALLOCATE(ipc_client_device_t, flags, 0, 0); 158 154 icd->ipc_c = ipc_c; 159 155 icd->base.update_inputs = ipc_client_device_update_inputs; 160 156 icd->base.get_tracked_pose = ipc_client_device_get_tracked_pose;
+15 -19
src/xrt/ipc/client/ipc_client_hmd.c
··· 1 - // Copyright 2020, Collabora, Ltd. 1 + // Copyright 2020-2023, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file ··· 37 37 */ 38 38 39 39 /*! 40 - * An IPC client proxy for an HMD @ref xrt_device. 41 - * @implements xrt_device 40 + * An IPC client proxy for an HMD @ref xrt_device and @ref ipc_client_xdev. 41 + * Using a typedef reduce impact of refactor change. 42 + * 43 + * @implements ipc_client_xdev 44 + * @ingroup ipc_client 42 45 */ 43 - struct ipc_client_hmd 44 - { 45 - struct xrt_device base; 46 - 47 - struct ipc_connection *ipc_c; 48 - 49 - uint32_t device_id; 50 - }; 46 + typedef struct ipc_client_xdev ipc_client_hmd_t; 51 47 52 48 53 49 /* ··· 56 52 * 57 53 */ 58 54 59 - static inline struct ipc_client_hmd * 55 + static inline ipc_client_hmd_t * 60 56 ipc_client_hmd(struct xrt_device *xdev) 61 57 { 62 - return (struct ipc_client_hmd *)xdev; 58 + return (ipc_client_hmd_t *)xdev; 63 59 } 64 60 65 61 static void 66 62 ipc_client_hmd_destroy(struct xrt_device *xdev) 67 63 { 68 - struct ipc_client_hmd *ich = ipc_client_hmd(xdev); 64 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 69 65 70 66 // Remove the variable tracking. 71 67 u_var_remove_root(ich); ··· 81 77 static void 82 78 ipc_client_hmd_update_inputs(struct xrt_device *xdev) 83 79 { 84 - struct ipc_client_hmd *ich = ipc_client_hmd(xdev); 80 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 85 81 86 82 xrt_result_t r = ipc_call_device_update_input(ich->ipc_c, ich->device_id); 87 83 if (r != XRT_SUCCESS) { ··· 95 91 uint64_t at_timestamp_ns, 96 92 struct xrt_space_relation *out_relation) 97 93 { 98 - struct ipc_client_hmd *ich = ipc_client_hmd(xdev); 94 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 99 95 100 96 xrt_result_t r = 101 97 ipc_call_device_get_tracked_pose(ich->ipc_c, ich->device_id, name, at_timestamp_ns, out_relation); ··· 113 109 struct xrt_fov *out_fovs, 114 110 struct xrt_pose *out_poses) 115 111 { 116 - struct ipc_client_hmd *ich = ipc_client_hmd(xdev); 112 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 117 113 118 114 struct ipc_info_get_view_poses_2 info = {0}; 119 115 ··· 142 138 static bool 143 139 ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor) 144 140 { 145 - struct ipc_client_hmd *ich = ipc_client_hmd(xdev); 141 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 146 142 bool available = false; 147 143 xrt_result_t r = ipc_call_device_is_form_factor_available(ich->ipc_c, ich->device_id, form_factor, &available); 148 144 if (r != XRT_SUCCESS) { ··· 163 159 164 160 165 161 enum u_device_alloc_flags flags = (enum u_device_alloc_flags)(U_DEVICE_ALLOC_HMD); 166 - struct ipc_client_hmd *ich = U_DEVICE_ALLOCATE(struct ipc_client_hmd, flags, 0, 0); 162 + ipc_client_hmd_t *ich = U_DEVICE_ALLOCATE(ipc_client_hmd_t, flags, 0, 0); 167 163 ich->ipc_c = ipc_c; 168 164 ich->device_id = device_id; 169 165 ich->base.update_inputs = ipc_client_hmd_update_inputs;