2020-05-27 21:09:32 +00:00
|
|
|
// Copyright 2020, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Shared default implementation of the instance: pieces that are used
|
|
|
|
* whether or not there's a compositor.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "target_lists.h"
|
|
|
|
|
|
|
|
#include "xrt/xrt_prober.h"
|
|
|
|
#include "xrt/xrt_instance.h"
|
|
|
|
|
|
|
|
#include "util/u_misc.h"
|
2022-11-20 13:11:18 +00:00
|
|
|
#include "util/u_trace_marker.h"
|
2020-05-27 21:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Struct and helpers.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-06-03 16:43:30 +00:00
|
|
|
/*!
|
|
|
|
* Main "real" instance implementation.
|
|
|
|
*
|
2022-05-17 22:04:22 +00:00
|
|
|
* Used in instances both with and without compositor usage.
|
2020-06-03 16:43:30 +00:00
|
|
|
*
|
|
|
|
* @implements xrt_instance
|
|
|
|
*/
|
2020-05-27 21:09:32 +00:00
|
|
|
struct t_instance
|
|
|
|
{
|
|
|
|
struct xrt_instance base;
|
|
|
|
struct xrt_prober *xp;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct t_instance *
|
|
|
|
t_instance(struct xrt_instance *xinst)
|
|
|
|
{
|
|
|
|
return (struct t_instance *)xinst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Member functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-05-18 14:18:22 +00:00
|
|
|
static xrt_result_t
|
2020-05-27 21:09:32 +00:00
|
|
|
t_instance_get_prober(struct xrt_instance *xinst, struct xrt_prober **out_xp)
|
|
|
|
{
|
2022-11-20 13:11:18 +00:00
|
|
|
XRT_TRACE_MARKER();
|
|
|
|
|
2020-05-27 21:09:32 +00:00
|
|
|
struct t_instance *tinst = t_instance(xinst);
|
|
|
|
|
2022-05-18 14:18:22 +00:00
|
|
|
if (tinst->xp == NULL) {
|
|
|
|
return XRT_ERROR_PROBER_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2020-05-27 21:09:32 +00:00
|
|
|
*out_xp = tinst->xp;
|
|
|
|
|
2022-05-18 14:18:22 +00:00
|
|
|
return XRT_SUCCESS;
|
2020-05-27 21:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
t_instance_destroy(struct xrt_instance *xinst)
|
|
|
|
{
|
2022-11-20 13:11:18 +00:00
|
|
|
XRT_TRACE_MARKER();
|
|
|
|
|
2020-05-27 21:09:32 +00:00
|
|
|
struct t_instance *tinst = t_instance(xinst);
|
|
|
|
|
|
|
|
xrt_prober_destroy(&tinst->xp);
|
|
|
|
free(tinst);
|
|
|
|
}
|