2020-04-11 00:28:35 +00:00
|
|
|
// Copyright 2020, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Common client side code.
|
|
|
|
* @author Pete Black <pblack@collabora.com>
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup ipc_client
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "xrt/xrt_compiler.h"
|
|
|
|
#include "ipc_protocol.h"
|
2020-07-07 22:56:40 +00:00
|
|
|
#include "ipc_utils.h"
|
2020-04-11 00:28:35 +00:00
|
|
|
|
2020-05-01 14:11:26 +00:00
|
|
|
#include "util/u_threading.h"
|
|
|
|
|
2020-04-11 00:28:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Logging
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Spew level logging.
|
|
|
|
*/
|
|
|
|
#define IPC_SPEW(c, ...) \
|
|
|
|
do { \
|
|
|
|
if ((c)->print_spew) { \
|
|
|
|
fprintf(stderr, "%s - ", __func__); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Debug level logging.
|
|
|
|
*/
|
|
|
|
#define IPC_DEBUG(c, ...) \
|
|
|
|
do { \
|
|
|
|
if ((c)->print_debug) { \
|
|
|
|
fprintf(stderr, "%s - ", __func__); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Error level logging.
|
|
|
|
*/
|
|
|
|
#define IPC_ERROR(c, ...) \
|
|
|
|
do { \
|
|
|
|
(void)(c)->print_debug; \
|
|
|
|
fprintf(stderr, "%s - ", __func__); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Structs
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-07-14 22:13:07 +00:00
|
|
|
struct xrt_compositor_native;
|
2020-04-11 00:28:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Connection.
|
|
|
|
*/
|
2020-07-07 17:24:52 +00:00
|
|
|
struct ipc_connection
|
2020-04-11 00:28:35 +00:00
|
|
|
{
|
2020-07-07 22:56:40 +00:00
|
|
|
struct ipc_message_channel imc;
|
2020-04-11 00:28:35 +00:00
|
|
|
|
|
|
|
struct ipc_shared_memory *ism;
|
2020-07-16 16:22:40 +00:00
|
|
|
xrt_shmem_handle_t ism_handle;
|
2020-04-11 00:28:35 +00:00
|
|
|
|
2020-05-01 14:11:26 +00:00
|
|
|
struct os_mutex mutex;
|
|
|
|
|
2020-04-11 00:28:35 +00:00
|
|
|
bool print_debug; // TODO: link to settings
|
|
|
|
bool print_spew; // TODO: link to settings
|
2020-07-07 17:24:52 +00:00
|
|
|
};
|
2020-04-11 00:28:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Internal functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2020-07-07 17:24:52 +00:00
|
|
|
ipc_client_compositor_create(struct ipc_connection *ipc_c,
|
2020-08-12 09:43:14 +00:00
|
|
|
struct xrt_image_native_allocator *xina,
|
2020-04-11 00:28:35 +00:00
|
|
|
struct xrt_device *xdev,
|
2020-07-14 22:13:07 +00:00
|
|
|
struct xrt_compositor_native **out_xcn);
|
2020-04-11 00:28:35 +00:00
|
|
|
|
|
|
|
struct xrt_device *
|
2020-07-07 17:24:52 +00:00
|
|
|
ipc_client_hmd_create(struct ipc_connection *ipc_c,
|
2020-05-07 15:24:14 +00:00
|
|
|
struct xrt_tracking_origin *xtrack,
|
|
|
|
uint32_t device_id);
|
2020-04-11 00:28:35 +00:00
|
|
|
|
|
|
|
struct xrt_device *
|
2020-07-07 17:24:52 +00:00
|
|
|
ipc_client_device_create(struct ipc_connection *ipc_c,
|
2020-05-07 15:24:14 +00:00
|
|
|
struct xrt_tracking_origin *xtrack,
|
|
|
|
uint32_t device_id);
|