diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index b030c01e9..10102dbd2 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -352,7 +352,7 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom %{_libdir}/fwupd-plugins-3/libfu_plugin_uefi.so %{_libdir}/fwupd-plugins-3/libfu_plugin_uefi_recovery.so %endif -%{_libdir}/fwupd-plugins-3/libfu_plugin_unifying.so +%{_libdir}/fwupd-plugins-3/libfu_plugin_logitech_hidpp.so %{_libdir}/fwupd-plugins-3/libfu_plugin_upower.so %{_libdir}/fwupd-plugins-3/libfu_plugin_vli_usbhub.so %{_libdir}/fwupd-plugins-3/libfu_plugin_wacom_raw.so diff --git a/data/installed-tests/hardware.py b/data/installed-tests/hardware.py index 2debb01ca..460292238 100755 --- a/data/installed-tests/hardware.py +++ b/data/installed-tests/hardware.py @@ -118,13 +118,13 @@ if __name__ == '__main__': test.add_file('0a29848de74d26348bc5a6e24fc9f03778eddf0e-hughski-colorhug2-2.0.7.cab', '2.0.7') tests.append(test) - # Logitech Unifying Receiver (RQR12) using 'unifying' + # Logitech Unifying Receiver (RQR12) using logitech_hidpp test = Test('UnifyingRQR12', '9d131a0c-a606-580f-8eda-80587250b8d6') test.add_file('6e5ab5961ec4c577bff198ebb465106e979cf686-Logitech-Unifying-RQR12.05_B0028.cab', 'RQR12.05_B0028') test.add_file('938fec082652c603a1cdafde7cd25d76baadc70d-Logitech-Unifying-RQR12.07_B0029.cab', 'RQR12.07_B0029') tests.append(test) - # Logitech Unifying Receiver (RQR24) using 'unifying' + # Logitech Unifying Receiver (RQR24) using logitech_hidpp test = Test('UnifyingRQR24', 'cc4cbfa9-bf9d-540b-b92b-172ce31013c1') test.add_file('82b90b2614a9a4d0aced1ab8a4a99e228c95585c-Logitech-Unifying-RQ024.03_B0027.cab', 'RQR24.03_B0027') test.add_file('4511b9b0d123bdbe8a2007233318ab215a59dfe6-Logitech-Unifying-RQR24.05_B0029.cab', 'RQR24.05_B0029') diff --git a/docs/libfwupd/libfwupd-docs.xml b/docs/libfwupd/libfwupd-docs.xml index 68ad43745..ec27ea641 100644 --- a/docs/libfwupd/libfwupd-docs.xml +++ b/docs/libfwupd/libfwupd-docs.xml @@ -412,8 +412,8 @@ fu_plugin_update_reload (FuPlugin *plugin, FuDevice *device, GError **error) set process-wide. This allows plugins to detect when they should output detailed debugging information that would normally be too verbose to keep in the journal. - For example, using --plugin-verbose=unifying would set - FWUPD_UNIFYING_VERBOSE=1. + For example, using --plugin-verbose=logitech_hidpp would set + FWUPD_LOGITECH_HID_VERBOSE=1. diff --git a/plugins/unifying/README.md b/plugins/logitech-hidpp/README.md similarity index 98% rename from plugins/unifying/README.md rename to plugins/logitech-hidpp/README.md index 8125a6adb..ad065aacd 100644 --- a/plugins/unifying/README.md +++ b/plugins/logitech-hidpp/README.md @@ -1,4 +1,4 @@ -Unifying Support +Logitech HID Support ================ Introduction diff --git a/plugins/unifying/data/dump.csv.gz b/plugins/logitech-hidpp/data/dump.csv.gz similarity index 100% rename from plugins/unifying/data/dump.csv.gz rename to plugins/logitech-hidpp/data/dump.csv.gz diff --git a/plugins/unifying/data/dump.tdc b/plugins/logitech-hidpp/data/dump.tdc similarity index 100% rename from plugins/unifying/data/dump.tdc rename to plugins/logitech-hidpp/data/dump.tdc diff --git a/plugins/unifying/data/lsusb-U0007-bootloader.txt b/plugins/logitech-hidpp/data/lsusb-U0007-bootloader.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0007-bootloader.txt rename to plugins/logitech-hidpp/data/lsusb-U0007-bootloader.txt diff --git a/plugins/unifying/data/lsusb-U0007.txt b/plugins/logitech-hidpp/data/lsusb-U0007.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0007.txt rename to plugins/logitech-hidpp/data/lsusb-U0007.txt diff --git a/plugins/unifying/data/lsusb-U0008-bootloader-old.txt b/plugins/logitech-hidpp/data/lsusb-U0008-bootloader-old.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0008-bootloader-old.txt rename to plugins/logitech-hidpp/data/lsusb-U0008-bootloader-old.txt diff --git a/plugins/unifying/data/lsusb-U0008-bootloader.txt b/plugins/logitech-hidpp/data/lsusb-U0008-bootloader.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0008-bootloader.txt rename to plugins/logitech-hidpp/data/lsusb-U0008-bootloader.txt diff --git a/plugins/unifying/data/lsusb-U0008-old.txt b/plugins/logitech-hidpp/data/lsusb-U0008-old.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0008-old.txt rename to plugins/logitech-hidpp/data/lsusb-U0008-old.txt diff --git a/plugins/unifying/data/lsusb-U0008.txt b/plugins/logitech-hidpp/data/lsusb-U0008.txt similarity index 100% rename from plugins/unifying/data/lsusb-U0008.txt rename to plugins/logitech-hidpp/data/lsusb-U0008.txt diff --git a/plugins/unifying/fu-unifying-bootloader-nordic.c b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.c similarity index 57% rename from plugins/unifying/fu-unifying-bootloader-nordic.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.c index bbf58b889..4ab02ad48 100644 --- a/plugins/unifying/fu-unifying-bootloader-nordic.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.c @@ -8,22 +8,22 @@ #include -#include "fu-unifying-common.h" -#include "fu-unifying-bootloader-nordic.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-bootloader-nordic.h" -struct _FuUnifyingBootloaderNordic +struct _FuLogitechHidPpBootloaderNordic { - FuUnifyingBootloader parent_instance; + FuLogitechHidPpBootloader parent_instance; }; -G_DEFINE_TYPE (FuUnifyingBootloaderNordic, fu_unifying_bootloader_nordic, FU_TYPE_UNIFYING_BOOTLOADER) +G_DEFINE_TYPE (FuLogitechHidPpBootloaderNordic, fu_logitech_hidpp_bootloader_nordic, FU_TYPE_UNIFYING_BOOTLOADER) static gchar * -fu_unifying_bootloader_nordic_get_hw_platform_id (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_nordic_get_hw_platform_id (FuLogitechHidPpBootloader *self, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_HW_PLATFORM_ID; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to get HW ID: "); return NULL; } @@ -31,42 +31,42 @@ fu_unifying_bootloader_nordic_get_hw_platform_id (FuUnifyingBootloader *self, GE } static gchar * -fu_unifying_bootloader_nordic_get_fw_version (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_nordic_get_fw_version (FuLogitechHidPpBootloader *self, GError **error) { guint16 micro; - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_FW_VERSION; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to get firmware version: "); return NULL; } /* RRRxx.yy_Bzzzz * 012345678901234*/ - micro = (guint16) fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; - micro += fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 12); - return fu_unifying_format_version ("RQR", - fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 3), - fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 6), - micro); + micro = (guint16) fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; + micro += fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 12); + return fu_logitech_hidpp_format_version ("RQR", + fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 3), + fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 6), + micro); } static gboolean -fu_unifying_bootloader_nordic_setup (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_nordic_setup (FuLogitechHidPpBootloader *self, GError **error) { g_autofree gchar *hw_platform_id = NULL; g_autofree gchar *version_fw = NULL; g_autoptr(GError) error_local = NULL; /* get MCU */ - hw_platform_id = fu_unifying_bootloader_nordic_get_hw_platform_id (self, error); + hw_platform_id = fu_logitech_hidpp_bootloader_nordic_get_hw_platform_id (self, error); if (hw_platform_id == NULL) return FALSE; g_debug ("hw-platform-id=%s", hw_platform_id); /* get firmware version, which is not fatal */ - version_fw = fu_unifying_bootloader_nordic_get_fw_version (self, &error_local); + version_fw = fu_logitech_hidpp_bootloader_nordic_get_fw_version (self, &error_local); if (version_fw == NULL) { g_warning ("failed to get firmware version: %s", error_local->message); @@ -81,16 +81,16 @@ fu_unifying_bootloader_nordic_setup (FuUnifyingBootloader *self, GError **error) } static gboolean -fu_unifying_bootloader_nordic_write_signature (FuUnifyingBootloader *self, +fu_logitech_hidpp_bootloader_nordic_write_signature (FuLogitechHidPpBootloader *self, guint16 addr, guint8 len, const guint8 *data, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new(); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new(); req->cmd = 0xC0; req->addr = addr; req->len = len; memcpy (req->data, data, req->len); - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to write sig @0x%02x: ", addr); return FALSE; } @@ -106,11 +106,11 @@ fu_unifying_bootloader_nordic_write_signature (FuUnifyingBootloader *self, } static gboolean -fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self, +fu_logitech_hidpp_bootloader_nordic_write (FuLogitechHidPpBootloader *self, guint16 addr, guint8 len, const guint8 *data, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_WRITE; req->addr = addr; req->len = len; @@ -123,7 +123,7 @@ fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self, return FALSE; } memcpy (req->data, data, req->len); - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to transfer fw @0x%02x: ", addr); return FALSE; } @@ -165,13 +165,13 @@ fu_unifying_bootloader_nordic_write (FuUnifyingBootloader *self, } static gboolean -fu_unifying_bootloader_nordic_erase (FuUnifyingBootloader *self, guint16 addr, GError **error) +fu_logitech_hidpp_bootloader_nordic_erase (FuLogitechHidPpBootloader *self, guint16 addr, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_ERASE_PAGE; req->addr = addr; req->len = 0x01; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to erase fw @0x%02x: ", addr); return FALSE; } @@ -195,13 +195,13 @@ fu_unifying_bootloader_nordic_erase (FuUnifyingBootloader *self, guint16 addr, G } static gboolean -fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, +fu_logitech_hidpp_bootloader_nordic_write_firmware (FuDevice *device, FuFirmware *firmware, FwupdInstallFlags flags, GError **error) { - FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); - const FuUnifyingBootloaderRequest *payload; + FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device); + const FuLogitechHidPpBootloaderRequest *payload; guint16 addr; g_autoptr(GBytes) fw = NULL; g_autoptr(GPtrArray) reqs = NULL; @@ -213,15 +213,15 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, /* erase firmware pages up to the bootloader */ fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE); - for (addr = fu_unifying_bootloader_get_addr_lo (self); - addr < fu_unifying_bootloader_get_addr_hi (self); - addr += fu_unifying_bootloader_get_blocksize (self)) { - if (!fu_unifying_bootloader_nordic_erase (self, addr, error)) + for (addr = fu_logitech_hidpp_bootloader_get_addr_lo (self); + addr < fu_logitech_hidpp_bootloader_get_addr_hi (self); + addr += fu_logitech_hidpp_bootloader_get_blocksize (self)) { + if (!fu_logitech_hidpp_bootloader_nordic_erase (self, addr, error)) return FALSE; } /* transfer payload */ - reqs = fu_unifying_bootloader_parse_requests (self, fw, error); + reqs = fu_logitech_hidpp_bootloader_parse_requests (self, fw, error); if (reqs == NULL) return FALSE; fu_device_set_status (device, FWUPD_STATUS_DEVICE_WRITE); @@ -230,17 +230,17 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, payload = g_ptr_array_index (reqs, i); if (payload->cmd == FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE) { - res = fu_unifying_bootloader_nordic_write_signature (self, - payload->addr, - payload->len, - payload->data, - error); + res = fu_logitech_hidpp_bootloader_nordic_write_signature (self, + payload->addr, + payload->len, + payload->data, + error); } else { - res = fu_unifying_bootloader_nordic_write (self, - payload->addr, - payload->len, - payload->data, - error); + res = fu_logitech_hidpp_bootloader_nordic_write (self, + payload->addr, + payload->len, + payload->data, + error); } if (!res) @@ -250,18 +250,18 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, /* send the first managed packet last, excluding the reset vector */ payload = g_ptr_array_index (reqs, 0); - if (!fu_unifying_bootloader_nordic_write (self, - payload->addr + 1, - payload->len - 1, - payload->data + 1, - error)) + if (!fu_logitech_hidpp_bootloader_nordic_write (self, + payload->addr + 1, + payload->len - 1, + payload->data + 1, + error)) return FALSE; - if (!fu_unifying_bootloader_nordic_write (self, - 0x0000, - 0x01, - payload->data, - error)) + if (!fu_logitech_hidpp_bootloader_nordic_write (self, + 0x0000, + 0x01, + payload->data, + error)) return FALSE; /* mark as complete */ @@ -272,15 +272,15 @@ fu_unifying_bootloader_nordic_write_firmware (FuDevice *device, } static void -fu_unifying_bootloader_nordic_class_init (FuUnifyingBootloaderNordicClass *klass) +fu_logitech_hidpp_bootloader_nordic_class_init (FuLogitechHidPpBootloaderNordicClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); - FuUnifyingBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); - klass_device->write_firmware = fu_unifying_bootloader_nordic_write_firmware; - klass_device_bootloader->setup = fu_unifying_bootloader_nordic_setup; + FuLogitechHidPpBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); + klass_device->write_firmware = fu_logitech_hidpp_bootloader_nordic_write_firmware; + klass_device_bootloader->setup = fu_logitech_hidpp_bootloader_nordic_setup; } static void -fu_unifying_bootloader_nordic_init (FuUnifyingBootloaderNordic *self) +fu_logitech_hidpp_bootloader_nordic_init (FuLogitechHidPpBootloaderNordic *self) { } diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.h b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.h new file mode 100644 index 000000000..554da7485 --- /dev/null +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-nordic.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2016-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include "fu-logitech-hidpp-bootloader.h" + +#define FU_TYPE_UNIFYING_BOOTLOADER_NORDIC (fu_logitech_hidpp_bootloader_nordic_get_type ()) +G_DECLARE_FINAL_TYPE (FuLogitechHidPpBootloaderNordic, fu_logitech_hidpp_bootloader_nordic, FU, UNIFYING_BOOTLOADER_NORDIC, FuLogitechHidPpBootloader) diff --git a/plugins/unifying/fu-unifying-bootloader-texas.c b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.c similarity index 66% rename from plugins/unifying/fu-unifying-bootloader-texas.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.c index a0e5c7d1b..da0a3050b 100644 --- a/plugins/unifying/fu-unifying-bootloader-texas.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.c @@ -8,24 +8,24 @@ #include -#include "fu-unifying-common.h" -#include "fu-unifying-bootloader-texas.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-bootloader-texas.h" -struct _FuUnifyingBootloaderTexas +struct _FuLogitechHidPpBootloaderTexas { - FuUnifyingBootloader parent_instance; + FuLogitechHidPpBootloader parent_instance; }; -G_DEFINE_TYPE (FuUnifyingBootloaderTexas, fu_unifying_bootloader_texas, FU_TYPE_UNIFYING_BOOTLOADER) +G_DEFINE_TYPE (FuLogitechHidPpBootloaderTexas, fu_logitech_hidpp_bootloader_texas, FU_TYPE_UNIFYING_BOOTLOADER) static gboolean -fu_unifying_bootloader_texas_erase_all (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_texas_erase_all (FuLogitechHidPpBootloader *self, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM; req->len = 0x01; /* magic number */ req->data[0] = 0x00; /* magic number */ - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to erase all pages: "); return FALSE; } @@ -33,13 +33,13 @@ fu_unifying_bootloader_texas_erase_all (FuUnifyingBootloader *self, GError **err } static gboolean -fu_unifying_bootloader_texas_compute_and_test_crc (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_texas_compute_and_test_crc (FuLogitechHidPpBootloader *self, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM; req->len = 0x01; /* magic number */ req->data[0] = 0x03; /* magic number */ - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to compute and test CRC: "); return FALSE; } @@ -54,14 +54,14 @@ fu_unifying_bootloader_texas_compute_and_test_crc (FuUnifyingBootloader *self, G } static gboolean -fu_unifying_bootloader_texas_flash_ram_buffer (FuUnifyingBootloader *self, guint16 addr, GError **error) +fu_logitech_hidpp_bootloader_texas_flash_ram_buffer (FuLogitechHidPpBootloader *self, guint16 addr, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM; req->addr = addr; req->len = 0x01; /* magic number */ req->data[0] = 0x01; /* magic number */ - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to flash ram buffer @%04x: ", addr); return FALSE; } @@ -93,14 +93,14 @@ fu_unifying_bootloader_texas_flash_ram_buffer (FuUnifyingBootloader *self, guint } static gboolean -fu_unifying_bootloader_texas_clear_ram_buffer (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_texas_clear_ram_buffer (FuLogitechHidPpBootloader *self, GError **error) { - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM; req->addr = 0x0000; req->len = 0x01; /* magic number */ req->data[0] = 0x02; /* magic number */ - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to clear ram buffer @%04x: ", req->addr); return FALSE; } @@ -108,16 +108,16 @@ fu_unifying_bootloader_texas_clear_ram_buffer (FuUnifyingBootloader *self, GErro } static gboolean -fu_unifying_bootloader_texas_write_firmware (FuDevice *device, +fu_logitech_hidpp_bootloader_texas_write_firmware (FuDevice *device, FuFirmware *firmware, FwupdInstallFlags flags, GError **error) { - FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); - const FuUnifyingBootloaderRequest *payload; + FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device); + const FuLogitechHidPpBootloaderRequest *payload; g_autoptr(GBytes) fw = NULL; g_autoptr(GPtrArray) reqs = NULL; - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); /* get default image */ fw = fu_firmware_get_image_default_bytes (firmware, error); @@ -125,17 +125,17 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device, return FALSE; /* transfer payload */ - reqs = fu_unifying_bootloader_parse_requests (self, fw, error); + reqs = fu_logitech_hidpp_bootloader_parse_requests (self, fw, error); if (reqs == NULL) return FALSE; /* erase all flash pages */ fu_device_set_status (device, FWUPD_STATUS_DEVICE_ERASE); - if (!fu_unifying_bootloader_texas_erase_all (self, error)) + if (!fu_logitech_hidpp_bootloader_texas_erase_all (self, error)) return FALSE; /* set existing RAM buffer to 0xff's */ - if (!fu_unifying_bootloader_texas_clear_ram_buffer (self, error)) + if (!fu_logitech_hidpp_bootloader_texas_clear_ram_buffer (self, error)) return FALSE; /* write to RAM buffer */ @@ -164,7 +164,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device, req->len = payload->len; memcpy (req->data, payload->data, payload->len); - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to write ram buffer @0x%02x: ", req->addr); @@ -193,7 +193,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device, guint16 addr_start = payload->addr - (7 * 0x10); g_debug ("addr flush @ 0x%04x for 0x%04x", payload->addr, addr_start); - if (!fu_unifying_bootloader_texas_flash_ram_buffer (self, + if (!fu_logitech_hidpp_bootloader_texas_flash_ram_buffer (self, addr_start, error)) { g_prefix_error (error, @@ -208,7 +208,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device, } /* check CRC */ - if (!fu_unifying_bootloader_texas_compute_and_test_crc (self, error)) + if (!fu_logitech_hidpp_bootloader_texas_compute_and_test_crc (self, error)) return FALSE; /* mark as complete */ @@ -219,7 +219,7 @@ fu_unifying_bootloader_texas_write_firmware (FuDevice *device, } static gboolean -fu_unifying_bootloader_texas_setup (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_texas_setup (FuLogitechHidPpBootloader *self, GError **error) { fu_device_set_version (FU_DEVICE (self), "RQR24.00_B0000", FWUPD_VERSION_FORMAT_PLAIN); @@ -227,15 +227,15 @@ fu_unifying_bootloader_texas_setup (FuUnifyingBootloader *self, GError **error) } static void -fu_unifying_bootloader_texas_class_init (FuUnifyingBootloaderTexasClass *klass) +fu_logitech_hidpp_bootloader_texas_class_init (FuLogitechHidPpBootloaderTexasClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); - FuUnifyingBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); - klass_device->write_firmware = fu_unifying_bootloader_texas_write_firmware; - klass_device_bootloader->setup = fu_unifying_bootloader_texas_setup; + FuLogitechHidPpBootloaderClass *klass_device_bootloader = FU_UNIFYING_BOOTLOADER_CLASS (klass); + klass_device->write_firmware = fu_logitech_hidpp_bootloader_texas_write_firmware; + klass_device_bootloader->setup = fu_logitech_hidpp_bootloader_texas_setup; } static void -fu_unifying_bootloader_texas_init (FuUnifyingBootloaderTexas *self) +fu_logitech_hidpp_bootloader_texas_init (FuLogitechHidPpBootloaderTexas *self) { } diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.h b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.h new file mode 100644 index 000000000..1326dbe7f --- /dev/null +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader-texas.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2016-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include "fu-logitech-hidpp-bootloader.h" + +#define FU_TYPE_UNIFYING_BOOTLOADER_TEXAS (fu_logitech_hidpp_bootloader_texas_get_type ()) +G_DECLARE_FINAL_TYPE (FuLogitechHidPpBootloaderTexas, fu_logitech_hidpp_bootloader_texas, FU, UNIFYING_BOOTLOADER_TEXAS, FuLogitechHidPpBootloader) diff --git a/plugins/unifying/fu-unifying-bootloader.c b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c similarity index 73% rename from plugins/unifying/fu-unifying-bootloader.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c index f17b8c07d..11a33bcf7 100644 --- a/plugins/unifying/fu-unifying-bootloader.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c @@ -9,43 +9,43 @@ #include #include "fu-firmware-common.h" -#include "fu-unifying-common.h" -#include "fu-unifying-bootloader.h" -#include "fu-unifying-hidpp.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-bootloader.h" +#include "fu-logitech-hidpp-hidpp.h" typedef struct { guint16 flash_addr_lo; guint16 flash_addr_hi; guint16 flash_blocksize; -} FuUnifyingBootloaderPrivate; +} FuLogitechHidPpBootloaderPrivate; #define FU_UNIFYING_DEVICE_EP1 0x81 #define FU_UNIFYING_DEVICE_EP3 0x83 -G_DEFINE_TYPE_WITH_PRIVATE (FuUnifyingBootloader, fu_unifying_bootloader, FU_TYPE_USB_DEVICE) +G_DEFINE_TYPE_WITH_PRIVATE (FuLogitechHidPpBootloader, fu_logitech_hidpp_bootloader, FU_TYPE_USB_DEVICE) -#define GET_PRIVATE(o) (fu_unifying_bootloader_get_instance_private (o)) +#define GET_PRIVATE(o) (fu_logitech_hidpp_bootloader_get_instance_private (o)) static void -fu_unifying_bootloader_to_string (FuDevice *device, guint idt, GString *str) +fu_logitech_hidpp_bootloader_to_string (FuDevice *device, guint idt, GString *str) { - FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); - FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); + FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device); + FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self); fu_common_string_append_kx (str, idt, "FlashAddrHigh", priv->flash_addr_hi); fu_common_string_append_kx (str, idt, "FlashAddrLow", priv->flash_addr_lo); fu_common_string_append_kx (str, idt, "FlashBlockSize", priv->flash_blocksize); } -FuUnifyingBootloaderRequest * -fu_unifying_bootloader_request_new (void) +FuLogitechHidPpBootloaderRequest * +fu_logitech_hidpp_bootloader_request_new (void) { - FuUnifyingBootloaderRequest *req = g_new0 (FuUnifyingBootloaderRequest, 1); + FuLogitechHidPpBootloaderRequest *req = g_new0 (FuLogitechHidPpBootloaderRequest, 1); return req; } GPtrArray * -fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, GError **error) +fu_logitech_hidpp_bootloader_parse_requests (FuLogitechHidPpBootloader *self, GBytes *fw, GError **error) { const gchar *tmp; g_auto(GStrv) lines = NULL; @@ -56,7 +56,7 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G tmp = g_bytes_get_data (fw, NULL); lines = g_strsplit_set (tmp, "\n\r", -1); for (guint i = 0; lines[i] != NULL; i++) { - g_autoptr(FuUnifyingBootloaderRequest) payload = NULL; + g_autoptr(FuLogitechHidPpBootloaderRequest) payload = NULL; guint8 rec_type = 0x00; guint16 offset = 0x0000; gboolean exit = FALSE; @@ -66,8 +66,8 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G if (strlen (tmp) < 5) continue; - payload = fu_unifying_bootloader_request_new (); - payload->len = fu_unifying_buffer_read_uint8 (tmp + 0x01); + payload = fu_logitech_hidpp_bootloader_request_new (); + payload->len = fu_logitech_hidpp_buffer_read_uint8 (tmp + 0x01); if (payload->len > 28) { g_set_error (error, G_IO_ERROR, @@ -79,7 +79,7 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G payload->addr = fu_firmware_strparse_uint16 (tmp + 0x03); payload->cmd = FU_UNIFYING_BOOTLOADER_CMD_WRITE_RAM_BUFFER; - rec_type = fu_unifying_buffer_read_uint8 (tmp + 0x07); + rec_type = fu_logitech_hidpp_buffer_read_uint8 (tmp + 0x07); switch (rec_type) { case 0x00: /* data */ @@ -134,7 +134,7 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G payload->len); return NULL; } - payload->data[j] = fu_unifying_buffer_read_uint8 (ptr); + payload->data[j] = fu_logitech_hidpp_buffer_read_uint8 (ptr); } /* no need to bound check signature addresses */ @@ -144,13 +144,13 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G } /* skip the bootloader */ - if (payload->addr > fu_unifying_bootloader_get_addr_hi (self)) { + if (payload->addr > fu_logitech_hidpp_bootloader_get_addr_hi (self)) { g_debug ("skipping write @ %04x", payload->addr); continue; } /* skip the header */ - if (payload->addr < fu_unifying_bootloader_get_addr_lo (self)) { + if (payload->addr < fu_logitech_hidpp_bootloader_get_addr_lo (self)) { g_debug ("skipping write @ %04x", payload->addr); continue; } @@ -176,36 +176,36 @@ fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, GBytes *fw, G } guint16 -fu_unifying_bootloader_get_addr_lo (FuUnifyingBootloader *self) +fu_logitech_hidpp_bootloader_get_addr_lo (FuLogitechHidPpBootloader *self) { - FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); + FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000); return priv->flash_addr_lo; } guint16 -fu_unifying_bootloader_get_addr_hi (FuUnifyingBootloader *self) +fu_logitech_hidpp_bootloader_get_addr_hi (FuLogitechHidPpBootloader *self) { - FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); + FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000); return priv->flash_addr_hi; } guint16 -fu_unifying_bootloader_get_blocksize (FuUnifyingBootloader *self) +fu_logitech_hidpp_bootloader_get_blocksize (FuLogitechHidPpBootloader *self) { - FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); + FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self); g_return_val_if_fail (FU_IS_UNIFYING_BOOTLOADER (self), 0x0000); return priv->flash_blocksize; } static gboolean -fu_unifying_bootloader_attach (FuDevice *device, GError **error) +fu_logitech_hidpp_bootloader_attach (FuDevice *device, GError **error) { - FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); req->cmd = FU_UNIFYING_BOOTLOADER_CMD_REBOOT; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to attach back to runtime: "); return FALSE; } @@ -214,26 +214,26 @@ fu_unifying_bootloader_attach (FuDevice *device, GError **error) } static gboolean -fu_unifying_bootloader_set_bl_version (FuUnifyingBootloader *self, GError **error) +fu_logitech_hidpp_bootloader_set_bl_version (FuLogitechHidPpBootloader *self, GError **error) { guint16 build; g_autofree gchar *version = NULL; - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); /* call into hardware */ req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_BL_VERSION; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to get firmware version: "); return FALSE; } /* BOTxx.yy_Bzzzz * 012345678901234 */ - build = (guint16) fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; - build += fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 12); - version = fu_unifying_format_version ("BOT", - fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 3), - fu_unifying_buffer_read_uint8 ((const gchar *) req->data + 6), + build = (guint16) fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 10) << 8; + build += fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 12); + version = fu_logitech_hidpp_format_version ("BOT", + fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 3), + fu_logitech_hidpp_buffer_read_uint8 ((const gchar *) req->data + 6), build); if (version == NULL) { g_prefix_error (error, "failed to format firmware version: "); @@ -244,7 +244,7 @@ fu_unifying_bootloader_set_bl_version (FuUnifyingBootloader *self, GError **erro } static gboolean -fu_unifying_bootloader_open (FuUsbDevice *device, GError **error) +fu_logitech_hidpp_bootloader_open (FuUsbDevice *device, GError **error) { GUsbDevice *usb_device = fu_usb_device_get_dev (device); const guint idx = 0x00; @@ -262,16 +262,16 @@ fu_unifying_bootloader_open (FuUsbDevice *device, GError **error) } static gboolean -fu_unifying_bootloader_setup (FuDevice *device, GError **error) +fu_logitech_hidpp_bootloader_setup (FuDevice *device, GError **error) { - FuUnifyingBootloaderClass *klass = FU_UNIFYING_BOOTLOADER_GET_CLASS (device); - FuUnifyingBootloader *self = FU_UNIFYING_BOOTLOADER (device); - FuUnifyingBootloaderPrivate *priv = GET_PRIVATE (self); - g_autoptr(FuUnifyingBootloaderRequest) req = fu_unifying_bootloader_request_new (); + FuLogitechHidPpBootloaderClass *klass = FU_UNIFYING_BOOTLOADER_GET_CLASS (device); + FuLogitechHidPpBootloader *self = FU_UNIFYING_BOOTLOADER (device); + FuLogitechHidPpBootloaderPrivate *priv = GET_PRIVATE (self); + g_autoptr(FuLogitechHidPpBootloaderRequest) req = fu_logitech_hidpp_bootloader_request_new (); /* get memory map */ req->cmd = FU_UNIFYING_BOOTLOADER_CMD_GET_MEMINFO; - if (!fu_unifying_bootloader_request (self, req, error)) { + if (!fu_logitech_hidpp_bootloader_request (self, req, error)) { g_prefix_error (error, "failed to get meminfo: "); return FALSE; } @@ -290,7 +290,7 @@ fu_unifying_bootloader_setup (FuDevice *device, GError **error) priv->flash_blocksize = fu_common_read_uint16 (req->data + 4, G_BIG_ENDIAN); /* get bootloader version */ - if (!fu_unifying_bootloader_set_bl_version (self, error)) + if (!fu_logitech_hidpp_bootloader_set_bl_version (self, error)) return FALSE; /* subclassed further */ @@ -302,7 +302,7 @@ fu_unifying_bootloader_setup (FuDevice *device, GError **error) } static gboolean -fu_unifying_bootloader_close (FuUsbDevice *device, GError **error) +fu_logitech_hidpp_bootloader_close (FuUsbDevice *device, GError **error) { GUsbDevice *usb_device = fu_usb_device_get_dev (device); if (usb_device != NULL) { @@ -316,9 +316,9 @@ fu_unifying_bootloader_close (FuUsbDevice *device, GError **error) } gboolean -fu_unifying_bootloader_request (FuUnifyingBootloader *self, - FuUnifyingBootloaderRequest *req, - GError **error) +fu_logitech_hidpp_bootloader_request (FuLogitechHidPpBootloader *self, + FuLogitechHidPpBootloaderRequest *req, + GError **error) { GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (self)); gsize actual_length = 0; @@ -440,7 +440,7 @@ fu_unifying_bootloader_request (FuUnifyingBootloader *self, } static void -fu_unifying_bootloader_init (FuUnifyingBootloader *self) +fu_logitech_hidpp_bootloader_init (FuLogitechHidPpBootloader *self) { fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); @@ -452,13 +452,13 @@ fu_unifying_bootloader_init (FuUnifyingBootloader *self) } static void -fu_unifying_bootloader_class_init (FuUnifyingBootloaderClass *klass) +fu_logitech_hidpp_bootloader_class_init (FuLogitechHidPpBootloaderClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuUsbDeviceClass *klass_usb_device = FU_USB_DEVICE_CLASS (klass); - klass_device->to_string = fu_unifying_bootloader_to_string; - klass_device->attach = fu_unifying_bootloader_attach; - klass_device->setup = fu_unifying_bootloader_setup; - klass_usb_device->open = fu_unifying_bootloader_open; - klass_usb_device->close = fu_unifying_bootloader_close; + klass_device->to_string = fu_logitech_hidpp_bootloader_to_string; + klass_device->attach = fu_logitech_hidpp_bootloader_attach; + klass_device->setup = fu_logitech_hidpp_bootloader_setup; + klass_usb_device->open = fu_logitech_hidpp_bootloader_open; + klass_usb_device->close = fu_logitech_hidpp_bootloader_close; } diff --git a/plugins/unifying/fu-unifying-bootloader.h b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.h similarity index 64% rename from plugins/unifying/fu-unifying-bootloader.h rename to plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.h index 460d5c742..df3473e6e 100644 --- a/plugins/unifying/fu-unifying-bootloader.h +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.h @@ -8,13 +8,13 @@ #include "fu-usb-device.h" -#define FU_TYPE_UNIFYING_BOOTLOADER (fu_unifying_bootloader_get_type ()) -G_DECLARE_DERIVABLE_TYPE (FuUnifyingBootloader, fu_unifying_bootloader, FU, UNIFYING_BOOTLOADER, FuUsbDevice) +#define FU_TYPE_UNIFYING_BOOTLOADER (fu_logitech_hidpp_bootloader_get_type ()) +G_DECLARE_DERIVABLE_TYPE (FuLogitechHidPpBootloader, fu_logitech_hidpp_bootloader, FU, UNIFYING_BOOTLOADER, FuUsbDevice) -struct _FuUnifyingBootloaderClass +struct _FuLogitechHidPpBootloaderClass { FuUsbDeviceClass parent_class; - gboolean (*setup) (FuUnifyingBootloader *self, + gboolean (*setup) (FuLogitechHidPpBootloader *self, GError **error); }; @@ -47,7 +47,7 @@ typedef enum { FU_UNIFYING_BOOTLOADER_CMD_FLASH_RAM_INVALID_ORDER = 0xd4, FU_UNIFYING_BOOTLOADER_CMD_WRITE_SIGNATURE = 0xe0, FU_UNIFYING_BOOTLOADER_CMD_LAST -} FuUnifyingBootloaderCmd; +} FuLogitechHidPpBootloaderCmd; /* packet to and from device */ typedef struct __attribute__((packed)) { @@ -55,22 +55,22 @@ typedef struct __attribute__((packed)) { guint16 addr; guint8 len; guint8 data[28]; -} FuUnifyingBootloaderRequest; +} FuLogitechHidPpBootloaderRequest; -FuUnifyingBootloaderRequest *fu_unifying_bootloader_request_new (void); +FuLogitechHidPpBootloaderRequest *fu_logitech_hidpp_bootloader_request_new (void); #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" -G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuUnifyingBootloaderRequest, g_free); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuLogitechHidPpBootloaderRequest, g_free); #pragma clang diagnostic pop -GPtrArray *fu_unifying_bootloader_parse_requests (FuUnifyingBootloader *self, - GBytes *fw, - GError **error); -gboolean fu_unifying_bootloader_request (FuUnifyingBootloader *self, - FuUnifyingBootloaderRequest *req, - GError **error); +GPtrArray *fu_logitech_hidpp_bootloader_parse_requests (FuLogitechHidPpBootloader *self, + GBytes *fw, + GError **error); +gboolean fu_logitech_hidpp_bootloader_request (FuLogitechHidPpBootloader *self, + FuLogitechHidPpBootloaderRequest *req, + GError **error); -guint16 fu_unifying_bootloader_get_addr_lo (FuUnifyingBootloader *self); -guint16 fu_unifying_bootloader_get_addr_hi (FuUnifyingBootloader *self); -guint16 fu_unifying_bootloader_get_blocksize (FuUnifyingBootloader *self); +guint16 fu_logitech_hidpp_bootloader_get_addr_lo (FuLogitechHidPpBootloader *self); +guint16 fu_logitech_hidpp_bootloader_get_addr_hi (FuLogitechHidPpBootloader *self); +guint16 fu_logitech_hidpp_bootloader_get_blocksize (FuLogitechHidPpBootloader *self); diff --git a/plugins/unifying/fu-unifying-common.c b/plugins/logitech-hidpp/fu-logitech-hidpp-common.c similarity index 76% rename from plugins/unifying/fu-unifying-common.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-common.c index b25b4ca2f..43b91cb88 100644 --- a/plugins/unifying/fu-unifying-common.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-common.c @@ -11,10 +11,10 @@ #include #include -#include "fu-unifying-common.h" +#include "fu-logitech-hidpp-common.h" guint8 -fu_unifying_buffer_read_uint8 (const gchar *str) +fu_logitech_hidpp_buffer_read_uint8 (const gchar *str) { guint64 tmp; gchar buf[3] = { 0x0, 0x0, 0x0 }; @@ -24,7 +24,7 @@ fu_unifying_buffer_read_uint8 (const gchar *str) } guint16 -fu_unifying_buffer_read_uint16 (const gchar *str) +fu_logitech_hidpp_buffer_read_uint16 (const gchar *str) { guint64 tmp; gchar buf[5] = { 0x0, 0x0, 0x0, 0x0, 0x0 }; @@ -34,7 +34,7 @@ fu_unifying_buffer_read_uint16 (const gchar *str) } gchar * -fu_unifying_format_version (const gchar *name, guint8 major, guint8 minor, guint16 build) +fu_logitech_hidpp_format_version (const gchar *name, guint8 major, guint8 minor, guint16 build) { GString *str = g_string_new (NULL); for (guint i = 0; i < 3; i++) { diff --git a/plugins/unifying/fu-unifying-common.h b/plugins/logitech-hidpp/fu-logitech-hidpp-common.h similarity index 68% rename from plugins/unifying/fu-unifying-common.h rename to plugins/logitech-hidpp/fu-logitech-hidpp-common.h index e33f27f42..108953b91 100644 --- a/plugins/unifying/fu-unifying-common.h +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-common.h @@ -19,10 +19,10 @@ /* Signed firmware are very long to verify on the device */ #define FU_UNIFYING_DEVICE_TIMEOUT_MS 30000 -guint8 fu_unifying_buffer_read_uint8 (const gchar *str); -guint16 fu_unifying_buffer_read_uint16 (const gchar *str); +guint8 fu_logitech_hidpp_buffer_read_uint8 (const gchar *str); +guint16 fu_logitech_hidpp_buffer_read_uint16 (const gchar *str); -gchar *fu_unifying_format_version (const gchar *name, - guint8 major, - guint8 minor, - guint16 build); +gchar *fu_logitech_hidpp_format_version (const gchar *name, + guint8 major, + guint8 minor, + guint16 build); diff --git a/plugins/unifying/fu-unifying-hidpp-msg.c b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.c similarity index 92% rename from plugins/unifying/fu-unifying-hidpp-msg.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.c index 7be52c834..c688cc370 100644 --- a/plugins/unifying/fu-unifying-hidpp-msg.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.c @@ -8,17 +8,17 @@ #include -#include "fu-unifying-hidpp.h" -#include "fu-unifying-hidpp-msg.h" +#include "fu-logitech-hidpp-hidpp.h" +#include "fu-logitech-hidpp-hidpp-msg.h" -FuUnifyingHidppMsg * -fu_unifying_hidpp_msg_new (void) +FuLogitechHidPpHidppMsg * +fu_logitech_hidpp_msg_new (void) { - return g_new0 (FuUnifyingHidppMsg, 1); + return g_new0 (FuLogitechHidPpHidppMsg, 1); } const gchar * -fu_unifying_hidpp_msg_dev_id_to_string (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_dev_id_to_string (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, NULL); if (msg->device_id == HIDPP_DEVICE_ID_WIRED) @@ -31,7 +31,7 @@ fu_unifying_hidpp_msg_dev_id_to_string (FuUnifyingHidppMsg *msg) } const gchar * -fu_unifying_hidpp_msg_rpt_id_to_string (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_rpt_id_to_string (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, NULL); if (msg->report_id == HIDPP_REPORT_ID_SHORT) @@ -44,7 +44,7 @@ fu_unifying_hidpp_msg_rpt_id_to_string (FuUnifyingHidppMsg *msg) } gsize -fu_unifying_hidpp_msg_get_payload_length (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_get_payload_length (FuLogitechHidPpHidppMsg *msg) { if (msg->report_id == HIDPP_REPORT_ID_SHORT) return 0x07; @@ -58,7 +58,7 @@ fu_unifying_hidpp_msg_get_payload_length (FuUnifyingHidppMsg *msg) } const gchar * -fu_unifying_hidpp_msg_fcn_id_to_string (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_fcn_id_to_string (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, NULL); switch (msg->sub_id) { @@ -113,7 +113,7 @@ fu_unifying_hidpp_msg_fcn_id_to_string (FuUnifyingHidppMsg *msg) } const gchar * -fu_unifying_hidpp_msg_sub_id_to_string (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_sub_id_to_string (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, NULL); if (msg->sub_id == HIDPP_SUBID_VENDOR_SPECIFIC_KEYS) @@ -196,7 +196,7 @@ fu_unifying_hidpp_msg_sub_id_to_string (FuUnifyingHidppMsg *msg) } gboolean -fu_unifying_hidpp_msg_is_reply (FuUnifyingHidppMsg *msg1, FuUnifyingHidppMsg *msg2) +fu_logitech_hidpp_msg_is_reply (FuLogitechHidPpHidppMsg *msg1, FuLogitechHidPpHidppMsg *msg2) { g_return_val_if_fail (msg1 != NULL, FALSE); g_return_val_if_fail (msg2 != NULL, FALSE); @@ -219,7 +219,7 @@ fu_unifying_hidpp_msg_is_reply (FuUnifyingHidppMsg *msg1, FuUnifyingHidppMsg *ms /* HID++ error */ gboolean -fu_unifying_hidpp_msg_is_error (FuUnifyingHidppMsg *msg, GError **error) +fu_logitech_hidpp_msg_is_error (FuLogitechHidPpHidppMsg *msg, GError **error) { g_return_val_if_fail (msg != NULL, FALSE); if (msg->sub_id == HIDPP_SUBID_ERROR_MSG) { @@ -362,7 +362,7 @@ fu_unifying_hidpp_msg_is_error (FuUnifyingHidppMsg *msg, GError **error) } void -fu_unifying_hidpp_msg_copy (FuUnifyingHidppMsg *msg_dst, const FuUnifyingHidppMsg *msg_src) +fu_logitech_hidpp_msg_copy (FuLogitechHidPpHidppMsg *msg_dst, const FuLogitechHidPpHidppMsg *msg_src) { g_return_if_fail (msg_dst != NULL); g_return_if_fail (msg_src != NULL); @@ -375,7 +375,7 @@ fu_unifying_hidpp_msg_copy (FuUnifyingHidppMsg *msg_dst, const FuUnifyingHidppMs /* filter HID++1.0 messages */ gboolean -fu_unifying_hidpp_msg_is_hidpp10_compat (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_is_hidpp10_compat (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, FALSE); if (msg->sub_id == 0x40 || @@ -389,7 +389,7 @@ fu_unifying_hidpp_msg_is_hidpp10_compat (FuUnifyingHidppMsg *msg) } gboolean -fu_unifying_hidpp_msg_verify_swid (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_verify_swid (FuLogitechHidPpHidppMsg *msg) { g_return_val_if_fail (msg != NULL, FALSE); if ((msg->function_id & 0x0f) != FU_UNIFYING_HIDPP_MSG_SW_ID) diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.h b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.h new file mode 100644 index 000000000..efef93614 --- /dev/null +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp-msg.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2017-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include + +typedef enum { + FU_UNIFYING_HIDPP_MSG_FLAG_NONE, + FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT = 1 << 0, + FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID = 1 << 1, + FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_FNCT_ID = 1 << 2, + FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID = 1 << 3, + /*< private >*/ + FU_UNIFYING_HIDPP_MSG_FLAG_LAST +} FuLogitechHidPpHidppMsgFlags; + +typedef struct __attribute__((packed)) { + guint8 report_id; + guint8 device_id; + guint8 sub_id; + guint8 function_id; /* funcId:software_id */ + guint8 data[47]; /* maximum supported by Windows XP SP2 */ + /* not included in the packet sent to the hardware */ + guint32 flags; + guint8 hidpp_version; +} FuLogitechHidPpHidppMsg; + +/* this is specific to fwupd */ +#define FU_UNIFYING_HIDPP_MSG_SW_ID 0x07 + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuLogitechHidPpHidppMsg, g_free); +#pragma clang diagnostic pop + +FuLogitechHidPpHidppMsg *fu_logitech_hidpp_msg_new (void); +void fu_logitech_hidpp_msg_copy (FuLogitechHidPpHidppMsg *msg_dst, + const FuLogitechHidPpHidppMsg *msg_src); +gsize fu_logitech_hidpp_msg_get_payload_length (FuLogitechHidPpHidppMsg *msg); +gboolean fu_logitech_hidpp_msg_is_reply (FuLogitechHidPpHidppMsg *msg1, + FuLogitechHidPpHidppMsg *msg2); +gboolean fu_logitech_hidpp_msg_is_hidpp10_compat (FuLogitechHidPpHidppMsg *msg); +gboolean fu_logitech_hidpp_msg_is_error (FuLogitechHidPpHidppMsg *msg, + GError **error); +gboolean fu_logitech_hidpp_msg_verify_swid (FuLogitechHidPpHidppMsg *msg); + +const gchar *fu_logitech_hidpp_msg_dev_id_to_string (FuLogitechHidPpHidppMsg *msg); +const gchar *fu_logitech_hidpp_msg_rpt_id_to_string (FuLogitechHidPpHidppMsg *msg); +const gchar *fu_logitech_hidpp_msg_sub_id_to_string (FuLogitechHidPpHidppMsg *msg); +const gchar *fu_logitech_hidpp_msg_fcn_id_to_string (FuLogitechHidPpHidppMsg *msg); diff --git a/plugins/unifying/fu-unifying-hidpp.c b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c similarity index 74% rename from plugins/unifying/fu-unifying-hidpp.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c index cf9213480..0ed4c38f4 100644 --- a/plugins/unifying/fu-unifying-hidpp.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.c @@ -7,11 +7,11 @@ #include "config.h" #include "fu-common.h" -#include "fu-unifying-common.h" -#include "fu-unifying-hidpp.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-hidpp.h" static gchar * -fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg) +fu_logitech_hidpp_msg_to_string (FuLogitechHidPpHidppMsg *msg) { GString *str = g_string_new (NULL); const gchar *tmp; @@ -39,17 +39,17 @@ fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg) flags_str->str); g_string_append_printf (str, "report-id: %02x [%s]\n", msg->report_id, - fu_unifying_hidpp_msg_rpt_id_to_string (msg)); - tmp = fu_unifying_hidpp_msg_dev_id_to_string (msg); + fu_logitech_hidpp_msg_rpt_id_to_string (msg)); + tmp = fu_logitech_hidpp_msg_dev_id_to_string (msg); g_string_append_printf (str, "device-id: %02x [%s]\n", msg->device_id, tmp ); g_string_append_printf (str, "sub-id: %02x [%s]\n", msg->sub_id, - fu_unifying_hidpp_msg_sub_id_to_string (msg)); + fu_logitech_hidpp_msg_sub_id_to_string (msg)); g_string_append_printf (str, "function-id: %02x [%s]\n", msg->function_id, - fu_unifying_hidpp_msg_fcn_id_to_string (msg)); - if (!fu_unifying_hidpp_msg_is_error (msg, &error)) { + fu_logitech_hidpp_msg_fcn_id_to_string (msg)); + if (!fu_logitech_hidpp_msg_is_error (msg, &error)) { g_string_append_printf (str, "error: %s\n", error->message); } @@ -57,12 +57,12 @@ fu_unifying_hidpp_msg_to_string (FuUnifyingHidppMsg *msg) } gboolean -fu_unifying_hidpp_send (FuIOChannel *io_channel, - FuUnifyingHidppMsg *msg, +fu_logitech_hidpp_send (FuIOChannel *io_channel, + FuLogitechHidPpHidppMsg *msg, guint timeout, GError **error) { - gsize len = fu_unifying_hidpp_msg_get_payload_length (msg); + gsize len = fu_logitech_hidpp_msg_get_payload_length (msg); /* only for HID++2.0 */ if (msg->hidpp_version >= 2.f) @@ -70,7 +70,7 @@ fu_unifying_hidpp_send (FuIOChannel *io_channel, /* detailed debugging */ if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) { - g_autofree gchar *str = fu_unifying_hidpp_msg_to_string (msg); + g_autofree gchar *str = fu_logitech_hidpp_msg_to_string (msg); fu_common_dump_raw (G_LOG_DOMAIN, "host->device", (guint8 *) msg, len); g_print ("%s", str); } @@ -88,8 +88,8 @@ fu_unifying_hidpp_send (FuIOChannel *io_channel, } gboolean -fu_unifying_hidpp_receive (FuIOChannel *io_channel, - FuUnifyingHidppMsg *msg, +fu_logitech_hidpp_receive (FuIOChannel *io_channel, + FuLogitechHidPpHidppMsg *msg, guint timeout, GError **error) { @@ -97,7 +97,7 @@ fu_unifying_hidpp_receive (FuIOChannel *io_channel, if (!fu_io_channel_read_raw (io_channel, (guint8 *) msg, - sizeof(FuUnifyingHidppMsg), + sizeof(FuLogitechHidPpHidppMsg), &read_size, timeout, FU_IO_CHANNEL_FLAG_SINGLE_SHOT, @@ -109,19 +109,19 @@ fu_unifying_hidpp_receive (FuIOChannel *io_channel, /* check long enough, but allow returning oversize packets */ if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) fu_common_dump_raw (G_LOG_DOMAIN, "device->host", (guint8 *) msg, read_size); - if (read_size < fu_unifying_hidpp_msg_get_payload_length (msg)) { + if (read_size < fu_logitech_hidpp_msg_get_payload_length (msg)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "message length too small, " "got %" G_GSIZE_FORMAT " expected %" G_GSIZE_FORMAT, - read_size, fu_unifying_hidpp_msg_get_payload_length (msg)); + read_size, fu_logitech_hidpp_msg_get_payload_length (msg)); return FALSE; } /* detailed debugging */ if (g_getenv ("FWUPD_UNIFYING_VERBOSE") != NULL) { - g_autofree gchar *str = fu_unifying_hidpp_msg_to_string (msg); + g_autofree gchar *str = fu_logitech_hidpp_msg_to_string (msg); g_print ("%s", str); } @@ -130,30 +130,30 @@ fu_unifying_hidpp_receive (FuIOChannel *io_channel, } gboolean -fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GError **error) +fu_logitech_hidpp_transfer (FuIOChannel *io_channel, FuLogitechHidPpHidppMsg *msg, GError **error) { guint timeout = FU_UNIFYING_DEVICE_TIMEOUT_MS; guint ignore_cnt = 0; - g_autoptr(FuUnifyingHidppMsg) msg_tmp = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg_tmp = fu_logitech_hidpp_msg_new (); /* increase timeout for some operations */ if (msg->flags & FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT) timeout *= 10; /* send request */ - if (!fu_unifying_hidpp_send (io_channel, msg, timeout, error)) + if (!fu_logitech_hidpp_send (io_channel, msg, timeout, error)) return FALSE; /* keep trying to receive until we get a valid reply */ while (1) { msg_tmp->hidpp_version = msg->hidpp_version; - if (!fu_unifying_hidpp_receive (io_channel, msg_tmp, timeout, error)) { + if (!fu_logitech_hidpp_receive (io_channel, msg_tmp, timeout, error)) { g_prefix_error (error, "failed to receive: "); return FALSE; } /* we don't know how to handle this report packet */ - if (fu_unifying_hidpp_msg_get_payload_length (msg_tmp) == 0x0) { + if (fu_logitech_hidpp_msg_get_payload_length (msg_tmp) == 0x0) { g_debug ("HID++1.0 report 0x%02x has unknown length, ignoring", msg_tmp->report_id); continue; @@ -161,11 +161,11 @@ fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GE /* maybe something is also writing to the device? -- * we can't use the SwID as this is a HID++2.0 feature */ - if (!fu_unifying_hidpp_msg_is_error (msg_tmp, error)) + if (!fu_logitech_hidpp_msg_is_error (msg_tmp, error)) return FALSE; /* is valid reply */ - if (fu_unifying_hidpp_msg_is_reply (msg, msg_tmp)) + if (fu_logitech_hidpp_msg_is_reply (msg, msg_tmp)) break; /* to ensure compatibility when an HID++ 2.0 device is @@ -173,14 +173,14 @@ fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GE * corresponding to an HID++ 1.0 sub-identifier which could be * sent by the receiver, must be assigned to a dummy feature */ if (msg->hidpp_version >= 2.f) { - if (fu_unifying_hidpp_msg_is_hidpp10_compat (msg_tmp)) { + if (fu_logitech_hidpp_msg_is_hidpp10_compat (msg_tmp)) { g_debug ("ignoring HID++1.0 reply"); continue; } /* not us */ if ((msg->flags & FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID) == 0) { - if (!fu_unifying_hidpp_msg_verify_swid (msg_tmp)) { + if (!fu_logitech_hidpp_msg_verify_swid (msg_tmp)) { g_debug ("ignoring reply with SwId 0x%02i, expected 0x%02i", msg_tmp->function_id & 0x0f, FU_UNIFYING_HIDPP_MSG_SW_ID); @@ -202,6 +202,6 @@ fu_unifying_hidpp_transfer (FuIOChannel *io_channel, FuUnifyingHidppMsg *msg, GE }; /* copy over data */ - fu_unifying_hidpp_msg_copy (msg, msg_tmp); + fu_logitech_hidpp_msg_copy (msg, msg_tmp); return TRUE; } diff --git a/plugins/unifying/fu-unifying-hidpp.h b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.h similarity index 94% rename from plugins/unifying/fu-unifying-hidpp.h rename to plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.h index 47d818cc1..c005f3b24 100644 --- a/plugins/unifying/fu-unifying-hidpp.h +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-hidpp.h @@ -133,16 +133,16 @@ #define HIDPP_FEATURE_ONBOARD_PROFILES 0x8100 #define HIDPP_FEATURE_MOUSE_BUTTON_SPY 0x8110 -#include "fu-unifying-hidpp-msg.h" +#include "fu-logitech-hidpp-hidpp-msg.h" -gboolean fu_unifying_hidpp_send (FuIOChannel *self, - FuUnifyingHidppMsg *msg, +gboolean fu_logitech_hidpp_send (FuIOChannel *self, + FuLogitechHidPpHidppMsg *msg, guint timeout, GError **error); -gboolean fu_unifying_hidpp_receive (FuIOChannel *self, - FuUnifyingHidppMsg *msg, +gboolean fu_logitech_hidpp_receive (FuIOChannel *self, + FuLogitechHidPpHidppMsg *msg, guint timeout, GError **error); -gboolean fu_unifying_hidpp_transfer (FuIOChannel *self, - FuUnifyingHidppMsg *msg, +gboolean fu_logitech_hidpp_transfer (FuIOChannel *self, + FuLogitechHidPpHidppMsg *msg, GError **error); diff --git a/plugins/unifying/fu-unifying-peripheral.c b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c similarity index 74% rename from plugins/unifying/fu-unifying-peripheral.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c index 37e1101b4..e079981ee 100644 --- a/plugins/unifying/fu-unifying-peripheral.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c @@ -8,11 +8,11 @@ #include -#include "fu-unifying-common.h" -#include "fu-unifying-peripheral.h" -#include "fu-unifying-hidpp.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-peripheral.h" +#include "fu-logitech-hidpp-hidpp.h" -struct _FuUnifyingPeripheral +struct _FuLogitechHidPpPeripheral { FuUdevDevice parent_instance; guint8 battery_level; @@ -22,15 +22,15 @@ struct _FuUnifyingPeripheral gboolean is_updatable; gboolean is_active; FuIOChannel *io_channel; - GPtrArray *feature_index; /* of FuUnifyingHidppMap */ + GPtrArray *feature_index; /* of FuLogitechHidPpHidppMap */ }; typedef struct { guint8 idx; guint16 feature; -} FuUnifyingHidppMap; +} FuLogitechHidPpHidppMap; -G_DEFINE_TYPE (FuUnifyingPeripheral, fu_unifying_peripheral, FU_TYPE_UDEV_DEVICE) +G_DEFINE_TYPE (FuLogitechHidPpPeripheral, fu_logitech_hidpp_peripheral, FU_TYPE_UDEV_DEVICE) typedef enum { FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD, @@ -42,10 +42,10 @@ typedef enum { FU_UNIFYING_PERIPHERAL_KIND_PRESENTER, FU_UNIFYING_PERIPHERAL_KIND_RECEIVER, FU_UNIFYING_PERIPHERAL_KIND_LAST -} FuUnifyingPeripheralKind; +} FuLogitechHidPpPeripheralKind; static const gchar * -fu_unifying_peripheral_get_icon (FuUnifyingPeripheralKind kind) +fu_logitech_hidpp_peripheral_get_icon (FuLogitechHidPpPeripheralKind kind) { if (kind == FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD) return "input-keyboard"; @@ -67,7 +67,7 @@ fu_unifying_peripheral_get_icon (FuUnifyingPeripheralKind kind) } static const gchar * -fu_unifying_peripheral_get_summary (FuUnifyingPeripheralKind kind) +fu_logitech_hidpp_peripheral_get_summary (FuLogitechHidPpPeripheralKind kind) { if (kind == FU_UNIFYING_PERIPHERAL_KIND_KEYBOARD) return "Unifying Keyboard"; @@ -89,7 +89,7 @@ fu_unifying_peripheral_get_summary (FuUnifyingPeripheralKind kind) } static const gchar * -fu_unifying_hidpp_feature_to_string (guint16 feature) +fu_logitech_hidpp_feature_to_string (guint16 feature) { if (feature == HIDPP_FEATURE_ROOT) return "Root"; @@ -109,7 +109,7 @@ fu_unifying_hidpp_feature_to_string (guint16 feature) } static void -fu_unifying_peripheral_refresh_updatable (FuUnifyingPeripheral *self) +fu_logitech_hidpp_peripheral_refresh_updatable (FuLogitechHidPpPeripheral *self) { /* device can only be upgraded if it is capable, and active */ if (self->is_updatable && self->is_active) { @@ -120,11 +120,11 @@ fu_unifying_peripheral_refresh_updatable (FuUnifyingPeripheral *self) } static gboolean -fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) +fu_logitech_hidpp_peripheral_ping (FuLogitechHidPpPeripheral *self, GError **error) { gdouble version; g_autoptr(GError) error_local = NULL; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* handle failure */ msg->report_id = HIDPP_REPORT_ID_SHORT; @@ -135,7 +135,7 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) msg->data[1] = 0x00; msg->data[2] = 0xaa; /* user-selected value */ msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, &error_local)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, &error_local)) { if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) { @@ -146,7 +146,7 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE)) { self->is_active = FALSE; - fu_unifying_peripheral_refresh_updatable (self); + fu_logitech_hidpp_peripheral_refresh_updatable (self); return TRUE; } g_set_error (error, @@ -160,7 +160,7 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) /* device no longer asleep */ self->is_active = TRUE; - fu_unifying_peripheral_refresh_updatable (self); + fu_logitech_hidpp_peripheral_refresh_updatable (self); /* if the HID++ ID is unset, grab it from the reply */ if (self->hidpp_id == HIDPP_DEVICE_ID_UNSET) { @@ -177,9 +177,9 @@ fu_unifying_peripheral_ping (FuUnifyingPeripheral *self, GError **error) } static gboolean -fu_unifying_peripheral_close (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_close (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); if (!fu_io_channel_shutdown (self->io_channel, error)) return FALSE; g_clear_object (&self->io_channel); @@ -187,12 +187,12 @@ fu_unifying_peripheral_close (FuDevice *device, GError **error) } static gboolean -fu_unifying_peripheral_poll (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_poll (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); const guint timeout = 1; /* ms */ g_autoptr(GError) error_local = NULL; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); g_autoptr(FuDeviceLocker) locker = NULL; /* open */ @@ -203,7 +203,7 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error) /* flush pending data */ msg->device_id = self->hidpp_id; msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_receive (self->io_channel, msg, timeout, &error_local)) { + if (!fu_logitech_hidpp_receive (self->io_channel, msg, timeout, &error_local)) { if (!g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) { @@ -215,7 +215,7 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error) } /* just ping */ - if (!fu_unifying_peripheral_ping (self, &error_local)) { + if (!fu_logitech_hidpp_peripheral_ping (self, &error_local)) { g_warning ("failed to ping device: %s", error_local->message); return TRUE; } @@ -232,9 +232,9 @@ fu_unifying_peripheral_poll (FuDevice *device, GError **error) } static gboolean -fu_unifying_peripheral_open (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_open (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device)); const gchar *devpath = g_udev_device_get_device_file (udev_device); @@ -247,35 +247,35 @@ fu_unifying_peripheral_open (FuDevice *device, GError **error) } static void -fu_unifying_hidpp_map_to_string (FuUnifyingHidppMap *map, guint idt, GString *str) +fu_logitech_hidpp_map_to_string (FuLogitechHidPpHidppMap *map, guint idt, GString *str) { g_autofree gchar *title = g_strdup_printf ("Feature%02x", map->idx); g_autofree gchar *tmp = g_strdup_printf ("%s [0x%04x]", - fu_unifying_hidpp_feature_to_string (map->feature), + fu_logitech_hidpp_feature_to_string (map->feature), map->feature); fu_common_string_append_kv (str, idt, title, tmp); } static void -fu_unifying_peripheral_to_string (FuDevice *device, guint idt, GString *str) +fu_logitech_hidpp_peripheral_to_string (FuDevice *device, guint idt, GString *str) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); fu_common_string_append_ku (str, idt, "HidppVersion", self->hidpp_version); fu_common_string_append_kx (str, idt, "HidppId", self->hidpp_id); fu_common_string_append_ku (str, idt, "BatteryLevel", self->battery_level); fu_common_string_append_kb (str, idt, "IsUpdatable", self->is_updatable); fu_common_string_append_kb (str, idt, "IsActive", self->is_active); for (guint i = 0; i < self->feature_index->len; i++) { - FuUnifyingHidppMap *map = g_ptr_array_index (self->feature_index, i); - fu_unifying_hidpp_map_to_string (map, idt, str); + FuLogitechHidPpHidppMap *map = g_ptr_array_index (self->feature_index, i); + fu_logitech_hidpp_map_to_string (map, idt, str); } } static guint8 -fu_unifying_peripheral_feature_get_idx (FuUnifyingPeripheral *self, guint16 feature) +fu_logitech_hidpp_peripheral_feature_get_idx (FuLogitechHidPpPeripheral *self, guint16 feature) { for (guint i = 0; i < self->feature_index->len; i++) { - FuUnifyingHidppMap *map = g_ptr_array_index (self->feature_index, i); + FuLogitechHidPpHidppMap *map = g_ptr_array_index (self->feature_index, i); if (map->feature == feature) return map->idx; } @@ -283,14 +283,14 @@ fu_unifying_peripheral_feature_get_idx (FuUnifyingPeripheral *self, guint16 feat } static gboolean -fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError **error) +fu_logitech_hidpp_peripheral_fetch_firmware_info (FuLogitechHidPpPeripheral *self, GError **error) { guint8 idx; guint8 entity_count; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* get the feature index */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_I_FIRMWARE_INFO); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_I_FIRMWARE_INFO); if (idx == 0x00) return TRUE; @@ -300,7 +300,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError * msg->sub_id = idx; msg->function_id = 0x00 << 4; /* getCount */ msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get firmware count: "); return FALSE; } @@ -318,7 +318,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError * msg->sub_id = idx; msg->function_id = 0x01 << 4; /* getInfo */ msg->data[0] = i; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get firmware info: "); return FALSE; } @@ -337,7 +337,7 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError * msg->data[2], msg->data[3]); build = ((guint16) msg->data[6]) << 8 | msg->data[7]; - version = fu_unifying_format_version (name, + version = fu_logitech_hidpp_format_version (name, msg->data[4], msg->data[5], build); @@ -358,20 +358,20 @@ fu_unifying_peripheral_fetch_firmware_info (FuUnifyingPeripheral *self, GError * } static gboolean -fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError **error) +fu_logitech_hidpp_peripheral_fetch_battery_level (FuLogitechHidPpPeripheral *self, GError **error) { /* try using HID++2.0 */ if (self->hidpp_version >= 2.f) { guint8 idx; - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_BATTERY_LEVEL_STATUS); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_BATTERY_LEVEL_STATUS); if (idx != 0x00) { - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = self->hidpp_id; msg->sub_id = idx; msg->function_id = 0x00; /* GetBatteryLevelStatus */ msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get battery info: "); return FALSE; } @@ -383,13 +383,13 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError * /* try HID++1.0 battery mileage */ if (self->hidpp_version == 1.f) { - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = self->hidpp_id; msg->sub_id = HIDPP_SUBID_GET_REGISTER; msg->function_id = HIDPP_REGISTER_BATTERY_MILEAGE; msg->hidpp_version = self->hidpp_version; - if (fu_unifying_hidpp_transfer (self->io_channel, msg, NULL)) { + if (fu_logitech_hidpp_transfer (self->io_channel, msg, NULL)) { if (msg->data[0] != 0x00) self->battery_level = msg->data[0]; return TRUE; @@ -397,7 +397,7 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError * /* try HID++1.0 battery status instead */ msg->function_id = HIDPP_REGISTER_BATTERY_STATUS; - if (fu_unifying_hidpp_transfer (self->io_channel, msg, NULL)) { + if (fu_logitech_hidpp_transfer (self->io_channel, msg, NULL)) { switch (msg->data[0]) { case 1: /* 0 - 10 */ self->battery_level = 5; @@ -425,11 +425,11 @@ fu_unifying_peripheral_fetch_battery_level (FuUnifyingPeripheral *self, GError * } static gboolean -fu_unifying_hidpp_feature_search (FuDevice *device, guint16 feature, GError **error) +fu_logitech_hidpp_feature_search (FuDevice *device, guint16 feature, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); - FuUnifyingHidppMap *map; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpHidppMap *map; + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* find the idx for the feature */ msg->report_id = HIDPP_REPORT_ID_SHORT; @@ -440,10 +440,10 @@ fu_unifying_hidpp_feature_search (FuDevice *device, guint16 feature, GError **er msg->data[1] = feature; msg->data[2] = 0x00; msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get idx for feature %s [0x%04x]: ", - fu_unifying_hidpp_feature_to_string (feature), feature); + fu_logitech_hidpp_feature_to_string (feature), feature); return FALSE; } @@ -453,22 +453,22 @@ fu_unifying_hidpp_feature_search (FuDevice *device, guint16 feature, GError **er G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "feature %s [0x%04x] not found", - fu_unifying_hidpp_feature_to_string (feature), feature); + fu_logitech_hidpp_feature_to_string (feature), feature); return FALSE; } /* add to map */ - map = g_new0 (FuUnifyingHidppMap, 1); + map = g_new0 (FuLogitechHidPpHidppMap, 1); map->idx = msg->data[0]; map->feature = feature; g_ptr_array_add (self->feature_index, map); g_debug ("added feature %s [0x%04x] as idx %02x", - fu_unifying_hidpp_feature_to_string (feature), feature, map->idx); + fu_logitech_hidpp_feature_to_string (feature), feature, map->idx); return TRUE; } static gboolean -fu_unifying_peripheral_probe (FuUdevDevice *device, GError **error) +fu_logitech_hidpp_peripheral_probe (FuUdevDevice *device, GError **error) { g_autofree gchar *devid = NULL; @@ -488,9 +488,9 @@ fu_unifying_peripheral_probe (FuUdevDevice *device, GError **error) } static gboolean -fu_unifying_peripheral_setup (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_setup (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); guint8 idx; const guint16 map_features[] = { HIDPP_FEATURE_GET_DEVICE_NAME_TYPE, @@ -502,13 +502,13 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) HIDPP_FEATURE_ROOT }; /* ping device to get HID++ version */ - if (!fu_unifying_peripheral_ping (self, error)) + if (!fu_logitech_hidpp_peripheral_ping (self, error)) return FALSE; /* add known root for HID++2.0 */ g_ptr_array_set_size (self->feature_index, 0); if (self->hidpp_version >= 2.f) { - FuUnifyingHidppMap *map = g_new0 (FuUnifyingHidppMap, 1); + FuLogitechHidPpHidppMap *map = g_new0 (FuLogitechHidPpHidppMap, 1); map->idx = 0x00; map->feature = HIDPP_FEATURE_ROOT; g_ptr_array_add (self->feature_index, map); @@ -517,7 +517,7 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) /* map some *optional* HID++2.0 features we might use */ for (guint i = 0; map_features[i] != HIDPP_FEATURE_ROOT; i++) { g_autoptr(GError) error_local = NULL; - if (!fu_unifying_hidpp_feature_search (device, + if (!fu_logitech_hidpp_feature_search (device, map_features[i], &error_local)) { g_debug ("%s", error_local->message); @@ -534,51 +534,51 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) } /* get the firmware information */ - if (!fu_unifying_peripheral_fetch_firmware_info (self, error)) + if (!fu_logitech_hidpp_peripheral_fetch_firmware_info (self, error)) return FALSE; /* get the battery level */ - if (!fu_unifying_peripheral_fetch_battery_level (self, error)) + if (!fu_logitech_hidpp_peripheral_fetch_battery_level (self, error)) return FALSE; /* try using HID++2.0 */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_GET_DEVICE_NAME_TYPE); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_GET_DEVICE_NAME_TYPE); if (idx != 0x00) { const gchar *tmp; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = self->hidpp_id; msg->sub_id = idx; msg->function_id = 0x02 << 4; /* getDeviceType */ msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get device type: "); return FALSE; } /* add nice-to-have data */ - tmp = fu_unifying_peripheral_get_summary (msg->data[0]); + tmp = fu_logitech_hidpp_peripheral_get_summary (msg->data[0]); if (tmp != NULL) fu_device_set_summary (FU_DEVICE (device), tmp); - tmp = fu_unifying_peripheral_get_icon (msg->data[0]); + tmp = fu_logitech_hidpp_peripheral_get_icon (msg->data[0]); if (tmp != NULL) fu_device_add_icon (FU_DEVICE (device), tmp); } - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL); if (idx != 0x00) { self->is_updatable = TRUE; fu_device_remove_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); } - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL_SIGNED); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL_SIGNED); if (idx != 0x00) { /* check the feature is available */ - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = self->hidpp_id; msg->sub_id = idx; msg->function_id = 0x00 << 4; /* getDfuStatus */ msg->hidpp_version = self->hidpp_version; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to get DFU status: "); return FALSE; } @@ -589,7 +589,7 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) fu_device_remove_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); } } - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); if (idx != 0x00) { self->is_updatable = TRUE; fu_device_add_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); @@ -602,7 +602,7 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) } /* this device may have changed state */ - fu_unifying_peripheral_refresh_updatable (self); + fu_logitech_hidpp_peripheral_refresh_updatable (self); /* poll for pings to track active state */ fu_device_set_poll_interval (device, 30000); @@ -610,14 +610,14 @@ fu_unifying_peripheral_setup (FuDevice *device, GError **error) } static gboolean -fu_unifying_peripheral_detach (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_detach (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); guint8 idx; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* this requires user action */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL); if (idx != 0x00) { msg->report_id = HIDPP_REPORT_ID_LONG; msg->device_id = self->hidpp_id; @@ -633,7 +633,7 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error) msg->hidpp_version = self->hidpp_version; msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID | FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to put device into DFU mode: "); return FALSE; } @@ -648,7 +648,7 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error) } /* this can reboot all by itself */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL_SIGNED); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU_CONTROL_SIGNED); if (idx != 0x00) { msg->report_id = HIDPP_REPORT_ID_LONG; msg->device_id = self->hidpp_id; @@ -662,11 +662,11 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error) msg->data[5] = 'F'; msg->data[6] = 'U'; msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to put device into DFU mode: "); return FALSE; } - return fu_unifying_peripheral_setup (FU_DEVICE (self), error); + return fu_logitech_hidpp_peripheral_setup (FU_DEVICE (self), error); } /* we don't know how */ @@ -678,7 +678,7 @@ fu_unifying_peripheral_detach (FuDevice *device, GError **error) } static gboolean -fu_unifying_peripheral_check_status (guint8 status, GError **error) +fu_logitech_hidpp_peripheral_check_status (guint8 status, GError **error) { switch (status & 0x7f) { case 0x00: @@ -824,14 +824,14 @@ fu_unifying_peripheral_check_status (guint8 status, GError **error) } static gboolean -fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, +fu_logitech_hidpp_peripheral_write_firmware_pkt (FuLogitechHidPpPeripheral *self, guint8 idx, guint8 cmd, const guint8 *data, GError **error) { guint32 packet_cnt; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); g_autoptr(GError) error_local = NULL; /* send firmware data */ @@ -841,7 +841,7 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, msg->function_id = cmd << 4; /* dfuStart or dfuCmdDataX */ msg->hidpp_version = self->hidpp_version; memcpy (msg->data, data, 16); - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, &error_local)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, &error_local)) { g_prefix_error (error, "failed to supply program data: "); return FALSE; } @@ -849,7 +849,7 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, /* check error */ packet_cnt = fu_common_read_uint32 (msg->data, G_BIG_ENDIAN); g_debug ("packet_cnt=0x%04x", packet_cnt); - if (fu_unifying_peripheral_check_status (msg->data[4], &error_local)) + if (fu_logitech_hidpp_peripheral_check_status (msg->data[4], &error_local)) return TRUE; /* fatal error */ @@ -866,13 +866,13 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, /* wait for the HID++ notification */ g_debug ("ignoring: %s", error_local->message); for (guint retry = 0; retry < 10; retry++) { - g_autoptr(FuUnifyingHidppMsg) msg2 = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg2 = fu_logitech_hidpp_msg_new (); msg2->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_FNCT_ID; - if (!fu_unifying_hidpp_receive (self->io_channel, msg2, 15000, error)) + if (!fu_logitech_hidpp_receive (self->io_channel, msg2, 15000, error)) return FALSE; - if (fu_unifying_hidpp_msg_is_reply (msg, msg2)) { + if (fu_logitech_hidpp_msg_is_reply (msg, msg2)) { g_autoptr(GError) error2 = NULL; - if (!fu_unifying_peripheral_check_status (msg2->data[4], &error2)) { + if (!fu_logitech_hidpp_peripheral_check_status (msg2->data[4], &error2)) { g_debug ("got %s, waiting a bit longer", error2->message); continue; } @@ -891,12 +891,12 @@ fu_unifying_peripheral_write_firmware_pkt (FuUnifyingPeripheral *self, } static gboolean -fu_unifying_peripheral_write_firmware (FuDevice *device, +fu_logitech_hidpp_peripheral_write_firmware (FuDevice *device, FuFirmware *firmware, FwupdInstallFlags flags, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); gsize sz = 0; const guint8 *data; guint8 cmd = 0x04; @@ -904,7 +904,7 @@ fu_unifying_peripheral_write_firmware (FuDevice *device, g_autoptr(GBytes) fw = NULL; /* if we're in bootloader mode, we should be able to get this feature */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); if (idx == 0x00) { g_set_error (error, G_IO_ERROR, @@ -925,7 +925,7 @@ fu_unifying_peripheral_write_firmware (FuDevice *device, /* send packet and wait for reply */ g_debug ("send data at addr=0x%04x", (guint) i * 16); - if (!fu_unifying_peripheral_write_firmware_pkt (self, + if (!fu_logitech_hidpp_peripheral_write_firmware_pkt (self, idx, cmd, data + (i * 16), @@ -947,14 +947,14 @@ fu_unifying_peripheral_write_firmware (FuDevice *device, } static gboolean -fu_unifying_peripheral_attach (FuDevice *device, GError **error) +fu_logitech_hidpp_peripheral_attach (FuDevice *device, GError **error) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (device); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (device); guint8 idx; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* if we're in bootloader mode, we should be able to get this feature */ - idx = fu_unifying_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); + idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); if (idx == 0x00) { g_set_error (error, G_IO_ERROR, @@ -973,13 +973,13 @@ fu_unifying_peripheral_attach (FuDevice *device, GError **error) msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID | FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID | // inferred? FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to restart device: "); return FALSE; } /* reprobe */ - if (!fu_unifying_peripheral_setup (device, error)) + if (!fu_logitech_hidpp_peripheral_setup (device, error)) return FALSE; /* success */ @@ -987,34 +987,34 @@ fu_unifying_peripheral_attach (FuDevice *device, GError **error) } static void -fu_unifying_peripheral_finalize (GObject *object) +fu_logitech_hidpp_peripheral_finalize (GObject *object) { - FuUnifyingPeripheral *self = FU_UNIFYING_PERIPHERAL (object); + FuLogitechHidPpPeripheral *self = FU_UNIFYING_PERIPHERAL (object); g_ptr_array_unref (self->feature_index); - G_OBJECT_CLASS (fu_unifying_peripheral_parent_class)->finalize (object); + G_OBJECT_CLASS (fu_logitech_hidpp_peripheral_parent_class)->finalize (object); } static void -fu_unifying_peripheral_class_init (FuUnifyingPeripheralClass *klass) +fu_logitech_hidpp_peripheral_class_init (FuLogitechHidPpPeripheralClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = fu_unifying_peripheral_finalize; - klass_device->setup = fu_unifying_peripheral_setup; - klass_device->open = fu_unifying_peripheral_open; - klass_device->close = fu_unifying_peripheral_close; - klass_device->write_firmware = fu_unifying_peripheral_write_firmware; - klass_device->attach = fu_unifying_peripheral_attach; - klass_device->detach = fu_unifying_peripheral_detach; - klass_device->poll = fu_unifying_peripheral_poll; - klass_device->to_string = fu_unifying_peripheral_to_string; - klass_device_udev->probe = fu_unifying_peripheral_probe; + object_class->finalize = fu_logitech_hidpp_peripheral_finalize; + klass_device->setup = fu_logitech_hidpp_peripheral_setup; + klass_device->open = fu_logitech_hidpp_peripheral_open; + klass_device->close = fu_logitech_hidpp_peripheral_close; + klass_device->write_firmware = fu_logitech_hidpp_peripheral_write_firmware; + klass_device->attach = fu_logitech_hidpp_peripheral_attach; + klass_device->detach = fu_logitech_hidpp_peripheral_detach; + klass_device->poll = fu_logitech_hidpp_peripheral_poll; + klass_device->to_string = fu_logitech_hidpp_peripheral_to_string; + klass_device_udev->probe = fu_logitech_hidpp_peripheral_probe; } static void -fu_unifying_peripheral_init (FuUnifyingPeripheral *self) +fu_logitech_hidpp_peripheral_init (FuLogitechHidPpPeripheral *self) { self->hidpp_id = HIDPP_DEVICE_ID_UNSET; self->feature_index = g_ptr_array_new_with_free_func (g_free); diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.h b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.h new file mode 100644 index 000000000..c6c371d14 --- /dev/null +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2017-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include "fu-udev-device.h" + +#define FU_TYPE_UNIFYING_PERIPHERAL (fu_logitech_hidpp_peripheral_get_type ()) +G_DECLARE_FINAL_TYPE (FuLogitechHidPpPeripheral, fu_logitech_hidpp_peripheral, FU, UNIFYING_PERIPHERAL, FuUdevDevice) diff --git a/plugins/unifying/fu-unifying-runtime.c b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c similarity index 71% rename from plugins/unifying/fu-unifying-runtime.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c index d1e81c131..c9cad0f20 100644 --- a/plugins/unifying/fu-unifying-runtime.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.c @@ -8,11 +8,11 @@ #include -#include "fu-unifying-common.h" -#include "fu-unifying-runtime.h" -#include "fu-unifying-hidpp.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-runtime.h" +#include "fu-logitech-hidpp-hidpp.h" -struct _FuUnifyingRuntime +struct _FuLogitechHidPpRuntime { FuUdevDevice parent_instance; guint8 version_bl_major; @@ -20,19 +20,19 @@ struct _FuUnifyingRuntime FuIOChannel *io_channel; }; -G_DEFINE_TYPE (FuUnifyingRuntime, fu_unifying_runtime, FU_TYPE_UDEV_DEVICE) +G_DEFINE_TYPE (FuLogitechHidPpRuntime, fu_logitech_hidpp_runtime, FU_TYPE_UDEV_DEVICE) static void -fu_unifying_runtime_to_string (FuDevice *device, guint idt, GString *str) +fu_logitech_hidpp_runtime_to_string (FuDevice *device, guint idt, GString *str) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); fu_common_string_append_kb (str, idt, "SignedFirmware", self->signed_firmware); } static gboolean -fu_unifying_runtime_enable_notifications (FuUnifyingRuntime *self, GError **error) +fu_logitech_hidpp_runtime_enable_notifications (FuLogitechHidPpRuntime *self, GError **error) { - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = HIDPP_DEVICE_ID_RECEIVER; msg->sub_id = HIDPP_SUBID_SET_REGISTER; @@ -41,13 +41,13 @@ fu_unifying_runtime_enable_notifications (FuUnifyingRuntime *self, GError **erro msg->data[1] = 0x05; /* Wireless + SoftwarePresent */ msg->data[2] = 0x00; msg->hidpp_version = 1; - return fu_unifying_hidpp_transfer (self->io_channel, msg, error); + return fu_logitech_hidpp_transfer (self->io_channel, msg, error); } static gboolean -fu_unifying_runtime_close (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_close (FuDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); if (!fu_io_channel_shutdown (self->io_channel, error)) return FALSE; g_clear_object (&self->io_channel); @@ -55,12 +55,12 @@ fu_unifying_runtime_close (FuDevice *device, GError **error) } static gboolean -fu_unifying_runtime_poll (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_poll (FuDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); const guint timeout = 1; /* ms */ g_autoptr(GError) error_local = NULL; - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); g_autoptr(FuDeviceLocker) locker = NULL; /* open */ @@ -70,7 +70,7 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error) /* is there any pending data to read */ msg->hidpp_version = 1; - if (!fu_unifying_hidpp_receive (self->io_channel, msg, timeout, &error_local)) { + if (!fu_logitech_hidpp_receive (self->io_channel, msg, timeout, &error_local)) { if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) { @@ -81,7 +81,7 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error) } /* HID++1.0 error */ - if (!fu_unifying_hidpp_msg_is_error (msg, &error_local)) { + if (!fu_logitech_hidpp_msg_is_error (msg, &error_local)) { g_warning ("failed to get pending read: %s", error_local->message); return TRUE; } @@ -109,9 +109,9 @@ fu_unifying_runtime_poll (FuDevice *device, GError **error) } static gboolean -fu_unifying_runtime_open (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_open (FuDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device)); const gchar *devpath = g_udev_device_get_device_file (udev_device); @@ -128,9 +128,9 @@ fu_unifying_runtime_open (FuDevice *device, GError **error) } static gboolean -fu_unifying_runtime_probe (FuUdevDevice *device, GError **error) +fu_logitech_hidpp_runtime_probe (FuUdevDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (device)); guint16 release = 0xffff; g_autoptr(GUdevDevice) udev_parent = NULL; @@ -176,16 +176,16 @@ fu_unifying_runtime_probe (FuUdevDevice *device, GError **error) } static gboolean -fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_setup_internal (FuDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); guint8 config[10]; g_autofree gchar *version_fw = NULL; /* read all 10 bytes of the version register */ memset (config, 0x00, sizeof (config)); for (guint i = 0x01; i < 0x05; i++) { - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); /* workaround a bug in the 12.01 firmware, which fails with * INVALID_VALUE when reading MCU1_HW_VERSION */ @@ -198,7 +198,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) msg->function_id = HIDPP_REGISTER_DEVICE_FIRMWARE_INFORMATION; msg->data[0] = i; msg->hidpp_version = 1; - if (!fu_unifying_hidpp_transfer (self->io_channel, msg, error)) { + if (!fu_logitech_hidpp_transfer (self->io_channel, msg, error)) { g_prefix_error (error, "failed to read device config: "); return FALSE; } @@ -209,7 +209,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) } /* get firmware version */ - version_fw = fu_unifying_format_version ("RQR", + version_fw = fu_logitech_hidpp_format_version ("RQR", config[2], config[3], (guint16) config[4] << 8 | @@ -219,7 +219,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) /* get bootloader version */ if (self->version_bl_major > 0) { g_autofree gchar *version_bl = NULL; - version_bl = fu_unifying_format_version ("BOT", + version_bl = fu_logitech_hidpp_format_version ("BOT", self->version_bl_major, config[8], config[9]); @@ -233,7 +233,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) } /* enable HID++ notifications */ - if (!fu_unifying_runtime_enable_notifications (self, error)) { + if (!fu_logitech_hidpp_runtime_enable_notifications (self, error)) { g_prefix_error (error, "failed to enable notifications: "); return FALSE; } @@ -243,7 +243,7 @@ fu_unifying_runtime_setup_internal (FuDevice *device, GError **error) } static gboolean -fu_unifying_runtime_setup (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_setup (FuDevice *device, GError **error) { g_autoptr(GError) error_local = NULL; for (guint i = 0; i < 5; i++) { @@ -251,7 +251,7 @@ fu_unifying_runtime_setup (FuDevice *device, GError **error) * the device first -- we can't use the SwID as this is a * HID++2.0 feature */ g_usleep (200*1000); - if (fu_unifying_runtime_setup_internal (device, &error_local)) + if (fu_logitech_hidpp_runtime_setup_internal (device, &error_local)) return TRUE; if (!g_error_matches (error_local, G_IO_ERROR, @@ -266,10 +266,10 @@ fu_unifying_runtime_setup (FuDevice *device, GError **error) } static gboolean -fu_unifying_runtime_detach (FuDevice *device, GError **error) +fu_logitech_hidpp_runtime_detach (FuDevice *device, GError **error) { - FuUnifyingRuntime *self = FU_UNIFYING_RUNTIME (device); - g_autoptr(FuUnifyingHidppMsg) msg = fu_unifying_hidpp_msg_new (); + FuLogitechHidPpRuntime *self = FU_UNIFYING_RUNTIME (device); + g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new (); msg->report_id = HIDPP_REPORT_ID_SHORT; msg->device_id = HIDPP_DEVICE_ID_RECEIVER; msg->sub_id = HIDPP_SUBID_SET_REGISTER; @@ -279,7 +279,7 @@ fu_unifying_runtime_detach (FuDevice *device, GError **error) msg->data[2] = 'P'; msg->hidpp_version = 1; msg->flags = FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT; - if (!fu_unifying_hidpp_send (self->io_channel, msg, FU_UNIFYING_DEVICE_TIMEOUT_MS, error)) { + if (!fu_logitech_hidpp_send (self->io_channel, msg, FU_UNIFYING_DEVICE_TIMEOUT_MS, error)) { g_prefix_error (error, "failed to detach to bootloader: "); return FALSE; } @@ -288,30 +288,30 @@ fu_unifying_runtime_detach (FuDevice *device, GError **error) } static void -fu_unifying_runtime_finalize (GObject *object) +fu_logitech_hidpp_runtime_finalize (GObject *object) { - G_OBJECT_CLASS (fu_unifying_runtime_parent_class)->finalize (object); + G_OBJECT_CLASS (fu_logitech_hidpp_runtime_parent_class)->finalize (object); } static void -fu_unifying_runtime_class_init (FuUnifyingRuntimeClass *klass) +fu_logitech_hidpp_runtime_class_init (FuLogitechHidPpRuntimeClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); FuUdevDeviceClass *klass_device_udev = FU_UDEV_DEVICE_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = fu_unifying_runtime_finalize; - klass_device->open = fu_unifying_runtime_open; - klass_device_udev->probe = fu_unifying_runtime_probe; - klass_device->setup = fu_unifying_runtime_setup; - klass_device->close = fu_unifying_runtime_close; - klass_device->detach = fu_unifying_runtime_detach; - klass_device->poll = fu_unifying_runtime_poll; - klass_device->to_string = fu_unifying_runtime_to_string; + object_class->finalize = fu_logitech_hidpp_runtime_finalize; + klass_device->open = fu_logitech_hidpp_runtime_open; + klass_device_udev->probe = fu_logitech_hidpp_runtime_probe; + klass_device->setup = fu_logitech_hidpp_runtime_setup; + klass_device->close = fu_logitech_hidpp_runtime_close; + klass_device->detach = fu_logitech_hidpp_runtime_detach; + klass_device->poll = fu_logitech_hidpp_runtime_poll; + klass_device->to_string = fu_logitech_hidpp_runtime_to_string; } static void -fu_unifying_runtime_init (FuUnifyingRuntime *self) +fu_logitech_hidpp_runtime_init (FuLogitechHidPpRuntime *self) { fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_icon (FU_DEVICE (self), "preferences-desktop-keyboard"); diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.h b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.h new file mode 100644 index 000000000..2221b4abc --- /dev/null +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-runtime.h @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2016-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include "fu-udev-device.h" + +#define FU_TYPE_UNIFYING_RUNTIME (fu_logitech_hidpp_runtime_get_type ()) +G_DECLARE_FINAL_TYPE (FuLogitechHidPpRuntime, fu_logitech_hidpp_runtime, FU, UNIFYING_RUNTIME, FuUdevDevice) diff --git a/plugins/unifying/fu-unifying-self-test.c b/plugins/logitech-hidpp/fu-logitech-hidpp-self-test.c similarity index 66% rename from plugins/unifying/fu-unifying-self-test.c rename to plugins/logitech-hidpp/fu-logitech-hidpp-self-test.c index ef1e1a392..73bbeef87 100644 --- a/plugins/unifying/fu-unifying-self-test.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-self-test.c @@ -9,21 +9,21 @@ #include #include -#include "fu-unifying-common.h" +#include "fu-logitech-hidpp-common.h" static void -fu_unifying_common (void) +fu_logitech_hidpp_common (void) { guint8 u8; guint16 u16; g_autofree gchar *ver1 = NULL; - u8 = fu_unifying_buffer_read_uint8 ("12"); + u8 = fu_logitech_hidpp_buffer_read_uint8 ("12"); g_assert_cmpint (u8, ==, 0x12); - u16 = fu_unifying_buffer_read_uint16 ("1234"); + u16 = fu_logitech_hidpp_buffer_read_uint16 ("1234"); g_assert_cmpint (u16, ==, 0x1234); - ver1 = fu_unifying_format_version (" A ", 0x87, 0x65, 0x4321); + ver1 = fu_logitech_hidpp_format_version (" A ", 0x87, 0x65, 0x4321); g_assert_cmpstr (ver1, ==, "A87.65_B4321"); } @@ -36,6 +36,6 @@ main (int argc, char **argv) g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); /* tests go here */ - g_test_add_func ("/unifying/common", fu_unifying_common); + g_test_add_func ("/unifying/common", fu_logitech_hidpp_common); return g_test_run (); } diff --git a/plugins/unifying/fu-plugin-unifying.c b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c similarity index 83% rename from plugins/unifying/fu-plugin-unifying.c rename to plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c index 14f2d378a..d4c5efa71 100644 --- a/plugins/unifying/fu-plugin-unifying.c +++ b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c @@ -10,11 +10,11 @@ #include "fu-plugin-vfuncs.h" -#include "fu-unifying-bootloader-nordic.h" -#include "fu-unifying-bootloader-texas.h" -#include "fu-unifying-common.h" -#include "fu-unifying-peripheral.h" -#include "fu-unifying-runtime.h" +#include "fu-logitech-hidpp-bootloader-nordic.h" +#include "fu-logitech-hidpp-bootloader-texas.h" +#include "fu-logitech-hidpp-common.h" +#include "fu-logitech-hidpp-peripheral.h" +#include "fu-logitech-hidpp-runtime.h" gboolean fu_plugin_startup (FuPlugin *plugin, GError **error) diff --git a/plugins/unifying/unifying.quirk b/plugins/logitech-hidpp/logitech-hidpp.quirk similarity index 67% rename from plugins/unifying/unifying.quirk rename to plugins/logitech-hidpp/logitech-hidpp.quirk index 091b3458d..6e5dbee32 100644 --- a/plugins/unifying/unifying.quirk +++ b/plugins/logitech-hidpp/logitech-hidpp.quirk @@ -1,43 +1,43 @@ # Unifying Receiver [DeviceInstanceId=HIDRAW\VEN_046D&DEV_C52B] -Plugin = unifying -GType = FuUnifyingRuntime +Plugin = logitech_hidpp +GType = FuLogitechHidPpRuntime VendorId=USB:0x046D InstallDuration = 30 # Nordic [DeviceInstanceId=USB\VID_046D&PID_AAAA] -Plugin = unifying -GType = FuUnifyingBootloaderNordic +Plugin = logitech_hidpp +GType = FuLogitechHidPpBootloaderNordic FirmwareSizeMin = 0x4000 CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B InstallDuration = 30 # Nordic Pico [DeviceInstanceId=USB\VID_046D&PID_AAAE] -Plugin = unifying -GType = FuUnifyingBootloaderNordic +Plugin = logitech_hidpp +GType = FuLogitechHidPpBootloaderNordic FirmwareSizeMin = 0x4000 CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B InstallDuration = 30 # Texas [DeviceInstanceId=USB\VID_046D&PID_AAAC] -Plugin = unifying -GType = FuUnifyingBootloaderTexas +Plugin = logitech_hidpp +GType = FuLogitechHidPpBootloaderTexas FirmwareSizeMin = 0x4000 CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B InstallDuration = 18 # Texas Pico [DeviceInstanceId=USB\VID_046D&PID_AAAD] -Plugin = unifying -GType = FuUnifyingBootloaderTexas +Plugin = logitech_hidpp +GType = FuLogitechHidPpBootloaderTexas FirmwareSizeMin = 0x4000 CounterpartGuid = HIDRAW\VEN_046D&DEV_C52B InstallDuration = 18 # Possible HID++ v2.0 peripheral device [DeviceInstanceId=HIDRAW\VEN_046D] -Plugin = unifying -GType = FuUnifyingPeripheral +Plugin = logitech_hidpp +GType = FuLogitechHidPpPeripheral diff --git a/plugins/unifying/meson.build b/plugins/logitech-hidpp/meson.build similarity index 54% rename from plugins/unifying/meson.build rename to plugins/logitech-hidpp/meson.build index f90d1fbf3..82b0fc69f 100644 --- a/plugins/unifying/meson.build +++ b/plugins/logitech-hidpp/meson.build @@ -1,24 +1,24 @@ -cargs = ['-DG_LOG_DOMAIN="FuPluginUnifying"'] +cargs = ['-DG_LOG_DOMAIN="FuPluginLogitechHidPp"'] install_data([ - 'unifying.quirk', + 'logitech-hidpp.quirk', ], install_dir: join_paths(datadir, 'fwupd', 'quirks.d') ) -shared_module('fu_plugin_unifying', +shared_module('fu_plugin_logitech_hidpp', fu_hash, sources : [ - 'fu-plugin-unifying.c', - 'fu-unifying-bootloader.c', - 'fu-unifying-bootloader-nordic.c', - 'fu-unifying-bootloader-texas.c', - 'fu-unifying-common.c', - 'fu-unifying-hidpp.c', - 'fu-unifying-hidpp-msg.c', - 'fu-unifying-peripheral.c', - 'fu-unifying-runtime.c', + 'fu-plugin-logitech-hidpp.c', + 'fu-logitech-hidpp-bootloader.c', + 'fu-logitech-hidpp-bootloader-nordic.c', + 'fu-logitech-hidpp-bootloader-texas.c', + 'fu-logitech-hidpp-common.c', + 'fu-logitech-hidpp-hidpp.c', + 'fu-logitech-hidpp-hidpp-msg.c', + 'fu-logitech-hidpp-peripheral.c', + 'fu-logitech-hidpp-runtime.c', ], include_directories : [ include_directories('../..'), @@ -38,11 +38,11 @@ shared_module('fu_plugin_unifying', if get_option('tests') e = executable( - 'unifying-self-test', + 'logitech-hidpp-self-test', fu_hash, sources : [ - 'fu-unifying-self-test.c', - 'fu-unifying-common.c', + 'fu-logitech-hidpp-self-test.c', + 'fu-logitech-hidpp-common.c', ], include_directories : [ include_directories('../..'), @@ -56,5 +56,5 @@ if get_option('tests') ], c_args : cargs, ) - test('unifying-self-test', e) + test('logitech-hidpp-self-test', e) endif diff --git a/plugins/meson.build b/plugins/meson.build index 08b5da311..f759c360d 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -7,6 +7,7 @@ subdir('fastboot') subdir('jabra') subdir('steelseries') subdir('dell-dock') +subdir('logitech-hidpp') subdir('nitrokey') subdir('optionrom') subdir('rts54hid') @@ -16,7 +17,6 @@ subdir('synaptics-cxaudio') subdir('synaptics-prometheus') subdir('test') subdir('thelio-io') -subdir('unifying') subdir('upower') subdir('wacom-raw') subdir('wacom-usb') diff --git a/plugins/unifying/fu-unifying-bootloader-nordic.h b/plugins/unifying/fu-unifying-bootloader-nordic.h deleted file mode 100644 index 8f46a8416..000000000 --- a/plugins/unifying/fu-unifying-bootloader-nordic.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2016-2018 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include "fu-unifying-bootloader.h" - -#define FU_TYPE_UNIFYING_BOOTLOADER_NORDIC (fu_unifying_bootloader_nordic_get_type ()) -G_DECLARE_FINAL_TYPE (FuUnifyingBootloaderNordic, fu_unifying_bootloader_nordic, FU, UNIFYING_BOOTLOADER_NORDIC, FuUnifyingBootloader) diff --git a/plugins/unifying/fu-unifying-bootloader-texas.h b/plugins/unifying/fu-unifying-bootloader-texas.h deleted file mode 100644 index ecfba14a9..000000000 --- a/plugins/unifying/fu-unifying-bootloader-texas.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2016-2018 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include "fu-unifying-bootloader.h" - -#define FU_TYPE_UNIFYING_BOOTLOADER_TEXAS (fu_unifying_bootloader_texas_get_type ()) -G_DECLARE_FINAL_TYPE (FuUnifyingBootloaderTexas, fu_unifying_bootloader_texas, FU, UNIFYING_BOOTLOADER_TEXAS, FuUnifyingBootloader) diff --git a/plugins/unifying/fu-unifying-hidpp-msg.h b/plugins/unifying/fu-unifying-hidpp-msg.h deleted file mode 100644 index 2a098d0c1..000000000 --- a/plugins/unifying/fu-unifying-hidpp-msg.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2017-2018 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include - -typedef enum { - FU_UNIFYING_HIDPP_MSG_FLAG_NONE, - FU_UNIFYING_HIDPP_MSG_FLAG_LONGER_TIMEOUT = 1 << 0, - FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SUB_ID = 1 << 1, - FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_FNCT_ID = 1 << 2, - FU_UNIFYING_HIDPP_MSG_FLAG_IGNORE_SWID = 1 << 3, - /*< private >*/ - FU_UNIFYING_HIDPP_MSG_FLAG_LAST -} FuUnifyingHidppMsgFlags; - -typedef struct __attribute__((packed)) { - guint8 report_id; - guint8 device_id; - guint8 sub_id; - guint8 function_id; /* funcId:software_id */ - guint8 data[47]; /* maximum supported by Windows XP SP2 */ - /* not included in the packet sent to the hardware */ - guint32 flags; - guint8 hidpp_version; -} FuUnifyingHidppMsg; - -/* this is specific to fwupd */ -#define FU_UNIFYING_HIDPP_MSG_SW_ID 0x07 - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-function" -G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuUnifyingHidppMsg, g_free); -#pragma clang diagnostic pop - -FuUnifyingHidppMsg *fu_unifying_hidpp_msg_new (void); -void fu_unifying_hidpp_msg_copy (FuUnifyingHidppMsg *msg_dst, - const FuUnifyingHidppMsg *msg_src); -gsize fu_unifying_hidpp_msg_get_payload_length (FuUnifyingHidppMsg *msg); -gboolean fu_unifying_hidpp_msg_is_reply (FuUnifyingHidppMsg *msg1, - FuUnifyingHidppMsg *msg2); -gboolean fu_unifying_hidpp_msg_is_hidpp10_compat (FuUnifyingHidppMsg *msg); -gboolean fu_unifying_hidpp_msg_is_error (FuUnifyingHidppMsg *msg, - GError **error); -gboolean fu_unifying_hidpp_msg_verify_swid (FuUnifyingHidppMsg *msg); - -const gchar *fu_unifying_hidpp_msg_dev_id_to_string (FuUnifyingHidppMsg *msg); -const gchar *fu_unifying_hidpp_msg_rpt_id_to_string (FuUnifyingHidppMsg *msg); -const gchar *fu_unifying_hidpp_msg_sub_id_to_string (FuUnifyingHidppMsg *msg); -const gchar *fu_unifying_hidpp_msg_fcn_id_to_string (FuUnifyingHidppMsg *msg); diff --git a/plugins/unifying/fu-unifying-peripheral.h b/plugins/unifying/fu-unifying-peripheral.h deleted file mode 100644 index 36b0bfff8..000000000 --- a/plugins/unifying/fu-unifying-peripheral.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2017-2018 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include "fu-udev-device.h" - -#define FU_TYPE_UNIFYING_PERIPHERAL (fu_unifying_peripheral_get_type ()) -G_DECLARE_FINAL_TYPE (FuUnifyingPeripheral, fu_unifying_peripheral, FU, UNIFYING_PERIPHERAL, FuUdevDevice) diff --git a/plugins/unifying/fu-unifying-runtime.h b/plugins/unifying/fu-unifying-runtime.h deleted file mode 100644 index 3b5332c87..000000000 --- a/plugins/unifying/fu-unifying-runtime.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2016-2018 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include "fu-udev-device.h" - -#define FU_TYPE_UNIFYING_RUNTIME (fu_unifying_runtime_get_type ()) -G_DECLARE_FINAL_TYPE (FuUnifyingRuntime, fu_unifying_runtime, FU, UNIFYING_RUNTIME, FuUdevDevice)