From bff220b6f85111e6c326c6deafadf197130dcc30 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz <jakob@collabora.com> Date: Thu, 9 Mar 2023 15:51:25 +0000 Subject: [PATCH] ipc: Implement xrt_device::compute_distortion --- src/xrt/ipc/client/ipc_client_hmd.c | 24 ++++++++++++++++++++++++ src/xrt/ipc/server/ipc_server_handler.c | 19 +++++++++++++++++++ src/xrt/ipc/shared/proto.json | 13 +++++++++++++ 3 files changed, 56 insertions(+) diff --git a/src/xrt/ipc/client/ipc_client_hmd.c b/src/xrt/ipc/client/ipc_client_hmd.c index caa81a3c8..bfaba4256 100644 --- a/src/xrt/ipc/client/ipc_client_hmd.c +++ b/src/xrt/ipc/client/ipc_client_hmd.c @@ -135,6 +135,29 @@ ipc_client_hmd_get_view_poses(struct xrt_device *xdev, } } +static bool +ipc_client_hmd_compute_distortion( + struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result) +{ + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); + + bool ret; + xrt_result_t xret = ipc_call_device_compute_distortion( // + ich->ipc_c, // + ich->device_id, // + view, // + u, // + v, // + &ret, // + out_result); // + if (xret != XRT_SUCCESS) { + IPC_ERROR(ich->ipc_c, "Error calling compute distortion!"); + return false; + } + + return ret; +} + static bool ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor) { @@ -165,6 +188,7 @@ ipc_client_hmd_create(struct ipc_connection *ipc_c, struct xrt_tracking_origin * ich->base.update_inputs = ipc_client_hmd_update_inputs; ich->base.get_tracked_pose = ipc_client_hmd_get_tracked_pose; ich->base.get_view_poses = ipc_client_hmd_get_view_poses; + ich->base.compute_distortion = ipc_client_hmd_compute_distortion; ich->base.destroy = ipc_client_hmd_destroy; ich->base.is_form_factor_available = ipc_client_hmd_is_form_factor_available; diff --git a/src/xrt/ipc/server/ipc_server_handler.c b/src/xrt/ipc/server/ipc_server_handler.c index b869465cd..edca90ef2 100644 --- a/src/xrt/ipc/server/ipc_server_handler.c +++ b/src/xrt/ipc/server/ipc_server_handler.c @@ -1140,6 +1140,25 @@ ipc_handle_device_get_view_poses_2(volatile struct ipc_client_state *ics, return XRT_SUCCESS; } +xrt_result_t +ipc_handle_device_compute_distortion(volatile struct ipc_client_state *ics, + uint32_t id, + uint32_t view, + float u, + float v, + bool *out_ret, + struct xrt_uv_triplet *out_triplet) +{ + // To make the code a bit more readable. + uint32_t device_id = id; + struct xrt_device *xdev = get_xdev(ics, device_id); + + bool ret = xrt_device_compute_distortion(xdev, view, u, v, out_triplet); + *out_ret = ret; + + return XRT_SUCCESS; +} + xrt_result_t ipc_handle_device_set_output(volatile struct ipc_client_state *ics, uint32_t id, diff --git a/src/xrt/ipc/shared/proto.json b/src/xrt/ipc/shared/proto.json index a6dbf5de9..7f944fd0f 100644 --- a/src/xrt/ipc/shared/proto.json +++ b/src/xrt/ipc/shared/proto.json @@ -246,6 +246,19 @@ ] }, + "device_compute_distortion": { + "in": [ + {"name": "id", "type": "uint32_t"}, + {"name": "view", "type": "uint32_t"}, + {"name": "u", "type": "float"}, + {"name": "v", "type": "float"} + ], + "out": [ + {"name": "ret", "type": "bool"}, + {"name": "triplet", "type": "struct xrt_uv_triplet"} + ] + }, + "device_set_output": { "in": [ {"name": "id", "type": "uint32_t"},