xrt: Make it possible to get builders from prober

This commit is contained in:
Jakob Bornecrantz 2023-12-21 13:29:08 +00:00
parent 40eaf117c6
commit 32ce9f342f
3 changed files with 40 additions and 23 deletions

View file

@ -258,19 +258,23 @@ struct xrt_prober
int (*list_video_devices)(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr); int (*list_video_devices)(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr);
/*! /*!
* Retrieve the raw @ref xrt_prober_entry and @ref xrt_auto_prober arrays. * Retrieve the raw @ref xrt_builder, @ref xrt_prober_entry and @ref xrt_auto_prober arrays.
* *
* @param xp Pointer to self * @param xp Pointer to self
* @param[out] out_builder_count The size of @p out_builders
* @param[out] out_builders An array of builders.
* @param[out] out_entry_count The size of @p out_entries * @param[out] out_entry_count The size of @p out_entries
* @param[out] out_entries An array of prober entries * @param[out] out_entries An array of prober entries
* @param[out] out_auto_probers An array of up to @ref XRT_MAX_AUTO_PROBERS auto-probers * @param[out] out_auto_probers An array of up to @ref XRT_MAX_AUTO_PROBERS auto-probers
* *
* @return 0 on success, <0 on error. * @return 0 on success, <0 on error.
*/ */
int (*get_entries)(struct xrt_prober *xp, int (*get_builders)(struct xrt_prober *xp,
size_t *out_entry_count, size_t *out_builder_count,
struct xrt_prober_entry ***out_entries, struct xrt_builder ***out_builders,
struct xrt_auto_prober ***out_auto_probers); size_t *out_entry_count,
struct xrt_prober_entry ***out_entries,
struct xrt_auto_prober ***out_auto_probers);
/*! /*!
* Returns a string property on the device of the given type * Returns a string property on the device of the given type
@ -469,19 +473,21 @@ xrt_prober_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_
} }
/*! /*!
* @copydoc xrt_prober::get_entries * @copydoc xrt_prober::get_builders
* *
* Helper function for @ref xrt_prober::get_entries. * Helper function for @ref xrt_prober::get_builders.
* *
* @public @memberof xrt_prober * @public @memberof xrt_prober
*/ */
static inline int static inline int
xrt_prober_get_entries(struct xrt_prober *xp, xrt_prober_get_builders(struct xrt_prober *xp,
size_t *out_entry_count, size_t *out_builder_count,
struct xrt_prober_entry ***out_entries, struct xrt_builder ***out_builders,
struct xrt_auto_prober ***out_auto_probers) size_t *out_entry_count,
struct xrt_prober_entry ***out_entries,
struct xrt_auto_prober ***out_auto_probers)
{ {
return xp->get_entries(xp, out_entry_count, out_entries, out_auto_probers); return xp->get_builders(xp, out_builder_count, out_builders, out_entry_count, out_entries, out_auto_probers);
} }
/*! /*!

View file

@ -113,10 +113,12 @@ static int
p_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr); p_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, void *ptr);
static int static int
p_get_entries(struct xrt_prober *xp, p_get_builders(struct xrt_prober *xp,
size_t *out_num_entries, size_t *out_builder_count,
struct xrt_prober_entry ***out_entries, struct xrt_builder ***out_builders,
struct xrt_auto_prober ***out_auto_probers); size_t *out_num_entries,
struct xrt_prober_entry ***out_entries,
struct xrt_auto_prober ***out_auto_probers);
static int static int
p_get_string_descriptor(struct xrt_prober *xp, p_get_string_descriptor(struct xrt_prober *xp,
@ -442,7 +444,7 @@ initialize(struct prober *p, struct xrt_prober_entry_lists *lists)
p->base.open_hid_interface = p_open_hid_interface; p->base.open_hid_interface = p_open_hid_interface;
p->base.open_video_device = p_open_video_device; p->base.open_video_device = p_open_video_device;
p->base.list_video_devices = p_list_video_devices; p->base.list_video_devices = p_list_video_devices;
p->base.get_entries = p_get_entries; p->base.get_builders = p_get_builders;
p->base.get_string_descriptor = p_get_string_descriptor; p->base.get_string_descriptor = p_get_string_descriptor;
p->base.can_open = p_can_open; p->base.can_open = p_can_open;
p->base.destroy = p_destroy; p->base.destroy = p_destroy;
@ -1310,16 +1312,23 @@ p_list_video_devices(struct xrt_prober *xp, xrt_prober_list_video_func_t cb, voi
} }
static int static int
p_get_entries(struct xrt_prober *xp, p_get_builders(struct xrt_prober *xp,
size_t *out_num_entries, size_t *out_builder_count,
struct xrt_prober_entry ***out_entries, struct xrt_builder ***out_builders,
struct xrt_auto_prober ***out_auto_probers) size_t *out_entry_count,
struct xrt_prober_entry ***out_entries,
struct xrt_auto_prober ***out_auto_probers)
{ {
XRT_TRACE_MARKER(); XRT_TRACE_MARKER();
struct prober *p = (struct prober *)xp; struct prober *p = (struct prober *)xp;
*out_num_entries = p->num_entries;
*out_builder_count = p->builder_count;
*out_builders = p->builders;
*out_entry_count = p->num_entries;
*out_entries = p->entries; *out_entries = p->entries;
*out_auto_probers = p->auto_probers; *out_auto_probers = p->auto_probers;
return 0; return 0;

View file

@ -73,10 +73,12 @@ cli_cmd_probe(int argc, const char **argv)
return do_exit(&xi, -1); return do_exit(&xi, -1);
} }
size_t builder_count;
struct xrt_builder **builders;
size_t num_entries; size_t num_entries;
struct xrt_prober_entry **entries; struct xrt_prober_entry **entries;
struct xrt_auto_prober **auto_probers; struct xrt_auto_prober **auto_probers;
ret = xrt_prober_get_entries(xp, &num_entries, &entries, &auto_probers); ret = xrt_prober_get_builders(xp, &builder_count, &builders, &num_entries, &entries, &auto_probers);
if (ret != 0) { if (ret != 0) {
do_exit(&xi, ret); do_exit(&xi, ret);
} }