mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 08:47:39 +00:00
Add quirks to set common USB properties
The name, summary and icon are not strictly required for a USB device supporting both DFU interfaces, but having this extra data makes GNOME Software look much nicer. Using the quirks feature means we can merge in support for new devices after fwupd has been released for stable distros.
This commit is contained in:
parent
ca0bc0adf7
commit
4591bdacbf
@ -343,9 +343,38 @@ fu_plugin_open (FuPlugin *plugin, const gchar *filename, GError **error)
|
||||
void
|
||||
fu_plugin_device_add (FuPlugin *plugin, FuDevice *device)
|
||||
{
|
||||
FuPluginPrivate *priv = GET_PRIVATE (plugin);
|
||||
|
||||
g_return_if_fail (FU_IS_PLUGIN (plugin));
|
||||
g_return_if_fail (FU_IS_DEVICE (device));
|
||||
|
||||
/* merge any quirks */
|
||||
if (FU_IS_USB_DEVICE (device)) {
|
||||
GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (device));
|
||||
const gchar *tmp;
|
||||
|
||||
/* name */
|
||||
tmp = fu_quirks_lookup_by_usb_device (priv->quirks,
|
||||
FU_QUIRKS_USB_NAME,
|
||||
usb_device);
|
||||
if (tmp != NULL)
|
||||
fu_device_set_name (device, tmp);
|
||||
|
||||
/* summary */
|
||||
tmp = fu_quirks_lookup_by_usb_device (priv->quirks,
|
||||
FU_QUIRKS_USB_SUMMARY,
|
||||
usb_device);
|
||||
if (tmp != NULL)
|
||||
fu_device_set_summary (device, tmp);
|
||||
|
||||
/* icon */
|
||||
tmp = fu_quirks_lookup_by_usb_device (priv->quirks,
|
||||
FU_QUIRKS_USB_ICON,
|
||||
usb_device);
|
||||
if (tmp != NULL)
|
||||
fu_device_add_icon (device, tmp);
|
||||
}
|
||||
|
||||
g_debug ("emit added from %s: %s",
|
||||
fu_plugin_get_name (plugin),
|
||||
fu_device_get_id (device));
|
||||
|
@ -158,6 +158,39 @@ const gchar *fu_quirks_lookup_by_usb_device (FuQuirks *self,
|
||||
*/
|
||||
#define FU_QUIRKS_DFU_FORCE_VERSION "fwupd-dfu-force-version"
|
||||
|
||||
/**
|
||||
* FU_QUIRKS_USB_SUMMARY:
|
||||
* @key: the USB device ID, e.g. `USB\VID_0763&PID_2806`
|
||||
* @value: the USB device summary, e.g. `An open source display colorimeter`
|
||||
*
|
||||
* Sets a name for a specific hardware device.
|
||||
*
|
||||
* Since: 1.0.2
|
||||
*/
|
||||
#define FU_QUIRKS_USB_SUMMARY "fwupd-usb-summary"
|
||||
|
||||
/**
|
||||
* FU_QUIRKS_USB_ICON:
|
||||
* @key: the USB device ID, e.g. `USB\VID_0763&PID_2806`
|
||||
* @value: the USB device icon name, e.g. `media-removable`
|
||||
*
|
||||
* Adds an icon name for a specific hardware device.
|
||||
*
|
||||
* Since: 1.0.2
|
||||
*/
|
||||
#define FU_QUIRKS_USB_ICON "fwupd-usb-icon"
|
||||
|
||||
/**
|
||||
* FU_QUIRKS_USB_NAME:
|
||||
* @key: the USB device ID, e.g. `USB\VID_0763&PID_2806`
|
||||
* @value: the USB device name, e.g. `ColorHug`
|
||||
*
|
||||
* Sets a name for a specific hardware device.
|
||||
*
|
||||
* Since: 1.0.2
|
||||
*/
|
||||
#define FU_QUIRKS_USB_NAME "fwupd-usb-name"
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __FU_QUIRKS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user