2023-02-27 18:30:39 +00:00
|
|
|
// Copyright 2019-2023, Collabora, Ltd.
|
2019-10-25 17:34:18 +00:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Just does a probe.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
*/
|
|
|
|
|
2023-02-27 18:30:39 +00:00
|
|
|
#include "xrt/xrt_space.h"
|
2022-05-06 14:46:21 +00:00
|
|
|
#include "xrt/xrt_system.h"
|
2020-05-26 21:47:07 +00:00
|
|
|
#include "xrt/xrt_device.h"
|
2021-03-01 23:51:18 +00:00
|
|
|
#include "xrt/xrt_prober.h"
|
2023-02-27 18:30:39 +00:00
|
|
|
#include "xrt/xrt_instance.h"
|
|
|
|
#include "xrt/xrt_config_drivers.h"
|
|
|
|
|
2019-10-25 17:34:18 +00:00
|
|
|
#include "cli_common.h"
|
|
|
|
|
2023-02-27 18:30:39 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2019-10-25 17:34:18 +00:00
|
|
|
|
|
|
|
static int
|
2020-05-26 21:47:07 +00:00
|
|
|
do_exit(struct xrt_instance **xi_ptr, int ret)
|
2019-10-25 17:34:18 +00:00
|
|
|
{
|
2020-05-26 21:47:07 +00:00
|
|
|
xrt_instance_destroy(xi_ptr);
|
2019-10-25 17:34:18 +00:00
|
|
|
|
|
|
|
printf(" :: Exiting '%i'\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NUM_XDEVS 32
|
|
|
|
|
|
|
|
int
|
|
|
|
cli_cmd_probe(int argc, const char **argv)
|
|
|
|
{
|
2020-05-26 21:47:07 +00:00
|
|
|
struct xrt_instance *xi = NULL;
|
2022-05-06 14:46:21 +00:00
|
|
|
xrt_result_t xret = XRT_SUCCESS;
|
2019-10-25 17:34:18 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
// Initialize the prober.
|
|
|
|
printf(" :: Creating instance!\n");
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
ret = xrt_instance_create(NULL, &xi);
|
|
|
|
if (ret != 0) {
|
|
|
|
return do_exit(&xi, 0);
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
// Need to prime the prober with devices before dumping and listing.
|
2022-05-06 14:46:21 +00:00
|
|
|
printf(" :: Creating system devices!\n");
|
|
|
|
|
|
|
|
struct xrt_system_devices *xsysd = NULL;
|
2023-02-27 18:30:39 +00:00
|
|
|
struct xrt_space_overseer *xso = NULL;
|
2022-05-06 14:46:21 +00:00
|
|
|
xret = xrt_instance_create_system( //
|
|
|
|
xi, // Instance
|
|
|
|
&xsysd, // System devices.
|
2023-02-27 18:30:39 +00:00
|
|
|
&xso, // Space overseer.
|
2022-05-06 14:46:21 +00:00
|
|
|
NULL); // System compositor.
|
|
|
|
if (xret != XRT_SUCCESS) {
|
|
|
|
printf("\tCall to xrt_instance_create_system failed! '%i'\n", xret);
|
|
|
|
return do_exit(&xi, -1);
|
|
|
|
}
|
|
|
|
if (xsysd == NULL) {
|
|
|
|
printf("\tNo xrt_system_devices returned!\n");
|
|
|
|
return do_exit(&xi, -1);
|
2021-03-01 23:51:18 +00:00
|
|
|
}
|
2020-11-23 22:04:29 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
struct xrt_prober *xp = NULL;
|
2022-05-17 17:45:53 +00:00
|
|
|
xret = xrt_instance_get_prober(xi, &xp);
|
|
|
|
if (xret != XRT_SUCCESS) {
|
|
|
|
printf("\tNo xrt_prober could be created!\n");
|
|
|
|
return do_exit(&xi, -1);
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
size_t num_entries;
|
|
|
|
struct xrt_prober_entry **entries;
|
|
|
|
struct xrt_auto_prober **auto_probers;
|
|
|
|
ret = xrt_prober_get_entries(xp, &num_entries, &entries, &auto_probers);
|
|
|
|
if (ret != 0) {
|
|
|
|
do_exit(&xi, ret);
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
printf(" :: Regular built in drivers\n");
|
|
|
|
for (size_t i = 0; i < num_entries; i++) {
|
|
|
|
if (entries[i] == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
// devices with the same driver name are usually grouped, don't print duplicates
|
|
|
|
if (i > 0 && strcmp(entries[i - 1]->driver_name, entries[i]->driver_name) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
printf("\t%s\n", entries[i]->driver_name);
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-11-10 18:14:27 +00:00
|
|
|
for (size_t i = 0; i < XRT_MAX_AUTO_PROBERS; i++) {
|
2021-03-01 23:51:18 +00:00
|
|
|
if (auto_probers[i] == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
printf("\t%s\n", auto_probers[i]->name);
|
|
|
|
}
|
2020-10-25 21:59:06 +00:00
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
printf(" :: Additional built in drivers\n");
|
|
|
|
// special cased drivers that are not probed through prober entries/autoprobers
|
|
|
|
#ifdef XRT_BUILD_DRIVER_REMOTE
|
|
|
|
printf("\tRemote Debugging\n");
|
2020-10-25 21:59:06 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
#ifdef XRT_BUILD_DRIVER_V4L2
|
|
|
|
printf("\tv4l2\n");
|
2020-10-25 21:59:06 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
#ifdef XRT_BUILD_DRIVER_VF
|
|
|
|
printf("\tvf\n");
|
2020-12-29 23:44:57 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-01 23:51:18 +00:00
|
|
|
printf(" :: Destroying probed devices\n");
|
2019-10-25 17:34:18 +00:00
|
|
|
|
2023-02-27 18:30:39 +00:00
|
|
|
xrt_space_overseer_destroy(&xso);
|
2022-05-06 14:46:21 +00:00
|
|
|
xrt_system_devices_destroy(&xsysd);
|
2019-10-25 17:34:18 +00:00
|
|
|
|
|
|
|
// End of program
|
|
|
|
printf(" :: All ok, shutting down.\n");
|
|
|
|
|
|
|
|
// Finally done
|
2020-05-26 21:47:07 +00:00
|
|
|
return do_exit(&xi, 0);
|
2019-10-25 17:34:18 +00:00
|
|
|
}
|