From 882ab0812ffe672a1c4d5f27fe7cea7fd41cb41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Fri, 3 Jun 2022 13:23:14 +0200 Subject: [PATCH] genesys: scaler: Allow to specify Cfi This allows to specify the Cfi device via the GenesysScalerCfiFlashId quirk key. --- plugins/genesys/README.md | 9 +++++++++ plugins/genesys/fu-genesys-scaler-device.c | 14 +++++++++++++- plugins/genesys/genesys.quirk | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/genesys/README.md b/plugins/genesys/README.md index c48272c37..6654658e7 100644 --- a/plugins/genesys/README.md +++ b/plugins/genesys/README.md @@ -126,6 +126,15 @@ Scaler GPIO value. Since 1.7.6. +### GenesysScalerCfiFlashId + +CFI Flash Id. + +* HP M24fd USB-C Monitor: `0xC22016` +* HP M27fd USB-C Monitor: `0xC84016` + +Since 1.8.2. + ## Runtime Requirement The USB Hub devices and its attached Scaler require libgusb version [0.3.8][1] or later to be detected. diff --git a/plugins/genesys/fu-genesys-scaler-device.c b/plugins/genesys/fu-genesys-scaler-device.c index 9cfc7d513..e6f48d137 100644 --- a/plugins/genesys/fu-genesys-scaler-device.c +++ b/plugins/genesys/fu-genesys-scaler-device.c @@ -63,6 +63,7 @@ struct _FuGenesysScalerDevice { FuDevice parent_instance; guint8 level; FuGenesysPublicKey public_key; + guint32 cfi_flash_id; FuCfiDevice *cfi_device; FuGenesysVendorCommand vc; guint32 sector_size; @@ -1643,8 +1644,10 @@ fu_genesys_scaler_device_setup(FuDevice *device, GError **error) guint64 size; guint32 sector_size; guint32 page_size; + g_autofree gchar *flash_id = NULL; - self->cfi_device = fu_cfi_device_new(fu_device_get_context(FU_DEVICE(self)), "C84016"); + flash_id = g_strdup_printf("%06X", self->cfi_flash_id); + self->cfi_device = fu_cfi_device_new(fu_device_get_context(FU_DEVICE(self)), flash_id); if (!fu_device_setup(FU_DEVICE(self->cfi_device), error)) return FALSE; @@ -1915,6 +1918,7 @@ fu_genesys_scaler_device_to_string(FuDevice *device, guint idt, GString *str) fu_common_string_append_kx(str, idt, "GpioOutputRegister", self->gpio_out_reg); fu_common_string_append_kx(str, idt, "GpioEnableRegister", self->gpio_en_reg); fu_common_string_append_kx(str, idt, "GpioValue", self->gpio_val); + fu_common_string_append_kx(str, idt, "CfiFlashId", self->cfi_flash_id); } static gboolean @@ -1958,6 +1962,14 @@ fu_genesys_scaler_device_set_quirk_kv(FuDevice *device, /* success */ return TRUE; } + if (g_strcmp0(key, "GenesysScalerCfiFlashId") == 0) { + if (!fu_common_strtoull_full(value, &tmp, 0, 0x00ffffffU, error)) + return FALSE; + self->cfi_flash_id = tmp; + + /* success */ + return TRUE; + } /* failure */ g_set_error_literal(error, diff --git a/plugins/genesys/genesys.quirk b/plugins/genesys/genesys.quirk index fc7c44351..08bd1ff88 100644 --- a/plugins/genesys/genesys.quirk +++ b/plugins/genesys/genesys.quirk @@ -41,6 +41,7 @@ Flags = use-i2c-ch0 GenesysScalerGpioOutputRegister = 0x0426 GenesysScalerGpioEnableRegister = 0x0428 GenesysScalerGpioValue = 0x01 +GenesysScalerCfiFlashId = 0xC22016 [GENESYS_SCALER\MSTAR_TSUM_G&PUBKEY_847A3650-8648-586B-83C8-8B53714F37E3&PANELREV_RIM101] Name = HP M27fd USB-C Monitor @@ -48,3 +49,4 @@ Flags = use-i2c-ch0 GenesysScalerGpioOutputRegister = 0x0426 GenesysScalerGpioEnableRegister = 0x0428 GenesysScalerGpioValue = 0x01 +GenesysScalerCfiFlashId = 0xC84016