ipc/shared: Support sending graphics sync handles

This commit is contained in:
Jakob Bornecrantz 2020-12-18 14:52:11 +00:00
parent 1302b07d68
commit 84d4b6aaae
2 changed files with 104 additions and 0 deletions

View file

@ -329,3 +329,47 @@ ipc_send_handles_graphics_buffer(struct ipc_message_channel *imc,
#else
#error "Need port to transport these graphics buffers"
#endif
/*
*
* FD graphics sync functions.
*
*/
#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
xrt_result_t
ipc_receive_handles_graphics_sync(struct ipc_message_channel *imc,
void *out_data,
size_t size,
xrt_graphics_sync_handle_t *out_handles,
uint32_t num_handles)
{
//! @todo Temporary hack to send no handles.
if (num_handles == 0) {
return ipc_receive(imc, out_data, size);
} else {
return ipc_receive_fds(imc, out_data, size, out_handles,
num_handles);
}
}
xrt_result_t
ipc_send_handles_graphics_sync(struct ipc_message_channel *imc,
const void *data,
size_t size,
const xrt_graphics_sync_handle_t *handles,
uint32_t num_handles)
{
//! @todo Temporary hack to send no handles.
if (num_handles == 0) {
return ipc_send(imc, data, size);
} else {
return ipc_send_fds(imc, data, size, handles, num_handles);
}
}
#else
#error "Need port to transport these graphics buffers"
#endif

View file

@ -181,12 +181,14 @@ ipc_send_handles_shmem(struct ipc_message_channel *imc,
* @}
*/
/*!
* @name Graphics buffer handle utilities
* @brief Send/receive graphics buffer handles along with scalar/aggregate
* message data.
* @{
*/
/*!
* Receive a message along with a known number of graphics buffer handles over
* the IPC channel.
@ -234,6 +236,64 @@ ipc_send_handles_graphics_buffer(struct ipc_message_channel *imc,
size_t size,
const xrt_graphics_buffer_handle_t *handles,
uint32_t num_handles);
/*!
* @}
*/
/*!
* @name Graphics buffer handle utilities
* @brief Send/receive graphics buffer handles along with scalar/aggregate
* message data.
* @{
*/
/*!
* Receive a message along with a known number of graphics sync handles over
* the IPC channel.
*
* @param imc Message channel to use
* @param[out] out_data Pointer to the sync to fill with data. Must not be null.
* @param[in] size Maximum size to read, must be greater than 0
* @param[out] out_handles Array of graphics sync handles to populate. Must not
* be null.
* @param[in] num_handles Number of elements to receive into @p out_handles,
* must be greater than 0 and must match the value provided at the other end.
*
* @public @memberof ipc_message_channel
* @relatesalso xrt_graphics_sync_handle_t
*/
xrt_result_t
ipc_receive_handles_graphics_sync(struct ipc_message_channel *imc,
void *out_data,
size_t size,
xrt_graphics_sync_handle_t *out_handles,
uint32_t num_handles);
/*!
* Send a message along with native graphics sync handles over the IPC channel.
*
* @param imc Message channel to use
* @param[in] data Pointer to the data sync to send. Must not be null: use a
* filler message if necessary.
* @param[in] size Size of data pointed-to by @p data, must be greater than 0
* @param[out] handles Array of graphics sync handles to send. Must not be
* null.
* @param[in] num_handles Number of elements in @p handles, must be greater than
* 0. If this is variable, it must also be separately transmitted ahead of time,
* because the receiver must have the same value in its receive call.
*
* @public @memberof ipc_message_channel
* @relatesalso xrt_graphics_sync_handle_t
*/
xrt_result_t
ipc_send_handles_graphics_sync(struct ipc_message_channel *imc,
const void *data,
size_t size,
const xrt_graphics_sync_handle_t *handles,
uint32_t num_handles);
/*!
* @}
*/