ipc: Implement display refresh rate functions

This commit is contained in:
Zhongwang Zhang 2023-04-18 14:25:51 +08:00 committed by Jakob Bornecrantz
parent df07128590
commit 74df016dbf
3 changed files with 59 additions and 0 deletions

View file

@ -792,6 +792,26 @@ ipc_compositor_set_thread_hint(struct xrt_compositor *xc, enum xrt_thread_hint h
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_set_thread_hint");
}
static xrt_result_t
ipc_compositor_get_display_refresh_rate(struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
xret = ipc_call_compositor_get_display_refresh_rate(icc->ipc_c, out_display_refresh_rate_hz);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_get_display_refresh_rate");
}
static xrt_result_t
ipc_compositor_request_display_refresh_rate(struct xrt_compositor *xc, float display_refresh_rate_hz)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
xret = ipc_call_compositor_request_display_refresh_rate(icc->ipc_c, display_refresh_rate_hz);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_request_display_refresh_rate");
}
static void
ipc_compositor_destroy(struct xrt_compositor *xc)
{
@ -839,6 +859,8 @@ ipc_compositor_init(struct ipc_client_compositor *icc, struct xrt_compositor_nat
icc->base.base.destroy = ipc_compositor_destroy;
icc->base.base.poll_events = ipc_compositor_poll_events;
icc->base.base.set_thread_hint = ipc_compositor_set_thread_hint;
icc->base.base.get_display_refresh_rate = ipc_compositor_get_display_refresh_rate;
icc->base.base.request_display_refresh_rate = ipc_compositor_request_display_refresh_rate;
// Using in wait frame.
os_precise_sleeper_init(&icc->sleeper);

View file

@ -556,6 +556,31 @@ ipc_handle_compositor_discard_frame(volatile struct ipc_client_state *ics, int64
return xrt_comp_discard_frame(ics->xc, frame_id);
}
xrt_result_t
ipc_handle_compositor_get_display_refresh_rate(volatile struct ipc_client_state *ics,
float *out_display_refresh_rate_hz)
{
IPC_TRACE_MARKER();
if (ics->xc == NULL) {
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
}
return xrt_comp_get_display_refresh_rate(ics->xc, out_display_refresh_rate_hz);
}
xrt_result_t
ipc_handle_compositor_request_display_refresh_rate(volatile struct ipc_client_state *ics, float display_refresh_rate_hz)
{
IPC_TRACE_MARKER();
if (ics->xc == NULL) {
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
}
return xrt_comp_request_display_refresh_rate(ics->xc, display_refresh_rate_hz);
}
static bool
_update_projection_layer(struct xrt_compositor *xc,
volatile struct ipc_client_state *ics,

View file

@ -203,6 +203,18 @@
]
},
"compositor_get_display_refresh_rate": {
"out": [
{"name": "out_display_refresh_rate_hz", "type": "float"}
]
},
"compositor_request_display_refresh_rate": {
"in": [
{"name": "display_refresh_rate_hz", "type": "float"}
]
},
"swapchain_get_properties": {
"in": [
{"name": "info", "type": "struct xrt_swapchain_create_info"}