mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
st/prober: Add remote loading
This commit is contained in:
parent
27abc58d51
commit
9440a9dd93
|
@ -177,6 +177,8 @@ parse_active(const char *str,
|
||||||
*out_active = P_ACTIVE_CONFIG_NONE;
|
*out_active = P_ACTIVE_CONFIG_NONE;
|
||||||
} else if (strcmp(str, "tracking") == 0) {
|
} else if (strcmp(str, "tracking") == 0) {
|
||||||
*out_active = P_ACTIVE_CONFIG_TRACKING;
|
*out_active = P_ACTIVE_CONFIG_TRACKING;
|
||||||
|
} else if (strcmp(str, "remote") == 0) {
|
||||||
|
*out_active = P_ACTIVE_CONFIG_REMOTE;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unknown active config '%s' from %s.\n", str,
|
fprintf(stderr, "Unknown active config '%s' from %s.\n", str,
|
||||||
from);
|
from);
|
||||||
|
@ -205,6 +207,35 @@ p_json_get_active(struct prober *p, enum p_active_config *out_active)
|
||||||
parse_active(tmp, "json", out_active);
|
parse_active(tmp, "json", out_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
p_json_get_remote_port(struct prober *p, int *out_port)
|
||||||
|
{
|
||||||
|
cJSON *t = cJSON_GetObjectItemCaseSensitive(p->json.root, "remote");
|
||||||
|
if (t == NULL) {
|
||||||
|
fprintf(stderr, "No remote node\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ver = -1;
|
||||||
|
if (!get_obj_int(t, "version", &ver)) {
|
||||||
|
fprintf(stderr, "Missing version tag!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ver >= 1) {
|
||||||
|
fprintf(stderr, "Unknown version tag '%i'!\n", ver);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int port = 0;
|
||||||
|
if (!get_obj_int(t, "port", &port)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_port = port;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
p_json_get_tracking_settings(struct prober *p, struct xrt_settings_tracking *s)
|
p_json_get_tracking_settings(struct prober *p, struct xrt_settings_tracking *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* @ingroup st_prober
|
* @ingroup st_prober
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "xrt/xrt_config_drivers.h"
|
||||||
|
|
||||||
#include "util/u_var.h"
|
#include "util/u_var.h"
|
||||||
#include "util/u_misc.h"
|
#include "util/u_misc.h"
|
||||||
#include "util/u_json.h"
|
#include "util/u_json.h"
|
||||||
|
@ -18,6 +20,10 @@
|
||||||
#include "v4l2/v4l2_interface.h"
|
#include "v4l2/v4l2_interface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XRT_BUILD_DRIVER_REMOTE
|
||||||
|
#include "remote/r_interface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -651,6 +657,27 @@ add_from_auto_probers(struct prober *p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_from_remote(struct prober *p,
|
||||||
|
struct xrt_device **xdevs,
|
||||||
|
size_t num_xdevs,
|
||||||
|
bool *have_hmd)
|
||||||
|
{
|
||||||
|
if (num_xdevs < 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XRT_BUILD_DRIVER_REMOTE
|
||||||
|
int port = 4242;
|
||||||
|
if (!p_json_get_remote_port(p, &port)) {
|
||||||
|
port = 4242;
|
||||||
|
}
|
||||||
|
|
||||||
|
r_create_devices(port, &xdevs[0], &xdevs[1], &xdevs[2]);
|
||||||
|
*have_hmd = xdevs[0] != NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
select_device(struct xrt_prober *xp,
|
select_device(struct xrt_prober *xp,
|
||||||
struct xrt_device **xdevs,
|
struct xrt_device **xdevs,
|
||||||
|
@ -668,6 +695,9 @@ select_device(struct xrt_prober *xp,
|
||||||
add_from_devices(p, xdevs, num_xdevs, &have_hmd);
|
add_from_devices(p, xdevs, num_xdevs, &have_hmd);
|
||||||
add_from_auto_probers(p, xdevs, num_xdevs, &have_hmd);
|
add_from_auto_probers(p, xdevs, num_xdevs, &have_hmd);
|
||||||
break;
|
break;
|
||||||
|
case P_ACTIVE_CONFIG_REMOTE:
|
||||||
|
add_from_remote(p, xdevs, num_xdevs, &have_hmd);
|
||||||
|
break;
|
||||||
default: assert(false);
|
default: assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ enum p_active_config
|
||||||
{
|
{
|
||||||
P_ACTIVE_CONFIG_NONE = 0,
|
P_ACTIVE_CONFIG_NONE = 0,
|
||||||
P_ACTIVE_CONFIG_TRACKING = 1,
|
P_ACTIVE_CONFIG_TRACKING = 1,
|
||||||
|
P_ACTIVE_CONFIG_REMOTE = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef XRT_OS_LINUX
|
#ifdef XRT_OS_LINUX
|
||||||
|
@ -220,6 +221,14 @@ p_json_get_active(struct prober *p, enum p_active_config *out_active);
|
||||||
bool
|
bool
|
||||||
p_json_get_tracking_settings(struct prober *p, struct xrt_settings_tracking *s);
|
p_json_get_tracking_settings(struct prober *p, struct xrt_settings_tracking *s);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Extract remote settings from the JSON.
|
||||||
|
*
|
||||||
|
* @public @memberof prober
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
p_json_get_remote_port(struct prober *p, int *out_port);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Dump the given device to stdout.
|
* Dump the given device to stdout.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue