mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
st/prober: Make sure the usb-product is always filled out
This commit is contained in:
parent
c021199b98
commit
798ef43342
|
@ -198,6 +198,30 @@ p_dev_get_bluetooth_dev(struct prober* p,
|
|||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
fill_out_product(struct prober* p, struct prober_device* pdev)
|
||||
{
|
||||
const char* bus =
|
||||
pdev->base.bus == XRT_BUS_TYPE_BLUETOOTH ? "bluetooth" : "usb";
|
||||
|
||||
char* str = NULL;
|
||||
int ret = 0;
|
||||
do {
|
||||
ret = snprintf(str, ret, "Unknown %s device: %04x:%04x", bus,
|
||||
pdev->base.vendor_id, pdev->base.product_id);
|
||||
if (ret <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (str == NULL) {
|
||||
str = U_CALLOC_WITH_CAST(char, ret + 1);
|
||||
} else {
|
||||
pdev->usb.product = str;
|
||||
return;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
static void
|
||||
add_device(struct prober* p, struct prober_device** out_dev)
|
||||
{
|
||||
|
@ -627,6 +651,10 @@ list_video_devices(struct xrt_prober* xp,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (pdev->usb.product == NULL) {
|
||||
fill_out_product(p, pdev);
|
||||
}
|
||||
|
||||
cb(xp, &pdev->base, pdev->usb.product, ptr);
|
||||
}
|
||||
|
||||
|
@ -656,6 +684,7 @@ get_string_descriptor(struct xrt_prober* xp,
|
|||
//! @todo make this unicode (utf-16)? utf-8 would be better...
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy(struct xrt_prober** xp)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue