genesys: usbhub: Add instance IDs for generic hub

1. add and set FuGenesysVendorSupportToolString.
2. customized instance IDs  with follow,
- "IC"
- "BONDING"
- "VENDOR" - mask code unsupported
- "PORTNUM"  - mask code unsupported
- "VENDORSUP"  - mask code unsupported
This commit is contained in:
adamgene 2022-03-30 16:57:45 +08:00 committed by Richard Hughes
parent 8f786b0818
commit acc9e9fbe7
2 changed files with 66 additions and 3 deletions

View File

@ -24,7 +24,13 @@ This plugin supports the following protocol IDs:
These devices use the standard USB DeviceInstanceId values for the USB Hub, e.g.
* `USB\VID_05E3&PID_0610`
* HP USB-C Controller: `USB\VID_03F0&PID_0610`
Additionally, some customized instance IDs are added. e.g.
* `USB\VID_03F0&PID_0610&IC_352330&BONDING_0F`
* `USB\VID_03F0&PID_0610&VENDOR_GENESYSLOGIC&IC_352330&BONDING_0F&PORTNUM_3233&VENDORSUP_C09B5DD3-1A23-51D2-995A-F7366AAB3CA4`
* HP M24fd USB-C Controller: `USB\VID_03F0&PID_0610&PUBKEY_B335BDCE-7073-5D0E-9BD3-9B69C1A6899F`
* HP M27fd USB-C Controller: `USB\VID_03F0&PID_0610&PUBKEY_847A3650-8648-586B-83C8-8B53714F37E3`
@ -45,6 +51,12 @@ USB Hub has a MStar Semiconductor Scaler attached via I²C.
Since 1.7.6.
### has-public-key
Device has a public-key appended to firmware.
Since 1.7.7
### GenesysUsbhubSwitchRequest
USB Hub Switch Request value.

View File

@ -132,6 +132,11 @@ typedef struct __attribute__((packed)) {
guint8 update_fw_time[12]; /* YYYYMMDDhhmm */
} FuGenesysFirmwareInfoToolString;
typedef struct __attribute__((packed)) {
guint8 version[2];
guint8 supports[29];
} FuGenesysVendorSupportToolString;
typedef struct {
guint8 req_switch;
guint8 req_read;
@ -143,6 +148,7 @@ struct _FuGenesysUsbhubDevice {
FuGenesysStaticToolString static_ts;
FuGenesysDynamicToolString dynamic_ts;
FuGenesysFirmwareInfoToolString fwinfo_ts;
FuGenesysVendorSupportToolString vs_ts;
FuGenesysVendorCommandSetting vcs;
FuGenesysChip chip;
guint32 running_bank;
@ -763,6 +769,7 @@ fu_genesys_usbhub_device_setup(FuDevice *device, GError **error)
g_autoptr(GError) error_local = NULL;
g_autoptr(GBytes) blob = NULL;
g_autofree guint8 *buf = NULL;
g_autofree gchar *ic_type = NULL;
/* FuUsbDevice->setup */
if (!FU_DEVICE_CLASS(fu_genesys_usbhub_device_parent_class)->setup(device, error)) {
@ -816,9 +823,8 @@ fu_genesys_usbhub_device_setup(FuDevice *device, GError **error)
} else if (memcmp(self->static_ts.mask_project_ic_type, "3590", 4) == 0) {
self->chip.model = ISP_MODEL_HUB_GL3590;
} else {
g_autofree gchar *ic_type =
fu_common_strsafe((const gchar *)&self->static_ts.mask_project_ic_type,
sizeof(self->static_ts.mask_project_ic_type));
ic_type = fu_common_strsafe((const gchar *)&self->static_ts.mask_project_ic_type,
sizeof(self->static_ts.mask_project_ic_type));
g_set_error(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
@ -889,6 +895,20 @@ fu_genesys_usbhub_device_setup(FuDevice *device, GError **error)
g_prefix_error(error, "failed to get vendor support info from device: ");
return FALSE;
}
if (!fu_genesys_usbhub_device_get_descriptor_data(
vendor_buf,
(guint8 *)&self->vs_ts,
sizeof(FuGenesysVendorSupportToolString),
error)) {
g_prefix_error(error, "failed to get vendor support info from device: ");
return FALSE;
}
if (g_getenv("FWUPD_GENESYS_USBHUB_VERBOSE") != NULL) {
fu_common_dump_raw(G_LOG_DOMAIN,
"Vendor support",
(guint8 *)&self->vs_ts,
sizeof(FuGenesysVendorSupportToolString));
}
}
if (fu_device_has_private_flag(device, FU_GENESYS_USBHUB_FLAG_HAS_PUBLIC_KEY)) {
@ -1056,6 +1076,37 @@ fu_genesys_usbhub_device_setup(FuDevice *device, GError **error)
fu_device_add_instance_strup(device, "PUBKEY", guid);
}
/* add specific product info */
ic_type = fu_common_strsafe((const gchar *)self->static_ts.mask_project_ic_type,
sizeof(self->static_ts.mask_project_ic_type));
fu_device_add_instance_str(device, "IC", ic_type);
fu_device_add_instance_u8(device, "BONDING", self->bonding);
if (self->running_bank != BANK_MASK_CODE) {
const gchar *vendor = fwupd_device_get_vendor(FWUPD_DEVICE(device));
guint16 port_num =
(self->dynamic_ts.ss_port_number << 8) + self->dynamic_ts.hs_port_number;
g_autofree gchar *guid = NULL;
guid = fwupd_guid_hash_data((const guint8 *)&self->vs_ts,
sizeof(self->vs_ts),
FWUPD_GUID_FLAG_NONE);
fu_device_add_instance_strup(device, "VENDOR", vendor);
fu_device_add_instance_u16(device, "PORTNUM", port_num);
fu_device_add_instance_strup(device, "VENDORSUP", guid);
}
fu_device_build_instance_id(device, NULL, "USB", "VID", "PID", "IC", "BONDING", NULL);
fu_device_build_instance_id(device,
NULL,
"USB",
"VID",
"PID",
"VENDOR",
"IC",
"BONDING",
"PORTNUM",
"VENDORSUP",
NULL);
fu_device_build_instance_id(device, NULL, "USB", "VID", "PID", "PUBKEY", NULL);
/* have MStar scaler */