Skip to content

Commit

Permalink
vli: Add support for the Realtek RTD21XX I²C protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsie committed Aug 17, 2020
1 parent 04afb39 commit 13b3343
Show file tree
Hide file tree
Showing 7 changed files with 586 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/vli/fu-vli-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ fu_vli_common_device_kind_to_string (FuVliDeviceKind device_kind)
return "MSP430";
if (device_kind == FU_VLI_DEVICE_KIND_PS186)
return "PS186";
if (device_kind == FU_VLI_DEVICE_KIND_RTD21XX)
return "RTD21XX";
return NULL;
}

Expand Down Expand Up @@ -150,6 +152,8 @@ fu_vli_common_device_kind_from_string (const gchar *device_kind)
return FU_VLI_DEVICE_KIND_MSP430;
if (g_strcmp0 (device_kind, "PS186") == 0)
return FU_VLI_DEVICE_KIND_PS186;
if (g_strcmp0 (device_kind, "RTD21XX") == 0)
return FU_VLI_DEVICE_KIND_RTD21XX;
return FU_VLI_DEVICE_KIND_UNKNOWN;
}

Expand Down
1 change: 1 addition & 0 deletions plugins/vli/fu-vli-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef enum {
FU_VLI_DEVICE_KIND_VL820Q8 = 0xb820,
FU_VLI_DEVICE_KIND_MSP430 = 0xf430, /* guessed */
FU_VLI_DEVICE_KIND_PS186 = 0xf186, /* guessed */
FU_VLI_DEVICE_KIND_RTD21XX = 0xff00, /* guessed */
} FuVliDeviceKind;

const gchar *fu_vli_common_device_kind_to_string (FuVliDeviceKind device_kind);
Expand Down
30 changes: 30 additions & 0 deletions plugins/vli/fu-vli-usbhub-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "fu-vli-usbhub-device.h"
#include "fu-vli-usbhub-firmware.h"
#include "fu-vli-usbhub-msp430-device.h"
#include "fu-vli-usbhub-rtd21xx-device.h"
#include "fu-vli-usbhub-pd-device.h"

struct _FuVliUsbhubDevice
Expand Down Expand Up @@ -563,6 +564,31 @@ fu_vli_usbhub_device_msp430_setup (FuVliUsbhubDevice *self, GError **error)
return TRUE;
}

static gboolean
fu_vli_usbhub_device_rtd21xx_setup (FuVliUsbhubDevice *self, GError **error)
{
g_autoptr(FuDevice) dev = NULL;
g_autoptr(GError) error_local = NULL;

/* add child */
dev = fu_vli_usbhub_rtd21xx_device_new (self);
if (!fu_device_probe (dev, error))
return FALSE;
if (!fu_device_setup (dev, &error_local)) {
if (g_error_matches (error_local,
FWUPD_ERROR,
FWUPD_ERROR_NOT_FOUND)) {
g_debug ("%s", error_local->message);
} else {
g_warning ("cannot create I²C device: %s",
error_local->message);
}
return TRUE;
}
fu_device_add_child (FU_DEVICE (self), dev);
return TRUE;
}

static gboolean
fu_vli_usbhub_device_setup (FuVliDevice *device, GError **error)
{
Expand Down Expand Up @@ -647,6 +673,10 @@ fu_vli_usbhub_device_setup (FuVliDevice *device, GError **error)
if (!fu_vli_usbhub_device_msp430_setup (self, error))
return FALSE;
}
if (fu_device_has_custom_flag (FU_DEVICE (self), "has-rtd21xx")) {
if (!fu_vli_usbhub_device_rtd21xx_setup (self, error))
return FALSE;
}

/* success */
return TRUE;
Expand Down
Loading

0 comments on commit 13b3343

Please sign in to comment.