Commit 1f848147 authored by Ryan Pavlik's avatar Ryan Pavlik Committed by Jakob Bornecrantz

st/prober: Allow "found" functions called by prober to make more than one device.

parent a673a4d4
Pipeline #44239 passed with stages
in 46 seconds
......@@ -446,7 +446,7 @@ int
psmv_found(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t index,
struct xrt_device **out_xdev)
struct xrt_device **out_xdevs)
{
struct os_hid_device *hid = NULL;
int ret;
......@@ -506,6 +506,6 @@ psmv_found(struct xrt_prober *xp,
psmv_read_hid(psmv);
// And finally done
*out_xdev = &psmv->base;
return 0;
*out_xdevs = &psmv->base;
return 1;
}
......@@ -33,7 +33,7 @@ int
psmv_found(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t index,
struct xrt_device **out_xdev);
struct xrt_device **out_xdevs);
/*!
* @dir drivers/psmv
......
......@@ -27,6 +27,14 @@ extern "C" {
struct xrt_prober;
struct xrt_prober_device;
/*!
* The maximum number of devices that a single "found" function called by the
* prober can create per-call.
*
* @ingroup xrt_iface
*/
#define XRT_MAX_DEVICES_PER_PROBE 16
/*!
* Entry for a single device.
*
......@@ -40,7 +48,7 @@ struct xrt_prober_entry
int (*found)(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t index,
struct xrt_device **out_xdev);
struct xrt_device **out_xdevs);
const char *name;
};
......
......@@ -444,14 +444,28 @@ select_device(struct xrt_prober* xp,
continue;
}
struct xrt_device* xdev = NULL;
entry->found(xp, dev_list, i, &xdev);
struct xrt_device*
new_xdevs[XRT_MAX_DEVICES_PER_PROBE] = {NULL};
int num_found =
entry->found(xp, dev_list, i, &(new_xdevs[0]));
if (xdev == NULL) {
if (num_found <= 0) {
continue;
}
handle_found_device(p, xdevs, num_xdevs, xdev);
for (int created_idx = 0; created_idx < num_found;
++created_idx) {
if (new_xdevs[created_idx] == NULL) {
P_DEBUG(
p,
"Leaving device creation loop "
"early: found function reported %i "
"created, but only %i non-null",
num_found, created_idx);
continue;
}
handle_found_device(p, xdevs, num_xdevs,
new_xdevs[created_idx]);
}
}
}
......
......@@ -34,11 +34,13 @@
* - `struct xrt_prober *xp`
* - `struct xrt_prober_device **devices`
* - `size_t index`
* - `struct xrt_device **out_xdev`
* - `struct xrt_device **out_xdevs` (an array of XRT_MAX_DEVICES_PER_PROBE
* xrt_device pointers)
*
* It is called when devices[index] match the VID and PID in the list.
* It should return 0 if it decides not to create any devices, or 1 if it
* creates one: it should assign *out_xdev to the created device.
* It should return 0 if it decides not to create any devices, negative on
* error, and the number of devices created if it creates one or more: it should
* assign sequential elements of out_xdevs to the created devices.
*/
struct xrt_prober_entry target_entry_list[] = {
#ifdef XRT_BUILD_PSVR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment