spa/v4l2: better device product names on current kernels

udev/kernel sometimes give "Video Capture N" as ID_V4L_PRODUCT, which is
bogus as a device product name.  The ID_MODEL* field seem to always have
a sensible product name.

Get device.product.name always from ID_MODEL*, and use ID_V4L_PRODUCT
only as the last fallback.
This commit is contained in:
Pauli Virtanen 2022-01-23 01:39:13 +02:00 committed by Wim Taymans
parent e1bc1c4569
commit a67f38f790

View file

@ -311,20 +311,19 @@ static int emit_object_info(struct impl *this, struct device *device)
}
}
str = udev_device_get_property_value(dev, "ID_V4L_PRODUCT");
if (!(str && *str)) {
str = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE");
if (!(str && *str)) {
str = udev_device_get_property_value(dev, "ID_MODEL_ENC");
if (!(str && *str)) {
str = udev_device_get_property_value(dev, "ID_MODEL");
if (!(str && *str))
str = udev_device_get_property_value(dev, "ID_V4L_PRODUCT");
} else {
char *t = alloca(strlen(str) + 1);
unescape(str, t);
str = t;
}
}
}
if (str && *str)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_PRODUCT_NAME, str);