mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa/v4l2: convdert udev's VID/PID from hex to decimal
udev's ID_MODEL_ID and ID_VENDOR_ID are inconsistent: always 4-digit hex but sound devices are prefixed with 0x, v4l devices are not. Depending on the actual ID, the value will look like decimal (1234) or hex (a234). pw-dump will then print those as either decimal integers (i.e. 0x1234 becomes decimal 1234) or double (i.e. a234 becomes 41524.00). Make this consistent by converting the string from hex do decimal where we get it.
This commit is contained in:
parent
5aa15d10e9
commit
65f5f2a6f8
2 changed files with 30 additions and 4 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include <spa/utils/keys.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/string.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
|
@ -324,7 +325,13 @@ static int emit_object_info(struct impl *this, struct device *device)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str);
|
||||
char *dec = alloca(6); /* 65535 is max */
|
||||
int32_t val;
|
||||
|
||||
if (spa_atoi32(str, &val, 16)) {
|
||||
snprintf(dec, 6, "%d", val);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec);
|
||||
}
|
||||
}
|
||||
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
|
||||
if (!(str && *str)) {
|
||||
|
|
@ -341,7 +348,13 @@ static int emit_object_info(struct impl *this, struct device *device)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str);
|
||||
char *dec = alloca(6); /* 65535 is max */
|
||||
int32_t val;
|
||||
|
||||
if (spa_atoi32(str, &val, 16)) {
|
||||
snprintf(dec, 6, "%d", val);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec);
|
||||
}
|
||||
}
|
||||
str = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE");
|
||||
if (!(str && *str)) {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <spa/utils/keys.h>
|
||||
#include <spa/utils/names.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/utils/string.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/monitor/device.h>
|
||||
|
|
@ -270,7 +271,13 @@ static int emit_object_info(struct impl *this, struct device *device)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_SUBSYSTEM, str);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(dev, "ID_VENDOR_ID")) && *str) {
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, str);
|
||||
char *dec = alloca(6); /* 65535 is max */
|
||||
int32_t val;
|
||||
|
||||
if (spa_atoi32(str, &val, 16)) {
|
||||
snprintf(dec, 6, "%d", val);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_ID, dec);
|
||||
}
|
||||
}
|
||||
str = udev_device_get_property_value(dev, "ID_VENDOR_FROM_DATABASE");
|
||||
if (!(str && *str)) {
|
||||
|
|
@ -287,7 +294,13 @@ static int emit_object_info(struct impl *this, struct device *device)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_VENDOR_NAME, str);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(dev, "ID_MODEL_ID")) && *str) {
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, str);
|
||||
char *dec = alloca(6); /* 65535 is max */
|
||||
int32_t val;
|
||||
|
||||
if (spa_atoi32(str, &val, 16)) {
|
||||
snprintf(dec, 6, "%d", val);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_ID, dec);
|
||||
}
|
||||
}
|
||||
|
||||
str = udev_device_get_property_value(dev, "ID_V4L_PRODUCT");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue