mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Remove product_name from xrt_prober_device struct
And move it to an internal struct instead. Better to keep it internal to the prober as it was only used for the bluetooth probing. And there was a function that applications should use to get strings from xrt_prober_device.
This commit is contained in:
parent
363132f424
commit
bab4a126ae
|
@ -328,6 +328,18 @@ pssense_found(struct xrt_prober *xp,
|
|||
return -1;
|
||||
}
|
||||
|
||||
unsigned char product_name[128];
|
||||
ret = xrt_prober_get_string_descriptor( //
|
||||
xp, //
|
||||
devices[index], //
|
||||
XRT_PROBER_STRING_PRODUCT, //
|
||||
product_name, //
|
||||
sizeof(product_name)); //
|
||||
if (ret != 0) {
|
||||
U_LOG_E("Failed to get product name from Bluetooth device!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
enum u_device_alloc_flags flags = U_DEVICE_ALLOC_TRACKING_NONE;
|
||||
struct pssense_device *pssense = U_DEVICE_ALLOCATE(struct pssense_device, flags, 13, 1);
|
||||
|
||||
|
@ -335,7 +347,7 @@ pssense_found(struct xrt_prober *xp,
|
|||
pssense->base.destroy = pssense_device_destroy;
|
||||
pssense->base.update_inputs = pssense_device_update_inputs;
|
||||
pssense->base.name = XRT_DEVICE_PSSENSE;
|
||||
snprintf(pssense->base.str, XRT_DEVICE_NAME_LEN, "%s", devices[index]->product_name);
|
||||
snprintf(pssense->base.str, XRT_DEVICE_NAME_LEN, "%s", product_name);
|
||||
|
||||
pssense->log_level = debug_get_log_option_pssense_log();
|
||||
pssense->hid = hid;
|
||||
|
|
|
@ -380,7 +380,7 @@ wmr_create_bt_controller(struct xrt_prober *xp,
|
|||
return XRT_ERROR_DEVICE_CREATION_FAILED;
|
||||
}
|
||||
|
||||
char product_name[XRT_DEVICE_PRODUCT_NAME_LEN] = {0};
|
||||
char product_name[256] = {0};
|
||||
int ret = xrt_prober_get_string_descriptor( //
|
||||
xp, //
|
||||
xpdev, //
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define XRT_DEVICE_NAME_LEN 256
|
||||
#define XRT_DEVICE_PRODUCT_NAME_LEN 64 // Incl. termination
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct xrt_tracking;
|
||||
|
||||
#define XRT_DEVICE_NAME_LEN 256
|
||||
|
||||
|
||||
/*!
|
||||
* A per-lens/display view information.
|
||||
|
|
|
@ -91,7 +91,6 @@ struct xrt_prober_device
|
|||
* USB/Bluetooth product ID (PID)
|
||||
*/
|
||||
uint16_t product_id;
|
||||
char product_name[XRT_DEVICE_PRODUCT_NAME_LEN];
|
||||
|
||||
/*!
|
||||
* Device bus type
|
||||
|
|
|
@ -194,8 +194,12 @@ p_dev_get_usb_dev(struct prober *p,
|
|||
}
|
||||
|
||||
int
|
||||
p_dev_get_bluetooth_dev(
|
||||
struct prober *p, uint64_t id, uint16_t vendor_id, uint16_t product_id, struct prober_device **out_pdev)
|
||||
p_dev_get_bluetooth_dev(struct prober *p,
|
||||
uint64_t id,
|
||||
uint16_t vendor_id,
|
||||
uint16_t product_id,
|
||||
const char *product_name,
|
||||
struct prober_device **out_pdev)
|
||||
{
|
||||
struct prober_device *pdev;
|
||||
|
||||
|
@ -225,6 +229,7 @@ p_dev_get_bluetooth_dev(
|
|||
pdev->base.product_id = product_id;
|
||||
pdev->base.bus = XRT_BUS_TYPE_BLUETOOTH;
|
||||
pdev->bluetooth.id = id;
|
||||
snprintf(pdev->bluetooth.product, ARRAY_SIZE(pdev->bluetooth.product), "%s", product_name);
|
||||
|
||||
*out_pdev = pdev;
|
||||
|
||||
|
@ -246,13 +251,8 @@ fill_out_product(struct prober *p, struct prober_device *pdev)
|
|||
char *str = NULL;
|
||||
int ret = 0;
|
||||
do {
|
||||
if (strlen(pdev->base.product_name)) {
|
||||
|
||||
ret = snprintf(str, ret, "%s device: %s", bus, pdev->base.product_name);
|
||||
} else {
|
||||
ret = snprintf(str, ret, "Unknown %s device: %04x:%04x", bus, pdev->base.vendor_id,
|
||||
pdev->base.product_id);
|
||||
}
|
||||
ret = snprintf(str, ret, "Unknown %s device: %04x:%04x", bus, pdev->base.vendor_id,
|
||||
pdev->base.product_id);
|
||||
if (ret <= 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -1342,7 +1342,7 @@ p_get_string_descriptor(struct xrt_prober *xp,
|
|||
u.arr[3], u.arr[2], u.arr[1], u.arr[0]);
|
||||
}; break;
|
||||
case XRT_PROBER_STRING_PRODUCT:
|
||||
ret = snprintf((char *)buffer, max_length, "%s", pdev->base.product_name);
|
||||
ret = snprintf((char *)buffer, max_length, "%s", pdev->bluetooth.product);
|
||||
break;
|
||||
default: ret = 0; break;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define P_PROBER_BLUETOOTH_PRODUCT_COUNT 64
|
||||
|
||||
#define P_TRACE(d, ...) U_LOG_IFL_T(d->log_level, __VA_ARGS__)
|
||||
#define P_DEBUG(d, ...) U_LOG_IFL_D(d->log_level, __VA_ARGS__)
|
||||
#define P_INFO(d, ...) U_LOG_IFL_I(d->log_level, __VA_ARGS__)
|
||||
|
@ -93,6 +95,8 @@ struct prober_device
|
|||
struct
|
||||
{
|
||||
uint64_t id;
|
||||
|
||||
char product[P_PROBER_BLUETOOTH_PRODUCT_COUNT];
|
||||
} bluetooth;
|
||||
|
||||
#ifdef XRT_HAVE_LIBUVC
|
||||
|
@ -207,8 +211,12 @@ p_dev_get_usb_dev(struct prober *p,
|
|||
* @public @memberof prober
|
||||
*/
|
||||
int
|
||||
p_dev_get_bluetooth_dev(
|
||||
struct prober *p, uint64_t id, uint16_t vendor_id, uint16_t product_id, struct prober_device **out_pdev);
|
||||
p_dev_get_bluetooth_dev(struct prober *p,
|
||||
uint64_t id,
|
||||
uint16_t vendor_id,
|
||||
uint16_t product_id,
|
||||
const char *product_name,
|
||||
struct prober_device **out_pdev);
|
||||
|
||||
/*!
|
||||
* @name Tracking systems
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "p_prober.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <libudev.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -55,7 +56,7 @@ static void
|
|||
p_udev_enumerate_hidraw(struct prober *p, struct udev *udev);
|
||||
|
||||
static void
|
||||
p_udev_add_hidraw(struct prober_device *pdev, uint32_t interface, const char *path, const char *product_name);
|
||||
p_udev_add_hidraw(struct prober_device *pdev, uint32_t interface, const char *path);
|
||||
|
||||
static int
|
||||
p_udev_get_interface_number(struct udev_device *raw_dev, uint16_t *interface_number);
|
||||
|
@ -65,7 +66,7 @@ p_udev_get_and_parse_uevent(struct udev_device *raw_dev,
|
|||
uint32_t *out_bus_type,
|
||||
uint16_t *out_vendor_id,
|
||||
uint16_t *out_product_id,
|
||||
char (*out_product_name)[XRT_DEVICE_PRODUCT_NAME_LEN],
|
||||
char (*out_product_name)[P_PROBER_BLUETOOTH_PRODUCT_COUNT],
|
||||
uint64_t *out_bluetooth_serial);
|
||||
|
||||
static int
|
||||
|
@ -394,7 +395,7 @@ p_udev_enumerate_hidraw(struct prober *p, struct udev *udev)
|
|||
uint16_t usb_addr = 0;
|
||||
uint32_t bus_type = 0;
|
||||
uint64_t bluetooth_id = 0;
|
||||
char product_name[XRT_DEVICE_PRODUCT_NAME_LEN] = {0};
|
||||
char product_name[P_PROBER_BLUETOOTH_PRODUCT_COUNT] = {0};
|
||||
const char *sysfs_path;
|
||||
const char *dev_path;
|
||||
int ret;
|
||||
|
@ -439,7 +440,7 @@ p_udev_enumerate_hidraw(struct prober *p, struct udev *udev)
|
|||
}
|
||||
|
||||
if (bus_type == HIDRAW_BUS_BLUETOOTH) {
|
||||
ret = p_dev_get_bluetooth_dev(p, bluetooth_id, vendor_id, product_id, &pdev);
|
||||
ret = p_dev_get_bluetooth_dev(p, bluetooth_id, vendor_id, product_id, product_name, &pdev);
|
||||
} else if (bus_type == HIDRAW_BUS_USB) {
|
||||
ret = p_dev_get_usb_dev(p, usb_bus, usb_addr, vendor_id, product_id, &pdev);
|
||||
} else {
|
||||
|
@ -473,7 +474,7 @@ p_udev_enumerate_hidraw(struct prober *p, struct udev *udev)
|
|||
}
|
||||
|
||||
// Add this interface to the usb device.
|
||||
p_udev_add_hidraw(pdev, interface, dev_path, product_name);
|
||||
p_udev_add_hidraw(pdev, interface, dev_path);
|
||||
|
||||
next:
|
||||
udev_device_unref(raw_dev);
|
||||
|
@ -483,7 +484,7 @@ p_udev_enumerate_hidraw(struct prober *p, struct udev *udev)
|
|||
}
|
||||
|
||||
static void
|
||||
p_udev_add_hidraw(struct prober_device *pdev, uint32_t interface, const char *path, const char *product_name)
|
||||
p_udev_add_hidraw(struct prober_device *pdev, uint32_t interface, const char *path)
|
||||
{
|
||||
U_ARRAY_REALLOC_OR_FREE(pdev->hidraws, struct prober_hidraw, (pdev->num_hidraws + 1));
|
||||
|
||||
|
@ -492,7 +493,6 @@ p_udev_add_hidraw(struct prober_device *pdev, uint32_t interface, const char *pa
|
|||
|
||||
hidraw->interface = interface;
|
||||
hidraw->path = strdup(path);
|
||||
strncpy(pdev->base.product_name, product_name, 64);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -549,7 +549,7 @@ p_udev_get_and_parse_uevent(struct udev_device *raw_dev,
|
|||
uint32_t *out_bus_type,
|
||||
uint16_t *out_vendor_id,
|
||||
uint16_t *out_product_id,
|
||||
char (*out_product_name)[XRT_DEVICE_PRODUCT_NAME_LEN],
|
||||
char (*out_product_name)[P_PROBER_BLUETOOTH_PRODUCT_COUNT],
|
||||
uint64_t *out_bluetooth_serial)
|
||||
{
|
||||
struct udev_device *hid_dev;
|
||||
|
@ -565,6 +565,7 @@ p_udev_get_and_parse_uevent(struct udev_device *raw_dev,
|
|||
char *tmp;
|
||||
int ret;
|
||||
|
||||
|
||||
// Dig through and find the regular hid node.
|
||||
hid_dev = udev_device_get_parent_with_subsystem_devtype(raw_dev, "hid", NULL);
|
||||
if (hid_dev == NULL) {
|
||||
|
|
Loading…
Reference in a new issue